summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java56
1 files changed, 13 insertions, 43 deletions
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;
+ }
}