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.Part;
023: import org.jaffa.persistence.domainobjects.PartMeta;
024:
025: // .//GEN-END:1_be
026: // Add additional imports//GEN-FIRST:imports
027:
028: // .//GEN-LAST:imports
029: // .//GEN-BEGIN:2_be
030: /**
031: * Auto Generated Persistent class for the ZZ_JUT_PART_REM_PIC table.
032: * @author Auto-Generated
033: */
034: public class PartRemarksPicture extends Persistent {
035:
036: private static final Logger log = Logger
037: .getLogger(PartRemarksPicture.class);
038:
039: /** Holds value of property part. */
040: private java.lang.String m_part;
041:
042: /** Holds value of property remarks. */
043: private java.lang.String m_remarks;
044:
045: /** Holds value of property picture. */
046: private byte[] m_picture;
047:
048: /** Holds related Part object. */
049: private transient Part m_partObject;
050:
051: /** Check if the domain object exists for the input Primary Key.
052: * @return true if the domain object exists for the input Primary Key.
053: * @throws FrameworkException Indicates some system error
054: */
055: public static boolean exists(UOW uow, java.lang.String part)
056: throws FrameworkException {
057: return findByPK(uow, part) != null ? true : false;
058: }
059:
060: /** Returns the domain object for the input Primary Key.
061: * @return the domain object for the input Primary Key. A null is returned if the domain object is not found.
062: * @throws FrameworkException Indicates some system error
063: */
064: public static PartRemarksPicture findByPK(UOW uow,
065: java.lang.String part) throws FrameworkException {
066: boolean localUow = false;
067: try {
068: if (uow == null || !uow.isActive()) {
069: uow = new UOW();
070: localUow = true;
071: }
072: Criteria criteria = findByPKCriteria(part);
073: Iterator itr = uow.query(criteria).iterator();
074: if (itr.hasNext())
075: return (PartRemarksPicture) itr.next();
076: else
077: return null;
078: } finally {
079: if (localUow && uow != null)
080: uow.rollback();
081: }
082: }
083:
084: /** Returns a Criteria object for retrieving the domain object based on the input Primary Key.
085: * @return a Criteria object for retrieving the domain object based on the input Primary Key.
086: */
087: public static Criteria findByPKCriteria(java.lang.String part) {
088: Criteria criteria = new Criteria();
089: criteria.setTable(PartRemarksPictureMeta.getName());
090: criteria.addCriteria(PartRemarksPictureMeta.PART, part);
091: return criteria;
092: }
093:
094: // .//GEN-END:2_be
095: // .//GEN-BEGIN:part_be
096: /** Getter for property part.
097: * @return Value of property part.
098: */
099: public java.lang.String getPart() {
100: return m_part;
101: }
102:
103: /** Use this method to update the property part.
104: * This method will do nothing and simply return if the input value is the same as the current value.
105: * Validation will be performed on the input value.
106: * This will try to lock the underlying database row, in case CAUTIOUS locking is specified at the time of query.
107: * @param part New value of property part.
108: * @throws ValidationException if an invalid value is passed.
109: * @throws UpdatePrimaryKeyException if this domain object was loaded from the database.
110: * @throws ReadOnlyObjectException if a Read-Only object is updated.
111: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
112: * @throws FrameworkException Indicates some system error
113: */
114: public void setPart(java.lang.String part)
115: throws ValidationException, UpdatePrimaryKeyException,
116: ReadOnlyObjectException, AlreadyLockedObjectException,
117: FrameworkException {
118: // ignore, if the current value and new value are the same
119: if (m_part == null ? part == null : m_part.equals(part))
120: return;
121:
122: // this is part of the primary key.. do not update if its a database occurence.
123: if (isDatabaseOccurence())
124: throw new UpdatePrimaryKeyException();
125:
126: part = validatePart(part);
127: // .//GEN-END:part_be
128: // Add custom code before setting the value//GEN-FIRST:part
129:
130: // .//GEN-LAST:part
131: // .//GEN-BEGIN:part_1_be
132: super .update();
133: super .addInitialValue(PartRemarksPictureMeta.PART, m_part);
134: m_part = part;
135: m_partObject = null;
136: // .//GEN-END:part_1_be
137: // Add custom code after setting the value//GEN-FIRST:part_3
138:
139: // .//GEN-LAST:part_3
140: // .//GEN-BEGIN:part_2_be
141: }
142:
143: /** This method is present for backwards compatibility only.
144: * It merely invokes the setPart() method.
145: * @param part New value of property part.
146: * @throws ValidationException if an invalid value is passed.
147: * @throws UpdatePrimaryKeyException if this domain object was loaded from the database.
148: * @throws ReadOnlyObjectException if a Read-Only object is updated.
149: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
150: * @throws FrameworkException Indicates some system error
151: */
152: public void updatePart(java.lang.String part)
153: throws ValidationException, UpdatePrimaryKeyException,
154: ReadOnlyObjectException, AlreadyLockedObjectException,
155: FrameworkException {
156: setPart(part);
157: }
158:
159: /** Use this method to validate a value for the property part.
160: * @param part Value to be validated for the property part.
161: * @throws ValidationException if an invalid value is passed
162: * @throws FrameworkException Indicates some system error
163: */
164: public java.lang.String validatePart(java.lang.String part)
165: throws ValidationException, FrameworkException {
166: // .//GEN-END:part_2_be
167: // Add custom code before validation//GEN-FIRST:part_1
168:
169: // .//GEN-LAST:part_1
170: // .//GEN-BEGIN:part_3_be
171: part = FieldValidator.validate(part,
172: (StringFieldMetaData) PartRemarksPictureMeta.META_PART,
173: true);
174:
175: // Invoke the Dynamic Rules Engine
176: RulesEngine.doAllValidationsForDomainField(
177: PartRemarksPictureMeta.getName(),
178: PartRemarksPictureMeta.PART, part, this .getUOW());
179:
180: // .//GEN-END:part_3_be
181: // Add custom code after a successful validation//GEN-FIRST:part_2
182:
183: // .//GEN-LAST:part_2
184: // .//GEN-BEGIN:part_4_be
185: return part;
186: }
187:
188: // .//GEN-END:part_4_be
189: // .//GEN-BEGIN:remarks_be
190: /** Getter for property remarks.
191: * @return Value of property remarks.
192: */
193: public java.lang.String getRemarks() {
194: return m_remarks;
195: }
196:
197: /** Use this method to update the property remarks.
198: * This method will do nothing and simply return if the input value is the same as the current value.
199: * Validation will be performed on the input value.
200: * This will try to lock the underlying database row, in case CAUTIOUS locking is specified at the time of query.
201: * @param remarks New value of property remarks.
202: * @throws ValidationException if an invalid value is passed.
203: * @throws ReadOnlyObjectException if a Read-Only object is updated.
204: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
205: * @throws FrameworkException Indicates some system error
206: */
207: public void setRemarks(java.lang.String remarks)
208: throws ValidationException, ReadOnlyObjectException,
209: AlreadyLockedObjectException, FrameworkException {
210: // ignore, if the current value and new value are the same
211: if (m_remarks == null ? remarks == null : m_remarks
212: .equals(remarks))
213: return;
214:
215: remarks = validateRemarks(remarks);
216: // .//GEN-END:remarks_be
217: // Add custom code before setting the value//GEN-FIRST:remarks
218:
219: // .//GEN-LAST:remarks
220: // .//GEN-BEGIN:remarks_1_be
221: super .update();
222: super
223: .addInitialValue(PartRemarksPictureMeta.REMARKS,
224: m_remarks);
225: m_remarks = remarks;
226: // .//GEN-END:remarks_1_be
227: // Add custom code after setting the value//GEN-FIRST:remarks_3
228:
229: // .//GEN-LAST:remarks_3
230: // .//GEN-BEGIN:remarks_2_be
231: }
232:
233: /** This method is present for backwards compatibility only.
234: * It merely invokes the setRemarks() method.
235: * @param remarks New value of property remarks.
236: * @throws ValidationException if an invalid value is passed.
237: * @throws ReadOnlyObjectException if a Read-Only object is updated.
238: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
239: * @throws FrameworkException Indicates some system error
240: */
241: public void updateRemarks(java.lang.String remarks)
242: throws ValidationException, ReadOnlyObjectException,
243: AlreadyLockedObjectException, FrameworkException {
244: setRemarks(remarks);
245: }
246:
247: /** Use this method to validate a value for the property remarks.
248: * @param remarks Value to be validated for the property remarks.
249: * @throws ValidationException if an invalid value is passed
250: * @throws FrameworkException Indicates some system error
251: */
252: public java.lang.String validateRemarks(java.lang.String remarks)
253: throws ValidationException, FrameworkException {
254: // .//GEN-END:remarks_2_be
255: // Add custom code before validation//GEN-FIRST:remarks_1
256:
257: // .//GEN-LAST:remarks_1
258: // .//GEN-BEGIN:remarks_3_be
259: remarks = FieldValidator
260: .validate(
261: remarks,
262: (StringFieldMetaData) PartRemarksPictureMeta.META_REMARKS,
263: true);
264:
265: // Invoke the Dynamic Rules Engine
266: RulesEngine.doAllValidationsForDomainField(
267: PartRemarksPictureMeta.getName(),
268: PartRemarksPictureMeta.REMARKS, remarks, this .getUOW());
269:
270: // .//GEN-END:remarks_3_be
271: // Add custom code after a successful validation//GEN-FIRST:remarks_2
272:
273: // .//GEN-LAST:remarks_2
274: // .//GEN-BEGIN:remarks_4_be
275: return remarks;
276: }
277:
278: // .//GEN-END:remarks_4_be
279: // .//GEN-BEGIN:picture_be
280: /** Getter for property picture.
281: * @return Value of property picture.
282: */
283: public byte[] getPicture() {
284: return m_picture;
285: }
286:
287: /** Use this method to update the property picture.
288: * This method will do nothing and simply return if the input value is the same as the current value.
289: * Validation will be performed on the input value.
290: * This will try to lock the underlying database row, in case CAUTIOUS locking is specified at the time of query.
291: * @param picture New value of property picture.
292: * @throws ValidationException if an invalid value is passed.
293: * @throws ReadOnlyObjectException if a Read-Only object is updated.
294: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
295: * @throws FrameworkException Indicates some system error
296: */
297: public void setPicture(byte[] picture) throws ValidationException,
298: ReadOnlyObjectException, AlreadyLockedObjectException,
299: FrameworkException {
300: // ignore, if the current value and new value are the same
301: if (m_picture == null ? picture == null : m_picture
302: .equals(picture))
303: return;
304:
305: picture = validatePicture(picture);
306: // .//GEN-END:picture_be
307: // Add custom code before setting the value//GEN-FIRST:picture
308:
309: // .//GEN-LAST:picture
310: // .//GEN-BEGIN:picture_1_be
311: super .update();
312: super
313: .addInitialValue(PartRemarksPictureMeta.PICTURE,
314: m_picture);
315: m_picture = picture;
316: // .//GEN-END:picture_1_be
317: // Add custom code after setting the value//GEN-FIRST:picture_3
318:
319: // .//GEN-LAST:picture_3
320: // .//GEN-BEGIN:picture_2_be
321: }
322:
323: /** This method is present for backwards compatibility only.
324: * It merely invokes the setPicture() method.
325: * @param picture New value of property picture.
326: * @throws ValidationException if an invalid value is passed.
327: * @throws ReadOnlyObjectException if a Read-Only object is updated.
328: * @throws AlreadyLockedObjectException if the underlying database row is already locked by another process.
329: * @throws FrameworkException Indicates some system error
330: */
331: public void updatePicture(byte[] picture)
332: throws ValidationException, ReadOnlyObjectException,
333: AlreadyLockedObjectException, FrameworkException {
334: setPicture(picture);
335: }
336:
337: /** Use this method to validate a value for the property picture.
338: * @param picture Value to be validated for the property picture.
339: * @throws ValidationException if an invalid value is passed
340: * @throws FrameworkException Indicates some system error
341: */
342: public byte[] validatePicture(byte[] picture)
343: throws ValidationException, FrameworkException {
344: // .//GEN-END:picture_2_be
345: // Add custom code before validation//GEN-FIRST:picture_1
346:
347: // .//GEN-LAST:picture_1
348: // .//GEN-BEGIN:picture_3_be
349: picture = FieldValidator.validate(picture,
350: (RawFieldMetaData) PartRemarksPictureMeta.META_PICTURE,
351: true);
352:
353: // Invoke the Dynamic Rules Engine
354: RulesEngine.doAllValidationsForDomainField(
355: PartRemarksPictureMeta.getName(),
356: PartRemarksPictureMeta.PICTURE, picture, this .getUOW());
357:
358: // .//GEN-END:picture_3_be
359: // Add custom code after a successful validation//GEN-FIRST:picture_2
360:
361: // .//GEN-LAST:picture_2
362: // .//GEN-BEGIN:picture_4_be
363: return picture;
364: }
365:
366: // .//GEN-END:picture_4_be
367: // .//GEN-BEGIN:partObject_1_be
368: /** Returns a related Part object.
369: * @return a related Part object.
370: * @throws ValidationException if an invalid foreign key is set.
371: * @throws FrameworkException Indicates some system error
372: */
373: public Part getPartObject() throws ValidationException,
374: FrameworkException {
375: UOW uow = getUOW();
376: boolean localUow = false;
377: try {
378: if (m_partObject == null && getPart() != null) {
379: Criteria criteria = new Criteria();
380: criteria.setTable(PartMeta.getName());
381: criteria.addCriteria(PartMeta.PART, getPart());
382: if (uow == null || !uow.isActive()) {
383: uow = new UOW();
384: localUow = true;
385: }
386: Iterator itr = uow.query(criteria).iterator();
387: if (itr.hasNext())
388: m_partObject = (Part) itr.next();
389: if (m_partObject == null)
390: throw new InvalidForeignKeyException(
391: PartRemarksPictureMeta.META_PART
392: .getLabelToken(),
393: new Object[] { PartMeta.getLabelToken(),
394: PartMeta.META_PART.getLabelToken() });
395: }
396: return m_partObject;
397: } finally {
398: if (localUow && uow != null)
399: uow.rollback();
400: }
401: }
402:
403: // .//GEN-END:partObject_1_be
404: // .//GEN-BEGIN:toString_1_be
405: /** This returns the diagnostic information.
406: * @return the diagnostic information.
407: */
408: public String toString() {
409: StringBuffer buf = new StringBuffer();
410: buf.append("<PartRemarksPicture>");
411: buf.append("<part>");
412: if (m_part != null)
413: buf.append(m_part);
414: buf.append("</part>");
415: buf.append("<remarks>");
416: if (m_remarks != null)
417: buf.append(m_remarks);
418: buf.append("</remarks>");
419: buf.append("<picture>");
420: if (m_picture != null)
421: buf.append(m_picture);
422: buf.append("</picture>");
423: // .//GEN-END:toString_1_be
424: // Add custom debug information//GEN-FIRST:toString_1
425:
426: // .//GEN-LAST:toString_1
427: // .//GEN-BEGIN:toString_2_be
428: buf.append(super .toString());
429: buf.append("</PartRemarksPicture>");
430: return buf.toString();
431: }
432:
433: // .//GEN-END:toString_2_be
434: // .//GEN-BEGIN:clone_1_be
435: /** Returns a clone of the object.
436: * @throws CloneNotSupportedException if cloning is not supported. This should never happen.
437: * @return a clone of the object.
438: */
439: public Object clone() throws CloneNotSupportedException {
440: PartRemarksPicture obj = (PartRemarksPicture) super .clone();
441: obj.m_partObject = null;
442: return obj;
443: }
444:
445: // .//GEN-END:clone_1_be
446: // .//GEN-BEGIN:performForeignKeyValidations_1_be
447: /** This method ensures that the modified foreign-keys are valid.
448: * @throws ApplicationExceptions if an invalid foreign key is set.
449: * @throws FrameworkException Indicates some system error
450: */
451: public void performForeignKeyValidations()
452: throws ApplicationExceptions, FrameworkException {
453: ApplicationExceptions appExps = new ApplicationExceptions();
454: try {
455: if (isModified(PartRemarksPictureMeta.PART))
456: getPartObject();
457: } catch (ValidationException e) {
458: appExps.add(e);
459: }
460: if (appExps.size() > 0)
461: throw appExps;
462: }
463:
464: // .//GEN-END:performForeignKeyValidations_1_be
465: // .//GEN-BEGIN:performPreDeleteReferentialIntegrity_1_be
466: /** This method is triggered by the UOW, before adding this object to the Delete-Store.
467: * This will raise an exception if any associated/aggregated objects exist.
468: * This will cascade delete all composite objects.
469: * @throws PreDeleteFailedException if any error occurs during the process.
470: */
471: public void performPreDeleteReferentialIntegrity()
472: throws PreDeleteFailedException {
473: }
474: // .//GEN-END:performPreDeleteReferentialIntegrity_1_be
475: // .//GEN-BEGIN:3_be
476: /**
477: * @clientCardinality 0..1
478: * @supplierCardinality 1
479: * @clientQualifier part
480: * @supplierQualifier part
481: * @link association
482: */
483: /*#Part lnkPart;*/
484:
485: // .//GEN-END:3_be
486: // All the custom code goes here//GEN-FIRST:custom
487:
488: // .//GEN-LAST:custom
489: }
|