Search in sources :

Example 6 with Dependency

use of org.cristalise.kernel.collection.Dependency in project kernel by cristal-ise.

the class ActivityDef method makeDescCollection.

public Dependency makeDescCollection(BuiltInCollections collection, DescriptionObject... descs) throws InvalidDataException {
    // TODO: restrict membership based on kernel property desc
    Dependency descDep = new Dependency(collection.getName());
    if (mVersion != null && mVersion > -1) {
        descDep.setVersion(mVersion);
    }
    for (DescriptionObject thisDesc : descs) {
        if (thisDesc == null)
            continue;
        try {
            DependencyMember descMem = descDep.addMember(thisDesc.getItemPath());
            descMem.setBuiltInProperty(VERSION, thisDesc.getVersion());
        } catch (Exception e) {
            Logger.error(e);
            throw new InvalidDataException("Problem creating description collection for " + thisDesc + " in " + getName());
        }
    }
    return descDep;
}
Also used : DependencyMember(org.cristalise.kernel.collection.DependencyMember) DescriptionObject(org.cristalise.kernel.utils.DescriptionObject) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Dependency(org.cristalise.kernel.collection.Dependency) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) IOException(java.io.IOException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 7 with Dependency

use of org.cristalise.kernel.collection.Dependency in project kernel by cristal-ise.

the class CreateItemFromDescription method instantiateCollections.

/**
 * Copies the CollectionDescriptions of the Item requesting this predefined step.
 *
 * @param descItemPath
 * @param descVer
 * @param locker
 * @return the new collection
 * @throws ObjectNotFoundException
 * @throws PersistencyException
 * @throws InvalidDataException
 */
protected CollectionArrayList instantiateCollections(ItemPath descItemPath, String descVer, PropertyArrayList newProps, Object locker) throws ObjectNotFoundException, PersistencyException, InvalidDataException {
    // loop through collections, collecting instantiated descriptions and finding the default workflow def
    CollectionArrayList colls = new CollectionArrayList();
    String[] collNames = Gateway.getStorage().getClusterContents(descItemPath, ClusterType.COLLECTION);
    for (String collName : collNames) {
        @SuppressWarnings("unchecked") Collection<? extends CollectionMember> thisCol = (Collection<? extends CollectionMember>) Gateway.getStorage().get(descItemPath, ClusterType.COLLECTION + "/" + collName + "/" + descVer, locker);
        if (thisCol instanceof CollectionDescription) {
            Logger.msg(5, "CreateItemFromDescription - Instantiating CollectionDescription:" + collName);
            CollectionDescription<?> thisDesc = (CollectionDescription<?>) thisCol;
            colls.put(thisDesc.newInstance());
        } else if (thisCol instanceof Dependency) {
            Logger.msg(5, "CreateItemFromDescription - Instantiating Dependency:" + collName);
            ((Dependency) thisCol).addToItemProperties(newProps);
        } else {
            Logger.warning("CreateItemFromDescription - CANNOT instantiate collection:" + collName + " class:" + thisCol.getClass().getName());
        }
    }
    return colls;
}
Also used : CollectionMember(org.cristalise.kernel.collection.CollectionMember) CollectionDescription(org.cristalise.kernel.collection.CollectionDescription) Collection(org.cristalise.kernel.collection.Collection) Dependency(org.cristalise.kernel.collection.Dependency) CollectionArrayList(org.cristalise.kernel.collection.CollectionArrayList)

Example 8 with Dependency

use of org.cristalise.kernel.collection.Dependency in project kernel by cristal-ise.

the class Script method makeDescCollections.

/**
 */
@Override
public CollectionArrayList makeDescCollections() throws InvalidDataException, ObjectNotFoundException {
    CollectionArrayList retArr = new CollectionArrayList();
    Dependency includeColl = new Dependency(INCLUDE);
    for (Script script : mIncludes) {
        try {
            includeColl.addMember(script.getItemPath());
        } catch (InvalidCollectionModification e) {
            throw new InvalidDataException("Could not add " + script.getName() + " to description collection. " + e.getMessage());
        } catch (ObjectAlreadyExistsException e) {
            throw new InvalidDataException("Script " + script.getName() + " included more than once.");
        }
    // 
    }
    retArr.put(includeColl);
    return retArr;
}
Also used : CompiledScript(javax.script.CompiledScript) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) InvalidCollectionModification(org.cristalise.kernel.common.InvalidCollectionModification) Dependency(org.cristalise.kernel.collection.Dependency) CollectionArrayList(org.cristalise.kernel.collection.CollectionArrayList) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException)

Aggregations

Dependency (org.cristalise.kernel.collection.Dependency)8 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)5 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)4 PersistencyException (org.cristalise.kernel.common.PersistencyException)4 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)3 DependencyMember (org.cristalise.kernel.collection.DependencyMember)2 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)2 DomainPath (org.cristalise.kernel.lookup.DomainPath)2 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)2 ItemPath (org.cristalise.kernel.lookup.ItemPath)2 DescriptionObject (org.cristalise.kernel.utils.DescriptionObject)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CompiledScript (javax.script.CompiledScript)1 Aggregation (org.cristalise.kernel.collection.Aggregation)1 Collection (org.cristalise.kernel.collection.Collection)1 CollectionDescription (org.cristalise.kernel.collection.CollectionDescription)1 CollectionMember (org.cristalise.kernel.collection.CollectionMember)1 DependencyDescription (org.cristalise.kernel.collection.DependencyDescription)1 InvalidCollectionModification (org.cristalise.kernel.common.InvalidCollectionModification)1