Search in sources :

Example 6 with GraphableVertex

use of org.cristalise.kernel.graph.model.GraphableVertex in project kernel by cristal-ise.

the class ActivityDataHelper method get.

/**
 * Retrieves the Workflow of the given Item, searches the Activity using the activity path and
 * retrieves a single value based on XPath
 */
@Override
public String get(ItemPath itemPath, String actContext, String dataPath, Object locker) throws InvalidDataException, PersistencyException, ObjectNotFoundException {
    Logger.msg(5, "ActivityDataHelper.get() - item:" + itemPath + ", actContext:" + actContext + ", dataPath:" + dataPath);
    String[] paths = dataPath.split(":");
    if (paths.length != 2)
        throw new InvalidDataException("Invalid path '" + dataPath + "' it must have one and only one colon (:)");
    String actPath = paths[0];
    String xpath = paths[1];
    if (actPath.startsWith(".")) {
        actPath = actContext + (actContext.endsWith("/") ? "" : "/") + actPath.substring(2);
    }
    // Find the referenced activity, so get the workflow and search
    Workflow workflow = (Workflow) Gateway.getStorage().get(itemPath, ClusterType.LIFECYCLE + "/workflow", locker);
    GraphableVertex act = workflow.search(actPath);
    if (act == null) {
        throw new InvalidDataException("Workflow search failed for actPath:" + actPath + " - item:" + itemPath + ", actContext:" + actContext + ", dataPath:" + dataPath);
    }
    // Get the schema and viewpoint names
    String schemaName = act.getBuiltInProperty(SCHEMA_NAME).toString();
    Integer schemaVersion = Integer.valueOf(act.getBuiltInProperty(SCHEMA_VERSION).toString());
    String viewName = act.getBuiltInProperty(VIEW_POINT).toString();
    if (StringUtils.isBlank(viewName))
        viewName = "last";
    // checks if schema/version was correct
    Schema schema = LocalObjectLoader.getSchema(schemaName, schemaVersion);
    // get the viewpoint and outcome
    Viewpoint view = (Viewpoint) Gateway.getStorage().get(itemPath, ClusterType.VIEWPOINT + "/" + schema.getName() + "/" + viewName, locker);
    Outcome outcome = (Outcome) view.getOutcome(locker);
    // apply the XPath to its outcome
    try {
        return outcome.getFieldByXPath(xpath);
    } catch (XPathExpressionException e) {
        throw new InvalidDataException("Invalid xpath:" + xpath + " - item:" + itemPath + ", actContext:" + actContext + ", dataPath:" + dataPath);
    }
}
Also used : Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint) Outcome(org.cristalise.kernel.persistency.outcome.Outcome) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Schema(org.cristalise.kernel.persistency.outcome.Schema) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex) Workflow(org.cristalise.kernel.lifecycle.instance.Workflow)

Example 7 with GraphableVertex

use of org.cristalise.kernel.graph.model.GraphableVertex in project kernel by cristal-ise.

the class CompositeActivity method verify.

/**
 * launch the verification of the subprocess()
 */
@Override
public boolean verify() {
    boolean err = super.verify();
    GraphableVertex[] vChildren = getChildren();
    for (int i = 0; i < vChildren.length; i++) {
        if (!((WfVertex) vChildren[i]).verify()) {
            mErrors.add("error in children");
            return false;
        }
    }
    return err;
}
Also used : GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 8 with GraphableVertex

use of org.cristalise.kernel.graph.model.GraphableVertex in project kernel by cristal-ise.

the class Workflow method requestAction.

public String requestAction(AgentPath agent, AgentPath delegator, String stepPath, ItemPath itemPath, int transitionID, String requestData) throws ObjectNotFoundException, AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectCannotBeUpdated, CannotManageException, InvalidCollectionModification {
    Logger.msg(3, "Workflow::requestAction() - transition:" + transitionID + " step:" + stepPath + " agent:" + agent);
    GraphableVertex vert = search(stepPath);
    if (vert != null && vert instanceof Activity)
        return ((Activity) vert).request(agent, delegator, itemPath, transitionID, requestData, this);
    else
        throw new ObjectNotFoundException(stepPath + " not found");
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex)

Aggregations

GraphableVertex (org.cristalise.kernel.graph.model.GraphableVertex)8 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)4 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)2 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)2 WfVertex (org.cristalise.kernel.lifecycle.instance.WfVertex)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)1 BuiltInVertexProperties (org.cristalise.kernel.graph.model.BuiltInVertexProperties)1 Vertex (org.cristalise.kernel.graph.model.Vertex)1 Workflow (org.cristalise.kernel.lifecycle.instance.Workflow)1 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)1 Schema (org.cristalise.kernel.persistency.outcome.Schema)1 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)1 CastorHashMap (org.cristalise.kernel.utils.CastorHashMap)1