Search in sources :

Example 1 with PropertyDescriptionList

use of org.cristalise.kernel.property.PropertyDescriptionList in project kernel by cristal-ise.

the class ImportAggregation method create.

public org.cristalise.kernel.collection.Aggregation create() throws InvalidCollectionModification, ObjectNotFoundException, ObjectAlreadyExistsException {
    Aggregation newAgg = isDescription ? new AggregationDescription(name) : new AggregationInstance(name);
    if (version != null)
        newAgg.setVersion(version);
    for (ImportAggregationMember thisMem : aggregationMemberList) {
        StringBuffer classProps = new StringBuffer();
        ItemPath itemPath = null;
        if (thisMem.itemDescriptionPath != null && thisMem.itemDescriptionPath.length() > 0) {
            try {
                itemPath = new ItemPath(thisMem.itemDescriptionPath);
            } catch (InvalidItemPathException ex) {
                itemPath = new DomainPath(thisMem.itemDescriptionPath).getItemPath();
            }
            String descVer = thisMem.itemDescriptionVersion == null ? "last" : thisMem.itemDescriptionVersion;
            PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer, null);
            for (PropertyDescription pd : propList.list) {
                thisMem.props.put(pd.getName(), pd.getDefaultValue());
                if (pd.getIsClassIdentifier())
                    classProps.append((classProps.length() > 0 ? "," : "")).append(pd.getName());
            }
        }
        if (thisMem.itemPath != null && thisMem.itemPath.length() > 0) {
            try {
                itemPath = new ItemPath(thisMem.itemPath);
            } catch (InvalidItemPathException ex) {
                itemPath = new DomainPath(thisMem.itemPath).getItemPath();
            }
        }
        newAgg.addMember(itemPath, thisMem.props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height);
    }
    return newAgg;
}
Also used : Aggregation(org.cristalise.kernel.collection.Aggregation) PropertyDescription(org.cristalise.kernel.property.PropertyDescription) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) DomainPath(org.cristalise.kernel.lookup.DomainPath) AggregationDescription(org.cristalise.kernel.collection.AggregationDescription) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint) AggregationInstance(org.cristalise.kernel.collection.AggregationInstance) PropertyDescriptionList(org.cristalise.kernel.property.PropertyDescriptionList) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 2 with PropertyDescriptionList

use of org.cristalise.kernel.property.PropertyDescriptionList in project kernel by cristal-ise.

the class ImportDependency method create.

public Dependency create() throws InvalidCollectionModification, ObjectNotFoundException, ObjectAlreadyExistsException {
    Dependency newDep = isDescription ? new DependencyDescription(name) : new Dependency(name);
    if (version != null)
        newDep.setVersion(version);
    if (itemDescriptionPath != null && itemDescriptionPath.length() > 0) {
        ItemPath itemPath;
        try {
            itemPath = new ItemPath(itemDescriptionPath);
        } catch (InvalidItemPathException ex) {
            itemPath = new DomainPath(itemDescriptionPath).getItemPath();
        }
        String descVer = itemDescriptionVersion == null ? "last" : itemDescriptionVersion;
        PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer, null);
        StringBuffer classProps = new StringBuffer();
        for (PropertyDescription pd : propList.list) {
            props.put(pd.getName(), pd.getDefaultValue());
            if (pd.getIsClassIdentifier())
                classProps.append((classProps.length() > 0 ? "," : "")).append(pd.getName());
        }
        newDep.setProperties(props);
        newDep.setClassProps(classProps.toString());
    }
    for (ImportDependencyMember thisMem : dependencyMemberList) {
        ItemPath itemPath;
        try {
            itemPath = new ItemPath(thisMem.itemPath);
        } catch (InvalidItemPathException ex) {
            itemPath = new DomainPath(thisMem.itemPath).getItemPath();
        }
        org.cristalise.kernel.collection.DependencyMember newDepMem = newDep.addMember(itemPath);
        newDepMem.getProperties().putAll(thisMem.props);
    }
    return newDep;
}
Also used : InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) DomainPath(org.cristalise.kernel.lookup.DomainPath) Dependency(org.cristalise.kernel.collection.Dependency) PropertyDescription(org.cristalise.kernel.property.PropertyDescription) DependencyDescription(org.cristalise.kernel.collection.DependencyDescription) PropertyDescriptionList(org.cristalise.kernel.property.PropertyDescriptionList) ItemPath(org.cristalise.kernel.lookup.ItemPath)

Example 3 with PropertyDescriptionList

use of org.cristalise.kernel.property.PropertyDescriptionList in project kernel by cristal-ise.

the class DependencyDescription method newInstance.

