Search in sources :

Example 1 with CompositeActivityDef

use of org.cristalise.kernel.lifecycle.CompositeActivityDef 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 2 with CompositeActivityDef

use of org.cristalise.kernel.lifecycle.CompositeActivityDef in project kernel by cristal-ise.

the class ModuleWorkflow method populateActivityDef.

@Override
public void populateActivityDef() throws ObjectNotFoundException, CannotManageException {
    super.populateActivityDef();
    CompositeActivityDef compActDef = (CompositeActivityDef) actDef;
    ArrayList<ActivityDef> graphActDefs = compActDef.getRefChildActDef();
    if (activities.size() != graphActDefs.size())
        throw new CannotManageException("There were " + activities.size() + " declared activities, but the graph uses " + graphActDefs.size());
    for (ModuleDescRef moduleDescRef : activities) {
        boolean found = false;
        for (ActivityDef childActDef : graphActDefs) {
            if (childActDef.getName().equals(moduleDescRef.getName()) && childActDef.getVersion().equals(moduleDescRef.getVersion())) {
                found = true;
                break;
            }
        }
        if (!found)
            throw new CannotManageException("Graphed child activity " + moduleDescRef.getName() + " v" + moduleDescRef.getVersion() + " not referenced in module for " + getName());
    }
}
Also used : CannotManageException(org.cristalise.kernel.common.CannotManageException) CompositeActivityDef(org.cristalise.kernel.lifecycle.CompositeActivityDef) ActivityDef(org.cristalise.kernel.lifecycle.ActivityDef) CompositeActivityDef(org.cristalise.kernel.lifecycle.CompositeActivityDef)

Example 3 with CompositeActivityDef

use of org.cristalise.kernel.lifecycle.CompositeActivityDef in project kernel by cristal-ise.

the class Bootstrap method initServerItemWf.

public static void initServerItemWf() throws Exception {
    CompositeActivityDef serverWfCa = (CompositeActivityDef) LocalObjectLoader.getActDef("ServerItemWorkflow", 0);
    Workflow wf = new Workflow((CompositeActivity) serverWfCa.instantiate(), new ServerPredefinedStepContainer());
    wf.initialise(thisServerPath.getItemPath(), systemAgents.get("system").getPath(), null);
    Gateway.getStorage().put(thisServerPath.getItemPath(), wf, null);
}
Also used : Workflow(org.cristalise.kernel.lifecycle.instance.Workflow) CompositeActivityDef(org.cristalise.kernel.lifecycle.CompositeActivityDef) ServerPredefinedStepContainer(org.cristalise.kernel.lifecycle.instance.predefined.server.ServerPredefinedStepContainer)

Example 4 with CompositeActivityDef

use of org.cristalise.kernel.lifecycle.CompositeActivityDef in project kernel by cristal-ise.

the class CreateItemFromDescription method instantiateWorkflow.

/**
 * Retrieve the Workflow dependency for the given description version, instantiate the loaded CompositeActivityDef
 *
 * @param descItemPath
 * @param descVer
 * @param locker
 * @return the Workflow instance
 * @throws ObjectNotFoundException
 * @throws InvalidDataException
 * @throws PersistencyException
 */
protected CompositeActivity instantiateWorkflow(ItemPath descItemPath, String descVer, Object locker) throws ObjectNotFoundException, InvalidDataException, PersistencyException {
    @SuppressWarnings("unchecked") Collection<? extends CollectionMember> thisCol = (Collection<? extends CollectionMember>) Gateway.getStorage().get(descItemPath, ClusterType.COLLECTION + "/" + WORKFLOW + "/" + descVer, locker);
    CollectionMember wfMember = thisCol.getMembers().list.get(0);
    String wfDefName = wfMember.resolveItem().getName();
    Object wfVerObj = wfMember.getProperties().getBuiltInProperty(VERSION);
    if (wfVerObj == null || String.valueOf(wfVerObj).length() == 0) {
        throw new InvalidDataException("Workflow version number not set");
    }
    try {
        Integer wfDefVer = Integer.parseInt(wfVerObj.toString());
        if (wfDefName == null)
            throw new InvalidDataException("No workflow given or defined");
        // load workflow def
        CompositeActivityDef wfDef = (CompositeActivityDef) LocalObjectLoader.getActDef(wfDefName, wfDefVer);
        return (CompositeActivity) wfDef.instantiate();
    } catch (NumberFormatException ex) {
        throw new InvalidDataException("Invalid workflow version number: " + wfVerObj.toString());
    } catch (ClassCastException ex) {
        Logger.error(ex);
        throw new InvalidDataException("Activity def '" + wfDefName + "' was not Composite");
    }
}
Also used : CompositeActivity(org.cristalise.kernel.lifecycle.instance.CompositeActivity) CollectionMember(org.cristalise.kernel.collection.CollectionMember) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Collection(org.cristalise.kernel.collection.Collection) CompositeActivityDef(org.cristalise.kernel.lifecycle.CompositeActivityDef)

Example 5 with CompositeActivityDef

use of org.cristalise.kernel.lifecycle.CompositeActivityDef in project kernel by cristal-ise.

the class LifecycleRendererTest method generateDef_SVG.

@Test
public void generateDef_SVG() throws Exception {
    String caDefXML = FileStringUtility.url2String(Gateway.getResource().getKernelResourceURL("boot/CA/ManageModule.xml"));
    CompositeActivityDef caDef = (CompositeActivityDef) Gateway.getMarshaller().unmarshall(caDefXML);
    LifecycleRenderer generator = new LifecycleRenderer(caDef.getChildrenGraphModel(), true);
    int zoomFactor = generator.getZoomFactor(500, 500);
    SVGGraphics2D svgG2D = new SVGGraphics2D(500, 500);
    svgG2D.scale((double) zoomFactor / 100, (double) zoomFactor / 100);
    generator.draw(svgG2D);
    SVGUtils.writeToSVG(new File("target/ManageModule.svg"), svgG2D.getSVGElement());
}
Also used : LifecycleRenderer(org.cristalise.kernel.lifecycle.renderer.LifecycleRenderer) SVGGraphics2D(org.jfree.graphics2d.svg.SVGGraphics2D) CompositeActivityDef(org.cristalise.kernel.lifecycle.CompositeActivityDef) File(java.io.File) Test(org.junit.Test)

Aggregations

CompositeActivityDef (org.cristalise.kernel.lifecycle.CompositeActivityDef)6 File (java.io.File)2 CompositeActivity (org.cristalise.kernel.lifecycle.instance.CompositeActivity)2 LifecycleRenderer (org.cristalise.kernel.lifecycle.renderer.LifecycleRenderer)2 Test (org.junit.Test)2 BufferedImage (java.awt.image.BufferedImage)1 Collection (org.cristalise.kernel.collection.Collection)1 CollectionMember (org.cristalise.kernel.collection.CollectionMember)1 CannotManageException (org.cristalise.kernel.common.CannotManageException)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 ItemProxy (org.cristalise.kernel.entity.proxy.ItemProxy)1 ActivityDef (org.cristalise.kernel.lifecycle.ActivityDef)1 Workflow (org.cristalise.kernel.lifecycle.instance.Workflow)1 ServerPredefinedStepContainer (org.cristalise.kernel.lifecycle.instance.predefined.server.ServerPredefinedStepContainer)1 DomainPath (org.cristalise.kernel.lookup.DomainPath)1 LookupManager (org.cristalise.kernel.lookup.LookupManager)1 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)1 Property (org.cristalise.kernel.property.Property)1 PropertyArrayList (org.cristalise.kernel.property.PropertyArrayList)1