Skip to main content



      Home
Home » Modeling » Epsilon » Assign existing Papyrus model and diagram to a ETL target model and diagram
Assign existing Papyrus model and diagram to a ETL target model and diagram [message #1588267] Tue, 27 January 2015 16:13 Go to next message
Eclipse UserFriend
Hi Folks,

I created a Papyrus target model manually with an empty model and diagram. Now I would like to run my ETL trafo to get my source model transformed to the initially created target model - hence, to replace the latter. Also the diagram should be updated.

At the Moment, when I do my Transformation with the current logic, it just creates a new model beside the initially created model. And I do not get a diagram created.

Has anybody an idea for the approach? Is there any Statement like "tgtModel.setContainer(Model.all.selectOne(m|m.name="model");"

Thanks and Kind regards, Alex
Re: Assign existing Papyrus model and diagram to a ETL target model and diagram [message #1589423 is a reply to message #1588267] Wed, 28 January 2015 07:37 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alex,

If your target model file exists and you don't wish to preserve its contents, you should un-tick the "Read on load" option in its configuration dialog. Does this help?

Cheers,
Dimitris

[Updated on: Wed, 28 January 2015 07:37] by Moderator

Re: Assign existing Papyrus model and diagram to a ETL target model and diagram [message #1590121 is a reply to message #1589423] Wed, 28 January 2015 16:21 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dimitris,

thanks for your Support and your proposal. Unfortunately, this has not changed anything. The Problem that I face is the fact, that I call the EtlModule from my Java application as an InMemoryEmfModel. As this class has no constructor without the urge to specify the resource file (in my case the target), I Need to create it beforehand. On the other side this Approach has also a good side, as I can create a Papyrus model by Hand that is my favourite model Format. Do you have any other idea? Thanks a lot and Kind regards, Alex
Re: Assign existing Papyrus model and diagram to a ETL target model and diagram [message #1590218 is a reply to message #1590121] Wed, 28 January 2015 17:39 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alex,

In this case, I'd suggest adding a pre block to your ETL transformation that deletes any existing instances of Model before proceeding with the rest of your transformation logic e.g.

pre {
  for (m in Target!Model.all) {
    delete m;
  }
}


Does this help?

Cheers,
Dimitris
Re: Assign existing Papyrus model and diagram to a ETL target model and diagram [message #1591919 is a reply to message #1590218] Thu, 29 January 2015 15:36 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dimitris,

yes, this helps to avoid the second model! Thanks a lot. However, what I am still missing is the diagram. How can I create a Papyrus diagram from within an EOL/ETL module?

Thanks and Kind regards, Alex
Re: Assign existing Papyrus model and diagram to a ETL target model and diagram [message #1600860 is a reply to message #1591919] Wed, 04 February 2015 09:48 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alex,

I believe that Papyrus diagrams are also XMI-based models. I don't have any experience with interacting with these from Epsilon but opening one of them with a text editor (to find out the nsURI they conform to) could be a useful first step.

Cheers,
Dimitris
Re: Assign existing Papyrus model and diagram to a ETL target model and diagram [message #1603621 is a reply to message #1600860] Fri, 06 February 2015 04:26 Go to previous message
Eclipse UserFriend
Hi Dimitris,

thanks for that hint. In the meantime, I have been able to find a way to create a Papyrus diagram using an EOL script. I attached a screenshot of the configuration settings as well as the EOL script itself to this answer. It works fine when I launch it separately. The problem that I am now struggling with is that I do not manage to execute this EOL script from my Java plug-in. I do not know how to create an appropriate model within my plug-in. I just tried to use the following you provided me some time ago that is valid for UML metamodels and works fine for that:

	public InMemoryEmfModel getUmlModel(String i_name, File i_file)
				throws Exception {
		
		/**
		 * Name of model:
		 */
		String l_name = i_name;
		
		/**
		 * File name model .uml file:
		 */
		File l_file = i_file;
		
		/**
		 * Resource set:
		 */
		ResourceSet resSet = null;
		
		/**
		 * Resource for model:
		 */
		Resource res = null;
		
		/**
		 * EPackages:
		 */
		Collection<EPackage> ePackages = null;
		
		resSet = new ResourceSetImpl();
		UMLResourcesUtil.init(resSet);
		resSet.getPackageRegistry().put(UMLPackage.eNS_URI,
				UMLPackage.eINSTANCE);
		resSet.getResourceFactoryRegistry().getExtensionToFactoryMap().
		    put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
		res = resSet.getResource(URI.createFileURI(l_file.
				getAbsolutePath()), true);
		res.load(null);
		ePackages = new ArrayList<EPackage>();
		for (Object ePackage : resSet.getPackageRegistry().values()) {
			ePackages.add((EPackage) ePackage);
		}
		return new InMemoryEmfModel(l_name, res, ePackages);
	}


If I use an InMemoryEmfModel instance created according to the preceeding code for the Papyrus notation file, the EOL script returns errors that are related to the meta model (e.g. "Diagram" is not a valid variable, type or model").

I am not sure whether I do mistakes in adding the meta model properties. In the following code excerpt, you see how I use them. The excerpt shows the complete handling of my Papyrus diagram creation within my Java plug-in:

/**
 * Testing area: Create Eol module to generate diagram of the target model:	
 */
		InMemoryEmfModel pcpTgtNotationModel = null;
		pcpTgtNotationModel = this.getUmlModel("PcpNotationModel",
				pcpTgtNotationFile);
		StringProperties tgtDiagramProps = null;	
		tgtDiagramProps = new StringProperties();
		tgtDiagramProps.put(InMemoryEmfModel.PROPERTY_FILE_BASED_METAMODEL_URI,
			"http://www.eclipse.org/gmf/runtime/1.0.2/notation");
		tgtDiagramProps.put(InMemoryEmfModel.PROPERTY_FILE_BASED_METAMODEL_URI,
				"http://www.eclipse.org/emf/2002/Ecore");			
		tgtDiagramProps.put(InMemoryEmfModel.PROPERTY_FILE_BASED_METAMODEL_URI,
				"http://www.eclipse.org/papyrus/infra/gmfdiag/css");			
		tgtDiagramProps.put(InMemoryEmfModel.PROPERTY_FILE_BASED_METAMODEL_URI,
				"http://www.eclipse.org/uml2/4.0.0/UML");
		tgtDiagramProps.put(InMemoryEmfModel.PROPERTY_READONLOAD, true + "");
		tgtDiagramProps.put(InMemoryEmfModel.PROPERTY_STOREONDISPOSAL, true + "");			
		pcpTgtNotationModel.load(tgtDiagramProps, null);
		tgtDiagramProps = null;
		EolModule eolModule = new EolModule();
		eolModule.parse(this.getFileInBundle("/res/ProPMan_EpsilonModules/ProPGenEpsilonModules/GeneralPurposesEpsilonModules/PatternDiagramGenerator.eol"));
			
			if (eolModule.getParseProblems().size() > 0) {
				System.err.println("Parse errors occured...");
				for (ParseProblem problem : 
					eolModule.getParseProblems()) {
					System.err.println(problem.toString());
				}
				System.exit(-1);
			}				
		
		eolModule.getContext().getModelRepository().
			addModel(pcpTgtNotationModel);
		eolModule.execute();
		((IModel) eolModule).dispose();	


It would be great if you can tell me how to properly create a model instance in Java that is based on the Papyrus notation file and the meta models given.

Thanks a lot in advance for your appreciated support and kind regards, Alex
Previous Topic:[Flock] Model includes references
Next Topic:[ETL] How to create a target model by java code
Goto Forum:
  


Current Time: Fri Nov 07 08:02:40 EST 2025

Powered by FUDForum. Page generated in 0.03661 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top