no message

This commit is contained in:
2024-10-09 22:21:57 +03:00
parent 54c80c516b
commit 6252af944e
699 changed files with 2634 additions and 1997 deletions

View File

@@ -0,0 +1,131 @@
package _VisualDVM.GlobalData.Tasks;
import Common.CommonConstants;
import Common.Utils.CommonUtils;
import _VisualDVM.Constants;
import Common.Database.Objects.iDBObject;
import _VisualDVM.Utils;
import _VisualDVM.GlobalData.Machine.Machine;
import _VisualDVM.GlobalData.User.User;
import _VisualDVM.ProjectData.Project.db_project_info;
import com.sun.org.glassfish.gmbal.Description;
import java.io.File;
import java.nio.file.Paths;
import java.util.Date;
public abstract class Task extends iDBObject {
//<editor-fold desc="файловые константы">
//</editor-fold>
public TaskState state = TaskState.Inactive;
//----------------------------------
public int machine_id = CommonConstants.Nan;
public int user_id = CommonConstants.Nan;
//-----------------------------------
public String PID = "";
public String project_path;// путь к проекту.
public String project_description; // краткое описание(чтобы не лезть в бд целевого проекта). только для таблицы.
public int maxtime = 40;
//результаты-------------------------------
public double Time; //время выполнения.
public long StartDate = 0; //дата начала выполнения
public long EndDate = 0;//дата окончания выполнения
//---------------------------------
@Description("IGNORE")
public int progressStep = CommonConstants.Nan;
@Description("IGNORE")
public int progressAll = CommonConstants.Nan;
public boolean belongsToProject(db_project_info project) {
return this.project_path.equalsIgnoreCase(project.Home.getAbsolutePath());
}
public void DropResults() throws Exception {
Utils.forceDeleteWithCheck(getOutputFile());
Utils.forceDeleteWithCheck(getErrorsFile());
//-
StartDate = 0;
EndDate = 0;
Time = 0;
state = TaskState.Inactive;
CommonUtils.db.Update(this);
}
//</editor-fold>
//<editor-fold desc="локальные файлы">
public abstract File getHome();
public File getLocalWorkspace() {
return Paths.get(getHome().getAbsolutePath(), String.valueOf(id)).toFile();
}
public File getOutputFile() {
return Paths.get(getLocalWorkspace().getAbsolutePath(), Constants.out_file).toFile();
}
public File getErrorsFile() {
return Paths.get(getLocalWorkspace().getAbsolutePath(), Constants.err_file).toFile();
}
public File getTimeFile() {
return Paths.get(getLocalWorkspace().getAbsolutePath(), Constants.time_file).toFile();
}
public abstract String getFullCommand();
public Date getEndDate() {
return new Date(EndDate);
}
public Machine getMachine() {
return CommonUtils.db.getById(Machine.class, machine_id);
}
public User getUser() {
return CommonUtils.db.getById(User.class, user_id);
}
protected String getTextResult(File file) {
return (file.exists()) ? Utils.ReadAllText(file) : "файл не найден. Задача еще не выполнялась или была завершена некорректно";
}
//подразумевается, что выходные потоки задачи видны только при открытом проекте
public String getOutput() {
return getTextResult(getOutputFile());
}
public String getErrors() {
return getTextResult(getErrorsFile());
}
public void RefreshTime() {
Time = Double.parseDouble(Utils.ReadAllText(getTimeFile()));
}
public void MaximizeTime() {
Time = maxtime + 1;
}
public void UpdateState(TaskState state_in) {
if (state != state_in) {
state = state_in;
try {
CommonUtils.db.Update(this);
} catch (Exception ex) {
CommonUtils.MainLog.PrintException(ex);
}
}
}
public void Reset() {
PID = "";
StartDate = 0;
EndDate = 0;
state = TaskState.Inactive;
}
public void setProgress(int progressStep_in, int progressAll_in) {
progressStep = progressStep_in;
progressAll = progressAll_in;
}
public void dropProgress() {
progressStep = CommonConstants.Nan;
progressAll = CommonConstants.Nan;
}
public boolean hasProgress() {
return (progressStep != CommonConstants.Nan) && (progressAll != CommonConstants.Nan);
}
//---------------------------------
public void AnalyzeResultsTexts(db_project_info project) throws Exception {
state = TaskState.Done;
AnalyzeOutFile(project);
AnalyzeErrorsFile(project);
}
public void AnalyzeOutFile(db_project_info project) throws Exception {
}
public void AnalyzeErrorsFile(db_project_info project) throws Exception {
}
public boolean isPassive() {
return (state != TaskState.Queued) && (state != TaskState.Running);
}
}