Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2015-12-16 16:11:09 +0000
committerAnsgar Radermacher2015-12-16 16:17:03 +0000
commit842607427e697734ef1a73f5a0a1005223302cf7 (patch)
treec2502bd028d77898a60264f48dfea1eb62314587 /plugins/uml
parente3155394f1d12d061193f5726ef74e28498f224c (diff)
downloadorg.eclipse.papyrus-842607427e697734ef1a73f5a0a1005223302cf7.tar.gz
org.eclipse.papyrus-842607427e697734ef1a73f5a0a1005223302cf7.tar.xz
org.eclipse.papyrus-842607427e697734ef1a73f5a0a1005223302cf7.zip
Bug 484464 - [Papyrus DSML Validation] nsURI is taken from definition in case of static profile
Addition of oep.uml.tools.utils.StaticProfileUtil (pre-condition for further changes) Change-Id: I18c92bb3e7e6380e49bb5aa5790ebe7aaacd4161
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java91
1 files changed, 91 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..11fc8dab291
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/StaticProfileUtil.java
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * 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 String basePackage;
+
+ protected String packageName;
+
+ protected EPackage definition;
+}
+
+

Back to the top