/** * Copyright (c) 2015-2016 Obeo, Inria * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * - William Piers <william.piers@obeo.fr> * - Philippe Merle <philippe.merle@inria.fr> */ package org.occiware.clouddesigner.occi.impl; import java.lang.reflect.InvocationTargetException; import java.util.Map; import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.ocl.pivot.evaluation.Executor; import org.eclipse.ocl.pivot.ids.IdResolver; import org.eclipse.ocl.pivot.ids.TypeId; import org.eclipse.ocl.pivot.internal.utilities.PivotUtilInternal; import org.eclipse.ocl.pivot.library.classifier.ClassifierOclContainerOperation; import org.eclipse.ocl.pivot.library.numeric.NumericMinusOperation; import org.eclipse.ocl.pivot.library.oclany.OclAnyOclAsTypeOperation; import org.eclipse.ocl.pivot.library.oclany.OclComparableLessThanEqualOperation; import org.eclipse.ocl.pivot.library.string.CGStringGetSeverityOperation; import org.eclipse.ocl.pivot.library.string.CGStringLogDiagnosticOperation; import org.eclipse.ocl.pivot.library.string.StringConcatOperation; import org.eclipse.ocl.pivot.library.string.StringSizeOperation; import org.eclipse.ocl.pivot.library.string.StringSubstringOperation; import org.eclipse.ocl.pivot.utilities.ClassUtil; import org.eclipse.ocl.pivot.utilities.ValueUtil; import org.eclipse.ocl.pivot.values.IntegerValue; import org.occiware.clouddesigner.occi.Action; import org.occiware.clouddesigner.occi.Category; import org.occiware.clouddesigner.occi.OCCIPackage; import org.occiware.clouddesigner.occi.OCCITables; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Action</b></em>'. * <!-- end-user-doc --> * * @generated */ public class ActionImpl extends CategoryImpl implements Action { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ActionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return OCCIPackage.Literals.ACTION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean CorrectScheme(final DiagnosticChain diagnostics, final Map<Object, Object> context) { /** * * inv CorrectScheme: * let severity : Integer[1] = 'Action::CorrectScheme'.getSeverity() * in * if severity <= 0 * then true * else * let * status : OclAny[1] = let * category : ::Category[1] = oclContainer() * .oclAsType(Category) * in scheme = * category.scheme.substring(1, category.scheme.size() - 1) + '/' + category.term + '/action#' * in * 'Action::CorrectScheme'.logDiagnostic(self, null, diagnostics, context, null, severity, status, 0) * endif */ final /*@NonInvalid*/ Executor executor = PivotUtilInternal.getExecutor(this); final /*@NonInvalid*/ IdResolver idResolver = executor.getIdResolver(); final /*@NonInvalid*/ IntegerValue severity_0 = CGStringGetSeverityOperation.INSTANCE.evaluate(executor, OCCITables.STR_Action_c_c_CorrectScheme); final /*@NonInvalid*/ boolean le = OclComparableLessThanEqualOperation.INSTANCE.evaluate(executor, severity_0, OCCITables.INT_0).booleanValue(); /*@NonInvalid*/ boolean symbol_0; if (le) { symbol_0 = ValueUtil.TRUE_VALUE; } else { /*@Caught*/ /*@NonNull*/ Object CAUGHT_eq; try { final /*@NonInvalid*/ org.eclipse.ocl.pivot.Class TYP_occi_c_c_Category_0 = idResolver.getClass(OCCITables.CLSSid_Category, null); final /*@NonInvalid*/ Object oclContainer = ClassifierOclContainerOperation.INSTANCE.evaluate(executor, this); final /*@Thrown*/ Category category = ClassUtil.nonNullState((Category)OclAnyOclAsTypeOperation.INSTANCE.evaluate(executor, oclContainer, TYP_occi_c_c_Category_0)); final /*@Thrown*/ String scheme_0 = category.getScheme(); final /*@Thrown*/ String scheme = this.getScheme(); final /*@Thrown*/ IntegerValue size = StringSizeOperation.INSTANCE.evaluate(scheme_0); final /*@Thrown*/ IntegerValue diff = (IntegerValue)NumericMinusOperation.INSTANCE.evaluate(size, OCCITables.INT_1); final /*@Thrown*/ String substring = StringSubstringOperation.INSTANCE.evaluate(scheme_0, OCCITables.INT_1, diff); final /*@Thrown*/ String sum = StringConcatOperation.INSTANCE.evaluate(substring, OCCITables.STR_quot); final /*@Thrown*/ String term = category.getTerm(); final /*@Thrown*/ String sum_0 = StringConcatOperation.INSTANCE.evaluate(sum, term); final /*@Thrown*/ String sum_1 = StringConcatOperation.INSTANCE.evaluate(sum_0, OCCITables.STR__s_action_35); final /*@Thrown*/ boolean eq = scheme.equals(sum_1); CAUGHT_eq = eq; } catch (Exception e) { CAUGHT_eq = ValueUtil.createInvalidValue(e); } final /*@NonInvalid*/ boolean logDiagnostic = CGStringLogDiagnosticOperation.INSTANCE.evaluate(executor, TypeId.BOOLEAN, OCCITables.STR_Action_c_c_CorrectScheme, this, null, diagnostics, context, null, severity_0, CAUGHT_eq, OCCITables.INT_0).booleanValue(); symbol_0 = logDiagnostic; } return Boolean.TRUE == symbol_0; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override @SuppressWarnings("unchecked") public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case OCCIPackage.ACTION___CORRECT_SCHEME__DIAGNOSTICCHAIN_MAP: return CorrectScheme((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); } return super.eInvoke(operationID, arguments); } } //ActionImpl