@Override public Class<?> getPropertyType(String propertyName) { return getMapping(propertyName).getAttributeClassification(); }
public Class<?> getPropertyType(String propertyName) { return getMapping(propertyName).getAttributeClassification(); }
public Class<?> getPropertyType(int propertyIndex) { return getMapping(propertyIndex).getAttributeClassification(); }
public Class<?> getPropertyType(String propertyName) { return getMapping(propertyName).getAttributeClassification(); }
@Override public Class<?> getPropertyType(int propertyIndex) { return getDescriptor().getMappings().get(propertyIndex).getAttributeClassification(); }
public Class<?> getPropertyType(int propertyIndex) { return getDescriptor().getMappings().get(propertyIndex).getAttributeClassification(); }
@SuppressWarnings("unchecked") @Override public void initialize(final DatabaseMapping mapping, final Session session) { enumClass = mapping.getAttributeClassification(); pgTypeName = mapping.getField().getColumnDefinition(); checkPgTypeName(); // if (Strings.isNullOrEmpty(pgTypeName)) { // pgTypeName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, enumClass.getSimpleName()); // } }
@Override public Class<?> getAttributeClass() { if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping)mapping; if (refMapping.isCollectionMapping()) { return ((CollectionMapping)refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (mapping.getAttributeClassification() == null) { return ClassConstants.OBJECT; } return mapping.getAttributeClassification(); } } }
@Override public Class<?> getAttributeClass() { if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping)mapping; if (refMapping.isCollectionMapping()) { return ((CollectionMapping)refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (mapping.getAttributeClassification() == null) { return ClassConstants.OBJECT; } return mapping.getAttributeClassification(); } } }
/** * Test if a mapping requires initialization when a new instance is created. * This is true for: * <ul> * <li>primitives * <li>collection mappings * <li>basic indirection references * </ul> * * @see DynamicHelper#newDynamicEntity for creation and initialization */ private boolean requiresInitialization(DatabaseMapping mapping) { if (mapping.isDirectToFieldMapping() && mapping.getAttributeClassification() != null && mapping.getAttributeClassification().isPrimitive()) { return true; } if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping frMapping = (ForeignReferenceMapping) mapping; return frMapping.usesIndirection() || frMapping.isCollectionMapping(); } if (mapping.isAggregateObjectMapping() && !mapping.isXMLMapping()) { return !((AggregateObjectMapping) mapping).isNullAllowed(); } return false; }
/** * Test if a mapping requires initialization when a new instance is created. * This is true for: * <ul> * <li>primitives * <li>collection mappings * <li>basic indirection references * </ul> * * @see DynamicHelper#newDynamicEntity for creation and initialization */ private boolean requiresInitialization(DatabaseMapping mapping) { if (mapping.isDirectToFieldMapping() && mapping.getAttributeClassification() != null && mapping.getAttributeClassification().isPrimitive()) { return true; } if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping frMapping = (ForeignReferenceMapping) mapping; return frMapping.usesIndirection() || frMapping.isCollectionMapping(); } if (mapping.isAggregateObjectMapping() && !mapping.isXMLMapping()) { return !((AggregateObjectMapping) mapping).isNullAllowed(); } return false; }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { XMLRoot root = new XMLRoot(); root.setLocalName(this.rootFragment.getLocalName()); root.setNamespaceURI(this.rootFragment.getNamespaceURI()); if(mapping.isAbstractDirectMapping()){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } root.setObject(dataValue); return root; }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { XMLRoot root = new XMLRoot(); root.setLocalName(this.rootFragment.getLocalName()); root.setNamespaceURI(this.rootFragment.getNamespaceURI()); if(mapping.isAbstractDirectMapping()){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } root.setObject(dataValue); return root; }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { XMLRoot root = new XMLRoot(); root.setLocalName(this.rootFragment.getLocalName()); root.setNamespaceURI(this.rootFragment.getNamespaceURI()); if(mapping.isAbstractDirectMapping()){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } root.setObject(dataValue); return root; }
@Override public Class<?> getAttributeClass() { if (getMapping().isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping) getMapping(); if (refMapping.isCollectionMapping()) { return ((CollectionMapping) refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (getMapping().getAttributeClassification() == null) { return ClassConstants.OBJECT; } return getMapping().getAttributeClassification(); } } }
/** * INTERNAL: * Default to the PK of the owning descriptor when no MapKey or MapKey:name attribute is specified. * Prerequisites: policy on the mapping is of type MappedKeyMapPolicy * @return */ private Class getOwningPKTypeWhenMapKeyAnnotationMissingOrDefaulted(MappedKeyMapContainerPolicy policy) { Class<?> javaClass = null;; MapKeyMapping mapKeyMapping = policy.getKeyMapping(); ClassDescriptor descriptor = ((DatabaseMapping)mapKeyMapping).getDescriptor(); // If the reference descriptor is null then we are on a direct mapping if(null != descriptor) { javaClass = ((DatabaseMapping)mapKeyMapping).getAttributeClassification(); if(null == javaClass) { // Default to the PK of the owning descriptor when no MapKey or MapKey:name attribute is specified if (descriptor.getCMPPolicy() != null) { javaClass = descriptor.getCMPPolicy().getPKClass(); } } } return javaClass; }
private Property buildProperty(PersistenceContext context, DatabaseMapping mapping) { if (mapping.isCollectionMapping()) { final Property property = new Property(); property.setType("array"); property.setItems(buildProperty(context, getCollectionGenericClass(mapping))); return property; } else if (mapping.isForeignReferenceMapping()) { final ForeignReferenceMapping foreignReferenceMapping = (ForeignReferenceMapping)mapping; final String href = HrefHelper.buildEntityMetadataHref(context, foreignReferenceMapping.getReferenceClass().getSimpleName() + "#"); return new Property(href); } else { return buildProperty(context, mapping.getAttributeClassification()); } }
private Property buildProperty(PersistenceContext context, DatabaseMapping mapping) { if (mapping.isCollectionMapping()) { final Property property = new Property(); property.setType("array"); property.setItems(buildProperty(context, getCollectionGenericClass(mapping))); return property; } else if (mapping.isForeignReferenceMapping()) { final ForeignReferenceMapping foreignReferenceMapping = (ForeignReferenceMapping)mapping; final String href = HrefHelper.buildEntityMetadataHref(context, foreignReferenceMapping.getReferenceClass().getSimpleName() + "#"); return new Property(href); } else { return buildProperty(context, mapping.getAttributeClassification()); } }
/** * INTERNAL: * Set the mapping. */ public void initialize(DatabaseMapping mapping, Session session) { this.mapping = mapping; // CR#... Mapping must also have the field classification. if (getMapping().isDirectToFieldMapping()) { AbstractDirectMapping directMapping = (AbstractDirectMapping)getMapping(); // Allow user to specify field type to override computed value. (i.e. blob, nchar) if (directMapping.getFieldClassification() == null) { directMapping.setFieldClassification(getSerializer().getType()); } } if (this.serializer != null) { this.serializer.initialize(mapping.getAttributeClassification(), this.serializerPackage, session); } }
/** * INTERNAL: * Set the mapping. */ public void initialize(DatabaseMapping mapping, Session session) { this.mapping = mapping; // CR#... Mapping must also have the field classification. if (getMapping().isDirectToFieldMapping()) { AbstractDirectMapping directMapping = (AbstractDirectMapping)getMapping(); // Allow user to specify field type to override computed value. (i.e. blob, nchar) if (directMapping.getFieldClassification() == null) { directMapping.setFieldClassification(getSerializer().getType()); } } if (this.serializer != null) { this.serializer.initialize(mapping.getAttributeClassification(), this.serializerPackage, session); } }