Example usage for org.hibernate.mapping Component getMetaAttribute

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

Introduction

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

Prototype

@Override
    public MetaAttribute getMetaAttribute(String attributeName) 

Source Link

Usage

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

License:Open Source License

public static EClass getEClassFromMeta(Component component) {
    final MetaAttribute ePackageMetaAttribute = component.getMetaAttribute(HbMapperConstants.EPACKAGE_PARAM);
    if (ePackageMetaAttribute == null) {
        return null;
    }//from  www  . j  av  a 2  s  .  c  o m
    final EPackage epackage = PackageRegistryProvider.getInstance().getPackageRegistry()
            .getEPackage(ePackageMetaAttribute.getValue());
    if (epackage == null) {
        throw new IllegalArgumentException(
                "Could not find ePackage using nsuri " + ePackageMetaAttribute.getValue());
    }
    final MetaAttribute eClassMetaAttribute = component.getMetaAttribute(HbMapperConstants.ECLASS_NAME_META);
    if (eClassMetaAttribute == null) {
        return null;
    }
    return (EClass) epackage.getEClassifier(eClassMetaAttribute.getValue());
}

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);
    }// ww  w  . j av a 2  s .com

    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);
}