Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-dev] Question about Henshins wrap model and GUI

Am 23.09.2013 18:19, schrieb Christian Krause:
[…]
Indeed, there is no special syntax for the wrapper model in the moment.
If it helps: there are two examples (generic copy & metamodel evolution)
in the examples plugin. The copy example you can also find on the web.

Oh, thats no problem for me; I'm currently just asking myself to what extent it makes sense to me to migrate my current approach realizing dynamic types to the wrapper model.

I am trying to test the wrapper model and built a simple UML model as well as a transformation unit the traditional way and as a wrapper (see attachements).

The unit "testrule_orig" does have a match at the original model as expected, but "testrule_wrap" does not have a match at the wrapped model.

However, there seems to be a problem when generating the wrapped model. When I generate the wrapped model, the map contained in the variable graph has about 17000 entries, although wrappers contains only 14.

What am I doing wrong?

Thanks in advance,

Jens
--
Dipl.-Inf. Jens Bürger
Technische Universität Dortmund
Lehrstuhl 14 AG SECSE
Otto-Hahn-Straße 14
44227 Dortmund

Raum 332
Tel.: +49 231 755-2690
Fax:  +49 231 755-7936

Attachment: model.png
Description: PNG image

Attachment: henshin.png
Description: PNG image

	public void load() {

		EPackage.Registry.INSTANCE
				.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
				UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);

		// Create a resource set with a base directory:
		resourceSet = new HenshinResourceSet(null);
	
		// Load the module:
		model.setTransformationModule(resourceSet.getModule(
				model.getHenshinFile(), false));

		resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
				UMLPackage.eINSTANCE);	resourceSet.registerXMIResourceFactories("uml");
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
				.put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);

		// Load the model into an EGraph:
		Resource resource = resourceSet.getResource(model.getModelFile());
		for (EObject o : resource.getContents()){
			if (o instanceof Model) {modelRef=o;}
		}
		model.setModelGraph(new EGraphImpl(resource));
		
	
List<EObject> modell = resourceSet.getResource(model.getModelFile()).getContents();
		
		// Build the wrap model:
		Map<EObject,WObject> wrappers = WrapFactory.eINSTANCE.createWModelTree(modell, true);
		
		System.out.println(wrappers.toString());
		//System.out.println(wf.createWModelTree(model.getTransformationModule().getUnit("testrule_orig").eContents(),false).toString());
		

		System.out.println("und nicht da");
		
		
	EGraph graph = new EGraphImpl(wrappers.values());
for (Match match : engine.findMatches((Rule) model.getTransformationModule().getUnit("testrule_wrap"), graph, null)) {
		System.out.println(match.toString());
	}
	
	
	Map<Object, Object> options = new HashMap<Object, Object>();
	options.put(XMIResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
	options.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE);
	options.put(XMIResource.OPTION_SAVE_TYPE_INFORMATION, Boolean.TRUE);
	Resource resource2 = resourceSet.createResource(URI.createFileURI(model.getModelFile().replace(".uml", "_XYZ.uml")));
	// Only save the UML-Model and instances of UMLsec-stereotypes:
	
	for (EObject o : graph().getRoots()){
		if (o instanceof Model && o==modelRef) {resource2.getContents().add(o);}
		if (UMLsec.contains(o.eClass().getName())) {resource2.getContents().add(o);}
	}
	resource2.getContents().addAll(graph);
	try {
		resource2.save(options);
	} catch (IOException e) {
		model.handleStatus(new Status(Status.ERROR, APPActivator.PLUGIN_ID, "While saving the patched instance-model, an IO error occured.",e), StatusManager.BLOCK | StatusManager.LOG);
	}

Back to the top