/** * INTERNAL: * Iterate over the specified attribute value, */ public void iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue) { iterator.iterateValueHolderForMapping((ValueHolderInterface)attributeValue, this.getMapping()); }
/** * INTERNAL * Replace the client value holder with the server value holder, * after copying some of the settings from the client value holder. */ public void mergeRemoteValueHolder(Object clientSideDomainObject, Object serverSideDomainObject, MergeManager mergeManager) { // This will always be a remote value holder coming from the server, RemoteValueHolder serverValueHolder = (RemoteValueHolder)getMapping().getAttributeValueFromObject(serverSideDomainObject); mergeClientIntoServerValueHolder(serverValueHolder, mergeManager); getMapping().setAttributeValueInObject(clientSideDomainObject, serverValueHolder); }
/** * Reset the wrapper used to store the value. */ public void reset(Object target) { getMapping().setAttributeValueInObject(target, new ValueHolder()); }
/** * INTERNAL: * Verify that the value of the attribute within an instantiated object * is of the appropriate type for the indirection policy. * In this case, the attribute must be non-null and it must be a * ValueHolderInterface. * If the value is null return a new indirection object to be used for the attribute. */ public Object validateAttributeOfInstantiatedObject(Object attributeValue) { // PERF: If the value is null, create a new value holder instance for the attribute value, // this allows for indirection attributes to not be instantiated in the constructor as they // are typically replaced when reading or cloning so is very inefficient to initialize. if (attributeValue == null) { return new ValueHolder(); } if (!(attributeValue instanceof ValueHolderInterface)) { throw DescriptorException.valueHolderInstantiationMismatch(attributeValue, this.getMapping()); } return attributeValue; }
/** * INTERNAL: * An object has been serialized from the server to the client. * Replace the transient attributes of the remote value holders * with client-side objects. */ public void fixObjectReferences(Object object, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, RemoteSession session) { Object attributeValue = this.getMapping().getAttributeValueFromObject(object); //bug 4147755 if it is not a Remote Valueholder then treat as if there was no VH... if (attributeValue instanceof RemoteValueHolder){ RemoteValueHolder rvh = (RemoteValueHolder)this.getMapping().getAttributeValueFromObject(object); rvh.setSession(session); rvh.setMapping(this.getMapping()); if ((!query.shouldMaintainCache()) && ((!query.shouldCascadeParts()) || (query.shouldCascadePrivateParts() && (!getMapping().isPrivateOwned())))) { rvh.setQuery(null); } else { rvh.setQuery(query); } // set to uninstantiated since no objects are serialized past remote value holders rvh.setUninstantiated(); }else{ this.getMapping().fixRealObjectReferences(object, objectDescriptors, processedObjects, query, session); } }
/** * INTERNAL: * Verify that getter returnType is correct for the * indirection policy. If it is incorrect, add an exception * to the integrity checker. * In this case, the return type MUST be ValueHolderInterface. */ public void validateGetMethodReturnType(Class returnType, IntegrityChecker checker) throws DescriptorException { super.validateGetMethodReturnType(returnType, checker); if (!this.typeIsValid(returnType)) { checker.handleError(DescriptorException.returnAndMappingWithIndirectionMismatch(this.getMapping())); } }
/** * INTERNAL: * Set the value of the appropriate attribute of target to attributeValue. * In this case, place the value inside the target's ValueHolder. */ public void setRealAttributeValueInObject(Object target, Object attributeValue) { ValueHolderInterface holder = (ValueHolderInterface)this.getMapping().getAttributeValueFromObject(target); if (holder == null) { holder = new ValueHolder(attributeValue); } else { holder.setValue(attributeValue); } super.setRealAttributeValueInObject(target, holder); }
/** * INTERNAL: * Verify that attributeType is correct for the * indirection policy. If it is incorrect, add an exception to the * integrity checker. * In this case, the attribute type MUST be ValueHolderInterface. */ public void validateDeclaredAttributeType(Class attributeType, IntegrityChecker checker) throws DescriptorException { super.validateDeclaredAttributeType(attributeType, checker); if (!this.typeIsValid(attributeType)) { checker.handleError(DescriptorException.attributeAndMappingWithIndirectionMismatch(this.getMapping())); } }
/** * INTERNAL: * Verify that setter parameterType is correct for the * indirection policy. If it is incorrect, add an exception * to the integrity checker. * In this case, the parameter type MUST be ValueHolderInterface. */ public void validateSetMethodParameterType(Class parameterType, IntegrityChecker checker) throws DescriptorException { super.validateSetMethodParameterType(parameterType, checker); if (!this.typeIsValid(parameterType)) { checker.handleError(DescriptorException.parameterAndMappingWithIndirectionMismatch(this.getMapping())); } }
&& (((DatabaseValueHolder) valueHolder).getSession() == null) && (! ((DatabaseValueHolder) valueHolder).isSerializedRemoteUnitOfWorkValueHolder())) { throw DescriptorException.attemptToRegisterDeadIndirection(original, getMapping()); if (this.getMapping().getRelationshipPartner() == null) { result = new ValueHolder(); result.setValue(this.getMapping().buildCloneForPartObject(valueHolder.getValue(), original, clone, unitOfWork, false)); } else { row = ((DatabaseValueHolder)valueHolder).getRow(); result = this.getMapping().createUnitOfWorkValueHolder(valueHolder, original, clone, row, unitOfWork, buildDirectlyFromRow); Object newObject = this.getMapping().buildCloneForPartObject(valueHolder.getValue(), original, clone, unitOfWork, false); ((UnitOfWorkValueHolder)result).privilegedSetValue(newObject); ((UnitOfWorkValueHolder)result).setInstantiated(); row = ((DatabaseValueHolder)valueHolder).getRow(); result = this.getMapping().createUnitOfWorkValueHolder(valueHolder, original, clone, row, unitOfWork, buildDirectlyFromRow);
AbstractRecord row = getMapping().getDescriptor().getObjectBuilder().buildRow(object, session); ReadObjectQuery query = new ReadObjectQuery(); query.setSession(((RemoteUnitOfWork) session).getParent()); valueHolder = (ValueHolderInterface) getMapping().valueFromRow(row, null, query); } else { valueHolder = (ValueHolderInterface) controller.getRemoteValueHolders().get(id);