Example usage for org.hibernate.mapping Property getMetaAttribute

List of usage examples for org.hibernate.mapping Property getMetaAttribute

Introduction

In this page you can find the example usage for org.hibernate.mapping Property getMetaAttribute.

Prototype

public MetaAttribute getMetaAttribute(String attributeName) 

Source Link

Usage

From source file:com.siemens.scr.avt.ad.query.common.DicomMappingDictionaryLoadingStrategy.java

License:Open Source License

private void loadDicomHeaderMetadata(DicomMappingDictionary dict, String table, String column, Property prop) {
    MetaAttribute isHeader = prop.getMetaAttribute(DICOM_HEADER);
    if (isHeader != null)
        if (isHeader != null && Boolean.parseBoolean(isHeader.getValue())) {
            DefaultDicomHeaderEntry.setHeaderTable(table);
            DefaultDicomHeaderEntry.setHeaderColumn(column);
        }/* ww  w . ja v  a  2  s  .  c  o m*/
}

From source file:com.siemens.scr.avt.ad.query.common.DicomMappingDictionaryLoadingStrategy.java

License:Open Source License

private void loadTag(DicomMappingDictionary dict, Property prop, String key) {
    MetaAttribute tag = prop.getMetaAttribute(TAG);

    if (tag != null) {
        dict.addTag2Key(parseHex(tag.getValue()), key);
    }//from   ww w  .ja  va2s  .  co  m
}

From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer.java

License:Open Source License

@Override
protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) {
    initEClass(mappedEntity);//  w ww. j a va  2s . c  om
    if (TRACER.isEnabled()) {
        TRACER.trace("Building property getter for " + eClass.getName() + "." + mappedProperty.getName()); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (mappedProperty.isBackRef()) {
        return mappedProperty.getGetter(mappedEntity.getMappedClass());
    }
    final CDOPropertyGetter getter;
    if (mappedProperty == mappedEntity.getIdentifierProperty()) {
        getter = new CDOIDPropertyGetter(this, mappedProperty.getName());
    } else if (mappedProperty.getMetaAttribute("version") != null) {
        getter = new CDOVersionPropertyGetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.RESOURCE_PROPERTY) == 0) {
        getter = new CDOResourceIDGetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.CONTAINER_PROPERTY) == 0) {
        getter = new CDOContainerGetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.COMMITTIMESTAMP_PROPERTY) == 0) {
        getter = new CDOBranchTimeStampGetter(this, mappedProperty.getName());
    } else {
        EStructuralFeature feature = getEClass().getEStructuralFeature(mappedProperty.getName());
        if (feature instanceof EReference && feature.isMany()
                && HibernateUtil.getInstance().isCDOResourceContents(feature)) {
            getter = new CDOManyAttributeGetter(this, mappedProperty.getName());
        } else if (feature instanceof EReference && feature.isMany()) {
            getter = new CDOManyReferenceGetter(this, mappedProperty.getName());
        } else if (feature instanceof EReference) {
            getter = new CDOReferenceGetter(this, mappedProperty.getName());
        } else if (feature instanceof EAttribute && feature.isMany()) {
            getter = new CDOManyAttributeGetter(this, mappedProperty.getName());
        } else {
            getter = new CDOPropertyGetter(this, mappedProperty.getName());
        }
    }

    HibernateStore hbStore = HibernateStore.getCurrentHibernateStore();
    getter.setPersistenceOptions(hbStore.getCDODataStore().getPersistenceOptions());
    return getter;
}

From source file:org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.CDORevisionTuplizer.java

License:Open Source License

