001: // .//GEN-BEGIN:1_be
002: /******************************************************
003: * Code Generated From JAFFA Framework Default Pattern
004: *
005: * The JAFFA Project can be found at http://jaffa.sourceforge.net
006: * and is available under the Lesser GNU Public License
007: ******************************************************/package org.jaffa.persistence.domainobjects;
008:
009: import org.apache.log4j.Logger;
010: import java.util.*;
011: import org.jaffa.datatypes.*;
012: import org.jaffa.metadata.*;
013: import org.jaffa.rules.RulesEngine;
014: import org.jaffa.persistence.*;
015: import org.jaffa.persistence.exceptions.*;
016: import org.jaffa.exceptions.FrameworkException;
017: import org.jaffa.exceptions.RelatedDomainObjectFoundException;
018: import org.jaffa.exceptions.DuplicateKeyException;
019: import org.jaffa.datatypes.exceptions.InvalidForeignKeyException;
020: import org.jaffa.exceptions.ApplicationExceptions;
021:
022: import org.jaffa.persistence.domainobjects.Asset;
023: import org.jaffa.persistence.domainobjects.AssetMeta;
024: import org.jaffa.persistence.domainobjects.Item;
025: import org.jaffa.persistence.domainobjects.ItemMeta;
026: import org.jaffa.persistence.domainobjects.CategoryOfInstrument;
027: import org.jaffa.persistence.domainobjects.CategoryOfInstrumentMeta;
028: import org.jaffa.persistence.domainobjects.PartRemarks;
029: import org.jaffa.persistence.domainobjects.PartRemarksMeta;
030: import org.jaffa.persistence.domainobjects.PartPicture;
031: import org.jaffa.persistence.domainobjects.PartPictureMeta;
032: import org.jaffa.persistence.domainobjects.PartRemarksPicture;
033: import org.jaffa.persistence.domainobjects.PartRemarksPictureMeta;
034:
035: // .//GEN-END:1_be
036: // Add additional imports//GEN-FIRST:imports
037:
038: // .//GEN-LAST:imports
039: // .//GEN-BEGIN:2_be
040: /**
041: * Auto Generated Persistent class for the ZZ_JUT_PART table.
042: * @author Auto-Generated
043: */
044: public class Part extends Persistent {
045:
046: private static final Logger log = Logger.getLogger(Part.class);
047:
048: /** Holds value of property part. */
049: private java.lang.String m_part;
050:
051: /** Holds value of property noun. */
052: private java.lang.String m_noun;
053:
054: /** Holds value of property categoryInstrument. */
055: private java.lang.String m_categoryInstrument;
056:
057: /** Holds related Asset objects. */
058: private transient Collection m_assetCollection;
059:
060: /** Holds related Item objects. */
061: private transient Collection m_itemCollection;
062:
063: /** Holds related foreign CategoryOfInstrument object. */
064: private transient CategoryOfInstrument m_categoryOfInstrumentObject;
065:
066: /** Holds related PartRemarks object. */
067: private transient PartRemarks m_partRemarksObject;
068:
069: /** Holds related PartPicture object. */
070: private transient PartPicture m_partPictureObject;
071:
072: /** Holds related PartRemarksPicture object. */
073: private transient PartRemarksPicture m_partRemarksPictureObject;
074:
075: /** Check if the domain object exists for the input Primary Key.
076: * @return true if the domain object exists for the input Primary Key.
077: * @throws FrameworkException Indicates some system error
078: */
079: public static boolean exists(UOW uow, java.lang.String part)
080: throws FrameworkException {
081: return findByPK(uow, part) != null ? true : false;
082: }
083:
084: /** Returns the domain object for the input Primary Key.
085: * @return the domain object for the input Primary Key. A null is returned if the domain object is not found.
086: * @throws FrameworkException Indicates some system error
087: */
088: public static Part findByPK(UOW uow, java.lang.String part)
089: throws FrameworkException {
090: boolean localUow = false;
091: try {
092: if (uow == null || !uow.isActive()) {
093: uow = new UOW();
094: localUow = true;
095: }
096: Criteria criteria = findByPKCriteria(part);
097: Iterator itr = uow.query(criteria).iterator();
098: if (itr.hasNext())
099: return (Part) itr.next();
100: else
101: return null;
102: } finally {
103: if (localUow && uow != null)
104: uow.rollback();
105: }
106: }
107:
108: /** Returns a Criteria object for retrieving the domain object based on the input Primary Key.
109: * @return a Criteria object for retrieving the domain object based on the input Primary Key.
110: */
111: public static Criteria findByPKCriteria(java.lang.String part) {
112: Criteria criteria = new Criteria();
113: criteria.setTable(PartMeta.getName());
114: criteria.addCriteria(PartMeta.PART, part);
115: return criteria;
116: }
117:
118: // .//GEN-END:2_be
119: // .//GEN-BEGIN:part_be
120: /** Getter for property part.
121: * @return Value of property part.
122: */
123: public java.lang.String getPart() {
124: return m_part;
125: }
126:
127: /** Use this method to update the property part.
128: * This method will do nothing and simply return if the input value is the same as the current value.
129: * Validation will be performed on the input value.
130: * This will try to lock the underlying database row, in case CAUTIOUS locking is specified at the time of query.
131: * @param part New value of property part.
132: * @throws ValidationException if an invalid value is passed.
133: * @throws UpdatePrimaryKeyException if this domain object was loaded from the database.
134: * @throws ReadOnlyObjectException if a Read-Only object is updated.
135: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
136: * @throws FrameworkException Indicates some system error
137: */
138: public void setPart(java.lang.String part)
139: throws ValidationException, UpdatePrimaryKeyException,
140: ReadOnlyObjectException, AlreadyLockedObjectException,
141: FrameworkException {
142: // ignore, if the current value and new value are the same
143: if (m_part == null ? part == null : m_part.equals(part))
144: return;
145:
146: // this is part of the primary key.. do not update if its a database occurence.
147: if (isDatabaseOccurence())
148: throw new UpdatePrimaryKeyException();
149:
150: part = validatePart(part);
151: // .//GEN-END:part_be
152: // Add custom code before setting the value//GEN-FIRST:part
153:
154: // .//GEN-LAST:part
155: // .//GEN-BEGIN:part_1_be
156: super .update();
157: super .addInitialValue(PartMeta.PART, m_part);
158: m_part = part;
159: m_partRemarksObject = null;
160: m_partPictureObject = null;
161: m_partRemarksPictureObject = null;
162: // .//GEN-END:part_1_be
163: // Add custom code after setting the value//GEN-FIRST:part_3
164:
165: // .//GEN-LAST:part_3
166: // .//GEN-BEGIN:part_2_be
167: }
168:
169: /** This method is present for backwards compatibility only.
170: * It merely invokes the setPart() method.
171: * @param part New value of property part.
172: * @throws ValidationException if an invalid value is passed.
173: * @throws UpdatePrimaryKeyException if this domain object was loaded from the database.
174: * @throws ReadOnlyObjectException if a Read-Only object is updated.
175: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
176: * @throws FrameworkException Indicates some system error
177: */
178: public void updatePart(java.lang.String part)
179: throws ValidationException, UpdatePrimaryKeyException,
180: ReadOnlyObjectException, AlreadyLockedObjectException,
181: FrameworkException {
182: setPart(part);
183: }
184:
185: /** Use this method to validate a value for the property part.
186: * @param part Value to be validated for the property part.
187: * @throws ValidationException if an invalid value is passed
188: * @throws FrameworkException Indicates some system error
189: */
190: public java.lang.String validatePart(java.lang.String part)
191: throws ValidationException, FrameworkException {
192: // .//GEN-END:part_2_be
193: // Add custom code before validation//GEN-FIRST:part_1
194:
195: // .//GEN-LAST:part_1
196: // .//GEN-BEGIN:part_3_be
197: part = FieldValidator.validate(part,
198: (StringFieldMetaData) PartMeta.META_PART, true);
199:
200: // Invoke the Dynamic Rules Engine
201: RulesEngine.doAllValidationsForDomainField(PartMeta.getName(),
202: PartMeta.PART, part, this .getUOW());
203:
204: // .//GEN-END:part_3_be
205: // Add custom code after a successful validation//GEN-FIRST:part_2
206:
207: // .//GEN-LAST:part_2
208: // .//GEN-BEGIN:part_4_be
209: return part;
210: }
211:
212: // .//GEN-END:part_4_be
213: // .//GEN-BEGIN:noun_be
214: /** Getter for property noun.
215: * @return Value of property noun.
216: */
217: public java.lang.String getNoun() {
218: return m_noun;
219: }
220:
221: /** Use this method to update the property noun.
222: * This method will do nothing and simply return if the input value is the same as the current value.
223: * Validation will be performed on the input value.
224: * This will try to lock the underlying database row, in case CAUTIOUS locking is specified at the time of query.
225: * @param noun New value of property noun.
226: * @throws ValidationException if an invalid value is passed.
227: * @throws ReadOnlyObjectException if a Read-Only object is updated.
228: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
229: * @throws FrameworkException Indicates some system error
230: */
231: public void setNoun(java.lang.String noun)
232: throws ValidationException, ReadOnlyObjectException,
233: AlreadyLockedObjectException, FrameworkException {
234: // ignore, if the current value and new value are the same
235: if (m_noun == null ? noun == null : m_noun.equals(noun))
236: return;
237:
238: noun = validateNoun(noun);
239: // .//GEN-END:noun_be
240: // Add custom code before setting the value//GEN-FIRST:noun
241:
242: // .//GEN-LAST:noun
243: // .//GEN-BEGIN:noun_1_be
244: super .update();
245: super .addInitialValue(PartMeta.NOUN, m_noun);
246: m_noun = noun;
247: // .//GEN-END:noun_1_be
248: // Add custom code after setting the value//GEN-FIRST:noun_3
249:
250: // .//GEN-LAST:noun_3
251: // .//GEN-BEGIN:noun_2_be
252: }
253:
254: /** This method is present for backwards compatibility only.
255: * It merely invokes the setNoun() method.
256: * @param noun New value of property noun.
257: * @throws ValidationException if an invalid value is passed.
258: * @throws ReadOnlyObjectException if a Read-Only object is updated.
259: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
260: * @throws FrameworkException Indicates some system error
261: */
262: public void updateNoun(java.lang.String noun)
263: throws ValidationException, ReadOnlyObjectException,
264: AlreadyLockedObjectException, FrameworkException {
265: setNoun(noun);
266: }
267:
268: /** Use this method to validate a value for the property noun.
269: * @param noun Value to be validated for the property noun.
270: * @throws ValidationException if an invalid value is passed
271: * @throws FrameworkException Indicates some system error
272: */
273: public java.lang.String validateNoun(java.lang.String noun)
274: throws ValidationException, FrameworkException {
275: // .//GEN-END:noun_2_be
276: // Add custom code before validation//GEN-FIRST:noun_1
277:
278: // .//GEN-LAST:noun_1
279: // .//GEN-BEGIN:noun_3_be
280: noun = FieldValidator.validate(noun,
281: (StringFieldMetaData) PartMeta.META_NOUN, true);
282:
283: // Invoke the Dynamic Rules Engine
284: RulesEngine.doAllValidationsForDomainField(PartMeta.getName(),
285: PartMeta.NOUN, noun, this .getUOW());
286:
287: // .//GEN-END:noun_3_be
288: // Add custom code after a successful validation//GEN-FIRST:noun_2
289:
290: // .//GEN-LAST:noun_2
291: // .//GEN-BEGIN:noun_4_be
292: return noun;
293: }
294:
295: // .//GEN-END:noun_4_be
296: // .//GEN-BEGIN:categoryInstrument_be
297: /** Getter for property categoryInstrument.
298: * @return Value of property categoryInstrument.
299: */
300: public java.lang.String getCategoryInstrument() {
301: return m_categoryInstrument;
302: }
303:
304: /** Use this method to update the property categoryInstrument.
305: * This method will do nothing and simply return if the input value is the same as the current value.
306: * Validation will be performed on the input value.
307: * This will try to lock the underlying database row, in case CAUTIOUS locking is specified at the time of query.
308: * @param categoryInstrument New value of property categoryInstrument.
309: * @throws ValidationException if an invalid value is passed.
310: * @throws ReadOnlyObjectException if a Read-Only object is updated.
311: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
312: * @throws FrameworkException Indicates some system error
313: */
314: public void setCategoryInstrument(
315: java.lang.String categoryInstrument)
316: throws ValidationException, ReadOnlyObjectException,
317: AlreadyLockedObjectException, FrameworkException {
318: // ignore, if the current value and new value are the same
319: if (m_categoryInstrument == null ? categoryInstrument == null
320: : m_categoryInstrument.equals(categoryInstrument))
321: return;
322:
323: categoryInstrument = validateCategoryInstrument(categoryInstrument);
324: // .//GEN-END:categoryInstrument_be
325: // Add custom code before setting the value//GEN-FIRST:categoryInstrument
326:
327: // .//GEN-LAST:categoryInstrument
328: // .//GEN-BEGIN:categoryInstrument_1_be
329: super .update();
330: super .addInitialValue(PartMeta.CATEGORY_INSTRUMENT,
331: m_categoryInstrument);
332: m_categoryInstrument = categoryInstrument;
333: m_categoryOfInstrumentObject = null;
334: // .//GEN-END:categoryInstrument_1_be
335: // Add custom code after setting the value//GEN-FIRST:categoryInstrument_3
336:
337: // .//GEN-LAST:categoryInstrument_3
338: // .//GEN-BEGIN:categoryInstrument_2_be
339: }
340:
341: /** This method is present for backwards compatibility only.
342: * It merely invokes the setCategoryInstrument() method.
343: * @param categoryInstrument New value of property categoryInstrument.
344: * @throws ValidationException if an invalid value is passed.
345: * @throws ReadOnlyObjectException if a Read-Only object is updated.
346: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
347: * @throws FrameworkException Indicates some system error
348: */
349: public void updateCategoryInstrument(
350: java.lang.String categoryInstrument)
351: throws ValidationException, ReadOnlyObjectException,
352: AlreadyLockedObjectException, FrameworkException {
353: setCategoryInstrument(categoryInstrument);
354: }
355:
356: /** Use this method to validate a value for the property categoryInstrument.
357: * @param categoryInstrument Value to be validated for the property categoryInstrument.
358: * @throws ValidationException if an invalid value is passed
359: * @throws FrameworkException Indicates some system error
360: */
361: public java.lang.String validateCategoryInstrument(
362: java.lang.String categoryInstrument)
363: throws ValidationException, FrameworkException {
364: // .//GEN-END:categoryInstrument_2_be
365: // Add custom code before validation//GEN-FIRST:categoryInstrument_1
366:
367: // .//GEN-LAST:categoryInstrument_1
368: // .//GEN-BEGIN:categoryInstrument_3_be
369: categoryInstrument = FieldValidator
370: .validate(
371: categoryInstrument,
372: (StringFieldMetaData) PartMeta.META_CATEGORY_INSTRUMENT,
373: true);
374:
375: // Invoke the Dynamic Rules Engine
376: RulesEngine.doAllValidationsForDomainField(PartMeta.getName(),
377: PartMeta.CATEGORY_INSTRUMENT, categoryInstrument, this
378: .getUOW());
379:
380: // .//GEN-END:categoryInstrument_3_be
381: // Add custom code after a successful validation//GEN-FIRST:categoryInstrument_2
382:
383: // .//GEN-LAST:categoryInstrument_2
384: // .//GEN-BEGIN:categoryInstrument_4_be
385: return categoryInstrument;
386: }
387:
388: // .//GEN-END:categoryInstrument_4_be
389: // .//GEN-BEGIN:assetArray_1_be
390: /** Returns an array of related Asset objects.
391: * @return an array of related Asset objects.
392: * @throws FrameworkException Indicates some system error
393: */
394: public Asset[] getAssetArray() throws FrameworkException {
395: UOW uow = getUOW();
396: boolean localUow = false;
397: try {
398: Asset[] output = null;
399: if (m_assetCollection == null && isDatabaseOccurence()) {
400: Criteria criteria = findAssetCriteria();
401: if (uow == null || !uow.isActive()) {
402: uow = new UOW();
403: localUow = true;
404: }
405: Collection col = uow.query(criteria);
406: m_assetCollection = new ArrayList();
407: for (Iterator itr = col.iterator(); itr.hasNext();)
408: m_assetCollection.add(itr.next());
409: }
410:
411: if (m_assetCollection != null)
412: output = (Asset[]) m_assetCollection
413: .toArray(new Asset[0]);
414: return output;
415: } finally {
416: if (localUow && uow != null)
417: uow.rollback();
418: }
419: }
420:
421: /** Returns a Criteria object for retrieving the related Asset objects.
422: * @return a Criteria object for retrieving the related Asset objects.
423: */
424: public Criteria findAssetCriteria() {
425: Criteria criteria = new Criteria();
426: criteria.setTable(AssetMeta.getName());
427: criteria.addCriteria(AssetMeta.PART, getPart());
428: // .//GEN-END:assetArray_1_be
429: // Add custom criteria//GEN-FIRST:assetArray_1
430:
431: // .//GEN-LAST:assetArray_1
432: // .//GEN-BEGIN:assetArray_2_be
433: return criteria;
434: }
435:
436: /** Creates a new Asset object and initializes the related fields.
437: * This will uncache the related Asset objects.
438: * @throws ValidationException if an invalid value is passed.
439: * @throws FrameworkException Indicates some system error
440: * @return the related Asset object with the initialized related fields.
441: */
442: public Asset newAssetObject() throws ValidationException,
443: FrameworkException {
444: m_assetCollection = null;
445: Asset asset = new Asset();
446: asset.setPart(getPart());
447: // .//GEN-END:assetArray_2_be
448: // Add custom code//GEN-FIRST:assetArray_2
449:
450: // .//GEN-LAST:assetArray_2
451: // .//GEN-BEGIN:assetArray_3_be
452: return asset;
453: }
454:
455: // .//GEN-END:assetArray_3_be
456: // .//GEN-BEGIN:itemArray_1_be
457: /** Returns an array of related Item objects.
458: * @return an array of related Item objects.
459: * @throws FrameworkException Indicates some system error
460: */
461: public Item[] getItemArray() throws FrameworkException {
462: UOW uow = getUOW();
463: boolean localUow = false;
464: try {
465: Item[] output = null;
466: if (m_itemCollection == null && isDatabaseOccurence()) {
467: Criteria criteria = findItemCriteria();
468: if (uow == null || !uow.isActive()) {
469: uow = new UOW();
470: localUow = true;
471: }
472: Collection col = uow.query(criteria);
473: m_itemCollection = new ArrayList();
474: for (Iterator itr = col.iterator(); itr.hasNext();)
475: m_itemCollection.add(itr.next());
476: }
477:
478: if (m_itemCollection != null)
479: output = (Item[]) m_itemCollection.toArray(new Item[0]);
480: return output;
481: } finally {
482: if (localUow && uow != null)
483: uow.rollback();
484: }
485: }
486:
487: /** Returns a Criteria object for retrieving the related Item objects.
488: * @return a Criteria object for retrieving the related Item objects.
489: */
490: public Criteria findItemCriteria() {
491: Criteria criteria = new Criteria();
492: criteria.setTable(ItemMeta.getName());
493: criteria.addCriteria(ItemMeta.PART, getPart());
494: // .//GEN-END:itemArray_1_be
495: // Add custom criteria//GEN-FIRST:itemArray_1
496:
497: // .//GEN-LAST:itemArray_1
498: // .//GEN-BEGIN:itemArray_2_be
499: return criteria;
500: }
501:
502: /** Creates a new Item object and initializes the related fields.
503: * This will uncache the related Item objects.
504: * @throws ValidationException if an invalid value is passed.
505: * @throws FrameworkException Indicates some system error
506: * @return the related Item object with the initialized related fields.
507: */
508: public Item newItemObject() throws ValidationException,
509: FrameworkException {
510: m_itemCollection = null;
511: Item item = new Item();
512: item.setPart(getPart());
513: // .//GEN-END:itemArray_2_be
514: // Add custom code//GEN-FIRST:itemArray_2
515:
516: // .//GEN-LAST:itemArray_2
517: // .//GEN-BEGIN:itemArray_3_be
518: return item;
519: }
520:
521: // .//GEN-END:itemArray_3_be
522: // .//GEN-BEGIN:categoryOfInstrumentObject_1_be
523: /** Returns the related foreign CategoryOfInstrument object.
524: * The object is lazy-loaded.
525: * @return the related foreign CategoryOfInstrument object.
526: * @throws ValidationException if an invalid foreign key is set.
527: * @throws FrameworkException Indicates some system error
528: */
529: public CategoryOfInstrument getCategoryOfInstrumentObject()
530: throws ValidationException, FrameworkException {
531: UOW uow = getUOW();
532: boolean localUow = false;
533: try {
534: if (m_categoryOfInstrumentObject == null
535: && getCategoryInstrument() != null) {
536: Criteria criteria = new Criteria();
537: criteria.setTable(CategoryOfInstrumentMeta.getName());
538: criteria.addCriteria(
539: CategoryOfInstrumentMeta.CATEGORY_INSTRUMENT,
540: getCategoryInstrument());
541: if (uow == null || !uow.isActive()) {
542: uow = new UOW();
543: localUow = true;
544: }
545: Iterator itr = uow.query(criteria).iterator();
546: if (itr.hasNext())
547: m_categoryOfInstrumentObject = (CategoryOfInstrument) itr
548: .next();
549: if (m_categoryOfInstrumentObject == null)
550: throw new InvalidForeignKeyException(
551: PartMeta.META_CATEGORY_INSTRUMENT
552: .getLabelToken(),
553: new Object[] {
554: CategoryOfInstrumentMeta
555: .getLabelToken(),
556: CategoryOfInstrumentMeta.META_CATEGORY_INSTRUMENT
557: .getLabelToken() });
558: }
559: return m_categoryOfInstrumentObject;
560: } finally {
561: if (localUow && uow != null)
562: uow.rollback();
563: }
564: }
565:
566: // .//GEN-END:categoryOfInstrumentObject_1_be
567: // .//GEN-BEGIN:partRemarksObject_1_be
568: /** Returns a related PartRemarks object.
569: * @return a related PartRemarks object.
570: * @throws FrameworkException Indicates some system error
571: */
572: public PartRemarks getPartRemarksObject() throws FrameworkException {
573: UOW uow = getUOW();
574: boolean localUow = false;
575: try {
576: if (m_partRemarksObject == null && getPart() != null) {
577: Criteria criteria = new Criteria();
578: criteria.setTable(PartRemarksMeta.getName());
579: criteria.addCriteria(PartRemarksMeta.PART, getPart());
580: if (uow == null || !uow.isActive()) {
581: uow = new UOW();
582: localUow = true;
583: }
584: Iterator itr = uow.query(criteria).iterator();
585: if (itr.hasNext())
586: m_partRemarksObject = (PartRemarks) itr.next();
587: }
588: return m_partRemarksObject;
589: } finally {
590: if (localUow && uow != null)
591: uow.rollback();
592: }
593: }
594:
595: /** Creates a new PartRemarks object and initializes the related fields.
596: * @throws ValidationException if an invalid value is passed.
597: * @throws FrameworkException Indicates some system error
598: * @return the related PartRemarks object with the initialized related fields.
599: */
600: public PartRemarks newPartRemarksObject()
601: throws ValidationException, FrameworkException {
602: PartRemarks partRemarks = new PartRemarks();
603: partRemarks.setPart(getPart());
604: // .//GEN-END:partRemarksObject_1_be
605: // Add custom code//GEN-FIRST:partRemarksObject_1
606:
607: // .//GEN-LAST:partRemarksObject_1
608: // .//GEN-BEGIN:partRemarksObject_2_be
609: return partRemarks;
610: }
611:
612: // .//GEN-END:partRemarksObject_2_be
613: // .//GEN-BEGIN:partPictureObject_1_be
614: /** Returns a related PartPicture object.
615: * @return a related PartPicture object.
616: * @throws FrameworkException Indicates some system error
617: */
618: public PartPicture getPartPictureObject() throws FrameworkException {
619: UOW uow = getUOW();
620: boolean localUow = false;
621: try {
622: if (m_partPictureObject == null && getPart() != null) {
623: Criteria criteria = new Criteria();
624: criteria.setTable(PartPictureMeta.getName());
625: criteria.addCriteria(PartPictureMeta.PART, getPart());
626: if (uow == null || !uow.isActive()) {
627: uow = new UOW();
628: localUow = true;
629: }
630: Iterator itr = uow.query(criteria).iterator();
631: if (itr.hasNext())
632: m_partPictureObject = (PartPicture) itr.next();
633: }
634: return m_partPictureObject;
635: } finally {
636: if (localUow && uow != null)
637: uow.rollback();
638: }
639: }
640:
641: /** Creates a new PartPicture object and initializes the related fields.
642: * @throws ValidationException if an invalid value is passed.
643: * @throws FrameworkException Indicates some system error
644: * @return the related PartPicture object with the initialized related fields.
645: */
646: public PartPicture newPartPictureObject()
647: throws ValidationException, FrameworkException {
648: PartPicture partPicture = new PartPicture();
649: partPicture.setPart(getPart());
650: // .//GEN-END:partPictureObject_1_be
651: // Add custom code//GEN-FIRST:partPictureObject_1
652:
653: // .//GEN-LAST:partPictureObject_1
654: // .//GEN-BEGIN:partPictureObject_2_be
655: return partPicture;
656: }
657:
658: // .//GEN-END:partPictureObject_2_be
659: // .//GEN-BEGIN:partRemarksPictureObject_1_be
660: /** Returns a related PartRemarksPicture object.
661: * @return a related PartRemarksPicture object.
662: * @throws FrameworkException Indicates some system error
663: */
664: public PartRemarksPicture getPartRemarksPictureObject()
665: throws FrameworkException {
666: UOW uow = getUOW();
667: boolean localUow = false;
668: try {
669: if (m_partRemarksPictureObject == null && getPart() != null) {
670: Criteria criteria = new Criteria();
671: criteria.setTable(PartRemarksPictureMeta.getName());
672: criteria.addCriteria(PartRemarksPictureMeta.PART,
673: getPart());
674: if (uow == null || !uow.isActive()) {
675: uow = new UOW();
676: localUow = true;
677: }
678: Iterator itr = uow.query(criteria).iterator();
679: if (itr.hasNext())
680: m_partRemarksPictureObject = (PartRemarksPicture) itr
681: .next();
682: }
683: return m_partRemarksPictureObject;
684: } finally {
685: if (localUow && uow != null)
686: uow.rollback();
687: }
688: }
689:
690: /** Creates a new PartRemarksPicture object and initializes the related fields.
691: * @throws ValidationException if an invalid value is passed.
692: * @throws FrameworkException Indicates some system error
693: * @return the related PartRemarksPicture object with the initialized related fields.
694: */
695: public PartRemarksPicture newPartRemarksPictureObject()
696: throws ValidationException, FrameworkException {
697: PartRemarksPicture partRemarksPicture = new PartRemarksPicture();
698: partRemarksPicture.setPart(getPart());
699: // .//GEN-END:partRemarksPictureObject_1_be
700: // Add custom code//GEN-FIRST:partRemarksPictureObject_1
701:
702: // .//GEN-LAST:partRemarksPictureObject_1
703: // .//GEN-BEGIN:partRemarksPictureObject_2_be
704: return partRemarksPicture;
705: }
706:
707: // .//GEN-END:partRemarksPictureObject_2_be
708: // .//GEN-BEGIN:toString_1_be
709: /** This returns the diagnostic information.
710: * @return the diagnostic information.
711: */
712: public String toString() {
713: StringBuffer buf = new StringBuffer();
714: buf.append("<Part>");
715: buf.append("<part>");
716: if (m_part != null)
717: buf.append(m_part);
718: buf.append("</part>");
719: buf.append("<noun>");
720: if (m_noun != null)
721: buf.append(m_noun);
722: buf.append("</noun>");
723: buf.append("<categoryInstrument>");
724: if (m_categoryInstrument != null)
725: buf.append(m_categoryInstrument);
726: buf.append("</categoryInstrument>");
727: // .//GEN-END:toString_1_be
728: // Add custom debug information//GEN-FIRST:toString_1
729:
730: // .//GEN-LAST:toString_1
731: // .//GEN-BEGIN:toString_2_be
732: buf.append(super .toString());
733: buf.append("</Part>");
734: return buf.toString();
735: }
736:
737: // .//GEN-END:toString_2_be
738: // .//GEN-BEGIN:clone_1_be
739: /** Returns a clone of the object.
740: * @throws CloneNotSupportedException if cloning is not supported. This should never happen.
741: * @return a clone of the object.
742: */
743: public Object clone() throws CloneNotSupportedException {
744: Part obj = (Part) super .clone();
745: obj.m_assetCollection = null;
746: obj.m_itemCollection = null;
747: obj.m_categoryOfInstrumentObject = null;
748: obj.m_partRemarksObject = null;
749: obj.m_partPictureObject = null;
750: obj.m_partRemarksPictureObject = null;
751: return obj;
752: }
753:
754: // .//GEN-END:clone_1_be
755: // .//GEN-BEGIN:performForeignKeyValidations_1_be
756: /** This method ensures that the modified foreign-keys are valid.
757: * @throws ApplicationExceptions if an invalid foreign key is set.
758: * @throws FrameworkException Indicates some system error
759: */
760: public void performForeignKeyValidations()
761: throws ApplicationExceptions, FrameworkException {
762: ApplicationExceptions appExps = new ApplicationExceptions();
763: try {
764: if (isModified(PartMeta.CATEGORY_INSTRUMENT))
765: getCategoryOfInstrumentObject();
766: } catch (ValidationException e) {
767: appExps.add(e);
768: }
769: if (appExps.size() > 0)
770: throw appExps;
771: }
772:
773: // .//GEN-END:performForeignKeyValidations_1_be
774: // .//GEN-BEGIN:performPreDeleteReferentialIntegrity_1_be
775: /** This method is triggered by the UOW, before adding this object to the Delete-Store.
776: * This will raise an exception if any associated/aggregated objects exist.
777: * This will cascade delete all composite objects.
778: * @throws PreDeleteFailedException if any error occurs during the process.
779: */
780: public void performPreDeleteReferentialIntegrity()
781: throws PreDeleteFailedException {
782: Asset[] assetArray = null;
783: try {
784: assetArray = getAssetArray();
785: } catch (FrameworkException e) {
786: throw new PreDeleteFailedException(null, e);
787: }
788: if (assetArray != null && assetArray.length > 0) {
789: try {
790: // Perform cascade deletes
791: for (int i = 0; i < assetArray.length; i++)
792: getUOW().delete(assetArray[i]);
793: } catch (Exception e) {
794: throw new PreDeleteFailedException(null, e);
795: }
796: }
797: Item[] itemArray = null;
798: try {
799: itemArray = getItemArray();
800: } catch (FrameworkException e) {
801: throw new PreDeleteFailedException(null, e);
802: }
803: if (itemArray != null && itemArray.length > 0) {
804: try {
805: // Perform cascade deletes
806: for (int i = 0; i < itemArray.length; i++)
807: getUOW().delete(itemArray[i]);
808: } catch (Exception e) {
809: throw new PreDeleteFailedException(null, e);
810: }
811: }
812: PartRemarks partRemarksObject = null;
813: try {
814: partRemarksObject = getPartRemarksObject();
815: } catch (FrameworkException e) {
816: throw new PreDeleteFailedException(null, e);
817: }
818: if (partRemarksObject != null) {
819: // Stop the deletion !!
820: throw new PreDeleteFailedException(null,
821: new RelatedDomainObjectFoundException(
822: PartRemarksMeta.getLabelToken()));
823: }
824: PartPicture partPictureObject = null;
825: try {
826: partPictureObject = getPartPictureObject();
827: } catch (FrameworkException e) {
828: throw new PreDeleteFailedException(null, e);
829: }
830: if (partPictureObject != null) {
831: try {
832: // Perform cascade delete
833: getUOW().delete(partPictureObject);
834: } catch (Exception e) {
835: throw new PreDeleteFailedException(null, e);
836: }
837: }
838: PartRemarksPicture partRemarksPictureObject = null;
839: try {
840: partRemarksPictureObject = getPartRemarksPictureObject();
841: } catch (FrameworkException e) {
842: throw new PreDeleteFailedException(null, e);
843: }
844: if (partRemarksPictureObject != null) {
845: try {
846: // Perform cascade delete
847: getUOW().delete(partRemarksPictureObject);
848: } catch (Exception e) {
849: throw new PreDeleteFailedException(null, e);
850: }
851: }
852: }
853: // .//GEN-END:performPreDeleteReferentialIntegrity_1_be
854: // .//GEN-BEGIN:3_be
855: /**
856: * @clientCardinality 1
857: * @supplierCardinality 0..*
858: * @clientQualifier part
859: * @supplierQualifier part
860: * @link composition
861: */
862: /*#Asset lnkAsset;*/
863:
864: /**
865: * @clientCardinality 1
866: * @supplierCardinality 0..*
867: * @clientQualifier part
868: * @supplierQualifier part
869: * @link composition
870: */
871: /*#Item lnkItem;*/
872:
873: /**
874: * @clientCardinality 0..*
875: * @supplierCardinality 1
876: * @clientQualifier categoryInstrument
877: * @supplierQualifier categoryInstrument
878: * @link association
879: */
880: /*#CategoryOfInstrument lnkCategoryOfInstrument;*/
881:
882: /**
883: * @clientCardinality 1
884: * @supplierCardinality 0..1
885: * @clientQualifier part
886: * @supplierQualifier part
887: * @link association
888: */
889: /*#PartRemarks lnkPartRemarks;*/
890:
891: /**
892: * @clientCardinality 1
893: * @supplierCardinality 0..1
894: * @clientQualifier part
895: * @supplierQualifier part
896: * @link composition
897: */
898: /*#PartPicture lnkPartPicture;*/
899:
900: /**
901: * @clientCardinality 1
902: * @supplierCardinality 0..1
903: * @clientQualifier part
904: * @supplierQualifier part
905: * @link composition
906: */
907: /*#PartRemarksPicture lnkPartRemarksPicture;*/
908:
909: // .//GEN-END:3_be
910: // All the custom code goes here//GEN-FIRST:custom
911:
912: // .//GEN-LAST:custom
913: }
|