blob: 9cb389400e03cac1b0def92d7cb9f55223d7e0a4 (
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
|
package com.c2kernel.lifecycle.instance.predefined.entitycreation;
import java.util.ArrayList;
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.DomainPath;
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;
import com.c2kernel.utils.Logger;
public class Dependency implements java.io.Serializable {
public String name;
public boolean isDescription;
public String itemDescriptionPath;
public ArrayList<DependencyMember> dependencyMemberList = new ArrayList<DependencyMember>();
public CastorHashMap props = new CastorHashMap();
public Dependency() {
super();
}
public Dependency(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) {
Logger.debug(itemDescriptionPath);
PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getSysKey());
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 (DependencyMember thisMem : dependencyMemberList) {
int syskey = new DomainPath(thisMem.itemPath).getSysKey();
if (syskey == -1)
throw new MembershipException("Cannot find "+thisMem.itemPath+" specified for collection.");
com.c2kernel.collection.DependencyMember newDepMem = newDep.addMember(syskey);
newDepMem.getProperties().putAll(thisMem.props);
}
return newDep;
}
}
|