Search in sources :

Example 1 with Job

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;
}
Also used : C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) Job(org.cristalise.kernel.entity.agent.Job)

Example 2 with Job

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;
}
Also used : C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) Job(org.cristalise.kernel.entity.agent.Job)

Example 3 with Job

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;
}
Also used : ArrayList(java.util.ArrayList) Transition(org.cristalise.kernel.lifecycle.instance.stateMachine.Transition) Job(org.cristalise.kernel.entity.agent.Job)

Example 4 with Job

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;
}
Also used : ArrayList(java.util.ArrayList) Job(org.cristalise.kernel.entity.agent.Job) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 5 with Job

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;
}
Also used : Job(org.cristalise.kernel.entity.agent.Job)

Aggregations

Job (org.cristalise.kernel.entity.agent.Job)7 ArrayList (java.util.ArrayList)2 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)2 AccessRightsException (org.cristalise.kernel.common.AccessRightsException)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 InvalidTransitionException (org.cristalise.kernel.common.InvalidTransitionException)1 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 PersistencyException (org.cristalise.kernel.common.PersistencyException)1 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)1 Transition (org.cristalise.kernel.lifecycle.instance.stateMachine.Transition)1 ScriptErrorException (org.cristalise.kernel.scripting.ScriptErrorException)1