Bug 510933 - [Toolsmiths] create a developer plugin to migrate the
newchildmenucreation and expansionmodel models
Actions:
-Remove unexpected dependencies
-Fix failing tests
Change-Id: Ic046648d0442b86ab044bb4bbac500380019509d
diff --git a/migrationelementtype/.project b/migrationelementtype/.project
new file mode 100644
index 0000000..6258187
--- /dev/null
+++ b/migrationelementtype/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>migrationelementtype</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/.classpath b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/.classpath
new file mode 100644
index 0000000..9ae7bca
--- /dev/null
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/.classpath
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/.project b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/.project
new file mode 100644
index 0000000..3096efe
--- /dev/null
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.developer.migration.elementtypereference.common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/common/AbstractElementTypeMigrationModel.java b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/common/AbstractElementTypeMigrationModel.java
index 16fca90..0849e46 100644
--- a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/common/AbstractElementTypeMigrationModel.java
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/common/AbstractElementTypeMigrationModel.java
@@ -28,7 +28,6 @@
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.io.FileUtils;
-import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -37,57 +36,58 @@
/**
*
- * Dedicated class to implement the generic strategy
+ * Dedicated class to implement the generic strategy
*
*/
public abstract class AbstractElementTypeMigrationModel {
- static Logger LOG4J = Logger.getLogger("org.eclipse.papyrus.developer.migration.elementtypereference.common.AbstractElementTypeMigrationModel");
+
static String ELEMENTTYPESCONFIGURATIONS = new String("elementtypesconfigurations");
- protected HashMap<String,ArrayList<String>> identifier2Id ;
+ protected HashMap<String, ArrayList<String>> identifier2Id;
public AbstractElementTypeMigrationModel(String folderRootGit4ElementtypeData) {
- identifier2Id = new HashMap<String,ArrayList<String>>();
+ identifier2Id = new HashMap<String, ArrayList<String>>();
parseDataModel(folderRootGit4ElementtypeData);
}
/**
- * @param gitRootFolder the root folder where the tool can find any needed elementypeconfiguration files
+ * @param gitRootFolder
+ * the root folder where the tool can find any needed elementypeconfiguration files
* @return
*/
/**
* @param gitRootFolder
* @return
*/
- private void parseDataModel(String gitRootFolder){
+ private void parseDataModel(String gitRootFolder) {
try {
File folder = new File(gitRootFolder);
- if(folder.isDirectory()) {
+ if (folder.isDirectory()) {
- String[] extension = new String[] {ELEMENTTYPESCONFIGURATIONS};
- List<File> files = (List<File>) FileUtils.listFiles(folder, extension, true );
+ String[] extension = new String[] { ELEMENTTYPESCONFIGURATIONS };
+ List<File> files = (List<File>) FileUtils.listFiles(folder, extension, true);
for (File file : files) {
if (file.isFile()) {
- LOG4J.debug("Dealing with "+ file.getAbsolutePath());
+ System.err.println("Dealing with " + file.getAbsolutePath());
- //Find the root folder of the plugin containng the elementtypeconfiguration file
+ // Find the root folder of the plugin containng the elementtypeconfiguration file
File rootPlugin = getPluginRoot(file);
- //Parsing the data
+ // Parsing the data
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(file);
- //optional, but recommended
- //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
+ // optional, but recommended
+ // read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
doc.getDocumentElement().normalize();
- //Ensuring to add right header
+ // Ensuring to add right header
Element root = doc.getDocumentElement();
- if(root.getAttribute("xmlns:elementtypesconfigurations").length()==0) {
+ if (root.getAttribute("xmlns:elementtypesconfigurations").length() == 0) {
root.setAttribute("xmlns:elementtypesconfigurations", "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2");
}
@@ -99,24 +99,23 @@
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
- if(identifier2Id.get(eElement.getAttribute("identifier"))==null && eElement.getAttribute("xmi:id")!=null) {
+ if (identifier2Id.get(eElement.getAttribute("identifier")) == null && eElement.getAttribute("xmi:id") != null) {
ArrayList<String> a = new ArrayList<String>();
a.add(eElement.getAttribute("xmi:id"));
- a.add(rootPlugin.getName()+file.getAbsolutePath().split(rootPlugin.getName())[1]);
+ a.add(rootPlugin.getName() + file.getAbsolutePath().split(rootPlugin.getName())[1]);
a.add(eElement.getAttribute("xsi:type"));
- identifier2Id.put(eElement.getAttribute("identifier"),a );//+"\t"+listOfFiles[i]);
- }
- else {
- LOG4J.warn(eElement.getAttribute("identifier")+"\t"+eElement.getAttribute("xmi:id")+"\t"+file.getAbsolutePath() + " VERSUS "+ eElement.getAttribute("identifier")+"\t"+identifier2Id.get(eElement.getAttribute("identifier")));
+ identifier2Id.put(eElement.getAttribute("identifier"), a);// +"\t"+listOfFiles[i]);
+ } else {
+ System.err.println(eElement.getAttribute("identifier") + "\t" + eElement.getAttribute("xmi:id") + "\t" + file.getAbsolutePath() + " VERSUS " + eElement.getAttribute("identifier") + "\t"
+ + identifier2Id.get(eElement.getAttribute("identifier")));
}
}
}
}
}
- }
- else {
- LOG4J.warn("Root folder is not a directory, no elementtype data found:" + gitRootFolder);
+ } else {
+ System.err.println("Root folder is not a directory, no elementtype data found:" + gitRootFolder);
}
@@ -127,52 +126,55 @@
/**
* Recursive function to find the plugin root by looking for the plugin.xml file or pom.xml or .project
+ *
* @param initialFile
* @return
*/
private File getPluginRoot(File initialFile) {
File f = initialFile.getParentFile();
- String dir= new String(File.separator);
- File lookFile ;
- if(f==null) {
- String[] items= initialFile.getAbsolutePath().split(File.separator);
- for(int i=1; i<items.length-1;i++) {
- dir+=items[i]+File.separator;
+ String dir = new String(File.separator);
+ File lookFile;
+ if (f == null) {
+ String[] items = initialFile.getAbsolutePath().split(File.separator);
+ for (int i = 1; i < items.length - 1; i++) {
+ dir += items[i] + File.separator;
}
lookFile = new File(dir);
- }
- else {
+ } else {
lookFile = f;
}
- if(lookFile.isDirectory()) {
- String[] extension = new String[] {"xml"};
- List<File> files = (List<File>) FileUtils.listFiles(lookFile, extension, true );
- for(File tmpFile : files) {
- if(tmpFile.getName().equals("plugin.xml") || tmpFile.getName().equals("pom.xml") || tmpFile.getName().equals(".project")) {
- LOG4J.debug("found in "+lookFile.getAbsolutePath());
+ if (lookFile.isDirectory()) {
+ String[] extension = new String[] { "xml" };
+ List<File> files = (List<File>) FileUtils.listFiles(lookFile, extension, true);
+ for (File tmpFile : files) {
+ if (tmpFile.getName().equals("plugin.xml") || tmpFile.getName().equals("pom.xml") || tmpFile.getName().equals(".project")) {
+ System.err.println("found in " + lookFile.getAbsolutePath());
return lookFile;
}
}
return getPluginRoot(lookFile);
- }
- else {
+ } else {
return null;
}
}
/**
* The method where the strategy to migrate the old model in the new model, have to be implemented by all model transformations
- * @param rootFolder place to look for model files to migrate
+ *
+ * @param rootFolder
+ * place to look for model files to migrate
* @param identifier2Id
- * @param outputRootFolder if set to null, will replace the content of the initial files
+ * @param outputRootFolder
+ * if set to null, will replace the content of the initial files
* @return
*/
public abstract void migrateModelDocuments(String rootFolder, String outputRootFolder);
/**
* Model writing method
+ *
* @param doc
* @param file
* @param outputRootFolder
@@ -192,21 +194,20 @@
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
final DOMSource source = new DOMSource(doc);
- final StreamResult output ;
- //Code to display in file
+ final StreamResult output;
+ // Code to display in file
File f;
- if(outputRootFolder!=null && outputRootFolder.length()!=0) {
- f = new File(outputRootFolder+File.separator+file.getName());
- }
- else {
+ if (outputRootFolder != null && outputRootFolder.length() != 0) {
+ f = new File(outputRootFolder + File.separator + file.getName());
+ } else {
f = new File(file.getAbsolutePath());
}
- LOG4J.debug("Output to "+f.getAbsolutePath());
+ System.err.println("Output to " + f.getAbsolutePath());
output = new StreamResult(f);
- //Code to export to console
- //final StreamResult sortie = new StreamResult(System.out);
+ // Code to export to console
+ // final StreamResult sortie = new StreamResult(System.out);
transformer.transform(source, output);
} catch (TransformerConfigurationException e) {
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/src/main/resources/log4j.xml b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/src/main/resources/log4j.xml
deleted file mode 100644
index 5d49612..0000000
--- a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.common/src/main/resources/log4j.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration debug="true"
- xmlns:log4j='http://jakarta.apache.org/log4j/'>
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern"
- value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
- </layout>
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
\ No newline at end of file
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/ElementTypeMigrationCreationMenuModel.java b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/ElementTypeMigrationCreationMenuModel.java
index 577c055..bbbd6d0 100644
--- a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/ElementTypeMigrationCreationMenuModel.java
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/ElementTypeMigrationCreationMenuModel.java
@@ -17,8 +17,8 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+
import org.apache.commons.io.FileUtils;
-import org.apache.log4j.Logger;
import org.eclipse.papyrus.developer.migration.elementtypereference.common.AbstractElementTypeMigrationModel;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -28,45 +28,45 @@
/**
*
- * Dedicated to migrate
+ * Dedicated to migrate
*
*/
-public class ElementTypeMigrationCreationMenuModel extends AbstractElementTypeMigrationModel{
+public class ElementTypeMigrationCreationMenuModel extends AbstractElementTypeMigrationModel {
- static Logger LOG4J = Logger.getLogger("org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel.ElementTypeMigration");
-
+
+
static String CREATIONMENUMODEL = new String("creationmenumodel");
-
+
public ElementTypeMigrationCreationMenuModel(String folderRootGit4ElementtypeData) {
super(folderRootGit4ElementtypeData);
}
- public void migrateModelDocuments(String rootFolder, String outputRootFolder){
+ public void migrateModelDocuments(String rootFolder, String outputRootFolder) {
Document doc = null;
try {
- String[] extensions = new String[] {CREATIONMENUMODEL};
+ String[] extensions = new String[] { CREATIONMENUMODEL };
File folder = new File(rootFolder);
- List<File> files = (List<File>) FileUtils.listFiles(folder, extensions, true );
+ List<File> files = (List<File>) FileUtils.listFiles(folder, extensions, true);
boolean migrated;
for (File file : files) {
- LOG4J.debug("Dealing with creationmenumodel: "+ file.getAbsolutePath());
+ System.err.println("Dealing with creationmenumodel: " + file.getAbsolutePath());
migrated = false;
if (file.isFile()) {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
- //optional, but recommended
- //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
+ // optional, but recommended
+ // read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
doc.getDocumentElement().normalize();
Element root = doc.getDocumentElement();
- if(root.getAttribute("xmlns:elementtypesconfigurations").length()==0) {
+ if (root.getAttribute("xmlns:elementtypesconfigurations").length() == 0) {
root.setAttribute("xmlns:elementtypesconfigurations", "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2");
}
-
+
NodeList nList = doc.getElementsByTagName("menu");
for (int temp = 0; temp < nList.getLength(); temp++) {
@@ -74,24 +74,23 @@
Node nNode = nList.item(temp);
Element eElement = (Element) nNode;
- if(eElement.getAttribute("elementTypeIdRef")!=null && eElement.getAttribute("identifier") !=null) {
- if(identifier2Id.get(eElement.getAttribute("elementTypeIdRef"))!=null) {
+ if (eElement.getAttribute("elementTypeIdRef") != null && eElement.getAttribute("identifier") != null) {
+ if (identifier2Id.get(eElement.getAttribute("elementTypeIdRef")) != null) {
Element newChild = doc.createElement("elementType");
newChild.setAttribute("xsi:type", "elementtypesconfigurations:MetamodelTypeConfiguration");
- newChild.setAttribute("href", "platform:/plugin/"+identifier2Id.get(eElement.getAttribute("elementTypeIdRef")).get(1)+"#"+identifier2Id.get(eElement.getAttribute("elementTypeIdRef")).get(0));
+ newChild.setAttribute("href", "platform:/plugin/" + identifier2Id.get(eElement.getAttribute("elementTypeIdRef")).get(1) + "#" + identifier2Id.get(eElement.getAttribute("elementTypeIdRef")).get(0));
eElement.appendChild(newChild);
eElement.removeAttribute("elementTypeIdRef");
- migrated=true;
- }
- else {
- LOG4J.warn(eElement.getAttribute("elementTypeIdRef")+"\t@"+identifier2Id.get(eElement.getAttribute("elementTypeIdRef")));
+ migrated = true;
+ } else {
+ System.err.println(eElement.getAttribute("elementTypeIdRef") + "\t@" + identifier2Id.get(eElement.getAttribute("elementTypeIdRef")));
}
}
}
- if(migrated) {
- exportDocument2File(doc, file, outputRootFolder) ;
+ if (migrated) {
+ exportDocument2File(doc, file, outputRootFolder);
}
}
}
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/ElementTypeMigrationCreationMenuRunner.java b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/ElementTypeMigrationCreationMenuRunner.java
index fc92519..d49a97e 100644
--- a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/ElementTypeMigrationCreationMenuRunner.java
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/ElementTypeMigrationCreationMenuRunner.java
@@ -12,27 +12,24 @@
*****************************************************************************/
package org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel;
-import org.apache.log4j.Logger;
-
-
/**
*
- * Dedicated to migrate
+ * Dedicated to migrate
*
*/
-public class ElementTypeMigrationCreationMenuRunner{
-
- static Logger LOG4J = Logger.getLogger("org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel.ElementTypeMigrationCreationMenuRunner");
-
+public class ElementTypeMigrationCreationMenuRunner {
+
+
+
public static void main(String argv[]) {
String folderRootGit4ElementtypeData = argv[0];
String folderRootGit4CreationMenuModel = argv[1];
- String outputRootFolder=null;
- if(argv.length==3) {
- outputRootFolder = argv[2];
+ String outputRootFolder = null;
+ if (argv.length == 3) {
+ outputRootFolder = argv[2];
}
ElementTypeMigrationCreationMenuModel myElementTypeMigrationCreationMenuModel = new ElementTypeMigrationCreationMenuModel(folderRootGit4ElementtypeData);
- myElementTypeMigrationCreationMenuModel.migrateModelDocuments(folderRootGit4CreationMenuModel,outputRootFolder );
+ myElementTypeMigrationCreationMenuModel.migrateModelDocuments(folderRootGit4CreationMenuModel, outputRootFolder);
}
}
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/resources/log4j.xml b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/resources/log4j.xml
deleted file mode 100644
index 5d49612..0000000
--- a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/main/resources/log4j.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration debug="true"
- xmlns:log4j='http://jakarta.apache.org/log4j/'>
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern"
- value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
- </layout>
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
\ No newline at end of file
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/test/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/test/ElementTypeMigrationCreationMenuModelTest.java b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/test/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/test/ElementTypeMigrationCreationMenuModelTest.java
index 2a19099..19d572f 100644
--- a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/test/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/test/ElementTypeMigrationCreationMenuModelTest.java
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel/src/test/java/org/eclipse/papyrus/developer/migration/elementtypereference/creationmenumodel/test/ElementTypeMigrationCreationMenuModelTest.java
@@ -12,41 +12,41 @@
*****************************************************************************/
package org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel.test;
+import static org.junit.Assert.assertEquals;
+
import java.io.File;
import java.io.IOException;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+
import org.apache.commons.io.FileUtils;
-import org.apache.log4j.Logger;
import org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel.ElementTypeMigrationCreationMenuModel;
-import org.junit.jupiter.api.Test;
+import org.junit.Test;
/**
*
- * Dedicated to test migration for elementtype in creationmenumodel
+ * Dedicated to test migration for elementtype in creationmenumodel
*
*/
-public class ElementTypeMigrationCreationMenuModelTest{
- static Logger LOG4J = Logger.getLogger("org.eclipse.papyrus.developer.migration.elementtypereference.creationmenumodel.test.ElementTypeMigrationCreationMenuModelTest");
-
+public class ElementTypeMigrationCreationMenuModelTest {
+
@Test
- void myFirstTest() {
+ public void myFirstTest() {
String folderRootGit4ElementtypeData = new String("src/test/resources/input/");
String folderRootGit4CreationMenuModel = new String("src/test/resources/input/");
String outputRootFolder = new String("target");
-
-
+
+
ElementTypeMigrationCreationMenuModel myElementTypeMigrationCreationMenuModel = new ElementTypeMigrationCreationMenuModel(folderRootGit4ElementtypeData);
-
- myElementTypeMigrationCreationMenuModel.migrateModelDocuments(folderRootGit4CreationMenuModel,outputRootFolder );
-
+
+ myElementTypeMigrationCreationMenuModel.migrateModelDocuments(folderRootGit4CreationMenuModel, outputRootFolder);
+
File file1 = new File("src/test/resources/output/DeployUndeployTests.creationmenumodel");
- File file2 = new File("target/DeployUndeployTests.creationmenumodel");
+ File file2 = new File("target/test-classes/output/DeployUndeployTests.creationmenumodel");
try {
- LOG4J.debug(file1.getAbsolutePath());
- LOG4J.debug(file2.getAbsolutePath());
+ System.err.println(file1.getAbsolutePath());
+ System.err.println(file2.getAbsolutePath());
boolean isTwoEqual = FileUtils.contentEquals(file1, file2);
- assertEquals(true,isTwoEqual);
+ assertEquals(true, isTwoEqual);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/.classpath b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/.classpath
new file mode 100644
index 0000000..9fc2de7
--- /dev/null
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/.classpath
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/.project b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/.project
new file mode 100644
index 0000000..5c6ed34
--- /dev/null
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/expansionmodel/ElementTypeMigrationExpansionModel.java b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/expansionmodel/ElementTypeMigrationExpansionModel.java
index 82ab8e1..905916f 100644
--- a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/expansionmodel/ElementTypeMigrationExpansionModel.java
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/main/java/org/eclipse/papyrus/developer/migration/elementtypereference/expansionmodel/ElementTypeMigrationExpansionModel.java
@@ -19,7 +19,6 @@
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.FileUtils;
-import org.apache.log4j.Logger;
import org.eclipse.papyrus.developer.migration.elementtypereference.common.AbstractElementTypeMigrationModel;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -29,29 +28,27 @@
/**
*
- * Dedicated to migrate
+ * Dedicated to migrate
*
*/
-public class ElementTypeMigrationExpansionModel extends AbstractElementTypeMigrationModel{
+public class ElementTypeMigrationExpansionModel extends AbstractElementTypeMigrationModel {
- static Logger LOG4J = Logger.getLogger("org.eclipse.papyrus.developer.migration.elementtypereference.expansion.ElementTypeMigrationExpansionModel");
-
static String ELEMENTTYPESCONFIGURATIONS = new String("elementtypesconfigurations");
static String EXPANSIONMODEL = new String("expansionmodel");
-
+
public ElementTypeMigrationExpansionModel(String folderRootGit4ElementtypeData) {
super(folderRootGit4ElementtypeData);
}
- public void migrateModelDocuments(String rootFolder, String outputRootFolder){
+ public void migrateModelDocuments(String rootFolder, String outputRootFolder) {
Document doc = null;
try {
- String[] extensions = new String[] {"xmi"};
+ String[] extensions = new String[] { "xmi" };
File folder = new File(rootFolder);
- List<File> files = (List<File>) FileUtils.listFiles(folder, extensions, true );
+ List<File> files = (List<File>) FileUtils.listFiles(folder, extensions, true);
boolean migrated;
for (File file : files) {
migrated = false;
@@ -60,46 +57,45 @@
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(file);
- //optional, but recommended
- //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
+ // optional, but recommended
+ // read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
doc.getDocumentElement().normalize();
- NodeList nList= doc.getElementsByTagName("expansionmodel:DiagramExpansion");
- if(nList!=null && nList.getLength()!=0) {
- LOG4J.debug("Dealing with expansionmodel: "+ file.getAbsolutePath());
-
+ NodeList nList = doc.getElementsByTagName("expansionmodel:DiagramExpansion");
+ if (nList != null && nList.getLength() != 0) {
+ System.err.println("Dealing with expansionmodel: " + file.getAbsolutePath());
+
Element root = doc.getDocumentElement();
- if(root.getAttribute("xmlns:elementtypesconfigurations").length()==0) {
+ if (root.getAttribute("xmlns:elementtypesconfigurations").length() == 0) {
root.setAttribute("xmlns:elementtypesconfigurations", "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2");
}
-
+
nList = doc.getElementsByTagName("representations");
for (int temp = 0; temp < nList.getLength(); temp++) {
doc.getElementsByTagName("ElementCreationMenuModel:Folder");
- //xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2"
-
+ // xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2"
+
Node nNode = nList.item(temp);
Element eElement = (Element) nNode;
- if(eElement.getAttribute("graphicalElementType")!=null) {
- if(identifier2Id.get(eElement.getAttribute("graphicalElementType"))!=null) {
+ if (eElement.getAttribute("graphicalElementType") != null) {
+ if (identifier2Id.get(eElement.getAttribute("graphicalElementType")) != null) {
Element newChild = doc.createElement("graphicalElementTypeRef");
newChild.setAttribute("xsi:type", identifier2Id.get(eElement.getAttribute("graphicalElementType")).get(2));
- newChild.setAttribute("href", "platform:/plugin/"+identifier2Id.get(eElement.getAttribute("graphicalElementType")).get(1)+"#"+identifier2Id.get(eElement.getAttribute("graphicalElementType")).get(0));
+ newChild.setAttribute("href", "platform:/plugin/" + identifier2Id.get(eElement.getAttribute("graphicalElementType")).get(1) + "#" + identifier2Id.get(eElement.getAttribute("graphicalElementType")).get(0));
eElement.appendChild(newChild);
eElement.removeAttribute("graphicalElementType");
- migrated=true;
-
- }
- else {
- LOG4J.warn(eElement.getAttribute("graphicalElementType")+"\t@"+identifier2Id.get(eElement.getAttribute("graphicalElementType")));
+ migrated = true;
+
+ } else {
+ System.err.println(eElement.getAttribute("graphicalElementType") + "\t@" + identifier2Id.get(eElement.getAttribute("graphicalElementType")));
}
}
}
- if(migrated) {
- exportDocument2File(doc, file, outputRootFolder) ;
+ if (migrated) {
+ exportDocument2File(doc, file, outputRootFolder);
}
-
-
+
+
}
}
}
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/main/resources/log4j.xml b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/main/resources/log4j.xml
deleted file mode 100644
index 5d49612..0000000
--- a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/main/resources/log4j.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration debug="true"
- xmlns:log4j='http://jakarta.apache.org/log4j/'>
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern"
- value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
- </layout>
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
\ No newline at end of file
diff --git a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/test/java/org/eclipse/papyrus/developer/migration/elementtypereference/expansionmodel/test/ElementTypeMigrationExpansionModelTest.java b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/test/java/org/eclipse/papyrus/developer/migration/elementtypereference/expansionmodel/test/ElementTypeMigrationExpansionModelTest.java
index 61bf262..d1408bf 100644
--- a/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/test/java/org/eclipse/papyrus/developer/migration/elementtypereference/expansionmodel/test/ElementTypeMigrationExpansionModelTest.java
+++ b/migrationelementtype/org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel/src/test/java/org/eclipse/papyrus/developer/migration/elementtypereference/expansionmodel/test/ElementTypeMigrationExpansionModelTest.java
@@ -12,39 +12,42 @@
*****************************************************************************/
package org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel.test;
+
+
+import static org.junit.Assert.assertEquals;
+
import java.io.File;
import java.io.IOException;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+
import org.apache.commons.io.FileUtils;
-import org.apache.log4j.Logger;
import org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel.ElementTypeMigrationExpansionModel;
-import org.junit.jupiter.api.Test;
+import org.junit.Test;
/**
*
- * Dedicated to test migration for elementtype in expansionmodel
+ * Dedicated to test migration for elementtype in expansionmodel
*
*/
-public class ElementTypeMigrationExpansionModelTest{
- static Logger LOG4J = Logger.getLogger("org.eclipse.papyrus.developer.migration.elementtypereference.expansionmodel.test.ElementTypeMigrationExpansionModelTest");
-
+public class ElementTypeMigrationExpansionModelTest {
+
+
@Test
- void myFirstTest() {
+ public void myFirstTest() {
String folderRootGit4ElementtypeData = new String("src/test/resources/input/");
String folderRootGit4ExpansionModel = new String("src/test/resources/input/");
String outputRootFolder = new String("target");
ElementTypeMigrationExpansionModel myElementTypeMigrationCreationMenuModel = new ElementTypeMigrationExpansionModel(folderRootGit4ElementtypeData);
-
- myElementTypeMigrationCreationMenuModel.migrateModelDocuments(folderRootGit4ExpansionModel,outputRootFolder );
-
+
+ myElementTypeMigrationCreationMenuModel.migrateModelDocuments(folderRootGit4ExpansionModel, outputRootFolder);
+
File file1 = new File("src/test/resources/output/AddBorderItem.xmi");
- File file2 = new File("target/AddBorderItem.xmi");
+ File file2 = new File("target/test-classes/output/AddBorderItem.xmi");
try {
- LOG4J.debug(file1.getAbsolutePath());
- LOG4J.debug(file2.getAbsolutePath());
+ System.err.println(file1.getAbsolutePath());
+ System.err.println(file2.getAbsolutePath());
boolean isTwoEqual = FileUtils.contentEquals(file1, file2);
- assertEquals(true,isTwoEqual);
+ assertEquals(true, isTwoEqual);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/migrationelementtype/pom.xml b/migrationelementtype/pom.xml
index 2b72889..3576a75 100644
--- a/migrationelementtype/pom.xml
+++ b/migrationelementtype/pom.xml
@@ -61,27 +61,21 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>2.5</version>
+ <version>2.2</version>
</dependency>
- <!-- https://mvnrepository.com/artifact/org.w3c/dom -->
+ <!-- https://mvnrepository.com/artifact/xerces/xercesImpl -->
<dependency>
- <groupId>org.w3c</groupId>
- <artifactId>dom</artifactId>
- <version>2.3.0-jaxb-1.0.6</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/org.apache.ws.commons/ws-commons-util -->
- <dependency>
- <groupId>org.apache.ws.commons</groupId>
- <artifactId>ws-commons-util</artifactId>
- <version>1.0.1</version>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.5.0</version>
</dependency>
- <!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
@@ -90,14 +84,6 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
-
-
</dependencies>
</dependencyManagement>
<dependencies>
@@ -108,26 +94,15 @@
<artifactId>commons-io</artifactId>
</dependency>
- <!-- https://mvnrepository.com/artifact/org.w3c/dom -->
+ <!-- https://mvnrepository.com/artifact/xerces/xercesImpl -->
<dependency>
- <groupId>org.w3c</groupId>
- <artifactId>dom</artifactId>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
</dependency>
- <!-- https://mvnrepository.com/artifact/org.apache.ws.commons/ws-commons-util -->
- <dependency>
- <groupId>org.apache.ws.commons</groupId>
- <artifactId>ws-commons-util</artifactId>
- </dependency>
-
- <!-- https://mvnrepository.com/artifact/log4j/log4j -->
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
-
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
+ <version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>