summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/collection/Aggregation.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-09-09 12:13:21 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-09-09 12:13:21 +0200
commitda731d2bb81666b9c697d9099da632e7dfcdc0f7 (patch)
tree567693c3c48f3d15ecbb2dac4f9db03bb6e58c72 /src/main/java/com/c2kernel/collection/Aggregation.java
parentae1e79e33fd30e3d8bcedbef8891a14a048276d7 (diff)
Replaced int sysKey Item identifier with UUID, which is now portable.
ItemPath objects are now used to identify Items throughout the kernel, replacing ints and Integers.
Diffstat (limited to 'src/main/java/com/c2kernel/collection/Aggregation.java')
-rw-r--r--src/main/java/com/c2kernel/collection/Aggregation.java76
1 files changed, 37 insertions, 39 deletions
diff --git a/src/main/java/com/c2kernel/collection/Aggregation.java b/src/main/java/com/c2kernel/collection/Aggregation.java
index f2ef710..2f01936 100644
--- a/src/main/java/com/c2kernel/collection/Aggregation.java
+++ b/src/main/java/com/c2kernel/collection/Aggregation.java
@@ -7,7 +7,6 @@ import com.c2kernel.graph.model.GraphModel;
import com.c2kernel.graph.model.GraphPoint;
import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.CastorHashMap;
@@ -50,12 +49,12 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb
return mVertexTypeNameAndConstructionInfo;
}
- public boolean exists(int sysKey)
+ public boolean exists(ItemPath itemPath)
{
for (int i=0; i<size(); i++)
{
AggregationMember element = mMembers.list.get(i);
- if (element.getSystemKey() == sysKey)
+ if (element.getItemPath().equals(itemPath))
return true;
}
return false;
@@ -73,46 +72,47 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb
}
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 sysKey, 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(ItemPath itemPath, CastorHashMap props, String classProps, GraphPoint location, int w, int h)
throws MembershipException
{
AggregationMember aggMem = addSlot(props, classProps, location, w, h);
- if (sysKey > -1) { // some clients use this method when not setting a member
- aggMem.assignItem(sysKey);
- aggMem.setIsComposite( getIsComposite(sysKey, getName()) );
+ if (itemPath != null) { // some clients use this method when not setting a member
+ aggMem.assignItem(itemPath);
+ aggMem.setIsComposite( getIsComposite(itemPath, getName()) );
}
- Logger.msg(8, "AggregationDescription::addMember(" + sysKey + ") assigned to new slot " + aggMem.getID());
+ Logger.msg(8, "AggregationDescription::addMember(" + itemPath + ") assigned to new slot " + aggMem.getID());
return aggMem;
}
@Override
- public AggregationMember addMember(int entityKey, CastorHashMap props, String classProps) throws MembershipException
+ public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws MembershipException
{
- return addMember(entityKey, props, classProps, null, -1, -1);
+ return addMember(itemPath, props, classProps, null, -1, -1);
}
public AggregationMember addSlot(CastorHashMap props, String classProps)
@@ -121,7 +121,7 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb
}
@Override
- public AggregationMember addMember(int entityKey) throws MembershipException {
+ public AggregationMember addMember(ItemPath itemPath) throws MembershipException {
throw new MembershipException("Aggregations cannot accept arbitrary members without type info");
}
@@ -138,16 +138,14 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb
throw new MembershipException("Member "+memberId+" not found");
}
- static public boolean getIsComposite(int entityKey, String name)
+ static public boolean getIsComposite(ItemPath itemPath, String name)
{
- if (entityKey == -1) return false;
+ if (itemPath == null) return false;
try {
- for(String collName: Gateway.getProxyManager().getProxy(new ItemPath(entityKey)).getContents(ClusterStorage.COLLECTION) )
+ for(String collName: Gateway.getProxyManager().getProxy(itemPath).getContents(ClusterStorage.COLLECTION) )
if (name == null || name.equals(collName)) return true;
} catch (ObjectNotFoundException e) {
return false;
- } catch (InvalidItemPathException e) {
- return false;
}
return false;
}