Bug 525663 - [PapyrusReq] Refactory API for migrating the model from
SysML 1.4 Requirement

Change-Id: I5ce2bb0365c8d4bb6be66a52d22d3650df1decc0
Signed-off-by: Yupanqui Munoz <yupanqui.munozjulho@cea.fr>
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/META-INF/MANIFEST.MF b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/META-INF/MANIFEST.MF
index 61be313..1439cce 100644
--- a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/META-INF/MANIFEST.MF
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/META-INF/MANIFEST.MF
@@ -16,3 +16,4 @@
  org.eclipse.papyrus.requirements.sysml14.migrationtoreq;bundle-version="0.7.0",
  org.eclipse.papyrus.requirements.sysml14.papyrusre,
  org.eclipse.papyrus.uml.tools.utils
+Export-Package: org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui.handler
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/MigartionToSysML14RequirementHandler.java b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/MigartionToSysML14RequirementHandler.java
new file mode 100644
index 0000000..347ff81
--- /dev/null
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/MigartionToSysML14RequirementHandler.java
@@ -0,0 +1,67 @@
+package org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+
+public abstract class MigartionToSysML14RequirementHandler extends AbstractHandler {
+
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+	/**
+	 * Get top owner element of the given element.
+	 *
+	 * @param element
+	 *            Starting point of the search
+	 * @return Top model found
+	 */
+	protected static Element getTopElement(final Element element) {
+
+		if (element.getOwner() != null) {
+			return getTopElement(element.getOwner());
+		} else {
+			return element;
+		}
+
+	}
+
+	/**
+	 * Get the selected EObject from Model Explorer.
+	 * 
+	 * @return
+	 */
+	protected static EObject getEObjectOfSelection() {
+		IStructuredSelection selection = (IStructuredSelection) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+		EObject selectedEObject = null;
+
+		if (selection != null) {
+			selectedEObject = EMFHelper.getEObject(selection.getFirstElement());
+		}
+
+		return selectedEObject;
+	}
+
+	/**
+	 * The handler is capable of executing at this time if the selected element is a UML Class.
+	 * 
+	 * {@inheritDoc}
+	 */
+	@Override
+	public boolean isEnabled() {
+		if (getEObjectOfSelection() instanceof Package) {
+			return true;
+		}
+		return super.isEnabled();
+	}
+
+}
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/SysML14ToPapyrusREHandler.java b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/SysML14ToPapyrusREHandler.java
index dc85c5e..a246c61 100644
--- a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/SysML14ToPapyrusREHandler.java
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/ui/handler/SysML14ToPapyrusREHandler.java
@@ -10,19 +10,14 @@
  *******************************************************************************/
 package org.eclipse.papyrus.requirements.sysml14.migrationtoreq.ui.handler;
 
-import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.requirements.sysml14.migrationtoreq.SysML14ToPapyrusRE;
+import org.eclipse.papyrus.requirements.sysml14.migrationtoreq.MigrationToSysML14Requirement;
 import org.eclipse.papyrus.requirements.sysml14.migrationtoreq.SysML14ToPapyrusRERules;
 import org.eclipse.papyrus.requirements.sysml14.papyrusre.set.PapyrusRESet;
 import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.Element;
 import org.eclipse.uml2.uml.Model;
 import org.eclipse.uml2.uml.Package;
 import org.eclipse.uml2.uml.Profile;
@@ -31,7 +26,7 @@
  * Handler class for migrating a SysML 1.4 model to a PapyrusRE model.
  *
  */
-public class SysML14ToPapyrusREHandler extends AbstractHandler {
+public class SysML14ToPapyrusREHandler extends MigartionToSysML14RequirementHandler {
 
 	@Override
 	public Object execute(ExecutionEvent event) throws ExecutionException {
@@ -49,56 +44,10 @@
 
 			Profile papyrusREProfile = (Profile) PackageUtil.loadPackage(URI.createURI(PapyrusRESet.PROFILE_PATH), topModel.eResource().getResourceSet());
 			SysML14ToPapyrusRERules rules = new SysML14ToPapyrusRERules();
-			SysML14ToPapyrusRE.executeMigration(selectedPackage, rules, papyrusREProfile, topModel);
+			MigrationToSysML14Requirement.executeMigration(selectedPackage, rules, papyrusREProfile, topModel);
 		}
 
 		return null;
 	}
 
-	/**
-	 * Get top owner element of the given element.
-	 *
-	 * @param element
-	 *            Starting point of the search
-	 * @return Top model found
-	 */
-	private static Element getTopElement(final Element element) {
-
-		if (element.getOwner() != null) {
-			return getTopElement(element.getOwner());
-		} else {
-			return element;
-		}
-
-	}
-
-	/**
-	 * Get the selected EObject from Model Explorer.
-	 * 
-	 * @return
-	 */
-	private static EObject getEObjectOfSelection() {
-		IStructuredSelection selection = (IStructuredSelection) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
-		EObject selectedEObject = null;
-
-		if (selection != null) {
-			selectedEObject = EMFHelper.getEObject(selection.getFirstElement());
-		}
-
-		return selectedEObject;
-	}
-
-	/**
-	 * The handler is capable of executing at this time if the selected element is a UML Class.
-	 * 
-	 * {@inheritDoc}
-	 */
-	@Override
-	public boolean isEnabled() {
-		if (getEObjectOfSelection() instanceof Package) {
-			return true;
-		}
-		return super.isEnabled();
-	}
-
 }
diff --git a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/SysML14ToPapyrusRE.java b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/MigrationToSysML14Requirement.java
similarity index 91%
rename from plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/SysML14ToPapyrusRE.java
rename to plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/MigrationToSysML14Requirement.java
index 254f801..7f3222c 100644
--- a/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/SysML14ToPapyrusRE.java
+++ b/plugins/sysml14/org.eclipse.papyrus.requirements.sysml14.migrationtoreq/src/org/eclipse/papyrus/requirements/sysml14/migrationtoreq/MigrationToSysML14Requirement.java
@@ -24,13 +24,13 @@
 import org.eclipse.uml2.uml.util.UMLUtil;
 
 /**
- * This class executes the migration from SysML 1.4 model to PapyrusRE model. 
+ * This class executes the migration from SysML 1.4 model to another domain model. 
  *
  */
-public class SysML14ToPapyrusRE {
+public class MigrationToSysML14Requirement {
 
 	/** Label of the command to apply annotation on the UML model. */
-	private static final String CMD_LABEL_APPLY_ANNOTATION_ON_UML_MODEL = "PapyrusRE: Apply Annotation on the UML model"; //$NON-NLS-1$
+	private static final String CMD_LABEL_APPLY_ANNOTATION_ON_UML_MODEL = "Apply Annotation on the UML model"; //$NON-NLS-1$
 
 	/** Message of the error during the service registry search. */
 	private static final String ERROR_SERVICE_REAGITRY_SEARCH = "Error during the service registry search"; //$NON-NLS-1$
@@ -55,7 +55,7 @@
 		try {
 			domain.getCommandStack().execute(applyAnnotationCmd);
 		} catch (final IllegalArgumentException exception) {
-			Activator.log.error("Error during the application of the PapyrusRE annotation on the model", exception); //$NON-NLS-1$
+			Activator.log.error("Error during the the migration from SysML 1.4 model to another domain model", exception); //$NON-NLS-1$
 
 		}
 	}