summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java
blob: 0896534a1df9e26f02fbf7beac0162edefdb162a (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
package com.c2kernel.lifecycle.instance.predefined.entitycreation;

import java.util.ArrayList;
import java.util.Iterator;

import com.c2kernel.collection.MembershipException;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.property.PropertyUtility;

public class Dependency implements java.io.Serializable {

    public String name;
    public boolean isDescription;
    public String itemDescriptionPath;
    public ArrayList dependencyMemberList;

    public Dependency() {
        super();
        dependencyMemberList = new ArrayList();
    } 
    
    public Dependency(String itemDesc) {
        this();
        this.itemDescriptionPath = itemDesc;
    }

    /**
     * @return
     */
    public com.c2kernel.collection.Dependency create() throws MembershipException{
        com.c2kernel.collection.Dependency newDep = new com.c2kernel.collection.Dependency(name);
        if (itemDescriptionPath != null) {
            PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getSysKey());
            //TODO: set props and class identifiers
        }
        for (Iterator mems = dependencyMemberList.iterator(); mems.hasNext();) {
            DependencyMember thisMem = (DependencyMember) mems.next();
            int syskey = new DomainPath(thisMem.itemPath).getSysKey();
            if (syskey == -1)
            	throw new MembershipException("Cannot find "+thisMem.itemPath+" specified for collection.");
            newDep.addMember(syskey);
        }
        return newDep;
    }

}