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;
}
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());
}
}
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);
}
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");
}
}
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());
}
Aggregations