1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.devaki.nextobjects.workspace.models.objects;
21 import java.io.Serializable;
22 import java.util.Vector;
23 import org.devaki.nextobjects.workspace.models.ConceptualModel;
24 import org.devaki.nextobjects.workspace.models.columns.Column;
25 import org.devaki.nextobjects.workspace.models.graphics.EntityView;
26 import org.devaki.nextobjects.workspace.models.graphics.ObjectView;
27 /***
28 * The entities in the merise model
29 * @see http://www.devaki.org/cdm.html
30 */
31 public class Entity extends BaseClass implements Serializable
32 {
33 /***
34 *
35 * the subsequent Table deduced in a Merise Transformation
36 */
37 private transient Table subSequentTable;
38 /***
39 * The EntityView
40 *
41 */
42 private EntityView entityView;
43 /***
44 * Construct a new 'Entity' object
45 * @param pObject the entity to clone
46 */
47 public Entity(final Entity pObject)
48 {
49 super(pObject);
50 this.entityView = new EntityView(this);
51 }
52 /***
53 * Construct a new 'Entity' object
54 * @param pModel the context model
55 */
56 public Entity(final ConceptualModel pModel)
57 {
58 super(pModel);
59 this.setName(
60 new StringBuffer()
61 .append("Entity ")
62 .append(pModel.countEntities())
63 .toString());
64 this.setCode(
65 new StringBuffer()
66 .append("Entity")
67 .append(pModel.countEntities())
68 .toString());
69 this.entityView = new EntityView(this);
70 }
71 /***
72 * Return the first Primary key
73 * @return the column
74 */
75 public final Column getIdentifier()
76 {
77 Vector columns = this.getColumns();
78 Column tmpPk = null;
79 for (int i = 0; i < columns.size(); i++)
80 {
81 if (((Column) columns.elementAt(i)).isPk())
82 {
83 tmpPk = (Column) columns.elementAt(i);
84 break;
85 }
86 }
87 return tmpPk;
88 }
89 /***
90 * Return all Primary key
91 * @return the primary jeys
92 */
93 public final Vector getAllIdentifier()
94 {
95 Vector tmpVect = new Vector();
96 Vector columns = this.getColumns();
97 Column tmpPk = null;
98 for (int i = 0; i < columns.size(); i++)
99 {
100 if (((Column) columns.elementAt(i)).isPk())
101 {
102 tmpPk = (Column) columns.elementAt(i);
103 tmpVect.add(tmpPk);
104 }
105 }
106 return tmpVect;
107 }
108 /***
109 * Get the subsequent table in a pdm
110 * @return the table
111 */
112 public final Table getSubsequentTable()
113 {
114 return this.subSequentTable;
115 }
116 /***
117 * Return the entity view
118 * @return the object view
119 */
120 public final ObjectView getObjectView()
121 {
122 return this.entityView;
123 }
124 /***
125 * Set the subsequent table
126 * @param pTable the table
127 */
128 public final void setSubsequentTable(final Table pTable)
129 {
130 this.subSequentTable = pTable;
131 }
132 }