From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: More code cleanup: Refactored Entity Proxy Subscription to handle generics better Rewrote RemoteMap to use TreeMap instead of the internal array for order. It now sorts its keys by number if they parse, else as strings. Removed a no-longer-in-progress outcome form class --- .../com/c2kernel/collection/AggregationMember.java | 59 ++++++++++++---------- 1 file changed, 33 insertions(+), 26 deletions(-) mode change 100755 => 100644 source/com/c2kernel/collection/AggregationMember.java (limited to 'source/com/c2kernel/collection/AggregationMember.java') diff --git a/source/com/c2kernel/collection/AggregationMember.java b/source/com/c2kernel/collection/AggregationMember.java old mode 100755 new mode 100644 index 753f503..d383f02 --- a/source/com/c2kernel/collection/AggregationMember.java +++ b/source/com/c2kernel/collection/AggregationMember.java @@ -27,8 +27,8 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb { private int mEntityKey = -1; - private EntityProxy mEntity = null; - private Collection mCollection = null; + private EntityProxy mEntity = null; + private Aggregation mCollection = null; private String mClassProps = null; String entityName; Image image; @@ -44,50 +44,55 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb mCollection = null; } - public void setEntityKey(int entityKey) { - mEntityKey = entityKey; + @Override + public void setEntityKey(int entityKey) { + mEntityKey = entityKey; entityName = null; } - - public void setCollection(Collection aggregation) + + public void setCollection(Aggregation aggregation) { mCollection = aggregation; } - public void setClassProps(String props) + @Override + public void setClassProps(String props) { mClassProps = props; } - public int getEntityKey() + @Override + public int getEntityKey() { return mEntityKey; } - public Collection getCollection() + public Aggregation getCollection() { return mCollection; } - public String getClassProps() + @Override + public String getClassProps() { return mClassProps; } - public void assignEntity(int entityKey) throws MembershipException + @Override + public void assignEntity(int entityKey) throws MembershipException { if (entityKey > -1) { if (mClassProps == null || getProperties() == null) throw new MembershipException("ClassProps not yet set. Cannot check membership validity."); - + //for each mandatory prop check if its in the member property and has the matching value StringTokenizer sub = new StringTokenizer(mClassProps, ","); while (sub.hasMoreTokens()) { - String aClassProp = sub.nextToken(); - try { - String memberValue = (String)getProperties().get(aClassProp); - Property entityProperty = (Property)Gateway.getStorage().get(entityKey, ClusterStorage.PROPERTY+"/"+aClassProp, null); + String aClassProp = sub.nextToken(); + try { + String memberValue = (String)getProperties().get(aClassProp); + Property entityProperty = (Property)Gateway.getStorage().get(entityKey, ClusterStorage.PROPERTY+"/"+aClassProp, null); if (entityProperty == null) throw new MembershipException("Property "+aClassProp+ " does not exist for entityKey=" + entityKey ); if (entityProperty.getValue() == null || !entityProperty.getValue().equalsIgnoreCase(memberValue)) @@ -96,25 +101,27 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb catch (MembershipException ex) { throw ex; } - catch (Exception ex) + catch (Exception ex) { Logger.error(ex); throw new MembershipException("Error checking properties"); } - } + } } - + mEntityKey = entityKey; mEntity = null; entityName = null; } - - public void clearEntity() { + + @Override + public void clearEntity() { mEntityKey = -1; mEntity = null; } - - public EntityProxy resolveEntity() throws ObjectNotFoundException { + + @Override + public EntityProxy resolveEntity() throws ObjectNotFoundException { if (mEntity == null) { try { EntityPath path = new EntityPath(mEntityKey); @@ -124,9 +131,9 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb } } return mEntity; - + } - + public Image getImage() { if (image == null) { image = Resource.getImageResource("typeicons/"+getProperties().get("Type")+"_16.png").getImage(); @@ -147,7 +154,7 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb else entityName = "Empty"; } - + return entityName; } -- cgit v1.2.3