-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[569477] Add a migration contribution for trace resources (#15)
- If the trace file is present in the capella project it is automatically migrated during the project migration. - If the trace file is present elsewhere in the workspace, a migration menu is available. - Add JUnit -- Trace Helper JUnits -- Migration procedure JUnit - Add migration documentation Change-Id: I8c94b2261bfdab00c55ae975099f1b3271e0c994 Signed-off-by: Sandu Postaru <sandu.postaru@thalesgroup.com>
- Loading branch information
1 parent
9421088
commit f58eb56
Showing
25 changed files
with
1,952 additions
and
12 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
plugins/org.polarsys.capella.vp.requirements.doc/html/3_userguide/33_1_migration.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | ||
<link rel="stylesheet" type="text/css" | ||
href="PLUGINS_ROOT/org.polarsys.capella.doc/html/styles.css" | ||
media="all" /> | ||
<title>Migration</title> | ||
</head> | ||
<body> | ||
<h1>Migration procedure</h1> | ||
<p>As specified in the previous section, after a Reqif import a new | ||
file .bridgetraces is created aside the .capella file which is used | ||
for successive imports. Models that have been created in previous | ||
versions of Capella need to be migrated for this version, including | ||
the .bridgetraces file.</p> | ||
|
||
<ul> | ||
<li>If the .bridgetraces file is present in your Capella project, | ||
it will be automatically migrated during the migration procedure. For | ||
more details regarding the migration please of Capella projects | ||
please consult <b>Capella Guide / User Manual / First steps with | ||
Capella / How to Migrate Capella Project</b> | ||
</li> | ||
<li><img src="../../images/migration1.png" | ||
style="max-width: 700px; height: auto;" /></li> | ||
<li>If the .bridgetraces file is present in elsewhere in your | ||
workspace, you can migrate them independently by doing <b>Right | ||
Click / Migration / Migrate Trace resource to current version</b> | ||
</li> | ||
<li><img src="../../images/migration2.png" | ||
style="max-width: 750px; height: auto;" /></li> | ||
</ul> | ||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+23.1 KB
plugins/org.polarsys.capella.vp.requirements.doc/images/migration1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.6 KB
plugins/org.polarsys.capella.vp.requirements.doc/images/migration2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+950 Bytes
...s.capella.vp.requirements.model.helpers/icons/full/etools16/capella_migrate.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
plugins/org.polarsys.capella.vp.requirements.model.helpers/icons/full/etools16/license.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
These followings icons are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
|
||
<icon file path> - <original eclipse plug-in> - <original file path> | ||
|
||
/icons/full/etools16/capella_migrate.gif - org.eclipse.debug.ui - org.eclipse.debug.ui/icons/full/obj16/debugt_obj.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...nts.model.helpers/src/org/polarsys/capella/vp/requirements/model/helpers/TraceHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 THALES GLOBAL SERVICES. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.vp.requirements.model.helpers; | ||
|
||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IPath; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.emf.common.util.URI; | ||
import org.polarsys.capella.core.model.handler.command.CapellaResourceHelper; | ||
|
||
public class TraceHelper { | ||
private static final String TRACE_FILE_EXTENSION = "bridgetraces"; | ||
|
||
public static URI getTraceURI(URI uri) { | ||
return uri.appendFileExtension(TRACE_FILE_EXTENSION); | ||
} | ||
|
||
// Initial: model-with-manually-created-elements.melodymodeller.bridgetraces | ||
// Expected: model-with-manually-created-elements.capella.bridgetraces | ||
|
||
private static boolean hasTraceExtension(IResource resource) { | ||
return resource != null && IResource.FILE == resource.getType() | ||
&& TRACE_FILE_EXTENSION.equals(resource.getFileExtension()); | ||
} | ||
|
||
private static boolean hasSecondaryExtension(IResource resource, String expectedExtension) { | ||
if (expectedExtension != null && hasTraceExtension(resource)) { | ||
IPath resourcePath = resource.getFullPath(); | ||
IPath capellaResourcePath = resourcePath.removeFileExtension(); | ||
String capellaResourceExtension = capellaResourcePath.getFileExtension(); | ||
return expectedExtension.equals(capellaResourceExtension); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public static boolean isLegacyTraceResource(IResource resource) { | ||
return hasSecondaryExtension(resource, CapellaResourceHelper.LEGACY_CAPELLA_MODEL_FILE_EXTENSION); | ||
} | ||
|
||
public static boolean isTraceResource(IResource resource) { | ||
return hasSecondaryExtension(resource, CapellaResourceHelper.CAPELLA_MODEL_FILE_EXTENSION); | ||
} | ||
|
||
public static IPath convertLegacyTracePathToModern(IPath tracePath) { | ||
IPath legacyCapellaResourcePath = tracePath.removeFileExtension(); | ||
IPath modernCapellaResourcePath = CapellaResourceHelper | ||
.convertLegacyResourcePathToModern(legacyCapellaResourcePath); | ||
|
||
return modernCapellaResourcePath.addFileExtension(TRACE_FILE_EXTENSION); | ||
} | ||
|
||
public static void renameLegacyTraceFile(IFile traceFile) throws CoreException { | ||
IPath legacyTracePath = traceFile.getFullPath(); | ||
IPath modernTracePath = convertLegacyTracePathToModern(legacyTracePath); | ||
|
||
traceFile.move(modernTracePath, true, new NullProgressMonitor()); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...s/src/org/polarsys/capella/vp/requirements/model/migration/TraceMigrationContributor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 THALES GLOBAL SERVICES. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.vp.requirements.model.migration; | ||
|
||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.IResource; | ||
import org.polarsys.capella.core.data.migration.AbstractMigrationRunnable; | ||
import org.polarsys.capella.core.data.migration.MigrationConstants; | ||
import org.polarsys.capella.core.data.migration.contributor.AbstractMigrationContributor; | ||
import org.polarsys.capella.vp.requirements.model.helpers.TraceHelper; | ||
|
||
public class TraceMigrationContributor extends AbstractMigrationContributor { | ||
|
||
/** | ||
* @param member | ||
* @return | ||
*/ | ||
@Override | ||
public boolean isValidResource(IResource resource) { | ||
return TraceHelper.isLegacyTraceResource(resource); | ||
} | ||
|
||
@Override | ||
public String getKind() { | ||
return MigrationConstants.MIGRATION_KIND__SEMANTIC; | ||
} | ||
|
||
@Override | ||
public AbstractMigrationRunnable getRunnable(IFile file) { | ||
return new TraceMigrationRunnable(file); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...lpers/src/org/polarsys/capella/vp/requirements/model/migration/TraceMigrationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 THALES GLOBAL SERVICES. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.vp.requirements.model.migration; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.osgi.util.NLS; | ||
import org.eclipse.ui.handlers.HandlerUtil; | ||
import org.polarsys.capella.core.data.migration.AbstractMigrationRunnable; | ||
import org.polarsys.capella.core.data.migration.Messages; | ||
import org.polarsys.capella.core.data.migration.MigrationJobScheduler; | ||
import org.polarsys.capella.core.data.migration.context.MigrationContext; | ||
import org.polarsys.capella.core.data.migration.handlers.AbstractMigrationHandler; | ||
import org.polarsys.capella.vp.requirements.model.helpers.TraceHelper; | ||
|
||
public class TraceMigrationHandler extends AbstractMigrationHandler { | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException { | ||
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); | ||
|
||
for (Object element : selection.toArray()) { | ||
if (element instanceof IFile) { | ||
IFile traceFile = (IFile) element; | ||
|
||
MigrationContext context = new MigrationContext(); | ||
context.setName(NLS.bind(Messages.MigrationAction_Title, traceFile.getName())); | ||
context.setShell(HandlerUtil.getActiveShell(event)); | ||
context.setSkipConfirmation(false); | ||
context.setBackupModel(false); | ||
|
||
AbstractMigrationRunnable migrationRunnable = new TraceMigrationRunnable(traceFile); | ||
LinkedList<AbstractMigrationRunnable> runnables = new LinkedList<>(); | ||
runnables.add(migrationRunnable); | ||
|
||
new MigrationJobScheduler().run(runnables, context, true, false); | ||
} | ||
} | ||
|
||
return event; | ||
|
||
} | ||
|
||
@Override | ||
protected boolean isValidSelection(List<Object> selection) { | ||
return selection.stream().allMatch(o -> o instanceof IFile && TraceHelper.isLegacyTraceResource((IFile) o)); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
...pers/src/org/polarsys/capella/vp/requirements/model/migration/TraceMigrationRunnable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 THALES GLOBAL SERVICES. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.vp.requirements.model.migration; | ||
|
||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.Status; | ||
import org.polarsys.capella.core.data.migration.AbstractMigrationRunnable; | ||
import org.polarsys.capella.core.data.migration.context.MigrationContext; | ||
import org.polarsys.capella.vp.requirements.model.helpers.TraceHelper; | ||
|
||
public class TraceMigrationRunnable extends AbstractMigrationRunnable { | ||
|
||
public TraceMigrationRunnable(IFile file) { | ||
super(file); | ||
} | ||
|
||
@Override | ||
public IStatus run(MigrationContext context, boolean checkVersion) { | ||
IFile traceFile = getFile(); | ||
|
||
if (TraceHelper.isLegacyTraceResource(traceFile)) { | ||
try { | ||
TraceHelper.renameLegacyTraceFile(traceFile); | ||
} catch (CoreException exception) { | ||
return new Status(IStatus.ERROR, TraceMigrationRunnable.class, exception.getMessage(), exception); | ||
} | ||
|
||
} | ||
return Status.OK_STATUS; | ||
} | ||
} |
Oops, something went wrong.