@Override
protected Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity) {
    initEClass(mappedEntity);//from w  w w . j  a v  a  2s.c om
    if (TRACER.isEnabled()) {
        TRACER.trace("Building property setter for " + eClass.getName() + "." + mappedProperty.getName()); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (mappedProperty.isBackRef()) {
        return mappedProperty.getSetter(mappedEntity.getMappedClass());
    }

    final CDOPropertySetter setter;
    if (mappedProperty == mappedEntity.getIdentifierProperty()) {
        setIdentifierTypeAsAnnotation(mappedProperty);
        setter = new CDOIDPropertySetter(this, mappedProperty.getName());
    } else if (mappedProperty.getMetaAttribute("version") != null) {
        setter = new CDOVersionPropertySetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.RESOURCE_PROPERTY) == 0) {
        setter = new CDOResourceIDSetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.CONTAINER_PROPERTY) == 0) {
        setter = new CDOContainerSetter(this, mappedProperty.getName());
    } else if (mappedProperty.getName().compareTo(CDOHibernateConstants.COMMITTIMESTAMP_PROPERTY) == 0) {
        setter = new CDOBranchTimeStampSetter(this, mappedProperty.getName());
    } else {
        EStructuralFeature feature = getEClass().getEStructuralFeature(mappedProperty.getName());
        if (feature instanceof EReference && feature.isMany()
                && HibernateUtil.getInstance().isCDOResourceContents(feature)) {
            setter = new CDOManyAttributeSetter(this, mappedProperty.getName());
        } else if (feature instanceof EReference && feature.isMany()) {
            setter = new CDOManyReferenceSetter(this, mappedProperty.getName());
        } else if (feature instanceof EAttribute && feature.isMany()) {
            setter = new CDOManyAttributeSetter(this, mappedProperty.getName());
        } else

        if (feature instanceof EReference) {
            setter = new CDOReferenceSetter(this, mappedProperty.getName());
        } else {
            setter = new CDOPropertySetter(this, mappedProperty.getName());
        }
    }

    HibernateStore hbStore = HibernateStore.getCurrentHibernateStore();
    setter.setPersistenceOptions(hbStore.getCDODataStore().getPersistenceOptions());
    return setter;
}

From source file:org.eclipse.emf.teneo.hibernate.HbUtil.java

License:Open Source License

