Browse Source

Merge branch 'master' of github.com:AToMPM/atompm

Bentley James Oakes 7 years ago
parent
commit
3bb83606dc
2 changed files with 107 additions and 5 deletions
  1. 80 0
      plugins/export2ecore_README.md
  2. 27 5
      plugins/exportM2Ecore.js

+ 80 - 0
plugins/export2ecore_README.md

@@ -0,0 +1,80 @@
+==========================================================================================
+
+AToMPM - A Tool for Multi-Paradigm Modelling
+
+Copyright (c) 2017 Khady FALL
+(khady.fall@umontreal.ca)
+
+==========================================================================================
+
+EXPORTING AToMPM's METAMODELS AND MODELS TO ECORE
+
+This implementation allows you to export metamodels and models from AToMPM to Ecore.
+
+==========================================================================================
+
+INSTALLATION :
+
+In the \implementation folder, there are two folders : \Ecore and \Plugins.
+
+To install the exporting files, do the following :
+
+1- Copy and paste the \Ecore folder in your AToMPM installation at \atompm\users
+
+\[your_username]\Toolbars.
+
+2- Copy and paste the two files ExportMM2Ecore.js and ExportM2Ecore.js located in \Plugins
+
+in your AToMPM installation at \atompm\plugins.
+
+All the files have been properly installed.
+
+
+
+UTILISATION :
+
+To export metamodels or models in AToMPM, follow these steps :
+
+1- Open a new session in AToMPM.
+
+2- Click on the "(re-)load a toolbar" button.
+
+3- In the \Toolbars\Ecore folder, choose "Export2Ecore.buttons.model" then click the "ok"
+
+button.
+
+4- Load your metamodel or model in the current canvas.
+
+5- If you want to export a metamodel, click on the "MM -> Ecore" button of the loaded
+
+toolbar (the first button). If you want to export a model, rather click on the "M ->
+
+Ecore" button (the second button).
+
+6- If you want to export a model, you will be asked to enter the name of the model, the
+
+name of the metamodel and its URI. Also, you will be asked if you want a dynamic instance
+
+or a static one. There are default values : the model's name will be the current model
+
+name, the metamodel's name and URI will be composed as follow :
+
+"[name_of_current_model]Metamodel" and "http://[name_of_current_model]", respectively.
+
+7- If you want to export a metamodel, you will be asked to enter the name of the metamodel
+
+and its URI. There are default values : the name of the current metamodel and a URI
+
+composed as follow : "http://[name_of_(meta)model]".
+
+8- After entering those informations, click the "ok" button.
+
+9- A file .ecore for a metamodel, or a file .xmi for a model, has been created. That file
+
+is in a folder \exported_to_ecore located in the \atompm folder of your AToMPM
+
+installation.
+
+10- If you want to use the exported file in Eclipse, you have to register the metamodel.
+
+==========================================================================================

+ 27 - 5
plugins/exportM2Ecore.js

@@ -111,7 +111,7 @@ module.exports = {
                          **/
                          **/
                         function createRootClass(list) {
                         function createRootClass(list) {
                             var node = {};
                             var node = {};
-                            node.name = reqData['root'];
+                            node.name = reqData['name'] + 'Root';
                             var contain = [];
                             var contain = [];
                             for (var i = 0; i < list.length; i++)
                             for (var i = 0; i < list.length; i++)
                                 contain.push(createNode(list[i]));
                                 contain.push(createNode(list[i]));
@@ -236,9 +236,10 @@ module.exports = {
                         /**
                         /**
                          This function will write the header of the file including the
                          This function will write the header of the file including the
                          name of the root and the URI of the metamodel.
                          name of the root and the URI of the metamodel.
+                         This header is generated when the user doesn't want a dynamic instance.
                          **/
                          **/
-                        function writeHeader() {
-                            var head = '<?xml version="1.0" encoding="ISO-8859-1"?> \n';
+                        function writeHeaderStatic() {
+                            var head = '<?xml version="1.0" encoding="UTF-8"?> \n';
                             head += '<' + root.name;
                             head += '<' + root.name;
                             head += ' xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="' + reqData['uri'] + '"';
                             head += ' xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="' + reqData['uri'] + '"';
                             if (root.attributes != null)
                             if (root.attributes != null)
@@ -249,6 +250,24 @@ module.exports = {
                         }
                         }
 
 
 
 
+                        /**
+            								This function will write the header of the file including the
+            								name of the root and the URI of the metamodel.
+            								This header is generated when the user want a dynamic instance.
+          							**/
+          							function writeHeaderDynamic(){
+          								var head = '<?xml version="1.0" encoding="UTF-8"?> \n';
+          								head += '<' + reqData['name'] + ':' + root.name;
+          								head += ' xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n';
+          								head += 'xmlns:' + reqData['name'] + '="' + reqData['uri'] + '" xsi:schemaLocation="' + reqData['uri'] + ' ' + reqData['nameMM'] + '.ecore"';
+          								if(root.attributes != null)
+          									head += writeAttributes(root, 0);
+          								else
+          									head += '> \n';
+          								return head;
+          							}
+
+
                         /**
                         /**
                          This function writes the attributes of an element.
                          This function writes the attributes of an element.
                          **/
                          **/
@@ -302,7 +321,10 @@ module.exports = {
                          in a string.
                          in a string.
                          **/
                          **/
                         function writeFile() {
                         function writeFile() {
-                            file_contents += writeHeader();
+                            if(reqData['type'] == 'Dynamic instance')
+                              file_contents += writeHeaderDynamic();
+                            else
+                              file_contents += writeHeaderStatic();
                             file_contents += writeContained(root.contain, 0);
                             file_contents += writeContained(root.contain, 0);
                             file_contents += '</' + root.name + '>';
                             file_contents += '</' + root.name + '>';
                         }
                         }
@@ -415,4 +437,4 @@ module.exports = {
                 'respIndex': resp
                 'respIndex': resp
             });
             });
     }
     }
-};
+};