diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-07-06 15:50:45 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-07-06 15:50:45 +0200 |
| commit | b53164978a9a264fbe26679c07e32731a4d495f9 (patch) | |
| tree | b0f0335625c4ee11012d51df3da5daae270bdd2f /src | |
| parent | 24314dc1699c7e73048fa24e33729f1aa1ec0e86 (diff) | |
Remove XML parsing from module processing, use Castor unmarshalling
instead.
Create module item with collection of imported Items and module XML
registered as an outcome.
Diffstat (limited to 'src')
14 files changed, 186 insertions, 259 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Aggregation.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Aggregation.java index 88d9249..40e0604 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Aggregation.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Aggregation.java @@ -2,9 +2,6 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation; import java.util.ArrayList;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.graph.model.GraphPoint;
@@ -29,17 +26,6 @@ public class Aggregation implements java.io.Serializable { this.isDescription = isDescription;
}
- public Aggregation(Element agg) {
- name = agg.getAttribute("name");
- isDescription = agg.getAttribute("isDescription").equals("true");
- NodeList depmemnl = agg.getElementsByTagName("AggregationMember");
- for (int k=0; k<depmemnl.getLength(); k++) {
- Element memElem = (Element)depmemnl.item(k);
- AggregationMember newAggMem = new AggregationMember(memElem);
- aggregationMemberList.add(newAggMem);
- }
- }
-
public com.c2kernel.collection.Aggregation create() throws MembershipException, ObjectNotFoundException {
com.c2kernel.collection.Aggregation newAgg = isDescription?new com.c2kernel.collection.AggregationDescription(name):new com.c2kernel.collection.AggregationInstance(name);
newAgg.setName(name);
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/AggregationMember.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/AggregationMember.java index 64215da..82c0437 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/AggregationMember.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/AggregationMember.java @@ -1,9 +1,5 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
import com.c2kernel.utils.CastorHashMap;
import com.c2kernel.utils.KeyValuePair;
@@ -27,19 +23,6 @@ public class AggregationMember implements java.io.Serializable { this.geometry = geometry;
}
- public AggregationMember(Element memElem) {
- Element geom = (Element)memElem.getElementsByTagName("Geometry").item(0);
- this.slotNo = Integer.parseInt(memElem.getAttribute("slotNo"));
- this.itemDescriptionPath = memElem.getAttribute("itemDescriptionPath");
- this.itemPath = memElem.getAttribute("itemPath");
- this.geometry = new Geometry(Integer.parseInt(geom.getAttribute("x")), Integer.parseInt(geom.getAttribute("y")),
- Integer.parseInt(geom.getAttribute("width")), Integer.parseInt(geom.getAttribute("height")));
- NodeList cmpnl = memElem.getElementsByTagName("MemberProperty");
- for (int l=0; l<cmpnl.getLength(); l++) {
- Element p = (Element)cmpnl.item(l);
- props.put(p.getAttribute("name"), ((Text)p.getFirstChild()).getData());
- }
- }
public KeyValuePair[] getKeyValuePairs() {
return props.getKeyValuePairs();
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java index a0d7a1e..9cb3894 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java @@ -2,10 +2,6 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation; import java.util.ArrayList;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.DomainPath;
@@ -14,6 +10,7 @@ import com.c2kernel.property.PropertyDescriptionList; import com.c2kernel.property.PropertyUtility;
import com.c2kernel.utils.CastorHashMap;
import com.c2kernel.utils.KeyValuePair;
+import com.c2kernel.utils.Logger;
public class Dependency implements java.io.Serializable {
@@ -22,32 +19,16 @@ public class Dependency implements java.io.Serializable { public String itemDescriptionPath;
public ArrayList<DependencyMember> dependencyMemberList = new ArrayList<DependencyMember>();
public CastorHashMap props = new CastorHashMap();
- Element elem;
public Dependency() {
super();
}
- public Dependency(String itemDesc) {
+ public Dependency(String name) {
this();
- this.itemDescriptionPath = itemDesc;
+ this.name = name;
}
- public Dependency(Element dep) {
- elem = dep;
- name = dep.getAttribute("name");
- isDescription = dep.getAttribute("isDescription").equals("true");
- NodeList cpnl = dep.getElementsByTagName("CollectionProperty");
- for (int k=0; k<cpnl.getLength(); k++) {
- Element p = (Element)cpnl.item(k);
- props.put(p.getAttribute("name"), ((Text)p.getFirstChild()).getData());
- }
- NodeList depmemnl = dep.getElementsByTagName("DependencyMember");
- for (int k=0; k<depmemnl.getLength(); k++) {
- Element p = (Element)depmemnl.item(k);
- dependencyMemberList.add(new DependencyMember(p));
- }
- }
public KeyValuePair[] getKeyValuePairs() {
return props.getKeyValuePairs();
}
@@ -62,6 +43,7 @@ public class Dependency implements java.io.Serializable { public com.c2kernel.collection.Dependency create() throws MembershipException, ObjectNotFoundException {
com.c2kernel.collection.Dependency newDep = isDescription?new com.c2kernel.collection.DependencyDescription(name):new com.c2kernel.collection.Dependency(name);
if (itemDescriptionPath != null && itemDescriptionPath.length()>0) {
+ Logger.debug(itemDescriptionPath);
PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getSysKey());
StringBuffer classProps = new StringBuffer();
for (PropertyDescription pd : propList.list) {
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/DependencyMember.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/DependencyMember.java index e20fe8b..573cdc8 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/DependencyMember.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/DependencyMember.java @@ -1,10 +1,6 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
import com.c2kernel.utils.CastorHashMap;
import com.c2kernel.utils.KeyValuePair;
@@ -23,14 +19,6 @@ public class DependencyMember implements java.io.Serializable { }
- public DependencyMember(Element elem) {
- itemPath = elem.getAttribute("itemPath");
- NodeList cmpnl = elem.getElementsByTagName("MemberProperty");
- for (int l=0; l<cmpnl.getLength(); l++) {
- Element p = (Element)cmpnl.item(l);
- props.put(p.getAttribute("name"), ((Text)p.getFirstChild()).getData());
- }
- }
public KeyValuePair[] getKeyValuePairs() {
return props.getKeyValuePairs();
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java index 07d2250..f13bced 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java @@ -3,10 +3,6 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation; import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
import com.c2kernel.common.CannotManageException;
import com.c2kernel.common.ObjectAlreadyExistsException;
import com.c2kernel.common.ObjectCannotBeUpdated;
@@ -15,7 +11,6 @@ import com.c2kernel.entity.agent.ActiveEntity; import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.RolePath;
import com.c2kernel.process.Gateway;
-import com.c2kernel.process.module.Module;
import com.c2kernel.process.module.ModuleImport;
import com.c2kernel.property.Property;
import com.c2kernel.property.PropertyArrayList;
@@ -29,29 +24,13 @@ public class NewAgent extends ModuleImport implements java.io.Serializable { public ArrayList<Property> properties = new ArrayList<Property>();
public NewAgent() {
- super(null);
}
public NewAgent(String name, String password) {
- super(null);
this.name = name;
this.password = password;
}
- public NewAgent(Element imp) {
- super(imp);
- password = imp.getAttribute("password");
- NodeList rolenl = imp.getElementsByTagName("Role");
- for (int j=0; j<rolenl.getLength(); j++) {
- roles.add(((Text)rolenl.item(j).getFirstChild()).getData());
- }
- NodeList pnl = imp.getElementsByTagName("Property");
- for (int j=0; j<pnl.getLength(); j++) {
- Element p = (Element)pnl.item(j);
- properties.add(Module.newProperty(p));
- }
- }
-
public void create(int agentId) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException, CannotManageException, ObjectAlreadyExistsException {
AgentPath newAgent = Gateway.getLDAPLookup().getNextKeyManager().generateNextAgentKey();
newAgent.setAgentName(name);
@@ -78,4 +57,9 @@ public class NewAgent extends ModuleImport implements java.io.Serializable { }
}
+
+ @Override
+ public String getPath(String ns) {
+ return null;
+ }
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java index 050615f..caa53e4 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java @@ -3,10 +3,6 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation; import java.util.ArrayList;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.CannotManageException;
import com.c2kernel.common.ObjectAlreadyExistsException;
@@ -23,13 +19,11 @@ import com.c2kernel.lookup.EntityPath; import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Viewpoint;
import com.c2kernel.process.Gateway;
-import com.c2kernel.process.module.Module;
import com.c2kernel.process.module.ModuleImport;
import com.c2kernel.property.Property;
import com.c2kernel.property.PropertyArrayList;
import com.c2kernel.utils.LocalObjectLoader;
import com.c2kernel.utils.Logger;
-import com.c2kernel.utils.Resource;
/**
* Complete Structure for new item
@@ -45,10 +39,9 @@ public class NewItem extends ModuleImport { public ArrayList<Aggregation> aggregationList = new ArrayList<Aggregation>();
public ArrayList<Dependency> dependencyList = new ArrayList<Dependency>();
public ArrayList<Outcome> outcomes = new ArrayList<Outcome>();
- public String ns;
+ private String ns;
public NewItem() {
- super(null);
}
public NewItem(String name, String initialPath, String wf) {
@@ -58,41 +51,13 @@ public class NewItem extends ModuleImport { this.workflow = wf;
}
- public NewItem(String ns, Element elem) {
- super(elem);
+ public void setNamespace(String ns) {
this.ns = ns;
- workflow = elem.getAttribute("workflow");
- if (elem.hasAttribute("initialPath"))
- initialPath = elem.getAttribute("initialPath");
- else
- initialPath = "/desc/"+ns;
- NodeList pnl = elem.getElementsByTagName("Property");
- for (int j=0; j<pnl.getLength(); j++) {
- Element p = (Element)pnl.item(j);
- properties.add(Module.newProperty(p));
- }
- NodeList ocnl = elem.getElementsByTagName("Outcome");
- for (int j=0; j<ocnl.getLength(); j++) {
- Element oc = (Element)ocnl.item(j);
- outcomes.add(new Outcome(oc.getAttribute("schema"), oc.getAttribute("version"), oc.getAttribute("viewname"), ((Text)oc.getFirstChild()).getData()));
- }
-
- NodeList depnl = elem.getElementsByTagName("Dependency");
- for (int j=0; j<depnl.getLength(); j++) {
- Element dep = (Element)depnl.item(j);
- Dependency newDep = new Dependency(dep);
- dependencyList.add(newDep);
- }
- NodeList aggnl = elem.getElementsByTagName("Aggregation");
- for (int j=0; j<aggnl.getLength(); j++) {
- Element agg = (Element)aggnl.item(j);
- Aggregation newAgg = new Aggregation(agg);
- aggregationList.add(newAgg);
- }
+ if (initialPath == null) initialPath = "/desc/"+ns;
}
-
- public void setNs(String ns) {
- this.ns = ns;
+
+ public String getNamespace() {
+ return ns;
}
public void create(int agentId) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException {
@@ -127,9 +92,8 @@ public class NewItem extends ModuleImport { History hist = new History(entPath.getSysKey(), null);
for (Outcome thisOutcome : outcomes) {
- String data = Resource.getTextResource(ns, thisOutcome.path);
Event newEvent = hist.addEvent("system", "Admin", Transitions.DONE, "Import", "Import", "Import", States.FINISHED);
- com.c2kernel.persistency.outcome.Outcome newOutcome = new com.c2kernel.persistency.outcome.Outcome(newEvent.getID(), data, thisOutcome.schema, thisOutcome.version);
+ com.c2kernel.persistency.outcome.Outcome newOutcome = new com.c2kernel.persistency.outcome.Outcome(newEvent.getID(), thisOutcome.getData(ns), thisOutcome.schema, thisOutcome.version);
Viewpoint newLastView = new Viewpoint(entPath.getSysKey(), thisOutcome.schema, thisOutcome.viewname, thisOutcome.version, newEvent.getID());
try {
Gateway.getStorage().put(entPath.getSysKey(), newOutcome, null);
@@ -168,4 +132,10 @@ public class NewItem extends ModuleImport { domPath.setEntity(entPath);
Gateway.getLDAPLookup().add(domPath);
}
+
+ @Override
+ public String getPath(String ns) {
+ setNamespace(ns);
+ return initialPath;
+ }
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Outcome.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Outcome.java index c0e62ec..a8431de 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Outcome.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Outcome.java @@ -1,7 +1,10 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.utils.Resource;
+
public class Outcome {
- public String schema, viewname, path;
+ public String schema, viewname, path, data;
public int version;
public Outcome() {
@@ -14,5 +17,11 @@ public class Outcome { this.viewname = viewname;
this.path = path;
}
+
+ public String getData(String ns) throws ObjectNotFoundException {
+ if (data == null)
+ data = Resource.getTextResource(ns, path);
+ return data;
+ }
}
diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java index 22f4543..4a0987a 100644 --- a/src/main/java/com/c2kernel/process/module/Module.java +++ b/src/main/java/com/c2kernel/process/module/Module.java @@ -1,26 +1,19 @@ package com.c2kernel.process.module;
-import java.io.StringReader;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Properties;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-
import com.c2kernel.common.CannotManageException;
import com.c2kernel.common.ObjectAlreadyExistsException;
import com.c2kernel.common.ObjectCannotBeUpdated;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.proxy.ItemProxy;
+import com.c2kernel.lifecycle.instance.predefined.entitycreation.Dependency;
+import com.c2kernel.lifecycle.instance.predefined.entitycreation.DependencyMember;
import com.c2kernel.lifecycle.instance.predefined.entitycreation.NewAgent;
import com.c2kernel.lifecycle.instance.predefined.entitycreation.NewItem;
+import com.c2kernel.lifecycle.instance.predefined.entitycreation.Outcome;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.process.Bootstrap;
import com.c2kernel.process.Gateway;
@@ -37,109 +30,12 @@ public class Module { public ModuleImports imports = new ModuleImports();
public ArrayList<ModuleConfig> config = new ArrayList<ModuleConfig>();
public ArrayList<ModuleScript> scripts = new ArrayList<ModuleScript>();
- private static DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- private DocumentBuilder parser;
- private Document moduleDOM;
+ public NewItem moduleItem;
- static {
- dbf.setValidating(false);
- dbf.setNamespaceAware(false);
- }
-
public Module() {
super();
}
- public Module(String moduleXML) throws ModuleException {
- try {
- parser = dbf.newDocumentBuilder();
- moduleDOM = parser.parse(new InputSource(new StringReader(moduleXML)));
- } catch (Exception e) {
- Logger.error(e);
- throw new ModuleException("Could not process modules. XML Parser exception");
- }
-
- Element root = (Element)moduleDOM.getElementsByTagName("CristalModule").item(0);
-
- // Get module metadata
- ns = root.getAttribute("ns");
- name = root.getAttribute("name");
-
- Element infoElem = (Element)moduleDOM.getElementsByTagName("Info").item(0);
- info = new ModuleInfo();
- info.desc = ((Text)infoElem.getElementsByTagName("Description").item(0).getFirstChild()).getData();
- info.version = ((Text)infoElem.getElementsByTagName("Version").item(0).getFirstChild()).getData();
- NodeList nl = infoElem.getElementsByTagName("Dependency");
- for (int i=0; i<nl.getLength();i++)
- info.dependency.add(((Text)nl.item(i).getFirstChild()).getData());
-
- // register resource URL
- nl = root.getElementsByTagName("ResourceURL");
- if (nl.getLength()>0) {
- resURL = ((Text)nl.item(0).getFirstChild()).getData();
- Resource.addModuleBaseURL(ns, resURL);
- }
-
- // Get config properties
- nl = root.getElementsByTagName("Config");
- for (int i=0; i<nl.getLength();i++) {
- Element confElement = (Element)nl.item(i);
- String target = confElement.getAttribute("target");
- String name = confElement.getAttribute("name");
- String value = ((Text)confElement.getFirstChild()).getData();
- config.add(new ModuleConfig(name, value, target));
- }
-
- // find scripts
- nl = root.getElementsByTagName("Script");
- for (int i=0; i<nl.getLength();i++) {
- Element confElement = (Element)nl.item(i);
- String target = confElement.getAttribute("target");
- String event = confElement.getAttribute("event");
- String lang = confElement.getAttribute("lang");
- scripts.add(new ModuleScript(target, event, lang, ((Text)confElement.getFirstChild()).getData()));
- }
-
- // Get imports
- nl = moduleDOM.getElementsByTagName("Imports");
- if (nl.getLength()>0) {
- Element impElem = (Element)nl.item(0);
- nl = impElem.getChildNodes();
- for (int i=0; i<nl.getLength();i++) {
- if (!(nl.item(i) instanceof Element)) continue;
- Element imp = (Element)nl.item(i);
- ModuleImport newImp;
- String type = imp.getTagName();
- if (type.equals("Resource")) {
- ModuleResource newRes = new ModuleResource(imp);
- newImp = newRes;
- }
- else if (type.equals("Item")) {
- NewItem newItem = new NewItem(ns, imp);
- newImp = newItem;
- }
- else if (type.equals("Agent")) {
- NewAgent newAgent = new NewAgent(imp);
- newImp = newAgent;
- }
- else {
- Logger.warning("Unknown import type "+type);
- continue;
- }
-
- newImp.name = imp.getAttribute("name");
- imports.list.add(newImp);
- Logger.msg(8, "Found import "+imports.list.size()+"- "+newImp.name+": "+newImp.getClass().getSimpleName());
-
- }
- }
-
- }
-
- public static com.c2kernel.property.Property newProperty(Element p) {
- return new com.c2kernel.property.Property(p.getAttribute("name"), ((Text)p.getFirstChild()).getData());
- }
-
public void runScript(String event, boolean isServer) throws ScriptingEngineException {
for (ModuleScript script : scripts) {
if (script.shouldRun(event, isServer)) {
@@ -156,7 +52,31 @@ public class Module { }
}
- public void importAll(ItemProxy serverEntity) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException, NoSuchAlgorithmException {
+ public void addModuleItem(String moduleXML) {
+ NewItem moduleItem = new NewItem(name, "/desc/modules/", "ModuleWorkflow");
+ // Module properties
+ moduleItem.properties.add(new com.c2kernel.property.Property("Namespace", ns));
+ moduleItem.properties.add(new com.c2kernel.property.Property("Name", name));
+ moduleItem.properties.add(new com.c2kernel.property.Property("Type", "Module"));
+ moduleItem.properties.add(new com.c2kernel.property.Property("Version", info.version));
+ // Add dependency for all children
+ Dependency children = new Dependency("Contents");
+ for (ModuleImport thisImport : imports.list) {
+ String path = thisImport.getPath(ns);
+ if (path != null)
+ children.dependencyMemberList.add(
+ new DependencyMember(path+"/"+thisImport.name));
+ }
+ moduleItem.dependencyList.add(children);
+ // Add moduleXML
+ Outcome moduleOutcome = new Outcome("Module", "0", "last", null);
+ moduleOutcome.data = moduleXML;
+ moduleItem.outcomes.add(moduleOutcome);
+ imports.list.add(moduleItem);
+ }
+
+ public void importAll(ItemProxy serverEntity, String moduleXML) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException, NoSuchAlgorithmException {
+ addModuleItem(moduleXML);
for (ModuleImport thisImp : imports.list) {
Logger.msg(5, "Importing "+thisImp.name+" "+thisImp.getClass().getSimpleName());
if (thisImp instanceof ModuleResource) {
@@ -169,7 +89,7 @@ public class Module { }
else if (thisImp instanceof NewItem) {
NewItem thisItem = (NewItem)thisImp;
- thisItem.ns=ns;
+ thisItem.setNamespace(ns);
try {
new DomainPath(new DomainPath(thisItem.initialPath), thisItem.name).getEntity();
Logger.msg(3, "Module.importAll() - Item '"+thisItem.name+"' found.");
diff --git a/src/main/java/com/c2kernel/process/module/ModuleImport.java b/src/main/java/com/c2kernel/process/module/ModuleImport.java index 60193c7..422b3d2 100644 --- a/src/main/java/com/c2kernel/process/module/ModuleImport.java +++ b/src/main/java/com/c2kernel/process/module/ModuleImport.java @@ -1,13 +1,9 @@ package com.c2kernel.process.module;
-import org.w3c.dom.Element;
-
public abstract class ModuleImport {
- Element elem;
public String name;
- public ModuleImport(Element elem) {
- this.elem = elem;
- }
+ public abstract String getPath(String ns);
+
}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/process/module/ModuleManager.java b/src/main/java/com/c2kernel/process/module/ModuleManager.java index ca47ec9..0870c6f 100644 --- a/src/main/java/com/c2kernel/process/module/ModuleManager.java +++ b/src/main/java/com/c2kernel/process/module/ModuleManager.java @@ -4,6 +4,7 @@ import java.net.URL; import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Properties;
import com.c2kernel.common.CannotManageException;
@@ -16,9 +17,11 @@ import com.c2kernel.process.Gateway; import com.c2kernel.scripting.ScriptingEngineException;
import com.c2kernel.utils.FileStringUtility;
import com.c2kernel.utils.Logger;
+import com.c2kernel.utils.Resource;
public class ModuleManager {
ArrayList<Module> modules = new ArrayList<Module>();
+ HashMap<String, String> modulesXML = new HashMap<String, String>();
Properties props = new Properties();
boolean isServer;
@@ -29,10 +32,11 @@ public class ModuleManager { while(moduleEnum.hasMoreElements()) {
URL newModuleURL = moduleEnum.nextElement();
try {
- //Module newModule = (Module)Gateway.getMarshaller().unmarshall(FileStringUtility.url2String(newModuleURL));
- //Resource.addModuleBaseURL(newModule.ns, newModule.resURL);
- Module newModule = new Module(FileStringUtility.url2String(newModuleURL));
+ String moduleXML = FileStringUtility.url2String(newModuleURL);
+ Module newModule = (Module)Gateway.getMarshaller().unmarshall(moduleXML);
+ Resource.addModuleBaseURL(newModule.ns, newModule.resURL);
modules.add(newModule);
+ modulesXML.put(newModule.ns, moduleXML);
if (loadedModules.contains(newModule.getName())) throw new ModuleException("Module name clash: "+newModule.getName());
if (moduleNs.contains(newModule.getNs())) throw new ModuleException("Module namespace clash: "+newModule.getNs());
Logger.debug(4, "Module found: "+newModule.getNs()+" - "+newModule.getName());
@@ -96,7 +100,7 @@ public class ModuleManager { Logger.debug(3, "Registering modules");
for (Module thisMod : modules) {
Logger.msg("Registering module "+thisMod.getName());
- thisMod.importAll(serverEntity);
+ thisMod.importAll(serverEntity, modulesXML.get(thisMod.ns));
Logger.msg("Module "+thisMod.getName()+" registered");
}
}
diff --git a/src/main/java/com/c2kernel/process/module/ModuleResource.java b/src/main/java/com/c2kernel/process/module/ModuleResource.java index f355f6f..274e522 100644 --- a/src/main/java/com/c2kernel/process/module/ModuleResource.java +++ b/src/main/java/com/c2kernel/process/module/ModuleResource.java @@ -1,21 +1,23 @@ package com.c2kernel.process.module;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-
public class ModuleResource extends ModuleImport {
public String resourceType;
public String resourceLocation;
public ModuleResource() {
- super(null);
}
- public ModuleResource(Element elem) {
- super(elem);
- resourceType = elem.getAttribute("type");
- resourceLocation = ((Text)elem.getFirstChild()).getData();
+ @Override
+ public String getPath(String ns) {
+ StringBuffer path = new StringBuffer();
+ if (resourceType.equals("CA") || resourceType.equals("EA"))
+ path.append("/desc/ActivityDesc/");
+ if (resourceType.equals("SC"))
+ path.append("/desc/Script/");
+ if (resourceType.equals("OD"))
+ path.append("/desc/OutcomeDesc/");
+ path.append("system/").append(ns==null?"kernel":ns);
+ return path.toString();
}
-
}
\ No newline at end of file diff --git a/src/main/resources/boot/CA/ModuleWorkflow.xml b/src/main/resources/boot/CA/ModuleWorkflow.xml new file mode 100644 index 0000000..20ce685 --- /dev/null +++ b/src/main/resources/boot/CA/ModuleWorkflow.xml @@ -0,0 +1,100 @@ +<CompositeActivityDef ID="-1" Name="ModuleWorkflow" Height="0" Width="0" IsLayoutable="false" IsComposite="true">
+ <childrenGraphModel>
+ <GraphModelCastorData StartVertexId="1" NextId="8">
+ <JoinDef ID="6" Name="" Height="24" Width="60" IsLayoutable="true" IsComposite="false">
+ <CentrePoint x="308" y="379"/>
+ <OutlinePoint x="278" y="367"/>
+ <OutlinePoint x="338" y="367"/>
+ <OutlinePoint x="338" y="391"/>
+ <OutlinePoint x="278" y="391"/>
+ <InEdgeId>7</InEdgeId>
+ <Properties>
+ <KeyValuePair Key="Type" String="Join"/>
+ </Properties>
+ </JoinDef>
+ <LoopDef ID="2" Name="" Height="24" Width="60" IsLayoutable="true" IsComposite="false" isNext="0">
+ <CentrePoint x="322" y="286"/>
+ <OutlinePoint x="292" y="274"/>
+ <OutlinePoint x="352" y="274"/>
+ <OutlinePoint x="352" y="298"/>
+ <OutlinePoint x="292" y="298"/>
+ <InEdgeId>4</InEdgeId>
+ <OutEdgeId>5</OutEdgeId>
+ <OutEdgeId>7</OutEdgeId>
+ <Properties>
+ <KeyValuePair Key="LastNum" String="2"/>
+ <KeyValuePair Key="RoutingScriptName" String=""/>
+ <KeyValuePair Key="RoutingScriptVersion" String=""/>
+ </Properties>
+ </LoopDef>
+ <JoinDef ID="1" Name="" Height="24" Width="60" IsLayoutable="true" IsComposite="false">
+ <CentrePoint x="308" y="42"/>
+ <OutlinePoint x="278" y="30"/>
+ <OutlinePoint x="338" y="30"/>
+ <OutlinePoint x="338" y="54"/>
+ <OutlinePoint x="278" y="54"/>
+ <InEdgeId>5</InEdgeId>
+ <OutEdgeId>3</OutEdgeId>
+ <Properties>
+ <KeyValuePair Key="Type" String="Join"/>
+ </Properties>
+ </JoinDef>
+ <ActivitySlotDef ID="0" Name="EditModuleDefinition slot" Height="60" Width="130" IsLayoutable="true" IsComposite="false">
+ <CentrePoint x="206" y="151"/>
+ <OutlinePoint x="141" y="121"/>
+ <OutlinePoint x="271" y="121"/>
+ <OutlinePoint x="271" y="181"/>
+ <OutlinePoint x="141" y="181"/>
+ <InEdgeId>3</InEdgeId>
+ <OutEdgeId>4</OutEdgeId>
+ <Properties>
+ <KeyValuePair Key="Name" String="EditModuleDefinition"/>
+ <KeyValuePair Key="Version" String="0"/>
+ </Properties>
+ <activityDef>EditModuleDefinition</activityDef>
+ </ActivitySlotDef>
+ <NextDef ID="5" OriginVertexId="2" TerminusVertexId="1">
+ <OriginPoint x="322" y="286"/>
+ <TerminusPoint x="308" y="42"/>
+ <Properties>
+ <KeyValuePair Key="Alias" String="true"/>
+ </Properties>
+ </NextDef>
+ <NextDef ID="4" OriginVertexId="0" TerminusVertexId="2">
+ <OriginPoint x="206" y="151"/>
+ <TerminusPoint x="322" y="286"/>
+ <Properties/>
+ </NextDef>
+ <NextDef ID="3" OriginVertexId="1" TerminusVertexId="0">
+ <OriginPoint x="308" y="42"/>
+ <TerminusPoint x="206" y="151"/>
+ <Properties/>
+ </NextDef>
+ <NextDef ID="7" OriginVertexId="2" TerminusVertexId="6">
+ <OriginPoint x="322" y="286"/>
+ <TerminusPoint x="308" y="379"/>
+ <Properties>
+ <KeyValuePair Key="Alias" String="false"/>
+ </Properties>
+ </NextDef>
+ </GraphModelCastorData>
+ </childrenGraphModel>
+ <Properties>
+ <KeyValuePair Key="Description" String=""/>
+ <KeyValuePair Key="Ignorable" Boolean="false"/>
+ <KeyValuePair Key="ScriptVersion" String=""/>
+ <KeyValuePair Key="Mail Message" String=""/>
+ <KeyValuePair Key="Viewpoint" String=""/>
+ <KeyValuePair Key="Agent Name" String=""/>
+ <KeyValuePair Key="SchemaVersion" String=""/>
+ <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=""/>
+ </Properties>
+</CompositeActivityDef>
\ No newline at end of file diff --git a/src/main/resources/boot/EA/EditModuleDefinition.xml b/src/main/resources/boot/EA/EditModuleDefinition.xml new file mode 100644 index 0000000..04afe4d --- /dev/null +++ b/src/main/resources/boot/EA/EditModuleDefinition.xml @@ -0,0 +1 @@ +<ActivityDef ID="-1" Name="EditModuleDefinition" Height="0" Width="0" IsLayoutable="false" IsComposite="false"><Properties><KeyValuePair Key="Description" String=""/><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="Module"/></Properties></ActivityDef>
\ No newline at end of file diff --git a/src/main/resources/boot/allbootitems.txt b/src/main/resources/boot/allbootitems.txt index 09a98b8..810d5ee 100644 --- a/src/main/resources/boot/allbootitems.txt +++ b/src/main/resources/boot/allbootitems.txt @@ -13,8 +13,10 @@ EA/EditSchema EA/EditScriptDefinition
EA/CreateNewItem
EA/CreateNewAgent
+EA/EditModuleDefinition
CA/NoWorkflow
CA/ServerItemWorkflow
+CA/ModuleWorkflow
CA/ManageCompositeActDef
CA/ManageElementaryActDef
CA/ManageSchema
|