/** Returns the correct accessor on the basis of the type of property */
public static PropertyAccessor getPropertyAccessor(Property mappedProperty, HbDataStore ds, String entityName,
        EClass mappedEClass) {/*from w ww.j  av a2 s.  c o  m*/
    if (mappedProperty.getMetaAttribute(HbConstants.SYNTHETIC_PROPERTY_INDICATOR) != null) { // synthetic
        return new SyntheticPropertyHandler(mappedProperty.getName());
    } else if (mappedProperty.getMetaAttribute(HbMapperConstants.ID_META) != null) { // synthetic
        // ID
        return new IdentifierPropertyHandler();
    } else if (mappedProperty.getMetaAttribute(HbMapperConstants.VERSION_META) != null) {
        return ds.getHbContext().createVersionAccessor();
    } else if (mappedProperty.getName().compareToIgnoreCase("_identifierMapper") == 0) { // name
        // is
        // used
        // by
        // hb
        return new EmbeddedPropertyAccessor(); // new
        // DummyPropertyHandler();
    } else if (mappedProperty.getName().compareToIgnoreCase(HbConstants.PROPERTY_ECONTAINER) == 0) {
        return ds.getHbContext().createEContainerAccessor();
    } else if (mappedProperty.getName()
            .compareToIgnoreCase(HbConstants.PROPERTY_ECONTAINER_FEATURE_NAME) == 0) {
        return ds.getExtensionManager().getExtension(NewEContainerFeatureIDPropertyHandler.class);
    } else if (mappedProperty.getName().compareToIgnoreCase(HbConstants.PROPERTY_ECONTAINER_FEATURE_ID) == 0) {
        return ds.getHbContext().createEContainerFeatureIDAccessor();
    }

    EClass eClass = null;
    if (mappedEClass != null) {
        eClass = mappedEClass;
    } else {
        eClass = ds.getEntityNameStrategy().toEClass(entityName);
        if (eClass == null) {
            // for components this is the case
            eClass = ERuntime.INSTANCE.getEClass(entityName);
        }
    }
    final EStructuralFeature efeature = StoreUtil.getEStructuralFeature(eClass, mappedProperty.getName());

    if (efeature == null) {
        throw new HbMapperException("Feature not found for eclass/entity/property " + eClass.getName() + "/"
                + entityName + "/" + mappedProperty.getName());
    }

    if (log.isDebugEnabled()) {
        log.debug("Creating property accessor for " + mappedProperty.getName() + "/" + entityName + "/"
                + efeature.getName());
    }

    // check extra lazy
    final boolean extraLazy = mappedProperty.getValue() instanceof Collection
            && ((Collection) mappedProperty.getValue()).isExtraLazy();

    if (FeatureMapUtil.isFeatureMap(efeature)) {
        return ds.getHbContext().createFeatureMapPropertyAccessor(efeature);
    } else if (efeature instanceof EReference) {
        final EReference eref = (EReference) efeature;
        if (eref.isMany()) {
            return ds.getHbContext().createEListAccessor(efeature, extraLazy,
                    ds.getPersistenceOptions().isMapEMapAsTrueMap());
        } else {
            PropertyAccessor erefPropertyHandler = ds.getHbContext().createEReferenceAccessor(eref);
            if (erefPropertyHandler instanceof EReferencePropertyHandler) {
                if (mappedProperty.getPersistentClass() != null) {
                    ((EReferencePropertyHandler) erefPropertyHandler).setId(
                            mappedProperty == mappedProperty.getPersistentClass().getIdentifierProperty());
                }
            }
            return erefPropertyHandler;
        }
    } else {
        final EAttribute eattr = (EAttribute) efeature;
        if (eattr.isMany()) {
            return ds.getHbContext().createEListAccessor(efeature, extraLazy,
                    ds.getPersistenceOptions().isMapEMapAsTrueMap());
        } else {
            // note also array types are going here!
            final PropertyAccessor pa = ds.getHbContext().createEAttributeAccessor(eattr);
            // note this check is necessary because maybe somebody override
            // HBContext.createEAttributeAccessor
            // to not return a EAttributePropertyHandler
            if (pa instanceof EAttributePropertyHandler) {
                final EAttributePropertyHandler eAttributePropertyHandler = (EAttributePropertyHandler) pa;
                eAttributePropertyHandler.setPersistenceOptions(ds.getPersistenceOptions());
                if (mappedProperty.getPersistentClass() != null) {
                    eAttributePropertyHandler.setId(
                            mappedProperty == mappedProperty.getPersistentClass().getIdentifierProperty());
                }
            }
            return pa;
        }
    }
}

From source file:org.eclipse.emf.teneo.hibernate.mapping.elist.FeatureMapEntryComponentTuplizer.java

License:Open Source License

protected PropertyAccessor getPropertyAccessor(Property mappedProperty, Component component) {
    final HbDataStore hds = HbHelper.INSTANCE.getDataStore(component.getOwner());
    if (mappedProperty.getMetaAttribute(HbMapperConstants.VERSION_META) != null) {
        return hds.getHbContext().createVersionAccessor();
    } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_FEATURE) == 0) {
        return hds.getHbContext().createFeatureMapEntryFeatureURIAccessor();
    } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_CDATA) == 0) {
        return hds.getHbContext().createFeatureMapEntryAccessor(Constants.CDATA);
    } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_COMMENT) == 0) {
        return hds.getHbContext().createFeatureMapEntryAccessor(Constants.COMMENT);
    } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_TEXT) == 0) {
        return hds.getHbContext().createFeatureMapEntryAccessor(Constants.TEXT);
    } else if (mappedProperty.getName().endsWith(HbMapperConstants.PROPERTY_ANY_PRIMITIVE)) {
        return hds.getExtensionManager().getExtension(WildCardAttributePropertyHandler.class);
    } else if (mappedProperty.getName().endsWith(HbMapperConstants.PROPERTY_ANY_REFERENCE)) {
        return hds.getExtensionManager().getExtension(WildCardReferencePropertyHandler.class);
    }/*from  www.j a v a2  s  .c o  m*/

    final MetaAttribute ma = component.getMetaAttribute(HbMapperConstants.FEATUREMAP_META);
    final String eclassUri = ma.getValue();
    final EClass eClass = hds.getEntityNameStrategy().toEClass(eclassUri);
    final EStructuralFeature efeature = StoreUtil.getEStructuralFeature(eClass, mappedProperty.getName());

    if (efeature == null) {
        throw new HbMapperException("Feature not found for property " + mappedProperty.getName());
    }

    if (log.isDebugEnabled()) {
        log.debug("Creating property accessor for " + mappedProperty.getName() + "/" + eclassUri + "/"
                + efeature.getName());
    }

    return hds.getHbContext().createFeatureMapEntryAccessor(efeature);
}

