001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.openejb.jee.jpa;
017:
018: import javax.xml.bind.annotation.XmlAccessType;
019: import javax.xml.bind.annotation.XmlAccessorType;
020: import javax.xml.bind.annotation.XmlAttribute;
021: import javax.xml.bind.annotation.XmlElement;
022: import javax.xml.bind.annotation.XmlType;
023:
024: /**
025: *
026: *
027: * Defines the settings and mappings for a mapped superclass. Is
028: * allowed to be sparsely populated and used in conjunction with
029: * the annotations. Alternatively, the metadata-complete attribute
030: * can be used to indicate that no annotations are to be processed
031: * If this is the case then the defaulting rules will be recursively
032: * applied.
033: *
034: * @Target(TYPE) @Retention(RUNTIME)
035: * public @interface MappedSuperclass{}
036: *
037: *
038: *
039: * <p>Java class for mapped-superclass complex type.
040: *
041: * <p>The following schema fragment specifies the expected content contained within this class.
042: *
043: * <pre>
044: * <complexType name="mapped-superclass">
045: * <complexContent>
046: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
047: * <sequence>
048: * <element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
049: * <element name="id-class" type="{http://java.sun.com/xml/ns/persistence/orm}id-class" minOccurs="0"/>
050: * <element name="exclude-default-listeners" type="{http://java.sun.com/xml/ns/persistence/orm}emptyType" minOccurs="0"/>
051: * <element name="exclude-superclass-listeners" type="{http://java.sun.com/xml/ns/persistence/orm}emptyType" minOccurs="0"/>
052: * <element name="entity-listeners" type="{http://java.sun.com/xml/ns/persistence/orm}entity-listeners" minOccurs="0"/>
053: * <element name="pre-persist" type="{http://java.sun.com/xml/ns/persistence/orm}pre-persist" minOccurs="0"/>
054: * <element name="post-persist" type="{http://java.sun.com/xml/ns/persistence/orm}post-persist" minOccurs="0"/>
055: * <element name="pre-remove" type="{http://java.sun.com/xml/ns/persistence/orm}pre-remove" minOccurs="0"/>
056: * <element name="post-remove" type="{http://java.sun.com/xml/ns/persistence/orm}post-remove" minOccurs="0"/>
057: * <element name="pre-update" type="{http://java.sun.com/xml/ns/persistence/orm}pre-update" minOccurs="0"/>
058: * <element name="post-update" type="{http://java.sun.com/xml/ns/persistence/orm}post-update" minOccurs="0"/>
059: * <element name="post-load" type="{http://java.sun.com/xml/ns/persistence/orm}post-load" minOccurs="0"/>
060: * <element name="attributes" type="{http://java.sun.com/xml/ns/persistence/orm}attributes" minOccurs="0"/>
061: * </sequence>
062: * <attribute name="access" type="{http://java.sun.com/xml/ns/persistence/orm}access-type" />
063: * <attribute name="class" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
064: * <attribute name="metadata-complete" type="{http://www.w3.org/2001/XMLSchema}boolean" />
065: * </restriction>
066: * </complexContent>
067: * </complexType>
068: * </pre>
069: *
070: *
071: */
072: @XmlAccessorType(XmlAccessType.FIELD)
073: @XmlType(name="mapped-superclass",propOrder={"description","idClass","excludeDefaultListeners","excludeSuperclassListeners","entityListeners","prePersist","postPersist","preRemove","postRemove","preUpdate","postUpdate","postLoad","attributes"})
074: public class MappedSuperclass implements Mapping {
075:
076: protected String description;
077: @XmlElement(name="id-class")
078: protected IdClass idClass;
079: @XmlElement(name="exclude-default-listeners")
080: protected EmptyType excludeDefaultListeners;
081: @XmlElement(name="exclude-superclass-listeners")
082: protected EmptyType excludeSuperclassListeners;
083: @XmlElement(name="entity-listeners")
084: protected EntityListeners entityListeners;
085: @XmlElement(name="pre-persist")
086: protected PrePersist prePersist;
087: @XmlElement(name="post-persist")
088: protected PostPersist postPersist;
089: @XmlElement(name="pre-remove")
090: protected PreRemove preRemove;
091: @XmlElement(name="post-remove")
092: protected PostRemove postRemove;
093: @XmlElement(name="pre-update")
094: protected PreUpdate preUpdate;
095: @XmlElement(name="post-update")
096: protected PostUpdate postUpdate;
097: @XmlElement(name="post-load")
098: protected PostLoad postLoad;
099: protected Attributes attributes;
100: @XmlAttribute
101: protected AccessType access;
102: @XmlAttribute(name="class",required=true)
103: protected String clazz;
104: @XmlAttribute(name="metadata-complete")
105: protected Boolean metadataComplete;
106:
107: public MappedSuperclass() {
108: }
109:
110: public MappedSuperclass(String clazz) {
111: this .clazz = clazz;
112: }
113:
114: /**
115: * Gets the value of the description property.
116: *
117: * @return
118: * possible object is
119: * {@link String }
120: *
121: */
122: public String getDescription() {
123: return description;
124: }
125:
126: /**
127: * Sets the value of the description property.
128: *
129: * @param value
130: * allowed object is
131: * {@link String }
132: *
133: */
134: public void setDescription(String value) {
135: this .description = value;
136: }
137:
138: /**
139: * Gets the value of the idClass property.
140: *
141: * @return
142: * possible object is
143: * {@link IdClass }
144: *
145: */
146: public IdClass getIdClass() {
147: return idClass;
148: }
149:
150: /**
151: * Sets the value of the idClass property.
152: *
153: * @param value
154: * allowed object is
155: * {@link IdClass }
156: *
157: */
158: public void setIdClass(IdClass value) {
159: this .idClass = value;
160: }
161:
162: /**
163: * Gets the value of the excludeDefaultListeners property.
164: *
165: * @return
166: * possible object is
167: * {@link boolean }
168: *
169: */
170: public boolean isExcludeDefaultListeners() {
171: return excludeDefaultListeners != null;
172: }
173:
174: /**
175: * Sets the value of the excludeDefaultListeners property.
176: *
177: * @param value
178: * allowed object is
179: * {@link boolean }
180: *
181: */
182: public void setExcludeDefaultListeners(boolean value) {
183: this .excludeDefaultListeners = value ? new EmptyType() : null;
184: }
185:
186: /**
187: * Gets the value of the excludeSuperclassListeners property.
188: *
189: * @return
190: * possible object is
191: * {@link boolean }
192: *
193: */
194: public boolean isExcludeSuperclassListeners() {
195: return excludeSuperclassListeners != null;
196: }
197:
198: /**
199: * Sets the value of the excludeSuperclassListeners property.
200: *
201: * @param value
202: * allowed object is
203: * {@link boolean }
204: *
205: */
206: public void setExcludeSuperclassListeners(boolean value) {
207: this .excludeSuperclassListeners = value ? new EmptyType()
208: : null;
209: }
210:
211: /**
212: * Gets the value of the entityListeners property.
213: *
214: * @return
215: * possible object is
216: * {@link EntityListeners }
217: *
218: */
219: public EntityListeners getEntityListeners() {
220: return entityListeners;
221: }
222:
223: /**
224: * Sets the value of the entityListeners property.
225: *
226: * @param value
227: * allowed object is
228: * {@link EntityListeners }
229: *
230: */
231: public void setEntityListeners(EntityListeners value) {
232: this .entityListeners = value;
233: }
234:
235: /**
236: * Gets the value of the prePersist property.
237: *
238: * @return
239: * possible object is
240: * {@link PrePersist }
241: *
242: */
243: public PrePersist getPrePersist() {
244: return prePersist;
245: }
246:
247: /**
248: * Sets the value of the prePersist property.
249: *
250: * @param value
251: * allowed object is
252: * {@link PrePersist }
253: *
254: */
255: public void setPrePersist(PrePersist value) {
256: this .prePersist = value;
257: }
258:
259: /**
260: * Gets the value of the postPersist property.
261: *
262: * @return
263: * possible object is
264: * {@link PostPersist }
265: *
266: */
267: public PostPersist getPostPersist() {
268: return postPersist;
269: }
270:
271: /**
272: * Sets the value of the postPersist property.
273: *
274: * @param value
275: * allowed object is
276: * {@link PostPersist }
277: *
278: */
279: public void setPostPersist(PostPersist value) {
280: this .postPersist = value;
281: }
282:
283: /**
284: * Gets the value of the preRemove property.
285: *
286: * @return
287: * possible object is
288: * {@link PreRemove }
289: *
290: */
291: public PreRemove getPreRemove() {
292: return preRemove;
293: }
294:
295: /**
296: * Sets the value of the preRemove property.
297: *
298: * @param value
299: * allowed object is
300: * {@link PreRemove }
301: *
302: */
303: public void setPreRemove(PreRemove value) {
304: this .preRemove = value;
305: }
306:
307: /**
308: * Gets the value of the postRemove property.
309: *
310: * @return
311: * possible object is
312: * {@link PostRemove }
313: *
314: */
315: public PostRemove getPostRemove() {
316: return postRemove;
317: }
318:
319: /**
320: * Sets the value of the postRemove property.
321: *
322: * @param value
323: * allowed object is
324: * {@link PostRemove }
325: *
326: */
327: public void setPostRemove(PostRemove value) {
328: this .postRemove = value;
329: }
330:
331: /**
332: * Gets the value of the preUpdate property.
333: *
334: * @return
335: * possible object is
336: * {@link PreUpdate }
337: *
338: */
339: public PreUpdate getPreUpdate() {
340: return preUpdate;
341: }
342:
343: /**
344: * Sets the value of the preUpdate property.
345: *
346: * @param value
347: * allowed object is
348: * {@link PreUpdate }
349: *
350: */
351: public void setPreUpdate(PreUpdate value) {
352: this .preUpdate = value;
353: }
354:
355: /**
356: * Gets the value of the postUpdate property.
357: *
358: * @return
359: * possible object is
360: * {@link PostUpdate }
361: *
362: */
363: public PostUpdate getPostUpdate() {
364: return postUpdate;
365: }
366:
367: /**
368: * Sets the value of the postUpdate property.
369: *
370: * @param value
371: * allowed object is
372: * {@link PostUpdate }
373: *
374: */
375: public void setPostUpdate(PostUpdate value) {
376: this .postUpdate = value;
377: }
378:
379: /**
380: * Gets the value of the postLoad property.
381: *
382: * @return
383: * possible object is
384: * {@link PostLoad }
385: *
386: */
387: public PostLoad getPostLoad() {
388: return postLoad;
389: }
390:
391: /**
392: * Sets the value of the postLoad property.
393: *
394: * @param value
395: * allowed object is
396: * {@link PostLoad }
397: *
398: */
399: public void setPostLoad(PostLoad value) {
400: this .postLoad = value;
401: }
402:
403: /**
404: * Gets the value of the attributes property.
405: *
406: * @return
407: * possible object is
408: * {@link Attributes }
409: *
410: */
411: public Attributes getAttributes() {
412: return attributes;
413: }
414:
415: /**
416: * Sets the value of the attributes property.
417: *
418: * @param value
419: * allowed object is
420: * {@link Attributes }
421: *
422: */
423: public void setAttributes(Attributes value) {
424: this .attributes = value;
425: }
426:
427: /**
428: * Gets the value of the access property.
429: *
430: * @return
431: * possible object is
432: * {@link AccessType }
433: *
434: */
435: public AccessType getAccess() {
436: return access;
437: }
438:
439: /**
440: * Sets the value of the access property.
441: *
442: * @param value
443: * allowed object is
444: * {@link AccessType }
445: *
446: */
447: public void setAccess(AccessType value) {
448: this .access = value;
449: }
450:
451: /**
452: * Gets the value of the clazz property.
453: *
454: * @return
455: * possible object is
456: * {@link String }
457: *
458: */
459: public String getClazz() {
460: return clazz;
461: }
462:
463: /**
464: * Sets the value of the clazz property.
465: *
466: * @param value
467: * allowed object is
468: * {@link String }
469: *
470: */
471: public void setClazz(String value) {
472: this .clazz = value;
473: }
474:
475: /**
476: * Gets the value of the metadataComplete property.
477: *
478: * @return
479: * possible object is
480: * {@link Boolean }
481: *
482: */
483: public Boolean isMetadataComplete() {
484: return metadataComplete;
485: }
486:
487: /**
488: * Sets the value of the metadataComplete property.
489: *
490: * @param value
491: * allowed object is
492: * {@link Boolean }
493: *
494: */
495: public void setMetadataComplete(Boolean value) {
496: this .metadataComplete = value;
497: }
498:
499: public void addField(Field field) {
500: if (field == null)
501: throw new NullPointerException("field is null");
502: if (field instanceof Id) {
503: if (attributes == null)
504: attributes = new Attributes();
505: attributes.getId().add((Id) field);
506: } else if (field instanceof Basic) {
507: if (attributes == null)
508: attributes = new Attributes();
509: attributes.getBasic().add((Basic) field);
510: } else if (field instanceof Transient) {
511: if (attributes == null)
512: attributes = new Attributes();
513: attributes.getTransient().add((Transient) field);
514: } else if (field instanceof AttributeOverride) {
515: throw new IllegalArgumentException(
516: "Mapped super class does not support attribute override");
517: } else {
518: throw new IllegalArgumentException("Unknown field type "
519: + field.getClass());
520: }
521: }
522: }
|