use of org.cristalise.kernel.entity.agent.Job in project kernel by cristal-ise.
the class UserCodeProcess method getJob.
/**
* @param jobs
* @param transition
* @return
*/
private static Job getJob(HashMap<String, C2KLocalObject> jobs, int transition) {
for (C2KLocalObject c2kLocalObject : jobs.values()) {
Job thisJob = (Job) c2kLocalObject;
if (thisJob.getTransition().getId() == transition) {
Logger.msg(1, "=================================================================");
Logger.msg(5, "UserCodeProcess.getJob() - job:" + thisJob);
return thisJob;
}
}
return null;
}
use of org.cristalise.kernel.entity.agent.Job in project kernel by cristal-ise.
the class UserCodeProcess method getErrorJob.
/**
* @param completeJob
* @param errorTrans
* @return
*/
private Job getErrorJob(Job completeJob, int errorTrans) {
Job errorJob = null;
synchronized (jobs) {
for (C2KLocalObject c2kLocalObject : jobs.values()) {
Job thisJob = (Job) c2kLocalObject;
if (thisJob.getItemUUID().equals(completeJob.getItemUUID()) && thisJob.getTransition().getId() == errorTrans) {
Logger.msg(5, "UserCodeProcess.getErrorJob() - job:" + thisJob);
errorJob = thisJob;
}
}
}
return errorJob;
}
use of org.cristalise.kernel.entity.agent.Job in project kernel by cristal-ise.
the class Activity method calculateJobsBase.
private ArrayList<Job> calculateJobsBase(AgentPath agent, ItemPath itemPath, boolean includeInactive) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException {
Logger.msg(7, "Activity.calculateJobsBase() - act:" + getPath());
ArrayList<Job> jobs = new ArrayList<Job>();
Map<Transition, String> transitions;
if ((includeInactive || getActive()) && !getName().equals("domain")) {
transitions = getStateMachine().getPossibleTransitions(this, agent);
Logger.msg(7, "Activity.calculateJobsBase() - Got " + transitions.size() + " transitions.");
for (Transition transition : transitions.keySet()) {
Logger.msg(7, "Activity.calculateJobsBase() - Creating Job object for transition " + transition.getName());
jobs.add(new Job(this, itemPath, transition, agent, null, transitions.get(transition)));
}
}
return jobs;
}
use of org.cristalise.kernel.entity.agent.Job in project kernel by cristal-ise.
the class CompositeActivity method calculateJobs.
/**
*/
@Override
public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws InvalidAgentPathException, ObjectNotFoundException, InvalidDataException {
ArrayList<Job> jobs = new ArrayList<Job>();
boolean childActive = false;
if (recurse) {
for (int i = 0; i < getChildren().length; i++) {
if (getChildren()[i] instanceof Activity) {
Activity child = (Activity) getChildren()[i];
jobs.addAll(child.calculateJobs(agent, itemPath, recurse));
childActive |= child.active;
}
}
}
if (!childActive)
jobs.addAll(super.calculateJobs(agent, itemPath, recurse));
return jobs;
}
use of org.cristalise.kernel.entity.agent.Job in project kernel by cristal-ise.
the class UserCodeProcess method getActualJob.
/**
* Gets the next possible Job based on the Transitions of the Default StateMachine
*
* @return the actual Job
*/
protected Job getActualJob() {
Job thisJob = null;
synchronized (jobs) {
if (jobs.size() > 0) {
thisJob = getJob(jobs, COMPLETE);
if (thisJob == null)
thisJob = getJob(jobs, START);
if (thisJob == null) {
Logger.error("No supported jobs, but joblist is not empty! Discarding remaining jobs");
jobs.clear();
} else {
jobs.remove(ClusterStorage.getPath(thisJob));
}
}
}
return thisJob;
}
Aggregations