Search in sources :

Example 1 with OutcomeInitiator

use of org.cristalise.kernel.persistency.outcome.OutcomeInitiator in project kernel by cristal-ise.

the class Job method getOutcome.

/**
 * Returns the Outcome if exists otherwise tries to read and duplicate the Outcome of 'last' ViewPoint.
 * If that does not exists it tries to use an OutcomeInitiator.
 *
 * @return the Outcome object or null
 * @throws InvalidDataException inconsistent data
 * @throws ObjectNotFoundException Schema was not found
 */
public Outcome getOutcome() throws InvalidDataException, ObjectNotFoundException {
    if (outcome == null && transition.hasOutcome(actProps)) {
        if (getItem().checkViewpoint(getSchema().getName(), getValidViewpointName())) {
            Outcome tempOutcome = getLastOutcome();
            outcome = new Outcome(tempOutcome.getData(), tempOutcome.getSchema());
        } else {
            OutcomeInitiator ocInit = getOutcomeInitiator();
            if (ocInit != null)
                outcome = ocInit.initOutcomeInstance(this);
        }
    } else {
        Logger.msg(8, "Job.getOutcome() - Job does not require Outcome job:" + this);
    }
    return outcome;
}
Also used : Outcome(org.cristalise.kernel.persistency.outcome.Outcome) OutcomeInitiator(org.cristalise.kernel.persistency.outcome.OutcomeInitiator)

Example 2 with OutcomeInitiator

use of org.cristalise.kernel.persistency.outcome.OutcomeInitiator in project kernel by cristal-ise.

the class Job method getOutcomeInitiator.

/**
 * Retrieve the OutcomeInitiator associated with this Job.
 *
 * @see BuiltInVertexProperties#OUTCOME_INIT
 *
 * @return the configured OutcomeInitiator
 * @throws InvalidDataException OutcomeInitiator could not be created
 */
public OutcomeInitiator getOutcomeInitiator() throws InvalidDataException {
    String ocInitName = getActPropString(OUTCOME_INIT);
    if (StringUtils.isNotBlank(ocInitName)) {
        String ocConfigPropName = OUTCOME_INIT.getName() + "." + ocInitName;
        OutcomeInitiator ocInit;
        synchronized (ocInitCache) {
            Logger.msg(5, "Job.getOutcomeInitiator() - ocConfigPropName:" + ocConfigPropName);
            ocInit = ocInitCache.get(ocConfigPropName);
            if (ocInit == null) {
                if (!Gateway.getProperties().containsKey(ocConfigPropName)) {
                    throw new InvalidDataException("Property OutcomeInstantiator " + ocConfigPropName + " isn't defined. Check module.xml");
                }
                try {
                    ocInit = (OutcomeInitiator) Gateway.getProperties().getInstance(ocConfigPropName);
                    ocInitCache.put(ocConfigPropName, ocInit);
                } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
                    Logger.error(e);
                    throw new InvalidDataException("OutcomeInstantiator " + ocConfigPropName + " couldn't be instantiated:" + e.getMessage());
                }
            }
        }
        return ocInit;
    } else
        return null;
}
Also used : InvalidDataException(org.cristalise.kernel.common.InvalidDataException) OutcomeInitiator(org.cristalise.kernel.persistency.outcome.OutcomeInitiator)

Aggregations

OutcomeInitiator (org.cristalise.kernel.persistency.outcome.OutcomeInitiator)2 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)1