001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.rm.metadata;
020:
021: import java.util.*;
022: import java.util.logging.*;
023:
024: import org.openharmonise.commons.dsi.*;
025: import org.openharmonise.commons.dsi.dml.*;
026: import org.openharmonise.commons.xml.XMLUtils;
027: import org.openharmonise.rm.*;
028: import org.openharmonise.rm.publishing.*;
029: import org.openharmonise.rm.resources.*;
030: import org.openharmonise.rm.resources.lifecycle.EditException;
031: import org.openharmonise.rm.resources.metadata.properties.Property;
032: import org.openharmonise.rm.resources.publishing.Template;
033: import org.w3c.dom.*;
034:
035: /**
036: * The <code>ProfilePropertyInstance</code> class represents an instance of a
037: * <code>Property</code> which can have other property instances as values.
038: *
039: * @author Michael Bell
040: * @version $Revision: 1.4.2.1 $
041: *
042: */
043: public class ProfilePropertyInstance extends AbstractPropertyInstance
044: implements Publishable {
045:
046: //DB constants
047: /**
048: * Parent profile id database column name
049: */
050: protected static final String CLMN_PROFILE_PARENT = "parent_profile_id";
051:
052: //XML constant
053: /**
054: * Property instance group XML element name
055: */
056: public static final String TAG_PROPERTYINSTANCE_GROUP = "PropertyInstanceGroup";
057:
058: /**
059: * Logger for this class
060: */
061: public static final Logger m_logger = Logger
062: .getLogger(ProfilePropertyInstance.class.getName());
063:
064: /**
065: * Constructs a property instance
066: */
067: public ProfilePropertyInstance() {
068: super ();
069:
070: }
071:
072: /**
073: * Constructs a property instance with an interface to the data store
074: *
075: * @param dbint the data store interface
076: */
077: public ProfilePropertyInstance(AbstractDataStoreInterface dbint) {
078: super (dbint);
079:
080: }
081:
082: /**
083: * Constructs a property instance with an interface to
084: * the data store and a reference to the <code>Profile</code> which
085: * will contain this property instance.
086: *
087: * @param dbintrf the data store interface
088: * @param profile the 'owning' <code>Profile</code>
089: */
090: public ProfilePropertyInstance(AbstractDataStoreInterface dbintrf,
091: Profile profile) {
092: super (dbintrf, profile);
093:
094: }
095:
096: /**
097: * Constructs a property instance with an interface to the data store,
098: * a reference to the <code>Profile</code> which will contain this
099: * property instance and a reference to the <code>Property</code>
100: * identified by the specified id.
101: *
102: * @param dbintrf the data store interface
103: * @param nPropertyId the id of the <code>Property</code> that this object is an instance of
104: * @param profile the 'owning' <code>Profile</code>
105: */
106: public ProfilePropertyInstance(AbstractDataStoreInterface dbintrf,
107: int nPropertyId, Profile profile) {
108: super (dbintrf, nPropertyId, profile);
109:
110: }
111:
112: /**
113: * Constructs a property instance of the specified <code>Property</code>
114: * with an interface to the data store.
115: *
116: * @param dbintrf the data store interface
117: * @param prop the <code>Property</code> that this object is an instance of
118: */
119: public ProfilePropertyInstance(AbstractDataStoreInterface dbintrf,
120: Property prop) {
121: super (dbintrf, prop);
122: }
123:
124: /**
125: * Constructs a property instance with an interface to the data store,
126: * a reference to the <code>Profile</code> which will contain this
127: * property instance and a reference to the <code>Property</code>
128: * which this object is an instance of.
129: *
130: * @param dbintrf the data store interface
131: * @param property the <code>Property</code>
132: * @param profile the 'owner' <code>Profile</code>
133: */
134: public ProfilePropertyInstance(AbstractDataStoreInterface dbintrf,
135: Property property, Profile profile) {
136: super (dbintrf, property, profile);
137:
138: }
139:
140: /**
141: * Adds the given <code>Profile</code> as a value of this instance.
142: *
143: * @param prof the <code>Profile</code> to add
144: * @throws InvalidPropertyValueException if the value is invalid for
145: * this property instance
146: */
147: public void addValue(Profile prof) throws PopulateException {
148: if (prof != null) {
149: super .addValue(prof);
150: }
151: }
152:
153: /**
154: * Adds the given <code>Profile</code> as a value of this instance.
155: *
156: * @param prof the <code>Profile</code> to add
157: * @param nId the id of the <code>Profile</code>
158: * @throws InvalidPropertyValueException if the value is invalid for
159: * this property instance
160: */
161: public void addValue(Profile prof, int nId)
162: throws PopulateException {
163:
164: if (prof != null) {
165: super .addValue(prof, nId);
166: }
167:
168: }
169:
170: /**
171: * Removes the given <code>Profile</code> as a value of this instance.
172: *
173: * @param prof the <code>Profile</code> to remove
174: * @throws InvalidPropertyValueException if the value is invalid for
175: * this property instance
176: */
177: public void removeValue(Profile prof)
178: throws InvalidPropertyValueException {
179: super .removeValue(prof);
180: }
181:
182: /* (non-Javadoc)
183: * @see org.openharmonise.rm.publishing.Publishable#populate(org.w3c.dom.Element, org.openharmonise.rm.publishing.State)
184: */
185: public void populate(Element xmlElement, State state)
186: throws PopulateException {
187: String sTagName = xmlElement.getTagName();
188: Text txt = null;
189:
190: if (sTagName.equals(TAG_PROP_INSTANCE_VALUES) == true) {
191: NodeList nodes = xmlElement
192: .getElementsByTagName(Profile.TAG_PROFILE);
193:
194: for (int i = 0; i < nodes.getLength(); i++) {
195: Element profEl = (Element) nodes.item(i);
196: Profile tmpProf = new Profile(m_dsi, m_profile
197: .getProfiledObject());
198: try {
199: tmpProf.populate(profEl, state);
200: addValue(tmpProf);
201: } catch (InvalidPropertyValueException e) {
202: throw new PopulateException(
203: "Invalid value for PropertyInstance", e);
204: }
205: }
206: } else {
207: super .populate(xmlElement, state);
208: }
209: }
210:
211: /* (non-Javadoc)
212: * @see org.openharmonise.rm.publishing.Publishable#publish(org.w3c.dom.Element, org.openharmonise.rm.publishing.HarmoniseOutput, org.openharmonise.rm.publishing.State)
213: */
214: public Element publish(Element formEl, HarmoniseOutput xmlDoc,
215: State state) throws PublishException {
216:
217: Element resultEl = null;
218: String sTagname = formEl.getTagName();
219:
220: if (sTagname.equals(TAG_PROPERTYINSTANCE) == true) {
221: resultEl = super .publish(formEl, xmlDoc, state);
222: } else if (sTagname.equals(TAG_PROP_INSTANCE_VALUES)) {
223: resultEl = xmlDoc.createElement(TAG_PROP_INSTANCE_VALUES);
224:
225: if (m_values != null) {
226:
227: boolean bAllProps = false;
228: // need to build up map of required prop names with prop inst els
229: // to publish with
230: Map propInstMap = new Hashtable();
231: List propInstEls = XMLUtils.getChildrenByName(formEl,
232: TAG_PROPERTYINSTANCE);
233: Element publishPropInstEl = null;
234: Element publishValueEl = null;
235: Element publishAllPropEl = null;
236: Element publishTemplateEl = null;
237:
238: if (propInstEls.size() > 0) {
239:
240: //get prop names
241: Iterator iter = propInstEls.iterator();
242:
243: while (iter.hasNext()) {
244: Element propInstEl = (Element) iter.next();
245:
246: List propEls = XMLUtils.getChildrenByName(
247: propInstEl, Property.TAG_PROPERTY);
248:
249: if (propEls.size() > 0) {
250: Element nameEl = (Element) ((Element) propEls
251: .get(0)).getElementsByTagName(
252: AbstractObject.TAG_NAME).item(0);
253:
254: String sName = nameEl.getChildNodes().item(
255: 0).getNodeValue();
256:
257: propInstMap.put(sName, propInstEl);
258: }
259:
260: }
261: } else {
262: bAllProps = true;
263:
264: NamedNodeMap attrs = formEl.getAttributes();
265:
266: publishPropInstEl = xmlDoc
267: .createElement(TAG_PROPERTYINSTANCE);
268:
269: Element propEl = xmlDoc
270: .createElement(Property.TAG_PROPERTY);
271: publishPropInstEl.appendChild(propEl);
272:
273: publishValueEl = xmlDoc
274: .createElement(AbstractPropertyInstance.TAG_PROP_INSTANCE_VALUES);
275:
276: publishPropInstEl.appendChild(publishValueEl);
277:
278: List allprop = XMLUtils.getChildrenByName(formEl,
279: Profile.TAG_ALLPROPERTYINSTANCES);
280:
281: if (allprop.size() > 0) {
282: Element allpropEl = (Element) allprop.get(0);
283:
284: Element templateEl = (Element) XMLUtils
285: .getFirstNamedChild(allpropEl,
286: Template.TAG_TEMPLATE);
287:
288: if (templateEl != null) {
289: publishTemplateEl = (Element) xmlDoc
290: .importNode(templateEl, true);
291:
292: if (publishAllPropEl != null) {
293: publishAllPropEl
294: .appendChild(publishTemplateEl
295: .cloneNode(true));
296: }
297: }
298:
299: publishAllPropEl = xmlDoc
300: .createElement(Profile.TAG_ALLPROPERTYINSTANCES);
301:
302: for (int i = 0; i < attrs.getLength(); i++) {
303: Attr attr = (Attr) attrs.item(i);
304: publishAllPropEl.setAttribute(attr
305: .getName(), attr.getValue());
306: publishValueEl.setAttribute(attr.getName(),
307: attr.getValue());
308: }
309:
310: //check for specification on publishing the property of the sub property instance
311: Element origPropEl = XMLUtils
312: .getFirstNamedChild(allpropEl,
313: Property.TAG_PROPERTY);
314:
315: if (origPropEl != null) {
316: NodeList nodes = origPropEl.getChildNodes();
317:
318: for (int i = 0; i < nodes.getLength(); i++) {
319: Node node = (Node) nodes.item(i);
320: propEl.appendChild(xmlDoc.importNode(
321: node, true));
322: }
323: }
324:
325: Element clonePropEl = (Element) propEl
326: .cloneNode(true);
327: publishAllPropEl.appendChild(clonePropEl);
328:
329: }
330:
331: }
332:
333: for (int j = 0; j < m_values.size(); j++) {
334:
335: try {
336: Element groupEl = xmlDoc
337: .createElement(ProfilePropertyInstance.TAG_PROPERTYINSTANCE_GROUP);
338:
339: Profile tmpProf = (Profile) m_values.get(j);
340:
341: List propInsts = tmpProf.getPropertyInstances();
342:
343: Iterator iter = propInsts.iterator();
344:
345: while (iter.hasNext()) {
346: AbstractPropertyInstance propInst = (AbstractPropertyInstance) iter
347: .next();
348: String sPropName = propInst.getName();
349: if (bAllProps == true) {
350:
351: //need to add and remove appropriate elements
352: //depending on propInst type
353: if (publishTemplateEl != null) {
354: if (propInst instanceof ChildObjectPropertyInstance) {
355: publishValueEl
356: .appendChild(publishTemplateEl);
357: }
358: }
359:
360: if (publishAllPropEl != null
361: && propInst instanceof ProfilePropertyInstance) {
362: publishValueEl
363: .appendChild(publishAllPropEl);
364: }
365:
366: Element publishedEl = propInst.publish(
367: publishPropInstEl, xmlDoc,
368: state);
369: groupEl.appendChild(publishedEl);
370:
371: if (publishTemplateEl != null) {
372: if (propInst instanceof ChildObjectPropertyInstance) {
373: publishValueEl
374: .removeChild(publishTemplateEl);
375: }
376: }
377:
378: if (publishAllPropEl != null
379: && propInst instanceof ProfilePropertyInstance) {
380: publishValueEl
381: .removeChild(publishAllPropEl);
382: }
383:
384: } else if (propInstMap
385: .containsKey(sPropName)) {
386: Element tmpEl = (Element) propInstMap
387: .get(sPropName);
388:
389: Element publishedEl = propInst.publish(
390: tmpEl, xmlDoc, state);
391:
392: groupEl.appendChild(publishedEl);
393: }
394: }
395:
396: resultEl.appendChild(groupEl);
397: } catch (DataAccessException e) {
398: throw new PublishException(e
399: .getLocalizedMessage(), e);
400: }
401: }
402:
403: }
404:
405: } else {
406: resultEl = super .publish(formEl, xmlDoc, state);
407: }
408:
409: if (resultEl == null) {
410: resultEl = xmlDoc.createElement(TAG_ERROR);
411: resultEl.appendChild(xmlDoc
412: .createTextNode("Problem publishing " + sTagname));
413: }
414:
415: return resultEl;
416: }
417:
418: /* (non-Javadoc)
419: * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#match(org.openharmonise.rm.metadata.AbstractPropertyInstance)
420: */
421: public boolean match(AbstractPropertyInstance propInst)
422: throws ProfileException {
423: boolean bMatch = false;
424:
425: if (propInst instanceof ProfilePropertyInstance) {
426: List otherProfs = propInst.getValues();
427:
428: boolean bLooping = true;
429:
430: List vals = getValues();
431:
432: //first make sure there are the same number of profiles
433: if (vals.size() == otherProfs.size()) {
434:
435: Iterator iter = vals.iterator();
436: Iterator otherIter = otherProfs.iterator();
437:
438: //loop through profiles to check matches
439: while (iter.hasNext() && bLooping == true) {
440: Profile tmpProf = (Profile) iter.next();
441: boolean bFound = false;
442:
443: while (otherIter.hasNext() == true
444: && bFound == false) {
445: Profile otherProf = (Profile) otherIter.next();
446:
447: if (tmpProf.match(otherProf) == true) {
448: bFound = true;
449: }
450: }
451:
452: if (bFound == false) {
453: bLooping = false;
454: }
455: }
456: }
457:
458: // if we've looped through all profiles and bLooping is still true
459: // then there was a match for every profile
460: if (bLooping == true) {
461: bMatch = true;
462: }
463: }
464:
465: return bMatch;
466: }
467:
468: /* (non-Javadoc)
469: * @see org.openharmonise.rm.dsi.DataStoreObject#getInstanceJoinConditions(java.lang.String, boolean)
470: */
471: public JoinConditions getInstanceJoinConditions(String sObjectTag,
472: boolean bIsOuter) throws DataStoreException {
473: throw new UnsupportedOperationException();
474: }
475:
476: /* (non-Javadoc)
477: * @see org.openharmonise.rm.dsi.DataStoreObject#processResultSet(org.openharmonise.commons.dsi.CachedResultSet, org.openharmonise.commons.dsi.dml.SelectStatement)
478: */
479: public List processResultSet(CachedResultSet resultSet,
480: SelectStatement select) {
481: throw new UnsupportedOperationException();
482: }
483:
484: /* (non-Javadoc)
485: * @see org.openharmonise.rm.dsi.DataStoreObject#processResultSet(org.openharmonise.commons.dsi.CachedResultSet, org.openharmonise.commons.dsi.dml.SelectStatement, int)
486: */
487: public List processResultSet(CachedResultSet resultSet,
488: SelectStatement select, int limit) {
489: throw new UnsupportedOperationException();
490: }
491:
492: /* (non-Javadoc)
493: * @see org.openharmonise.rm.dsi.DataStoreObject#getInstanceColumnRef(java.lang.String, boolean)
494: */
495: public ColumnRef getInstanceColumnRef(String sColumn,
496: boolean bIsHist) throws DataStoreException {
497: ColumnRef returnColRef = null;
498: String sDBTable = getDBTableName();
499:
500: if (sColumn.equals(CLMN_PROFILE_PARENT) == true) {
501: returnColRef = new ColumnRef(sDBTable, CLMN_PROFILE_PARENT,
502: ColumnRef.NUMBER);
503: }
504:
505: if (returnColRef != null) {
506: return returnColRef;
507: } else {
508: return super .getInstanceColumnRef(sColumn, bIsHist);
509: }
510: }
511:
512: /**
513: * Returns the column reference for the column in the profile database table
514: * belonging to the specified <code>AbstractProfiledObject</code>.
515: *
516: * @param profObj the <code>AbstractProfiledObject</code> associated to the
517: * required column reference
518: * @param sColumn the database column name
519: * @param bIsHist <code>true</code> if the column reference returned should
520: * reference the historical table
521: * @return the column reference for the column in the profile database table
522: * belonging to the specified <code>AbstractProfiledObject</code>
523: * @throws DataStoreException if the specified column is invalid
524: */
525: static public ColumnRef getColumnRef(
526: AbstractProfiledObject profObj, String sColumn,
527: boolean bIsHist) throws DataStoreException {
528: ColumnRef returnColRef = null;
529: String sDBTable = Profile.getDBTableName(profObj);
530:
531: if (sColumn.equals(TAG_VALUE) == true
532: || sColumn.equals(CLMN_PROFILE_PARENT) == true) {
533: returnColRef = new ColumnRef(sDBTable, CLMN_PROFILE_PARENT,
534: ColumnRef.NUMBER);
535: }
536:
537: if (returnColRef != null) {
538: return returnColRef;
539: } else {
540: throw new InvalidColumnReferenceException(sColumn);
541: }
542: }
543:
544: /**
545: * Returns the database table which holds the data for this
546: * property instance type for the specified <code>Profile</code>.
547: *
548: * @param profile the <code>Profile</code> for which the requested
549: * property instance table will be linked to
550: * @return the database table which holds the data for this
551: * property instance type for the specified <code>Profile</code>
552: */
553: public static String getDBTableName(Profile profile) {
554: return profile.getDBTableName();
555: }
556:
557: /*-------------------------------------------------------------------------------------
558: Protected Methods
559: --------------------------------------------------------------------------------------*/
560:
561: /* (non-Javadoc)
562: * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#save(org.openharmonise.rm.metadata.Profile)
563: */
564: protected void save(Profile prof) throws ProfileException,
565: EditException {
566: if ((m_bIsTemporary == false) && hasValues() == true) {
567: //make sure database table is current
568: setDBTable(prof);
569:
570: m_profile = prof;
571:
572: UpdateStatement update = new UpdateStatement();
573: String sTable = getDBTableName();
574:
575: for (int i = 0; i < m_values.size(); i++) {
576: try {
577:
578: Profile tmpProf = (Profile) m_values.get(i);
579:
580: update.clear();
581:
582: tmpProf = tmpProf.save(prof.getProfiledObject());
583:
584: m_values.set(i, tmpProf);
585:
586: boolean bIsHist = isHistorical();
587:
588: update.setTable(sTable);
589:
590: update.addColumnValue(this .getInstanceColumnRef(
591: CLMN_PROFILE_PARENT, bIsHist), m_profile
592: .getId());
593: update.addColumnValue(this .getInstanceColumnRef(
594: CLMN_PROPERTY_ID, bIsHist), getProperty()
595: .getId());
596:
597: update.addWhereCondition(this .getInstanceColumnRef(
598: CLMN_ID, bIsHist), "=", tmpProf.getId());
599:
600: m_dsi.execute(update);
601: } catch (DataStoreException e) {
602: throw new ProfileException(e.getMessage(), e);
603: } catch (DataAccessException e) {
604: throw new ProfileException(e.getMessage(), e);
605: }
606: }
607:
608: update.clear();
609:
610: m_values2Add.clear();
611: m_values2Remove.clear();
612:
613: setIsChanged(false);
614: setIsPopulated(true);
615: }
616: }
617:
618: /* (non-Javadoc)
619: * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#update(org.openharmonise.rm.metadata.Profile)
620: */
621: protected void update(Profile prof) throws ProfileException,
622: EditException {
623: if (isPopulated() == true && isChanged() == true) {
624: UpdateStatement update = new UpdateStatement();
625: //make sure database table is current
626: setDBTable(prof);
627:
628: m_profile = prof;
629:
630: boolean bIsHist = isHistorical();
631:
632: String sTable = getDBTableName();
633:
634: for (int i = 0; i < m_values2Add.size(); i++) {
635: Profile profVal = (Profile) m_values2Add.get(i);
636: int nIndex = m_values.indexOf(profVal);
637:
638: update.clear();
639: try {
640:
641: Profile tmpProf = profVal.save(prof
642: .getProfiledObject());
643:
644: if (nIndex >= 0) {
645: m_values.set(nIndex, tmpProf);
646: } else {
647: m_values.add(tmpProf);
648: }
649:
650: update.setTable(sTable);
651:
652: update.addColumnValue(this .getInstanceColumnRef(
653: CLMN_PROFILE_PARENT, bIsHist), m_profile
654: .getId());
655: update.addColumnValue(this .getInstanceColumnRef(
656: CLMN_PROPERTY_ID, bIsHist), getProperty()
657: .getId());
658:
659: update.addWhereCondition(this .getInstanceColumnRef(
660: CLMN_ID, bIsHist), "=", tmpProf.getId());
661:
662: m_dsi.execute(update);
663: } catch (DataStoreException e) {
664: throw new ProfileException(
665: "Error occurred processing insert", e);
666: } catch (DataAccessException e) {
667: throw new ProfileException(
668: "Error occurred processing insert", e);
669: }
670: }
671:
672: Iterator iter = m_values2Remove.iterator();
673:
674: while (iter.hasNext()) {
675: Profile tmpProf = (Profile) iter.next();
676: int nIndex = m_values.indexOf(tmpProf);
677:
678: if (nIndex >= 0) {
679: m_values.remove(nIndex);
680: }
681:
682: tmpProf.delete();
683: }
684: } else if (isPopulated() == false) {
685: // if this happens to be a new property instance on the profile
686: save(prof);
687: }
688:
689: m_values2Add.clear();
690: m_values2Remove.clear();
691:
692: setIsChanged(false);
693: setIsPopulated(true);
694:
695: }
696:
697: /**
698: * Deletes this instance, which in turn will delete all the
699: * <code>Profile</code> values and their property instances.
700: *
701: * @throws ProfileException if there is an error deleting any
702: * of the <code>Profile</code> values
703: */
704: protected void delete() throws ProfileException {
705: Iterator iter = m_values.iterator();
706:
707: while (iter.hasNext()) {
708: Profile tmpProf = (Profile) iter.next();
709:
710: tmpProf.delete();
711: }
712:
713: m_values.clear();
714: }
715:
716: /* (non-Javadoc)
717: * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#getColumnForData()
718: */
719: protected ColumnRef getColumnForData() throws DataStoreException {
720: throw new UnsupportedOperationException();
721: }
722:
723: /* (non-Javadoc)
724: * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#getValueToStoreForValue(java.lang.Object)
725: */
726: protected Object getValueToStoreForValue(Object val)
727: throws ProfileException {
728: throw new UnsupportedOperationException();
729: }
730:
731: /* (non-Javadoc)
732: * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#setDBTable(org.openharmonise.rm.metadata.Profile)
733: */
734: protected void setDBTable(Profile profile) {
735: m_sDataTable = profile.getDBTableName();
736: }
737:
738: /* (non-Javadoc)
739: * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#isChanged()
740: */
741: protected boolean isChanged() {
742: boolean bIsChanged = super .isChanged();
743:
744: if (bIsChanged == false) {
745: Iterator iter = m_values.iterator();
746:
747: while (iter.hasNext() && bIsChanged == false) {
748: Profile prof = (Profile) iter.next();
749: try {
750: bIsChanged = prof.isChanged();
751: } catch (DataAccessException e) {
752: m_logger.log(Level.WARNING,
753: e.getLocalizedMessage(), e);
754: }
755: }
756: }
757:
758: return bIsChanged;
759: }
760:
761: /* (non-Javadoc)
762: * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#setHistorical(boolean)
763: */
764: protected void setHistorical(boolean bIsHist) {
765:
766: if (hasValues() == true) {
767: Iterator iter = m_values.iterator();
768:
769: while (iter.hasNext()) {
770: Profile tmpProf = (Profile) iter.next();
771: tmpProf.setHistorical(bIsHist);
772: }
773: }
774:
775: super .setHistorical(bIsHist);
776: }
777:
778: /**
779: * Mark all values as new, i.e. set ids to 0 such that values
780: * can be resaved as new vals
781: *
782: * @throws PopulateException
783: *
784: */
785: public void markValuesAsNew() throws PopulateException {
786: if (m_values != null) {
787: Iterator iter = m_values.iterator();
788:
789: while (iter.hasNext()) {
790: ProfileValue profVal = (ProfileValue) iter.next();
791: profVal.markAsNew();
792: }
793: }
794:
795: }
796:
797: }
|