Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions bin/main/com/company/commitet_jm/sheduledJob/Committer.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.company.commitet_jm.sheduledJob

import com.company.commitet_jm.service.GitWorker
import com.company.commitet_jm.service.git.GitServiceImpl
import io.jmix.core.DataManager
import io.jmix.core.FileStorageLocator
import io.jmix.core.security.SystemAuthenticator
Expand All @@ -20,11 +21,16 @@ class Committer(private val dataManager: DataManager): Job {

override fun execute(context: JobExecutionContext) {
systemAuthenticator?.runWithSystem {
val gitWorker = GitWorker(
val gitSrv = GitServiceImpl(
dataManager = dataManager,
fileStorageLocator = fileStorageLocator,
)
gitWorker.createCommit()
gitSrv.createCommit()
// val gitWorker = GitWorker(
// dataManager = dataManager,
// fileStorageLocator = fileStorageLocator,
// )
// gitWorker.createCommit()
}


Expand Down
16 changes: 9 additions & 7 deletions src/main/kotlin/com/company/commitet_jm/service/GitWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GitWorker(
}

fun createCommit() {

log.info("screateCommit from GitWorker")
val commitInfo = firstNewDataCommit() ?: return

log.info("start createCommit ${commitInfo.taskNum}")
Expand All @@ -63,14 +63,16 @@ class GitWorker(

try {

// if (repoDir != null) {
// beforeCmdCommit(repoDir, remoteBranch!!,newBranch, commitInfo)
// }else{
// throw RuntimeException("$repoDir not exist!!!")
// }
if (repoDir != null) {
beforeCmdCommit(repoDir, remoteBranch!!,newBranch, commitInfo)
}else{
throw RuntimeException("$repoDir not exist!!!")
}

commitInfo.project?.platform?.let { saveFileCommit(repoPath, commitInfo.files, it) }
// afterCmdCommit(commitInfo, repoDir, newBranch)

afterCmdCommit(commitInfo, repoDir, newBranch)

} catch (e: Exception) {
log.error("Error occurred while creating commit ${e.message}")
commitInfo.errorInfo = e.message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class FileServiceImpl(
}
file.getType()?.let { fileType ->
val unpackPath = when (fileType) {
TypesFiles.REPORT -> "$baseDir\\DataProcessorsExt\\erf"
TypesFiles.DATAPROCESSOR -> "$baseDir\\DataProcessorsExt\\epf"
TypesFiles.REPORT -> "$baseDir${File.separator}DataProcessorsExt${File.separator}erf"
TypesFiles.DATAPROCESSOR -> "$baseDir${File.separator}DataProcessorsExt${File.separator}epf"
else -> null
}
unpackPath?.let {
Expand All @@ -69,8 +69,8 @@ class FileServiceImpl(

override fun correctPath(baseDir: String, type: TypesFiles): File {
return when (type) {
TypesFiles.REPORT -> File(baseDir, "DataProcessorsExt\\Отчет\\")
TypesFiles.DATAPROCESSOR -> File(baseDir, "DataProcessorsExt\\Обработка\\")
TypesFiles.REPORT -> File(baseDir, "DataProcessorsExt${File.separator}Отчет${File.separator}")
TypesFiles.DATAPROCESSOR -> File(baseDir, "DataProcessorsExt${File.separator}Обработка${File.separator}")
TypesFiles.SCHEDULEDJOBS -> File(baseDir, "CodeExt")
TypesFiles.EXTERNAL_CODE -> File(baseDir, "CodeExt")
TypesFiles.EXCHANGE_RULES -> File(baseDir, "EXCHANGE_RULES")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class GitServiceImpl(
if (e.message?.contains("index.lock") == true) {
log.info("Обнаружена блокировка Git. Удаление index.lock...")

val lockFile = File("$repoDir/.git/index.lock")
val lockFile = File("$repoDir${File.separator}.git${File.separator}index.lock")
if (lockFile.exists()) {
lockFile.delete()
log.info("Файл index.lock удалён. Повторная попытка...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.company.commitet_jm.entity.Platform
import com.company.commitet_jm.view.onecstorage.HistoryOptions
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.io.File
import java.io.IOException
import java.nio.file.AccessDeniedException
import java.nio.file.Files
Expand Down Expand Up @@ -36,7 +37,7 @@ class OneCStorageService(

private fun prepareStorageDirectory(storage: OneCStorage): Path {
val path = Paths.get(
storage.project?.tempBasePath ?: "./temp",
storage.project?.tempBasePath ?: ".${File.separator}temp",
storage.name
)

Expand Down
69 changes: 44 additions & 25 deletions src/main/kotlin/com/company/commitet_jm/service/ones/OneRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import com.company.commitet_jm.component.ShellExecutor
import com.company.commitet_jm.entity.AppSettings
import com.company.commitet_jm.service.unpack.UnpackService
import io.jmix.core.DataManager
import org.apache.commons.compress.java.util.jar.Pack200
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.text.SimpleDateFormat
import java.util.Date

import java.io.File

Expand All @@ -21,41 +22,59 @@ class OneRunner(private val dataManager: DataManager
@Autowired
private lateinit var shellExecutor: ShellExecutor

var v8unpackPath : String = ""
var v8unpackPath : String = ""

fun uploadExtFiles(inputFile: File, outDir: String,pathInstall: String, version: String ) {
log.debug("2 Подготовка выгрузка файлов ")
// Имя файла без расширения
val fileNameWithoutExt = inputFile.nameWithoutExtension

// Итоговый каталог: outDir/<имя_файла_без_расширения>
val targetDir = File(outDir, fileNameWithoutExt)

// Создаём каталог, если его нет
if (!targetDir.exists()) {
targetDir.mkdirs()
}
// Формат времени для имени лог-файла
val timeStamp = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Date())
val logFileName = "OneLog${File.separator}out_$timeStamp.log"

val res = shellExecutor.executeCommand(listOf(
pathPlatform(pathInstall, version),
"DESIGNER",
"/DisableStartupDialogs",
"/DumpExternalDataProcessorOrReportToFiles",
"\"$outDir\"",
"\"${inputFile.path}\""
"${targetDir.path}${File.separator}",
"${inputFile.path}${File.separator}",
"/Out",
logFileName
))
log.debug("Строка запуска $res")
log.debug("2 Строка запуска $res")
}

fun unpackExtFiles(inputFile: File, outDir: String){
var unpackEnabled = false
if (unpackEnabled) {
if (v8unpackPath.isEmpty()){
val unpackPath = dataManager.load(AppSettings::class.java)
.query("select apps from AppSettings apps where apps.name = :pName")
.parameter("pName", "v8unpack")
.optional().get()
v8unpackPath = unpackPath.value.toString()
}

val res = shellExecutor.executeCommand(listOf(
v8unpackPath,
"-U",
inputFile.path,
outDir
))
}else{
val unp = UnpackService()
unp.unpackToDirectory(inputFile.path, outDir)
}

// if (v8unpackPath.isEmpty()){
// val unpackPath = dataManager.load(AppSettings::class.java)
// .query("select apps from AppSettings apps where apps.name = :pName")
// .parameter("pName", "v8unpack")
// .optional().get()
//
//
// v8unpackPath = unpackPath.value.toString()
// }
val unp = UnpackService()
unp.unpackToDirectory(inputFile.path, outDir)

// val res = shellExecutor.executeCommand(listOf(
// v8unpackPath,
// "-U",
// inputFile.path,
// outDir
//
// ))

log.info("unpack rename files")

Expand All @@ -72,7 +91,7 @@ class OneRunner(private val dataManager: DataManager
}
)
log.debug("hand made unpack")
//log.debug("Unpack command $res")

}

fun pathPlatform(basePath: String?, version: String?):String{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ class Committer(

override fun execute(context: JobExecutionContext) {
systemAuthenticator.runWithSystem {
val gitWorker = GitWorker(
dataManager = dataManager,
fileStorageLocator = fileStorageLocator,
ones = oneRunner,
)
gitWorker.createCommit()
systemAuthenticator?.runWithSystem {
systemAuthenticator.runWithSystem {
gitService.createCommit()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.company.commitet_jm.view.commit

import com.company.commitet_jm.entity.*
import com.company.commitet_jm.service.GitWorker
import com.company.commitet_jm.service.git.GitService
import com.company.commitet_jm.service.ones.OneRunner
import com.company.commitet_jm.view.main.MainView
import com.vaadin.flow.component.ClickEvent
import com.vaadin.flow.component.button.Button
Expand All @@ -27,6 +29,8 @@ import org.springframework.beans.factory.annotation.Autowired
@ViewDescriptor(path = "commit-detail-view.xml")
@EditedEntityContainer("commitDc")
class CommitDetailView : StandardDetailView<Commit>() {
@Autowired
private lateinit var oneRunner: OneRunner

@Autowired
private lateinit var timeSource: TimeSource
Expand Down Expand Up @@ -143,6 +147,12 @@ class CommitDetailView : StandardDetailView<Commit>() {

@Subscribe(id = "uploadFilesButton", subject = "clickListener")
private fun onUploadFilesButtonCommitClick(event: ClickEvent<JmixButton>) {
// val gitWorker = GitWorker(
// dataManager = dataManager,
// fileStorageLocator = fileStorageLocator,
// ones = oneRunner,
// )
// gitWorker.createCommit()
gitService.createCommit()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@

<formLayout id="form" dataContainer="commitDc" >
<vbox width="100%" alignSelf="STRETCH">
<hbox>
<textField id="taskNumField" property="taskNum" label="Номер задачи" required="true"/>
<textField id="statusField" property="status" label="Статус"/>
</hbox>

<tabSheet width="100%" alignSelf="STRETCH">
<tab id="info" label="Описание">
<vbox width="100%">
<hbox>
<textField id="taskNumField" property="taskNum" label="Номер задачи" required="true"/>
<textField id="statusField" property="status" label="Статус"/>
<button id="clearStatusCommit" text="В новый" icon="COFFEE" alignSelf="END" themeNames="danger" visible="false"/>
<textField property="dateCreated" label="Дата создания" readOnly="true"/>
</hbox>
<entityPicker id="projectField" width="100%" property="project" label="Проект" required="true">
<actions>
<action id="entityLookupAction" type="entity_lookup">
Expand All @@ -59,10 +62,8 @@
</tab>
<tab id="commit_value" label="Комментарии">
<vbox>
<textField property="dateCreated" label="Дата создания"/>
<button id="uploadFilesButton" text="Выгрузкить в файлы" visible="false"/>
<button id="startAnalyzeButton" text="Анализировать файлы" visible="false"/>
<button id="clearStatusCommit" text="Сбросить статус" icon="COFFEE" themeNames="danger" visible="false"/>
<button id="uploadFilesButton" text="Выгрузить в файлы" visible="false"/>
<button id="startAnalyzeButton" text="Анализировать файлы(todo)" visible="false"/>
</vbox>

</tab>
Expand Down
Loading