From 9c5d6e82b5ce733cf23e4317e3bafaa42c2221ba Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 1 Oct 2014 21:09:06 +0200 Subject: Collection version support, stored as a new final component of the Collection path. Null version implies "last". --- .../c2kernel/collection/AggregationDescription.java | 6 +++--- src/main/java/com/c2kernel/collection/Collection.java | 19 +++++++++++-------- .../c2kernel/collection/DependencyDescription.java | 5 +++-- 3 files changed, 17 insertions(+), 13 deletions(-) (limited to 'src/main/java/com/c2kernel/collection') diff --git a/src/main/java/com/c2kernel/collection/AggregationDescription.java b/src/main/java/com/c2kernel/collection/AggregationDescription.java index 132a357..10ea5f7 100644 --- a/src/main/java/com/c2kernel/collection/AggregationDescription.java +++ b/src/main/java/com/c2kernel/collection/AggregationDescription.java @@ -24,7 +24,6 @@ public class AggregationDescription extends Aggregation implements CollectionDes setName(name); } - @Override public Aggregation newInstance() throws ObjectNotFoundException { @@ -33,8 +32,9 @@ public class AggregationDescription extends Aggregation implements CollectionDes for (int i=0; i implements C2KLocal public int getCounter() { if (mCounter == -1) - for (Object name : mMembers.list) { - CollectionMember element = (CollectionMember)name; + for (E element : mMembers.list) { if (mCounter < element.getID()) mCounter = element.getID(); } @@ -89,19 +88,23 @@ abstract public class Collection implements C2KLocal } public boolean contains(ItemPath itemPath) { - for (Object name : mMembers.list) { - CollectionMember element = (CollectionMember)name; + for (E element : mMembers.list) { if (element.getItemPath().equals(itemPath)) return true; } return false; } + + public String getDescVer(E mem) { + String descVer = "last"; + Object descVerObj = mem.getProperties().get("Version"); + if (descVerObj != null) descVer = descVerObj.toString(); + return descVer; + } public boolean isFull() { - for (int i=0; i implements C2KLocal if (!same) return false; for (Iterator i = getMembers().list.iterator(); i.hasNext();) { try { - CollectionMember thisMem = i.next(); + E thisMem = i.next(); CollectionMember otherMem = otherColl.getMember(thisMem.getID()); if (!thisMem.equals(otherMem)) return false; } catch (ObjectNotFoundException ex) { diff --git a/src/main/java/com/c2kernel/collection/DependencyDescription.java b/src/main/java/com/c2kernel/collection/DependencyDescription.java index 3c3b287..6698be3 100644 --- a/src/main/java/com/c2kernel/collection/DependencyDescription.java +++ b/src/main/java/com/c2kernel/collection/DependencyDescription.java @@ -12,7 +12,7 @@ public class DependencyDescription extends Dependency implements CollectionDescr { setName("DependencyDescription"); } - + public DependencyDescription(String name) { setName(name); @@ -24,7 +24,8 @@ public class DependencyDescription extends Dependency implements CollectionDescr Dependency newDep = new Dependency(depName); if (mMembers.list.size() == 1) { // constrain the members based on the property description DependencyMember mem = mMembers.list.get(0); - PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath()); + String descVer = getDescVer(mem); + PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath(), descVer); if (pdList!=null) { newDep.setProperties(PropertyUtility.createProperty(pdList)); newDep.setClassProps(pdList.getClassProps()); -- cgit v1.2.3