KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > metadata > ProfilePropertyInstance


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.rm.metadata;
20
21 import java.util.*;
22 import java.util.logging.*;
23
24 import org.openharmonise.commons.dsi.*;
25 import org.openharmonise.commons.dsi.dml.*;
26 import org.openharmonise.commons.xml.XMLUtils;
27 import org.openharmonise.rm.*;
28 import org.openharmonise.rm.publishing.*;
29 import org.openharmonise.rm.resources.*;
30 import org.openharmonise.rm.resources.lifecycle.EditException;
31 import org.openharmonise.rm.resources.metadata.properties.Property;
32 import org.openharmonise.rm.resources.publishing.Template;
33 import org.w3c.dom.*;
34
35
36 /**
37  * The <code>ProfilePropertyInstance</code> class represents an instance of a
38  * <code>Property</code> which can have other property instances as values.
39  *
40  * @author Michael Bell
41  * @version $Revision: 1.4 $
42  *
43  */

44 public class ProfilePropertyInstance
45     extends AbstractPropertyInstance
46     implements Publishable {
47
48     //DB constants
49
/**
50      * Parent profile id database column name
51      */

52     protected static final String JavaDoc CLMN_PROFILE_PARENT = "parent_profile_id";
53
54     //XML constant
55
/**
56      * Property instance group XML element name
57      */

58     public static final String JavaDoc TAG_PROPERTYINSTANCE_GROUP = "PropertyInstanceGroup";
59
60     /**
61      * Logger for this class
62      */

63     public static final Logger m_logger = Logger.getLogger(ProfilePropertyInstance.class.getName());
64     
65     /**
66      * Constructs a property instance
67      */

68     public ProfilePropertyInstance() {
69         super();
70
71     }
72
73     /**
74      * Constructs a property instance with an interface to the data store
75      *
76      * @param dbint the data store interface
77      */

78     public ProfilePropertyInstance(AbstractDataStoreInterface dbint) {
79         super(dbint);
80
81     }
82
83     /**
84      * Constructs a property instance with an interface to
85      * the data store and a reference to the <code>Profile</code> which
86      * will contain this property instance.
87      *
88      * @param dbintrf the data store interface
89      * @param profile the 'owning' <code>Profile</code>
90      */

91     public ProfilePropertyInstance(
92         AbstractDataStoreInterface dbintrf,
93         Profile profile) {
94         super(dbintrf, profile);
95
96     }
97
98     /**
99       * Constructs a property instance with an interface to the data store,
100       * a reference to the <code>Profile</code> which will contain this
101       * property instance and a reference to the <code>Property</code>
102       * identified by the specified id.
103       *
104       * @param dbintrf the data store interface
105       * @param nPropertyId the id of the <code>Property</code> that this object is an instance of
106       * @param profile the 'owning' <code>Profile</code>
107       */

108     public ProfilePropertyInstance(
109         AbstractDataStoreInterface dbintrf,
110         int nPropertyId,
111         Profile profile) {
112         super(dbintrf, nPropertyId, profile);
113
114     }
115
116     /**
117      * Constructs a property instance of the specified <code>Property</code>
118      * with an interface to the data store.
119      *
120      * @param dbintrf the data store interface
121      * @param prop the <code>Property</code> that this object is an instance of
122      */

123     public ProfilePropertyInstance(
124         AbstractDataStoreInterface dbintrf,
125         Property prop) {
126         super(dbintrf, prop);
127     }
128
129     /**
130       * Constructs a property instance with an interface to the data store,
131       * a reference to the <code>Profile</code> which will contain this
132       * property instance and a reference to the <code>Property</code>
133       * which this object is an instance of.
134       *
135       * @param dbintrf the data store interface
136       * @param property the <code>Property</code>
137       * @param profile the 'owner' <code>Profile</code>
138       */

139     public ProfilePropertyInstance(
140         AbstractDataStoreInterface dbintrf,
141         Property property,
142         Profile profile) {
143         super(dbintrf, property, profile);
144
145     }
146
147     /**
148      * Adds the given <code>Profile</code> as a value of this instance.
149      *
150      * @param prof the <code>Profile</code> to add
151      * @throws InvalidPropertyValueException if the value is invalid for
152      * this property instance
153      */

154     public void addValue(Profile prof) throws PopulateException {
155         if(prof != null) {
156             super.addValue(prof);
157         }
158     }
159     
160     /**
161      * Adds the given <code>Profile</code> as a value of this instance.
162      *
163      * @param prof the <code>Profile</code> to add
164      * @param nId the id of the <code>Profile</code>
165      * @throws InvalidPropertyValueException if the value is invalid for
166      * this property instance
167      */

168     public void addValue(Profile prof, int nId) throws PopulateException {
169         
170         if(prof != null) {
171             super.addValue(prof,nId);
172         }
173         
174     }
175
176     /**
177      * Removes the given <code>Profile</code> as a value of this instance.
178      *
179      * @param prof the <code>Profile</code> to remove
180      * @throws InvalidPropertyValueException if the value is invalid for
181      * this property instance
182      */

183     public void removeValue(Profile prof)
184         throws InvalidPropertyValueException {
185         super.removeValue(prof);
186     }
187
188     /* (non-Javadoc)
189      * @see org.openharmonise.rm.publishing.Publishable#populate(org.w3c.dom.Element, org.openharmonise.rm.publishing.State)
190      */

191     public void populate(Element xmlElement, State state)
192         throws PopulateException {
193         String JavaDoc sTagName = xmlElement.getTagName();
194         Text txt = null;
195
196         if (sTagName.equals(TAG_PROP_INSTANCE_VALUES) == true) {
197             NodeList nodes =
198                 xmlElement.getElementsByTagName(Profile.TAG_PROFILE);
199
200             for (int i = 0; i < nodes.getLength(); i++) {
201                 Element profEl = (Element) nodes.item(i);
202                 Profile tmpProf =
203                     new Profile(m_dsi, m_profile.getProfiledObject());
204                 try {
205                     tmpProf.populate(profEl, state);
206                     addValue(tmpProf);
207                 } catch (InvalidPropertyValueException e) {
208                     throw new PopulateException(
209                         "Invalid value for PropertyInstance",e);
210                 }
211             }
212         } else {
213             super.populate(xmlElement, state);
214         }
215     }
216
217     /* (non-Javadoc)
218      * @see org.openharmonise.rm.publishing.Publishable#publish(org.w3c.dom.Element, org.openharmonise.rm.publishing.HarmoniseOutput, org.openharmonise.rm.publishing.State)
219      */

220     public Element publish(Element formEl, HarmoniseOutput xmlDoc, State state)
221         throws PublishException {
222
223         Element resultEl = null;
224         String JavaDoc sTagname = formEl.getTagName();
225
226         if (sTagname.equals(TAG_PROPERTYINSTANCE) == true) {
227             resultEl = super.publish(formEl, xmlDoc, state);
228         } else if(sTagname.equals(TAG_PROP_INSTANCE_VALUES)){
229             resultEl = xmlDoc.createElement(TAG_PROP_INSTANCE_VALUES);
230             
231             if (m_values != null) {
232
233                 boolean bAllProps = false;
234                 // need to build up map of required prop names with prop inst els
235
// to publish with
236
Map propInstMap = new Hashtable();
237                 List propInstEls = XMLUtils.getChildrenByName(formEl, TAG_PROPERTYINSTANCE);
238                 Element publishPropInstEl = null;
239                 Element publishValueEl = null;
240                 Element publishAllPropEl = null;
241                 Element publishTemplateEl = null;
242                 
243                 if(propInstEls.size() > 0) {
244
245                     //get prop names
246
Iterator iter = propInstEls.iterator();
247         
248                     while (iter.hasNext()) {
249                         Element propInstEl = (Element) iter.next();
250             
251                         List propEls = XMLUtils.getChildrenByName(propInstEl, Property.TAG_PROPERTY);
252             
253                         if(propEls.size() > 0) {
254                             Element nameEl = (Element) ((Element)propEls.get(0)).getElementsByTagName(AbstractObject.TAG_NAME).item(0);
255             
256                             String JavaDoc sName = nameEl.getChildNodes().item(0).getNodeValue();
257             
258                             propInstMap.put(sName,propInstEl);
259                         }
260         
261                     }
262                 } else {
263                     bAllProps = true;
264                     
265                     NamedNodeMap attrs = formEl.getAttributes();
266                     
267                     publishPropInstEl = xmlDoc.createElement(TAG_PROPERTYINSTANCE);
268                     
269                     Element propEl = xmlDoc.createElement(Property.TAG_PROPERTY);
270                     publishPropInstEl.appendChild(propEl);
271                     
272                     publishValueEl = xmlDoc.createElement(AbstractPropertyInstance.TAG_PROP_INSTANCE_VALUES);
273                     
274                     publishPropInstEl.appendChild(publishValueEl);
275                     
276                     List allprop = XMLUtils.getChildrenByName(formEl, Profile.TAG_ALLPROPERTYINSTANCES);
277                 
278                     if(allprop.size() > 0) {
279                         Element allpropEl = (Element) allprop.get(0);
280                         
281                         Element templateEl = (Element) XMLUtils.getFirstNamedChild(allpropEl, Template.TAG_TEMPLATE);
282                     
283                         if(templateEl != null) {
284                             publishTemplateEl = (Element) xmlDoc.importNode(templateEl, true);
285                             
286                             if(publishAllPropEl != null) {
287                                 publishAllPropEl.appendChild(publishTemplateEl.cloneNode(true));
288                             }
289                         }
290                         
291                         publishAllPropEl = xmlDoc.createElement(Profile.TAG_ALLPROPERTYINSTANCES);
292                         
293                         for(int i=0;i<attrs.getLength();i++) {
294                             Attr attr = (Attr) attrs.item(i);
295                             publishAllPropEl.setAttribute(attr.getName(), attr.getValue());
296                             publishValueEl.setAttribute(attr.getName(), attr.getValue());
297                         }
298                         
299                         
300                         //check for specification on publishing the property of the sub property instance
301
Element origPropEl = XMLUtils.getFirstNamedChild(allpropEl, Property.TAG_PROPERTY);
302                         
303                         if(origPropEl != null) {
304                             NodeList nodes = origPropEl.getChildNodes();
305                             
306                             for (int i = 0; i < nodes.getLength(); i++) {
307                                 Node node =
308                                     (Node) nodes.item(i);
309                                 propEl.appendChild(xmlDoc.importNode(node,true));
310                             }
311                         }
312                         
313                         Element clonePropEl = (Element) propEl.cloneNode(true);
314                         publishAllPropEl.appendChild(clonePropEl);
315                         
316                         
317                     }
318                     
319                 }
320             
321                 
322                 for (int j = 0; j < m_values.size(); j++) {
323                     
324                     try {
325                         Element groupEl = xmlDoc.createElement(ProfilePropertyInstance.TAG_PROPERTYINSTANCE_GROUP);
326                         
327                         Profile tmpProf = (Profile) m_values.get(j);
328                         
329                         List propInsts = tmpProf.getPropertyInstances();
330                         
331                         Iterator iter = propInsts.iterator();
332                         
333                         while (iter.hasNext()) {
334                             AbstractPropertyInstance propInst = (AbstractPropertyInstance) iter.next();
335                             String JavaDoc sPropName = propInst.getName();
336                             if(bAllProps == true) {
337                                 
338                                 //need to add and remove appropriate elements
339
//depending on propInst type
340
if(publishTemplateEl != null) {
341                                     if(propInst instanceof ChildObjectPropertyInstance) {
342                                         publishValueEl.appendChild(publishTemplateEl);
343                                     }
344                                 }
345                                 
346                                 if(publishAllPropEl != null && propInst instanceof ProfilePropertyInstance) {
347                                     publishValueEl.appendChild(publishAllPropEl);
348                                 }
349                                 
350                                 Element publishedEl = propInst.publish(publishPropInstEl, xmlDoc, state);
351                                 groupEl.appendChild(publishedEl);
352                                 
353                                 if(publishTemplateEl != null) {
354                                     if(propInst instanceof ChildObjectPropertyInstance) {
355                                         publishValueEl.removeChild(publishTemplateEl);
356                                     }
357                                 }
358                                 
359                                 if(publishAllPropEl != null && propInst instanceof ProfilePropertyInstance) {
360                                     publishValueEl.removeChild(publishAllPropEl);
361                                 }
362                                 
363                             } else if(propInstMap.containsKey(sPropName)) {
364                                 Element tmpEl = (Element) propInstMap.get(sPropName);
365                                 
366                                 Element publishedEl = propInst.publish(tmpEl, xmlDoc, state);
367                                 
368                                 groupEl.appendChild(publishedEl);
369                             }
370                         }
371                         
372                         resultEl.appendChild(groupEl);
373                     } catch (DataAccessException e) {
374                         throw new PublishException(e.getLocalizedMessage(),e);
375                     }
376                 }
377                 
378             }
379
380         } else {
381             resultEl = super.publish(formEl, xmlDoc, state);
382         }
383
384         if (resultEl == null) {
385             resultEl = xmlDoc.createElement(TAG_ERROR);
386             resultEl.appendChild(
387                 xmlDoc.createTextNode("Problem publishing " + sTagname));
388         }
389
390         return resultEl;
391     }
392
393     /* (non-Javadoc)
394      * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#match(org.openharmonise.rm.metadata.AbstractPropertyInstance)
395      */

396     public boolean match(AbstractPropertyInstance propInst)
397         throws ProfileException {
398         boolean bMatch = false;
399
400         if (propInst instanceof ProfilePropertyInstance) {
401             List otherProfs = propInst.getValues();
402
403             boolean bLooping = true;
404
405             List vals = getValues();
406
407             //first make sure there are the same number of profiles
408
if (vals.size() == otherProfs.size()) {
409
410                 Iterator iter = vals.iterator();
411                 Iterator otherIter = otherProfs.iterator();
412
413                 //loop through profiles to check matches
414
while (iter.hasNext() && bLooping == true) {
415                     Profile tmpProf = (Profile) iter.next();
416                     boolean bFound = false;
417
418                     while (otherIter.hasNext() == true && bFound == false) {
419                         Profile otherProf = (Profile) otherIter.next();
420
421                         if (tmpProf.match(otherProf) == true) {
422                             bFound = true;
423                         }
424                     }
425
426                     if (bFound == false) {
427                         bLooping = false;
428                     }
429                 }
430             }
431
432             // if we've looped through all profiles and bLooping is still true
433
// then there was a match for every profile
434
if (bLooping == true) {
435                 bMatch = true;
436             }
437         }
438
439         return bMatch;
440     }
441
442     /* (non-Javadoc)
443      * @see org.openharmonise.rm.dsi.DataStoreObject#getInstanceJoinConditions(java.lang.String, boolean)
444      */

445     public JoinConditions getInstanceJoinConditions(
446         String JavaDoc sObjectTag,
447         boolean bIsOuter)
448         throws DataStoreException {
449         throw new UnsupportedOperationException JavaDoc();
450     }
451
452     /* (non-Javadoc)
453      * @see org.openharmonise.rm.dsi.DataStoreObject#processResultSet(org.openharmonise.commons.dsi.CachedResultSet, org.openharmonise.commons.dsi.dml.SelectStatement)
454      */

455     public List processResultSet(CachedResultSet resultSet, SelectStatement select) {
456         throw new UnsupportedOperationException JavaDoc();
457     }
458
459     /* (non-Javadoc)
460      * @see org.openharmonise.rm.dsi.DataStoreObject#processResultSet(org.openharmonise.commons.dsi.CachedResultSet, org.openharmonise.commons.dsi.dml.SelectStatement, int)
461      */

462     public List processResultSet(CachedResultSet resultSet, SelectStatement select, int limit) {
463         throw new UnsupportedOperationException JavaDoc();
464     }
465
466     /* (non-Javadoc)
467      * @see org.openharmonise.rm.dsi.DataStoreObject#getInstanceColumnRef(java.lang.String, boolean)
468      */

469     public ColumnRef getInstanceColumnRef(String JavaDoc sColumn, boolean bIsHist)
470         throws DataStoreException {
471         ColumnRef returnColRef = null;
472         String JavaDoc sDBTable = getDBTableName();
473
474         if (sColumn.equals(CLMN_PROFILE_PARENT) == true) {
475             returnColRef =
476                 new ColumnRef(sDBTable, CLMN_PROFILE_PARENT, ColumnRef.NUMBER);
477         }
478
479         if (returnColRef != null) {
480             return returnColRef;
481         } else {
482             return super.getInstanceColumnRef(sColumn, bIsHist);
483         }
484     }
485     
486     /**
487      * Returns the column reference for the column in the profile database table
488      * belonging to the specified <code>AbstractProfiledObject</code>.
489      *
490      * @param profObj the <code>AbstractProfiledObject</code> associated to the
491      * required column reference
492      * @param sColumn the database column name
493      * @param bIsHist <code>true</code> if the column reference returned should
494      * reference the historical table
495      * @return the column reference for the column in the profile database table
496      * belonging to the specified <code>AbstractProfiledObject</code>
497      * @throws DataStoreException if the specified column is invalid
498      */

499     static public ColumnRef getColumnRef(AbstractProfiledObject profObj, String JavaDoc sColumn, boolean bIsHist) throws DataStoreException {
500         ColumnRef returnColRef = null;
501         String JavaDoc sDBTable = Profile.getDBTableName(profObj);
502
503         if (sColumn.equals(TAG_VALUE) == true || sColumn.equals(CLMN_PROFILE_PARENT) == true) {
504             returnColRef =
505                 new ColumnRef(sDBTable, CLMN_PROFILE_PARENT, ColumnRef.NUMBER);
506         }
507
508         if (returnColRef != null) {
509             return returnColRef;
510         } else {
511             throw new InvalidColumnReferenceException(sColumn);
512         }
513     }
514
515     /**
516      * Returns the database table which holds the data for this
517      * property instance type for the specified <code>Profile</code>.
518      *
519      * @param profile the <code>Profile</code> for which the requested
520      * property instance table will be linked to
521      * @return the database table which holds the data for this
522      * property instance type for the specified <code>Profile</code>
523      */

524     public static String JavaDoc getDBTableName(Profile profile) {
525         return profile.getDBTableName();
526     }
527
528     
529     /*-------------------------------------------------------------------------------------
530     Protected Methods
531     --------------------------------------------------------------------------------------*/

532
533     /* (non-Javadoc)
534      * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#save(org.openharmonise.rm.metadata.Profile)
535      */

536     protected void save(Profile prof) throws ProfileException, EditException {
537         if ((m_bIsTemporary == false) && hasValues() == true) {
538             //make sure database table is current
539
setDBTable(prof);
540
541             m_profile = prof;
542
543             UpdateStatement update = new UpdateStatement();
544             String JavaDoc sTable = getDBTableName();
545             
546             for(int i = 0; i < m_values.size() ;i++) {
547                 try {
548
549                     Profile tmpProf = (Profile) m_values.get(i);
550
551                     update.clear();
552
553                     tmpProf = tmpProf.save(prof.getProfiledObject());
554
555                     m_values.set(i, tmpProf);
556
557                     boolean bIsHist = isHistorical();
558
559                     update.setTable(sTable);
560
561                     update.addColumnValue(
562                         this.getInstanceColumnRef(CLMN_PROFILE_PARENT, bIsHist),
563                         m_profile.getId());
564                     update.addColumnValue(
565                         this.getInstanceColumnRef(CLMN_PROPERTY_ID, bIsHist),
566                         getProperty().getId());
567
568                     update.addWhereCondition(
569                         this.getInstanceColumnRef(CLMN_ID, bIsHist),
570                         "=",
571                         tmpProf.getId());
572
573                     m_dsi.execute(update);
574                 } catch (DataStoreException e) {
575                     throw new ProfileException(e.getMessage(),e);
576                 } catch (DataAccessException e) {
577                     throw new ProfileException(e.getMessage(),e);
578                 }
579             }
580
581             update.clear();
582             
583             m_values2Add.clear();
584             m_values2Remove.clear();
585
586             setIsChanged(false);
587             setIsPopulated(true);
588         }
589     }
590
591
592     /* (non-Javadoc)
593      * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#update(org.openharmonise.rm.metadata.Profile)
594      */

595     protected void update(Profile prof) throws ProfileException, EditException {
596         if (isPopulated() == true && isChanged() == true) {
597             UpdateStatement update = new UpdateStatement();
598             //make sure database table is current
599
setDBTable(prof);
600
601             m_profile = prof;
602
603             boolean bIsHist = isHistorical();
604             
605             String JavaDoc sTable = getDBTableName();
606             
607             for(int i = 0; i < m_values2Add.size() ;i++) {
608                 Profile profVal = (Profile) m_values2Add.get(i);
609                 int nIndex = m_values.indexOf(profVal);
610                 
611                 update.clear();
612                 try {
613                     
614                     Profile tmpProf = profVal.save(prof.getProfiledObject());
615                     
616                     if(nIndex >= 0) {
617                         m_values.set(nIndex, tmpProf);
618                     } else {
619                         m_values.add(tmpProf);
620                     }
621                     
622                     update.setTable(sTable);
623
624                     update.addColumnValue(
625                         this.getInstanceColumnRef(CLMN_PROFILE_PARENT, bIsHist),
626                         m_profile.getId());
627                     update.addColumnValue(
628                         this.getInstanceColumnRef(CLMN_PROPERTY_ID, bIsHist),
629                         getProperty().getId());
630
631                     update.addWhereCondition(
632                         this.getInstanceColumnRef(CLMN_ID, bIsHist),
633                         "=",
634                         tmpProf.getId());
635
636                     m_dsi.execute(update);
637                 } catch (DataStoreException e) {
638                     throw new ProfileException(
639                         "Error occurred processing insert",e);
640                 } catch (DataAccessException e) {
641                     throw new ProfileException(
642                         "Error occurred processing insert",e);
643                 }
644             }
645             
646             Iterator iter = m_values2Remove.iterator();
647             
648             while(iter.hasNext()) {
649                 Profile tmpProf = (Profile) iter.next();
650                 int nIndex = m_values.indexOf(tmpProf);
651                 
652                 if(nIndex >= 0) {
653                     m_values.remove(nIndex);
654                 }
655                 
656                 tmpProf.delete();
657             }
658         } else if(isPopulated() == false) {
659             // if this happens to be a new property instance on the profile
660
save(prof);
661         }
662         
663         m_values2Add.clear();
664         m_values2Remove.clear();
665
666         setIsChanged(false);
667         setIsPopulated(true);
668
669     }
670
671     /**
672      * Deletes this instance, which in turn will delete all the
673      * <code>Profile</code> values and their property instances.
674      *
675      * @throws ProfileException if there is an error deleting any
676      * of the <code>Profile</code> values
677      */

678     protected void delete() throws ProfileException {
679         Iterator iter = m_values.iterator();
680
681         while (iter.hasNext()) {
682             Profile tmpProf = (Profile) iter.next();
683
684             tmpProf.delete();
685         }
686
687         m_values.clear();
688     }
689
690     /* (non-Javadoc)
691      * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#getColumnForData()
692      */

693     protected ColumnRef getColumnForData() throws DataStoreException {
694         throw new UnsupportedOperationException JavaDoc();
695     }
696
697     /* (non-Javadoc)
698      * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#getValueToStoreForValue(java.lang.Object)
699      */

700     protected Object JavaDoc getValueToStoreForValue(Object JavaDoc val)
701         throws ProfileException {
702         throw new UnsupportedOperationException JavaDoc();
703     }
704
705     /* (non-Javadoc)
706      * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#setDBTable(org.openharmonise.rm.metadata.Profile)
707      */

708     protected void setDBTable(Profile profile) {
709         m_sDataTable = profile.getDBTableName();
710     }
711     /* (non-Javadoc)
712      * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#isChanged()
713      */

714     protected boolean isChanged() {
715         boolean bIsChanged = super.isChanged();
716         
717         if(bIsChanged == false) {
718             Iterator iter = m_values.iterator();
719             
720             while (iter.hasNext() && bIsChanged == false) {
721                 Profile prof = (Profile) iter.next();
722                 try {
723                     bIsChanged = prof.isChanged();
724                 } catch (DataAccessException e) {
725                     m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
726                 }
727             }
728         }
729         
730         return bIsChanged;
731     }
732
733     /* (non-Javadoc)
734      * @see org.openharmonise.rm.metadata.AbstractPropertyInstance#setHistorical(boolean)
735      */

736     protected void setHistorical(boolean bIsHist) {
737         
738         if(hasValues() == true) {
739             Iterator iter = m_values.iterator();
740             
741             while (iter.hasNext()) {
742                 Profile tmpProf = (Profile) iter.next();
743                 tmpProf.setHistorical(bIsHist);
744             }
745         }
746         
747         super.setHistorical(bIsHist);
748     }
749
750 }
751
Popular Tags