Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-dev] How to correctly build rules?

Am 09.10.2012 20:05, schrieb Christian Krause:
Could it be that the stereotypes are root nodes?

I'm not sure if we mean the same, but the structure of

If you execute your
transformation programmatically,

I am not at the moment, but as it is necessary for the future I'm trying it.

For the moment I'm not able to load the UML-model. I get an exception:

Cannot create a resource for 'seclinks.uml'; a registered resource factory is needed at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:394)

So I tried to do a "UMLResouceFactoryImpl" my way but apparently took the wrong way. I even get a exception when loading the henshin-file:

Exception in thread "main" java.lang.UnsupportedOperationException
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.doLoad(ResourceImpl.java:1549) at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1511) at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1290) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397) at org.eclipse.emf.henshin.model.resource.HenshinResourceSet.getResource(HenshinResourceSet.java:182)
	at TransformationTest.run(TransformationTest.java:31)
	at TransformationTest.main(TransformationTest.java:35)


Thanks in advance,
Jens

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
import org.eclipse.uml2.uml.resource.UMLResource;
import org.eclipse.uml2.uml.resource.UMLResource.Factory;

public class UMLResourceFactoryImpl implements UMLResource.Factory {
	  /**
	   * Creates an instance.
	   */
	  public UMLResourceFactoryImpl()
	  {
	    super();
	  }
	  
	  /**
	   * Returns a newly allocated default resource {@link org.eclipse.emf.ecore.resource.impl.ResourceImpl#ResourceImpl(URI) implementation}.
	   * @param uri the URI.
	   * @return a new resource for the URI.
	   */
	  public Resource createResource(URI uri)
	  {
	    return new ResourceImpl(uri);
	  }
}
import java.util.Map;

import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.henshin.interpreter.EGraph;
import org.eclipse.emf.henshin.interpreter.impl.EGraphImpl;
import org.eclipse.emf.henshin.model.Module;
import org.eclipse.emf.henshin.model.resource.HenshinResourceSet;

public class TransformationTest {
	/**
	 * @param args
	 */
	/**
	 * Relative path to the model files.
	 */
	public static final String PATH = "src/";

	public static void run(String path, boolean saveResult) {

		Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
		Map<String, Object> m = reg.getExtensionToFactoryMap();
		m.put("uml", new UMLResourceFactoryImpl());

		// Create a resource set with a base directory:
		HenshinResourceSet resourceSet = new HenshinResourceSet(path);

		// Load the module:
		Module module = resourceSet.getModule("secure_links.henshin");

		// Load the example model into an EGraph:
		EGraph graph = new EGraphImpl(resourceSet.getResource("seclinks.uml"));
	}

	public static void main(String[] args) {
		run(PATH, true);
		

	}

}

Back to the top