Hi Daniel,
thanks for the explanation, escaping the name value gets me the desired result.
I do need to create the rules via api since i want to generate them from the UML level model, so i cannot use the henshin UI.
I
seem to have another issue now, i am trying to set the name of a newly
created Class and the it ends up with the name qualified name of the
java object.
Here is how the code proceeds:
// Manually create two nodes on the RHS.
Node rhsClassNode = factory.createNode(rhsGraph, rhsClass.eClass(), null);
Node rhsPackageNode = factory.createNode(rhsGraph, rhsPackage.eClass(), null);
Edge rhsPackEdge = factory.createEdge(rhsPackageNode, rhsClassNode, UMLFactory.eINSTANCE.getUMLPackage().getPackage_PackagedElement());
String rhsname = (String) rhsPackage.eGet(UMLFactory.eINSTANCE.getUMLPackage().getNamedElement_Name());
rhsPackageNode.setName(rhsname);
rhsClassNode.setName("name");
Attribute nameatt = HenshinFactoryImpl.eINSTANCE.createAttribute();
nameatt.setType(UMLFactory.eINSTANCE.getUMLPackage().getNamedElement_Name());
nameatt.setValue("name");
rhsClassNode.getAttributes().add(nameatt);
Parameter nameParam = HenshinFactoryImpl.eINSTANCE.createParameter();
nameParam.setKind(ParameterKind.IN);
nameParam.setType(EcoreFactoryImpl.eINSTANCE.getEcorePackage().getEString());
nameParam.setName("name");
nameParam.setUnit(rule);
rule.getParameters().add(nameParam);
Mapping m1 = factory.createMapping(lhsPackageNode, rhsPackageNode);
rule.getMappings().add(m1);
Engine engine = new EngineImpl();
UnitApplication createAccountApp = new UnitApplicationImpl(engine);
createAccountApp.setEGraph(graph);
createAccountApp.setUnit(rule);
createAccountApp.setParameterValue("name", "myGreatName");
if (!createAccountApp.execute(null)) {
throw new RuntimeException("Error creating class.");
}
Do i need to set the name of the nodes?