Search in sources :

Example 1 with Activity

use of org.cristalise.kernel.lifecycle.instance.Activity in project kernel by cristal-ise.

the class ItemImplementation method handleError.

/**
 * @param agentId
 * @param delegateId
 * @param stepPath
 * @param ex
 * @return
 * @throws PersistencyException
 * @throws ObjectNotFoundException
 * @throws AccessRightsException
 * @throws InvalidTransitionException
 * @throws InvalidDataException
 * @throws ObjectAlreadyExistsException
 * @throws InvalidCollectionModification
 */
private String handleError(SystemKey agentId, SystemKey delegateId, String stepPath, Workflow lifeCycle, Exception ex) throws PersistencyException, ObjectNotFoundException, AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException, InvalidCollectionModification {
    if (!Gateway.getProperties().getBoolean("StateMachine.enableErrorHandling", false))
        return null;
    int errorTransId = ((Activity) lifeCycle.search(stepPath)).getErrorTransitionId();
    if (errorTransId == -1)
        return null;
    try {
        AgentPath agent = new AgentPath(agentId);
        AgentPath delegate = delegateId == null ? null : new AgentPath(delegateId);
        String errorOutcome = Gateway.getMarshaller().marshall(new ErrorInfo(ex));
        lifeCycle.requestAction(agent, delegate, stepPath, mItemPath, errorTransId, errorOutcome);
        if (!(stepPath.startsWith("workflow/predefined")))
            mStorage.put(mItemPath, lifeCycle, lifeCycle);
        return errorOutcome;
    } catch (InvalidAgentPathException | ObjectCannotBeUpdated | CannotManageException | MarshalException | ValidationException | IOException | MappingException e) {
        Logger.error(e);
        return "";
    }
}
Also used : MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) CannotManageException(org.cristalise.kernel.common.CannotManageException) AgentPath(org.cristalise.kernel.lookup.AgentPath) ErrorInfo(org.cristalise.kernel.scripting.ErrorInfo) Activity(org.cristalise.kernel.lifecycle.instance.Activity) CompositeActivity(org.cristalise.kernel.lifecycle.instance.CompositeActivity) IOException(java.io.IOException) Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint) MappingException(org.exolab.castor.mapping.MappingException) ObjectCannotBeUpdated(org.cristalise.kernel.common.ObjectCannotBeUpdated) InvalidAgentPathException(org.cristalise.kernel.lookup.InvalidAgentPathException)

Example 2 with Activity

use of org.cristalise.kernel.lifecycle.instance.Activity in project kernel by cristal-ise.

the class ActivitySlotDef method instantiate.

@Override
public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException {
    Activity newActivity = (Activity) getTheActivityDef().instantiate();
    configureInstance(newActivity);
    if (newActivity.getProperties().getAbstract().size() > 0) {
        throw new InvalidDataException("Abstract properties not overridden: " + newActivity.getProperties().getAbstract().toString());
    }
    return newActivity;
}
Also used : InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Activity(org.cristalise.kernel.lifecycle.instance.Activity)

Example 3 with Activity

use of org.cristalise.kernel.lifecycle.instance.Activity in project kernel by cristal-ise.

the class PredefinedStep method getPredefStepSchemaName.

public static String getPredefStepSchemaName(String stepName) {
    PredefinedStepContainer[] allSteps = { new ItemPredefinedStepContainer(), new AgentPredefinedStepContainer(), new ServerPredefinedStepContainer() };
    for (PredefinedStepContainer thisContainer : allSteps) {
        String stepPath = thisContainer.getName() + "/" + stepName;
        Activity step = (Activity) thisContainer.search(stepPath);
        if (step != null) {
            return (String) step.getBuiltInProperty(SCHEMA_NAME);
        }
    }
    // default to standard if not found - server may be a newer version
    return "PredefinedStepOutcome";
}
Also used : ItemPredefinedStepContainer(org.cristalise.kernel.lifecycle.instance.predefined.item.ItemPredefinedStepContainer) ServerPredefinedStepContainer(org.cristalise.kernel.lifecycle.instance.predefined.server.ServerPredefinedStepContainer) ItemPredefinedStepContainer(org.cristalise.kernel.lifecycle.instance.predefined.item.ItemPredefinedStepContainer) AgentPredefinedStepContainer(org.cristalise.kernel.lifecycle.instance.predefined.agent.AgentPredefinedStepContainer) Activity(org.cristalise.kernel.lifecycle.instance.Activity) AgentPredefinedStepContainer(org.cristalise.kernel.lifecycle.instance.predefined.agent.AgentPredefinedStepContainer) ServerPredefinedStepContainer(org.cristalise.kernel.lifecycle.instance.predefined.server.ServerPredefinedStepContainer)

