/** * INTERNAL: * Convenience method. * Return the value of an attribute, unwrapping value holders if necessary. * If the value is null, build a new container. */ public Object getRealCollectionAttributeValueFromObject(Object object, AbstractSession session) throws DescriptorException { Object value = this.getRealAttributeValueFromObject(object, session); if (value == null) { value = this.getContainerPolicy().containerInstance(1); } return value; }
/** * INTERNAL: * Convenience method. * Return the value of an attribute, unwrapping value holders if necessary. * If the value is null, build a new container. */ @Override public Object getRealCollectionAttributeValueFromObject(Object object, AbstractSession session) throws DescriptorException { Object value = this.getRealAttributeValueFromObject(object, session); if (value == null) { value = this.getContainerPolicy().containerInstance(1); } return value; }
/** * INTERNAL: * Convenience method. * Return the value of an attribute, unwrapping value holders if necessary. * If the value is null, build a new container. */ @Override public Object getRealCollectionAttributeValueFromObject(Object object, AbstractSession session) throws DescriptorException { Object value = this.getRealAttributeValueFromObject(object, session); if (value == null) { value = this.getContainerPolicy().containerInstance(1); } return value; }
/** * ADVANCED: * This method is used to have an object add to a collection once the changeSet is applied * The referenceKey parameter should only be used for direct Maps. PLEASE ENSURE that the changes * have been made in the object model first. */ public void simpleAddToCollectionChangeRecord(Object referenceKey, Object changeSetToAdd, ObjectChangeSet changeSet, AbstractSession session) { AggregateCollectionChangeRecord collectionChangeRecord = (AggregateCollectionChangeRecord)changeSet.getChangesForAttributeNamed(this.getAttributeName()); if (collectionChangeRecord == null) { //if there is no change for this attribute then create a changeSet for it. no need to modify the resulting // change record as it should be built from the clone which has the changes allready Object cloneObject = ((UnitOfWorkChangeSet)changeSet.getUOWChangeSet()).getUOWCloneForObjectChangeSet(changeSet); Object cloneCollection = this.getRealAttributeValueFromObject(cloneObject, session); collectionChangeRecord = (AggregateCollectionChangeRecord)convertToChangeRecord(cloneCollection, changeSet, session); changeSet.addChange(collectionChangeRecord); } else { collectionChangeRecord.getChangedValues().add(changeSetToAdd); } }
/** * ADVANCED: * This method is used to have an object removed from a collection once the changeSet is applied * The referenceKey parameter should only be used for direct Maps. PLEASE ENSURE that the changes * have been made in the object model first. */ public void simpleRemoveFromCollectionChangeRecord(Object referenceKey, Object changeSetToRemove, ObjectChangeSet changeSet, AbstractSession session) { AggregateCollectionChangeRecord collectionChangeRecord = (AggregateCollectionChangeRecord)changeSet.getChangesForAttributeNamed(this.getAttributeName()); if (collectionChangeRecord == null) { //if there is no change for this attribute then create a changeSet for it. no need to modify the resulting // change record as it should be built from the clone which has the changes allready Object cloneObject = ((UnitOfWorkChangeSet)changeSet.getUOWChangeSet()).getUOWCloneForObjectChangeSet(changeSet); Object cloneCollection = this.getRealAttributeValueFromObject(cloneObject, session); collectionChangeRecord = (AggregateCollectionChangeRecord)convertToChangeRecord(cloneCollection, changeSet, session); changeSet.addChange(collectionChangeRecord); } else { collectionChangeRecord.getChangedValues().remove(changeSetToRemove); } }