Search in sources :

Example 6 with Property

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

the class AggregationMember method assignItem.

@Override
public void assignItem(ItemPath itemPath) throws InvalidCollectionModification {
    if (itemPath != null) {
        if (mClassProps == null || getProperties() == null)
            throw new InvalidCollectionModification("ClassProps not yet set. Cannot check membership validity.");
        // for each mandatory prop check if its in the member property and has the matching value
        StringTokenizer sub = new StringTokenizer(mClassProps, ",");
        while (sub.hasMoreTokens()) {
            String aClassProp = sub.nextToken();
            try {
                String memberValue = (String) getProperties().get(aClassProp);
                Property ItemProperty = (Property) Gateway.getStorage().get(itemPath, ClusterType.PROPERTY + "/" + aClassProp, null);
                if (ItemProperty == null)
                    throw new InvalidCollectionModification("Property " + aClassProp + " does not exist for item " + itemPath);
                if (ItemProperty.getValue() == null || !ItemProperty.getValue().equalsIgnoreCase(memberValue))
                    throw new InvalidCollectionModification("Value of mandatory prop " + aClassProp + " does not match: " + ItemProperty.getValue() + "!=" + memberValue);
            } catch (InvalidCollectionModification ex) {
                throw ex;
            } catch (Exception ex) {
                Logger.error(ex);
                throw new InvalidCollectionModification("Error checking properties");
            }
        }
    }
    mItemPath = itemPath;
    mItem = null;
    mItemName = null;
}
Also used : StringTokenizer(java.util.StringTokenizer) InvalidCollectionModification(org.cristalise.kernel.common.InvalidCollectionModification) Property(org.cristalise.kernel.property.Property) InvalidItemPathException(org.cristalise.kernel.lookup.InvalidItemPathException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Example 7 with Property

use of org.cristalise.kernel.property.Property 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 8 with Property

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

the class Module method setInfo.

public void setInfo(ModuleInfo info) {
    this.info = info;
    replaceProp(new Property(VERSION, info.version, true));
}
Also used : Property(org.cristalise.kernel.property.Property)

Example 9 with Property

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

the class Module method setNamespace.

@Override
public void setNamespace(String ns) {
    super.setNamespace(ns);
    replaceProp(new Property(NAMESPACE, ns, false));
}
Also used : Property(org.cristalise.kernel.property.Property)

Example 10 with Property

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

the class Module method setName.

@Override
public void setName(String name) {
    super.setName(name);
    replaceProp(new Property(NAME, name, false));
}
Also used : Property(org.cristalise.kernel.property.Property)

Aggregations

Property (org.cristalise.kernel.property.Property)19 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)10 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)6 InvalidItemPathException (org.cristalise.kernel.lookup.InvalidItemPathException)6 PropertyArrayList (org.cristalise.kernel.property.PropertyArrayList)6 DomainPath (org.cristalise.kernel.lookup.DomainPath)4 ItemPath (org.cristalise.kernel.lookup.ItemPath)4 PersistencyException (org.cristalise.kernel.common.PersistencyException)3 AgentPath (org.cristalise.kernel.lookup.AgentPath)3 LookupManager (org.cristalise.kernel.lookup.LookupManager)3 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)3 StringTokenizer (java.util.StringTokenizer)2 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)2 AccessRightsException (org.cristalise.kernel.common.AccessRightsException)2 CannotManageException (org.cristalise.kernel.common.CannotManageException)2 InvalidCollectionModification (org.cristalise.kernel.common.InvalidCollectionModification)2 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)2 CompositeActivity (org.cristalise.kernel.lifecycle.instance.CompositeActivity)2 Workflow (org.cristalise.kernel.lifecycle.instance.Workflow)2 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)2