Search in sources :

Example 1 with ActivityDef

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

the class ModuleWorkflow method populateActivityDef.

@Override
public void populateActivityDef() throws ObjectNotFoundException, CannotManageException {
    super.populateActivityDef();
    CompositeActivityDef compActDef = (CompositeActivityDef) actDef;
    ArrayList<ActivityDef> graphActDefs = compActDef.getRefChildActDef();
    if (activities.size() != graphActDefs.size())
        throw new CannotManageException("There were " + activities.size() + " declared activities, but the graph uses " + graphActDefs.size());
    for (ModuleDescRef moduleDescRef : activities) {
        boolean found = false;
        for (ActivityDef childActDef : graphActDefs) {
            if (childActDef.getName().equals(moduleDescRef.getName()) && childActDef.getVersion().equals(moduleDescRef.getVersion())) {
                found = true;
                break;
            }
        }
        if (!found)
            throw new CannotManageException("Graphed child activity " + moduleDescRef.getName() + " v" + moduleDescRef.getVersion() + " not referenced in module for " + getName());
    }
}
Also used : CannotManageException(org.cristalise.kernel.common.CannotManageException) CompositeActivityDef(org.cristalise.kernel.lifecycle.CompositeActivityDef) ActivityDef(org.cristalise.kernel.lifecycle.ActivityDef) CompositeActivityDef(org.cristalise.kernel.lifecycle.CompositeActivityDef)

Example 2 with ActivityDef

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

the class ActDefCache method buildObject.

@Override
public ActivityDef buildObject(String name, int version, ItemPath path, String data) throws InvalidDataException {
    try {
        ActivityDef thisActDef = (ActivityDef) Gateway.getMarshaller().unmarshall(data);
        thisActDef.setBuiltInProperty(VERSION, version);
        thisActDef.setName(name);
        thisActDef.setVersion(version);
        thisActDef.setItemPath(path);
        return thisActDef;
    } catch (Exception ex) {
        Logger.error(ex);
        throw new InvalidDataException("Could not unmarshall Activity '" + name + "' v" + version + ": " + ex.getMessage());
    }
}
Also used : InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ActivityDef(org.cristalise.kernel.lifecycle.ActivityDef) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Example 3 with ActivityDef

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

the class Dependency method addToVertexProperties.

/**
 * Add Dependency specific values to VertexProperties (CastorHashMap). First checks if there is a Script
 * to be executed, if no Script defined it will use the default conversion implemented for BuiltInCollections
 *
 * @param props the current list of VertexProperties
 * @throws InvalidDataException inconsistent data was provided
 * @throws ObjectNotFoundException objects were not found while reading the properties
 */
