| /******************************************************************************* |
| * Copyright (c) 2004-2008 Peter Pasztor, Akos Horvath, Gergely Varro, Istvan Rath and Daniel Varro |
| * 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: |
| * Peter Pasztor, Akos Horvath, Gergely Varro, Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.gtasm.interpreter.impl.rules;
|
|
|
| |
| import org.eclipse.viatra2.core.EDeleteSemantics; |
| import org.eclipse.viatra2.core.EMultiplicityKind; |
| import org.eclipse.viatra2.core.IEntity; |
| import org.eclipse.viatra2.core.IModelElement; |
| import org.eclipse.viatra2.core.IModelManager; |
| import org.eclipse.viatra2.core.IRelation; |
| import org.eclipse.viatra2.errors.VPMCoreException; |
| import org.eclipse.viatra2.gtasm.interpreter.exception.ASMInterpreterErrorStrings; |
| import org.eclipse.viatra2.gtasm.interpreter.exception.ViatraTransformationException; |
| import org.eclipse.viatra2.gtasm.interpreter.executionEnvironment.IExecutionEnvironment; |
| import org.eclipse.viatra2.gtasm.interpreter.impl.machine.ASMInterpreterException; |
| import org.eclipse.viatra2.gtasm.interpreter.term.rules.TermEvaluator; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.enums.CopySemantics; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.enums.DeleteSemantics; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.enums.LogLevel; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.enums.MultiplicityKind; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.enums.ValueKind; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.simpleRules.ASMRuleInvocation; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.terms.VariableReference; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.copymove.ModelCopyRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.copymove.MoveRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.creation.CreateInstanceOf; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.creation.CreateSupertypeOf; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.creation.EntityCreateRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.creation.RelationCreateRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.deletion.DeleteInstanceOf; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.deletion.DeleteSupertypeOf; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.deletion.ElementDeleteRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.RenameRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.SetAggregationRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.SetAnySourceRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.SetAnyTargetRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.SetInverseRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.SetMultiplicityRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.SetRelationFrom; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.SetRelationTo; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.SetRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.modelmanagement.manipulationRules.update.SetValueRule; |
| import org.eclipse.viatra2.interpreters.IProgressReport; |
|
|
|
|
| public class ModelManipulationRuleInterpreter extends RuleInterpreter {
|
| private static ModelManipulationRuleInterpreter _instance = new ModelManipulationRuleInterpreter();
|
|
|
| private ModelManipulationRuleInterpreter() {
|
| ;
|
| }
|
|
|
| public static ModelManipulationRuleInterpreter getInstance() {
|
| return _instance;
|
| }
|
| /**
|
| * The current class encapsulates all model manipulation org.eclipse.viatra2.gtasm.interpreter.impl.rules.
|
| *
|
| * @author: Pasztor Peter, Akos Horvath
|
| * @see org.eclipse.viatra2.gtasm.interpreter.impl.rules.RuleInterpreter#interpretRule(org.eclipse.viatra2.gtasm.interpreter.executionEnvironment.IExecutionEnvironment, org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.simpleRules.ASMRuleInvocation)
|
| */
|
|
|
| @Override |
| public Boolean interpretRule(IExecutionEnvironment executionEnvironment, ASMRuleInvocation ruleToBeInterpreted, IProgressReport pr) |
| throws ViatraTransformationException
|
| { |
| IModelManager manager = executionEnvironment.getFramework().getTopmodel().getModelManager();
|
| TermEvaluator termEvaluator = TermEvaluator.getInstance();
|
|
|
| if(ruleToBeInterpreted instanceof RenameRule)
|
| {
|
|
|
| Object name=(termEvaluator.evaluate(executionEnvironment, ((RenameRule)ruleToBeInterpreted).getValue()));
|
|
|
| if(ValueKind.UNDEF_LITERAL.equals(name))
|
| { |
| String[] context = {"Name", ruleToBeInterpreted.getName()};
|
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| if(name instanceof String)
|
| {
|
|
|
| Object modelElement=(termEvaluator.evaluate(executionEnvironment,
|
| ((RenameRule)ruleToBeInterpreted).getElement()));
|
| if(ValueKind.UNDEF_LITERAL.equals(modelElement)) |
| {
|
| String[] context = {"ModelElement", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| if(modelElement instanceof IModelElement)
|
| {
|
| try {
|
| manager.setName((IModelElement)modelElement,(String)name);
|
| return Boolean.TRUE;
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
|
|
| }
|
| else { |
| String[] context = {"ModelElement","ModelElementToSet",ruleToBeInterpreted.getName(),convertToJavaType(modelElement)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| else |
| { |
| String[] context = {"String","Name",ruleToBeInterpreted.getName(),convertToJavaType(name)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
|
|
| }
|
| else if(ruleToBeInterpreted instanceof SetValueRule)
|
| {
|
| Object value=(termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getValue()));
|
| |
| if(ValueKind.UNDEF_LITERAL.equals(value)) |
| { |
| String[] context = {"Value", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
|
|
| if(!(value instanceof String || value instanceof Integer || value instanceof Double))
|
| {
|
| String[] context = {"String","Value",ruleToBeInterpreted.getName(),convertToJavaType(value)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
|
|
| Object modelElement=(termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getElement()));
|
| if(modelElement instanceof IEntity)
|
| {
|
| try {
|
| manager.setValue((IEntity)modelElement, value.toString());
|
| return Boolean.TRUE;
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| }
|
| else if(ValueKind.UNDEF_LITERAL.equals(modelElement)) |
| { |
| String[] context = {"ModelElement", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| else |
| {String[] context = {"Entity","EntityToSet",ruleToBeInterpreted.getName(),convertToJavaType(modelElement)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
|
|
| }
|
| //TODO: which is which parameter in the syntax??
|
| else if(ruleToBeInterpreted instanceof SetRelationTo)
|
| {
|
| Object relation = (termEvaluator.evaluate(executionEnvironment,
|
| ((SetRule)ruleToBeInterpreted).getElement()));
|
| Object modelElement=(termEvaluator.evaluate(executionEnvironment,
|
| ((SetRule)ruleToBeInterpreted).getValue()));
|
|
|
| if(!(relation instanceof IRelation))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation))
|
| { |
| String[] context = {"RelationToSet", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| else |
| {String[] context = {"Relation","RelationToSet",ruleToBeInterpreted.getName(),convertToJavaType(modelElement)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| if(!(modelElement instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(modelElement))
|
| { |
| String[] context = {"To", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| else |
| {String[] context = {"Entity","To",ruleToBeInterpreted.getName(),convertToJavaType(modelElement)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| try {
|
| manager.
|
| setRelationTo((IRelation)relation,(IModelElement)modelElement);
|
| return Boolean.TRUE;
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
|
|
| }
|
| else if(ruleToBeInterpreted instanceof SetRelationFrom)
|
| {
|
| Object relation = (termEvaluator.evaluate(executionEnvironment,
|
| ((SetRule)ruleToBeInterpreted).getElement()));
|
| Object modelElement=(termEvaluator.evaluate(executionEnvironment,
|
| ((SetRule)ruleToBeInterpreted).getValue()));
|
| if(!(relation instanceof IRelation))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation))
|
| if(ValueKind.UNDEF_LITERAL.equals(relation)) |
| { |
| String[] context = {"RelationToSet", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| {String[] context = {"Relation","RelationToSet",ruleToBeInterpreted.getName(),convertToJavaType(modelElement)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| if(!(modelElement instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(modelElement)) |
| { |
| String[] context = {"From", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| {String[] context = {"Entity","From",ruleToBeInterpreted.getName(),convertToJavaType(modelElement)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| try {
|
| manager.
|
| setRelationFrom((IRelation)relation,(IModelElement)modelElement);
|
| return Boolean.TRUE;
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
|
|
| }
|
| else if(ruleToBeInterpreted instanceof SetMultiplicityRule)
|
| {
|
| Object relation= termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getElement());
|
| Object multiplicity=termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getValue());
|
|
|
| if(!(relation instanceof IRelation))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation))
|
| { |
| String[] context = {"RelationToSet", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| else |
| { |
| String[] context = {"Relation","RelationToSet",ruleToBeInterpreted.getName(),convertToJavaType(relation)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| if(!(multiplicity instanceof MultiplicityKind))
|
| {
|
| String[] context = {"Multiplicity","MultiplicityTobeSet",ruleToBeInterpreted.getName(),convertToJavaType(multiplicity)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
|
|
| try {
|
| manager.
|
| setRelationMultiplicity(((IRelation)relation),(EMultiplicityKind)multiplicity);
|
| return Boolean.TRUE;
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
|
|
| }
|
| else if(ruleToBeInterpreted instanceof SetInverseRule)
|
| {
|
| Object relation1 = (termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getElement()));
|
| Object relation2 = (termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getValue()));
|
|
|
| if(!(relation1 instanceof IRelation))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation1))
|
| { |
| String[] context = {"RelationToSet", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"Relation","RelationToSet",ruleToBeInterpreted.getName(),convertToJavaType(relation1)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| if(!(relation2 instanceof IRelation))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation2))
|
| { |
| String[] context = {"InverseRelation", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"Relation","InverseRelation",ruleToBeInterpreted.getName(),convertToJavaType(relation2)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| try {
|
|
|
| manager.
|
| setRelationInverse((IRelation)relation1,(IRelation)relation2);
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
| }
|
| else if(ruleToBeInterpreted instanceof SetAnyTargetRule)
|
| {
|
| Object relation = (termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getElement()));
|
| Object bool = (termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getValue()));
|
|
|
| if(!(relation instanceof IRelation))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation)) |
| { |
| String[] context = {"RelationToSet", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"Relation","RelationToSet",ruleToBeInterpreted.getName(),convertToJavaType(relation)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| if(!(bool instanceof Boolean))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation)) |
| { |
| String[] context = {"isAnyTarget", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"Boolean","isAnyTarget",ruleToBeInterpreted.getName(),convertToJavaType(relation)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| try {
|
| manager.
|
| setIsAnyTo(((IRelation)relation),
|
| ((Boolean)bool));
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
| }
|
| else if(ruleToBeInterpreted instanceof SetAnySourceRule)
|
| {
|
| Object relation = (termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getElement()));
|
| Object bool = (termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getValue()));
|
|
|
| if(!(relation instanceof IRelation))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation)) |
| { |
| String[] context = {"RelationToSet", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"Relation","RelationToSet",ruleToBeInterpreted.getName(),convertToJavaType(relation)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| if(!(bool instanceof Boolean))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation)) |
| { |
| String[] context = {"isAnySource", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"Boolean","isAnySource",ruleToBeInterpreted.getName(),convertToJavaType(relation)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| try {
|
| manager.
|
| setIsAnyFrom(((IRelation)relation),
|
| ((Boolean)bool));
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
| }
|
| else if(ruleToBeInterpreted instanceof SetAggregationRule)
|
| {
|
| Object relation = (termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getElement()));
|
| Object bool = (termEvaluator.evaluate(executionEnvironment, ((SetRule)ruleToBeInterpreted).getValue()));
|
|
|
| if(!(relation instanceof IRelation))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation)) |
| { |
| String[] context = {"RelationToSet", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"Relation","RelationToSet",ruleToBeInterpreted.getName(),convertToJavaType(relation)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| if(!(bool instanceof Boolean))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(relation)) |
| { |
| String[] context = {"isAggregation", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"Boolean","isAggregation",ruleToBeInterpreted.getName(),convertToJavaType(relation)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
|
|
| try {
|
| manager.
|
| setRelationIsAggregation(((IRelation)relation),
|
| ((Boolean)bool));
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
| }
|
| /*
|
| * End of SetRules
|
| *
|
| *
|
| *
|
| *
|
| */
|
| else if(ruleToBeInterpreted instanceof CreateSupertypeOf){
|
|
|
| Object sup = (termEvaluator.evaluate(executionEnvironment, ((CreateSupertypeOf)ruleToBeInterpreted).getSuper()));
|
| Object sub = (termEvaluator.evaluate(executionEnvironment, ((CreateSupertypeOf)ruleToBeInterpreted).getSub()));
|
|
|
| if(!(sup instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(sup)) |
| { |
| String[] context = {"Supertype", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Supertype",ruleToBeInterpreted.getName(),convertToJavaType(sup)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| if(!(sub instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(sub)) |
| { |
| String[] context = {"Subtype", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Subtype",ruleToBeInterpreted.getName(),convertToJavaType(sub)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| try {
|
| manager.
|
| newSupertypeOf(((IModelElement)sup), ((IModelElement)sub));
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
| }
|
| else if(ruleToBeInterpreted instanceof CreateInstanceOf){
|
| Object type = (termEvaluator.evaluate(executionEnvironment, ((CreateInstanceOf)ruleToBeInterpreted).getSuper()));
|
| Object inst = (termEvaluator.evaluate(executionEnvironment, ((CreateInstanceOf)ruleToBeInterpreted).getSub()));
|
|
|
| if(!(type instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(type)) |
| { |
| String[] context = {"Type", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Type",ruleToBeInterpreted.getName(),convertToJavaType(type)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| if(!(inst instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(inst)) |
| { |
| String[] context = {"Instance", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Instance",ruleToBeInterpreted.getName(),convertToJavaType(inst)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| try {
|
| manager.
|
| newInstanceOf(((IModelElement)type), ((IModelElement)inst));
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
|
|
| }
|
| else if(ruleToBeInterpreted instanceof RelationCreateRule){
|
|
|
| RelationCreateRule relationCreateRule = (RelationCreateRule)ruleToBeInterpreted;
|
| Object source = (termEvaluator.evaluate(executionEnvironment, relationCreateRule.getSource()));
|
| Object target = (termEvaluator.evaluate(executionEnvironment, relationCreateRule.getTarget()));
|
|
|
|
|
| if(!(source instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(source)) |
| { |
| String[] context = {"Source", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Source",ruleToBeInterpreted.getName(),convertToJavaType(source)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| if(!(target instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(target)) |
| { |
| String[] context = {"Target", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Target",ruleToBeInterpreted.getName(),convertToJavaType(target)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| IRelation newRelation=null;
|
| try {
|
| newRelation=manager.
|
| newRelation(((IModelElement)source), ((IModelElement)target));
|
| try {
|
| executionEnvironment.setVariableValue(relationCreateRule.getTargetVariable().getVariable(), newRelation );
|
| } catch (ViatraTransformationException e) {
|
| String[] context = {relationCreateRule.getTargetVariable().getVariable().getName(),relationCreateRule.getName(),e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.SET_VAR_VALUE_AFTER_MODEL_MANPULATION_RULE |
| ,context |
| ,relationCreateRule);
|
| }
|
|
|
| if(relationCreateRule.getType()!=null)
|
| {
|
| // Creating an instanceof relation for the type.
|
| Object type = termEvaluator.evaluate(executionEnvironment, relationCreateRule.getType());
|
| if(type instanceof IModelElement)
|
| manager.newInstanceOf((IModelElement)type, newRelation);
|
| else
|
| { |
| String[] context = {ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.MODEL_MANIPULATION_NOTYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
|
|
| return Boolean.TRUE;
|
|
|
| }
|
| else if(ruleToBeInterpreted instanceof EntityCreateRule){
|
|
|
| IEntity newEntity = null;
|
| EntityCreateRule entityCreateRule = (EntityCreateRule)ruleToBeInterpreted;
|
| try {
|
| if(entityCreateRule.getParent()==null)
|
| {
|
| newEntity = manager.newEntity();
|
| try {
|
| executionEnvironment.setVariableValue(entityCreateRule.getTargetVariable().getVariable(), newEntity);
|
| } catch (ViatraTransformationException e) {
|
| String[] context = {entityCreateRule.getTargetVariable().getVariable().getName(),entityCreateRule.getName(),e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.SET_VAR_VALUE_AFTER_MODEL_MANPULATION_RULE |
| ,context |
| ,entityCreateRule);
|
| }
|
| }
|
| else
|
| {
|
| //the parent is not null but have to be checked that it is a valid IEntity
|
| Object parent = termEvaluator.evaluate(executionEnvironment, entityCreateRule.getParent());
|
|
|
| if(!(parent instanceof IEntity))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(parent)) |
| { |
| String[] context = {"Container", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"Entity","Container",ruleToBeInterpreted.getName(),convertToJavaType(parent)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| newEntity=manager.newEntity((IEntity)parent);
|
| try {
|
| executionEnvironment.setVariableValue(entityCreateRule.getTargetVariable().getVariable(), newEntity);
|
| } catch (ViatraTransformationException e) {
|
| String[] context = {entityCreateRule.getTargetVariable().getVariable().getName(),entityCreateRule.getName(),e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.SET_VAR_VALUE_AFTER_MODEL_MANPULATION_RULE |
| ,context |
| ,entityCreateRule);
|
| }
|
| }
|
|
|
| if((entityCreateRule.getType())!=null)
|
| {
|
| // Creating an instanceof relation for the type.
|
| Object type = termEvaluator.evaluate(executionEnvironment, entityCreateRule.getType());
|
| if(type instanceof IModelElement)
|
| manager.newInstanceOf((IModelElement)type, newEntity);
|
| else
|
| { |
| String[] context = {ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.MODEL_MANIPULATION_NOTYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
| }
|
| /*
|
| * End of Creation Rules
|
| *
|
| *
|
| *
|
| * Deletion Rules
|
| */
|
| else if(ruleToBeInterpreted instanceof DeleteInstanceOf){
|
|
|
| Object type = (termEvaluator.evaluate(executionEnvironment, ((DeleteInstanceOf)ruleToBeInterpreted).getSuper()));
|
| Object inst = (termEvaluator.evaluate(executionEnvironment, ((DeleteInstanceOf)ruleToBeInterpreted).getSub()));
|
| |
| if(!(type instanceof IModelElement)) |
| { |
| if(ValueKind.UNDEF_LITERAL.equals(type)) |
| { |
| String[] context = {"Type", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Type",ruleToBeInterpreted.getName(),convertToJavaType(type)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| } |
| if(!(inst instanceof IModelElement)) |
| { |
| if(ValueKind.UNDEF_LITERAL.equals(inst)) |
| { |
| String[] context = {"Instance", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Instance",ruleToBeInterpreted.getName(),convertToJavaType(inst)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| }
|
|
|
| try {
|
| manager.
|
| deleteInstanceOf(
|
| ((IModelElement)type),
|
| ((IModelElement)inst));
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
|
|
| }
|
| else if(ruleToBeInterpreted instanceof DeleteSupertypeOf){
|
| Object sup = (termEvaluator.evaluate(executionEnvironment, ((DeleteSupertypeOf)ruleToBeInterpreted).getSuper()));
|
| Object sub = (termEvaluator.evaluate(executionEnvironment, ((DeleteSupertypeOf)ruleToBeInterpreted).getSub()));
|
|
|
| if(!(sup instanceof IModelElement)) |
| { |
| if(ValueKind.UNDEF_LITERAL.equals(sup)) |
| { |
| String[] context = {"Supertype", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Supertype",ruleToBeInterpreted.getName(),convertToJavaType(sup)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| } |
| if(!(sub instanceof IModelElement)) |
| { |
| if(ValueKind.UNDEF_LITERAL.equals(sub)) |
| { |
| String[] context = {"Subtype", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Subtype",ruleToBeInterpreted.getName(),convertToJavaType(sub)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| }
|
|
|
| try {
|
| manager.
|
| deleteSupertypeOf(
|
| ((IModelElement)sup),
|
| ((IModelElement)sub));
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
|
|
| }
|
| else if(ruleToBeInterpreted instanceof ElementDeleteRule){
|
|
|
| EDeleteSemantics deleteSemantics=EDeleteSemantics.DELETE_SEMANTICS_BRANCH_FORCE;
|
| ElementDeleteRule elementDeleteRule = (ElementDeleteRule)ruleToBeInterpreted;
|
|
|
| if((elementDeleteRule).getSemantics().equals(DeleteSemantics.MOVE_CONTENT_LITERAL))
|
| {
|
| deleteSemantics = EDeleteSemantics.DELETE_SEMANTICS_FORCE;
|
| }
|
|
|
| try {
|
| Object elementToBeDeleted=termEvaluator.evaluate(executionEnvironment,elementDeleteRule.getElement());
|
| if(ValueKind.UNDEF_LITERAL.equals(elementToBeDeleted))
|
| {
|
| String sourceLine="";
|
| String sourceFile="";
|
| for (int i=0; i<elementDeleteRule.getAnnotations().size();i++) {
|
| if("sourceline".equals(elementDeleteRule.getAnnotations().get(i).getKey()))
|
| {
|
| sourceLine=elementDeleteRule.getAnnotations().get(i).getValue();
|
| }
|
| else if("sourcefile".equals(elementDeleteRule.getAnnotations().get(i).getKey()))
|
| {
|
| sourceFile=elementDeleteRule.getAnnotations().get(i).getValue();
|
| }
|
| }
|
| executionEnvironment.getFramework().getLogger().message(LogLevel.WARNING, "File: \""+sourceFile+"\", line: "+sourceLine+": Element Delete called for undefined argument!");
|
| return Boolean.TRUE;
|
| }
|
| manager.deleteElement((IModelElement)elementToBeDeleted,deleteSemantics);
|
| if(elementDeleteRule.getElement() instanceof VariableReference)
|
| {
|
| executionEnvironment.setVariableValue(((VariableReference)elementDeleteRule.getElement()).getVariable(),ValueKind.UNDEF_LITERAL);
|
| }
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
|
|
| }
|
| /*
|
| * End of Deletion Rules
|
| *
|
| *
|
| *
|
| * Copy/move Rules
|
| */
|
| else if(ruleToBeInterpreted instanceof MoveRule){
|
|
|
| Object srcRoot = (termEvaluator.evaluate(executionEnvironment, ((MoveRule)ruleToBeInterpreted).getSrcRoot()));
|
| Object trgContainer = (termEvaluator.evaluate(executionEnvironment, ((MoveRule)ruleToBeInterpreted).getTrgContainer()));
|
|
|
| if(!(srcRoot instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(srcRoot)) |
| { |
| String[] context = {"Source", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Source",ruleToBeInterpreted.getName(),convertToJavaType(srcRoot)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
| if(!(trgContainer instanceof IModelElement))
|
| {
|
| if(ValueKind.UNDEF_LITERAL.equals(trgContainer)) |
| { |
| String[] context = {"Target", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Target",ruleToBeInterpreted.getName(),convertToJavaType(trgContainer)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| }
|
|
|
| try {
|
| manager.
|
| moveEntityTo((IEntity)srcRoot,(IEntity)trgContainer);
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| }
|
| return Boolean.TRUE;
|
|
|
| }
|
| else if(ruleToBeInterpreted instanceof ModelCopyRule){
|
| Object srcRoot = (termEvaluator.evaluate(executionEnvironment, ((ModelCopyRule)ruleToBeInterpreted).getSrcRoot()));
|
| Object trgContainer = (termEvaluator.evaluate(executionEnvironment, ((ModelCopyRule)ruleToBeInterpreted).getTrgContainer()));
|
|
|
|
|
| if(!(srcRoot instanceof IModelElement)) |
| { |
| if(ValueKind.UNDEF_LITERAL.equals(srcRoot)) |
| { |
| String[] context = {"Source", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Source",ruleToBeInterpreted.getName(),convertToJavaType(srcRoot)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| } |
| if(!(trgContainer instanceof IModelElement)) |
| { |
| if(ValueKind.UNDEF_LITERAL.equals(trgContainer)) |
| { |
| String[] context = {"Target", ruleToBeInterpreted.getName()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE_UNDEF |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| else |
| { |
| String[] context = {"ModelElement (Entity or Relation)","Target",ruleToBeInterpreted.getName(),convertToJavaType(trgContainer)}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.PARAM_EXCEPTED_TYPE |
| ,context |
| ,ruleToBeInterpreted); |
| } |
| }
|
|
|
| try {
|
| executionEnvironment.
|
| setVariableValue(
|
| ((ModelCopyRule)ruleToBeInterpreted).getTargetVariable().getVariable(),
|
| manager.
|
| copyModelElement(
|
| (IModelElement)srcRoot,
|
| (IModelElement)trgContainer,
|
| ((ModelCopyRule)ruleToBeInterpreted).getSemantics()==CopySemantics.COPY_OUTER_EDGES_LITERAL));
|
| } catch (VPMCoreException e) {
|
| String[] context = {e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.VPM_CORE |
| ,context |
| ,ruleToBeInterpreted);
|
| } catch (ViatraTransformationException e) {
|
| String[] context = {((ModelCopyRule)ruleToBeInterpreted).getTargetVariable().getVariable().getName(),ruleToBeInterpreted.getName(),e.getMessage()}; |
| throw new ASMInterpreterException(ASMInterpreterErrorStrings.SET_VAR_VALUE_AFTER_MODEL_MANPULATION_RULE |
| ,context |
| ,ruleToBeInterpreted); |
| }
|
| return Boolean.TRUE;
|
| }
|
| return null;
|
| }
|
| }
|