summaryrefslogtreecommitdiff
path: root/src/main/resources/boot/SC/LocalObjectDefCreator.xml
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2012-06-04 15:37:34 +0200
committerAndrew Branson <andrew.branson@cern.ch>2012-06-04 15:37:34 +0200
commit388a76a73c8a8131c7af8df2ba03cf16511c8ea5 (patch)
tree473206237625785b7828dd73c7e7be8b184bfba0 /src/main/resources/boot/SC/LocalObjectDefCreator.xml
parenteac30db6329f05cc7cf2a35613497e357b4db3aa (diff)
Mavenized
Diffstat (limited to 'src/main/resources/boot/SC/LocalObjectDefCreator.xml')
-rw-r--r--src/main/resources/boot/SC/LocalObjectDefCreator.xml54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main/resources/boot/SC/LocalObjectDefCreator.xml b/src/main/resources/boot/SC/LocalObjectDefCreator.xml
new file mode 100644
index 0000000..32b154c
--- /dev/null
+++ b/src/main/resources/boot/SC/LocalObjectDefCreator.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cristalscript>
+ <output name="errors" type="com.c2kernel.scripting.ErrorInfo"/>
+ <script language="javascript" name="LocalObjectDefCreator"><![CDATA[
+ importClass(Packages.com.c2kernel.utils.CastorXMLUtility);
+ importClass(Packages.com.c2kernel.utils.Resource);
+ importClass(Packages.com.c2kernel.process.Bootstrap);
+ importClass(Packages.com.c2kernel.lifecycle.CompositeActivityDef);
+ importClass(Packages.com.c2kernel.lifecycle.ActivityDef);
+
+ var type = job.getActPropString("NewType");
+ 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
+ try {
+ agent.execute(item, "CreateItemFromDescription", params);
+ } catch (e) {
+ throw "Could not create "+name+": "+e.message;
+ }
+
+ // Store a fresh one in the new item
+
+ 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 {
+ // 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);
+
+ ]]></script>
+</cristalscript>