diff options
author | Martin Taal | 2012-11-06 07:54:06 +0000 |
---|---|---|
committer | Martin Taal | 2012-11-06 07:54:06 +0000 |
commit | 597318e3b767d7ffb0152b6b660e78838564e4b3 (patch) | |
tree | eae36fdb4a8b59598dc430cb014b4225a02f87c2 /hibernate/org.eclipse.emf.teneo.hibernate | |
parent | e9327a08d54a31aed4ca12c5dea4c88a80839ea5 (diff) | |
download | org.eclipse.emf.teneo-597318e3b767d7ffb0152b6b660e78838564e4b3.tar.gz org.eclipse.emf.teneo-597318e3b767d7ffb0152b6b660e78838564e4b3.tar.xz org.eclipse.emf.teneo-597318e3b767d7ffb0152b6b660e78838564e4b3.zip |
Improved entityname/eclass handling
Diffstat (limited to 'hibernate/org.eclipse.emf.teneo.hibernate')
13 files changed, 121 insertions, 60 deletions
diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbBaseSessionDataStore.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbBaseSessionDataStore.java index 777b666cc..58994f7bd 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbBaseSessionDataStore.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbBaseSessionDataStore.java @@ -80,9 +80,9 @@ public abstract class HbBaseSessionDataStore extends HbDataStore implements Sess if (sessionFactory != null && !sessionFactory.isClosed()) { sessionFactory.close(); sessionFactory = null; - // do set initialized false after closing it - setInitialized(false); } + // do set initialized false after closing it + setInitialized(false); } /** diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbDataStore.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbDataStore.java index 3369eaf41..740c2fe4b 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbDataStore.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbDataStore.java @@ -168,9 +168,6 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { /** The properties used to create the hibernate configuration object */ private PersistenceOptions persistenceOptions; - /** The properties */ - private Properties properties = new Properties(); - /** The interceptor */ private Interceptor interceptor; @@ -185,6 +182,10 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { /** the entitynamestrategy is read from the extensionManager */ private EntityNameStrategy entityNameStrategy; + private Map<String, EClass> entityNameToEClass; + + private Map<EClass, String> eClassToEntityName; + private EMFEntityNameResolver entityNameResolver; private Map<EClass, EStructuralFeature> idFeatureByEClass = null; @@ -219,11 +220,11 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { } public String toEntityName(EClass eClass) { - return getEntityNameStrategy().toEntityName(eClass); + return eClassToEntityName.get(eClass); } public EClass toEClass(String entityName) { - return getEntityNameStrategy().toEClass(entityName); + return entityNameToEClass.get(entityName); } /** @@ -354,6 +355,8 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { // is set in the List properties. buildMappings(); + computeEntityToEClass(); + entityNameStrategy = null; // create a new one getEntityNameStrategy(); @@ -392,6 +395,30 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { EModelResolver.instance().registerOwnerShip(this, getEPackages()); } + protected void computeEntityToEClass() { + entityNameToEClass = new HashMap<String, EClass>(); + eClassToEntityName = new HashMap<EClass, String>(); + + for (Iterator<?> pcs = getClassMappings(); pcs.hasNext();) { + final PersistentClass pc = (PersistentClass) pcs.next(); + if (pc.getEntityName() != null) { + EClass eClass = HbUtil.getEClassFromMeta(getPackageRegistry(), pc); + if (eClass == null) { + eClass = getEntityNameStrategy().toEClass(pc.getEntityName()); + } + if (eClass != null && !eClassToEntityName.containsKey(eClass)) { + entityNameToEClass.put(pc.getEntityName(), eClass); + eClassToEntityName.put(eClass, pc.getEntityName()); + } + } + } + } + + public void addEntityNameEClassMapping(String entityName, EClass eClass) { + entityNameToEClass.put(entityName, eClass); + eClassToEntityName.put(eClass, entityName); + } + /** Build the mappings in the configuration */ protected abstract void buildMappings(); @@ -458,7 +485,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { */ @Deprecated public Properties getHibernateProperties() { - return properties; + return getPersistenceOptions().getProperties(); } /** @@ -474,7 +501,9 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { */ @Deprecated public void setHibernateProperties(Properties hibernateProperties) { - this.properties = hibernateProperties; + final Properties props = getPersistenceOptions().getProperties(); + props.putAll(hibernateProperties); + this.setDataStoreProperties(props); } /** @@ -489,7 +518,6 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { public void setDataStoreProperties(Properties props) { this.persistenceOptions = getExtensionManager().getExtension(PersistenceOptions.class, new Object[] { props }); - this.properties = props; } protected void setDefaultProperties(Properties properties) { @@ -511,10 +539,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { * properties */ public Properties getDataStoreProperties() { - final Properties props = new Properties(); - props.putAll(properties); - props.putAll(getPersistenceOptions().getProperties()); - return props; + return getPersistenceOptions().getProperties(); } /** Get the session factory */ @@ -583,7 +608,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { String targetEntityName = null; if (referedTo instanceof EObject) { final EObject eReferedTo = (EObject) referedTo; - targetEntityName = getEntityNameStrategy().toEntityName(eReferedTo.eClass()); + targetEntityName = toEntityName(eReferedTo.eClass()); } else if (referedTo instanceof HibernateFeatureMapEntry) { final HibernateFeatureMapEntry fme = (HibernateFeatureMapEntry) referedTo; targetEntityName = fme.getEntityName(getEntityNameStrategy()); @@ -656,7 +681,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { final EClass eclass; if (pc.getEntityName() != null) { - eclass = getEntityNameStrategy().toEClass(pc.getEntityName()); + eclass = toEClass(pc.getEntityName()); } else { eclass = EModelResolver.instance().getEClass(pc.getMappedClass()); } @@ -735,7 +760,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { EClass eClass = null; if (pc.getMetaAttribute(HbMapperConstants.FEATUREMAP_META) == null) { if (pc.getEntityName() != null) { - eClass = getEntityNameStrategy().toEClass(pc.getEntityName()); + eClass = toEClass(pc.getEntityName()); } else { eClass = EModelResolver.instance().getEClass(pc.getMappedClass()); } @@ -911,13 +936,16 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { protected void setTuplizer() { for (Iterator<?> pcs = getClassMappings(); pcs.hasNext();) { final PersistentClass pc = (PersistentClass) pcs.next(); + if (pc.getTuplizerMap() != null) { + continue; + } + if (pc.getMetaAttribute(HbMapperConstants.FEATUREMAP_META) != null) { // featuremap // entry pc.addTuplizer(EntityMode.MAP, getHbContext().getFeatureMapEntryTuplizer(getHibernateConfiguration()).getName()); } else if (pc.getMetaAttribute(HbMapperConstants.ECLASS_NAME_META) != null) { // only the pc's with this meta should get a tuplizer - pc.addTuplizer(EntityMode.MAP, getHbContext().getEMFTuplizerClass(getHibernateConfiguration()).getName()); pc.addTuplizer(EntityMode.POJO, @@ -970,7 +998,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { // todo: change recognizing a component to using metadata! EClass eClass = ERuntime.INSTANCE.getEClass(component.getComponentClass()); if (eClass == null) { - eClass = getEntityNameStrategy().toEClass(component.getComponentClassName()); + eClass = toEClass(component.getComponentClassName()); } if (eClass != null) { if (log.isDebugEnabled()) { @@ -995,7 +1023,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { private boolean isContained(PersistentClass pc) { final EClass eclass; if (pc.getEntityName() != null) { - eclass = getEntityNameStrategy().toEClass(pc.getEntityName()); + eclass = toEClass(pc.getEntityName()); } else { eclass = EModelResolver.instance().getEClass(pc.getMappedClass()); } @@ -1046,6 +1074,8 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { hmg.setPersistenceOptions(po); final String hbm = hmg.generateToString(getPaModel()); + // System.err.println(hbm); + if (log.isDebugEnabled()) { log.debug("Computing id types of mapped EClasses"); } @@ -1177,7 +1207,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { final EClass eclass; if (pc.getEntityName() != null) { - eclass = getEntityNameStrategy().toEClass(pc.getEntityName()); + eclass = toEClass(pc.getEntityName()); } else { eclass = EModelResolver.instance().getEClass(pc.getMappedClass()); } @@ -1375,7 +1405,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { final PersistentClass pc = (PersistentClass) it.next(); EClass eClass; if (pc.getEntityName() != null) { - eClass = getEntityNameStrategy().toEClass(pc.getEntityName()); + eClass = toEClass(pc.getEntityName()); if (eClass != null) { EAnnotation eAnnotation = eClass.getEAnnotation(Constants.ANNOTATION_SOURCE_TENEO_JPA); if (eAnnotation == null) { @@ -1433,7 +1463,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { EClass eClass = null; if (pc.getMetaAttribute(HbMapperConstants.FEATUREMAP_META) == null) { if (pc.getEntityName() != null) { - eClass = getEntityNameStrategy().toEClass(pc.getEntityName()); + eClass = toEClass(pc.getEntityName()); } else { eClass = EModelResolver.instance().getEClass(pc.getMappedClass()); } @@ -1510,8 +1540,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { // prop.getCascadeStyle() // == // CascadeStyle.ALL; - toEntity = getEntityNameStrategy().toEntityName( - ((EReference) ef).getEReferenceType()); + toEntity = toEntityName(((EReference) ef).getEReferenceType()); } else if (ef instanceof EAttribute && ef.getEType() instanceof EClass) { // TODO // can // this @@ -1520,7 +1549,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { isContainer = true; // prop.getCascadeStyle().hasOrphanDelete() // || prop.getCascadeStyle() // == CascadeStyle.ALL; - toEntity = getEntityNameStrategy().toEntityName((EClass) ef.getEType()); + toEntity = toEntityName((EClass) ef.getEType()); } // filter out non eobjects else { @@ -1531,6 +1560,9 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { continue; } + if (toEntity == null) { + continue; + } java.util.List<ReferenceTo> list = result.get(toEntity); if (list == null) { list = new ArrayList<ReferenceTo>(); @@ -1571,11 +1603,10 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { */ private java.util.List<ReferenceTo> setRefersToOfSupers(String eClassUri, HashMap<String, java.util.List<ReferenceTo>> refersTo, ArrayList<EClass> classDone) { - final EntityNameStrategy ens = getEntityNameStrategy(); EClass eclass; // eclass = null when the refered to eclass is not mapped // because it is is embeddable - eclass = ens.toEClass(eClassUri); + eclass = toEClass(eClassUri); if (eclass == null) { return new ArrayList<ReferenceTo>(); } @@ -1584,12 +1615,12 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { return refersTo.get(eClassUri); } - final java.util.List<ReferenceTo> thisList = refersTo.get(ens.toEntityName(eclass)); + final java.util.List<ReferenceTo> thisList = refersTo.get(toEntityName(eclass)); if (thisList == null) { return new ArrayList<ReferenceTo>(); } for (EClass class1 : eclass.getESuperTypes()) { - String eclassUri = ens.toEntityName(class1); + String eclassUri = toEntityName(class1); addUnique(thisList, setRefersToOfSupers(eclassUri, refersTo, classDone)); } classDone.add(eclass); @@ -1711,7 +1742,7 @@ public abstract class HbDataStore implements DataStore, AuditDataStore { public EntityNameResolver getEntityNameResolver() { if (entityNameResolver == null) { entityNameResolver = getExtensionManager().getExtension(EMFEntityNameResolver.class); - entityNameResolver.setQualifyStrategy(getEntityNameStrategy()); + entityNameResolver.setDataStore(this); } return entityNameResolver; } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbUtil.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbUtil.java index a8afece0e..322fbd277 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbUtil.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/HbUtil.java @@ -101,6 +101,25 @@ public class HbUtil { return (EClass) epackage.getEClassifier(eClassMetaAttribute.getValue()); } + public static EClass getEClassFromMeta(EPackage.Registry registry, PersistentClass persistentClass) { + final MetaAttribute ePackageMetaAttribute = persistentClass + .getMetaAttribute(HbMapperConstants.EPACKAGE_PARAM); + if (ePackageMetaAttribute == null) { + return null; + } + final EPackage epackage = registry.getEPackage(ePackageMetaAttribute.getValue()); + if (epackage == null) { + throw new IllegalArgumentException("Could not find ePackage using nsuri " + + ePackageMetaAttribute.getValue()); + } + final MetaAttribute eClassMetaAttribute = persistentClass + .getMetaAttribute(HbMapperConstants.ECLASS_NAME_META); + if (eClassMetaAttribute == null) { + return null; + } + return (EClass) epackage.getEClassifier(eClassMetaAttribute.getValue()); + } + /** * A merge method which does not use Session.merge but uses the EMF api to travers object * references and execute merge through the object tree. The merge will traverse all EReferences. @@ -171,7 +190,7 @@ public class HbUtil { /** Encode the id of an eobject */ @SuppressWarnings("unchecked") public static String idToString(EObject eobj, HbDataStore hd, Session session) { - final PersistentClass pc = hd.getPersistentClass(hd.getEntityNameStrategy().toEntityName( + final PersistentClass pc = hd.getPersistentClass(hd.toEntityName( eobj.eClass())); if (pc == null) { // can happen with map entries return null; @@ -201,7 +220,7 @@ public class HbUtil { @SuppressWarnings("unchecked") public static Object stringToId(EClass eclass, HbDataStore hd, String id) { try { - final PersistentClass pc = hd.getPersistentClass(hd.getEntityNameStrategy().toEntityName( + final PersistentClass pc = hd.getPersistentClass(hd.toEntityName( eclass)); final Type t = pc.getIdentifierProperty().getType(); if (t instanceof IdentifierType) { @@ -247,7 +266,7 @@ public class HbUtil { if (mappedEClass != null) { eClass = mappedEClass; } else { - eClass = ds.getEntityNameStrategy().toEClass(entityName); + eClass = ds.toEClass(entityName); if (eClass == null) { // for components this is the case eClass = ERuntime.INSTANCE.getEClass(entityName); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditDataStore.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditDataStore.java index 498379786..4ce3f6341 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditDataStore.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditDataStore.java @@ -15,9 +15,11 @@ */ package org.eclipse.emf.teneo.hibernate.auditing; +import java.util.Properties; + import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.teneo.PersistenceOptions; +import org.eclipse.emf.teneo.hibernate.HbContext; import org.hibernate.SessionFactory; /** @@ -26,6 +28,7 @@ import org.hibernate.SessionFactory; * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> */ public interface AuditDataStore { + public HbContext getHbContext(); public AuditHandler getAuditHandler(); @@ -37,7 +40,7 @@ public interface AuditDataStore { public EPackage.Registry getPackageRegistry(); - public PersistenceOptions getPersistenceOptions(); + public Properties getDataStoreProperties(); public boolean isAuditing(); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditProcessHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditProcessHandler.java index d1059dd65..f5ad29656 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditProcessHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditProcessHandler.java @@ -360,8 +360,10 @@ public class AuditProcessHandler implements AfterTransactionCompletionProcess, public void setDataStore(AuditDataStore dataStore) { this.dataStore = dataStore; - pruneTime = 1000 * 3600 * 24 * dataStore.getPersistenceOptions().getAuditingPruneDays(); - pruneInterval = dataStore.getPersistenceOptions().getAuditingPruneCommitInterval(); + pruneTime = 1000 * 3600 * 24 * Long.parseLong(dataStore.getDataStoreProperties().getProperty( + PersistenceOptions.AUDITING_PRUNE_OLD_ENTRIES_DAYS)); + pruneInterval = Long.parseLong(dataStore.getDataStoreProperties().getProperty( + PersistenceOptions.AUDITING_PRUNE_COMMIT_INTERVAL)); } private synchronized void pruneEntries(SessionImplementor session) { diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVObjectTuplizer.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVObjectTuplizer.java index 02758cd91..9b16945fb 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVObjectTuplizer.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVObjectTuplizer.java @@ -164,7 +164,7 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { return null; } final HbDataStore ds = HbHelper.INSTANCE.getDataStore(persistentClass); - final EClass eclass = ds.getEntityNameStrategy().toEClass(persistentClass.getEntityName()); + final EClass eclass = ds.toEClass(persistentClass.getEntityName()); if (eclass == null) { throw new HbMapperException("No eclass found for entityname: " + persistentClass.getEntityName()); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryComponentTuplizer.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryComponentTuplizer.java index f525ad06f..52ea24b55 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryComponentTuplizer.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryComponentTuplizer.java @@ -89,7 +89,7 @@ public class FeatureMapEntryComponentTuplizer extends AbstractComponentTuplizer final MetaAttribute ma = component.getMetaAttribute(HbMapperConstants.FEATUREMAP_META); final String eclassUri = ma.getValue(); - final EClass eClass = hds.getEntityNameStrategy().toEClass(eclassUri); + final EClass eClass = hds.toEClass(eclassUri); final EStructuralFeature efeature = StoreUtil.getEStructuralFeature(eClass, mappedProperty.getName()); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryTuplizer.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryTuplizer.java index 268df8653..d0b26ab9d 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryTuplizer.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryTuplizer.java @@ -103,7 +103,7 @@ public class FeatureMapEntryTuplizer extends EMFTuplizer { } final String eclassUri = HbUtil.getEClassNameFromFeatureMapMeta(pc); - final EClass eClass = hds.getEntityNameStrategy().toEClass(eclassUri); + final EClass eClass = hds.toEClass(eclassUri); final EStructuralFeature efeature = StoreUtil.getEStructuralFeature(eClass, mappedProperty.getName()); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierUtil.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierUtil.java index 0c9e6abae..26579ba47 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierUtil.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierUtil.java @@ -125,7 +125,7 @@ public class IdentifierUtil { /** Returns the id of the passed object */ public static Serializable getID(EObject eobj, HbDataStore hd, SessionImplementor session) { - final String entityName = hd.getEntityNameStrategy().toEntityName(eobj.eClass()); + final String entityName = hd.toEntityName(eobj.eClass()); final EntityPersister entityPersister = ((SessionFactoryImpl) hd.getSessionFactory()) .getEntityPersister(entityName); return entityPersister.getIdentifier(eobj, session); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/resource/HibernateResource.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/resource/HibernateResource.java index 96fd3539c..945dbe0ae 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/resource/HibernateResource.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/resource/HibernateResource.java @@ -229,7 +229,7 @@ public class HibernateResource extends StoreResource implements HbResource { } // build a query - final EClass eclass = emfDataStore.getEntityNameStrategy().toEClass(parts[0]); + final EClass eclass = emfDataStore.toEClass(parts[0]); final int splitIndex = parts[1].indexOf("="); if (splitIndex == -1) { if (log.isDebugEnabled()) { @@ -301,7 +301,7 @@ public class HibernateResource extends StoreResource implements HbResource { return super.getURIFragment(object); } final StringBuffer idStr = new StringBuffer(); - idStr.append(emfDataStore.getEntityNameStrategy().toEntityName(object.eClass())); + idStr.append(emfDataStore.toEntityName(object.eClass())); idStr.append(SEPARATOR); idStr.append("id=" + theId); return idStr.toString(); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFComponentTuplizer.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFComponentTuplizer.java index 3f66ae5b9..87849e8ee 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFComponentTuplizer.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFComponentTuplizer.java @@ -58,7 +58,7 @@ public class EMFComponentTuplizer extends AbstractComponentTuplizer { private EClass getEClass(Component component) { if (eClass == null) { final HbDataStore ds = HbHelper.INSTANCE.getDataStore(component); - eClass = ds.getEntityNameStrategy().toEClass(component.getComponentClassName()); + eClass = ds.toEClass(component.getComponentClassName()); if (eClass == null) { eClass = ERuntime.INSTANCE.getEClass(component.getComponentClass()); } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFEntityNameResolver.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFEntityNameResolver.java index 1b617702b..0f2b70978 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFEntityNameResolver.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFEntityNameResolver.java @@ -18,7 +18,7 @@ package org.eclipse.emf.teneo.hibernate.tuplizer; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.teneo.extension.ExtensionPoint; -import org.eclipse.emf.teneo.mapping.strategy.EntityNameStrategy; +import org.eclipse.emf.teneo.hibernate.HbDataStore; import org.hibernate.EntityNameResolver; /** @@ -30,16 +30,7 @@ import org.hibernate.EntityNameResolver; public class EMFEntityNameResolver implements ExtensionPoint, EntityNameResolver { - /** The qualify property used to compute the eclassname */ - private EntityNameStrategy qualifyStrategy; - - public EntityNameStrategy getQualifyStrategy() { - return qualifyStrategy; - } - - public void setQualifyStrategy(EntityNameStrategy qualifyStrategy) { - this.qualifyStrategy = qualifyStrategy; - } + private HbDataStore dataStore; /* * @see org.hibernate.EntityNameResolver#resolveEntityName(java.lang.Object) @@ -48,8 +39,23 @@ public class EMFEntityNameResolver implements ExtensionPoint, EntityNameResolver if (entity instanceof EObject) { // TODO handle featuremap EObject eobj = (EObject) entity; - return qualifyStrategy.toEntityName(eobj.eClass()); + return dataStore.toEntityName(eobj.eClass()); } return null; } + + /** + * @return the dataStore + */ + public HbDataStore getDataStore() { + return dataStore; + } + + /** + * @param dataStore + * the dataStore to set + */ + public void setDataStore(HbDataStore dataStore) { + this.dataStore = dataStore; + } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFTuplizer.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFTuplizer.java index a7c8e2837..7e3331244 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFTuplizer.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/tuplizer/EMFTuplizer.java @@ -119,7 +119,7 @@ public class EMFTuplizer extends AbstractEntityTuplizer { if (entityInstance instanceof EObject) { EObject instance = (EObject) entityInstance; final HbDataStore ds = HbHelper.INSTANCE.getDataStore(persistentClass); - return ds.getEntityNameStrategy().toEntityName(instance.eClass()); + return ds.toEntityName(instance.eClass()); } final Class<?> concreteEntityClass = entityInstance.getClass(); @@ -175,7 +175,7 @@ public class EMFTuplizer extends AbstractEntityTuplizer { return new EAVInstantiator(); } final HbDataStore ds = HbHelper.INSTANCE.getDataStore(persistentClass); - final EClass eclass = ds.getEntityNameStrategy().toEClass(persistentClass.getEntityName()); + final EClass eclass = ds.toEClass(persistentClass.getEntityName()); if (eclass == null) { throw new HbMapperException("No eclass found for entityname: " + persistentClass.getEntityName()); @@ -240,7 +240,7 @@ public class EMFTuplizer extends AbstractEntityTuplizer { } final HbDataStore ds = HbHelper.INSTANCE.getDataStore(persistentClass); - final EClass eclass = ds.getEntityNameStrategy().toEClass(persistentClass.getEntityName()); + final EClass eclass = ds.toEClass(persistentClass.getEntityName()); if (eclass == null && !persistentClass.getEntityName().equals(Constants.EAV_EOBJECT_ENTITY_NAME)) { throw new HbMapperException("No eclass found for entityname: " |