/** * INTERNAL: * The mapping is initialized with the given session. This mapping is fully initialized * after this. */ public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); if (this.getContainerPolicy() instanceof MapContainerPolicy) { ((MapContainerPolicy)getContainerPolicy()).setElementClass(this.getReferenceClass()); } }
@Override protected AbstractRecord buildCompositeRow(Object attributeValue, AbstractSession session, AbstractRecord parentRow, WriteType writeType) { if (((EISDescriptor)getDescriptor()).isXMLFormat()) { XMLObjectBuilder objectBuilder = (XMLObjectBuilder)getReferenceDescriptor(attributeValue, session).getObjectBuilder(); return objectBuilder.buildRow(attributeValue, session, getField(), (XMLRecord)parentRow); } else { return this.getObjectBuilder(attributeValue, session).buildRow(attributeValue, session, writeType); } } }
/** * PUBLIC: * Set the name of the field mapped by the mapping. */ public void setFieldName(String fieldName) { this.setField(new DatabaseField(fieldName)); }
if (mapping.isEISMapping()) { EISCompositeCollectionMapping collectionMapping = (EISCompositeCollectionMapping) mapping; Class collectionClass = collectionMapping.getContainerPolicy().getContainerClass(); String collectionType = getSimplePublicCollectionTypeName(collectionClass); if (collectionType == null) { collectionType = collectionClass.getSimpleName(); if (collectionMapping.getReferenceClass() != null) { collectionName = collectionMapping.getReferenceClass().getSimpleName(); if ((collectionName == null) && (collectionMapping.getAttributeClassification() != null)) { collectionName = collectionMapping.getAttributeClassification().getSimpleName(); if (collectionMapping.getContainerPolicy().isMapPolicy()) { String mapKeyType = ((MapContainerPolicy) collectionMapping.getContainerPolicy()).getKeyType().getClass().getSimpleName(); target = collectionType + "<" + mapKeyType + ", " + collectionName + ">"; } else {
private Class getCollectionGenericClass(DatabaseMapping mapping) { Class collectionName = null; if (mapping.isEISMapping()) { final EISCompositeCollectionMapping collectionMapping = (EISCompositeCollectionMapping) mapping; if (collectionMapping.getReferenceClass() != null) { collectionName = collectionMapping.getReferenceClass(); } if ((collectionName == null) && (collectionMapping.getAttributeClassification() != null)) { collectionName = collectionMapping.getAttributeClassification(); } } else { final CollectionMapping collectionMapping = (CollectionMapping) mapping; if (collectionMapping.getReferenceClass() != null) { collectionName = collectionMapping.getReferenceClass(); } if ((collectionName == null) && (collectionMapping.getAttributeClassification() != null)) { collectionName = collectionMapping.getAttributeClassification(); } } return collectionName; } }
xmlElement.setContainerType(((EISCompositeDirectCollectionMapping) mapping).getContainerPolicy().getContainerClassName()); } else if (mapping instanceof EISCompositeCollectionMapping) { xmlElement.setContainerType(((EISCompositeCollectionMapping) mapping).getContainerPolicy().getContainerClassName()); xmlElement.setType(((EISCompositeCollectionMapping) mapping).getReferenceClassName());
/** * PUBLIC: * Return the name of the field mapped by the mapping. */ public String getFieldName() { return this.getField().getName(); }
/** * Return a new aggregate collection/element collection mapping for this type of descriptor. */ @Override public DatabaseMapping newAggregateCollectionMapping() { return new EISCompositeCollectionMapping(); }
private void setRelationshipInfo(Object entity) { if ((entity != null) && (entity instanceof PersistenceWeavedRest)) { ClassDescriptor descriptor = getServerSession().getClassDescriptor(entity.getClass()); if (descriptor != null) { ((PersistenceWeavedRest) entity)._persistence_setRelationships(new ArrayList<RelationshipInfo>()); for (DatabaseMapping mapping : descriptor.getMappings()) { if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping frMapping = (ForeignReferenceMapping) mapping; RelationshipInfo info = new RelationshipInfo(); info.setAttributeName(frMapping.getAttributeName()); info.setOwningEntity(entity); info.setOwningEntityAlias(descriptor.getAlias()); info.setPersistencePrimaryKey(descriptor.getObjectBuilder().extractPrimaryKeyFromObject(entity, (AbstractSession) getServerSession())); ((PersistenceWeavedRest) entity)._persistence_getRelationships().add(info); } else if (mapping.isEISMapping()) { if (mapping instanceof EISCompositeCollectionMapping) { EISCompositeCollectionMapping eisMapping = (EISCompositeCollectionMapping) mapping; RelationshipInfo info = new RelationshipInfo(); info.setAttributeName(eisMapping.getAttributeName()); info.setOwningEntity(entity); info.setOwningEntityAlias(descriptor.getAlias()); info.setPersistencePrimaryKey(descriptor.getObjectBuilder().extractPrimaryKeyFromObject(entity, (AbstractSession) getServerSession())); ((PersistenceWeavedRest) entity)._persistence_getRelationships().add(info); } } } } } }
if (mapping.isEISMapping()) { EISCompositeCollectionMapping collectionMapping = (EISCompositeCollectionMapping) mapping; Class collectionClass = collectionMapping.getContainerPolicy().getContainerClass(); String collectionType = getSimplePublicCollectionTypeName(collectionClass); if (collectionType == null) { collectionType = collectionClass.getSimpleName(); if (collectionMapping.getReferenceClass() != null) { collectionName = collectionMapping.getReferenceClass().getSimpleName(); if ((collectionName == null) && (collectionMapping.getAttributeClassification() != null)) { collectionName = collectionMapping.getAttributeClassification().getSimpleName(); if (collectionMapping.getContainerPolicy().isMapPolicy()) { String mapKeyType = ((MapContainerPolicy) collectionMapping.getContainerPolicy()).getKeyType().getClass().getSimpleName(); target = collectionType + "<" + mapKeyType + ", " + collectionName + ">"; } else {
private Class getCollectionGenericClass(DatabaseMapping mapping) { Class collectionName = null; if (mapping.isEISMapping()) { final EISCompositeCollectionMapping collectionMapping = (EISCompositeCollectionMapping) mapping; if (collectionMapping.getReferenceClass() != null) { collectionName = collectionMapping.getReferenceClass(); } if ((collectionName == null) && (collectionMapping.getAttributeClassification() != null)) { collectionName = collectionMapping.getAttributeClassification(); } } else { final CollectionMapping collectionMapping = (CollectionMapping) mapping; if (collectionMapping.getReferenceClass() != null) { collectionName = collectionMapping.getReferenceClass(); } if ((collectionName == null) && (collectionMapping.getAttributeClassification() != null)) { collectionName = collectionMapping.getAttributeClassification(); } } return collectionName; } }
xmlElement.setContainerType(((EISCompositeDirectCollectionMapping) mapping).getContainerPolicy().getContainerClassName()); } else if (mapping instanceof EISCompositeCollectionMapping) { xmlElement.setContainerType(((EISCompositeCollectionMapping) mapping).getContainerPolicy().getContainerClassName()); xmlElement.setType(((EISCompositeCollectionMapping) mapping).getReferenceClassName());
/** * Get the XPath String * * @return String the XPath String associated with this Mapping * */ public String getXPath() { return getField().getName(); }
/** * Return a new aggregate collection/element collection mapping for this type of descriptor. */ @Override public DatabaseMapping newAggregateCollectionMapping() { return new EISCompositeCollectionMapping(); }
private void setRelationshipInfo(Object entity) { if ((entity != null) && (entity instanceof PersistenceWeavedRest)) { ClassDescriptor descriptor = getServerSession().getClassDescriptor(entity.getClass()); if (descriptor != null) { ((PersistenceWeavedRest) entity)._persistence_setRelationships(new ArrayList<RelationshipInfo>()); for (DatabaseMapping mapping : descriptor.getMappings()) { if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping frMapping = (ForeignReferenceMapping) mapping; RelationshipInfo info = new RelationshipInfo(); info.setAttributeName(frMapping.getAttributeName()); info.setOwningEntity(entity); info.setOwningEntityAlias(descriptor.getAlias()); info.setPersistencePrimaryKey(descriptor.getObjectBuilder().extractPrimaryKeyFromObject(entity, (AbstractSession) getServerSession())); ((PersistenceWeavedRest) entity)._persistence_getRelationships().add(info); } else if (mapping.isEISMapping()) { if (mapping instanceof EISCompositeCollectionMapping) { EISCompositeCollectionMapping eisMapping = (EISCompositeCollectionMapping) mapping; RelationshipInfo info = new RelationshipInfo(); info.setAttributeName(eisMapping.getAttributeName()); info.setOwningEntity(entity); info.setOwningEntityAlias(descriptor.getAlias()); info.setPersistencePrimaryKey(descriptor.getObjectBuilder().extractPrimaryKeyFromObject(entity, (AbstractSession) getServerSession())); ((PersistenceWeavedRest) entity)._persistence_getRelationships().add(info); } } } } } }
protected AbstractRecord buildCompositeRow(Object attributeValue, AbstractSession session, AbstractRecord parentRow) { if (((EISDescriptor)getDescriptor()).getDataFormat() == EISDescriptor.XML) { XMLObjectBuilder objectBuilder = (XMLObjectBuilder)getReferenceDescriptor(attributeValue, session).getObjectBuilder(); return objectBuilder.buildRow(attributeValue, session, getField(), (XMLRecord)parentRow); } else { return this.getObjectBuilder(attributeValue, session).buildRow(attributeValue, session); } } }
/** * INTERNAL: * The mapping is initialized with the given session. This mapping is fully initialized * after this. */ public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); if (this.getContainerPolicy() instanceof MapContainerPolicy) { ((MapContainerPolicy)getContainerPolicy()).setElementClass(this.getReferenceClass()); } }
/** * PUBLIC: * Set the name of the field mapped by the mapping. */ public void setFieldName(String fieldName) { this.setField(new DatabaseField(fieldName)); }
/** * Get the XPath String * * @return String the XPath String associated with this Mapping * */ public String getXPath() { return getField().getName(); }
@Override protected AbstractRecord buildCompositeRow(Object attributeValue, AbstractSession session, AbstractRecord parentRow, WriteType writeType) { if (((EISDescriptor)getDescriptor()).isXMLFormat()) { XMLObjectBuilder objectBuilder = (XMLObjectBuilder)getReferenceDescriptor(attributeValue, session).getObjectBuilder(); return objectBuilder.buildRow(attributeValue, session, getField(), (XMLRecord)parentRow); } else { return this.getObjectBuilder(attributeValue, session).buildRow(attributeValue, session, writeType); } } }