summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/collection/AggregationDescription.java
blob: 07a681815a0ecf73d3a5fe9e246b5e1ebff077c0 (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
package com.c2kernel.collection;

/**
 * @version $Revision: 1.34 $ $Date: 2004/03/23 09:29:41 $
 * @author  $Author: abranson $
 */

import com.c2kernel.graph.model.Vertex;
import com.c2kernel.property.*;
import com.c2kernel.utils.Logger;

public class AggregationDescription extends Aggregation implements CollectionDescription
{

    public AggregationDescription()
    {
    	setName("AggregationDescription");
        mMembers = new CollectionMemberList();
    }

    public AggregationDescription(String name)
    {
    	setName(name);
        mMembers = new CollectionMemberList();
    }

    
    public Collection newInstance() 
    {
    	AggregationInstance newInstance = new AggregationInstance(getName());
    	newInstance.setURLInfo(getURLInfo());
    	//for each desc member
    	for (int i=0; i<size(); i++)
    	{
    		AggregationMember mem = (AggregationMember) mMembers.list.get(i);
			//get the propdesc of the member item									
			PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getEntityKey());
			if (pdList!=null)
			{
				//create the new props of the member object 
                try {
                    Vertex v = getLayout().getVertexById(mem.getID());
                    newInstance.addMember(-1, PropertyUtility.createProperty(pdList), pdList.getClassProps(),v.getCentrePoint(),v.getWidth(),v.getHeight());																								
                } catch (MembershipException e) {                	
                    // won't happen as we're not assigning an entity
                }
			}
			else
			{				
				Logger.error("AggregationDescription::newInstance() There is no PropertyDescription. Cannot instantiate. " + mem.getEntityKey());
				return null;
			}			


    	}

    	return newInstance;
    }              
}