aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Revol2017-09-22 05:11:42 -0400
committervincent lorenzo2017-09-29 04:55:11 -0400
commit2a31b2040ac80b69a8321f160c616f713ce155aa (patch)
tree2df89e65d44016412758b5dc8c28cd5115afd1ab
parentd368b639835790932c19d0c61fd855a23b464ab0 (diff)
downloadorg.eclipse.papyrus-2a31b2040ac80b69a8321f160c616f713ce155aa.zip
org.eclipse.papyrus-2a31b2040ac80b69a8321f160c616f713ce155aa.tar.gz
org.eclipse.papyrus-2a31b2040ac80b69a8321f160c616f713ce155aa.tar.xz
Bug 522631 - [Table] Improve performance of table displaying stereotype
attributes - Manage performances for synchronized tables - Modify the JUnit test to manage resources Change-Id: I0fb976d1a3b2b730f99617269e6c2ff0d8d75a29 Signed-off-by: Sebastien Revol <sebastien.revol@cea.fr> Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java29
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.di2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.notation2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.di2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.notation2
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.uml20
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.uml6
-rw-r--r--tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/UMLTableUtilsTest.java41
8 files changed, 79 insertions, 25 deletions
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java
index a31292d..66460c1 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 2017 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 435417
+ * Sebastien REVOL (CEA LIST) sebastien.revol@cea.fr - Bug 522631
*
*****************************************************************************/
package org.eclipse.papyrus.uml.nattable.utils;
@@ -42,6 +43,8 @@ import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.util.UMLUtil;
/**
*
@@ -194,26 +197,14 @@ public class UMLTableUtils {
}
if (null != nearestPackage) {
- // Bug 435417 : Search the properties by their qualified name instead of search by its stereotypes first
- // This allows to manage the inherit properties and the stereotypes in packages
- final Iterator<Profile> appliedProfilesIterator = nearestPackage.getAllAppliedProfiles().iterator();
- while(appliedProfilesIterator.hasNext() && null == result){
- final Profile appliedProfile = appliedProfilesIterator.next();
- // Bug 488082 : Loop on all stereotypes (check in sub packages)
- final Iterator<Stereotype> stereotypesIterator = StereotypeUtil.getAllStereotypes(appliedProfile).iterator();
- while(stereotypesIterator.hasNext() && null == result){
- final Stereotype ownedStereotype = stereotypesIterator.next();
- final Iterator<Property> propertiesIterator = ownedStereotype.getAllAttributes().iterator();
- while(propertiesIterator.hasNext() && null == result){
- final Property property = propertiesIterator.next();
- if(property.getQualifiedName().equals(propertyQN)){
- result = property;
- }
- }
- }
- }
+ result = UMLUtil.<Property>findNamedElements(nearestPackage.eResource().getResourceSet(),propertyQN , false, UMLPackage.eINSTANCE.getProperty())
+ .stream()
+ .findFirst()
+ .orElse(null) ;
+
+ //TODO should we still keep that? FindNamedElement browse all the resourceSet.
// 2. if not, the profile could be applied on a sub-package of the nearest package
/* the table can show element which are not children of its context, so the profile could not be available in its context */
if(null == result){
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.di
new file mode 100644
index 0000000..0812886
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.di
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<architecture:ArchitectureDescription xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:architecture="http://www.eclipse.org/papyrus/infra/core/architecture" contextId="org.eclipse.papyrus.infra.services.edit.TypeContext"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.notation
new file mode 100644
index 0000000..8634d4c
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.notation
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.di b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.di
new file mode 100644
index 0000000..4f26340
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.di
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<architecture:ArchitectureDescription xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:architecture="http://www.eclipse.org/papyrus/infra/core/architecture" contextId="org.eclipse.papyrus.uml.architecture.Profile"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.notation b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.notation
new file mode 100644
index 0000000..8634d4c
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.notation
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.uml
new file mode 100644
index 0000000..0172d20
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.profile.uml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Profile xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_QxR48J-YEeeKcbwPMn2SnA" name="ProfileRootElement">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_XnZcMJ-YEeeKcbwPMn2SnA" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <contents xmi:type="ecore:EPackage" xmi:id="_XnaDQJ-YEeeKcbwPMn2SnA" name="ProfileRootElement" nsURI="http:///schemas/ProfileRootElement/_XnYOEJ-YEeeKcbwPMn2SnA/0" nsPrefix="ProfileRootElement">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_Xnb4cJ-YEeeKcbwPMn2SnA" source="PapyrusVersion">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Xnb4cZ-YEeeKcbwPMn2SnA" key="Version" value="0.0.1"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Xnb4cp-YEeeKcbwPMn2SnA" key="Comment" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Xnb4c5-YEeeKcbwPMn2SnA" key="Copyright" value=""/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Xnb4dJ-YEeeKcbwPMn2SnA" key="Date" value="2017-09-22"/>
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Xnb4dZ-YEeeKcbwPMn2SnA" key="Author" value=""/>
+ </eAnnotations>
+ </contents>
+ </eAnnotations>
+ <packageImport xmi:type="uml:PackageImport" xmi:id="_Q6_1oJ-YEeeKcbwPMn2SnA">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+ </packageImport>
+ <packageImport xmi:type="uml:PackageImport" xmi:id="_Q7CR4J-YEeeKcbwPMn2SnA">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML_METAMODELS/UML.metamodel.uml#_0"/>
+ </packageImport>
+</uml:Profile>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.uml b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.uml
new file mode 100644
index 0000000..978b238
--- /dev/null
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/resources/UMLTableUtils/model.uml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_aakHYJ-YEeeKcbwPMn2SnA" name="RootElement">
+ <packageImport xmi:type="uml:PackageImport" xmi:id="_afiuAJ-YEeeKcbwPMn2SnA">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+ </packageImport>
+</uml:Model>
diff --git a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/UMLTableUtilsTest.java b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/UMLTableUtilsTest.java
index e571228..8104761 100644
--- a/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/UMLTableUtilsTest.java
+++ b/tests/junit/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.tests/src/org/eclipse/papyrus/uml/nattable/tests/tests/UMLTableUtilsTest.java
@@ -13,7 +13,15 @@
package org.eclipse.papyrus.uml.nattable.tests.tests;
+import java.io.IOException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
+import org.eclipse.papyrus.uml.nattable.tests.Activator;
import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.NamedElement;
@@ -25,6 +33,7 @@ import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
/**
@@ -57,7 +66,17 @@ public class UMLTableUtilsTest extends AbstractPapyrusTest {
*/
protected final static String SECOND_PROPERTY_NAME = "MyProperty2"; //$NON-NLS-1$
-
+ /**
+ * The house keeper.
+ */
+ @Rule
+ public final HouseKeeper houseKeeper = new HouseKeeper();
+
+ /**
+ * The resource set containing the needed resources for the test.
+ */
+ private ResourceSet resourceSet;
+
/**
* Reference to the created class in the root element.
*/
@@ -82,12 +101,20 @@ public class UMLTableUtilsTest extends AbstractPapyrusTest {
/**
* This allows to create the models needed for the JUnit tests.
+ *
+ * @throws IOException
*/
@Before
- public void initModel() {
+ public void initModel() throws IOException {
+
+ resourceSet = houseKeeper.createResourceSet();
+ EMFHelper.loadEMFModel(resourceSet, URI.createPlatformPluginURI(Activator.PLUGIN_ID + "/resources/UMLTableUtils/model.profile.di", true)); //$NON-NLS-1$
+ final Resource umlProfileModel = resourceSet.getResource(URI.createPlatformPluginURI(Activator.PLUGIN_ID + "/resources/UMLTableUtils/model.profile.uml", true), true); //$NON-NLS-1$
+
+ //we inits the field of this class
+ final Profile profileRootElement = (Profile) umlProfileModel.getContents().get(0);
+
// Create the profile model
- final Profile profileRootElement = UMLFactory.eINSTANCE.createProfile();
- profileRootElement.setName(PROFILE_ROOT_ELEMENT_NAME);
final Package packageInProfile = UMLFactory.eINSTANCE.createPackage();
packageInProfile.setName(PACKAGE_IN_PROFILE_NAME);
profileRootElement.getPackagedElements().add(packageInProfile);
@@ -101,9 +128,11 @@ public class UMLTableUtilsTest extends AbstractPapyrusTest {
stereotypeInPackage.getOwnedAttributes().add(firstPropertyInStereotype);
stereotypeInPackage.getOwnedAttributes().add(secondPropertyInStereotype);
+ EMFHelper.loadEMFModel(resourceSet, URI.createPlatformPluginURI(Activator.PLUGIN_ID + "/resources/UMLTableUtils/model.di", true)); //$NON-NLS-1$
+ final Resource umlModel = resourceSet.getResource(URI.createPlatformPluginURI(Activator.PLUGIN_ID + "/resources/UMLTableUtils/model.uml", true), true); //$NON-NLS-1$
+
// Create another model
- final Model rootElement = UMLFactory.eINSTANCE.createModel();
- rootElement.setName("RootElement"); //$NON-NLS-1$
+ final Model rootElement = (Model) umlModel.getContents().get(0);
ProfileApplication createdProfileApplication = UMLFactory.eINSTANCE.createProfileApplication();
createdProfileApplication.setAppliedProfile(profileRootElement);
rootElement.getProfileApplications().add(createdProfileApplication);