summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/predefined
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2012-06-22 10:11:17 +0200
committerAndrew Branson <andrew.branson@cern.ch>2012-06-22 10:11:17 +0200
commit0baa46d5ee4f62adb58f436af4978d9468454870 (patch)
treecb88cda1ed564b8bb445fd4180728fd0db25192f /src/main/java/com/c2kernel/lifecycle/instance/predefined
parente0b01f55e2be314ee60df092aa75f34c5f4cb8f2 (diff)
Modules and entitycreation support Aggregations, collection properties
and class identifiers
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Aggregation.java33
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java19
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java5
3 files changed, 51 insertions, 6 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 2de12e0..b99e898 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,6 +2,15 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation;
import java.util.ArrayList;
+import com.c2kernel.collection.MembershipException;
+import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.property.PropertyDescription;
+import com.c2kernel.property.PropertyDescriptionList;
+import com.c2kernel.property.PropertyUtility;
+import com.c2kernel.utils.CastorHashMap;
+
public class Aggregation implements java.io.Serializable {
public boolean isDescription;
@@ -19,7 +28,27 @@ public class Aggregation implements java.io.Serializable {
this.isDescription = isDescription;
}
- public com.c2kernel.collection.Aggregation create() {
- return new com.c2kernel.collection.AggregationInstance();
+ 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);
+ for (AggregationMember thisMem : aggregationMemberList) {
+ CastorHashMap props = new CastorHashMap();
+ StringBuffer classProps = new StringBuffer();
+ if (thisMem.itemDescriptionPath != null && thisMem.itemDescriptionPath.length()>0) {
+ PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(thisMem.itemDescriptionPath).getSysKey());
+ for (PropertyDescription pd : propList.list) {
+ props.put(pd.getName(), pd.getDefaultValue());
+ if (pd.getIsClassIdentifier())
+ classProps.append((classProps.length()>0?",":"")).append(pd.getName());
+ }
+ }
+ if (thisMem.itemPath != null && thisMem.itemPath.length()>0) {
+ int syskey = new DomainPath(thisMem.itemPath).getSysKey();
+ if (syskey == -1)
+ throw new MembershipException("Cannot find "+thisMem.itemPath+" specified for collection.");
+ newAgg.addMember(syskey, props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height);
+ }
+ }
+ return newAgg;
}
}
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 1124ede..5993f62 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
@@ -3,8 +3,12 @@ package com.c2kernel.lifecycle.instance.predefined.entitycreation;
import java.util.ArrayList;
import com.c2kernel.collection.MembershipException;
+import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.property.PropertyDescription;
+import com.c2kernel.property.PropertyDescriptionList;
import com.c2kernel.property.PropertyUtility;
+import com.c2kernel.utils.CastorHashMap;
public class Dependency implements java.io.Serializable {
@@ -26,12 +30,21 @@ public class Dependency implements java.io.Serializable {
/**
* @return
*/
- public com.c2kernel.collection.Dependency create() throws MembershipException{
+ 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) {
- PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getSysKey());
- //TODO: set props and class identifiers
+ 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());
+ if (pd.getIsClassIdentifier())
+ classProps.append((classProps.length()>0?",":"")).append(pd.getName());
+ }
+ newDep.setProperties(props);
+ newDep.setClassProps(classProps.toString());
}
+
for (DependencyMember thisMem : dependencyMemberList) {
int syskey = new DomainPath(thisMem.itemPath).getSysKey();
if (syskey == -1)
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 f155ced..16f6cbf 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
@@ -132,7 +132,10 @@ public class NewItem {
} catch (ClusterStorageException ex) {
Logger.error(ex);
throw new CannotManageException("Could not create Aggregation "+element.name, "");
- }
+ } catch (MembershipException ex) {
+ Logger.error(ex);
+ throw new CannotManageException("A specified member is not of the correct type in "+element.name, "");
+ }
}
// register domain path
domPath.setEntity(entPath);