blob: 87e6b11d2aac5387fa10b7c9db8fbe737766c4d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package com.c2kernel.entity.imports;
import java.util.ArrayList;
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.property.PropertyDescription;
import com.c2kernel.property.PropertyDescriptionList;
import com.c2kernel.property.PropertyUtility;
import com.c2kernel.utils.CastorHashMap;
import com.c2kernel.utils.KeyValuePair;
public class ImportDependency implements java.io.Serializable {
public String name;
public boolean isDescription;
public String itemDescriptionPath;
public ArrayList<ImportDependencyMember> dependencyMemberList = new ArrayList<ImportDependencyMember>();
public CastorHashMap props = new CastorHashMap();
public ImportDependency() {
super();
}
public ImportDependency(String name) {
this();
this.name = name;
}
public KeyValuePair[] getKeyValuePairs() {
return props.getKeyValuePairs();
}
public void setKeyValuePairs(KeyValuePair[] pairs) {
props.setKeyValuePairs(pairs);
}
/**
* @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);
if (itemDescriptionPath != null && itemDescriptionPath.length()>0) {
PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getItemPath());
StringBuffer classProps = new StringBuffer();
for (PropertyDescription pd : propList.list) {
props.put(pd.getName(), pd.getDefaultValue());
if (pd.getIsClassIdentifier())
classProps.append((classProps.length()>0?",":"")).append(pd.getName());
}
newDep.setProperties(props);
newDep.setClassProps(classProps.toString());
}
for (ImportDependencyMember thisMem : dependencyMemberList) {
ItemPath itemPath;
try {
itemPath = ItemPath.fromUUIDString(thisMem.itemPath);
} catch (InvalidItemPathException ex) {
itemPath = new DomainPath(thisMem.itemPath).getItemPath();
}
if (itemPath == null)
throw new MembershipException("Cannot find "+thisMem.itemPath+" specified for collection.");
com.c2kernel.collection.DependencyMember newDepMem = newDep.addMember(itemPath);
newDepMem.getProperties().putAll(thisMem.props);
}
return newDep;
}
}
|