Skip to content

Commit

Permalink
[588] Add support for multiple inheritance for domains
Browse files Browse the repository at this point in the history
Bug: #588
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
  • Loading branch information
pcdavid authored and sbegaudeau committed Aug 6, 2021
1 parent be2fda9 commit 212919d
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</style>
</conditionnalStyles>
</edgeMappings>
<edgeMappings name="Inheritance" sourceMapping="//@ownedViewpoints[name='Domain']/@ownedRepresentations[name='Domain']/@defaultLayer/@containerMappings[name='Entity']" targetMapping="//@ownedViewpoints[name='Domain']/@ownedRepresentations[name='Domain']/@defaultLayer/@containerMappings[name='Entity']" targetFinderExpression="feature:superType">
<edgeMappings name="Inheritance" sourceMapping="//@ownedViewpoints[name='Domain']/@ownedRepresentations[name='Domain']/@defaultLayer/@containerMappings[name='Entity']" targetMapping="//@ownedViewpoints[name='Domain']/@ownedRepresentations[name='Domain']/@defaultLayer/@containerMappings[name='Entity']" targetFinderExpression="feature:superTypes">
<style strokeColor="//@userColorsPalettes[name='Sirius%20Web']/@entries[name='grey%2Fgrey-600']" targetArrow="InputClosedArrow" routingStyle="manhattan">
<centerLabelStyleDescription labelSize="12" showIcon="false">
<labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
if (this.itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);

this.addSuperTypePropertyDescriptor(object);
this.addSuperTypesPropertyDescriptor(object);
this.addAbstractPropertyDescriptor(object);
}
return this.itemPropertyDescriptors;
}

/**
* This adds a property descriptor for the Super Type feature. <!-- begin-user-doc --> <!-- end-user-doc -->
* This adds a property descriptor for the Super Types feature. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected void addSuperTypePropertyDescriptor(Object object) {
protected void addSuperTypesPropertyDescriptor(Object object) {
this.itemPropertyDescriptors.add(
this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_Entity_superType_feature"), //$NON-NLS-1$
this.getString("_UI_PropertyDescriptor_description", "_UI_Entity_superType_feature", "_UI_Entity_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DomainPackage.Literals.ENTITY__SUPER_TYPE, true, false, true, null, null, null));
this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_Entity_superTypes_feature"), //$NON-NLS-1$
this.getString("_UI_PropertyDescriptor_description", "_UI_Entity_superTypes_feature", "_UI_Entity_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DomainPackage.Literals.ENTITY__SUPER_TYPES, true, false, true, null, null, null));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _UI_Domain_uri_feature = Uri
_UI_Domain_types_feature = Types
_UI_Entity_attributes_feature = Attributes
_UI_Entity_relations_feature = Relations
_UI_Entity_superType_feature = Super Type
_UI_Entity_superTypes_feature = Super Types
_UI_Entity_abstract_feature = Abstract
_UI_Feature_optional_feature = Optional
_UI_Feature_many_feature = Many
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,13 @@ public interface DomainPackage extends EPackage {
int ENTITY__RELATIONS = NAMED_ELEMENT_FEATURE_COUNT + 1;

/**
* The feature id for the '<em><b>Super Type</b></em>' reference. <!-- begin-user-doc --> <!-- end-user-doc -->
* The feature id for the '<em><b>Super Types</b></em>' reference list. <!-- begin-user-doc --> <!-- end-user-doc
* -->
*
* @generated
* @ordered
*/
int ENTITY__SUPER_TYPE = NAMED_ELEMENT_FEATURE_COUNT + 2;
int ENTITY__SUPER_TYPES = NAMED_ELEMENT_FEATURE_COUNT + 2;

/**
* The feature id for the '<em><b>Abstract</b></em>' attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
Expand Down Expand Up @@ -489,15 +490,15 @@ public interface DomainPackage extends EPackage {
EReference getEntity_Relations();

/**
* Returns the meta object for the reference '{@link org.eclipse.sirius.web.domain.Entity#getSuperType <em>Super
* Type</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
* Returns the meta object for the reference list '{@link org.eclipse.sirius.web.domain.Entity#getSuperTypes
* <em>Super Types</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @return the meta object for the reference '<em>Super Type</em>'.
* @see org.eclipse.sirius.web.domain.Entity#getSuperType()
* @return the meta object for the reference list '<em>Super Types</em>'.
* @see org.eclipse.sirius.web.domain.Entity#getSuperTypes()
* @see #getEntity()
* @generated
*/
EReference getEntity_SuperType();
EReference getEntity_SuperTypes();