@Override
public Collection<DependencyMember> newInstance() throws ObjectNotFoundException {
    // HACK: Knock the special 'prime' off the end for the case of descriptions of descriptions
    String depName = getName().replaceFirst("\'$", "");
    Dependency newDep = new Dependency(depName);
    // constrain the members based on the property description
    if (mMembers.list.size() == 1) {
        DependencyMember mem = mMembers.list.get(0);
        String descVer = getDescVer(mem);
        PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath(), descVer, null);
        if (pdList != null) {
            newDep.setProperties(PropertyUtility.convertTransitiveProperties(pdList));
            newDep.setClassProps(pdList.getClassProps());
        }
    }
    return newDep;
}
Also used : PropertyDescriptionList(org.cristalise.kernel.property.PropertyDescriptionList)

Example 4 with PropertyDescriptionList

use of org.cristalise.kernel.property.PropertyDescriptionList in project kernel by cristal-ise.

the class Bootstrap method createResourceItem.

/**
 * @param impHandler
 * @param itemName
 * @param ns
 * @param itemPath
 * @return the ItemProxy representing the newly create Item
 * @throws Exception
 */
private static ItemProxy createResourceItem(ResourceImportHandler impHandler, String itemName, String ns, ItemPath itemPath) throws Exception {
    // create props
    PropertyDescriptionList pdList = impHandler.getPropDesc();
    PropertyArrayList props = new PropertyArrayList();
    LookupManager lookupManager = Gateway.getLookupManager();
    for (int i = 0; i < pdList.list.size(); i++) {
        PropertyDescription pd = pdList.list.get(i);
        String propName = pd.getName();
        String propVal = pd.getDefaultValue();
        if (propName.equals(NAME.toString()))
            propVal = itemName;
        else if (propName.equals(MODULE.toString()))
            propVal = (ns == null) ? "kernel" : ns;
        props.list.add(new Property(propName, propVal, pd.getIsMutable()));
    }
    CompositeActivity ca = new CompositeActivity();
    try {
        ca = (CompositeActivity) ((CompositeActivityDef) LocalObjectLoader.getActDef(impHandler.getWorkflowName(), 0)).instantiate();
    } catch (ObjectNotFoundException ex) {
        Logger.error(ex);
        Logger.error("Module resource workflow " + impHandler.getWorkflowName() + " not found. Using empty.");
    }
    Gateway.getCorbaServer().createItem(itemPath);
    lookupManager.add(itemPath);
    DomainPath newDomPath = impHandler.getPath(itemName, ns);
    newDomPath.setItemPath(itemPath);
    lookupManager.add(newDomPath);
    ItemProxy newItemProxy = Gateway.getProxyManager().getProxy(itemPath);
    newItemProxy.initialise(systemAgents.get("system").getPath(), props, ca, null);
    return newItemProxy;
}
Also used : PropertyDescription(org.cristalise.kernel.property.PropertyDescription) DomainPath(org.cristalise.kernel.lookup.DomainPath) ItemProxy(org.cristalise.kernel.entity.proxy.ItemProxy) CompositeActivity(org.cristalise.kernel.lifecycle.instance.CompositeActivity) LookupManager(org.cristalise.kernel.lookup.LookupManager) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) PropertyArrayList(org.cristalise.kernel.property.PropertyArrayList) CompositeActivityDef(org.cristalise.kernel.lifecycle.CompositeActivityDef) PropertyDescriptionList(org.cristalise.kernel.property.PropertyDescriptionList) Property(org.cristalise.kernel.property.Property) Viewpoint(org.cristalise.kernel.persistency.outcome.Viewpoint)

Example 5 with PropertyDescriptionList

use of org.cristalise.kernel.property.PropertyDescriptionList 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)

Aggregations

PropertyDescriptionList (org.cristalise.kernel.property.PropertyDescriptionList)7 DomainPath (org.cristalise.kernel.lookup.DomainPath)4 PropertyDescription (org.cristalise.kernel.property.PropertyDescription)4 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)3 ItemPath (org.cristalise.kernel.lookup.ItemPath)3 Aggregation (org.cristalise.kernel.collection.Aggregation)2 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)2 Property (org.cristalise.kernel.property.Property)2 PropertyArrayList (org.cristalise.kernel.property.PropertyArrayList)2 AggregationDescription (org.cristalise.kernel.collection.AggregationDescription)1 AggregationInstance (org.cristalise.kernel.collection.AggregationInstance)1 Dependency (org.cristalise.kernel.collection.Dependency)1 DependencyDescription (org.cristalise.kernel.collection.DependencyDescription)1 InvalidCollectionModification (org.cristalise.kernel.common.InvalidCollectionModification)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)1 PersistencyException (org.cristalise.kernel.common.PersistencyException)1 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)1 ItemProxy (org.cristalise.kernel.entity.proxy.ItemProxy)1 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)1