001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: *
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or 1any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: *
022: * Initial developer: JOnAS team
023: * --------------------------------------------------------------------------
024: * $Id: Entity.java 4782 2004-05-19 21:18:56Z ehardesty $
025: * --------------------------------------------------------------------------
026: */package org.objectweb.jonas_ejb.deployment.xml;
027:
028: import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
029:
030: /**
031: * This class defines the implementation of the element entity
032: *
033: * @author JOnAS team
034: */
035:
036: public class Entity extends CommonEjb {
037:
038: /**
039: * persistence-type
040: */
041: private String persistenceType = null;
042:
043: /**
044: * prim-key-class
045: */
046: private String primKeyClass = null;
047:
048: /**
049: * reentrant
050: */
051: private String reentrant = null;
052:
053: /**
054: * cmp-version
055: */
056: private String cmpVersion = null;
057:
058: /**
059: * abstract-schema-name
060: */
061: private String abstractSchemaName = null;
062:
063: /**
064: * cmp-field
065: */
066: private JLinkedList cmpFieldList = null;
067:
068: /**
069: * primkey-field
070: */
071: private String primkeyField = null;
072:
073: /**
074: * query
075: */
076: private JLinkedList queryList = null;
077:
078: /**
079: * Constructor
080: */
081: public Entity() {
082: super ();
083: cmpFieldList = new JLinkedList("cmp-field");
084: queryList = new JLinkedList("query");
085: }
086:
087: /**
088: * Gets the persistence-type
089: * @return the persistence-type
090: */
091: public String getPersistenceType() {
092: return persistenceType;
093: }
094:
095: /**
096: * Set the persistence-type
097: * @param persistenceType persistenceType
098: */
099: public void setPersistenceType(String persistenceType) {
100: this .persistenceType = persistenceType;
101: }
102:
103: /**
104: * Gets the prim-key-class
105: * @return the prim-key-class
106: */
107: public String getPrimKeyClass() {
108: return primKeyClass;
109: }
110:
111: /**
112: * Set the prim-key-class
113: * @param primKeyClass primKeyClass
114: */
115: public void setPrimKeyClass(String primKeyClass) {
116: this .primKeyClass = primKeyClass;
117: }
118:
119: /**
120: * Gets the reentrant
121: * @return the reentrant
122: */
123: public String getReentrant() {
124: return reentrant;
125: }
126:
127: /**
128: * Set the reentrant
129: * @param reentrant reentrant
130: */
131: public void setReentrant(String reentrant) {
132: this .reentrant = reentrant;
133: }
134:
135: /**
136: * Gets the cmp-version
137: * @return the cmp-version
138: */
139: public String getCmpVersion() {
140: return cmpVersion;
141: }
142:
143: /**
144: * Set the cmp-version
145: * @param cmpVersion cmpVersion
146: */
147: public void setCmpVersion(String cmpVersion) {
148: this .cmpVersion = cmpVersion;
149: }
150:
151: /**
152: * Gets the abstract-schema-name
153: * @return the abstract-schema-name
154: */
155: public String getAbstractSchemaName() {
156: return abstractSchemaName;
157: }
158:
159: /**
160: * Set the abstract-schema-name
161: * @param abstractSchemaName abstractSchemaName
162: */
163: public void setAbstractSchemaName(String abstractSchemaName) {
164: this .abstractSchemaName = abstractSchemaName;
165: }
166:
167: /**
168: * Gets the cmp-field
169: * @return the cmp-field
170: */
171: public JLinkedList getCmpFieldList() {
172: return cmpFieldList;
173: }
174:
175: /**
176: * Set the cmp-field
177: * @param cmpFieldList cmpField
178: */
179: public void setCmpFieldList(JLinkedList cmpFieldList) {
180: this .cmpFieldList = cmpFieldList;
181: }
182:
183: /**
184: * Add a new cmp-field element to this object
185: * @param cmpField the cmpFieldobject
186: */
187: public void addCmpField(CmpField cmpField) {
188: cmpFieldList.add(cmpField);
189: }
190:
191: /**
192: * Gets the primkey-field
193: * @return the primkey-field
194: */
195: public String getPrimkeyField() {
196: return primkeyField;
197: }
198:
199: /**
200: * Set the primkey-field
201: * @param primkeyField primkeyField
202: */
203: public void setPrimkeyField(String primkeyField) {
204: this .primkeyField = primkeyField;
205: }
206:
207: /**
208: * Gets the query
209: * @return the query
210: */
211: public JLinkedList getQueryList() {
212: return queryList;
213: }
214:
215: /**
216: * Set the query
217: * @param queryList query
218: */
219: public void setQueryList(JLinkedList queryList) {
220: this .queryList = queryList;
221: }
222:
223: /**
224: * Add a new query element to this object
225: * @param query the queryobject
226: */
227: public void addQuery(Query query) {
228: queryList.add(query);
229: }
230:
231: /**
232: * Represents this element by it's XML description.
233: * @param indent use this indent for prexifing XML representation.
234: * @return the XML description of this object.
235: */
236: public String toXML(int indent) {
237: StringBuffer sb = new StringBuffer();
238: sb.append(indent(indent));
239: sb.append("<entity>\n");
240:
241: indent += 2;
242:
243: // description
244: sb.append(xmlElement(getDescription(), "description", indent));
245: // display-name
246: sb.append(xmlElement(getDisplayName(), "display-name", indent));
247: // small-icon
248: sb.append(xmlElement(getIcon().getSmallIcon(), "small-icon",
249: indent));
250: // large-icon
251: sb.append(xmlElement(getIcon().getLargeIcon(), "large-icon",
252: indent));
253: // ejb-name
254: sb.append(xmlElement(getEjbName(), "ejb-name", indent));
255: // home
256: sb.append(xmlElement(getHome(), "home", indent));
257: // remote
258: sb.append(xmlElement(getRemote(), "remote", indent));
259: // local-home
260: sb.append(xmlElement(getLocalHome(), "local-home", indent));
261: // local
262: sb.append(xmlElement(getLocal(), "local", indent));
263: // ejb-class
264: sb.append(xmlElement(getEjbClass(), "ejb-class", indent));
265: // persistence-type
266: sb.append(xmlElement(persistenceType, "persistence-type",
267: indent));
268: // prim-key-class
269: sb.append(xmlElement(primKeyClass, "prim-key-class", indent));
270: // reentrant
271: sb.append(xmlElement(reentrant, "reentrant", indent));
272: // cmp-version
273: sb.append(xmlElement(cmpVersion, "cmp-version", indent));
274: // abstract-schema-name
275: sb.append(xmlElement(abstractSchemaName,
276: "abstract-schema-name", indent));
277: // cmp-field
278: sb.append(cmpFieldList.toXML(indent));
279: // primkey-field
280: sb.append(xmlElement(primkeyField, "primkey-field", indent));
281: // env-entry
282: sb.append(getEnvEntryList().toXML(indent));
283: // ejb-ref
284: sb.append(getEjbRefList().toXML(indent));
285: // ejb-local-ref
286: sb.append(getEjbLocalRefList().toXML(indent));
287: // service-ref
288: sb.append(getServiceRefList().toXML(indent));
289: // resource-ref
290: sb.append(getResourceRefList().toXML(indent));
291: // resource-env-ref
292: sb.append(getResourceEnvRefList().toXML(indent));
293: // message-destination-ref
294: sb.append(getMessageDestinationRefList().toXML(indent));
295: // security-role-ref
296: sb.append(getSecurityRoleRefList().toXML(indent));
297: // security-identity
298: if (getSecurityIdentity() != null) {
299: sb.append(getSecurityIdentity().toXML(indent));
300: }
301: // query
302: sb.append(queryList.toXML(indent));
303: indent -= 2;
304: sb.append(indent(indent));
305: sb.append("</entity>\n");
306:
307: return sb.toString();
308: }
309: }
|