/**
* Returns the meta object for the attribute '{@link org.eclipse.sirius.web.domain.Entity#isAbstract
Expand Down Expand Up @@ -698,12 +699,12 @@ interface Literals {
EReference ENTITY__RELATIONS = eINSTANCE.getEntity_Relations();

/**
* The meta object literal for the '<em><b>Super Type</b></em>' reference feature. <!-- begin-user-doc --> <!--
* end-user-doc -->
* The meta object literal for the '<em><b>Super Types</b></em>' reference list feature. <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
EReference ENTITY__SUPER_TYPE = eINSTANCE.getEntity_SuperType();
EReference ENTITY__SUPER_TYPES = eINSTANCE.getEntity_SuperTypes();

/**
* The meta object literal for the '<em><b>Abstract</b></em>' attribute feature. <!-- begin-user-doc --> <!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* <ul>
* <li>{@link org.eclipse.sirius.web.domain.Entity#getAttributes <em>Attributes</em>}</li>
* <li>{@link org.eclipse.sirius.web.domain.Entity#getRelations <em>Relations</em>}</li>
* <li>{@link org.eclipse.sirius.web.domain.Entity#getSuperType <em>Super Type</em>}</li>
* <li>{@link org.eclipse.sirius.web.domain.Entity#getSuperTypes <em>Super Types</em>}</li>
* <li>{@link org.eclipse.sirius.web.domain.Entity#isAbstract <em>Abstract</em>}</li>
* </ul>
*
Expand Down Expand Up @@ -55,26 +55,15 @@ public interface Entity extends NamedElement {
EList<Relation> getRelations();

/**
* Returns the value of the '<em><b>Super Type</b></em>' reference. <!-- begin-user-doc --> <!-- end-user-doc -->
* Returns the value of the '<em><b>Super Types</b></em>' reference list. The list contents are of type
* {@link org.eclipse.sirius.web.domain.Entity}. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @return the value of the '<em>Super Type</em>' reference.
* @see #setSuperType(Entity)
* @see org.eclipse.sirius.web.domain.DomainPackage#getEntity_SuperType()
* @return the value of the '<em>Super Types</em>' reference list.
* @see org.eclipse.sirius.web.domain.DomainPackage#getEntity_SuperTypes()
* @model
* @generated
*/
Entity getSuperType();

/**
* Sets the value of the '{@link org.eclipse.sirius.web.domain.Entity#getSuperType <em>Super Type</em>}' reference.
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param value
* the new value of the '<em>Super Type</em>' reference.
* @see #getSuperType()
* @generated
*/
void setSuperType(Entity value);
EList<Entity> getSuperTypes();

