2023-09-17 22:13:42 +03:00
|
|
|
package GlobalData.Tasks.QueueSystem;
|
2024-10-07 14:22:52 +03:00
|
|
|
import Common.Utils.CommonUtils;
|
2023-09-17 22:13:42 +03:00
|
|
|
import GlobalData.Tasks.Task;
|
|
|
|
|
import GlobalData.Tasks.TaskState;
|
|
|
|
|
public class QueueSystem {
|
|
|
|
|
public String check_command;
|
|
|
|
|
public String cancel_command;
|
|
|
|
|
public String refuse;
|
|
|
|
|
QueueCommand[] commands;
|
|
|
|
|
public void checkTask(String Output, Task task) {
|
|
|
|
|
for (QueueCommand command : commands)
|
|
|
|
|
if (command.check(Output)) {
|
|
|
|
|
task.state = command.state;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void enqueueTask(String Output, Task task) {
|
|
|
|
|
if (Output.equalsIgnoreCase(refuse))
|
|
|
|
|
task.state = TaskState.FailedToQueue;
|
|
|
|
|
else
|
|
|
|
|
for (QueueCommand command : commands) {
|
|
|
|
|
String c_res = command.check_and_get_param(Output);
|
|
|
|
|
if (c_res != null) {
|
|
|
|
|
task.PID = c_res.replace("\"", "").replace("'", "");
|
|
|
|
|
task.state = command.state;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public String getCheckTaskCommand(Task task) {
|
2024-10-07 14:22:52 +03:00
|
|
|
return check_command + " " + CommonUtils.DQuotes(task.PID);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
public String getCancelTaskCommand(Task task) {
|
2024-10-07 14:22:52 +03:00
|
|
|
return cancel_command + " " + CommonUtils.DQuotes(task.PID);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|