| Assign existing Papyrus model and diagram to a ETL target model and diagram [message #1588267] |
Tue, 27 January 2015 16:13  |
Eclipse User |
|
|
|
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 #1603621 is a reply to message #1600860] |
Fri, 06 February 2015 04:26  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.05736 seconds