diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-07-06 11:00:24 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-07-06 11:00:24 +0200 |
| commit | 24314dc1699c7e73048fa24e33729f1aa1ec0e86 (patch) | |
| tree | c97af82997783b860c36f4410973b23caff0d42e /src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java | |
| parent | cc79e98c4763affba4fa2e17dfe5a412f9de66c3 (diff) | |
Modules serialize with Castor. Just about to remove the parsing.
CastorXMLUtility is now a static member of gateway. Domain specific
instances can be used by domain applications, but the maps do not
interfere with the kernel.
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java | 39 |
1 files changed, 34 insertions, 5 deletions
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 5993f62..a0d7a1e 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,6 +2,10 @@ 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;
@@ -9,17 +13,19 @@ import com.c2kernel.property.PropertyDescription; import com.c2kernel.property.PropertyDescriptionList;
import com.c2kernel.property.PropertyUtility;
import com.c2kernel.utils.CastorHashMap;
+import com.c2kernel.utils.KeyValuePair;
public class Dependency implements java.io.Serializable {
public String name;
public boolean isDescription;
public String itemDescriptionPath;
- public ArrayList<DependencyMember> dependencyMemberList;
+ public ArrayList<DependencyMember> dependencyMemberList = new ArrayList<DependencyMember>();
+ public CastorHashMap props = new CastorHashMap();
+ Element elem;
public Dependency() {
super();
- dependencyMemberList = new ArrayList<DependencyMember>();
}
public Dependency(String itemDesc) {
@@ -27,14 +33,36 @@ public class Dependency implements java.io.Serializable { this.itemDescriptionPath = itemDesc;
}
- /**
+ 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();
+ }
+
+ public void setKeyValuePairs(KeyValuePair[] pairs) {
+ props.setKeyValuePairs(pairs);
+ }
+
+ /**
* @return
*/
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) {
PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getSysKey());
- CastorHashMap props = new CastorHashMap();
StringBuffer classProps = new StringBuffer();
for (PropertyDescription pd : propList.list) {
props.put(pd.getName(), pd.getDefaultValue());
@@ -49,7 +77,8 @@ public class Dependency implements java.io.Serializable { int syskey = new DomainPath(thisMem.itemPath).getSysKey();
if (syskey == -1)
throw new MembershipException("Cannot find "+thisMem.itemPath+" specified for collection.");
- newDep.addMember(syskey);
+ com.c2kernel.collection.DependencyMember newDepMem = newDep.addMember(syskey);
+ newDepMem.getProperties().putAll(thisMem.props);
}
return newDep;
}
|
