Search in sources :

Example 1 with AggregationInstance

use of org.cristalise.kernel.collection.AggregationInstance 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)

Aggregations

Aggregation (org.cristalise.kernel.collection.Aggregation)1 AggregationDescription (org.cristalise.kernel.collection.AggregationDescription)1 AggregationInstance (org.cristalise.kernel.collection.AggregationInstance)1 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)1 DomainPath (org.cristalise.kernel.lookup.DomainPath)1 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)1 ItemPath (org.cristalise.kernel.lookup.ItemPath)1 PropertyDescription (org.cristalise.kernel.property.PropertyDescription)1 PropertyDescriptionList (org.cristalise.kernel.property.PropertyDescriptionList)1