blob: 3647e72ee334575b960672cd8b395abcb32f1e91 [file] [log] [blame]
/*
* Created on 2005.01.04.
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.eclipse.viatra2.imports.vtcl;
import java.util.Collection;
import java.util.Iterator;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.Vector;
import org.eclipse.viatra2.logger.Logger;
import org.eclipse.viatra2.core.*;
import org.eclipse.viatra2.errors.VPMCoreException;
import org.eclipse.viatra2.errors.VPMRuntimeException;
/*
import org.eclipse.viatra2.imports.vtcl.asmrules.ASMRuleDef;
import org.eclipse.viatra2.imports.vtcl.asmrules.CallRule;
import org.eclipse.viatra2.imports.vtcl.asmrules.DeleteElementRule;
import org.eclipse.viatra2.imports.vtcl.asmrules.DeleteRelationshipRule;
import org.eclipse.viatra2.imports.vtcl.asmrules.LogRule;
import org.eclipse.viatra2.imports.vtcl.asmrules.MoveRule;
import org.eclipse.viatra2.imports.vtcl.asmrules.NewEntityRule;
import org.eclipse.viatra2.imports.vtcl.asmrules.NewRelationRule;
import org.eclipse.viatra2.imports.vtcl.asmrules.NewRelationshipRule;
import org.eclipse.viatra2.imports.vtcl.asmrules.RenameRule;
import org.eclipse.viatra2.imports.vtcl.asmrules.SetValueRule;
import org.eclipse.viatra2.imports.vtcl.gt.GTPatternCallDef;
import org.eclipse.viatra2.imports.vtcl.gt.GTPatternDef;
import org.eclipse.viatra2.imports.vtcl.gt.GTRuleCallDef;
import org.eclipse.viatra2.imports.vtcl.gt.GTRuleDef;
import org.eclipse.viatra2.imports.vtcl.terms.FormulaDef;
import org.eclipse.viatra2.imports.vtcl.terms.TermDef;*/
/**
* @author babo
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class VTCLMetaModelHelper {
private static VTCLMetaModelHelper instance;
private static Logger log = null;
private IModelSpace modsp;
private IModelManager mm;
public IModelSpace getMSpace() { return modsp;}
/* %modelelement to variable mapping start%
ASM.metamodel ASM_metamodel
ASM.metamodel.ASMRules ASM_metamodel_ASMRules
ASM.metamodel.terms.Constant termConstant
datatypes.Integer typeInteger
datatypes.String typeString
%modelelement to variable mapping end% */
/* %fqn of model start%
ASM
datatypes
%fqn of model end% */
/* %auto generated modelelement variable definitions start% */
/* %auto generated modelelement variable definitions end% */
/* IEntity VARIABLE = null ;
IEntity TERM = null ;
IFunction TERM_NEXTPARAM = null ;
IEntity UPDATERULE = null ;
IFunction UPDATERULE_FUNCTION = null ;
IFunction UPDATERULE_VALUE = null ;
IFunction UPDATERULE_LOCATION = null ;
IFunction UPDATERULE_VARIABLE = null ;
IEntity UNARYOPERATION = null ;
IFunction UNARYOPERATION_FORMULA = null ;
IEntity SETVALUERULE = null ;
IFunction SETVALUERULE_VALUE = null ;
IFunction SETVALUERULE_ELEMENTREF = null ;
IEntity RELATIONSHIPTYPE = null ;
IEntity RELATIONCREATERULE = null ;
IFunction RELATIONCREATERULE_SOURCE = null ;
IFunction RELATIONCREATERULE_TARGET = null ;
IEntity RELATIONSHIPCREATERULE = null ;
IFunction RELATIONSHIPCREATERULE_FROMREF = null ;
IFunction RELATIONSHIPCREATERULE_TOREF = null ;
IFunction RELATIONSHIPCREATERULE_TYPE = null ;
IEntity RULEPARAMETER = null ;
IFunction RULEPARAMETER_NEXTPARAM = null ;
IFunction RULEPARAMETER_DIRECTION = null ;
IFunction RULEPARAMETER_VARIABLE = null ;
IEntity RENAMERULE = null ;
IFunction RENAMERULE_ELEMENT = null ;
IFunction RENAMERULE_NAME = null ;
IEntity RANDOMRULE = null ;
IEntity QUALIFIEDFORMULA = null ;
IFunction QUALIFIEDFORMULA_VARIABLE = null ;
IEntity SKIPRULE = null ;
IEntity SEQUENTIALRULE = null ;
IFunction SEQUENTIALRULE_FIRSTRULE = null ;
IEntity RELATIONSHIPDELETERULE = null ;
IFunction RELATIONSHIPDELETERULE_FROM = null ;
IFunction RELATIONSHIPDELETERULE_TO = null ;
IFunction RELATIONSHIPDELETERULE_TYPE = null ;
IEntity RELATIONALOPERATION = null ;
IFunction RELATIONALOPERATION_LEFTSIDE = null ;
IFunction RELATIONALOPERATION_RIGHTSIDE = null ;
IEntity PARALLELRULE = null ;
IEntity PRINTRULE = null ;
IFunction PRINTRULE_OUT = null ;
IEntity OR = null ;
IEntity NOTEQUALS = null ;
IEntity NOT = null ;
IEntity NESTEDRULE = null ;
IEntity NATIVEIMPLEMENTATION = null ;
IEntity NATIVEFUNCTION = null ;
IFunction NATIVEFUNCTION_IMPLEMENTATION = null ;
IEntity MODELMANIPULATIONRULE = null ;
IEntity MOVERULE = null ;
IFunction MOVERULE_FROM = null ;
IFunction MOVERULE_TO = null ;
IFunction MOVERULE_ELEMENT = null ;
IEntity MODELELEMENT = null ;
IEntity LOGRULE = null ;
IFunction LOGRULE_OUT = null ;
IFunction LOGRULE_LEVEL = null ;
IEntity LESSTHAN = null ;
IEntity LEVEL = null ;
IEntity LOCATION = null ;
IEntity LETRULE = null ;
IFunction LETRULE_VARIABLE = null ;
IFunction LETRULE_VALUE = null ;
IEntity ITERATERULE = null ;
IEntity GTRULEINVOCATION = null ;
IFunction GTRULEINVOCATION_RULE = null ;
IFunction GTRULEINVOCATION_FIRSTPARAM = null ;
IEntity IMPLICATION = null ;
IEntity GTRULE = null ;
IFunction GTRULE_ACTION = null ;
//IFunction GTRULE_PATTERN = null ;
IFunction GTRULE_FIRSTPARAM = null ;
IEntity GTPATTERN = null ;
IFunction GTPATTERN_PATTERNCALL = null ;
IFunction GTPATTERN_CHECK = null ;
IFunction GTPATTERN_FIRSTPARAMETER = null ;
IEntity FORMULA = null ;
IEntity EXISTS = null ;
IEntity EQUALS = null ;
IEntity FORALLRULE = null ;
IFunction FORALLRULE_FORMULA = null ;
IEntity FUNCTIONINVOCATION = null ;
IFunction FUNCTIONINVOCATION_FIRSTPARAM = null ;
IFunction FUNCTIONINVOCATION_FUNCTION = null ;
IEntity GREATERTHAN = null ;
IEntity ACTUALPARAMETER = null ;
IFunction ACTUALPARAMETER_NEXT = null ;
IFunction ACTUALPARAMETER_VALUE = null ;
IFunction ACTUALPARAMETER_VARIABLE = null ;
IEntity ENTITY = null ;
IEntity ELEMENTREFERENCE = null ;
IEntity CALLRULE = null ;
IFunction CALLRULE_RULE = null ;
IFunction CALLRULE_FIRSTPARAMETER = null ;
IEntity BINARYOPERATION = null ;
IFunction BINARYOPERATION_LEFT = null ;
IFunction BINARYOPERATION_RIGHT = null ;
IEntity CONDITIONALRULE = null ;
IFunction CONDITIONALRULE_CONDITION = null ;
IFunction CONDITIONALRULE_GTRULE = null ;
IFunction CONDITIONALRULE_RULE1 = null ;
IFunction CONDITIONALRULE_RULE2 = null ;
IEntity ELEMENTCREATERULE = null ;
IFunction ELEMENTCREATERULE_TYPE = null ;
IFunction ELEMENTCREATERULE_ELEMENT = null ;
IFunction ELEMENTCREATERULE_CONTAINERREF = null ;
IEntity CHOOSERULE = null ;
IFunction CHOOSERULE_FORMULA = null ;
IEntity CONSTANT = null ;
IEntity BLOCKRULE = null ;
IFunction BLOCKRULE_RULE = null ;
IFunction BLOCKRULE_GTRULE = null ;
IEntity ASMFUNCTION = null ;
IEntity ASMRULEINVOCATION = null ;
IFunction ASMRULEINVOCATION_RULE = null ;
IFunction ASMRULEINVOCATION_FIRSTPARAM = null ;
IEntity ELEMENTDELETERULE = null ;
IFunction ELEMENTDELETERULE_ELEMENT = null ;
IEntity ASMRULE = null ;
IFunction ASMRULE_FIRSTPARAM = null ;
IEntity AND = null ;
IEntity ALL = null ;
IRelation RULE = null ;
IRelation LOCATION_REL = null ;
IRelation NEGATIVE = null ;
IRelation NEXTRULE = null ;
*/
/*
* Manual extensions
*/
IEntity LEVEL_FATAL = null;
IEntity LEVEL_ERROR = null;
IEntity LEVEL_WARNING = null;
IEntity LEVEL_INFO = null;
IEntity LEVEL_DEBUG = null;
IEntity STRING = null;
IEntity RULEDEFINITION = null;
/* IFunction RULEDEFINITION_RULE = null;
IEntity GTPATTERNCALL = null;
IFunction GTPATTERNCALL_PATTERN = null;
IFunction GTPATTERNCALL_FIRSTPARAMETER=null;
IFunction GTRULE_POSTCONDITION = null;
IFunction GTRULE_PRECONDITION = null;
IFunction ANNOTATION = null;
/*
* New elements regarding to metamodel revision on 01/03/2005
*/
/*
IFunction GTPATTERNCALL_SCOPE = null;
IFunction GTPATTERNCALL_MODE = null;
IFunction GTRULEINVOCATION_SCOPE = null;
IFunction GTRULEINVOCATION_MODE = null;
IEntity SCOPEDPARAMETER = null;
IFunction SCOPEDPARAMETER_NAME = null;
IFunction SCOPEDPARAMETER_MODE = null;
IFunction SCOPEDPARAMETER_NEXT = null;
IFunction SCOPEDPARAMETER_BASE = null;
IFunction BLOCKRULE_FIRSTVARIABLE = null;
*/
Stack conts = new Stack();
public void addContainer(IEntity e)
{
conts.push(e);
}
public IEntity currentContainer()
{
return (IEntity)conts.peek();
}
public IEntity removeContainer()
{
return (IEntity)conts.pop();
}
public static VTCLMetaModelHelper getInstance() {
if (instance==null) instance = new VTCLMetaModelHelper();
if (instance.log==null) return null;
return instance;
}
private VTCLMetaModelHelper()
{
}
public static void init(Logger l, IModelSpace ms, ASTBuilder a) throws VPMRuntimeException
{
log = l;
getInstance().modsp = ms;
getInstance().mm = ms.getModelManager();
getInstance().ab=a;
getInstance().loadMetaModel();
}
public static void deleteInstance()
{
instance = null;
}
private void loadMetaModel() throws VPMRuntimeException
{
/* %auto generated modelelement load start% */
/* %auto generated modelelement load end% */
/*
VARIABLE = mm.getEntityByName("ASM.metamodel.Variable");
if (VARIABLE==null) {
log.error("ASM metamodel element ASM.metamodel.Variable not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
TERM = mm.getEntityByName("ASM.metamodel.Term");
if (TERM==null) {
log.error("ASM metamodel element ASM.metamodel.Term not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
TERM_NEXTPARAM = mm.getFunctionByName("ASM.metamodel.Term.nextParam");
if (TERM_NEXTPARAM==null) {
log.error("ASM metamodel element ASM.metamodel.Term.nextParam not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
UPDATERULE = mm.getEntityByName("ASM.metamodel.UpdateRule");
if (UPDATERULE==null) {
log.error("ASM metamodel element ASM.metamodel.UpdateRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
UPDATERULE_FUNCTION = mm.getFunctionByName("ASM.metamodel.UpdateRule.function");
if (UPDATERULE_FUNCTION==null) {
log.error("ASM metamodel element ASM.metamodel.UpdateRule.function not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
UPDATERULE_VALUE = mm.getFunctionByName("ASM.metamodel.UpdateRule.value");
if (UPDATERULE_VALUE==null) {
log.error("ASM metamodel element ASM.metamodel.UpdateRule.value not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
UPDATERULE_LOCATION = mm.getFunctionByName("ASM.metamodel.UpdateRule.location");
if (UPDATERULE_LOCATION==null) {
log.error("ASM metamodel element ASM.metamodel.UpdateRule.location not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
UPDATERULE_VARIABLE = mm.getFunctionByName("ASM.metamodel.UpdateRule.variable");
if (UPDATERULE_VARIABLE==null) {
log.error("ASM metamodel element ASM.metamodel.UpdateRule.variable not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
UNARYOPERATION = mm.getEntityByName("ASM.metamodel.UnaryOperation");
if (UNARYOPERATION==null) {
log.error("ASM metamodel element ASM.metamodel.UnaryOperation not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
UNARYOPERATION_FORMULA = mm.getFunctionByName("ASM.metamodel.UnaryOperation.formula");
if (UNARYOPERATION_FORMULA==null) {
log.error("ASM metamodel element ASM.metamodel.UnaryOperation.formula not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SETVALUERULE = mm.getEntityByName("ASM.metamodel.SetValueRule");
if (SETVALUERULE==null) {
log.error("ASM metamodel element ASM.metamodel.SetValueRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SETVALUERULE_VALUE = mm.getFunctionByName("ASM.metamodel.SetValueRule.value");
if (SETVALUERULE_VALUE==null) {
log.error("ASM metamodel element ASM.metamodel.SetValueRule.value not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SETVALUERULE_ELEMENTREF = mm.getFunctionByName("ASM.metamodel.SetValueRule.elementRef");
if (SETVALUERULE_ELEMENTREF==null) {
log.error("ASM metamodel element ASM.metamodel.SetValueRule.elementRef not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONSHIPTYPE = mm.getEntityByName("ASM.metamodel.RelationshipType");
if (RELATIONSHIPTYPE==null) {
log.error("ASM metamodel element ASM.metamodel.RelationshipType not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONCREATERULE = mm.getEntityByName("ASM.metamodel.RelationCreateRule");
if (RELATIONCREATERULE==null) {
log.error("ASM metamodel element ASM.metamodel.RelationCreateRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONCREATERULE_SOURCE = mm.getFunctionByName("ASM.metamodel.RelationCreateRule.source");
if (RELATIONCREATERULE_SOURCE==null) {
log.error("ASM metamodel element ASM.metamodel.RelationCreateRule.source not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONCREATERULE_TARGET = mm.getFunctionByName("ASM.metamodel.RelationCreateRule.target");
if (RELATIONCREATERULE_TARGET==null) {
log.error("ASM metamodel element ASM.metamodel.RelationCreateRule.target not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONSHIPCREATERULE = mm.getEntityByName("ASM.metamodel.RelationshipCreateRule");
if (RELATIONSHIPCREATERULE==null) {
log.error("ASM metamodel element ASM.metamodel.RelationshipCreateRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONSHIPCREATERULE_FROMREF = mm.getFunctionByName("ASM.metamodel.RelationshipCreateRule.fromRef");
if (RELATIONSHIPCREATERULE_FROMREF==null) {
log.error("ASM metamodel element ASM.metamodel.RelationshipCreateRule.fromRef not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONSHIPCREATERULE_TOREF = mm.getFunctionByName("ASM.metamodel.RelationshipCreateRule.toRef");
if (RELATIONSHIPCREATERULE_TOREF==null) {
log.error("ASM metamodel element ASM.metamodel.RelationshipCreateRule.toRef not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONSHIPCREATERULE_TYPE = mm.getFunctionByName("ASM.metamodel.RelationshipCreateRule.type");
if (RELATIONSHIPCREATERULE_TYPE==null) {
log.error("ASM metamodel element ASM.metamodel.RelationshipCreateRule.type not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RULEPARAMETER = mm.getEntityByName("ASM.metamodel.RuleParameter");
if (RULEPARAMETER==null) {
log.error("ASM metamodel element ASM.metamodel.RuleParameter not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RULEPARAMETER_NEXTPARAM = mm.getFunctionByName("ASM.metamodel.RuleParameter.nextParam");
if (RULEPARAMETER_NEXTPARAM==null) {
log.error("ASM metamodel element ASM.metamodel.RuleParameter.nextParam not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RULEPARAMETER_DIRECTION = mm.getFunctionByName("ASM.metamodel.RuleParameter.direction");
if (RULEPARAMETER_DIRECTION==null) {
log.error("ASM metamodel element ASM.metamodel.RuleParameter.direction not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RULEPARAMETER_VARIABLE = mm.getFunctionByName("ASM.metamodel.RuleParameter.variable");
if (RULEPARAMETER_VARIABLE==null) {
log.error("ASM metamodel element ASM.metamodel.RuleParameter.variable not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RENAMERULE = mm.getEntityByName("ASM.metamodel.RenameRule");
if (RENAMERULE==null) {
log.error("ASM metamodel element ASM.metamodel.RenameRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RENAMERULE_ELEMENT = mm.getFunctionByName("ASM.metamodel.RenameRule.element");
if (RENAMERULE_ELEMENT==null) {
log.error("ASM metamodel element ASM.metamodel.RenameRule.element not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RENAMERULE_NAME = mm.getFunctionByName("ASM.metamodel.RenameRule.name");
if (RENAMERULE_NAME==null) {
log.error("ASM metamodel element ASM.metamodel.RenameRule.name not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RANDOMRULE = mm.getEntityByName("ASM.metamodel.RandomRule");
if (RANDOMRULE==null) {
log.error("ASM metamodel element ASM.metamodel.RandomRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
QUALIFIEDFORMULA = mm.getEntityByName("ASM.metamodel.QualifiedFormula");
if (QUALIFIEDFORMULA==null) {
log.error("ASM metamodel element ASM.metamodel.QualifiedFormula not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
QUALIFIEDFORMULA_VARIABLE = mm.getFunctionByName("ASM.metamodel.QualifiedFormula.variable");
if (QUALIFIEDFORMULA_VARIABLE==null) {
log.error("ASM metamodel element ASM.metamodel.QualifiedFormula.variable not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SKIPRULE = mm.getEntityByName("ASM.metamodel.SkipRule");
if (SKIPRULE==null) {
log.error("ASM metamodel element ASM.metamodel.SkipRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SEQUENTIALRULE = mm.getEntityByName("ASM.metamodel.SequentialRule");
if (SEQUENTIALRULE==null) {
log.error("ASM metamodel element ASM.metamodel.SequentialRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SEQUENTIALRULE_FIRSTRULE = mm.getFunctionByName("ASM.metamodel.SequentialRule.firstRule");
if (SEQUENTIALRULE_FIRSTRULE==null) {
log.error("ASM metamodel element ASM.metamodel.SequentialRule.firstRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONSHIPDELETERULE = mm.getEntityByName("ASM.metamodel.RelationshipDeleteRule");
if (RELATIONSHIPDELETERULE==null) {
log.error("ASM metamodel element ASM.metamodel.RelationshipDeleteRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONSHIPDELETERULE_FROM = mm.getFunctionByName("ASM.metamodel.RelationshipDeleteRule.from");
if (RELATIONSHIPDELETERULE_FROM==null) {
log.error("ASM metamodel element ASM.metamodel.RelationshipDeleteRule.from not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONSHIPDELETERULE_TO = mm.getFunctionByName("ASM.metamodel.RelationshipDeleteRule.to");
if (RELATIONSHIPDELETERULE_TO==null) {
log.error("ASM metamodel element ASM.metamodel.RelationshipDeleteRule.to not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONSHIPDELETERULE_TYPE = mm.getFunctionByName("ASM.metamodel.RelationshipDeleteRule.type");
if (RELATIONSHIPDELETERULE_TYPE==null) {
log.error("ASM metamodel element ASM.metamodel.RelationshipDeleteRule.type not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONALOPERATION = mm.getEntityByName("ASM.metamodel.RelationalOperation");
if (RELATIONALOPERATION==null) {
log.error("ASM metamodel element ASM.metamodel.RelationalOperation not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONALOPERATION_LEFTSIDE = mm.getFunctionByName("ASM.metamodel.RelationalOperation.leftSide");
if (RELATIONALOPERATION_LEFTSIDE==null) {
log.error("ASM metamodel element ASM.metamodel.RelationalOperation.leftSide not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RELATIONALOPERATION_RIGHTSIDE = mm.getFunctionByName("ASM.metamodel.RelationalOperation.rightSide");
if (RELATIONALOPERATION_RIGHTSIDE==null) {
log.error("ASM metamodel element ASM.metamodel.RelationalOperation.rightSide not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
PARALLELRULE = mm.getEntityByName("ASM.metamodel.ParallelRule");
if (PARALLELRULE==null) {
log.error("ASM metamodel element ASM.metamodel.ParallelRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
PRINTRULE = mm.getEntityByName("ASM.metamodel.PrintRule");
if (PRINTRULE==null) {
log.error("ASM metamodel element ASM.metamodel.PrintRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
PRINTRULE_OUT = mm.getFunctionByName("ASM.metamodel.PrintRule.out");
if (PRINTRULE_OUT==null) {
log.error("ASM metamodel element ASM.metamodel.PrintRule.out not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
OR = mm.getEntityByName("ASM.metamodel.Or");
if (OR==null) {
log.error("ASM metamodel element ASM.metamodel.Or not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
NOTEQUALS = mm.getEntityByName("ASM.metamodel.NotEquals");
if (NOTEQUALS==null) {
log.error("ASM metamodel element ASM.metamodel.NotEquals not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
NOT = mm.getEntityByName("ASM.metamodel.Not");
if (NOT==null) {
log.error("ASM metamodel element ASM.metamodel.Not not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
NESTEDRULE = mm.getEntityByName("ASM.metamodel.NestedRule");
if (NESTEDRULE==null) {
log.error("ASM metamodel element ASM.metamodel.NestedRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
NATIVEIMPLEMENTATION = mm.getEntityByName("ASM.metamodel.NativeImplementation");
if (NATIVEIMPLEMENTATION==null) {
log.error("ASM metamodel element ASM.metamodel.NativeImplementation not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
NATIVEFUNCTION = mm.getEntityByName("ASM.metamodel.NativeFunction");
if (NATIVEFUNCTION==null) {
log.error("ASM metamodel element ASM.metamodel.NativeFunction not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
NATIVEFUNCTION_IMPLEMENTATION = mm.getFunctionByName("ASM.metamodel.NativeFunction.implementation");
if (NATIVEFUNCTION_IMPLEMENTATION==null) {
log.error("ASM metamodel element ASM.metamodel.NativeFunction.implementation not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
MODELMANIPULATIONRULE = mm.getEntityByName("ASM.metamodel.ModelManipulationRule");
if (MODELMANIPULATIONRULE==null) {
log.error("ASM metamodel element ASM.metamodel.ModelManipulationRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
MOVERULE = mm.getEntityByName("ASM.metamodel.MoveRule");
if (MOVERULE==null) {
log.error("ASM metamodel element ASM.metamodel.MoveRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
MOVERULE_FROM = mm.getFunctionByName("ASM.metamodel.MoveRule.from");
if (MOVERULE_FROM==null) {
log.error("ASM metamodel element ASM.metamodel.MoveRule.from not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
MOVERULE_TO = mm.getFunctionByName("ASM.metamodel.MoveRule.to");
if (MOVERULE_TO==null) {
log.error("ASM metamodel element ASM.metamodel.MoveRule.to not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
MOVERULE_ELEMENT = mm.getFunctionByName("ASM.metamodel.MoveRule.element");
if (MOVERULE_ELEMENT==null) {
log.error("ASM metamodel element ASM.metamodel.MoveRule.element not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
MODELELEMENT = mm.getEntityByName("ASM.metamodel.ModelElement");
if (MODELELEMENT==null) {
log.error("ASM metamodel element ASM.metamodel.ModelElement not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LOGRULE = mm.getEntityByName("ASM.metamodel.LogRule");
if (LOGRULE==null) {
log.error("ASM metamodel element ASM.metamodel.LogRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LOGRULE_OUT = mm.getFunctionByName("ASM.metamodel.LogRule.out");
if (LOGRULE_OUT==null) {
log.error("ASM metamodel element ASM.metamodel.LogRule.out not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LOGRULE_LEVEL = mm.getFunctionByName("ASM.metamodel.LogRule.level");
if (LOGRULE_LEVEL==null) {
log.error("ASM metamodel element ASM.metamodel.LogRule.level not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LESSTHAN = mm.getEntityByName("ASM.metamodel.LessThan");
if (LESSTHAN==null) {
log.error("ASM metamodel element ASM.metamodel.LessThan not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LEVEL = mm.getEntityByName("ASM.metamodel.Level");
if (LEVEL==null) {
log.error("ASM metamodel element ASM.metamodel.Level not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LOCATION = mm.getEntityByName("ASM.metamodel.Location");
if (LOCATION==null) {
log.error("ASM metamodel element ASM.metamodel.Location not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LETRULE = mm.getEntityByName("ASM.metamodel.LetRule");
if (LETRULE==null) {
log.error("ASM metamodel element ASM.metamodel.LetRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LETRULE_VARIABLE = mm.getFunctionByName("ASM.metamodel.LetRule.variable");
if (LETRULE_VARIABLE==null) {
log.error("ASM metamodel element ASM.metamodel.LetRule.variable not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LETRULE_VALUE = mm.getFunctionByName("ASM.metamodel.LetRule.value");
if (LETRULE_VALUE==null) {
log.error("ASM metamodel element ASM.metamodel.LetRule.value not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ITERATERULE = mm.getEntityByName("ASM.metamodel.IterateRule");
if (ITERATERULE==null) {
log.error("ASM metamodel element ASM.metamodel.IterateRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULEINVOCATION = mm.getEntityByName("ASM.metamodel.GTRuleInvocation");
if (GTRULEINVOCATION==null) {
log.error("ASM metamodel element ASM.metamodel.GTRuleInvocation not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULEINVOCATION_RULE = mm.getFunctionByName("ASM.metamodel.GTRuleInvocation.rule");
if (GTRULEINVOCATION_RULE==null) {
log.error("ASM metamodel element ASM.metamodel.GTRuleInvocation.rule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULEINVOCATION_FIRSTPARAM = mm.getFunctionByName("ASM.metamodel.GTRuleInvocation.firstParam");
if (GTRULEINVOCATION_FIRSTPARAM==null) {
log.error("ASM metamodel element ASM.metamodel.GTRuleInvocation.firstParam not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
IMPLICATION = mm.getEntityByName("ASM.metamodel.Implication");
if (IMPLICATION==null) {
log.error("ASM metamodel element ASM.metamodel.Implication not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULE = mm.getEntityByName("ASM.metamodel.GTRule");
if (GTRULE==null) {
log.error("ASM metamodel element ASM.metamodel.GTRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULE_ACTION = mm.getFunctionByName("ASM.metamodel.GTRule.action");
if (GTRULE_ACTION==null) {
log.error("ASM metamodel element ASM.metamodel.GTRule.action not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULE_PRECONDITION = mm.getFunctionByName("ASM.metamodel.GTRule.precondition");
if (GTRULE_PRECONDITION==null) {
log.error("ASM metamodel element ASM.metamodel.GTRule.precondition not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULE_POSTCONDITION = mm.getFunctionByName("ASM.metamodel.GTRule.postcondition");
if (GTRULE_POSTCONDITION==null) {
log.error("ASM metamodel element ASM.metamodel.GTRule.postcondition not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULE_FIRSTPARAM = mm.getFunctionByName("ASM.metamodel.GTRule.firstParam");
if (GTRULE_FIRSTPARAM==null) {
log.error("ASM metamodel element ASM.metamodel.GTRule.firstParam not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTPATTERN = mm.getEntityByName("ASM.metamodel.GTPattern");
if (GTPATTERN==null) {
log.error("ASM metamodel element ASM.metamodel.GTPattern not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTPATTERN_PATTERNCALL = mm.getFunctionByName("ASM.metamodel.GTPattern.patternCall");
if (GTPATTERN_PATTERNCALL==null) {
log.error("ASM metamodel element ASM.metamodel.GTPattern.patternCall not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTPATTERN_CHECK = mm.getFunctionByName("ASM.metamodel.GTPattern.check");
if (GTPATTERN_CHECK==null) {
log.error("ASM metamodel element ASM.metamodel.GTPattern.check not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTPATTERN_FIRSTPARAMETER = mm.getFunctionByName("ASM.metamodel.GTPattern.firstParameter");
if (GTPATTERN_FIRSTPARAMETER==null) {
log.error("ASM metamodel element ASM.metamodel.GTPattern.firstParameter not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
FORMULA = mm.getEntityByName("ASM.metamodel.Formula");
if (FORMULA==null) {
log.error("ASM metamodel element ASM.metamodel.Formula not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
EXISTS = mm.getEntityByName("ASM.metamodel.Exists");
if (EXISTS==null) {
log.error("ASM metamodel element ASM.metamodel.Exists not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
EQUALS = mm.getEntityByName("ASM.metamodel.Equals");
if (EQUALS==null) {
log.error("ASM metamodel element ASM.metamodel.Equals not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
FORALLRULE = mm.getEntityByName("ASM.metamodel.ForallRule");
if (FORALLRULE==null) {
log.error("ASM metamodel element ASM.metamodel.ForallRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
FORALLRULE_FORMULA = mm.getFunctionByName("ASM.metamodel.ForallRule.formula");
if (FORALLRULE_FORMULA==null) {
log.error("ASM metamodel element ASM.metamodel.ForallRule.formula not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
FUNCTIONINVOCATION = mm.getEntityByName("ASM.metamodel.FunctionInvocation");
if (FUNCTIONINVOCATION==null) {
log.error("ASM metamodel element ASM.metamodel.FunctionInvocation not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
FUNCTIONINVOCATION_FIRSTPARAM = mm.getFunctionByName("ASM.metamodel.FunctionInvocation.firstParam");
if (FUNCTIONINVOCATION_FIRSTPARAM==null) {
log.error("ASM metamodel element ASM.metamodel.FunctionInvocation.firstParam not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
FUNCTIONINVOCATION_FUNCTION = mm.getFunctionByName("ASM.metamodel.FunctionInvocation.function");
if (FUNCTIONINVOCATION_FUNCTION==null) {
log.error("ASM metamodel element ASM.metamodel.FunctionInvocation.function not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GREATERTHAN = mm.getEntityByName("ASM.metamodel.GreaterThan");
if (GREATERTHAN==null) {
log.error("ASM metamodel element ASM.metamodel.GreaterThan not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ACTUALPARAMETER = mm.getEntityByName("ASM.metamodel.ActualParameter");
if (ACTUALPARAMETER==null) {
log.error("ASM metamodel element ASM.metamodel.ActualParameter not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ACTUALPARAMETER_NEXT = mm.getFunctionByName("ASM.metamodel.ActualParameter.next");
if (ACTUALPARAMETER_NEXT==null) {
log.error("ASM metamodel element ASM.metamodel.ActualParameter.next not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ACTUALPARAMETER_VALUE = mm.getFunctionByName("ASM.metamodel.ActualParameter.value");
if (ACTUALPARAMETER_VALUE==null) {
log.error("ASM metamodel element ASM.metamodel.ActualParameter.value not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ACTUALPARAMETER_VARIABLE = mm.getFunctionByName("ASM.metamodel.ActualParameter.variable");
if (ACTUALPARAMETER_VARIABLE==null) {
log.error("ASM metamodel element ASM.metamodel.ActualParameter.variable not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ENTITY = mm.getEntityByName("ASM.metamodel.Entity");
if (ENTITY==null) {
log.error("ASM metamodel element ASM.metamodel.Entity not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ELEMENTREFERENCE = mm.getEntityByName("ASM.metamodel.ElementReference");
if (ELEMENTREFERENCE==null) {
log.error("ASM metamodel element ASM.metamodel.ElementReference not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CALLRULE = mm.getEntityByName("ASM.metamodel.CallRule");
if (CALLRULE==null) {
log.error("ASM metamodel element ASM.metamodel.CallRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CALLRULE_RULE = mm.getFunctionByName("ASM.metamodel.CallRule.rule");
if (CALLRULE_RULE==null) {
log.error("ASM metamodel element ASM.metamodel.CallRule.rule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CALLRULE_FIRSTPARAMETER = mm.getFunctionByName("ASM.metamodel.CallRule.firstParameter");
if (CALLRULE_FIRSTPARAMETER==null) {
log.error("ASM metamodel element ASM.metamodel.CallRule.firstParameter not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
BINARYOPERATION = mm.getEntityByName("ASM.metamodel.BinaryOperation");
if (BINARYOPERATION==null) {
log.error("ASM metamodel element ASM.metamodel.BinaryOperation not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
BINARYOPERATION_LEFT = mm.getFunctionByName("ASM.metamodel.BinaryOperation.left");
if (BINARYOPERATION_LEFT==null) {
log.error("ASM metamodel element ASM.metamodel.BinaryOperation.left not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
BINARYOPERATION_RIGHT = mm.getFunctionByName("ASM.metamodel.BinaryOperation.right");
if (BINARYOPERATION_RIGHT==null) {
log.error("ASM metamodel element ASM.metamodel.BinaryOperation.right not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CONDITIONALRULE = mm.getEntityByName("ASM.metamodel.ConditionalRule");
if (CONDITIONALRULE==null) {
log.error("ASM metamodel element ASM.metamodel.ConditionalRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CONDITIONALRULE_CONDITION = mm.getFunctionByName("ASM.metamodel.ConditionalRule.condition");
if (CONDITIONALRULE_CONDITION==null) {
log.error("ASM metamodel element ASM.metamodel.ConditionalRule.condition not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CONDITIONALRULE_GTRULE = mm.getFunctionByName("ASM.metamodel.ConditionalRule.gtrule");
if (CONDITIONALRULE_GTRULE==null) {
log.error("ASM metamodel element ASM.metamodel.ConditionalRule.gtrule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CONDITIONALRULE_RULE1 = mm.getFunctionByName("ASM.metamodel.ConditionalRule.rule1");
if (CONDITIONALRULE_RULE1==null) {
log.error("ASM metamodel element ASM.metamodel.ConditionalRule.rule1 not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CONDITIONALRULE_RULE2 = mm.getFunctionByName("ASM.metamodel.ConditionalRule.rule2");
if (CONDITIONALRULE_RULE2==null) {
log.error("ASM metamodel element ASM.metamodel.ConditionalRule.rule2 not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ELEMENTCREATERULE = mm.getEntityByName("ASM.metamodel.ElementCreateRule");
if (ELEMENTCREATERULE==null) {
log.error("ASM metamodel element ASM.metamodel.ElementCreateRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ELEMENTCREATERULE_TYPE = mm.getFunctionByName("ASM.metamodel.ElementCreateRule.type");
if (ELEMENTCREATERULE_TYPE==null) {
log.error("ASM metamodel element ASM.metamodel.ElementCreateRule.type not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ELEMENTCREATERULE_ELEMENT = mm.getFunctionByName("ASM.metamodel.ElementCreateRule.element");
if (ELEMENTCREATERULE_ELEMENT==null) {
log.error("ASM metamodel element ASM.metamodel.ElementCreateRule.element not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ELEMENTCREATERULE_CONTAINERREF = mm.getFunctionByName("ASM.metamodel.ElementCreateRule.containerRef");
if (ELEMENTCREATERULE_CONTAINERREF==null) {
log.error("ASM metamodel element ASM.metamodel.ElementCreateRule.containerRef not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CHOOSERULE = mm.getEntityByName("ASM.metamodel.ChooseRule");
if (CHOOSERULE==null) {
log.error("ASM metamodel element ASM.metamodel.ChooseRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CHOOSERULE_FORMULA = mm.getFunctionByName("ASM.metamodel.ChooseRule.formula");
if (CHOOSERULE_FORMULA==null) {
log.error("ASM metamodel element ASM.metamodel.ChooseRule.formula not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
CONSTANT = mm.getEntityByName("ASM.metamodel.Constant");
if (CONSTANT==null) {
log.error("ASM metamodel element ASM.metamodel.Constant not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
BLOCKRULE = mm.getEntityByName("ASM.metamodel.BlockRule");
if (BLOCKRULE==null) {
log.error("ASM metamodel element ASM.metamodel.BlockRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
BLOCKRULE_RULE = mm.getFunctionByName("ASM.metamodel.BlockRule.rule");
if (BLOCKRULE_RULE==null) {
log.error("ASM metamodel element ASM.metamodel.BlockRule.rule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
BLOCKRULE_GTRULE = mm.getFunctionByName("ASM.metamodel.BlockRule.gtrule");
if (BLOCKRULE_GTRULE==null) {
log.error("ASM metamodel element ASM.metamodel.BlockRule.gtrule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ASMFUNCTION = mm.getEntityByName("ASM.metamodel.ASMFunction");
if (ASMFUNCTION==null) {
log.error("ASM metamodel element ASM.metamodel.ASMFunction not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ASMRULEINVOCATION = mm.getEntityByName("ASM.metamodel.ASMRuleInvocation");
if (ASMRULEINVOCATION==null) {
log.error("ASM metamodel element ASM.metamodel.ASMRuleInvocation not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ASMRULEINVOCATION_RULE = mm.getFunctionByName("ASM.metamodel.ASMRuleInvocation.rule");
if (ASMRULEINVOCATION_RULE==null) {
log.error("ASM metamodel element ASM.metamodel.ASMRuleInvocation.rule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ASMRULEINVOCATION_FIRSTPARAM = mm.getFunctionByName("ASM.metamodel.ASMRuleInvocation.firstParam");
if (ASMRULEINVOCATION_FIRSTPARAM==null) {
log.error("ASM metamodel element ASM.metamodel.ASMRuleInvocation.firstParam not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ELEMENTDELETERULE = mm.getEntityByName("ASM.metamodel.ElementDeleteRule");
if (ELEMENTDELETERULE==null) {
log.error("ASM metamodel element ASM.metamodel.ElementDeleteRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ELEMENTDELETERULE_ELEMENT = mm.getFunctionByName("ASM.metamodel.ElementDeleteRule.element");
if (ELEMENTDELETERULE_ELEMENT==null) {
log.error("ASM metamodel element ASM.metamodel.ElementDeleteRule.element not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ASMRULE = mm.getEntityByName("ASM.metamodel.ASMRule");
if (ASMRULE==null) {
log.error("ASM metamodel element ASM.metamodel.ASMRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ASMRULE_FIRSTPARAM = mm.getFunctionByName("ASM.metamodel.ASMRule.firstParam");
if (ASMRULE_FIRSTPARAM==null) {
log.error("ASM metamodel element ASM.metamodel.ASMRule.firstParam not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
AND = mm.getEntityByName("ASM.metamodel.And");
if (AND==null) {
log.error("ASM metamodel element ASM.metamodel.And not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ALL = mm.getEntityByName("ASM.metamodel.All");
if (ALL==null) {
log.error("ASM metamodel element ASM.metamodel.All not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RULE = mm.getRelationByName("ASM.metamodel.rule");
if (RULE==null) {
log.error("ASM metamodel element ASM.metamodel.rule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LOCATION_REL = mm.getRelationByName("ASM.metamodel.location");
if (LOCATION_REL==null) {
log.error("ASM metamodel element ASM.metamodel.location not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
NEGATIVE = mm.getRelationByName("ASM.metamodel.negative");
if (NEGATIVE==null) {
log.error("ASM metamodel element ASM.metamodel.negative not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
NEXTRULE = mm.getRelationByName("ASM.metamodel.nextRule");
if (NEXTRULE==null) {
log.error("ASM metamodel element ASM.metamodel.nextRule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
/**********************************
* MANUAL EXTENSIONS
*/
/* LEVEL_FATAL = mm.getEntityByName("ASM.metamodel.Level.fatal");
if (LEVEL_FATAL==null)
{
log.error("ASM metamodel element ASM.metamodel.level.fatal not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LEVEL_ERROR = mm.getEntityByName("ASM.metamodel.Level.error");
if (LEVEL_ERROR==null)
{
log.error("ASM metamodel element ASM.metamodel.level.error not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LEVEL_WARNING = mm.getEntityByName("ASM.metamodel.Level.warning");
if (LEVEL_WARNING==null)
{
log.error("ASM metamodel element ASM.metamodel.level.warning not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LEVEL_INFO = mm.getEntityByName("ASM.metamodel.Level.info");
if (LEVEL_INFO==null)
{
log.error("ASM metamodel element ASM.metamodel.level.info not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
LEVEL_DEBUG = mm.getEntityByName("ASM.metamodel.Level.debug");
if (LEVEL_DEBUG==null)
{
log.error("ASM metamodel element ASM.metamodel.level.debug not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
STRING = mm.getEntityByName("datatypes.String");
if (STRING==null)
{
log.error("ASM metamodel element String not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RULEDEFINITION = mm.getEntityByName("ASM.metamodel.RuleDefinition");
if (RULEDEFINITION==null)
{
log.error("ASM metamodel element ASM.metamodel.RuleDefinition not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
RULEDEFINITION_RULE = mm.getFunctionByName("ASM.metamodel.RuleDefinition.rule");
if (RULEDEFINITION_RULE==null)
{
log.error("ASM metamodel element ASM.metamodel.RuleDefinition.rule not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTPATTERNCALL = mm.getEntityByName("ASM.metamodel.GTPatternCall");
if (GTPATTERNCALL==null)
{
log.error("ASM metamodel element ASM.metamodel.GTPatternCall not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTPATTERNCALL_PATTERN = mm.getFunctionByName("ASM.metamodel.GTPatternCall.pattern");
if (GTPATTERNCALL_PATTERN==null)
{
log.error("ASM metamodel element ASM.metamodel.GTPatternCall.pattern not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTPATTERNCALL_FIRSTPARAMETER = mm.getFunctionByName("ASM.metamodel.GTPatternCall.firstParameter");
if (GTPATTERNCALL_FIRSTPARAMETER==null)
{
log.error("ASM metamodel element ASM.metamodel.GTPatternCall.firstParameter not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTPATTERNCALL_SCOPE = mm.getFunctionByName("ASM.metamodel.GTPatternCall.scope");
if (GTPATTERNCALL_SCOPE==null)
{
log.error("ASM metamodel element ASM.metamodel.GTPatternCall.scope not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTPATTERNCALL_MODE = mm.getFunctionByName("ASM.metamodel.GTPatternCall.mode");
if (GTPATTERNCALL_MODE==null)
{
log.error("ASM metamodel element ASM.metamodel.GTPatternCall.mode not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULEINVOCATION_SCOPE = mm.getFunctionByName("ASM.metamodel.GTRuleInvocation.scope");
if (GTRULEINVOCATION_SCOPE==null)
{
log.error("ASM metamodel element ASM.metamodel.GTRuleInvocation.scope not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
GTRULEINVOCATION_MODE = mm.getFunctionByName("ASM.metamodel.GTRuleInvocation.mode");
if (GTRULEINVOCATION_MODE==null)
{
log.error("ASM metamodel element ASM.metamodel.GTRuleInvocation.mode not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SCOPEDPARAMETER = mm.getEntityByName("ASM.metamodel.ScopedParameter");
if (SCOPEDPARAMETER==null)
{
log.error("ASM metamodel element ASM.metamodel.ScopedParameter not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SCOPEDPARAMETER_BASE = mm.getFunctionByName("ASM.metamodel.ScopedParameter.base");
if (SCOPEDPARAMETER_BASE==null)
{
log.error("ASM metamodel element ASM.metamodel.ScopedParameter.base not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SCOPEDPARAMETER_NEXT = mm.getFunctionByName("ASM.metamodel.ScopedParameter.next");
if (SCOPEDPARAMETER_NEXT==null)
{
log.error("ASM metamodel element ASM.metamodel.ScopedParameter.next not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SCOPEDPARAMETER_MODE = mm.getFunctionByName("ASM.metamodel.ScopedParameter.mode");
if (SCOPEDPARAMETER_MODE==null)
{
log.error("ASM metamodel element ASM.metamodel.ScopedParameter.mode not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
SCOPEDPARAMETER_NAME = mm.getFunctionByName("ASM.metamodel.ScopedParameter.name");
if (SCOPEDPARAMETER_NAME==null)
{
log.error("ASM metamodel element ASM.metamodel.ScopedParameter.name not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
BLOCKRULE_FIRSTVARIABLE = mm.getFunctionByName("ASM.metamodel.BlockRule.firstVariable");
if (BLOCKRULE_FIRSTVARIABLE==null)
{
log.error("ASM metamodel element ASM.metamodel.BlockRule.firstVariable not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}
ANNOTATION = mm.getFunctionByName("ASM.metamodel.Annotation");
if (ANNOTATION==null)
{
log.error("ASM metamodel element ASM.metamodel.Annotation not found.");
throw new VPMRuntimeException("Metamodel incomplete.");
}*/
}
/*
* IEntity SCOPEDPARAMETER = null;
IFunction SCOPEDPARAMETER_NAME = null;
IFunction SCOPEDPARAMETER_MODE = null;
IFunction SCOPEDPARAMETER_NEXT = null;
IFunction SCOPEDPARAMETER_BASE = null;
*/
IEntity machine;
ASTBuilder ab;
public ASTBuilder getASTBuilder()
{
return ab;
}
/* public IEntity newConstant( String name)
{
try
{
IEntity e = mm.newEntity(currentContainer());
mm.newInstanceOf(CONSTANT,e);
mm.setValue(e,name);
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newVariableTerm( String name)
{
try
{
IEntity e = mm.newEntity(currentContainer());
mm.newInstanceOf(VARIABLE,e);
mm.setValue(e,name);
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newElementReferenceTerm( String name)
{
try
{
IEntity e = mm.newEntity(currentContainer());
mm.newInstanceOf(ELEMENTREFERENCE,e);
mm.setValue(e,name);
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newRelationalOp(int li,String op, TermDef l, TermDef r)
{
try
{
IEntity e = mm.newEntity(currentContainer());
addContainer(e);
generateAnnotation(li);
if (op.equals("==")) mm.newInstanceOf(EQUALS,e);
if (op.equals("!=")) mm.newInstanceOf(NOTEQUALS,e);
if (op.equals("<")) mm.newInstanceOf(LESSTHAN,e);
if (op.equals(">")) mm.newInstanceOf(GREATERTHAN,e);
if (op.equals("")) mm.newInstanceOf(VARIABLE,e);
mm.setValue(e,op);
IFunction fl = mm.newFunction(e,l.getElement(),currentContainer());
mm.newInstanceOf(RELATIONALOPERATION_LEFTSIDE,fl);
IFunction fr = mm.newFunction(e,r.getElement(),currentContainer());
mm.newInstanceOf(RELATIONALOPERATION_RIGHTSIDE,fr);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newBinaryOp(int li,String op, FormulaDef l, FormulaDef r)
{
try
{
IEntity e = mm.newEntity(currentContainer());
addContainer(e);
generateAnnotation(li);
if (op.equals("&&")) mm.newInstanceOf(AND,e);
if (op.equals("||")) mm.newInstanceOf(OR,e);
if (op.equals("->")) mm.newInstanceOf(IMPLICATION,e);
mm.setValue(e,op);
IFunction fl = mm.newFunction(e,l.getElement(),currentContainer());
mm.newInstanceOf(BINARYOPERATION_LEFT,fl);
IFunction fr = mm.newFunction(e,r.getElement(),currentContainer());
mm.newInstanceOf(BINARYOPERATION_RIGHT,fr);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public boolean checkMachine(String n, Vector funs, Vector rules,Vector patts, Vector gtrules)
{
try
{
Iterator i = rules.iterator();
while (i.hasNext())
{
ASMRuleDef a = (ASMRuleDef)i.next();
if (!a.checkDefintion(ab,modsp)) return false;
}
i = patts.iterator();
while (i.hasNext())
{
GTPatternDef a = (GTPatternDef)i.next();
if (!a.checkDefintion(ab,modsp)) return false;
}
i = gtrules.iterator();
while (i.hasNext())
{
GTRuleDef a = (GTRuleDef)i.next();
if (!a.checkDefintion(ab,modsp)) return false;
}
return true;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return false;
}
}
IEntity implicit = null;
public IEntity newGTPatternCall(int li,GTPatternDef pn, Vector pars,TermDef scope, int mode)
{
try
{
IEntity e = mm.newEntity(currentContainer());
addContainer(e);
generateAnnotation(li);
mm.newInstanceOf(GTPATTERNCALL,e);
IFunction fup = mm.newFunction(e,pn.getElement(),e);
mm.newInstanceOf(GTPATTERNCALL_PATTERN,fup);
if (scope!=null)
{
IFunction scopf = mm.newFunction(e,scope.getElement(),e);
mm.newInstanceOf(GTPATTERNCALL_SCOPE,scopf);
String s = "below";
if (mode==1) s = "in";
IEntity mod = mm.newEntity(e);
mm.newInstanceOf(STRING,mod);
mm.setValue(mod,s);
IFunction modf = mm.newFunction(e,mod,e);
mm.newInstanceOf(GTPATTERNCALL_MODE,modf);
}
if (pars!=null)
{
IEntity old = null;
for (int i=0;i<pars.size();i++)
{
TermDef t = (TermDef)pars.get(i);
if (i==0)
{
IEntity ee = mm.newEntity(e);
addContainer(ee);
mm.newInstanceOf(ACTUALPARAMETER,ee);
IFunction pv = mm.newFunction(ee,t.getElement(),currentContainer());
mm.newInstanceOf(ACTUALPARAMETER_VALUE,pv);
IFunction fir = mm.newFunction(e,ee,e);
mm.newInstanceOf(GTPATTERNCALL_FIRSTPARAMETER,fir);
old = ee;
removeContainer();
}
else
{
IEntity ee = mm.newEntity(e);
addContainer(ee);
mm.newInstanceOf(ACTUALPARAMETER,ee);
IFunction pv = mm.newFunction(ee,t.getElement(),currentContainer());
mm.newInstanceOf(ACTUALPARAMETER_VALUE,pv);
IFunction fir = mm.newFunction(old,ee,old);
mm.newInstanceOf(ACTUALPARAMETER_NEXT,fir);
old = ee;
removeContainer();
}
}
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newGTRuleCall(int li,GTRuleDef pn, Vector pars,TermDef scope, int mode)
{
try
{
IEntity e = mm.newEntity(currentContainer());
addContainer(e);
generateAnnotation(li);
mm.newInstanceOf(GTRULEINVOCATION,e);
IEntity gtrule_inv;
if ((machine.getContentByName(pn.getName())!=null) && (machine.getContentByName(pn.getName()) instanceof IEntity)) gtrule_inv=(IEntity)machine.getContentByName(pn.getName()); else gtrule_inv = pn.getElement();
IFunction fup = mm.newFunction(e,gtrule_inv,e);
mm.newInstanceOf(GTRULEINVOCATION_RULE,fup);
if (scope!=null)
{
IFunction scopf = mm.newFunction(e,scope.getElement(),e);
mm.newInstanceOf(GTRULEINVOCATION_SCOPE,scopf);
String s = "below";
if (mode==1) s = "in";
IEntity mod = mm.newEntity(e);
mm.newInstanceOf(STRING,mod);
mm.setValue(mod,s);
IFunction modf = mm.newFunction(e,mod,e);
mm.newInstanceOf(GTRULEINVOCATION_MODE,modf);
}
if (pars!=null)
{
IEntity old = null;
for (int i=0;i<pars.size();i++)
{
TermDef t = (TermDef)pars.get(i);
if (i==0)
{
IEntity ee = mm.newEntity(e);
addContainer(ee);
mm.newInstanceOf(ACTUALPARAMETER,ee);
IFunction pv = mm.newFunction(ee,t.getElement(),e);
mm.newInstanceOf(ACTUALPARAMETER_VALUE,pv);
IFunction fir = mm.newFunction(e,ee,ee);
mm.newInstanceOf(GTRULEINVOCATION_FIRSTPARAM,fir);
old = ee;
removeContainer();
}
else
{
IEntity ee = mm.newEntity(e);
addContainer(ee);
mm.newInstanceOf(ACTUALPARAMETER,ee);
IFunction pv = mm.newFunction(ee,t.getElement(),e);
mm.newInstanceOf(ACTUALPARAMETER_VALUE,pv);
IFunction fir = mm.newFunction(old,ee,e);
mm.newInstanceOf(ACTUALPARAMETER_NEXT,fir);
old = ee;
removeContainer();
}
}
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
Stack actpatt = new Stack();
public IEntity currentPattern()
{
if (actpatt.isEmpty()) return null;
return (IEntity)actpatt.peek();
}
public void addPattern(IEntity e)
{
actpatt.push(e);
}
public void removePattern()
{
if (!actpatt.isEmpty()) actpatt.pop();
}
public IEntity newGTPattern(int li,String n, Vector par, GTPatternCallDef cal, FormulaDef check, Vector negc, Vector negp, Vector el)
{
try
{
IEntity e;
if (currentPattern()!=null)
{
e = mm.newEntity(n,currentPattern());
}
else
{
if (act_gtrule!=null) e = mm.newEntity(n,act_gtrule);
else e = mm.newEntity(n,machine);
}
addContainer(e);
addPattern(e);
generateAnnotation(li);
mm.newInstanceOf(GTPATTERN,e);
if (cal!=null)
{
IFunction caf = mm.newFunction(e,cal.getElement(),e);
mm.newInstanceOf(GTPATTERN_PATTERNCALL,caf);
}
if (check!=null)
{
IFunction cef = mm.newFunction(e,check.getElement(),e);
mm.newInstanceOf(GTPATTERN_CHECK,cef);
}
if (par!=null)
{
generateGTParlist(par,e);
}
if (negc!=null)
{
Iterator i = negc.iterator();
while (i.hasNext())
{
GTPatternCallDef cd = (GTPatternCallDef)i.next();
IRelation nege = mm.newRelation(e,cd.getElement(),e);
mm.newInstanceOf(NEGATIVE,nege);
}
}
if (negp!=null)
{
Iterator i = negp.iterator();
while (i.hasNext())
{
GTPatternDef cd = (GTPatternDef)i.next();
IEntity npp = mm.newEntity(e);
mm.newInstanceOf(GTPATTERNCALL,npp);
IFunction fnpp = mm.newFunction(npp,cd.getElement(),npp);
mm.newInstanceOf(GTPATTERNCALL_PATTERN,fnpp);
IRelation nege = mm.newRelation(e,npp,e);
mm.newInstanceOf(NEGATIVE,nege);
}
}
actcont = mm.newEntity("pattern",currentContainer());
actset=el;
Iterator i = el.iterator();
while (i.hasNext())
{
Object o = i.next();
if (o instanceof EntityDefinition)
{
EntityDefinition ed = (EntityDefinition)o;
newEntityInPattern(ed);
continue;
}
if (o instanceof RelationDefinition)
{
RelationDefinition r = (RelationDefinition)o;
newRelationInPattern(r);
continue;
}
}
i = el.iterator();
while (i.hasNext())
{
Object o = i.next();
if (o instanceof TypeDefinition)
{
TypeDefinition d = (TypeDefinition)o;
// if (!elementExists(d.getMaster()) && (!ab.elementExists("",d.getMaster())))
IModelElement mast = mm.getElementByName(d.getMaster());
if (mast==null) mast = mm.getElementByName(actcont.getFullyQualifiedName()+"."+d.getMaster());
IModelElement slav = mm.getElementByName(d.getSlave());
if (slav==null) slav = mm.getElementByName(actcont.getFullyQualifiedName()+"."+d.getSlave());
if ((mast==null) || (slav==null))
{
log.error("model integrity error while creating relationships.");
return null;
}
try
{
mm.newInstanceOf(mast,slav);
}
catch (Exception exe)
{
log.error("Problems with instanceof! master: "+mast.getFullyQualifiedName()+" slave: "+slav.getFullyQualifiedName());
}
continue;
}
if (o instanceof SupertypeDefinition)
{
SupertypeDefinition d = (SupertypeDefinition)o;
IModelElement mast = mm.getElementByName(d.getMaster());
if (mast==null) mast = mm.getElementByName(actcont.getFullyQualifiedName()+"."+d.getMaster());
IModelElement slav = mm.getElementByName(d.getSlave());
if (slav==null) slav = mm.getElementByName(actcont.getFullyQualifiedName()+"."+d.getSlave());
if ((mast==null) || (slav==null))
{
log.error("model integrity error while creating relationships.");
return null;
}
mm.newSupertypeOf(mast,slav);
continue;
}
if (o instanceof ContainmentDefinition)
{
ContainmentDefinition d = (ContainmentDefinition)o;
IModelElement mast = mm.getElementByName(d.getMaster());
if (mast==null) mast = mm.getElementByName(actcont.getFullyQualifiedName()+"."+d.getMaster());
IModelElement slav = mm.getElementByName(d.getSlave());
if (slav==null) slav = mm.getElementByName(actcont.getFullyQualifiedName()+"."+d.getSlave());
if ((mast==null) || (slav==null) || (!(mast instanceof IEntity)))
{
log.error("model integrity error while creating relationships.");
return null;
}
mm.newContainment((IEntity)mast,slav);
continue;
}
}
removeContainer();
removePattern();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}*/
IEntity actcont;
Vector actset;
//public IEntity lookupEntity(Vector el, )
public EntityDefinition lookupEntityByName(String n)
{
Iterator i = actset.iterator();
while (i.hasNext())
{
Object o = i.next();
if (o instanceof EntityDefinition)
{
EntityDefinition e = (EntityDefinition)o;
if (e.getFQN().equals(n)) return e;
if (e.getName().equals(n)) return e;
}
}
return null;
}
public RelationDefinition lookupRelationByName(String n)
{
Iterator i = actset.iterator();
while (i.hasNext())
{
Object o = i.next();
if (o instanceof RelationDefinition)
{
RelationDefinition e = (RelationDefinition)o;
if (e.getFQN().equals(n)) return e;
if (e.getName().equals(n)) return e;
}
}
return null;
}
/* public IEntity newEntityInPattern(EntityDefinition d)
{
try{
IEntity e = mm.getEntityByName(actcont.getFullyQualifiedName()+"."+d.getFQN());
if (e==null)
{
StringTokenizer st = new StringTokenizer(d.getFQN(),".");
IEntity base = actcont;
String z = "";
while (st.hasMoreTokens())
{
String s = st.nextToken();
if (!z.equals("")) z=z+"."+s; else z=s;
IModelElement tmp = base.getContentByName(s);
if ((tmp!=null) && (tmp instanceof IEntity))
{
base = (IEntity)tmp;
}
else
{
base = mm.newEntity(s,base);
IEntity typ = mm.getEntityByName(lookupEntityByName(z).getType());
if (typ==null) typ=newEntityInPattern(lookupEntityByName(z));
mm.newInstanceOf(typ,base);
}
}
e = base;
log.debug("Created entity name = "+z+" in container "+base.getName());
}
return e;
} catch (VPMCoreException e)
{
e.printStackTrace();
log.error("Error creating pattern elements.");
return null;
}
}
public EntityDefinition lookupPatternEntityByName(String n)
{
Iterator i = actset.iterator();
while (i.hasNext())
{
Object o = i.next();
if (o instanceof EntityDefinition)
{
EntityDefinition e = (EntityDefinition)o;
log.debug("Looking up "+n+", currently found : "+e.getFQN());
if (e.getFQN().equals(n)) return e;
if (e.getName().equals(n)) return e;
}
}
return null;
}
public IRelation newRelationInPattern(RelationDefinition d)
{
try{
IRelation e = mm.getRelationByName(actcont.getFullyQualifiedName()+"."+d.getFQN());
if (e==null) e = mm.getFunctionByName(actcont.getFullyQualifiedName()+"."+d.getFQN());
if (e==null)
{
StringTokenizer st = new StringTokenizer(d.getFQN(),".");
IEntity base = actcont;
String z="";
String s = d.getName();
if (s.indexOf(".")>0) s = s.substring(s.lastIndexOf(".")+1);
//Lookup container
z = d.getNamespace();
if (!z.equals(""))
{
EntityDefinition edtmp = lookupPatternEntityByName(z);
base = newEntityInPattern(edtmp);
}
//Check whether the relation already exists in the container
IRelation rel = base.getRelationByName(s);
if (rel==null) rel = base.getFunctionByName(s);
if (rel==null) //No, create it
{
//Looking up type element
IRelation typ = mm.getRelationByName(d.getType());
if (typ==null) typ=mm.getFunctionByName(d.getType());
//Type does not exists, let's create it
if (typ==null)
{
typ = newRelationInPattern(lookupRelationByName(z));
}
//Looking up source
IEntity src = mm.getEntityByName(d.getSource());
if (src==null) src = newEntityInPattern(lookupPatternEntityByName(d.getSource()));
//Looking up target
IEntity trg = mm.getEntityByName(d.getTarget());
if (trg==null) trg = newEntityInPattern(lookupPatternEntityByName(d.getTarget()));
//Creating the new element
if (typ instanceof IFunction)
{
rel = mm.newFunction(s,src,trg,base);
}
else
{
rel = mm.newRelation(s,src,trg,base);
}
mm.newInstanceOf(typ,rel);
e = rel;
}
log.debug("Created relation name = "+z+" in container "+base.getName());
}
return e;
} catch (VPMCoreException e)
{
e.printStackTrace();
log.error("Error creating pattern elements.");
return null;
}
}
IEntity act_gtrule = null;
public IEntity newGTRule(GTRuleDef gtr)
{
try
{
IEntity e = mm.newEntity(gtr.getName(),machine);
mm.newInstanceOf(GTRULE,e);
addContainer(e);
generateAnnotation(gtr.getLine());
if (gtr.getParameters()!=null) generateGTRuleParlist(gtr.getParameters(),e);
act_gtrule = e;
if (gtr.getPrecondcall()!=null)
{
IFunction nege = mm.newFunction(e,gtr.getPrecondcall().getElement(),e);
mm.newInstanceOf(GTRULE_PRECONDITION,nege);
}
if (gtr.getPrecondpatt()!=null)
{
IEntity npp = mm.newEntity(e);
mm.newInstanceOf(GTPATTERNCALL,npp);
IFunction fnpp = mm.newFunction(npp,gtr.getPrecondpatt().getElement(),npp);
mm.newInstanceOf(GTPATTERNCALL_PATTERN,fnpp);
IFunction nege = mm.newFunction(e,npp,e);
mm.newInstanceOf(GTRULE_PRECONDITION,nege);
}
if (gtr.getPostcondcall()!=null)
{
IFunction nege = mm.newFunction(e,gtr.getPostcondcall().getElement(),e);
mm.newInstanceOf(GTRULE_POSTCONDITION,nege);
}
if (gtr.getPostcondpatt()!=null)
{
IEntity npp = mm.newEntity(e);
mm.newInstanceOf(GTPATTERNCALL,npp);
IFunction fnpp = mm.newFunction(npp,gtr.getPostcondpatt().getElement(),npp);
mm.newInstanceOf(GTPATTERNCALL_PATTERN,fnpp);
IFunction nege = mm.newFunction(e,npp,e);
mm.newInstanceOf(GTRULE_POSTCONDITION,nege);
}
if (gtr.getActions()!=null)
{
IEntity seqr = newSequentialRule(gtr.getLine(),null,null,gtr.getActions());
IFunction acfu = mm.newFunction(e,seqr,e);
mm.newInstanceOf(GTRULE_ACTION,acfu);
}
removeContainer();
act_gtrule = null;
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newMachine(String n, Vector funs, Vector rules, Vector gtpatterns, Vector gtrules)
{
try
{
IEntity e;
e = null;
IEntity base = null;
StringTokenizer st = new StringTokenizer(n,".");
while (st.hasMoreTokens())
{
String s = st.nextToken();
IEntity nb = null;
if (base==null)
{
nb = mm.getEntityByName(s);
}
else
{
nb = mm.getEntityByName(base.getFullyQualifiedName()+"."+s);
}
if (nb==null)
{
if (base == null)
nb = mm.newEntity(s);
else
nb = mm.newEntity(s,base);
}
base = nb;
}
e = base;
log.debug("Creating machine : "+e.getName());
mm.newInstanceOf(mm.getEntityByName("ASM"),e);
machine = e;
implicit = mm.newEntity("implicits",e);
addContainer(e);
Iterator i = funs.iterator();
while (i.hasNext())
{
ASMFunction af = (ASMFunction)i.next();
log.debug("processing asmfunction "+af.getName()+" at line "+af.getLine());
af.updateModelspace(ab,modsp);
}
i = gtpatterns.iterator();
while (i.hasNext())
{
GTPatternDef a = (GTPatternDef)i.next();
if (!a.isEmbedded())
{
log.debug("processing pattern "+a.getName()+" at line "+a.getLine());
a.updateModelspace(ab,modsp);
}
}
i = gtrules.iterator();
while (i.hasNext())
{
GTRuleDef a = (GTRuleDef)i.next();
log.debug("processing gtrule "+a.getName()+" at line "+a.getLine());
a.updateModelspace(ab,modsp);
}
i = rules.iterator();
while (i.hasNext())
{
ASMRuleDef a = (ASMRuleDef)i.next();
if (a.getName()!=null)
{
log.debug("processing rule "+a.getName()+" at line "+a.getLine());
a.updateModelspace(ab,modsp);
}
}
removeContainer();
machine=null;
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newConditionalRule(int li,String n,Vector rp, FormulaDef f, GTRuleCallDef gt, ASMRuleDef rule1, ASMRuleDef rule2)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(CONDITIONALRULE,e);
addContainer(e);
generateAnnotation(li);
if (f!=null)
{
IFunction fl = mm.newFunction(e,f.getElement(),currentContainer());
mm.newInstanceOf(CONDITIONALRULE_CONDITION,fl);
}
else
{
IFunction fl = mm.newFunction(e,gt.getElement(),currentContainer());
mm.newInstanceOf(CONDITIONALRULE_GTRULE,fl);
}
IEntity ri;
if (rule1 instanceof CallRule)
{
ri = rule1.getElement();
}
else
{
ri = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,rule1.getElement(),ri);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif);
}
IFunction fr1 = mm.newFunction(e,ri,currentContainer());
mm.newInstanceOf(CONDITIONALRULE_RULE1,fr1);
if (rule2!=null)
{
IEntity ri2;
if (rule2 instanceof CallRule)
{
ri2 = rule2.getElement();
}
else
{
ri2 = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri2);
IFunction rif2 = mm.newFunction(ri2,rule2.getElement(),ri2);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif2);
}
IFunction fr2 = mm.newFunction(e,ri2,currentContainer());
mm.newInstanceOf(CONDITIONALRULE_RULE2,fr2);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newPrintRule(int li,String n,Vector rp, TermDef t)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(PRINTRULE,e);
addContainer(e);
generateAnnotation(li);
IFunction fl = mm.newFunction(e,t.getElement(),currentContainer());
mm.newInstanceOf(PRINTRULE_OUT,fl);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public void generateGTRuleParlist(Vector rp, IEntity e) throws VPMCoreException
{
if (rp!=null)
{
IEntity oldpar = null;
for (int j=0;j<rp.size();j++)
{
RuleParameter rupa = (RuleParameter)rp.get(j);
IEntity newpar = mm.newEntity(e);
addContainer(newpar);
mm.newInstanceOf(RULEPARAMETER,newpar);
IEntity pardir = mm.newEntity(newpar);
mm.newInstanceOf(STRING,pardir);
mm.setValue(pardir,rupa.getDirection());
IFunction pardirf = mm.newFunction(newpar,pardir,newpar);
mm.newInstanceOf(RULEPARAMETER_DIRECTION,pardirf);
IFunction parvarf = mm.newFunction(newpar,newVariableTerm(rupa.getVariable()),newpar);
mm.newInstanceOf(RULEPARAMETER_VARIABLE,parvarf);
removeContainer();
if (j==0)
{
IFunction firpar = mm.newFunction(e,newpar,e);
mm.newInstanceOf(GTRULE_FIRSTPARAM,firpar);
}
else
{
IFunction firpar = mm.newFunction(oldpar,newpar,oldpar);
mm.newInstanceOf(RULEPARAMETER_NEXTPARAM,firpar);
}
oldpar= newpar;
}
}
}
public void generateParlist(Vector rp, IEntity e) throws VPMCoreException
{
if (rp!=null)
{
IEntity oldpar = null;
for (int j=0;j<rp.size();j++)
{
RuleParameter rupa = (RuleParameter)rp.get(j);
IEntity newpar = mm.newEntity(e);
addContainer(newpar);
mm.newInstanceOf(RULEPARAMETER,newpar);
IEntity pardir = mm.newEntity(newpar);
mm.newInstanceOf(STRING,pardir);
mm.setValue(pardir,rupa.getDirection());
IFunction pardirf = mm.newFunction(newpar,pardir,newpar);
mm.newInstanceOf(RULEPARAMETER_DIRECTION,pardirf);
IFunction parvarf = mm.newFunction(newpar,newVariableTerm(rupa.getVariable()),newpar);
mm.newInstanceOf(RULEPARAMETER_VARIABLE,parvarf);
removeContainer();
if (j==0)
{
IFunction firpar = mm.newFunction(e,newpar,e);
mm.newInstanceOf(ASMRULE_FIRSTPARAM,firpar);
}
else
{
IFunction firpar = mm.newFunction(oldpar,newpar,oldpar);
mm.newInstanceOf(RULEPARAMETER_NEXTPARAM,firpar);
}
oldpar= newpar;
}
}
}
public void generateGTParlist(Vector rp, IEntity e) throws VPMCoreException
{
if (rp!=null)
{
IEntity oldpar = null;
for (int j=0;j<rp.size();j++)
{
String rupa = (String)rp.get(j);
IEntity newpar = mm.newEntity(e);
addContainer(newpar);
mm.newInstanceOf(RULEPARAMETER,newpar);
IFunction parvarf = mm.newFunction(newpar,newVariableTerm(rupa),newpar);
mm.newInstanceOf(RULEPARAMETER_VARIABLE,parvarf);
removeContainer();
if (j==0)
{
IFunction firpar = mm.newFunction(e,newpar,e);
mm.newInstanceOf(GTPATTERN_FIRSTPARAMETER,firpar);
}
else
{
IFunction firpar = mm.newFunction(oldpar,newpar,oldpar);
mm.newInstanceOf(RULEPARAMETER_NEXTPARAM,firpar);
}
oldpar= newpar;
}
}
}
public void generateAnnotation(int i) throws VPMCoreException
{
IEntity e = mm.newEntity(currentContainer());
mm.newInstanceOf(STRING,e);
mm.setValue(e,"line:"+i);
IFunction an = mm.newFunction(currentContainer(),e,currentContainer());
mm.newInstanceOf(ANNOTATION,an);
}
public IEntity newLogRule(int li,String n,Vector rp, int l,TermDef t)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(LOGRULE,e);
addContainer(e);
generateAnnotation(li);
IEntity lev = mm.newEntity(currentContainer());
switch (l)
{
case 1 :
{
mm.newInstanceOf(LEVEL_FATAL,lev);
break;
}
case 2 :
{
mm.newInstanceOf(LEVEL_ERROR,lev);
break;
}
case 3 :
{
mm.newInstanceOf(LEVEL_WARNING,lev);
break;
}
case 4 :
{
mm.newInstanceOf(LEVEL_INFO,lev);
break;
}
case 5 :
{
mm.newInstanceOf(LEVEL_DEBUG,lev);
break;
}
}
IFunction fl = mm.newFunction(e,t.getElement(),currentContainer());
mm.newInstanceOf(LOGRULE_OUT,fl);
IFunction fle = mm.newFunction(e,lev,currentContainer());
mm.newInstanceOf(LOGRULE_LEVEL,fle);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newSkipRule(int li, String n,Vector rp)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(SKIPRULE,e);
addContainer(e);
generateAnnotation(li);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity createScopedList(Vector v) throws VPMCoreException
{
if (v==null) return null;
IEntity first = null;
IEntity old = null;
for (int i=0;i<v.size();i++)
{
ScopedParameter sp = (ScopedParameter)v.get(i);
if (i==0)
{
IEntity tmp = mm.newEntity(currentContainer());
mm.newInstanceOf(SCOPEDPARAMETER,tmp);
addContainer(tmp);
if (sp.getTerm()!=null)
{
String m = "in";
if (sp.getMode()==2) m = "below";
IEntity mo = mm.newEntity(m,currentContainer());
mm.newInstanceOf(STRING,mo);
IFunction mf = mm.newFunction(tmp,mo,currentContainer());
mm.newInstanceOf(SCOPEDPARAMETER_MODE,mf);
IFunction tf = mm.newFunction(tmp,sp.getTerm().getElement(),currentContainer());
mm.newInstanceOf(SCOPEDPARAMETER_BASE,tf);
}
IEntity na = mm.newEntity(sp.getVariable(),currentContainer());
mm.newInstanceOf(STRING,na);
IFunction nf = mm.newFunction(tmp,na,currentContainer());
mm.newInstanceOf(SCOPEDPARAMETER_NAME,nf);
old = tmp;
first = tmp;
removeContainer();
}
else
{
IEntity tmp = mm.newEntity(currentContainer());
mm.newInstanceOf(SCOPEDPARAMETER,tmp);
addContainer(tmp);
if (sp.getTerm()!=null)
{
String m = "in";
if (sp.getMode()==2) m = "below";
IEntity mo = mm.newEntity(m,currentContainer());
mm.newInstanceOf(STRING,mo);
IFunction mf = mm.newFunction(tmp,mo,currentContainer());
mm.newInstanceOf(SCOPEDPARAMETER_MODE,mf);
IFunction tf = mm.newFunction(tmp,sp.getTerm().getElement(),currentContainer());
mm.newInstanceOf(SCOPEDPARAMETER_BASE,tf);
}
IEntity na = mm.newEntity(sp.getVariable(),currentContainer());
mm.newInstanceOf(STRING,na);
IFunction nf = mm.newFunction(tmp,na,currentContainer());
mm.newInstanceOf(SCOPEDPARAMETER_NAME,nf);
IFunction xf = mm.newFunction(old,tmp,old);
mm.newInstanceOf(SCOPEDPARAMETER_NEXT,xf);
old = tmp;
removeContainer();
}
}
return first;
}
public IEntity newForallRule(int li,String n, Vector rp,Vector vars, int mod, TermDef base, FormulaDef fo, ASMRuleDef r, GTRuleCallDef gt)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(FORALLRULE,e);
addContainer(e);
generateAnnotation(li);
if (vars!=null)
{
IEntity vl = createScopedList(vars);
IFunction vf = mm.newFunction(e,vl,currentContainer());
mm.newInstanceOf(BLOCKRULE_FIRSTVARIABLE,vf);
}
/*
for (int i=0;i<vars.size();i++)
{
String va = (String)vars.get(i);
IRelation fu = mm.newRelation(e,newVariableTerm(va),currentContainer());
mm.newInstanceOf(VARIABLE_FORALL,fu);
}*//*
if (fo!=null)
{
IFunction form = mm.newFunction(e,fo.getElement(),e);
mm.newInstanceOf(FORALLRULE_FORMULA,form);
}
if (r!=null)
{
IEntity ri;
if (r instanceof CallRule)
{
ri = r.getElement();
}
else
{
ri = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,r.getElement(),ri);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif);
}
IFunction fu = mm.newFunction(e,ri,currentContainer());
mm.newInstanceOf(BLOCKRULE_RULE,fu);
}
else
{
//IEntity ri = mm.newEntity(currentContainer());
//mm.newInstanceOf(GTRULEINVOCATION,ri);
//IFunction rif = mm.newFunction(ri,gt.getElement(),ri);
//mm.newInstanceOf(GTRULEINVOCATION_RULE,rif);
IFunction fu = mm.newFunction(e,gt.getElement(),currentContainer());
mm.newInstanceOf(BLOCKRULE_GTRULE,fu);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newManipNewEntityRule(NewEntityRule r)
{
try
{
IEntity e;
if (r.getName()==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(r.getName(),machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(r.getVarlist(),rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(ELEMENTCREATERULE,e);
addContainer(e);
generateAnnotation(r.getLine());
//IEntity typ = mm.newEntity(e);
//mm.setValue(typ,r.getTyperef());
//mm.newInstanceOf(ELEMENTREFERENCE,typ);
IFunction typr = mm.newFunction(e,r.getTyperef().getElement(),e);
mm.newInstanceOf(ELEMENTCREATERULE_TYPE,typr);
IFunction nam = mm.newFunction(e,r.getElname().getElement(),e);
mm.newInstanceOf(ELEMENTCREATERULE_ELEMENT,nam);
if (r.getContainer()!=null)
{
IFunction con = mm.newFunction(e,r.getContainer().getElement(),e);
mm.newInstanceOf(ELEMENTCREATERULE_CONTAINERREF,con);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newManipNewRelationshipRule(NewRelationshipRule r)
{
try
{
IEntity e;
if (r.getName()==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(r.getName(),machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(r.getVarlist(),rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(RELATIONSHIPCREATERULE,e);
addContainer(e);
generateAnnotation(r.getLine());
IEntity typ = mm.newEntity(e);
mm.setValue(typ,r.getReltype());
if (r.getReltype().equals("instanceOf")) mm.newInstanceOf(RELATIONSHIPTYPE.getContentByName("instanceOf"),typ);
if (r.getReltype().equals("supertypeOf")) mm.newInstanceOf(RELATIONSHIPTYPE.getContentByName("supertypeOf"),typ);
if (r.getReltype().equals("contains")) mm.newInstanceOf(RELATIONSHIPTYPE.getContentByName("contains"),typ);
IFunction typr = mm.newFunction(e,typ,e);
mm.newInstanceOf(RELATIONSHIPCREATERULE_TYPE,typr);
IFunction supe = mm.newFunction(e,r.getSup().getElement(),e);
mm.newInstanceOf(RELATIONSHIPCREATERULE_FROMREF,supe);
IFunction slave = mm.newFunction(e,r.getSlav().getElement(),e);
mm.newInstanceOf(RELATIONSHIPCREATERULE_TOREF,slave);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newManipDeleteRelationshipRule(DeleteRelationshipRule r)
{
try
{
IEntity e;
if (r.getName()==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(r.getName(),machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(r.getVarlist(),rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(RELATIONSHIPDELETERULE,e);
addContainer(e);
generateAnnotation(r.getLine());
IEntity typ = mm.newEntity(e);
mm.setValue(typ,r.getReltype());
if (r.getReltype().equals("instanceOf")) mm.newInstanceOf(RELATIONSHIPTYPE.getContentByName("instanceOf"),typ);
if (r.getReltype().equals("supertypeOf")) mm.newInstanceOf(RELATIONSHIPTYPE.getContentByName("supertypeOf"),typ);
if (r.getReltype().equals("contains")) mm.newInstanceOf(RELATIONSHIPTYPE.getContentByName("contains"),typ);
IFunction typr = mm.newFunction(e,typ,e);
mm.newInstanceOf(RELATIONSHIPDELETERULE_TYPE,typr);
IFunction supe = mm.newFunction(e,r.getSup().getElement(),e);
mm.newInstanceOf(RELATIONSHIPDELETERULE_FROM,supe);
IFunction slave = mm.newFunction(e,r.getSlav().getElement(),e);
mm.newInstanceOf(RELATIONSHIPDELETERULE_TO,slave);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newManipDeleteElementRule(DeleteElementRule r)
{
try
{
IEntity e;
if (r.getName()==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(r.getName(),machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(r.getVarlist(),rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(ELEMENTDELETERULE,e);
addContainer(e);
generateAnnotation(r.getLine());
IFunction typr = mm.newFunction(e,r.getElemref().getElement(),e);
mm.newInstanceOf(ELEMENTDELETERULE_ELEMENT,typr);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newManipSetValueRule(SetValueRule r)
{
try
{
IEntity e;
if (r.getName()==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(r.getName(),machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(r.getVarlist(),rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(SETVALUERULE,e);
addContainer(e);
generateAnnotation(r.getLine());
IFunction typr = mm.newFunction(e,r.getElemref().getElement(),e);
mm.newInstanceOf(SETVALUERULE_ELEMENTREF,typr);
IFunction valf = mm.newFunction(e,r.getValue().getElement(),e);
mm.newInstanceOf(SETVALUERULE_VALUE,valf);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newManipMoveRule(MoveRule r)
{
try
{
IEntity e;
if (r.getName()==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(r.getName(),machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(r.getVarlist(),rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(MOVERULE,e);
addContainer(e);
generateAnnotation(r.getLine());
IFunction typr = mm.newFunction(e,r.getElemref().getElement(),e);
mm.newInstanceOf(MOVERULE_ELEMENT,typr);
if (r.getFrom()!=null)
{
IFunction valf = mm.newFunction(e,r.getFrom().getElement(),e);
mm.newInstanceOf(MOVERULE_FROM,valf);
}
IFunction valt = mm.newFunction(e,r.getTo().getElement(),e);
mm.newInstanceOf(MOVERULE_TO,valt);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newManipRenameRule(RenameRule r)
{
try
{
IEntity e;
if (r.getName()==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(r.getName(),machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(r.getVarlist(),rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(RENAMERULE,e);
addContainer(e);
generateAnnotation(r.getLine());
IFunction typr = mm.newFunction(e,r.getElemref().getElement(),e);
mm.newInstanceOf(RENAMERULE_ELEMENT,typr);
IFunction valf = mm.newFunction(e,r.getValue().getElement(),e);
mm.newInstanceOf(RENAMERULE_NAME,valf);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newManipNewRelationRule(NewRelationRule r)
{
try
{
IEntity e;
if (r.getName()==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(r.getName(),machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(r.getVarlist(),rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(RELATIONCREATERULE,e);
addContainer(e);
generateAnnotation(r.getLine());
//IEntity typ = mm.newEntity(e);
//mm.setValue(typ,r.getTyperef());
//mm.newInstanceOf(ELEMENTREFERENCE,typ);
IFunction typr = mm.newFunction(e,r.getTyperef().getElement(),e);
mm.newInstanceOf(ELEMENTCREATERULE_TYPE,typr);
IFunction nam = mm.newFunction(e,r.getElname().getElement(),e);
mm.newInstanceOf(ELEMENTCREATERULE_ELEMENT,nam);
IFunction src = mm.newFunction(e,r.getSource().getElement(),e);
mm.newInstanceOf(RELATIONCREATERULE_SOURCE,src);
IFunction trg = mm.newFunction(e,r.getTarget().getElement(),e);
mm.newInstanceOf(RELATIONCREATERULE_TARGET,trg);
if (r.getContainer()!=null)
{
IFunction con = mm.newFunction(e,r.getContainer().getElement(),e);
mm.newInstanceOf(ELEMENTCREATERULE_CONTAINERREF,con);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newChooseRule(int li,String n, Vector rp,Vector vars, int mod, TermDef base, FormulaDef fo, ASMRuleDef r, GTRuleCallDef gt)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(CHOOSERULE,e);
addContainer(e);
generateAnnotation(li);
if (vars!=null)
{
IEntity vl = createScopedList(vars);
IFunction vf = mm.newFunction(e,vl,currentContainer());
mm.newInstanceOf(BLOCKRULE_FIRSTVARIABLE,vf);
}
/*
for (int i=0;i<vars.size();i++)
{
String va = (String)vars.get(i);
IRelation fu = mm.newRelation(e,newVariableTerm(va),currentContainer());
mm.newInstanceOf(VARIABLE_CHOOSE,fu);
}*//*
if (fo!=null)
{
IFunction form = mm.newFunction(e,fo.getElement(),e);
mm.newInstanceOf(CHOOSERULE_FORMULA,form);
}
if (r!=null)
{
IEntity ri;
if (r instanceof CallRule)
{
ri = r.getElement();
}
else
{
ri = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,r.getElement(),ri);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif);
}
IFunction fu = mm.newFunction(e,ri,currentContainer());
mm.newInstanceOf(BLOCKRULE_RULE,fu);
}
else
{
IEntity ri = mm.newEntity(currentContainer());
mm.newInstanceOf(GTRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,gt.getElement(),ri);
mm.newInstanceOf(GTRULEINVOCATION_RULE,rif);
IFunction fu = mm.newFunction(e,ri,currentContainer());
mm.newInstanceOf(BLOCKRULE_GTRULE,fu);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newIterateRule(int li,String n, Vector rp,ASMRuleDef r, GTRuleCallDef gt)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(ITERATERULE,e);
addContainer(e);
generateAnnotation(li);
if (r!=null)
{
IEntity ri;
if (r instanceof CallRule)
{
ri = r.getElement();
}
else
{
ri = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,r.getElement(),ri);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif);
}
IFunction fu = mm.newFunction(e,ri,currentContainer());
mm.newInstanceOf(BLOCKRULE_RULE,fu);
}
else
{
IEntity ri = mm.newEntity(currentContainer());
mm.newInstanceOf(GTRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,gt.getElement(),ri);
mm.newInstanceOf(GTRULEINVOCATION_RULE,rif);
IFunction fu = mm.newFunction(e,ri,currentContainer());
mm.newInstanceOf(BLOCKRULE_GTRULE,fu);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newLetRule(int li,String n, Vector rp, String var, TermDef te, ASMRuleDef r)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(LETRULE,e);
addContainer(e);
generateAnnotation(li);
IEntity ri;
if (r instanceof CallRule)
{
ri = r.getElement();
}
else
{
ri = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,r.getElement(),ri);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif);
}
IFunction fu = mm.newFunction(e,ri,currentContainer());
mm.newInstanceOf(BLOCKRULE_RULE,fu);
IFunction varf = mm.newFunction(e,newVariableTerm(var),e);
mm.newInstanceOf(LETRULE_VARIABLE,varf);
IFunction valf = mm.newFunction(e,te.getElement(),e);
mm.newInstanceOf(LETRULE_VALUE,valf);
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newASMFunction(ASMFunction f)
{
try
{
IEntity e = mm.newEntity(f.getName(),machine);
mm.newInstanceOf(ASMFUNCTION,e);
addContainer(e);
Iterator i = f.getLocations().iterator();
while (i.hasNext())
{
FunctionLocation fl = (FunctionLocation)i.next();
IEntity lc = mm.newEntity(currentContainer());
mm.setValue(lc,fl.getValue());
mm.newInstanceOf(CONSTANT,lc);
IRelation lre = mm.newRelation(fl.getLocation(),e,lc,e);
mm.newInstanceOf(LOCATION_REL,lre);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newCallRule(int li,String n, Vector v, ASMRuleDef rule, Vector actp)
{
try
{
IEntity ri = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri);
String rulnam = rule.getName();
IEntity rul_to_inv = null;
try
{
rul_to_inv = (IEntity) machine.getContentByName(rulnam);
}
catch (Exception e)
{
}
addContainer(ri);
generateAnnotation(li);
removeContainer();
if (rul_to_inv==null) rul_to_inv = rule.getElement().getParentByName(rule.getName());
IFunction rif = mm.newFunction(ri,rul_to_inv,ri);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif);
IEntity old=null;
if (actp!=null)
{
for (int i=0;i<actp.size();i++)
{
TermDef s = (TermDef)actp.get(i);
if (i==0)
{
old = mm.newEntity(ri);
mm.newInstanceOf(ACTUALPARAMETER,old);
addContainer(old);
IFunction fu = mm.newFunction(old,s.getElement(),currentContainer());
mm.newInstanceOf(ACTUALPARAMETER_VALUE,fu);
IFunction ff = mm.newFunction(ri,old,ri);
mm.newInstanceOf(ASMRULEINVOCATION_FIRSTPARAM,ff);
removeContainer();
}
else
{
IEntity ne = mm.newEntity(ri);
mm.newInstanceOf(ACTUALPARAMETER,ne);
addContainer(ne);
IFunction fu = mm.newFunction(ne,s.getElement(),currentContainer());
mm.newInstanceOf(ACTUALPARAMETER_VALUE,fu);
IFunction ff = mm.newFunction(old,ne,old);
mm.newInstanceOf(ACTUALPARAMETER_NEXT,ff);
old = ne;
removeContainer();
}
}
}
return ri;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newParallelRule(int li,String n, Vector rp,Vector v)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(PARALLELRULE,e);
addContainer(e);
generateAnnotation(li);
for (int i=0;i<v.size();i++)
{
ASMRuleDef r = (ASMRuleDef)v.get(i);
IEntity ri = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,r.getElement(),ri);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif);
IRelation fu = mm.newRelation(e,ri,currentContainer());
mm.newInstanceOf(RULE,fu);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newSequentialRule(int li,String n, Vector rp,Vector v)
{
try
{
IEntity e=null;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(SEQUENTIALRULE,e);
addContainer(e);
generateAnnotation(li);
IEntity old = null;
for (int i=0;i<v.size();i++)
{
ASMRuleDef r = (ASMRuleDef)v.get(i);
IEntity ri = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,r.getElement(),ri);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif);
IRelation fu = mm.newRelation(e,ri,currentContainer());
mm.newInstanceOf(RULE,fu);
if (i==0)
{
IFunction fir = mm.newFunction(e,ri,e);
mm.newInstanceOf(SEQUENTIALRULE_FIRSTRULE,fir);
}
else
{
IRelation nex = mm.newRelation(old,ri,old);
mm.newInstanceOf(NEXTRULE,nex);
}
old = ri;
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newRandomRule(int li,String n, Vector rp,Vector v)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(RANDOMRULE,e);
addContainer(e);
generateAnnotation(li);
for (int i=0;i<v.size();i++)
{
ASMRuleDef r = (ASMRuleDef)v.get(i);
IEntity ri = mm.newEntity(currentContainer());
mm.newInstanceOf(ASMRULEINVOCATION,ri);
IFunction rif = mm.newFunction(ri,r.getElement(),ri);
mm.newInstanceOf(ASMRULEINVOCATION_RULE,rif);
IRelation fu = mm.newRelation(e,ri,currentContainer());
mm.newInstanceOf(RULE,fu);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newUpdateRule(int li,String n, Vector rp,String var, String fun, Vector l, TermDef val)
{
try
{
IEntity e;
if (n==null) e = mm.newEntity(currentContainer());
else
{
IEntity rd = mm.newEntity(n,machine);
mm.newInstanceOf(RULEDEFINITION,rd);
generateParlist(rp,rd);
e = mm.newEntity(rd);
IFunction rdr = mm.newFunction(rd,e,rd);
mm.newInstanceOf(RULEDEFINITION_RULE,rdr);
}
mm.newInstanceOf(UPDATERULE,e);
addContainer(e);
generateAnnotation(li);
IFunction value = mm.newFunction(e,val.getElement(),e);
mm.newInstanceOf(UPDATERULE_VALUE,value);
if (var!=null)
{
IFunction varf = mm.newFunction(e,newVariableTerm(var),e);
mm.newInstanceOf(UPDATERULE_VARIABLE,varf);
}
else
{
IFunction func = mm.newFunction(e,lookupFunction(fun),e);
mm.newInstanceOf(UPDATERULE_FUNCTION,func);
IEntity old = null;
for (int i=0;i<l.size();i++)
{
TermDef s = (TermDef)l.get(i);
if (i==0)
{
old = mm.newEntity(currentContainer());
mm.newInstanceOf(ACTUALPARAMETER,old);
addContainer(old);
IFunction fu = mm.newFunction(old,s.getElement(),currentContainer());
mm.newInstanceOf(ACTUALPARAMETER_VALUE,fu);
IFunction ff = mm.newFunction(e,old,e);
mm.newInstanceOf(UPDATERULE_LOCATION,ff);
removeContainer();
}
else
{
IEntity ne = mm.newEntity(currentContainer());
mm.newInstanceOf(ACTUALPARAMETER,ne);
addContainer(ne);
IFunction fu = mm.newFunction(ne,s.getElement(),currentContainer());
mm.newInstanceOf(ACTUALPARAMETER_VALUE,fu);
IFunction ff = mm.newFunction(old,ne,old);
mm.newInstanceOf(ACTUALPARAMETER_NEXT,ff);
old = ne;
removeContainer();
}
}
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity newUnaryOp(int li,String op, FormulaDef f, String var)
{
try
{
IEntity e = mm.newEntity(currentContainer());
addContainer(e);
generateAnnotation(li);
if (op.equals("!")) mm.newInstanceOf(NOT,e);
if (op.equals("all")) mm.newInstanceOf(ALL,e);
if (op.equals("exists")) mm.newInstanceOf(EXISTS,e);
mm.setValue(e,op);
IFunction fl = mm.newFunction(e,f.getElement(),currentContainer());
mm.newInstanceOf(UNARYOPERATION_FORMULA,fl);
if (var!=null)
{
IEntity vr = newVariableTerm(var);
IFunction fr = mm.newFunction(e,vr,currentContainer());
mm.newInstanceOf(QUALIFIEDFORMULA_VARIABLE,fr);
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}
public IEntity lookupFunction(String n) throws VPMCoreException
{
Collection c = ASMFUNCTION.getAllSubtypes();
Iterator i = c.iterator();
while (i.hasNext())
{
IEntity e = (IEntity)i.next();
if ((e.getName().equals(n)))
return e;
}
c = ASMFUNCTION.getAllInstances();
i = c.iterator();
while (i.hasNext())
{
IEntity e = (IEntity)i.next();
if ((e.getName().equals(n)))
return e;
}
c = NATIVEFUNCTION.getAllInstances();
i = c.iterator();
while (i.hasNext())
{
IEntity e = (IEntity)i.next();
if ((e.getName().equals(n)))
return e;
}
return null;
}
public IEntity newFunctionInvoke(int li, String fname, Vector p)
{
try
{
IEntity e = mm.newEntity(currentContainer());
addContainer(e);
generateAnnotation(li);
mm.newInstanceOf(FUNCTIONINVOCATION,e);
IEntity old = null;
IFunction fun = mm.newFunction(e,lookupFunction(fname),currentContainer());
mm.newInstanceOf(FUNCTIONINVOCATION_FUNCTION,fun);
for (int i=0;i<p.size();i++)
{
TermDef s = (TermDef)p.get(i);
if (i==0)
{
old = mm.newEntity(currentContainer());
mm.newInstanceOf(ACTUALPARAMETER,old);
addContainer(old);
IFunction fu = mm.newFunction(old,s.getElement(),currentContainer());
mm.newInstanceOf(ACTUALPARAMETER_VALUE,fu);
IFunction ff = mm.newFunction(e,old,e);
mm.newInstanceOf(FUNCTIONINVOCATION_FIRSTPARAM,ff);
removeContainer();
}
else
{
IEntity ne = mm.newEntity(currentContainer());
mm.newInstanceOf(ACTUALPARAMETER,ne);
addContainer(ne);
IFunction fu = mm.newFunction(ne,s.getElement(),currentContainer());
mm.newInstanceOf(ACTUALPARAMETER_VALUE,fu);
IFunction ff = mm.newFunction(old,ne,currentContainer());
mm.newInstanceOf(ACTUALPARAMETER_NEXT,ff);
old = ne;
removeContainer();
}
}
removeContainer();
return e;
}
catch (Exception e)
{
log.error("Cannot create model elements. Import failed. root cause: "+e.getLocalizedMessage());
e.printStackTrace();
return null;
}
}*/
}