package com.c2kernel.collection; import com.c2kernel.collection.gui.model.AggregationVertexOutlineCreator; import com.c2kernel.graph.model.GraphModel; import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.graph.model.TypeNameAndConstructionInfo; import com.c2kernel.utils.CastorHashMap; import com.c2kernel.utils.Language; import com.c2kernel.utils.Logger; /** * @version $Revision: 1.59 $ $Date: 2004/08/10 07:56:08 $ * @author $Author: abranson $ */ abstract public class Aggregation extends Parent2ChildCollection { protected GraphModel mLayout = new GraphModel(new AggregationVertexOutlineCreator()); private final TypeNameAndConstructionInfo[] mVertexTypeNameAndConstructionInfo = { new TypeNameAndConstructionInfo(Language.translate("Slot"), "AggregationMember") }; public Aggregation() { setName("Aggregation"); } public GraphModel getLayout() { return mLayout; } public void setLayout(GraphModel layout) { mLayout = layout; } public TypeNameAndConstructionInfo[] getVertexTypeNameAndConstructionInfo() { return mVertexTypeNameAndConstructionInfo; } public boolean exists(int entityKey) { for (int i=0; i -1) { aggMem.assignEntity(entityKey); aggMem.setIsComposite( RelationshipUtils.getIsComposite(entityKey) ); } // create vertex com.c2kernel.graph.model.Vertex vertex = new com.c2kernel.graph.model.Vertex(); vertex.setHeight(h); vertex.setWidth(w); mLayout.addVertexAndCreateId(vertex,location); aggMem.setCollection(this); aggMem.setID(vertex.getID()); aggMem.setIsLayoutable(true); mMembers.list.add(aggMem); Logger.msg(8, "AggregationDescription::addMember(" + entityKey + ") added to children linked to vertexid " + vertex.getID()); return aggMem; } @Override public AggregationMember addMember(int entityKey, CastorHashMap props, String classProps) throws MembershipException { return addMember(entityKey, props, classProps, new GraphPoint(100,100*getCounter()), 20, 20); } @Override public AggregationMember addMember(int entityKey) throws MembershipException { throw new MembershipException("Aggregations cannot accept arbitrary members without type info"); } @Override public void removeMember(int memberId) throws MembershipException { for (AggregationMember element : mMembers.list) { if (element.getID() == memberId) { element.clearEntity(); mLayout.removeVertex(getLayout().getVertexById(memberId)); return; } } throw new MembershipException("Member "+memberId+" not found"); } }