Search in sources :

Example 6 with InvalidCollectionModification

use of org.cristalise.kernel.common.InvalidCollectionModification in project kernel by cristal-ise.

the class AggregationDescription method newInstance.

/**
 * For each  member get the {@link PropertyDescriptionList} of the member item and look for an explicit version
 */
@Override
public Aggregation newInstance() throws ObjectNotFoundException {
    AggregationInstance newInstance = new AggregationInstance(getName());
    for (int i = 0; i < size(); i++) {
        AggregationMember mem = mMembers.list.get(i);
        // 
        String descVer = getDescVer(mem);
        PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath(), descVer, null);
        if (pdList != null) {
            // create the new props of the member object
            try {
                Vertex v = getLayout().getVertexById(mem.getID());
                newInstance.addMember(null, PropertyUtility.convertTransitiveProperties(pdList), pdList.getClassProps(), v.getCentrePoint(), v.getWidth(), v.getHeight());
            } catch (InvalidCollectionModification e) {
            } catch (ObjectAlreadyExistsException e) {
            }
        } else {
            Logger.error("AggregationDescription::newInstance() There is no PropertyDescription. Cannot instantiate. " + mem.getItemPath());
            return null;
        }
    }
    return newInstance;
}
Also used : Vertex(org.cristalise.kernel.graph.model.Vertex) InvalidCollectionModification(org.cristalise.kernel.common.InvalidCollectionModification) PropertyDescriptionList(org.cristalise.kernel.property.PropertyDescriptionList) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException)

Example 7 with InvalidCollectionModification

use of org.cristalise.kernel.common.InvalidCollectionModification in project kernel by cristal-ise.

the class CreateItemFromDescription method initialiseItem.

/**
 * @param agent
 * @param descItemPath
 * @param locker
 * @param input
 * @param newName
 * @param descVer
 * @param context
 * @param newItemPath
 * @param newItem
 * @throws ObjectCannotBeUpdated
 * @throws CannotManageException
 * @throws InvalidDataException
 * @throws ObjectAlreadyExistsException
 * @throws PersistencyException
 * @throws ObjectNotFoundException
 */
protected void initialiseItem(ItemOperations newItem, AgentPath agent, ItemPath descItemPath, PropertyArrayList initProps, String newName, String descVer, DomainPath context, ItemPath newItemPath, Object locker) throws ObjectCannotBeUpdated, CannotManageException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException {
    // initialise it with its properties and workflow
    Logger.msg(3, "CreateItemFromDescription.initialiseItem() - Initializing Item:" + newName);
    try {
        PropertyArrayList newProps = instantiateProperties(descItemPath, descVer, initProps, newName, agent, locker);
        CollectionArrayList newColls = instantiateCollections(descItemPath, descVer, newProps, locker);
        CompositeActivity newWorkflow = instantiateWorkflow(descItemPath, descVer, locker);
        newItem.initialise(agent.getSystemKey(), Gateway.getMarshaller().marshall(newProps), Gateway.getMarshaller().marshall(newWorkflow), Gateway.getMarshaller().marshall(newColls));
    } catch (MarshalException | ValidationException | AccessRightsException | IOException | MappingException | InvalidCollectionModification e) {
        Logger.error(e);
        Gateway.getLookupManager().delete(newItemPath);
        throw new InvalidDataException("CreateItemFromDescription: Problem initializing new Item. See log: " + e.getMessage());
    } catch (InvalidDataException | ObjectNotFoundException | PersistencyException e) {
        Logger.error(e);
        Gateway.getLookupManager().delete(newItemPath);
        throw e;
    }
    // add its domain path
    Logger.msg(3, "CreateItemFromDescription - Creating " + context);
    context.setItemPath(newItemPath);
    Gateway.getLookupManager().add(context);
}
Also used : MarshalException(org.exolab.castor.xml.MarshalException) AccessRightsException(org.cristalise.kernel.common.AccessRightsException) ValidationException(org.exolab.castor.xml.ValidationException) InvalidCollectionModification(org.cristalise.kernel.common.InvalidCollectionModification) IOException(java.io.IOException) CollectionArrayList(org.cristalise.kernel.collection.CollectionArrayList) MappingException(org.exolab.castor.mapping.MappingException) CompositeActivity(org.cristalise.kernel.lifecycle.instance.CompositeActivity) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PropertyArrayList(org.cristalise.kernel.property.PropertyArrayList) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) PersistencyException(org.cristalise.kernel.common.PersistencyException)

Example 8 with InvalidCollectionModification

use of org.cristalise.kernel.common.InvalidCollectionModification 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

InvalidCollectionModification (org.cristalise.kernel.common.InvalidCollectionModification)8 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)5 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)4 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)4 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)3 IOException (java.io.IOException)2 StringTokenizer (java.util.StringTokenizer)2 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)2 AccessRightsException (org.cristalise.kernel.common.AccessRightsException)2 PersistencyException (org.cristalise.kernel.common.PersistencyException)2 Property (org.cristalise.kernel.property.Property)2 MappingException (org.exolab.castor.mapping.MappingException)2 MarshalException (org.exolab.castor.xml.MarshalException)2 ValidationException (org.exolab.castor.xml.ValidationException)2 CompiledScript (javax.script.CompiledScript)1 Dependency (org.cristalise.kernel.collection.Dependency)1 CannotManageException (org.cristalise.kernel.common.CannotManageException)1 InvalidTransitionException (org.cristalise.kernel.common.InvalidTransitionException)1 ObjectCannotBeUpdated (org.cristalise.kernel.common.ObjectCannotBeUpdated)1 Vertex (org.cristalise.kernel.graph.model.Vertex)1