diff options
Diffstat (limited to 'src/main/java/com/c2kernel/collection/Aggregation.java')
| -rw-r--r-- | src/main/java/com/c2kernel/collection/Aggregation.java | 70 |
1 files changed, 53 insertions, 17 deletions
diff --git a/src/main/java/com/c2kernel/collection/Aggregation.java b/src/main/java/com/c2kernel/collection/Aggregation.java index 9c7b4ce..063eb77 100644 --- a/src/main/java/com/c2kernel/collection/Aggregation.java +++ b/src/main/java/com/c2kernel/collection/Aggregation.java @@ -2,9 +2,14 @@ package com.c2kernel.collection; import com.c2kernel.collection.gui.model.AggregationVertexOutlineCreator;
+import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.graph.model.GraphModel;
import com.c2kernel.graph.model.GraphPoint;
import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.lookup.InvalidEntityPathException;
+import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.process.Gateway;
import com.c2kernel.utils.CastorHashMap;
import com.c2kernel.utils.Language;
import com.c2kernel.utils.Logger;
@@ -67,27 +72,39 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb return null;
}
+ public AggregationMember addSlot(CastorHashMap props, String classProps, GraphPoint location, int w, int h)
+ {
+
+ // Default geometry if not present
+ if (location == null) location = new GraphPoint(100,100*getCounter());
+ if (w<0) w = 20;
+ if (h<0) h = 20;
+
+ // Create new member object
+ AggregationMember aggMem = new AggregationMember();
+ aggMem.setProperties(props);
+ aggMem.setClassProps(classProps);
+ // create vertex
+ com.c2kernel.graph.model.Vertex vertex = new com.c2kernel.graph.model.Vertex();
+ vertex.setHeight(h); vertex.setWidth(w);
+ mLayout.addVertexAndCreateId(vertex,location);
+ aggMem.setCollection(this);
+ aggMem.setID(vertex.getID());
+ aggMem.setIsLayoutable(true);
+
+ mMembers.list.add(aggMem);
+ Logger.msg(8, "AggregationDescription::addSlot new slot linked to vertexid " + vertex.getID());
+ return aggMem;
+ }
public AggregationMember addMember(int entityKey, CastorHashMap props, String classProps, GraphPoint location, int w, int h)
throws MembershipException
{
- // Create new member object
- AggregationMember aggMem = new AggregationMember();
- aggMem.setProperties(props);
- aggMem.setClassProps(classProps);
- if (entityKey > -1) {
+ AggregationMember aggMem = addSlot(props, classProps, location, w, h);
+ if (entityKey > -1) { // some clients use this method when not setting a member
aggMem.assignEntity(entityKey);
- aggMem.setIsComposite( RelationshipUtils.getIsComposite(entityKey) );
+ aggMem.setIsComposite( getIsComposite(entityKey, getName()) );
}
- // create vertex
- com.c2kernel.graph.model.Vertex vertex = new com.c2kernel.graph.model.Vertex();
- vertex.setHeight(h); vertex.setWidth(w);
- mLayout.addVertexAndCreateId(vertex,location);
- aggMem.setCollection(this);
- aggMem.setID(vertex.getID());
- aggMem.setIsLayoutable(true);
-
- mMembers.list.add(aggMem);
- Logger.msg(8, "AggregationDescription::addMember(" + entityKey + ") added to children linked to vertexid " + vertex.getID());
+ Logger.msg(8, "AggregationDescription::addMember(" + entityKey + ") assigned to new slot " + aggMem.getID());
return aggMem;
}
@@ -95,7 +112,12 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb @Override
public AggregationMember addMember(int entityKey, CastorHashMap props, String classProps) throws MembershipException
{
- return addMember(entityKey, props, classProps, new GraphPoint(100,100*getCounter()), 20, 20);
+ return addMember(entityKey, props, classProps, null, -1, -1);
+ }
+
+ public AggregationMember addSlot(CastorHashMap props, String classProps)
+ {
+ return addSlot(props, classProps, null, -1, -1);
}
@Override
@@ -115,5 +137,19 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb }
throw new MembershipException("Member "+memberId+" not found");
}
+
+ static public boolean getIsComposite(int entityKey, String name)
+ {
+ if (entityKey == -1) return false;
+ try {
+ for(String collName: Gateway.getProxyManager().getProxy(new EntityPath(entityKey)).getContents(ClusterStorage.COLLECTION) )
+ if (name == null || name.equals(collName)) return true;
+ } catch (ObjectNotFoundException e) {
+ return false;
+ } catch (InvalidEntityPathException e) {
+ return false;
+ }
+ return false;
+ }
}
|