Example 4 with Activity

use of org.cristalise.kernel.lifecycle.instance.Activity in project kernel by cristal-ise.

the class GraphableVertex method updatePropertiesFromCollection.

public void updatePropertiesFromCollection(BuiltInVertexProperties vertexProp, CastorHashMap newProps) throws InvalidDataException {
    switch(vertexProp) {
        case ACTIVITY_DEF_URN:
            if (this instanceof Activity) {
                Object value = null;
                Activity thisAct = (Activity) this;
                if (newProps.containsKey(thisAct.getID()))
                    value = newProps.get(thisAct.getID());
                else if (newProps.containsKey(thisAct.getTypeName()))
                    value = newProps.get(thisAct.getTypeName());
                if (value != null) {
                    Logger.msg(5, "GraphableVertex.updatePropertiesFromCollection(" + vertexProp + ") - UPDATING typeName:" + thisAct.getTypeName() + " id:" + thisAct.getID());
                    mProperties.setBuiltInProperty(ACTIVITY_DEF_URN, value);
                } else
                    Logger.msg(5, "GraphableVertex.updatePropertiesFromCollection(" + vertexProp + ") - SKIPPING typeName:" + thisAct.getTypeName() + " id:" + thisAct.getID());
            }
            break;
        default:
            throw new InvalidDataException("Cannot handle BuiltInVertexProperty:" + vertexProp);
    }
}
Also used : InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Activity(org.cristalise.kernel.lifecycle.instance.Activity)

Example 5 with Activity

use of org.cristalise.kernel.lifecycle.instance.Activity in project kernel by cristal-ise.

the class LifecycleVertexOutlineCreator method setOutline.

@Override
public void setOutline(Vertex vertex) {
    GraphPoint centrePoint = vertex.getCentrePoint();
    GraphPoint[] outlinePoints = new GraphPoint[4];
    int vertexWidth = 0;
    int vertexHeight = 0;
    if (vertex instanceof Activity || vertex instanceof ActivitySlotDef || vertex instanceof ActivityDef) {
        vertexWidth = mActivityWidth;
        vertexHeight = mActivityHeight;
    } else {
        vertexWidth = mSplitJoinWidth;
        vertexHeight = mSplitJoinHeight;
    }
    outlinePoints[0] = new GraphPoint(centrePoint.x - vertexWidth / 2, centrePoint.y - vertexHeight / 2);
    outlinePoints[1] = new GraphPoint(centrePoint.x + vertexWidth / 2, centrePoint.y - vertexHeight / 2);
    outlinePoints[2] = new GraphPoint(centrePoint.x + vertexWidth / 2, centrePoint.y + vertexHeight / 2);
    outlinePoints[3] = new GraphPoint(centrePoint.x - vertexWidth / 2, centrePoint.y + vertexHeight / 2);
    vertex.setOutlinePoints(outlinePoints);
}
Also used : GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) Activity(org.cristalise.kernel.lifecycle.instance.Activity) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Aggregations

Activity (org.cristalise.kernel.lifecycle.instance.Activity)7 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CannotManageException (org.cristalise.kernel.common.CannotManageException)1 ObjectCannotBeUpdated (org.cristalise.kernel.common.ObjectCannotBeUpdated)1 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)1 CompositeActivity (org.cristalise.kernel.lifecycle.instance.CompositeActivity)1 AgentPredefinedStepContainer (org.cristalise.kernel.lifecycle.instance.predefined.agent.AgentPredefinedStepContainer)1 ItemPredefinedStepContainer (org.cristalise.kernel.lifecycle.instance.predefined.item.ItemPredefinedStepContainer)1 ServerPredefinedStepContainer (org.cristalise.kernel.lifecycle.instance.predefined.server.ServerPredefinedStepContainer)1 AgentPath (org.cristalise.kernel.lookup.AgentPath)1 InvalidAgentPathException (org.cristalise.kernel.lookup.InvalidAgentPathException)1 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)1 ErrorInfo (org.cristalise.kernel.scripting.ErrorInfo)1 MappingException (org.exolab.castor.mapping.MappingException)1 MarshalException (org.exolab.castor.xml.MarshalException)1 ValidationException (org.exolab.castor.xml.ValidationException)1