Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Fasani2015-12-21 18:00:26 +0000
committerLaurent Fasani2016-01-08 10:59:00 +0000
commitec09880f74a2fb0d9417c927ce083a33f84ae0b3 (patch)
treef86cde778d10396d3c3cd9ac495ce6d7c74fc0bc
parent23e0b5ce75162c20917f2453108b73e662efeca4 (diff)
downloadorg.eclipse.sirius-ec09880f74a2fb0d9417c927ce083a33f84ae0b3.tar.gz
org.eclipse.sirius-ec09880f74a2fb0d9417c927ce083a33f84ae0b3.tar.xz
org.eclipse.sirius-ec09880f74a2fb0d9417c927ce083a33f84ae0b3.zip
[483574] Add migration participant
Add migration participant for VSM and aird file. Add tests Bug: 483574 Change-Id: I9859b43a940c0c39000574f5810dfb166a028980 Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/plugin.xml8
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/FilterVariableValueMigrationParticipant.java67
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/description/VariableMigrationParticipant.java61
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.aird64
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.ecore6
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.odesign38
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/migration/VariableMigrationTest.java202
7 files changed, 446 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml
index 6c4d9fb250..424718fe15 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml
+++ b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml
@@ -1848,6 +1848,14 @@
class="org.eclipse.sirius.diagram.ui.business.internal.migration.BorderSizeRepresentationFileMigrationParticipant"
kind="RepresentationsFile">
</participant>
+ <participant
+ class="org.eclipse.sirius.diagram.ui.business.internal.migration.FilterVariableValueMigrationParticipant"
+ kind="RepresentationsFile">
+ </participant>
+ <participant
+ class="org.eclipse.sirius.diagram.ui.business.internal.migration.description.VariableMigrationParticipant"
+ kind="VSM">
+ </participant>
</extension>
<extension point="org.eclipse.emf.edit.itemProviderAdapterFactories">
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/FilterVariableValueMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/FilterVariableValueMigrationParticipant.java
new file mode 100644
index 0000000000..549965580b
--- /dev/null
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/FilterVariableValueMigrationParticipant.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.diagram.ui.business.internal.migration;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.sirius.business.api.migration.AbstractRepresentationsFileMigrationParticipant;
+import org.eclipse.sirius.diagram.DiagramPackage;
+import org.eclipse.sirius.viewpoint.description.tool.ToolPackage;
+import org.osgi.framework.Version;
+
+/**
+ * Replace all instance of FilterVariableValue by {@link EObjectVariableValue}.
+ *
+ * @author <a href="mailto:laurent.fasani@obeo.fr">Laurent Fasani</a>
+ */
+public class FilterVariableValueMigrationParticipant extends AbstractRepresentationsFileMigrationParticipant {
+
+ /**
+ * The version for which this migration is added.
+ */
+ public static final Version MIGRATION_VERSION = new Version("10.1.3.201601041200"); //$NON-NLS-1$
+
+ @Override
+ public Version getMigrationVersion() {
+ return MIGRATION_VERSION;
+ }
+
+ @Override
+ public EClassifier getType(EPackage ePackage, String name, String loadedVersion) {
+ EClassifier eClass = null;
+ if (Version.parseVersion(loadedVersion).compareTo(MIGRATION_VERSION) < 0) {
+ if (name.equals("FilterVariableValue")) { //$NON-NLS-1$
+ eClass = DiagramPackage.eINSTANCE.getEObjectVariableValue();
+ }
+ if (name.equals("FilterVariable")) { //$NON-NLS-1$
+ eClass = ToolPackage.eINSTANCE.getSelectModelElementVariable();
+ }
+ }
+ return eClass;
+ }
+
+ @Override
+ public EStructuralFeature getLocalElement(EClass eClass, String name, String loadedVersion) {
+ EStructuralFeature feature = null;
+ if (Version.parseVersion(loadedVersion).compareTo(MIGRATION_VERSION) < 0) {
+ if (DiagramPackage.eINSTANCE.getEObjectVariableValue().equals(eClass)) {
+ if (name.equals("variableDefinition")) { //$NON-NLS-1$
+ feature = DiagramPackage.eINSTANCE.getEObjectVariableValue_VariableDefinition();
+ } else if (name.equals("modelElement")) { //$NON-NLS-1$
+ feature = DiagramPackage.eINSTANCE.getEObjectVariableValue_ModelElement();
+ }
+ }
+ }
+ return feature;
+ }
+}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/description/VariableMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/description/VariableMigrationParticipant.java
new file mode 100644
index 0000000000..2aacf9a263
--- /dev/null
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/description/VariableMigrationParticipant.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.diagram.ui.business.internal.migration.description;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.sirius.business.api.migration.AbstractVSMMigrationParticipant;
+import org.eclipse.sirius.viewpoint.description.tool.ToolPackage;
+import org.osgi.framework.Version;
+
+/**
+ * Replace the old instance of FilterVariable by an instance of
+ * SelectModelElementVariable.
+ *
+ * @author <a href="mailto:laurent.fasani@obeo.fr">Laurent Fasani</a>
+ */
+public class VariableMigrationParticipant extends AbstractVSMMigrationParticipant {
+ /**
+ * The version for which this migration is added.
+ */
+ public static final Version MIGRATION_VERSION = new Version("10.1.3.201601041200"); //$NON-NLS-1$
+
+ @Override
+ public Version getMigrationVersion() {
+ return MIGRATION_VERSION;
+ }
+
+ @Override
+ public EClassifier getType(EPackage ePackage, String name, String loadedVersion) {
+ if (Version.parseVersion(loadedVersion).compareTo(MIGRATION_VERSION) < 0) {
+ // ownedVariables was of concrete type FilterVariable, so xsi::type
+ // was not serialized. Thus, the required type of the class is asked
+ // with the name of the new feature type and not with
+ // "VariableFilter"
+ if (name.equals("InteractiveVariableDescription")) { //$NON-NLS-1$
+ return ToolPackage.eINSTANCE.getSelectModelElementVariable();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public EStructuralFeature getLocalElement(EClass eClass, String name, String loadedVersion) {
+ if (Version.parseVersion(loadedVersion).compareTo(MIGRATION_VERSION) < 0) {
+ if (org.eclipse.sirius.diagram.description.filter.FilterPackage.eINSTANCE.getVariableFilter().equals(eClass) && name.equals("ownedVariables")) { //$NON-NLS-1$
+ return org.eclipse.sirius.diagram.description.filter.FilterPackage.eINSTANCE.getVariableFilter_OwnedVariables();
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.aird b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.aird
new file mode 100644
index 0000000000..dba3c86191
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.aird
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<viewpoint:DAnalysis xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:diagram="http://www.eclipse.org/sirius/diagram/1.1.0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:filter="http://www.eclipse.org/sirius/diagram/description/filter/1.1.0" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description http://www.eclipse.org/sirius/diagram/description/filter/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/filter http://www.eclipse.org/sirius/diagram/description/style/1.1.0 http://www.eclipse.org/sirius/diagram/1.1.0#//description/style" xmi:id="_LzkCAKMpEeWhmpHp1N50Xg" selectedViews="_v0iCMK7XEeWCKa5bQ33Yhg" version="10.1.0.201509162000">
+ <semanticResources>filterMigration.ecore</semanticResources>
+ <ownedViews xmi:type="viewpoint:DRepresentationContainer" xmi:id="_v0iCMK7XEeWCKa5bQ33Yhg">
+ <ownedRepresentations xmi:type="diagram:DSemanticDiagram" xmi:id="_1kaWIK7XEeWCKa5bQ33Yhg" name="new ClassDiagram">
+ <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_1kaWIa7XEeWCKa5bQ33Yhg" source="DANNOTATION_CUSTOMIZATION_KEY">
+ <data xmi:type="diagram:ComputedStyleDescriptionRegistry" xmi:id="_1kaWIq7XEeWCKa5bQ33Yhg"/>
+ </ownedAnnotationEntries>
+ <ownedAnnotationEntries xmi:type="description:AnnotationEntry" xmi:id="_1k9IsK7XEeWCKa5bQ33Yhg" source="GMF_DIAGRAMS">
+ <data xmi:type="notation:Diagram" xmi:id="_1k9Isa7XEeWCKa5bQ33Yhg" type="Sirius" element="_1kaWIK7XEeWCKa5bQ33Yhg" measurementUnit="Pixel">
+ <children xmi:type="notation:Node" xmi:id="_5lQVYK7XEeWCKa5bQ33Yhg" type="2002" element="_5kuw8K7XEeWCKa5bQ33Yhg">
+ <children xmi:type="notation:Node" xmi:id="_5lXqIK7XEeWCKa5bQ33Yhg" type="5006"/>
+ <children xmi:type="notation:Node" xmi:id="_5laGYK7XEeWCKa5bQ33Yhg" type="7001">
+ <styles xmi:type="notation:SortingStyle" xmi:id="_5latcK7XEeWCKa5bQ33Yhg"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_5latca7XEeWCKa5bQ33Yhg"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_5lQVYa7XEeWCKa5bQ33Yhg" fontName="Segoe UI" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_5lQVYq7XEeWCKa5bQ33Yhg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_5lbUgK7XEeWCKa5bQ33Yhg" visible="false" type="2002" element="_5lBE0K7XEeWCKa5bQ33Yhg">
+ <children xmi:type="notation:Node" xmi:id="_5lcioK7XEeWCKa5bQ33Yhg" type="5006"/>
+ <children xmi:type="notation:Node" xmi:id="_5lcioa7XEeWCKa5bQ33Yhg" type="7001">
+ <styles xmi:type="notation:SortingStyle" xmi:id="_5lcioq7XEeWCKa5bQ33Yhg"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_5lcio67XEeWCKa5bQ33Yhg"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_5lbUga7XEeWCKa5bQ33Yhg" fontName="Segoe UI" fontHeight="8"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_5lbUgq7XEeWCKa5bQ33Yhg" x="210"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_1k9Isq7XEeWCKa5bQ33Yhg"/>
+ </data>
+ </ownedAnnotationEntries>
+ <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_5kuw8K7XEeWCKa5bQ33Yhg" name="class1">
+ <target xmi:type="ecore:EClass" href="filterMigration.ecore#//class1"/>
+ <semanticElements xmi:type="ecore:EClass" href="filterMigration.ecore#//class1"/>
+ <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_5k9acK7XEeWCKa5bQ33Yhg" borderSize="1" borderSizeComputationExpression="1">
+ <description xmi:type="style:FlatContainerStyleDescription" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']/@ownedRepresentations[name='ClassDiagram']/@defaultLayer/@containerMappings[name='EClass']/@style"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:ContainerMapping" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']/@ownedRepresentations[name='ClassDiagram']/@defaultLayer/@containerMappings[name='EClass']"/>
+ </ownedDiagramElements>
+ <ownedDiagramElements xmi:type="diagram:DNodeContainer" xmi:id="_5lBE0K7XEeWCKa5bQ33Yhg" name="class2" visible="false">
+ <target xmi:type="ecore:EClass" href="filterMigration.ecore#//class2"/>
+ <semanticElements xmi:type="ecore:EClass" href="filterMigration.ecore#//class2"/>
+ <graphicalFilters xmi:type="diagram:AppliedCompositeFilters" xmi:id="_nZujoK7YEeWCKa5bQ33Yhg">
+ <compositeFilterDescriptions xmi:type="filter:CompositeFilterDescription" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']/@ownedRepresentations[name='ClassDiagram']/@filters[name='ClassFilter']"/>
+ </graphicalFilters>
+ <ownedStyle xmi:type="diagram:FlatContainerStyle" xmi:id="_5lBr4K7XEeWCKa5bQ33Yhg" borderSize="1" borderSizeComputationExpression="1">
+ <description xmi:type="style:FlatContainerStyleDescription" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']/@ownedRepresentations[name='ClassDiagram']/@defaultLayer/@containerMappings[name='EClass']/@style"/>
+ </ownedStyle>
+ <actualMapping xmi:type="description_1:ContainerMapping" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']/@ownedRepresentations[name='ClassDiagram']/@defaultLayer/@containerMappings[name='EClass']"/>
+ </ownedDiagramElements>
+ <description xmi:type="description_1:DiagramDescription" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']/@ownedRepresentations[name='ClassDiagram']"/>
+ <activatedFilters xmi:type="filter:CompositeFilterDescription" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']/@ownedRepresentations[name='ClassDiagram']/@filters[name='ClassFilter']"/>
+ <filterVariableHistory xmi:type="diagram:FilterVariableHistory" xmi:id="_1kaWI67XEeWCKa5bQ33Yhg">
+ <ownedValues xmi:type="diagram:FilterVariableValue" xmi:id="_nZsHYK7YEeWCKa5bQ33Yhg">
+ <variableDefinition xmi:type="filter:FilterVariable" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']/@ownedRepresentations[name='ClassDiagram']/@filters[name='ClassFilter']/@filters.0/@ownedVariables.0"/>
+ <modelElement xmi:type="ecore:EClass" href="filterMigration.ecore#//class1"/>
+ </ownedValues>
+ </filterVariableHistory>
+ <activatedLayers xmi:type="description_1:Layer" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']/@ownedRepresentations[name='ClassDiagram']/@defaultLayer"/>
+ <target xmi:type="ecore:EPackage" href="filterMigration.ecore#/"/>
+ </ownedRepresentations>
+ <viewpoint xmi:type="description:Viewpoint" href="filterMigration.odesign#//@ownedViewpoints[name='vpFilter']"/>
+ </ownedViews>
+</viewpoint:DAnalysis>
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.ecore b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.ecore
new file mode 100644
index 0000000000..68ea2f1178
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.ecore
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="P0" nsPrefix="">
+ <eClassifiers xsi:type="ecore:EClass" name="class1"/>
+ <eClassifiers xsi:type="ecore:EClass" name="class2"/>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.odesign
new file mode 100644
index 0000000000..b6d59aa67b
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/migration/variableFilter/filterMigration.odesign
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:filter="http://www.eclipse.org/sirius/diagram/description/filter/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" version="10.1.3.201511131800">
+ <ownedViewpoints name="vpFilter">
+ <ownedRepresentations xsi:type="description_1:DiagramDescription" name="ClassDiagram" domainClass="EPackage">
+ <filters xsi:type="filter:CompositeFilterDescription" name="ClassFilter">
+ <filters xsi:type="filter:VariableFilter" semanticConditionExpression="aql:MyVariable->includes(self)">
+ <ownedVariables candidatesExpression="aql:self.eContents()" multiple="true" message="message" name="MyVariable"/>
+ </filters>
+ </filters>
+ <defaultLayer name="Default">
+ <containerMappings name="EClass" domainClass="EClass">
+ <style xsi:type="style:FlatContainerStyleDescription" arcWidth="1" arcHeight="1" borderSizeComputationExpression="1">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </containerMappings>
+ <containerMappings name="EEnum" domainClass="EEnum">
+ <style xsi:type="style:FlatContainerStyleDescription" arcWidth="1" arcHeight="1" borderSizeComputationExpression="1">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </containerMappings>
+ <containerMappings name="EPackage" domainClass="EPackage">
+ <style xsi:type="style:FlatContainerStyleDescription" arcWidth="1" arcHeight="1" borderSizeComputationExpression="1">
+ <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
+ <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
+ <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='light_gray']"/>
+ </style>
+ </containerMappings>
+ </defaultLayer>
+ </ownedRepresentations>
+ </ownedViewpoints>
+</description:Group>
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/migration/VariableMigrationTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/migration/VariableMigrationTest.java
new file mode 100644
index 0000000000..aab9eb35d6
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/migration/VariableMigrationTest.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.tests.unit.common.migration;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.sirius.business.internal.migration.RepresentationsFileMigrationService;
+import org.eclipse.sirius.business.internal.migration.description.VSMMigrationService;
+import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.diagram.EObjectVariableValue;
+import org.eclipse.sirius.diagram.FilterVariableHistory;
+import org.eclipse.sirius.diagram.VariableValue;
+import org.eclipse.sirius.diagram.description.DiagramDescription;
+import org.eclipse.sirius.diagram.description.filter.CompositeFilterDescription;
+import org.eclipse.sirius.diagram.description.filter.VariableFilter;
+import org.eclipse.sirius.diagram.tools.api.command.IDiagramCommandFactory;
+import org.eclipse.sirius.diagram.ui.business.internal.migration.FilterVariableValueMigrationParticipant;
+import org.eclipse.sirius.diagram.ui.business.internal.migration.description.VariableMigrationParticipant;
+import org.eclipse.sirius.ecore.extender.tool.api.ModelUtils;
+import org.eclipse.sirius.tests.SiriusTestsPlugin;
+import org.eclipse.sirius.tests.support.api.SiriusTestCase;
+import org.eclipse.sirius.viewpoint.DAnalysis;
+import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.description.Group;
+import org.eclipse.sirius.viewpoint.description.InteractiveVariableDescription;
+import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
+import org.eclipse.sirius.viewpoint.description.tool.SelectModelElementVariable;
+import org.osgi.framework.Version;
+
+/**
+ * Ensures correct migration from FilterVariable to SelectModelElementVariable
+ * and from FilterVariableValue to EObjectVariableValue.
+ *
+ * @author <a href="mailto:laurent.fasani@obeo.fr">Laurent Fasani</a>
+ */
+public class VariableMigrationTest extends SiriusTestCase {
+
+ private static final String REPRESENTATIONS_FILE_PATH = "/data/unit/migration/variableFilter/";
+
+ private static final String REPRESENTATIONS_FILE_NAME = "filterMigration.aird";
+
+ private static final String MODEL_FILE_NAME = "filterMigration.ecore";
+
+ private static final String MODELER_FILE_NAME = "filterMigration.odesign";
+
+ @Override
+ protected IDiagramCommandFactory getCommandFactory() {
+ return null;
+ }
+
+ /**
+ * Test that the data were not migrated. It allows to check the effect of
+ * the migration in the other test.
+ */
+ public void testRepMigrationIsNeededOnData() {
+ Version loadedVersion = checkRepresentationFileMigrationStatus(URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + REPRESENTATIONS_FILE_PATH + REPRESENTATIONS_FILE_NAME, true), true);
+
+ // Check that the migration is needed.
+ Version migration = FilterVariableValueMigrationParticipant.MIGRATION_VERSION;
+ assertTrue("The migration must be required on test data.", loadedVersion == null || migration.compareTo(loadedVersion) > 0);
+ }
+
+ /**
+ * Test that the data were not migrated. It allows to check the effect of
+ * the migration in the other test.
+ */
+ public void testVSMMigrationIsNeededOnData() {
+ Version loadedVersion = checkVsmFileMigrationStatus(URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + REPRESENTATIONS_FILE_PATH + MODELER_FILE_NAME, true), true);
+
+ // Check that the migration is needed.
+ Version migration = VariableMigrationParticipant.MIGRATION_VERSION;
+ assertTrue("The migration must be required on test data.", loadedVersion == null || migration.compareTo(loadedVersion) > 0);
+ }
+
+ /**
+ * Check that the instances of FilterVariableHistory.ownedValues are
+ * correctly converted into EObjectVariableValue
+ */
+ public void testFilterVariableValueToEObjectVariableValueMigration() {
+ copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, REPRESENTATIONS_FILE_PATH, REPRESENTATIONS_FILE_NAME, MODEL_FILE_NAME, MODELER_FILE_NAME);
+
+ ResourceSet set = new ResourceSetImpl();
+ DAnalysis analysis = null;
+ try {
+ analysis = (DAnalysis) ModelUtils.load(URI.createPlatformResourceURI(TEMPORARY_PROJECT_NAME + "/" + REPRESENTATIONS_FILE_NAME, true), set);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // Check that the migration was done.
+
+ assertNotNull("Analysis is not retrieved.", analysis);
+
+ // The version will change on save, so migration service will still
+ // indicates that the migration is needed.
+ String version = analysis.getVersion();
+ assertTrue("Before save, the migration framework will return true even if the migration has been done during load.",
+ RepresentationsFileMigrationService.getInstance().isMigrationNeeded(Version.parseVersion(version)));
+
+ try {
+ analysis.eResource().save(Collections.emptyMap());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ // save should update the version.
+ version = analysis.getVersion();
+ assertFalse("The version tag should now be set telling that the migration was done.", RepresentationsFileMigrationService.getInstance().isMigrationNeeded(Version.parseVersion(version)));
+
+ // We can now check the migration effect to be sure that the migration
+ // is effective.
+ checkRepMigrationEffect(analysis);
+
+ }
+
+ private void checkRepMigrationEffect(DAnalysis analysis) {
+ DRepresentation dView = analysis.getOwnedViews().get(0).getOwnedRepresentations().get(0);
+ if (dView instanceof DDiagram) {
+ DDiagram diagram = (DDiagram) dView;
+ FilterVariableHistory filterVariableHistory = diagram.getFilterVariableHistory();
+ EList<VariableValue> ownedValues = filterVariableHistory.getOwnedValues();
+ VariableValue variableValue = ownedValues.get(0);
+
+ assertTrue("FilterVariableHistory.ownedValues should be of type EObjectVariableValue", variableValue instanceof EObjectVariableValue);
+ EObjectVariableValue objectValue = (EObjectVariableValue) variableValue;
+ EObject modelElement = objectValue.getModelElement();
+ assertNotNull("EObjectVariableValue.modelElement is not set", modelElement);
+ SelectModelElementVariable variableDefinition = objectValue.getVariableDefinition();
+ assertNotNull("EObjectVariableValue.variableDefinition is not set", variableDefinition);
+ }
+ }
+
+ /**
+ * Check that the instances of FilterVariableHistory.ownedValues are
+ * correctly converted into EObjectVariableValue
+ */
+ public void testFilterVariableToSelectModelElementVariableMigration() {
+ copyFilesToTestProject(SiriusTestsPlugin.PLUGIN_ID, REPRESENTATIONS_FILE_PATH, MODELER_FILE_NAME);
+
+ ResourceSet set = new ResourceSetImpl();
+ Group group = null;
+ try {
+ group = (Group) ModelUtils.load(URI.createPlatformResourceURI(TEMPORARY_PROJECT_NAME + "/" + MODELER_FILE_NAME, true), set);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // Check that the migration was done.
+
+ assertNotNull("Group is not retrieved.", group);
+
+ // The version will change on save, so migration service will still
+ // indicates that the migration is needed.
+ String version = group.getVersion();
+ assertTrue("Before save, the migration framework will return true even if the migration has been done during load.",
+ VSMMigrationService.getInstance().isMigrationNeeded(Version.parseVersion(version)));
+
+ try {
+ group.eResource().save(Collections.emptyMap());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ // save should update the version.
+ version = group.getVersion();
+ assertFalse("The version tag should now be set telling that the migration was done.", VSMMigrationService.getInstance().isMigrationNeeded(Version.parseVersion(version)));
+
+ // We can now check the migration effect to be sure that the migration
+ // is effective.
+ checkVSMMigrationEffect(group);
+
+ }
+
+ private void checkVSMMigrationEffect(Group group) {
+ RepresentationDescription representationDescription = group.getOwnedViewpoints().get(0).getOwnedRepresentations().get(0);
+ if (representationDescription instanceof DiagramDescription) {
+ DiagramDescription diagramDesc = (DiagramDescription) representationDescription;
+ InteractiveVariableDescription interactiveVariableDescription = ((VariableFilter) ((CompositeFilterDescription) diagramDesc.getFilters().get(0)).getFilters().get(0)).getOwnedVariables()
+ .get(0);
+
+ assertTrue("VariableFilter.ownedVariables should be of type SelectModelElementVariable", interactiveVariableDescription instanceof SelectModelElementVariable);
+
+ SelectModelElementVariable variable = (SelectModelElementVariable) interactiveVariableDescription;
+ assertEquals("Bad SelectModelElementVariable.candidatesExpression", "aql:self.eContents()", variable.getCandidatesExpression());
+
+ assertEquals("Bad SelectModelElementVariable.name", "MyVariable", variable.getName());
+ assertEquals("Bad SelectModelElementVariable.message", "message", variable.getMessage());
+ }
+ }
+}

Back to the top