Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2015-12-16 10:01:52 +0000
committerGerrit Code Review @ Eclipse.org2015-12-16 11:57:15 +0000
commit1811680b89946b741263e70c56e912a146bd6e12 (patch)
treeb2204ac66823b4a583b18a276b5c82b593bd4b5b /plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse
parentcd554a80023aa7f4fa0b671afc7d756d0234c3e8 (diff)
downloadorg.eclipse.papyrus-1811680b89946b741263e70c56e912a146bd6e12.tar.gz
org.eclipse.papyrus-1811680b89946b741263e70c56e912a146bd6e12.tar.xz
org.eclipse.papyrus-1811680b89946b741263e70c56e912a146bd6e12.zip
Bug 484464 - [Papyrus DSML Validation] nsURI is taken from definition in case of static profile
Diffstat (limited to 'plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse')
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java90
1 files changed, 90 insertions, 0 deletions
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
new file mode 100644
index 00000000000..a71c6acf9aa
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * 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;
+}
+
+

Back to the top