diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | changelog | 8 | ||||
| -rw-r--r-- | resources/boot/EA/AssignNewVersionFromLast.xml | 2 | ||||
| -rw-r--r-- | resources/boot/EA/CreateItem.xml | 21 | ||||
| -rw-r--r-- | resources/boot/EA/CreateNewLocalObjectDef.xml | 2 | ||||
| -rw-r--r-- | resources/boot/EA/EditPropertyDescription.xml | 21 | ||||
| -rw-r--r-- | resources/boot/EA/SetInstanceWorkflow.xml | 21 | ||||
| -rw-r--r-- | resources/boot/SC/InstantiateItem.xml | 23 | ||||
| -rw-r--r-- | resources/boot/SC/LocalObjectDefCreator.xml | 19 | ||||
| -rw-r--r-- | resources/boot/SC/SetWorkflow.xml | 52 | ||||
| -rw-r--r-- | src/module.xml | 2 |
11 files changed, 127 insertions, 45 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/changelog b/changelog new file mode 100644 index 0000000..46017e0 --- /dev/null +++ b/changelog @@ -0,0 +1,8 @@ +0.2 - Description Factory
+-------------------------
+ - DescriptionFactory
+
+0.1 - Initial release
+---------------------
+ - Extracted dev stuff from kernel 2.3
+ - Activity, Schema, Script Factories
\ No newline at end of file diff --git a/resources/boot/EA/AssignNewVersionFromLast.xml b/resources/boot/EA/AssignNewVersionFromLast.xml index 1ef30b5..248dfee 100644 --- a/resources/boot/EA/AssignNewVersionFromLast.xml +++ b/resources/boot/EA/AssignNewVersionFromLast.xml @@ -5,7 +5,7 @@ <KeyValuePair Key="Autostart" Boolean="true"/>
<KeyValuePair Key="Mail Message" String=""/>
<KeyValuePair Key="Mail event" String=""/>
- <KeyValuePair Key="Description" String="Creates a new numbered viewpoint as a clone of the last for use in workflows. You can change the referenced version in the Data Viewer."/>
+ <KeyValuePair Key="Description" String="Creates a new numbered viewpoint as a clone of the last for use in workflows. You can change the specific outcome referenced by this viewpoint in the Data Viewer."/>
<KeyValuePair Key="SchemaVersion" String=""/>
<KeyValuePair Key="Show time" Boolean="true"/>
<KeyValuePair Key="Viewpoint" String=""/>
diff --git a/resources/boot/EA/CreateItem.xml b/resources/boot/EA/CreateItem.xml index 6facb82..d54cd4d 100644 --- a/resources/boot/EA/CreateItem.xml +++ b/resources/boot/EA/CreateItem.xml @@ -1 +1,20 @@ -<ActivityDef ID="-1" Name="CreateItem" Height="0" Width="0" IsLayoutable="false" IsComposite="false"><Properties><KeyValuePair Key="Description" String=""/><KeyValuePair Key="Ignorable" Boolean="false"/><KeyValuePair Key="ScriptVersion" String="0"/><KeyValuePair Key="Mail Message" String=""/><KeyValuePair Key="Viewpoint" String=""/><KeyValuePair Key="Agent Name" String=""/><KeyValuePair Key="SchemaVersion" String="0"/><KeyValuePair Key="Skippable" Boolean="false"/><KeyValuePair Key="ScriptName" String="InstantiateItem"/><KeyValuePair Key="Mail event" String=""/><KeyValuePair Key="Autostart" Boolean="true"/><KeyValuePair Key="Repeatable" Boolean="false"/><KeyValuePair Key="Show time" Boolean="true"/><KeyValuePair Key="Agent Role" String=""/><KeyValuePair Key="AlwaysUseOutcome" Boolean="false"/><KeyValuePair Key="SchemaType" String="NewDevObjectDef"/></Properties></ActivityDef>
\ No newline at end of file +<ActivityDef ID="-1" Name="CreateItem" Height="0" Width="0" IsLayoutable="false" IsComposite="false">
+ <Properties>
+ <KeyValuePair Key="Description" String="Create a new Item from this Description"/>
+ <KeyValuePair Key="Ignorable" Boolean="false"/>
+ <KeyValuePair Key="ScriptVersion" String="0"/>
+ <KeyValuePair Key="Mail Message" String=""/>
+ <KeyValuePair Key="Viewpoint" String=""/>
+ <KeyValuePair Key="Agent Name" String=""/>
+ <KeyValuePair Key="SchemaVersion" String="0"/>
+ <KeyValuePair Key="Skippable" Boolean="false"/>
+ <KeyValuePair Key="ScriptName" String="InstantiateItem"/>
+ <KeyValuePair Key="Mail event" String=""/>
+ <KeyValuePair Key="Autostart" Boolean="true"/>
+ <KeyValuePair Key="Repeatable" Boolean="false"/>
+ <KeyValuePair Key="Show time" Boolean="true"/>
+ <KeyValuePair Key="Agent Role" String=""/>
+ <KeyValuePair Key="AlwaysUseOutcome" Boolean="false"/>
+ <KeyValuePair Key="SchemaType" String="NewDevObjectDef"/>
+ </Properties>
+</ActivityDef>
diff --git a/resources/boot/EA/CreateNewLocalObjectDef.xml b/resources/boot/EA/CreateNewLocalObjectDef.xml index 8c8c9c1..840c32d 100644 --- a/resources/boot/EA/CreateNewLocalObjectDef.xml +++ b/resources/boot/EA/CreateNewLocalObjectDef.xml @@ -5,7 +5,7 @@ <KeyValuePair Key="Autostart" Boolean="true"/>
<KeyValuePair Key="Mail Message" String=""/>
<KeyValuePair Key="Mail event" String=""/>
- <KeyValuePair Key="Description" String="CreateNewLocalObjectDef"/>
+ <KeyValuePair Key="Description" String="Create a new C2KLocalObject Definition"/>
<KeyValuePair Key="SchemaVersion" String="0"/>
<KeyValuePair Key="Show time" Boolean="true"/>
<KeyValuePair Key="Viewpoint" String=""/>
diff --git a/resources/boot/EA/EditPropertyDescription.xml b/resources/boot/EA/EditPropertyDescription.xml index f560988..2cbf763 100644 --- a/resources/boot/EA/EditPropertyDescription.xml +++ b/resources/boot/EA/EditPropertyDescription.xml @@ -1 +1,20 @@ -<ActivityDef ID="-1" Name="EditPropertyDescription" Height="0" Width="0" IsLayoutable="false" IsComposite="false"><Properties><KeyValuePair Key="Description" String="Set the initial properties for new instances."/><KeyValuePair Key="Ignorable" Boolean="false"/><KeyValuePair Key="ScriptVersion" String=""/><KeyValuePair Key="Mail Message" String=""/><KeyValuePair Key="Viewpoint" String="last"/><KeyValuePair Key="Agent Name" String=""/><KeyValuePair Key="SchemaVersion" String="0"/><KeyValuePair Key="Skippable" Boolean="false"/><KeyValuePair Key="ScriptName" String=""/><KeyValuePair Key="Mail event" String=""/><KeyValuePair Key="Autostart" Boolean="true"/><KeyValuePair Key="Repeatable" Boolean="false"/><KeyValuePair Key="Show time" Boolean="true"/><KeyValuePair Key="Agent Role" String=""/><KeyValuePair Key="AlwaysUseOutcome" Boolean="false"/><KeyValuePair Key="SchemaType" String="PropertyDescription"/></Properties></ActivityDef>
\ No newline at end of file +<ActivityDef ID="-1" Name="EditPropertyDescription" Height="0" Width="0" IsLayoutable="false" IsComposite="false">
+ <Properties>
+ <KeyValuePair Key="Description" String="Set the initial properties for new instances."/>
+ <KeyValuePair Key="Ignorable" Boolean="false"/>
+ <KeyValuePair Key="ScriptVersion" String=""/>
+ <KeyValuePair Key="Mail Message" String=""/>
+ <KeyValuePair Key="Viewpoint" String="last"/>
+ <KeyValuePair Key="Agent Name" String=""/>
+ <KeyValuePair Key="SchemaVersion" String="0"/>
+ <KeyValuePair Key="Skippable" Boolean="false"/>
+ <KeyValuePair Key="ScriptName" String=""/>
+ <KeyValuePair Key="Mail event" String=""/>
+ <KeyValuePair Key="Autostart" Boolean="true"/>
+ <KeyValuePair Key="Repeatable" Boolean="false"/>
+ <KeyValuePair Key="Show time" Boolean="true"/>
+ <KeyValuePair Key="Agent Role" String=""/>
+ <KeyValuePair Key="AlwaysUseOutcome" Boolean="false"/>
+ <KeyValuePair Key="SchemaType" String="PropertyDescription"/>
+ </Properties>
+</ActivityDef>
diff --git a/resources/boot/EA/SetInstanceWorkflow.xml b/resources/boot/EA/SetInstanceWorkflow.xml index 63f07ea..a9e7d7b 100644 --- a/resources/boot/EA/SetInstanceWorkflow.xml +++ b/resources/boot/EA/SetInstanceWorkflow.xml @@ -1 +1,20 @@ -<ActivityDef ID="-1" Name="SetInstanceWorkflow" Height="0" Width="0" IsLayoutable="false" IsComposite="false"><Properties><KeyValuePair Key="Description" String=""/><KeyValuePair Key="Ignorable" Boolean="false"/><KeyValuePair Key="ScriptVersion" String="0"/><KeyValuePair Key="Mail Message" String=""/><KeyValuePair Key="Viewpoint" String="last"/><KeyValuePair Key="Agent Name" String=""/><KeyValuePair Key="SchemaVersion" String="0"/><KeyValuePair Key="Skippable" Boolean="false"/><KeyValuePair Key="ScriptName" String="SetWorkflow"/><KeyValuePair Key="Mail event" String=""/><KeyValuePair Key="Autostart" Boolean="true"/><KeyValuePair Key="Repeatable" Boolean="false"/><KeyValuePair Key="Show time" Boolean="true"/><KeyValuePair Key="Agent Role" String=""/><KeyValuePair Key="AlwaysUseOutcome" Boolean="false"/><KeyValuePair Key="SchemaType" String="ChooseWorkflow"/></Properties></ActivityDef>
\ No newline at end of file +<ActivityDef ID="-1" Name="SetInstanceWorkflow" Height="0" Width="0" IsLayoutable="false" IsComposite="false">
+ <Properties>
+ <KeyValuePair Key="Description" String="Choose a CompositeActivityDefinition to use for the workflow of new instances"/>
+ <KeyValuePair Key="Ignorable" Boolean="false"/>
+ <KeyValuePair Key="ScriptVersion" String="0"/>
+ <KeyValuePair Key="Mail Message" String=""/>
+ <KeyValuePair Key="Viewpoint" String="last"/>
+ <KeyValuePair Key="Agent Name" String=""/>
+ <KeyValuePair Key="SchemaVersion" String="0"/>
+ <KeyValuePair Key="Skippable" Boolean="false"/>
+ <KeyValuePair Key="ScriptName" String="SetWorkflow"/>
+ <KeyValuePair Key="Mail event" String=""/>
+ <KeyValuePair Key="Autostart" Boolean="true"/>
+ <KeyValuePair Key="Repeatable" Boolean="false"/>
+ <KeyValuePair Key="Show time" Boolean="true"/>
+ <KeyValuePair Key="Agent Role" String=""/>
+ <KeyValuePair Key="AlwaysUseOutcome" Boolean="false"/>
+ <KeyValuePair Key="SchemaType" String="ChooseWorkflow"/>
+ </Properties>
+</ActivityDef>
diff --git a/resources/boot/SC/InstantiateItem.xml b/resources/boot/SC/InstantiateItem.xml index 4cd84b5..0f16a65 100644 --- a/resources/boot/SC/InstantiateItem.xml +++ b/resources/boot/SC/InstantiateItem.xml @@ -2,19 +2,20 @@ <cristalscript>
<output name="errors" type="com.c2kernel.scripting.ErrorInfo"/>
<script language="javascript" name="InstantiateItem"><![CDATA[
+ importClass(Packages.com.c2kernel.lookup.DomainPath);
+ // Load contextual objects
var job = bsf.lookupBean("job");
var item = bsf.lookupBean("item");
var agent = bsf.lookupBean("agent");
var errorBuffer = bsf.lookupBean("errors");
- - var name = job.getOutcome().getDOM().getDocumentElement(). - getElementsByTagName("ObjectName").item(0).getFirstChild().getData(); - var folder = job.getOutcome().getDOM().getDocumentElement(). - getElementsByTagName("SubFolder").item(0).getFirstChild(); - var domPath = "/" + (folder != null?folder.getData():""); - -
var params = new Array(2); +
+ // Get parameters from outcome + var name = job.getOutcome().getField("ObjectName"); + var folder = job.getOutcome().getField("SubFolder"); + var domPath = "/" + (folder != null?folder:""); +
// Create new Item
+ var params = new Array(2); params[0] = name; params[1] = domPath; @@ -24,7 +25,11 @@ errorBuffer.addError("Could not create "+name+": "+e.message); errorBuffer.setFatal(); } - +
+ // If this script is running in the Cristal GUI, open the new item.
+ var tree = Packages.com.c2kernel.gui.MainFrame.treeBrowser;
+ if (tree != null)
+ tree.push(new DomainPath(domPath+"/"+name));
errorBuffer;
]]></script>
</cristalscript>
diff --git a/resources/boot/SC/LocalObjectDefCreator.xml b/resources/boot/SC/LocalObjectDefCreator.xml index cce559e..445a517 100644 --- a/resources/boot/SC/LocalObjectDefCreator.xml +++ b/resources/boot/SC/LocalObjectDefCreator.xml @@ -13,18 +13,17 @@ var agent = bsf.lookupBean("agent");
var errorBuffer = bsf.lookupBean("errors");
var type = job.getActPropString("NewType");
- var name = job.getOutcome().getDOM().getDocumentElement().
- getElementsByTagName("ObjectName").item(0).getFirstChild().getData();
- var folder = job.getOutcome().getDOM().getDocumentElement().
- getElementsByTagName("SubFolder").item(0).getFirstChild();
+ var name = job.getOutcome().getField("ObjectName");
+ var folder = job.getOutcome().getField("SubFolder");
+ // Find the root of that object type
var domPath = Bootstrap.getTypeRoot(type).toString();
if (folder != null) domPath = domPath + "/" + folder.getData();
var params = new Array(2);
params[0] = name;
-
params[1] = domPath;
+ // Create the new item
if (!(errorBuffer.getFatal())) {
try {
agent.execute(item, "CreateItemFromDescription", params);
@@ -34,20 +33,26 @@ }
}
- if (!(errorBuffer.getFatal())) { // store an outcome in the new desc
+ // Store a fresh one in the new item
+ if (!(errorBuffer.getFatal())) {
var newObj;
+ // Activities are serialized new instances
if (type.equals("EA") || type.equals("CA")) {
var newAct = type.equals("CA")?new CompositeActivityDef(): new ActivityDef();
newAct.setName(name);
newObj = CastorXMLUtility.marshall(newAct);
}
- else {
+ else {
+ // Empty schemas and scripts are stored as outcomes of the factory.
var fileType = type.equals("OD")?"Schema":"Script";
newObj = item.getObject("/ViewPoint/"+fileType+"/last").getOutcome().getData();
}
+ // Store the new object with the 'EditDefinition' activity
var newPath = new Packages.com.c2kernel.lookup.DomainPath(domPath+"/"+name);
var newItem = agent.getItem(newPath);
newItem.requestAction(agent.getSystemKey(), "workflow/domain/EditDefinition", 4, newObj);
+
+ // If this script is running in the Cristal GUI, open the new item.
var tree = Packages.com.c2kernel.gui.MainFrame.treeBrowser;
if (tree != null) // open new item in the gui
tree.push(newPath);
diff --git a/resources/boot/SC/SetWorkflow.xml b/resources/boot/SC/SetWorkflow.xml index 0fb2a30..5dbfa6d 100644 --- a/resources/boot/SC/SetWorkflow.xml +++ b/resources/boot/SC/SetWorkflow.xml @@ -9,37 +9,43 @@ var agent = bsf.lookupBean("agent");
var errorBuffer = bsf.lookupBean("errors");
+ // Fetch the requested name from the outcome field
var wfDefName = job.getOutcome().getField("WorkflowDefinitionName"); + // Look up the description
var root = new DomainPath("/desc/ActivityDesc"); var wfItem; try { - var wfPath = root.find(wfDefName); - wfItem = agent.getItem(wfPath); + var wfPath = root.find(wfDefName); + wfItem = agent.getItem(wfPath); } catch (e) { errorBuffer.addError(wfDefName+" is not a valid item"); errorBuffer.setFatal(); } - +
+ // Make sure it has the right properties to be a composite activity desc if (!errorBuffer.getFatal()) { - var itemType = wfItem.getProperty("Type"); - var complex = wfItem.getProperty("Complexity"); - if (!itemType.equals("ActivityDesc")) { - errorBuffer.addError(wfDefName+" is not an activity description"); - errorBuffer.setFatal(); - } - if (!complex.equals("Composite")) { - errorBuffer.addError(wfDefName+" is not a composite activity description"); - errorBuffer.setFatal(); - } + var itemType = wfItem.getProperty("Type"); + var complex = wfItem.getProperty("Complexity"); + if (!itemType.equals("ActivityDesc")) { + errorBuffer.addError(wfDefName+" is not an activity description"); + errorBuffer.setFatal(); + } + if (!complex.equals("Composite")) { + errorBuffer.addError(wfDefName+" is not a composite activity description"); + errorBuffer.setFatal(); + } } - +
if (!errorBuffer.getFatal()) { - var coll = item.getObject("/Collection/Workflow"); - if (coll.size() > 0) { - var member = coll.getMembers().list.get(0); - coll.removeMember(member.getID()); - } - coll.addMember(wfItem.getSystemKey()); - var params = new Array(1); - params[0] = agent.marshall(coll); - agent.execute(item, "AddC2KObject", params); + // Fetch the 'Workflow' collection
+ var coll = item.getObject("/Collection/Workflow"); + if (coll.size() > 0) { // if there's already a member, remove it + var member = coll.getMembers().list.get(0); + coll.removeMember(member.getID()); + } + // add the new member
+ coll.addMember(wfItem.getSystemKey()); + // save it back to the item + var params = new Array(1); + params[0] = agent.marshall(coll); + agent.execute(item, "AddC2KObject", params); } errorBuffer;
diff --git a/src/module.xml b/src/module.xml index bbf7109..83bc461 100644 --- a/src/module.xml +++ b/src/module.xml @@ -2,7 +2,7 @@ <CristalModule ns="dev" name="CristalDev" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Info>
<Description>CRISTAL Development Items, such as resource factories and workflows. Also includes a demonstrative description factory</Description>
- <Version>0.1</Version>
+ <Version>0.2</Version>
</Info>
<ResourceURL>ch/cern/cristaldev/resources/</ResourceURL>
<Imports>
|