From source file:org.eclipse.emf.teneo.hibernate.mapping.elist.FeatureMapEntryTuplizer.java

License:Open Source License

/** Returns the correct accessor on the basis of the type of property */
@Override//from   ww w.ja v a 2 s .c  o m
protected PropertyAccessor getPropertyAccessor(Property mappedProperty, PersistentClass pc) {
    final HbDataStore hds = HbHelper.INSTANCE.getDataStore(pc);
    if (mappedProperty.getMetaAttribute(HbMapperConstants.VERSION_META) != null) {
        return hds.getHbContext().createVersionAccessor();
    } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_FEATURE) == 0) {
        return hds.getHbContext().createFeatureMapEntryFeatureURIAccessor();
    } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_CDATA) == 0) {
        return hds.getHbContext().createFeatureMapEntryAccessor(Constants.CDATA);
    } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_COMMENT) == 0) {
        return hds.getHbContext().createFeatureMapEntryAccessor(Constants.COMMENT);
    } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_TEXT) == 0) {
        return hds.getHbContext().createFeatureMapEntryAccessor(Constants.TEXT);
    } else if (mappedProperty.getName().endsWith(HbMapperConstants.PROPERTY_ANY_PRIMITIVE)) {
        return hds.getExtensionManager().getExtension(WildCardAttributePropertyHandler.class);
    } else if (mappedProperty.getName().endsWith(HbMapperConstants.PROPERTY_ANY_REFERENCE)) {
        return hds.getExtensionManager().getExtension(WildCardReferencePropertyHandler.class);
    }

    final String eclassUri = HbUtil.getEClassNameFromFeatureMapMeta(pc);
    final EClass eClass = hds.getEntityNameStrategy().toEClass(eclassUri);
    final EStructuralFeature efeature = StoreUtil.getEStructuralFeature(eClass, mappedProperty.getName());

    if (efeature == null) {
        throw new HbMapperException(
                "Feature not found for entity/property " + pc.getEntityName() + "/" + mappedProperty.getName());
    }

    if (log.isDebugEnabled()) {
        log.debug("Creating property accessor for " + mappedProperty.getName() + "/" + pc.getEntityName() + "/"
                + eclassUri + "/" + efeature.getName());
    }

    return hds.getHbContext().createFeatureMapEntryAccessor(efeature);
}

From source file:org.web4thejob.orm.MetaUtil.java

License:Open Source License

public static String getMetaAttribute(Property property, String name) {
    return property.getMetaAttribute(name).getValue();
}

From source file:org.web4thejob.orm.MetaUtil.java

License:Open Source License

public static boolean hasMetaAttribute(Property property, String name) {
    final MetaAttribute metaAttribute = property.getMetaAttribute(name);
    if (metaAttribute != null) {
        try {//from www. j a  va 2s .  com
            return metaAttribute.getValue() != null;
        } catch (final Exception e) {
            return false;
        }
    }
    return false;
}