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". --- .../com/c2kernel/entity/imports/ImportDependency.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/c2kernel/entity/imports/ImportDependency.java') diff --git a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java b/src/main/java/com/c2kernel/entity/imports/ImportDependency.java index c235ba4..dc26551 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportDependency.java @@ -2,6 +2,8 @@ package com.c2kernel.entity.imports; import java.util.ArrayList; +import com.c2kernel.collection.Dependency; +import com.c2kernel.collection.DependencyDescription; import com.c2kernel.collection.MembershipException; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lookup.DomainPath; @@ -16,8 +18,10 @@ import com.c2kernel.utils.KeyValuePair; public class ImportDependency { public String name; + public Integer version; public boolean isDescription; public String itemDescriptionPath; + public String itemDescriptionVersion = null; public ArrayList dependencyMemberList = new ArrayList(); public CastorHashMap props = new CastorHashMap(); @@ -42,9 +46,17 @@ public class ImportDependency { * @return */ 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); + Dependency newDep = isDescription?new DependencyDescription(name):new Dependency(name); + if (version!= null) newDep.setVersion(version); if (itemDescriptionPath != null && itemDescriptionPath.length()>0) { - PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getItemPath()); + ItemPath itemPath; + try { + itemPath = new ItemPath(itemDescriptionPath); + } catch (InvalidItemPathException ex) { + itemPath = new DomainPath(itemDescriptionPath).getItemPath(); + } + String descVer = itemDescriptionVersion==null?"last":itemDescriptionVersion; + PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer); StringBuffer classProps = new StringBuffer(); for (PropertyDescription pd : propList.list) { props.put(pd.getName(), pd.getDefaultValue()); -- cgit v1.2.3