Skip to content

Commit

Permalink
Added model and syntactic support for sum aggregation function (can b…
Browse files Browse the repository at this point in the history
…e easily extended to support other aggregation functions as well).
  • Loading branch information
BuckeyHack committed May 27, 2016
1 parent f0d2dfc commit ee24f4c
Show file tree
Hide file tree
Showing 7 changed files with 679 additions and 4 deletions.
204 changes: 200 additions & 4 deletions jdeeco-edl-model/model/edl.aird

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions jdeeco-edl-model/model/edl.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,12 @@
<eParameters name="query" eType="#//StringLiteral"/>
</eOperations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Aggregation" abstract="true" eSuperTypes="#//ComparableQuery">
<eStructuralFeatures xsi:type="ecore:EReference" name="collection" lowerBound="1"
eType="#//QualifiedName" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Sum" eSuperTypes="#//Aggregation">
<eStructuralFeatures xsi:type="ecore:EReference" name="item" lowerBound="1" eType="#//Query"
containment="true"/>
</eClassifiers>
</ecore:EPackage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
/**
*/
package cz.cuni.mff.d3s.jdeeco.edl.model.edl.impl;

import cz.cuni.mff.d3s.jdeeco.edl.model.edl.Aggregation;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.EdlPackage;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.QualifiedName;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.QueryVisitor;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Aggregation</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link cz.cuni.mff.d3s.jdeeco.edl.model.edl.impl.AggregationImpl#getCollection <em>Collection</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public abstract class AggregationImpl extends MinimalEObjectImpl.Container implements Aggregation {
/**
* The cached value of the '{@link #getCollection() <em>Collection</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCollection()
* @generated
* @ordered
*/
protected QualifiedName collection;

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected AggregationImpl() {
super();
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return EdlPackage.Literals.AGGREGATION;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public QualifiedName getCollection() {
return collection;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCollection(QualifiedName newCollection, NotificationChain msgs) {
QualifiedName oldCollection = collection;
collection = newCollection;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EdlPackage.AGGREGATION__COLLECTION, oldCollection, newCollection);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCollection(QualifiedName newCollection) {
if (newCollection != collection) {
NotificationChain msgs = null;
if (collection != null)
msgs = ((InternalEObject)collection).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EdlPackage.AGGREGATION__COLLECTION, null, msgs);
if (newCollection != null)
msgs = ((InternalEObject)newCollection).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EdlPackage.AGGREGATION__COLLECTION, null, msgs);
msgs = basicSetCollection(newCollection, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EdlPackage.AGGREGATION__COLLECTION, newCollection, newCollection));
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public <T> T accept(QueryVisitor<T> visitor) {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case EdlPackage.AGGREGATION__COLLECTION:
return basicSetCollection(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case EdlPackage.AGGREGATION__COLLECTION:
return getCollection();
}
return super.eGet(featureID, resolve, coreType);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case EdlPackage.AGGREGATION__COLLECTION:
setCollection((QualifiedName)newValue);
return;
}
super.eSet(featureID, newValue);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case EdlPackage.AGGREGATION__COLLECTION:
setCollection((QualifiedName)null);
return;
}
super.eUnset(featureID);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case EdlPackage.AGGREGATION__COLLECTION:
return collection != null;
}
return super.eIsSet(featureID);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@SuppressWarnings({"rawtypes", "unchecked" })
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
switch (operationID) {
case EdlPackage.AGGREGATION___ACCEPT__QUERYVISITOR:
return accept((QueryVisitor)arguments.get(0));
}
return super.eInvoke(operationID, arguments);
}

} //AggregationImpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public EObject create(EClass eClass) {
case EdlPackage.DATA_CONTRACT_DEFINITION: return createDataContractDefinition();
case EdlPackage.FIELD_DECLARATION: return createFieldDeclaration();
case EdlPackage.TYPE_DEFINITION: return createTypeDefinition();
case EdlPackage.SUM: return createSum();
default:
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
}
Expand Down Expand Up @@ -353,6 +354,16 @@ public TypeDefinition createTypeDefinition() {
return typeDefinition;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Sum createSum() {
SumImpl sum = new SumImpl();
return sum;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import cz.cuni.mff.d3s.jdeeco.edl.model.edl.AdditiveInverse;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.AdditiveOperator;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.Aggregation;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.AliasDefinition;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.BinaryOperator;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.BinaryOperatorType;
Expand Down Expand Up @@ -34,6 +35,7 @@
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.RelationOperatorType;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.RoleDefinition;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.StringLiteral;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.Sum;
import cz.cuni.mff.d3s.jdeeco.edl.model.edl.TypeDefinition;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
Expand Down Expand Up @@ -248,6 +250,20 @@ public class EdlPackageImpl extends EPackageImpl implements EdlPackage {
*/
private EClass queryVisitorEClass = null;

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private EClass aggregationEClass = null;

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private EClass sumEClass = null;

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
Expand Down Expand Up @@ -1167,6 +1183,42 @@ public EOperation getQueryVisitor__Visit__StringLiteral() {
return queryVisitorEClass.getEOperations().get(10);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EClass getAggregation() {
return aggregationEClass;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EReference getAggregation_Collection() {
return (EReference)aggregationEClass.getEStructuralFeatures().get(0);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EClass getSum() {
return sumEClass;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EReference getSum_Item() {
return (EReference)sumEClass.getEStructuralFeatures().get(0);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
Expand Down Expand Up @@ -1343,6 +1395,12 @@ public void createPackageContents() {
createEOperation(queryVisitorEClass, QUERY_VISITOR___VISIT__RELATIONOPERATOR);
createEOperation(queryVisitorEClass, QUERY_VISITOR___VISIT__STRINGLITERAL);

aggregationEClass = createEClass(AGGREGATION);
createEReference(aggregationEClass, AGGREGATION__COLLECTION);

sumEClass = createEClass(SUM);
createEReference(sumEClass, SUM__ITEM);

// Create enums
boolOperatorTypeEEnum = createEEnum(BOOL_OPERATOR_TYPE);
binaryOperatorTypeEEnum = createEEnum(BINARY_OPERATOR_TYPE);
Expand Down Expand Up @@ -1395,6 +1453,8 @@ public void initializePackageContents() {
multiplicativeOperatorEClass.getESuperTypes().add(this.getBinaryOperator());
additiveInverseEClass.getESuperTypes().add(this.getComparableQuery());
dataContractDefinitionEClass.getESuperTypes().add(this.getTypeDefinition());
aggregationEClass.getESuperTypes().add(this.getComparableQuery());
sumEClass.getESuperTypes().add(this.getAggregation());

// Initialize classes, features, and operations; add parameters
initEClass(edlDocumentEClass, EdlDocument.class, "EdlDocument", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
Expand Down Expand Up @@ -1572,6 +1632,12 @@ public void initializePackageContents() {
g1 = createEGenericType(queryVisitorEClass_T);
initEOperation(op, g1);

initEClass(aggregationEClass, Aggregation.class, "Aggregation", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getAggregation_Collection(), this.getQualifiedName(), null, "collection", null, 1, 1, Aggregation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

initEClass(sumEClass, Sum.class, "Sum", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getSum_Item(), this.getQuery(), null, "item", null, 1, 1, Sum.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

// Initialize enums and add enum literals
initEEnum(boolOperatorTypeEEnum, BoolOperatorType.class, "BoolOperatorType");
addEEnumLiteral(boolOperatorTypeEEnum, BoolOperatorType.AND);
Expand Down
Loading

0 comments on commit ee24f4c

Please sign in to comment.