diff options
author | mtaal | 2007-03-21 16:10:12 +0000 |
---|---|---|
committer | mtaal | 2007-03-21 16:10:12 +0000 |
commit | 2a6cb08cee8183de8ad80eab5889699fbfab3d84 (patch) | |
tree | 02a86b178236a409b3ff06be8073f5964e5deb64 | |
parent | 8f3446b0466968ac55be80261dc00394c4c4fb60 (diff) | |
download | org.eclipse.emf.teneo-2a6cb08cee8183de8ad80eab5889699fbfab3d84.tar.gz org.eclipse.emf.teneo-2a6cb08cee8183de8ad80eab5889699fbfab3d84.tar.xz org.eclipse.emf.teneo-2a6cb08cee8183de8ad80eab5889699fbfab3d84.zip |
[178471]build_200703211214
[176651]
[176710]
[178311]
[178461]
4 files changed, 173 insertions, 132 deletions
diff --git a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/mapper/AbstractProcessingContext.java b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/mapper/AbstractProcessingContext.java index 8b3469c88..e17b019de 100644 --- a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/mapper/AbstractProcessingContext.java +++ b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/mapper/AbstractProcessingContext.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: AbstractProcessingContext.java,v 1.3.2.1 2007/03/20 15:39:16 mtaal Exp $ + * $Id: AbstractProcessingContext.java,v 1.3.2.2 2007/03/21 16:10:13 mtaal Exp $ */ package org.eclipse.emf.teneo.annotations.mapper; @@ -32,6 +32,7 @@ import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEAttribute; import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEClass; import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEReference; import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature; +import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedModel; import org.eclipse.emf.teneo.annotations.pannotation.AssociationOverride; import org.eclipse.emf.teneo.annotations.pannotation.AttributeOverride; import org.eclipse.emf.teneo.annotations.pannotation.Column; @@ -40,7 +41,7 @@ import org.eclipse.emf.teneo.annotations.pannotation.Column; * ProcessingContext which handles attributes overrides. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.3.2.1 $ + * @version $Revision: 1.3.2.2 $ */ public class AbstractProcessingContext { @@ -128,57 +129,105 @@ public class AbstractProcessingContext { } /** - * Returns the flattened list of all features of the supertypes for which the features should be added to the - * mapping of the passed eclass. This is required to (more-or-less) support multiple inheritance scenarios. In the - * case of multiple inheritance the first supertype is the 'real' mapped supertype, the other types are treated as - * mappedsuperclasses. + * This method returns all inherited features which need to be added to the + * mapping of the aclass itself. The method makes a distinction makes a + * distinction between the first supertype (the first one in the list) and + * later ones. The features of the first type are only added to the mapping + * if the first type is a mappedsuperclass, in all other cases the features + * of the first type are not mapped in the aclass itself because they are + * inherited (the mapping describes the inheritance relation). For the other + * supertypes (located at index 1 and up in getESuperTypes) the features are + * mapped as properties in the class itself. */ - public List getMultipleInheritedFeatures(PAnnotatedEClass aClass) { + public List getInheritedFeatures( + PAnnotatedEClass aClass) { + // if no supertypes then there are no inherited features final EClass eclass = aClass.getAnnotatedEClass(); - // if one or less supertype then no multiple inheritance - if (eclass.getESuperTypes().size() <=1) { + if (eclass.getESuperTypes().size() == 0) { return new ArrayList(); } - - log.debug("Determining synthetic mapped features for " + aClass.getAnnotatedEClass().getName()); - final List mappedFeatures = new ArrayList(eclass.getEAllStructuralFeatures()); + log + .debug("Determining inherited features which are mapped locally for " + + aClass.getAnnotatedEClass().getName()); + final List inheritedFeatures = new ArrayList( + eclass.getEAllStructuralFeatures()); + + // remove all the features of the eclass itself + inheritedFeatures.removeAll(eclass.getEStructuralFeatures()); + + // check if the type has a supertype (a non-transient, non-mappedsuperclass, if so then + // remove all features inherited from the first supertype + // as this inheritance is done in the mapping file + if (aClass.getPaSuperEntity() != null) { + inheritedFeatures.removeAll(aClass.getPaSuperEntity().getAnnotatedEClass() + .getEAllStructuralFeatures()); + } - // remove all of our own features - mappedFeatures.removeAll(eclass.getEStructuralFeatures()); + // get all efeatures from direct mappedsuperclasses + // the id feature inherited from a direct mappedsuperclass should be + // maintained in other cases the id features are not mapped locally. + // The system can also ignore this and let the user be more carefull not + // to + // add id features here and there in the inheritance structure but this + // is + // more robust + removeIdFeatures(aClass, inheritedFeatures); + + // convert the result + final PAnnotatedModel paModel = aClass.getPaModel(); + final ArrayList result = new ArrayList(); + for (Iterator it = inheritedFeatures.iterator(); it.hasNext();) { + EStructuralFeature esf = (EStructuralFeature)it.next(); + result.add(paModel.getPAnnotated(esf)); + } - // remove all features inherited from the first supertype - // as this part is modeled in the hbm anyway - mappedFeatures.removeAll(((EClass)eclass.getESuperTypes().get(0)).getEAllStructuralFeatures()); - - // then remove all id features, these can not be used - final ArrayList toReturn = new ArrayList(); - for (Iterator it = mappedFeatures.iterator(); it.hasNext();) { - final EStructuralFeature esf = (EStructuralFeature) it.next(); - final PAnnotatedEStructuralFeature pef = aClass.getPaModel().getPAnnotated(esf); - if (!(pef instanceof PAnnotatedEAttribute) || ((PAnnotatedEAttribute) pef).getId() == null) { - toReturn.add(pef); + return result; + } + + /** Remove all id-features not inherited from a direct mapped superclass */ + private void removeIdFeatures(PAnnotatedEClass aClass, + List inheritedFeatures) { + // first get all the mapped superclasses + final ArrayList mappedSuperEClasses = new ArrayList(); + for (Iterator it = aClass.getAnnotatedEClass().getESuperTypes().iterator(); it.hasNext();) { + EClass superEClass = (EClass)it.next(); + final PAnnotatedEClass superPAClass = aClass.getPaModel() + .getPAnnotated(superEClass); + if (superPAClass != null + && superPAClass.getMappedSuperclass() != null) { + mappedSuperEClasses.add(superPAClass.getAnnotatedEClass()); } } - return toReturn; - } - /** Returns all mapped super classes */ - public List getMappedSuperClasses(PAnnotatedEClass entity) { - final List result = new ArrayList(); - for (Iterator it = entity.getAnnotatedEClass().getESuperTypes().iterator(); it.hasNext();) { - final EClass superEClass = (EClass) it.next(); - PAnnotatedEClass superPAClass = entity.getPaModel().getPAnnotated(superEClass); - if (superPAClass != null && superPAClass.getMappedSuperclass() != null) { - result.add(superPAClass); - // and add the mapped super classes of the mapped superclass - // note that only the unbroken chain of mappedsuperclasses is added to the result, if there - // is a non-mappedsuperclass in the inheritance then it stops there - // issue also identified by Douglas Bitting - result.addAll(getMappedSuperClasses(superPAClass)); + // now get all the efeatures of the mappedsuperclasses to prevent any id + // features from them being removed, only do that when the aclass does not + // have a real super type, in that case the id can be inherited from the + // mappedsuperclass + final ArrayList mappedSuperFeatures = new ArrayList(); + if (aClass.getPaSuperEntity() == null) { + for (Iterator it = mappedSuperEClasses.iterator(); it.hasNext();) { + final EClass mappedSuperEClass = (EClass)it.next(); + mappedSuperFeatures.removeAll(mappedSuperEClass + .getEAllStructuralFeatures()); + mappedSuperFeatures.addAll(mappedSuperEClass + .getEAllStructuralFeatures()); } } - return result; + // now remove all id features not coming from a direct mapped superclass + final ArrayList toRemove = new ArrayList(); + for (Iterator it = inheritedFeatures.iterator(); it.hasNext();) { + EStructuralFeature esf = (EStructuralFeature)it.next(); + final PAnnotatedEStructuralFeature pef = aClass.getPaModel() + .getPAnnotated(esf); + + if (pef instanceof PAnnotatedEAttribute + && ((PAnnotatedEAttribute) pef).getId() != null + && !mappedSuperFeatures.contains(esf)) { + toRemove.add(esf); + } + } + inheritedFeatures.removeAll(toRemove); } /** Returns true if the eclass only has mappedsuperclasses without id annotated property */ diff --git a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/PAnnotatedEClass.java b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/PAnnotatedEClass.java index 94d051e02..d65b76c0d 100644 --- a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/PAnnotatedEClass.java +++ b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/PAnnotatedEClass.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: PAnnotatedEClass.java,v 1.9 2007/02/08 23:12:33 mtaal Exp $ + * $Id: PAnnotatedEClass.java,v 1.8.2.1 2007/03/21 16:10:12 mtaal Exp $ */ package org.eclipse.emf.teneo.annotations.pamodel; @@ -10,8 +10,6 @@ import java.util.List; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.teneo.annotations.pannotation.AssociationOverride; -import org.eclipse.emf.teneo.annotations.pannotation.AttributeOverride; import org.eclipse.emf.teneo.annotations.pannotation.DiscriminatorColumn; import org.eclipse.emf.teneo.annotations.pannotation.DiscriminatorValue; import org.eclipse.emf.teneo.annotations.pannotation.Embeddable; @@ -20,8 +18,6 @@ import org.eclipse.emf.teneo.annotations.pannotation.IdClass; import org.eclipse.emf.teneo.annotations.pannotation.Inheritance; import org.eclipse.emf.teneo.annotations.pannotation.InheritanceType; import org.eclipse.emf.teneo.annotations.pannotation.MappedSuperclass; -import org.eclipse.emf.teneo.annotations.pannotation.PrimaryKeyJoinColumn; -import org.eclipse.emf.teneo.annotations.pannotation.SecondaryTable; import org.eclipse.emf.teneo.annotations.pannotation.Table; import org.eclipse.emf.teneo.annotations.pannotation.TableGenerator; @@ -133,7 +129,7 @@ public interface PAnnotatedEClass extends PAnnotatedEModelElement { * annotation="teneo/internal/PersistenceMapping ignore='true'" * @generated */ - EList<PAnnotatedEStructuralFeature> getPaEStructuralFeatures(); + EList getPaEStructuralFeatures(); /** * Returns the value of the '<em><b>Attribute Overrides</b></em>' containment reference list. @@ -150,7 +146,7 @@ public interface PAnnotatedEClass extends PAnnotatedEModelElement { * @model type="org.eclipse.emf.teneo.annotations.pannotation.AttributeOverride" containment="true" * @generated */ - EList<AttributeOverride> getAttributeOverrides(); + EList getAttributeOverrides(); /** * Returns the value of the '<em><b>Discriminator Column</b></em>' containment reference. @@ -344,7 +340,7 @@ public interface PAnnotatedEClass extends PAnnotatedEModelElement { * @model containment="true" * @generated */ - EList<PrimaryKeyJoinColumn> getPrimaryKeyJoinColumns(); + EList getPrimaryKeyJoinColumns(); /** * Returns the value of the '<em><b>Secondary Tables</b></em>' containment reference list. @@ -360,7 +356,7 @@ public interface PAnnotatedEClass extends PAnnotatedEModelElement { * @model type="org.eclipse.emf.teneo.annotations.pannotation.SecondaryTable" containment="true" * @generated */ - EList<SecondaryTable> getSecondaryTables(); + EList getSecondaryTables(); /** * Returns the value of the '<em><b>Table</b></em>' containment reference. @@ -427,13 +423,13 @@ public interface PAnnotatedEClass extends PAnnotatedEModelElement { * @model type="org.eclipse.emf.teneo.annotations.pannotation.AssociationOverride" containment="true" * @generated */ - EList<AssociationOverride> getAssociationOverrides(); + EList getAssociationOverrides(); /** * @return Returns the List of PAnnotatedEAttributes belonging to this PAnnotatedEClass for which an Id PAnnotation * is present. */ - List<PAnnotatedEStructuralFeature> getPaIdFeatures(); + List getPaIdAttributes(); /** Returns true if the eclass has an PAnnotatedEStructuralFeature with an id annotation */ boolean hasIdAnnotatedFeature(); @@ -445,7 +441,7 @@ public interface PAnnotatedEClass extends PAnnotatedEModelElement { * @return Returns the PAnnotatedEntity that is MappedSuperclass of this PAnnotatedEClass, <code>null</code> if it * has none. TODO support multiple mapped superclasses. */ - PAnnotatedEClass getPaMappedSuper(); + List getPaMappedSupers(); /** * @return Returns the PAnnotatedEntity that is a super entity of this PAnnotatedEClass, <code>null</code> if this diff --git a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/impl/PAnnotatedEClassImpl.java b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/impl/PAnnotatedEClassImpl.java index b1c2b4dfa..2bebc30a2 100644 --- a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/impl/PAnnotatedEClassImpl.java +++ b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/impl/PAnnotatedEClassImpl.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: PAnnotatedEClassImpl.java,v 1.11 2007/02/08 23:12:35 mtaal Exp $ + * $Id: PAnnotatedEClassImpl.java,v 1.10.2.1 2007/03/21 16:10:12 mtaal Exp $ */ package org.eclipse.emf.teneo.annotations.pamodel.impl; @@ -98,7 +98,7 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * @generated * @ordered */ - protected EList<PAnnotatedEStructuralFeature> paEStructuralFeatures = null; + protected EList paEStructuralFeatures = null; /** * The cached value of the '{@link #getAttributeOverrides() <em>Attribute Overrides</em>}' containment reference list. @@ -108,7 +108,7 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * @generated * @ordered */ - protected EList<AttributeOverride> attributeOverrides = null; + protected EList attributeOverrides = null; /** * The cached value of the '{@link #getDiscriminatorColumn() <em>Discriminator Column</em>}' containment reference. @@ -188,7 +188,7 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * @generated * @ordered */ - protected EList<PrimaryKeyJoinColumn> primaryKeyJoinColumns = null; + protected EList primaryKeyJoinColumns = null; /** * The cached value of the '{@link #getSecondaryTables() <em>Secondary Tables</em>}' containment reference list. @@ -198,7 +198,7 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * @generated * @ordered */ - protected EList<SecondaryTable> secondaryTables = null; + protected EList secondaryTables = null; /** * The cached value of the '{@link #getTable() <em>Table</em>}' containment reference. @@ -228,7 +228,7 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * @generated * @ordered */ - protected EList<AssociationOverride> associationOverrides = null; + protected EList associationOverrides = null; /** * <!-- begin-user-doc --> @@ -244,7 +244,6 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - @Override protected EClass eStaticClass() { return PamodelPackage.Literals.PANNOTATED_ECLASS; } @@ -343,9 +342,9 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - public EList<PAnnotatedEStructuralFeature> getPaEStructuralFeatures() { + public EList getPaEStructuralFeatures() { if (paEStructuralFeatures == null) { - paEStructuralFeatures = new EObjectContainmentWithInverseEList<PAnnotatedEStructuralFeature>(PAnnotatedEStructuralFeature.class, this, PamodelPackage.PANNOTATED_ECLASS__PA_ESTRUCTURAL_FEATURES, PamodelPackage.PANNOTATED_ESTRUCTURAL_FEATURE__PA_ECLASS); + paEStructuralFeatures = new EObjectContainmentWithInverseEList(PAnnotatedEStructuralFeature.class, this, PamodelPackage.PANNOTATED_ECLASS__PA_ESTRUCTURAL_FEATURES, PamodelPackage.PANNOTATED_ESTRUCTURAL_FEATURE__PA_ECLASS); } return paEStructuralFeatures; } @@ -355,9 +354,9 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - public EList<AttributeOverride> getAttributeOverrides() { + public EList getAttributeOverrides() { if (attributeOverrides == null) { - attributeOverrides = new EObjectContainmentEList<AttributeOverride>(AttributeOverride.class, this, PamodelPackage.PANNOTATED_ECLASS__ATTRIBUTE_OVERRIDES); + attributeOverrides = new EObjectContainmentEList(AttributeOverride.class, this, PamodelPackage.PANNOTATED_ECLASS__ATTRIBUTE_OVERRIDES); } return attributeOverrides; } @@ -668,9 +667,9 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - public EList<PrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() { + public EList getPrimaryKeyJoinColumns() { if (primaryKeyJoinColumns == null) { - primaryKeyJoinColumns = new EObjectContainmentEList<PrimaryKeyJoinColumn>(PrimaryKeyJoinColumn.class, this, PamodelPackage.PANNOTATED_ECLASS__PRIMARY_KEY_JOIN_COLUMNS); + primaryKeyJoinColumns = new EObjectContainmentEList(PrimaryKeyJoinColumn.class, this, PamodelPackage.PANNOTATED_ECLASS__PRIMARY_KEY_JOIN_COLUMNS); } return primaryKeyJoinColumns; } @@ -680,9 +679,9 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - public EList<SecondaryTable> getSecondaryTables() { + public EList getSecondaryTables() { if (secondaryTables == null) { - secondaryTables = new EObjectContainmentEList<SecondaryTable>(SecondaryTable.class, this, PamodelPackage.PANNOTATED_ECLASS__SECONDARY_TABLES); + secondaryTables = new EObjectContainmentEList(SecondaryTable.class, this, PamodelPackage.PANNOTATED_ECLASS__SECONDARY_TABLES); } return secondaryTables; } @@ -778,9 +777,9 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - public EList<AssociationOverride> getAssociationOverrides() { + public EList getAssociationOverrides() { if (associationOverrides == null) { - associationOverrides = new EObjectContainmentEList<AssociationOverride>(AssociationOverride.class, this, PamodelPackage.PANNOTATED_ECLASS__ASSOCIATION_OVERRIDES); + associationOverrides = new EObjectContainmentEList(AssociationOverride.class, this, PamodelPackage.PANNOTATED_ECLASS__ASSOCIATION_OVERRIDES); } return associationOverrides; } @@ -790,8 +789,6 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - @SuppressWarnings("unchecked") - @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case PamodelPackage.PANNOTATED_ECLASS__PA_EPACKAGE: @@ -799,7 +796,7 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements msgs = eBasicRemoveFromContainer(msgs); return basicSetPaEPackage((PAnnotatedEPackage)otherEnd, msgs); case PamodelPackage.PANNOTATED_ECLASS__PA_ESTRUCTURAL_FEATURES: - return ((InternalEList<InternalEObject>)(InternalEList<?>)getPaEStructuralFeatures()).basicAdd(otherEnd, msgs); + return ((InternalEList)getPaEStructuralFeatures()).basicAdd(otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } @@ -809,15 +806,14 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case PamodelPackage.PANNOTATED_ECLASS__PA_EPACKAGE: return basicSetPaEPackage(null, msgs); case PamodelPackage.PANNOTATED_ECLASS__PA_ESTRUCTURAL_FEATURES: - return ((InternalEList<?>)getPaEStructuralFeatures()).basicRemove(otherEnd, msgs); + return ((InternalEList)getPaEStructuralFeatures()).basicRemove(otherEnd, msgs); case PamodelPackage.PANNOTATED_ECLASS__ATTRIBUTE_OVERRIDES: - return ((InternalEList<?>)getAttributeOverrides()).basicRemove(otherEnd, msgs); + return ((InternalEList)getAttributeOverrides()).basicRemove(otherEnd, msgs); case PamodelPackage.PANNOTATED_ECLASS__DISCRIMINATOR_COLUMN: return basicSetDiscriminatorColumn(null, msgs); case PamodelPackage.PANNOTATED_ECLASS__DISCRIMINATOR_VALUE: @@ -833,15 +829,15 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements case PamodelPackage.PANNOTATED_ECLASS__INHERITANCE: return basicSetInheritance(null, msgs); case PamodelPackage.PANNOTATED_ECLASS__PRIMARY_KEY_JOIN_COLUMNS: - return ((InternalEList<?>)getPrimaryKeyJoinColumns()).basicRemove(otherEnd, msgs); + return ((InternalEList)getPrimaryKeyJoinColumns()).basicRemove(otherEnd, msgs); case PamodelPackage.PANNOTATED_ECLASS__SECONDARY_TABLES: - return ((InternalEList<?>)getSecondaryTables()).basicRemove(otherEnd, msgs); + return ((InternalEList)getSecondaryTables()).basicRemove(otherEnd, msgs); case PamodelPackage.PANNOTATED_ECLASS__TABLE: return basicSetTable(null, msgs); case PamodelPackage.PANNOTATED_ECLASS__TABLE_GENERATOR: return basicSetTableGenerator(null, msgs); case PamodelPackage.PANNOTATED_ECLASS__ASSOCIATION_OVERRIDES: - return ((InternalEList<?>)getAssociationOverrides()).basicRemove(otherEnd, msgs); + return ((InternalEList)getAssociationOverrides()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } @@ -851,7 +847,6 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID) { case PamodelPackage.PANNOTATED_ECLASS__PA_EPACKAGE: @@ -865,7 +860,6 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case PamodelPackage.PANNOTATED_ECLASS__PA_EPACKAGE: @@ -910,8 +904,6 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - @SuppressWarnings("unchecked") - @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case PamodelPackage.PANNOTATED_ECLASS__PA_EPACKAGE: @@ -922,11 +914,11 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements return; case PamodelPackage.PANNOTATED_ECLASS__PA_ESTRUCTURAL_FEATURES: getPaEStructuralFeatures().clear(); - getPaEStructuralFeatures().addAll((Collection<? extends PAnnotatedEStructuralFeature>)newValue); + getPaEStructuralFeatures().addAll((Collection)newValue); return; case PamodelPackage.PANNOTATED_ECLASS__ATTRIBUTE_OVERRIDES: getAttributeOverrides().clear(); - getAttributeOverrides().addAll((Collection<? extends AttributeOverride>)newValue); + getAttributeOverrides().addAll((Collection)newValue); return; case PamodelPackage.PANNOTATED_ECLASS__DISCRIMINATOR_COLUMN: setDiscriminatorColumn((DiscriminatorColumn)newValue); @@ -951,11 +943,11 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements return; case PamodelPackage.PANNOTATED_ECLASS__PRIMARY_KEY_JOIN_COLUMNS: getPrimaryKeyJoinColumns().clear(); - getPrimaryKeyJoinColumns().addAll((Collection<? extends PrimaryKeyJoinColumn>)newValue); + getPrimaryKeyJoinColumns().addAll((Collection)newValue); return; case PamodelPackage.PANNOTATED_ECLASS__SECONDARY_TABLES: getSecondaryTables().clear(); - getSecondaryTables().addAll((Collection<? extends SecondaryTable>)newValue); + getSecondaryTables().addAll((Collection)newValue); return; case PamodelPackage.PANNOTATED_ECLASS__TABLE: setTable((Table)newValue); @@ -965,7 +957,7 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements return; case PamodelPackage.PANNOTATED_ECLASS__ASSOCIATION_OVERRIDES: getAssociationOverrides().clear(); - getAssociationOverrides().addAll((Collection<? extends AssociationOverride>)newValue); + getAssociationOverrides().addAll((Collection)newValue); return; } super.eSet(featureID, newValue); @@ -976,7 +968,6 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - @Override public void eUnset(int featureID) { switch (featureID) { case PamodelPackage.PANNOTATED_ECLASS__PA_EPACKAGE: @@ -1036,7 +1027,6 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * <!-- end-user-doc --> * @generated */ - @Override public boolean eIsSet(int featureID) { switch (featureID) { case PamodelPackage.PANNOTATED_ECLASS__PA_EPACKAGE: @@ -1079,9 +1069,11 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements * @return true if the eclass or its ancestor has an PAnnotatedEStructuralFeature with an id annotation. */ public boolean hasIdAnnotatedFeature() { - if (!getPaIdFeatures().isEmpty()) return true; + if (!getPaIdAttributes().isEmpty()) return true; - for (EClass eSuper : getAnnotatedEClass().getEAllSuperTypes()) { + List eSupers = getAnnotatedEClass().getEAllSuperTypes(); + for (Iterator it = eSupers.iterator(); it.hasNext();) { + EClass eSuper = (EClass)it.next(); PAnnotatedEClass aClass = getPaModel().getPAnnotated(eSuper); if (aClass != null && aClass.hasIdAnnotatedFeature()) { return true; @@ -1092,7 +1084,9 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements /** Returns true if the eclass has an PAnnotatedEStructuralFeature with an version annotation */ public boolean hasVersionAnnotatedFeature() { - for (PAnnotatedEStructuralFeature aFeature : getPaEStructuralFeatures()) { + Iterator it = getPaEStructuralFeatures().iterator(); + while (it.hasNext()) { + PAnnotatedEStructuralFeature aFeature = (PAnnotatedEStructuralFeature)it.next(); if (aFeature instanceof PAnnotatedEAttribute) if (((PAnnotatedEAttribute) aFeature).getVersion() != null) return true; } @@ -1110,10 +1104,12 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements /** * {@inheritDoc} */ - public List<PAnnotatedEStructuralFeature> getPaIdFeatures() { + public List getPaIdAttributes() { // TODO cache this list - final List<PAnnotatedEStructuralFeature> attrs = new ArrayList<PAnnotatedEStructuralFeature>(); - for (PAnnotatedEStructuralFeature aFeature : getPaEStructuralFeatures()) { + List attrs = new ArrayList(); + Iterator it = getPaEStructuralFeatures().iterator(); + while (it.hasNext()) { + PAnnotatedEStructuralFeature aFeature = (PAnnotatedEStructuralFeature) it.next(); if (aFeature instanceof PAnnotatedEAttribute) { if (((PAnnotatedEAttribute) aFeature).getId() != null && ((PAnnotatedEAttribute) aFeature).getTransient() == null) { @@ -1132,19 +1128,19 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements /** * {@inheritDoc } */ - public PAnnotatedEClass getPaMappedSuper() { + public List getPaMappedSupers() { // TODO cache its MappedSuperClass PAnnotatedModel model = getPaModel(); - PAnnotatedEClass mappedSuper = null; + List mappedSupers = new ArrayList(); if (model != null && getAnnotatedEClass() != null) { - Iterator<EClass> i = getAnnotatedEClass().getESuperTypes().iterator(); - while (mappedSuper == null && i.hasNext()) { - PAnnotatedEClass x = model.getPAnnotated(i.next()); + Iterator i = getAnnotatedEClass().getESuperTypes().iterator(); + while (i.hasNext()) { + PAnnotatedEClass x = model.getPAnnotated((EClass) i.next()); if (x.getMappedSuperclass() != null) - mappedSuper = x; + mappedSupers.add(x); } } - return mappedSuper; + return mappedSupers; } /** @@ -1155,9 +1151,9 @@ public class PAnnotatedEClassImpl extends PAnnotatedEModelElementImpl implements PAnnotatedModel model = getPaModel(); PAnnotatedEClass superEntity = null; if (model != null && getAnnotatedEClass() != null) { - Iterator<EClass> i = getAnnotatedEClass().getESuperTypes().iterator(); + Iterator i = getAnnotatedEClass().getESuperTypes().iterator(); while (superEntity == null && i.hasNext()) { - PAnnotatedEClass x = model.getPAnnotated(i.next()); + PAnnotatedEClass x = model.getPAnnotated((EClass) i.next()); if (x.getEntity() != null) superEntity = x; } diff --git a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/util/PamodelValidator.java b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/util/PamodelValidator.java index 950e3427b..e91cc7dd5 100644 --- a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/util/PamodelValidator.java +++ b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pamodel/util/PamodelValidator.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: PamodelValidator.java,v 1.13.2.1 2007/02/11 20:44:01 mtaal Exp $ + * $Id: PamodelValidator.java,v 1.13.2.2 2007/03/21 16:10:13 mtaal Exp $ */ package org.eclipse.emf.teneo.annotations.pamodel.util; @@ -412,32 +412,32 @@ public class PamodelValidator extends EObjectValidator { return false; } // it is an entity with id, check it does not have a mapped superclass that has id - PAnnotatedEClass paMappedSuper = pAnnotatedEClass.getPaMappedSuper(); - if (paMappedSuper != null && paMappedSuper.hasIdAnnotatedFeature()) { - if (diagnostics != null) { - diagnostics.add - (new BasicDiagnostic - (Diagnostic.ERROR, - DIAGNOSTIC_SOURCE, - 0, - EcorePlugin.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "ProperPrimaryKey", getObjectLabel(pAnnotatedEClass, context) }), - new Object[] { pAnnotatedEClass })); - } - return false; - } - // check that it is a root entity - if (paMappedSuper.getPaSuperEntity() != null) { - if (diagnostics != null) { - diagnostics.add - (new BasicDiagnostic - (Diagnostic.ERROR, - DIAGNOSTIC_SOURCE, - 0, - EcorePlugin.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "ProperPrimaryKey", getObjectLabel(pAnnotatedEClass, context) }), - new Object[] { pAnnotatedEClass })); - } - return false; - } +// PAnnotatedEClass paMappedSuper = pAnnotatedEClass.getPaMappedSuper(); +// if (paMappedSuper != null && paMappedSuper.hasIdAnnotatedFeature()) { +// if (diagnostics != null) { +// diagnostics.add +// (new BasicDiagnostic +// (Diagnostic.ERROR, +// DIAGNOSTIC_SOURCE, +// 0, +// EcorePlugin.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "ProperPrimaryKey", getObjectLabel(pAnnotatedEClass, context) }), +// new Object[] { pAnnotatedEClass })); +// } +// return false; +// } +// // check that it is a root entity +// if (paMappedSuper.getPaSuperEntity() != null) { +// if (diagnostics != null) { +// diagnostics.add +// (new BasicDiagnostic +// (Diagnostic.ERROR, +// DIAGNOSTIC_SOURCE, +// 0, +// EcorePlugin.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "ProperPrimaryKey", getObjectLabel(pAnnotatedEClass, context) }), +// new Object[] { pAnnotatedEClass })); +// } +// return false; +// } return true; } |