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