public void addToVertexProperties(CastorHashMap props) throws InvalidDataException, ObjectNotFoundException {
    Logger.msg(2, "Dependency.addToVertexProperties(" + getName() + ") - Starting ...");
    BuiltInCollections builtInColl = BuiltInCollections.getValue(getName());
    for (DependencyMember member : getMembers().list) {
        String memberUUID = member.getChildUUID();
        Integer memberVer = LocalObjectLoader.deriveVersionNumber(member.getBuiltInProperty(VERSION));
        if (memberVer == null) {
            throw new InvalidDataException("Version is null for Collection:" + getName() + ", DependencyMember:" + memberUUID);
        }
        // - or this is not a BuiltInCollection
        if (convertToVertextPropsByScript(props, member) || builtInColl == null)
            continue;
        Logger.msg(5, "Dependency.addToVertexProperties() - Dependency:" + getName() + " memberUUID:" + memberUUID);
        // LocalObjectLoader checks if data is valid and loads object to cache
        switch(builtInColl) {
            // ***************************************************************************************************
            case SCHEMA:
                try {
                    LocalObjectLoader.getSchema(memberUUID, memberVer);
                    props.setBuiltInProperty(SCHEMA_NAME, memberUUID);
                    props.setBuiltInProperty(SCHEMA_VERSION, memberVer);
                } catch (ObjectNotFoundException e) {
                    // Schema dependency could be defined in Properties
                    if (props.containsKey(SCHEMA_NAME)) {
                        Logger.msg(8, "Dependency.addToVertexProperties() - BACKWARD COMPABILITY: Dependency '" + getName() + "' is defined in Properties");
                        String uuid = LocalObjectLoader.getSchema(props).getItemPath().getUUID().toString();
                        props.setBuiltInProperty(SCHEMA_NAME, uuid);
                    }
                }
                break;
            // ***************************************************************************************************
            case SCRIPT:
                try {
                    LocalObjectLoader.getScript(memberUUID, memberVer);
                    props.setBuiltInProperty(SCRIPT_NAME, memberUUID);
                    props.setBuiltInProperty(SCRIPT_VERSION, memberVer);
                } catch (ObjectNotFoundException e) {
                    // Backward compability: Script dependency could be defined in Properties
                    if (props.containsKey(SCRIPT_NAME)) {
                        Logger.msg(8, "Dependency.addToVertexProperties() - BACKWARD COMPABILITY: Dependency '" + getName() + "' is defined in Properties");
                        String uuid = LocalObjectLoader.getScript(props).getItemPath().getUUID().toString();
                        props.setBuiltInProperty(SCRIPT_NAME, uuid);
                    }
                }
                break;
            // ***************************************************************************************************
            case QUERY:
                try {
                    LocalObjectLoader.getQuery(memberUUID, memberVer);
                    props.setBuiltInProperty(QUERY_NAME, memberUUID);
                    props.setBuiltInProperty(QUERY_VERSION, memberVer);
                } catch (ObjectNotFoundException e) {
                    // Backward compability: Query dependency could be defined in Properties
                    if (props.containsKey(QUERY_NAME)) {
                        Logger.msg(8, "Dependency.addToVertexProperties() - BACKWARD COMPABILITY: Dependency '" + getName() + "' is defined in Properties");
                        String uuid = LocalObjectLoader.getQuery(props).getItemPath().getUUID().toString();
                        props.setBuiltInProperty(QUERY_NAME, uuid);
                    }
                }
                break;
            // ***************************************************************************************************
            case STATE_MACHINE:
                try {
                    LocalObjectLoader.getStateMachine(memberUUID, memberVer);
                    props.setBuiltInProperty(STATE_MACHINE_NAME, memberUUID);
                    props.setBuiltInProperty(STATE_MACHINE_VERSION, memberVer);
                } catch (ObjectNotFoundException e) {
                    if (props.containsKey(STATE_MACHINE_NAME)) {
                        Logger.msg(8, "Dependency.addToVertexProperties() -  BACKWARD COMPABILITY: Dependency '" + getName() + "' is defined in Properties");
                        String uuid = LocalObjectLoader.getStateMachine(props).getItemPath().getUUID().toString();
                        props.setBuiltInProperty(STATE_MACHINE_NAME, uuid);
                    }
                }
                break;
            // ***************************************************************************************************
            case ACTIVITY:
                ActivityDef actDef = LocalObjectLoader.getActDef(memberUUID, memberVer);
                CastorHashMap chm = null;
                if (props.containsKey(ACTIVITY_DEF_URN)) {
                    chm = (CastorHashMap) props.getBuiltInProperty(ACTIVITY_DEF_URN);
                } else {
                    chm = new CastorHashMap();
                    props.setBuiltInProperty(ACTIVITY_DEF_URN, chm);
                }
                Logger.msg(8, "Dependency.addToVertexProperties(" + getName() + ") - actDef:" + actDef.getActName());
                chm.put(actDef.getActName(), memberUUID + "~" + memberVer);
                break;
            // ***************************************************************************************************
            default:
                Logger.msg(8, "Dependency.addToVertexProperties() - Cannot handle BuiltIn Dependency:" + getName());
                break;
        }
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) CastorHashMap(org.cristalise.kernel.utils.CastorHashMap) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ActivityDef(org.cristalise.kernel.lifecycle.ActivityDef)

Aggregations

ActivityDef (org.cristalise.kernel.lifecycle.ActivityDef)3 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)2 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)2 CannotManageException (org.cristalise.kernel.common.CannotManageException)1 PersistencyException (org.cristalise.kernel.common.PersistencyException)1 CompositeActivityDef (org.cristalise.kernel.lifecycle.CompositeActivityDef)1 CastorHashMap (org.cristalise.kernel.utils.CastorHashMap)1