Commit 896675b6 authored by Simon Barner's avatar Simon Barner
Browse files

Add the following eOperations to AllocationTable

- getSourceElements(type)
- getTargetElements(type)
refs 2950
parent d8da4124
......@@ -122,6 +122,23 @@
</eGenericType>
</eParameters>
</eOperations>
<eOperations name="getTargetElements">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Returns the union of all target elements that are mapped in {@link AllocationEntry}s of the given {@code type} in this {@link AllocationTable}."/>
<details key="body" value="return AllocationTableStaticImpl.getTargetElements(this, type);"/>
</eAnnotations>
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList">
<eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/>
</eGenericType>
<eTypeParameters name="T">
<eBounds eClassifier="#//AllocationEntry"/>
</eTypeParameters>
<eParameters name="type" lowerBound="1">
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments eTypeParameter="#//AllocationTable/getTargetElements.2/T"/>
</eGenericType>
</eParameters>
</eOperations>
<eOperations name="getSourceElement" eType="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Returns the source element which is mapped to the given target element in a {@link org.fortiss.af3.allocation.OneToOneAllocationEntry}, or {@code null} in case no such mapping has been defined."/>
......@@ -199,6 +216,23 @@
</eGenericType>
</eParameters>
</eOperations>
<eOperations name="getSourceElements">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Returns the union of all source elements that are mapped in {@link AllocationEntry}s of the given {@code type} in this {@link AllocationTable}."/>
<details key="body" value="return AllocationTableStaticImpl.getSourceElements(this, type);"/>
</eAnnotations>
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList">
<eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/>
</eGenericType>
<eTypeParameters name="T">
<eBounds eClassifier="#//AllocationEntry"/>
</eTypeParameters>
<eParameters name="type" lowerBound="1">
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments eTypeParameter="#//AllocationTable/getSourceElements.2/T"/>
</eGenericType>
</eParameters>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="sourceView" eType="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHierarchicElement">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Source model for which to define {@link Allocation}."/>
......
......@@ -42,6 +42,10 @@
<genParameters ecoreParameter="allocation.ecore#//AllocationTable/getTargetElements.1/type"/>
<genTypeParameters ecoreTypeParameter="allocation.ecore#//AllocationTable/getTargetElements.1/T"/>
</genOperations>
<genOperations ecoreOperation="allocation.ecore#//AllocationTable/getTargetElements.2">
<genParameters ecoreParameter="allocation.ecore#//AllocationTable/getTargetElements.2/type"/>
<genTypeParameters ecoreTypeParameter="allocation.ecore#//AllocationTable/getTargetElements.2/T"/>
</genOperations>
<genOperations ecoreOperation="allocation.ecore#//AllocationTable/getSourceElement">
<genParameters ecoreParameter="allocation.ecore#//AllocationTable/getSourceElement/targetElement"/>
<genParameters ecoreParameter="allocation.ecore#//AllocationTable/getSourceElement/type"/>
......@@ -62,6 +66,10 @@
<genParameters ecoreParameter="allocation.ecore#//AllocationTable/getSourceElements.1/type"/>
<genTypeParameters ecoreTypeParameter="allocation.ecore#//AllocationTable/getSourceElements.1/T"/>
</genOperations>
<genOperations ecoreOperation="allocation.ecore#//AllocationTable/getSourceElements.2">
<genParameters ecoreParameter="allocation.ecore#//AllocationTable/getSourceElements.2/type"/>
<genTypeParameters ecoreTypeParameter="allocation.ecore#//AllocationTable/getSourceElements.2/T"/>
</genOperations>
</genClasses>
<genClasses image="false" ecoreClass="allocation.ecore#//AllocationEntry"/>
<genClasses ecoreClass="allocation.ecore#//OneToOneAllocationEntry">
......
......@@ -238,6 +238,34 @@ public class AllocationTableStaticImpl {
return rval.isEmpty() ? null : rval;
}
/**
* Returns the union of all target elements that are mapped in {@link AllocationEntry}s of the
* given {@code type} in the given {@link AllocationTable}.
*
* @param allocationTable
* {@link AllocationTable} in which to lookup all source model elements in
* {@link AllocationEntry} of the given type.
* @param type
* Underlying {@link AllocationEntry} type.
* @return Union of all target elements that are mapped in {@link AllocationEntry}s of the
* given {@code type} in the given {@link AllocationTable}
*/
public static <T extends AllocationEntry> EList<IModelElement> getTargetElements(
AllocationTable allocationTable, Class<T> type) {
EList<IModelElement> rval = new BasicEList<IModelElement>();
for(AllocationEntry ae : getAllocationEntries(allocationTable, type)) {
if(ae instanceof OneToOneAllocationEntry) {
rval.add(((OneToOneAllocationEntry)ae).getTargetElement());
} else if(ae instanceof OneToManyAllocationEntry) {
rval.addAll(((OneToManyAllocationEntry)ae).getTargetElements());
} else if(ae instanceof ManyToOneAllocationEntry) {
rval.add(((ManyToOneAllocationEntry)ae).getTargetElement());
}
}
return rval;
}
/**
* Returns the source element which is mapped to the given target element in a
* {@link IBidirectional} {@link OneToOneAllocationEntry}, or {@code null} in case no such
......@@ -404,4 +432,33 @@ public class AllocationTableStaticImpl {
return rval.isEmpty() ? null : rval;
}
/**
* Returns the union of all source elements that are mapped in {@link AllocationEntry}s of the
* given {@code type} in the given {@link AllocationTable}.
*
* @param allocationTable
* {@link AllocationTable} in which to lookup all source model elements in
* {@link AllocationEntry} of the given type.
* @param type
* Underlying {@link AllocationEntry} type.
* @return Union of all source elements that are mapped in {@link AllocationEntry}s of the
* given {@code type} in the given {@link AllocationTable}
*/
public static <T extends AllocationEntry> EList<IModelElement> getSourceElements(
AllocationTable allocationTable, Class<T> type) {
EList<IModelElement> rval = new BasicEList<IModelElement>();
for(AllocationEntry ae : getAllocationEntries(allocationTable, type)) {
if(ae instanceof OneToOneAllocationEntry) {
rval.add(((OneToOneAllocationEntry)ae).getSourceElement());
} else if(ae instanceof OneToManyAllocationEntry) {
rval.add(((OneToManyAllocationEntry)ae).getSourceElement());
} else if(ae instanceof ManyToOneAllocationEntry) {
rval.addAll(((ManyToOneAllocationEntry)ae).getSourceElements());
}
}
return rval;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment