diff options
author | Camille Letavernier | 2015-12-16 12:46:44 +0000 |
---|---|---|
committer | Camille Letavernier | 2015-12-16 12:46:44 +0000 |
commit | e3155394f1d12d061193f5726ef74e28498f224c (patch) | |
tree | bbbeb4a4027cd867fb6413179fa2edc28d3f28d6 | |
parent | 1811680b89946b741263e70c56e912a146bd6e12 (diff) | |
download | org.eclipse.papyrus-e3155394f1d12d061193f5726ef74e28498f224c.tar.gz org.eclipse.papyrus-e3155394f1d12d061193f5726ef74e28498f224c.tar.xz org.eclipse.papyrus-e3155394f1d12d061193f5726ef74e28498f224c.zip |
Revert "Bug 484464 - [Papyrus DSML Validation] nsURI is taken from definition in case of static profile"1.2.0M4
This reverts commit 1811680b89946b741263e70c56e912a146bd6e12.
4 files changed, 40 insertions, 115 deletions
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java index 768232e0df4..a1194510a3b 100644 --- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java +++ b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java @@ -19,8 +19,6 @@ import java.util.Map; import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category;
import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintProvider;
import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsManager;
-import org.eclipse.papyrus.dsml.validation.model.profilenames.Utils;
-import org.eclipse.papyrus.uml.tools.utils.StaticProfileUtil;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
@@ -102,8 +100,8 @@ public class ConstraintManagerImpl implements IConstraintsManager { */
private void relateCategoriesWithConstraints(Element element, Category category) {
+
if (element instanceof Profile) {
- Profile profile = (Profile) element;
// creation of a category
ConstraintCategoryImpl subCategory = new ConstraintCategoryImpl(((Profile) element).getName(), category);
@@ -115,13 +113,8 @@ public class ConstraintManagerImpl implements IConstraintsManager { // associate validation to category to provider
constraintProvider.getConstraintsCategories().add(subCategory);
constraintsProviders.add(constraintProvider);
- StaticProfileUtil staticProfile = new StaticProfileUtil(profile);
- Utils.setStaticProfile(staticProfile);
- if (staticProfile.getDefinition() != null) {
- constraintProvider.setEPackage(staticProfile.getDefinition());
- }
- else if (profile.getDefinition() != null) {
- constraintProvider.setEPackage(profile.getDefinition());
+ if (((Profile) element).getDefinition() != null) {
+ constraintProvider.setEPackage(((Profile) element).getDefinition());
}
// iterate on all direct element of the profile
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java index d1018c3fd5d..88d2047ac68 100644 --- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java +++ b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java @@ -15,10 +15,12 @@ package org.eclipse.papyrus.dsml.validation.model.profilenames; import java.util.HashMap;
import java.util.Map;
-import org.eclipse.papyrus.uml.tools.utils.StaticProfileUtil;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Namespace;
import org.eclipse.uml2.uml.OpaqueExpression;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.ValueSpecification;
@@ -32,7 +34,18 @@ public class Utils { private static final String DOT = "."; //$NON-NLS-1$
private static final String JAVA_LANGUAGE = "JAVA"; //$NON-NLS-1$
private static final String OCL_LANGUAGE = "OCL"; //$NON-NLS-1$
-
+
+ /**
+ * qualified name of EPackage stereotype (used for static profile detection)
+ */
+ public static final String EPackage_QNAME = "Ecore::EPackage"; //$NON-NLS-1$
+ /**
+ * Attributes of EPackage stereotype
+ */
+ private static final String EPKG_BASE_PACKAGE = "basePackage"; //$NON-NLS-1$
+ private static final String EPKG_PACKAGE_NAME = "packageName"; //$NON-NLS-1$
+
+
/*
* Map holding relations between String representing the qualified name of a
* constraint and name of a package to which it belongs. Package name in
@@ -107,17 +120,22 @@ public class Utils { Namespace nameSpace = constraint.getContext();
if (nameSpace instanceof Stereotype) {
- if (staticProfile != null) {
- String basePackage = staticProfile.getBasePackage();
- if (basePackage != null) {
- String packageName = staticProfile.getPackageName();
- if (packageName != null) {
- return basePackage + DOT + packageName + DOT + nameSpace.getName();
- } else {
- return basePackage + DOT + nameSpace.getQualifiedName();
+ Package profilePkg = PackageUtil.getRootPackage(constraint.getContext());
+ if (profilePkg instanceof Profile) {
+ Profile profile = (Profile) profilePkg;
+ Stereotype ePkg = profile.getAppliedStereotype(EPackage_QNAME);
+ String base = (String) profile.getValue(ePkg, EPKG_BASE_PACKAGE);
+ if (base != null) {
+ String pkgName = (String) profile.getValue(ePkg, EPKG_PACKAGE_NAME);
+ if (pkgName != null) {
+ return base + DOT + pkgName + DOT + nameSpace.getName();
+ }
+ else {
+ return base + DOT + nameSpace.getQualifiedName();
}
}
}
+ // Stereotype ePackage = umlProfile.getAppliedStereotype(EPackage_QNAME);
return nameSpace.getQualifiedName();
}
return ""; //$NON-NLS-1$
@@ -236,20 +254,20 @@ public class Utils { public static String getTopPkg() {
return pluginID.toLowerCase();
}
-
+
public static void setPluginID(String ID) {
pluginID = ID;
}
public static boolean isStaticProfile() {
- return staticProfile.getDefinition() != null;
+ return staticProfile;
}
- public static void setStaticProfile(StaticProfileUtil staticProfile) {
+ public static void setStaticProfile(boolean staticProfile) {
Utils.staticProfile = staticProfile;
}
private static String pluginID;
-
- private static StaticProfileUtil staticProfile;
+
+ private static boolean staticProfile;
}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.wizard/src/org/eclipse/papyrus/dsml/validation/wizard/JavaContentGenerator.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.wizard/src/org/eclipse/papyrus/dsml/validation/wizard/JavaContentGenerator.java index 3af86eb7933..fc492ea21f4 100644 --- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.wizard/src/org/eclipse/papyrus/dsml/validation/wizard/JavaContentGenerator.java +++ b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.wizard/src/org/eclipse/papyrus/dsml/validation/wizard/JavaContentGenerator.java @@ -25,6 +25,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.papyrus.dsml.validation.model.profilenames.Utils;
import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Stereotype;
/**
* this class generate java classes in the project
@@ -65,6 +66,9 @@ public class JavaContentGenerator { public void run(IProgressMonitor monitor) {
try {
+ // static profile apply the EPackage stereotype
+ Stereotype ePackage = umlProfile.getAppliedStereotype(Utils.EPackage_QNAME);
+ Utils.setStaticProfile(ePackage != null);
Utils.setPluginID(project.getName());
ClassesGenerator generator = new ClassesGenerator(umlProfile.eResource(), project);
generator.doGenerate(monitor);
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java deleted file mode 100644 index a71c6acf9aa..00000000000 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST and others. - * - * 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: - * CEA LIST - Initial API and implementation (Ansgar Radermacher) - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.tools.utils; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.uml2.uml.Profile; -import org.eclipse.uml2.uml.Stereotype; - - -/** - * Obtain information about an eventually applied Ecore::EPackage stereotype. - * The ecore profile should be a static one, but it is not. Therefore, information - * needs to be retrieved using the generic functions and string constants. - */ -public class StaticProfileUtil { - - /** - * qualified name of EPackage stereotype (used for static profile detection) - */ - public static final String EPackage_QNAME = "Ecore::EPackage"; //$NON-NLS-1$ - /** - * Attributes of EPackage stereotype - */ - public static final String EPKG_BASE_PACKAGE = "basePackage"; //$NON-NLS-1$ - public static final String EPKG_PACKAGE_NAME = "packageName"; //$NON-NLS-1$ - public static final String EPKG_NS_URI = "nsURI"; //$NON-NLS-1$ - public static final String EPKG_NS_PREFIX = "nsPrefix"; //$NON-NLS-1$ - - /** - * set the profile information - * @param profile - */ - public StaticProfileUtil(Profile profile) { - Stereotype ePkg = profile.getAppliedStereotype(EPackage_QNAME); - if (ePkg != null) { - basePackage = (String) profile.getValue(ePkg, EPKG_BASE_PACKAGE); - packageName = (String) profile.getValue(ePkg, EPKG_PACKAGE_NAME); - // create definition from stereotype - definition = EcoreFactory.eINSTANCE.createEPackage(); - definition.setNsPrefix((String) profile.getValue(ePkg, EPKG_NS_PREFIX)); - definition.setNsURI((String) profile.getValue(ePkg, EPKG_NS_URI)); - } - else { - basePackage = null; - packageName = null; - definition = null; - } - } - - /** - * @return the base package. - */ - public String getBasePackage() { - return basePackage; - } - - /** - * @return the package name. - */ - public String getPackageName() { - return packageName; - } - - /** - * @return a "definition" filled with information about nsPrefix and nsURI. - */ - public EPackage getDefinition() { - return definition; - } - - protected static String basePackage; - - protected static String packageName; - - protected static EPackage definition; -} - - |