/**
* Returns the value of the '<em><b>Abstract</b></em>' attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public EReference getEntity_Relations() {
* @generated
*/
@Override
public EReference getEntity_SuperType() {
public EReference getEntity_SuperTypes() {
return (EReference) this.entityEClass.getEStructuralFeatures().get(2);
}

Expand Down Expand Up @@ -373,7 +373,7 @@ public void createPackageContents() {
this.entityEClass = this.createEClass(ENTITY);
this.createEReference(this.entityEClass, ENTITY__ATTRIBUTES);
this.createEReference(this.entityEClass, ENTITY__RELATIONS);
this.createEReference(this.entityEClass, ENTITY__SUPER_TYPE);
this.createEReference(this.entityEClass, ENTITY__SUPER_TYPES);
this.createEAttribute(this.entityEClass, ENTITY__ABSTRACT);

this.featureEClass = this.createEClass(FEATURE);
Expand Down Expand Up @@ -441,7 +441,7 @@ public void initializePackageContents() {
!IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
this.initEReference(this.getEntity_Relations(), this.getRelation(), null, "relations", null, 0, -1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, //$NON-NLS-1$
!IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
this.initEReference(this.getEntity_SuperType(), this.getEntity(), null, "superType", null, 0, 1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, //$NON-NLS-1$
this.initEReference(this.getEntity_SuperTypes(), this.getEntity(), null, "superTypes", null, 0, -1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, //$NON-NLS-1$
!IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
this.initEAttribute(this.getEntity_Abstract(), this.ecorePackage.getEBoolean(), "abstract", null, 1, 1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, //$NON-NLS-1$
IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.sirius.web.domain.Attribute;
import org.eclipse.sirius.web.domain.DomainPackage;
Expand All @@ -35,7 +36,7 @@
* <ul>
* <li>{@link org.eclipse.sirius.web.domain.impl.EntityImpl#getAttributes <em>Attributes</em>}</li>
* <li>{@link org.eclipse.sirius.web.domain.impl.EntityImpl#getRelations <em>Relations</em>}</li>
* <li>{@link org.eclipse.sirius.web.domain.impl.EntityImpl#getSuperType <em>Super Type</em>}</li>
* <li>{@link org.eclipse.sirius.web.domain.impl.EntityImpl#getSuperTypes <em>Super Types</em>}</li>
* <li>{@link org.eclipse.sirius.web.domain.impl.EntityImpl#isAbstract <em>Abstract</em>}</li>
* </ul>
*
Expand Down Expand Up @@ -63,14 +64,14 @@ public class EntityImpl extends NamedElementImpl implements Entity {
protected EList<Relation> relations;

/**
* The cached value of the '{@link #getSuperType() <em>Super Type</em>}' reference. <!-- begin-user-doc --> <!--
* end-user-doc -->
* The cached value of the '{@link #getSuperTypes() <em>Super Types</em>}' reference list. <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getSuperType()
* @see #getSuperTypes()
* @generated
* @ordered
*/
protected Entity superType;
protected EList<Entity> superTypes;

/**
* The default value of the '{@link #isAbstract() <em>Abstract</em>}' attribute. <!-- begin-user-doc --> <!--
Expand Down Expand Up @@ -143,38 +144,11 @@ public EList<Relation> getRelations() {
* @generated
*/
@Override
public Entity getSuperType() {
if (this.superType != null && this.superType.eIsProxy()) {
InternalEObject oldSuperType = (InternalEObject) this.superType;
this.superType = (Entity) this.eResolveProxy(oldSuperType);
if (this.superType != oldSuperType) {
if (this.eNotificationRequired())
this.eNotify(new ENotificationImpl(this, Notification.RESOLVE, DomainPackage.ENTITY__SUPER_TYPE, oldSuperType, this.superType));
}
public EList<Entity> getSuperTypes() {
if (this.superTypes == null) {
this.superTypes = new EObjectResolvingEList<>(Entity.class, this, DomainPackage.ENTITY__SUPER_TYPES);
}
return this.superType;
}

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Entity basicGetSuperType() {
return this.superType;
}

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setSuperType(Entity newSuperType) {
Entity oldSuperType = this.superType;
this.superType = newSuperType;
if (this.eNotificationRequired())
this.eNotify(new ENotificationImpl(this, Notification.SET, DomainPackage.ENTITY__SUPER_TYPE, oldSuperType, this.superType));
return this.superTypes;
}

/**
Expand Down Expand Up @@ -228,10 +202,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) {
return this.getAttributes();
case DomainPackage.ENTITY__RELATIONS:
return this.getRelations();
case DomainPackage.ENTITY__SUPER_TYPE:
if (resolve)
return this.getSuperType();
return this.basicGetSuperType();
case DomainPackage.ENTITY__SUPER_TYPES:
return this.getSuperTypes();
case DomainPackage.ENTITY__ABSTRACT:
return this.isAbstract();
}
Expand All @@ -255,8 +227,9 @@ public void eSet(int featureID, Object newValue) {
this.getRelations().clear();
this.getRelations().addAll((Collection<? extends Relation>) newValue);
return;
case DomainPackage.ENTITY__SUPER_TYPE:
this.setSuperType((Entity) newValue);
case DomainPackage.ENTITY__SUPER_TYPES:
this.getSuperTypes().clear();
this.getSuperTypes().addAll((Collection<? extends Entity>) newValue);
return;
case DomainPackage.ENTITY__ABSTRACT:
this.setAbstract((Boolean) newValue);
Expand All @@ -279,8 +252,8 @@ public void eUnset(int featureID) {
case DomainPackage.ENTITY__RELATIONS:
this.getRelations().clear();
return;
case DomainPackage.ENTITY__SUPER_TYPE:
this.setSuperType((Entity) null);
case DomainPackage.ENTITY__SUPER_TYPES:
this.getSuperTypes().clear();
return;
case DomainPackage.ENTITY__ABSTRACT:
this.setAbstract(ABSTRACT_EDEFAULT);
Expand All @@ -301,8 +274,8 @@ public boolean eIsSet(int featureID) {
return this.attributes != null && !this.attributes.isEmpty();
case DomainPackage.ENTITY__RELATIONS:
return this.relations != null && !this.relations.isEmpty();
case DomainPackage.ENTITY__SUPER_TYPE:
return this.superType != null;
case DomainPackage.ENTITY__SUPER_TYPES:
return this.superTypes != null && !this.superTypes.isEmpty();
case DomainPackage.ENTITY__ABSTRACT:
return this.abstract_ != ABSTRACT_EDEFAULT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
eType="#//Attribute" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="relations" upperBound="-1"
eType="#//Relation" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="superType" eType="#//Entity"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="superTypes" upperBound="-1"
eType="#//Entity"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="abstract" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</eClassifiers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<genClasses ecoreClass="domain.ecore#//Entity">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference domain.ecore#//Entity/attributes"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference domain.ecore#//Entity/relations"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference domain.ecore#//Entity/superType"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference domain.ecore#//Entity/superTypes"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute domain.ecore#//Entity/abstract"/>
</genClasses>
<genClasses ecoreClass="domain.ecore#//Feature">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ public Optional<EPackage> convert(Domain domain) {
EReference eReference = this.convertRelation(relation, convertedTypes);
eClass.getEStructuralFeatures().add(eReference);
}
Entity superType = entity.getSuperType();
if (superType != null && convertedTypes.containsKey(superType)) {
eClass.getESuperTypes().add(convertedTypes.get(superType));
for (Entity superType : entity.getSuperTypes()) {
if (convertedTypes.containsKey(superType)) {
eClass.getESuperTypes().add(convertedTypes.get(superType));
}
}
}

Expand Down

0 comments on commit 212919d

Please sign in to comment.