Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenn Hussey2011-09-29 02:52:25 +0000
committerKenn Hussey2011-09-29 02:52:25 +0000
commit4831e7f96766350409a6f581bcb156ecf2b1ae59 (patch)
tree0c2aeaa29aed3ccba2da854c92fbcebf549357ce /plugins/org.eclipse.uml2.uml
parente2a6a51011e14276623db5817660a122fd2e2327 (diff)
downloadorg.eclipse.uml2.test-4831e7f96766350409a6f581bcb156ecf2b1ae59.tar.gz
org.eclipse.uml2.test-4831e7f96766350409a6f581bcb156ecf2b1ae59.tar.xz
org.eclipse.uml2.test-4831e7f96766350409a6f581bcb156ecf2b1ae59.zip
[327039] Adding support for interchange of XMI resources.
Diffstat (limited to 'plugins/org.eclipse.uml2.uml')
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLHandler.java34
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLResourceFactoryImpl.java33
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLHandler.java181
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLLoadImpl.java28
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLResourceFactoryImpl.java116
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLResourceImpl.java55
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHandler.java50
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHelperImpl.java1
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLResourceFactoryImpl.java20
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLSaveImpl.java89
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLExtendedMetaData.java2
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResource.java1
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResourceHandler.java69
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI222UMLResource.java33
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLExtendedMetaData.java47
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLResource.java61
16 files changed, 668 insertions, 152 deletions
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLHandler.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLHandler.java
index a67663dc..ab4f8d88 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLHandler.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLHandler.java
@@ -9,7 +9,6 @@
* IBM - initial API and implementation
* Kenn Hussey (CEA) - 327039
*
- * $Id: XMI212UMLHandler.java,v 1.2 2008/11/04 14:29:52 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.resource;
@@ -39,7 +38,6 @@ import org.eclipse.uml2.uml.resource.XMI2UMLResource;
public class XMI212UMLHandler
extends UMLHandler {
-
protected static final String PRIMITIVE_TYPE_BOOLEAN = "Boolean"; //$NON-NLS-1$
protected static final String PRIMITIVE_TYPE_BOOLEAN_URI = UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI + '#' + PRIMITIVE_TYPE_BOOLEAN;
@@ -56,18 +54,11 @@ public class XMI212UMLHandler
protected static final String PRIMITIVE_TYPE_UNLIMITED_NATURAL_URI = UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI + '#' + PRIMITIVE_TYPE_UNLIMITED_NATURAL;
- protected static final String STEREOTYPE_BUILD_COMPONENT = "BuildComponent"; //$NON-NLS-1$
-
- protected static final String STEREOTYPE_METAMODEL = "Metamodel"; //$NON-NLS-1$
-
- protected static final String STEREOTYPE_SYSTEM_MODEL = "SystemModel"; //$NON-NLS-1$
-
protected static final String ECORE_EXTENSION_TYPE = "ecoreExtension"; //$NON-NLS-1$
protected static final String XMI_IDREF = "idref"; //$NON-NLS-1$
protected static final String IDREF_ATTRIB = XMIResource.XMI_NS + ':' + XMI_IDREF;
-
public XMI212UMLHandler(XMLResource xmiResource, XMLHelper helper,
Map<?, ?> options) {
@@ -132,18 +123,23 @@ public class XMI212UMLHandler
: uriLiteral.substring(index));
}
} else if (uriLiteral
- .startsWith(XMI2UMLResource.STANDARD_PROFILE_2_1_1_URI)
- || uriLiteral.startsWith(XMI2UMLResource.STANDARD_PROFILE_2_1_URI)) {
+ .startsWith(XMI2UMLResource.STANDARD_L2_PROFILE_2_1_1_URI)
+ || uriLiteral
+ .startsWith(XMI2UMLResource.STANDARD_L2_PROFILE_2_1_URI)) {
int index = uriLiteral.indexOf('#');
- uriLiteral = (uriLiteral.endsWith(STEREOTYPE_BUILD_COMPONENT)
- || uriLiteral.endsWith(STEREOTYPE_METAMODEL)
- || uriLiteral.endsWith(STEREOTYPE_SYSTEM_MODEL)
- ? UMLResource.STANDARD_L3_PROFILE_URI
- : UMLResource.STANDARD_L2_PROFILE_URI)
- + (index == -1
- ? "#_0" //$NON-NLS-1$
- : uriLiteral.substring(index));
+ uriLiteral = UMLResource.STANDARD_L2_PROFILE_URI + (index == -1
+ ? "#_0" //$NON-NLS-1$
+ : uriLiteral.substring(index));
+ } else if (uriLiteral
+ .startsWith(XMI2UMLResource.STANDARD_L3_PROFILE_2_1_1_URI)
+ || uriLiteral
+ .startsWith(XMI2UMLResource.STANDARD_L3_PROFILE_2_1_URI)) {
+
+ int index = uriLiteral.indexOf('#');
+ uriLiteral = UMLResource.STANDARD_L3_PROFILE_URI + (index == -1
+ ? "#_0" //$NON-NLS-1$
+ : uriLiteral.substring(index));
}
super.handleProxy(proxy, uriLiteral);
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLResourceFactoryImpl.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLResourceFactoryImpl.java
index a2759808..0b12a38e 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLResourceFactoryImpl.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI212UMLResourceFactoryImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 IBM Corporation, CEA, 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
@@ -7,8 +7,8 @@
*
* Contributors:
* IBM - initial API and implementation
+ * Kenn Hussey (CEA) - 327039
*
- * $Id: XMI212UMLResourceFactoryImpl.java,v 1.3 2009/02/12 02:30:46 jbruck Exp $
*/
package org.eclipse.uml2.uml.internal.resource;
@@ -27,7 +27,8 @@ import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLRegistry;
import org.eclipse.emf.mapping.ecore2xml.impl.Ecore2XMLRegistryImpl;
import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.resource.UML2122UMLResourceHandler;
+import org.eclipse.uml2.uml.resource.CMOF2UMLResourceHandler;
+import org.eclipse.uml2.uml.resource.UML212UMLResourceHandler;
import org.eclipse.uml2.uml.resource.UML212UMLExtendedMetaData;
import org.eclipse.uml2.uml.resource.UML212UMLResource;
import org.eclipse.uml2.uml.resource.XMI212UMLResource;
@@ -58,7 +59,6 @@ public class XMI212UMLResourceFactoryImpl
@Override
public Resource createResource(URI uri) {
-
XMI212UMLResource resource = (XMI212UMLResource) super
.createResource(uri);
@@ -73,9 +73,6 @@ public class XMI212UMLResourceFactoryImpl
defaultSaveOptions.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION,
Boolean.TRUE);
- Map<Object, Object> defaultLoadOptions = resource
- .getDefaultLoadOptions();
-
EPackage.Registry ePackageRegistry = new EPackageRegistryImpl(
EPackage.Registry.INSTANCE);
@@ -84,7 +81,7 @@ public class XMI212UMLResourceFactoryImpl
ePackageRegistry.put(XMI2UMLResource.UML_METAMODEL_2_1_1_NS_URI,
UMLPackage.eINSTANCE);
-
+
ePackageRegistry
.put(
"platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore", UMLPackage.eINSTANCE); //$NON-NLS-1$
@@ -97,27 +94,25 @@ public class XMI212UMLResourceFactoryImpl
ecore2xmlRegistry
.put(
UML212UMLResource.UML_METAMODEL_NS_URI,
- EcoreUtil
- .getObjectByType(
- resourceSet
- .getResource(
- URI
- .createURI("platform:/plugin/org.eclipse.uml2.uml/model/UML21_2_UML.ecore2xml"), //$NON-NLS-1$
- true).getContents(),
- Ecore2XMLPackage.Literals.XML_MAP));
+ EcoreUtil.getObjectByType(
+ resourceSet
+ .getResource(
+ URI.createURI("platform:/plugin/org.eclipse.uml2.uml/model/UML21_2_UML.ecore2xml"), //$NON-NLS-1$
+ true).getContents(),
+ Ecore2XMLPackage.Literals.XML_MAP));
ExtendedMetaData extendedMetaData = new UML212UMLExtendedMetaData(
ePackageRegistry, ecore2xmlRegistry);
- resource.getDefaultLoadOptions().put(
- XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
+ Map<Object, Object> defaultLoadOptions = resource
+ .getDefaultLoadOptions();
defaultLoadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA,
extendedMetaData);
defaultLoadOptions.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING,
Boolean.FALSE);
defaultLoadOptions.put(XMLResource.OPTION_RESOURCE_HANDLER,
- new UML2122UMLResourceHandler());
+ new CMOF2UMLResourceHandler(new UML212UMLResourceHandler()));
return resource;
}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLHandler.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLHandler.java
new file mode 100644
index 00000000..fbeab21c
--- /dev/null
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLHandler.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2011 CEA 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 - initial API and implementation
+ *
+ */
+package org.eclipse.uml2.uml.internal.resource;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.ecore.xmi.XMLHelper;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.emf.ecore.xmi.impl.EMOFExtendedMetaData;
+import org.eclipse.emf.ecore.xml.type.AnyType;
+import org.eclipse.uml2.uml.resource.UML212UMLExtendedMetaData;
+import org.eclipse.uml2.uml.resource.UMLResource;
+import org.eclipse.uml2.uml.resource.XMI2UMLResource;
+
+/**
+ * Handler that converts .xmi models.
+ * OMG: UML 2.2 and UML 2.4
+ * API: UML2 3.x and UML2 4.0.x
+ *
+ * @since 4.0
+ */
+public class XMI222UMLHandler
+ extends UMLHandler {
+
+ protected static final String PRIMITIVE_TYPE_BOOLEAN = "Boolean"; //$NON-NLS-1$
+
+ protected static final String PRIMITIVE_TYPE_BOOLEAN_URI = UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI + '#' + PRIMITIVE_TYPE_BOOLEAN;
+
+ protected static final String PRIMITIVE_TYPE_INTEGER = "Integer"; //$NON-NLS-1$
+
+ protected static final String PRIMITIVE_TYPE_INTEGER_URI = UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI + '#' + PRIMITIVE_TYPE_INTEGER;
+
+ protected static final String PRIMITIVE_TYPE_STRING = "String"; //$NON-NLS-1$
+
+ protected static final String PRIMITIVE_TYPE_STRING_URI = UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI + '#' + PRIMITIVE_TYPE_STRING;
+
+ protected static final String PRIMITIVE_TYPE_UNLIMITED_NATURAL = "UnlimitedNatural"; //$NON-NLS-1$
+
+ protected static final String PRIMITIVE_TYPE_UNLIMITED_NATURAL_URI = UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI + '#' + PRIMITIVE_TYPE_UNLIMITED_NATURAL;
+
+ protected static final String ECORE_EXTENSION_TYPE = "ecoreExtension"; //$NON-NLS-1$
+
+ protected static final String XMI_IDREF = "idref"; //$NON-NLS-1$
+
+ protected static final String IDREF_ATTRIB = XMIResource.XMI_NS + ':' + XMI_IDREF;
+
+ public XMI222UMLHandler(XMLResource xmiResource, XMLHelper helper,
+ Map<?, ?> options) {
+ super(xmiResource, helper, options);
+ }
+
+ @Override
+ protected void createObject(EObject peekObject, EStructuralFeature feature) {
+
+ if (!isNull()) {
+ String xsiType = getXSIType();
+
+ Map<String, Map<EClassifier, String>> featureToTypeMap = xsiType == null
+ ? UML212UMLExtendedMetaData.getFeatureToTypeMap()
+ : null;
+
+ Map<EClassifier, String> typeMap = featureToTypeMap == null
+ ? null
+ : featureToTypeMap.get(feature.getName());
+
+ if (typeMap != null) {
+ EObject eObject = peekObject instanceof AnyType
+ ? (EObject) objects.get(objects.size() - 2)
+ : peekObject;
+
+ for (Map.Entry<EClassifier, String> entry : typeMap.entrySet()) {
+
+ if (entry.getKey().isInstance(eObject)) {
+ xsiType = entry.getValue();
+ break;
+ }
+ }
+ }
+
+ if (xsiType != null) {
+ createObjectFromTypeName(peekObject, xsiType, feature);
+ } else {
+ super.createObject(peekObject, feature);
+ }
+ }
+ }
+
+ @Override
+ protected void handleProxy(InternalEObject proxy, String uriLiteral) {
+
+ if (uriLiteral.startsWith(XMI2UMLResource.UML_METAMODEL_2_2_URI)) {
+
+ if (uriLiteral.endsWith(PRIMITIVE_TYPE_BOOLEAN)) {
+ uriLiteral = PRIMITIVE_TYPE_BOOLEAN_URI;
+ } else if (uriLiteral.endsWith(PRIMITIVE_TYPE_INTEGER)) {
+ uriLiteral = PRIMITIVE_TYPE_INTEGER_URI;
+ } else if (uriLiteral.endsWith(PRIMITIVE_TYPE_STRING)) {
+ uriLiteral = PRIMITIVE_TYPE_STRING_URI;
+ } else if (uriLiteral.endsWith(PRIMITIVE_TYPE_UNLIMITED_NATURAL)) {
+ uriLiteral = PRIMITIVE_TYPE_UNLIMITED_NATURAL_URI;
+ } else {
+ int index = uriLiteral.indexOf('#');
+ uriLiteral = UMLResource.UML_METAMODEL_URI + (index == -1
+ ? "#_0" //$NON-NLS-1$
+ : uriLiteral.substring(index));
+ }
+ } else if (uriLiteral
+ .startsWith(XMI2UMLResource.STANDARD_L2_PROFILE_2_2_URI)) {
+
+ int index = uriLiteral.indexOf('#');
+ uriLiteral = UMLResource.STANDARD_L2_PROFILE_URI + (index == -1
+ ? "#_0" //$NON-NLS-1$
+ : uriLiteral.substring(index));
+ } else if (uriLiteral
+ .startsWith(XMI2UMLResource.STANDARD_L3_PROFILE_2_2_URI)) {
+
+ int index = uriLiteral.indexOf('#');
+ uriLiteral = UMLResource.STANDARD_L3_PROFILE_URI + (index == -1
+ ? "#_0" //$NON-NLS-1$
+ : uriLiteral.substring(index));
+ }
+
+ super.handleProxy(proxy, uriLiteral);
+ }
+
+ @Override
+ protected void processElement(String name, String prefix, String localName) {
+
+ if (EMOFExtendedMetaData.EXTENSION.equals(localName)
+ && XMI2UMLResource.XMI_2_1_NS_URI.equals(helper.getURI(prefix))
+ && attribs != null
+ && EcorePackage.eNS_URI.equals(attribs
+ .getValue(EMOFExtendedMetaData.XMI_EXTENDER_ATTRIBUTE))) {
+
+ types.push(ECORE_EXTENSION_TYPE);
+ } else {
+ super.processElement(name, prefix, localName);
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String name) {
+
+ if (types.peek() == ECORE_EXTENSION_TYPE) {
+ elements.pop();
+ types.pop();
+ helper.popContext();
+ mixedTargets.pop();
+ } else {
+ super.endElement(uri, localName, name);
+ }
+ }
+
+ @Override
+ protected void setAttribValue(EObject object, String name, String value) {
+
+ if (IDREF_ATTRIB.equals(name)
+ && (!recordUnknownFeature || types.peek() != UNKNOWN_FEATURE_TYPE)) {
+
+ handleProxy((InternalEObject) object, '#' + value);
+ } else {
+ super.setAttribValue(object, name, value);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLLoadImpl.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLLoadImpl.java
new file mode 100644
index 00000000..4823ddfa
--- /dev/null
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLLoadImpl.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 CEA 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 - initial API and implementation
+ *
+ */
+package org.eclipse.uml2.uml.internal.resource;
+
+import org.eclipse.emf.ecore.xmi.XMLHelper;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class XMI222UMLLoadImpl
+ extends UMLLoadImpl {
+
+ public XMI222UMLLoadImpl(XMLHelper helper) {
+ super(helper);
+ }
+
+ @Override
+ protected DefaultHandler makeDefaultHandler() {
+ return new XMI222UMLHandler(resource, helper, options);
+ }
+}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLResourceFactoryImpl.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLResourceFactoryImpl.java
new file mode 100644
index 00000000..df5279f4
--- /dev/null
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLResourceFactoryImpl.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2011 CEA 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 - initial API and implementation
+ *
+ */
+package org.eclipse.uml2.uml.internal.resource;
+
+import java.util.Map;
+
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.resource.CMOF2UMLResourceHandler;
+import org.eclipse.uml2.uml.resource.UML302UMLExtendedMetaData;
+import org.eclipse.uml2.uml.resource.UML302UMLResource;
+import org.eclipse.uml2.uml.resource.UML302UMLResourceHandler;
+import org.eclipse.uml2.uml.resource.XMI2UMLExtendedMetaData;
+import org.eclipse.uml2.uml.resource.XMI2UMLResource;
+import org.eclipse.uml2.uml.resource.XMI222UMLResource;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
+import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLRegistry;
+import org.eclipse.emf.mapping.ecore2xml.impl.Ecore2XMLRegistryImpl;
+
+/**
+ * Resource factory that converts .xmi models.
+ * OMG: UML 2.2 and UML 2.4
+ * API: UML2 3.x and UML2 4.0.x
+ *
+ * @since 4.0
+ */
+public class XMI222UMLResourceFactoryImpl
+ extends UMLResourceFactoryImpl
+ implements XMI222UMLResource.Factory {
+
+ public XMI222UMLResourceFactoryImpl() {
+ super();
+ }
+
+ @Override
+ public Resource createResourceGen(URI uri) {
+ XMI222UMLResource result = new XMI222UMLResourceImpl(uri);
+ result.setEncoding(XMI2UMLResource.DEFAULT_ENCODING);
+ return result;
+ }
+
+ @Override
+ public Resource createResource(URI uri) {
+ XMI222UMLResource resource = (XMI222UMLResource) super
+ .createResource(uri);
+
+ ExtendedMetaData xmiExtendedMetaData = new XMI2UMLExtendedMetaData(
+ EPackage.Registry.INSTANCE);
+
+ Map<Object, Object> defaultSaveOptions = resource
+ .getDefaultSaveOptions();
+
+ defaultSaveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA,
+ xmiExtendedMetaData);
+ defaultSaveOptions.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION,
+ Boolean.TRUE);
+
+ EPackage.Registry ePackageRegistry = new EPackageRegistryImpl(
+ EPackage.Registry.INSTANCE);
+
+ ePackageRegistry.put(XMI2UMLResource.UML_METAMODEL_2_2_NS_URI,
+ UMLPackage.eINSTANCE);
+
+ ePackageRegistry
+ .put(
+ "platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore", UMLPackage.eINSTANCE); //$NON-NLS-1$
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.setPackageRegistry(ePackageRegistry);
+
+ Ecore2XMLRegistry ecore2xmlRegistry = new Ecore2XMLRegistryImpl(
+ Ecore2XMLRegistry.INSTANCE);
+ ecore2xmlRegistry
+ .put(
+ UML302UMLResource.UML_METAMODEL_NS_URI,
+ EcoreUtil.getObjectByType(
+ resourceSet
+ .getResource(
+ URI.createURI("platform:/plugin/org.eclipse.uml2.uml/model/UML30_2_UML.ecore2xml"), //$NON-NLS-1$
+ true).getContents(),
+ Ecore2XMLPackage.Literals.XML_MAP));
+
+ ExtendedMetaData extendedMetaData = new UML302UMLExtendedMetaData(
+ ePackageRegistry, ecore2xmlRegistry);
+
+ Map<Object, Object> defaultLoadOptions = resource
+ .getDefaultLoadOptions();
+
+ defaultLoadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA,
+ extendedMetaData);
+ defaultLoadOptions.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING,
+ Boolean.FALSE);
+ defaultLoadOptions.put(XMLResource.OPTION_RESOURCE_HANDLER,
+ new CMOF2UMLResourceHandler(new UML302UMLResourceHandler()));
+
+ return resource;
+ }
+}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLResourceImpl.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLResourceImpl.java
new file mode 100644
index 00000000..0e3c16dd
--- /dev/null
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI222UMLResourceImpl.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 CEA 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 - initial API and implementation
+ *
+ */
+package org.eclipse.uml2.uml.internal.resource;
+
+import org.eclipse.uml2.uml.resource.XMI222UMLResource;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.xmi.XMLHelper;
+import org.eclipse.emf.ecore.xmi.XMLLoad;
+import org.eclipse.emf.ecore.xmi.XMLSave;
+
+/**
+ * Resource that converts .xmi models.
+ * OMG: UML 2.2 and UML 2.4
+ * API: UML2 3.x and UML2 4.0.x
+ *
+ * @since 4.0
+ */
+public class XMI222UMLResourceImpl
+ extends UMLResourceImpl
+ implements XMI222UMLResource {
+
+ public XMI222UMLResourceImpl(URI uri) {
+ super(uri);
+ }
+
+ @Override
+ protected XMLHelper createXMLHelper() {
+ return new XMI2UMLHelperImpl(this);
+ }
+
+ @Override
+ protected boolean assignIDsWhileLoading() {
+ return false;
+ }
+
+ @Override
+ protected XMLLoad createXMLLoad() {
+ return new XMI222UMLLoadImpl(createXMLHelper());
+ }
+
+ @Override
+ protected XMLSave createXMLSave() {
+ return new XMI2UMLSaveImpl(createXMLHelper());
+ }
+}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHandler.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHandler.java
index c340f7fc..d7dff801 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHandler.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHandler.java
@@ -10,7 +10,6 @@
* Kenn Hussey (Embarcadero Technologies) - 199624, 204202
* Kenn Hussey (CEA) - 327039
*
- * $Id: XMI2UMLHandler.java,v 1.9 2008/10/03 20:50:37 jbruck Exp $
*/
package org.eclipse.uml2.uml.internal.resource;
@@ -49,12 +48,6 @@ public class XMI2UMLHandler
protected static final String PRIMITIVE_TYPE_UNLIMITED_NATURAL_URI = UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI + '#' + PRIMITIVE_TYPE_UNLIMITED_NATURAL;
- protected static final String STEREOTYPE_BUILD_COMPONENT = "BuildComponent"; //$NON-NLS-1$
-
- protected static final String STEREOTYPE_METAMODEL = "Metamodel"; //$NON-NLS-1$
-
- protected static final String STEREOTYPE_SYSTEM_MODEL = "SystemModel"; //$NON-NLS-1$
-
protected static final String ECORE_EXTENSION_TYPE = "ecoreExtension"; //$NON-NLS-1$
protected static final String XMI_IDREF = "idref"; //$NON-NLS-1$
@@ -68,54 +61,21 @@ public class XMI2UMLHandler
@Override
protected void handleProxy(InternalEObject proxy, String uriLiteral) {
- if (uriLiteral.startsWith(XMI2UMLResource.UML_METAMODEL_2_3_URI)
- || uriLiteral.startsWith(XMI2UMLResource.UML_METAMODEL_2_2_URI)
- || uriLiteral.startsWith(XMI2UMLResource.UML_METAMODEL_2_1_1_URI)
- || uriLiteral.startsWith(XMI2UMLResource.UML_METAMODEL_2_1_URI)) {
-
- if (uriLiteral.endsWith(PRIMITIVE_TYPE_BOOLEAN)) {
- uriLiteral = PRIMITIVE_TYPE_BOOLEAN_URI;
- } else if (uriLiteral.endsWith(PRIMITIVE_TYPE_INTEGER)) {
- uriLiteral = PRIMITIVE_TYPE_INTEGER_URI;
- } else if (uriLiteral.endsWith(PRIMITIVE_TYPE_STRING)) {
- uriLiteral = PRIMITIVE_TYPE_STRING_URI;
- } else if (uriLiteral.endsWith(PRIMITIVE_TYPE_UNLIMITED_NATURAL)) {
- uriLiteral = PRIMITIVE_TYPE_UNLIMITED_NATURAL_URI;
- } else {
- int index = uriLiteral.indexOf('#');
- uriLiteral = UMLResource.UML_METAMODEL_URI + (index == -1
- ? "#_0" //$NON-NLS-1$
- : uriLiteral.substring(index));
- }
- } else if (uriLiteral
- .startsWith(XMI2UMLResource.STANDARD_PROFILE_2_3_URI)
- || uriLiteral.startsWith(XMI2UMLResource.STANDARD_PROFILE_2_2_URI)
- || uriLiteral
- .startsWith(XMI2UMLResource.STANDARD_PROFILE_2_1_1_URI)
- || uriLiteral.startsWith(XMI2UMLResource.STANDARD_PROFILE_2_1_URI)) {
-
- int index = uriLiteral.indexOf('#');
- uriLiteral = (uriLiteral.endsWith(STEREOTYPE_BUILD_COMPONENT)
- || uriLiteral.endsWith(STEREOTYPE_METAMODEL)
- || uriLiteral.endsWith(STEREOTYPE_SYSTEM_MODEL)
- ? UMLResource.STANDARD_L3_PROFILE_URI
- : UMLResource.STANDARD_L2_PROFILE_URI)
- + (index == -1
- ? "#_0" //$NON-NLS-1$
- : uriLiteral.substring(index));
- } else if (uriLiteral.startsWith(XMI2UMLResource.UML_METAMODEL_URI)) {
+ if (uriLiteral.startsWith(XMI2UMLResource.UML_METAMODEL_URI)) {
int index = uriLiteral.indexOf('#');
uriLiteral = UMLResource.UML_METAMODEL_URI + (index == -1
? "#_0" //$NON-NLS-1$
: uriLiteral.substring(index));
} else if (uriLiteral
- .startsWith(XMI2UMLResource.STANDARD_L2_PROFILE_URI)) {
+ .startsWith(XMI2UMLResource.STANDARD_L2_PROFILE_URI) || uriLiteral
+ .startsWith(XMI2UMLResource.STANDARD_L2_PROFILE_2_2_URI)) {
int index = uriLiteral.indexOf('#');
uriLiteral = UMLResource.STANDARD_L2_PROFILE_URI + (index == -1
? "#_0" //$NON-NLS-1$
: uriLiteral.substring(index));
} else if (uriLiteral
- .startsWith(XMI2UMLResource.STANDARD_L3_PROFILE_URI)) {
+ .startsWith(XMI2UMLResource.STANDARD_L3_PROFILE_URI) || uriLiteral
+ .startsWith(XMI2UMLResource.STANDARD_L3_PROFILE_2_2_URI)) {
int index = uriLiteral.indexOf('#');
uriLiteral = UMLResource.STANDARD_L3_PROFILE_URI + (index == -1
? "#_0" //$NON-NLS-1$
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHelperImpl.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHelperImpl.java
index 0e1b7d80..8fa1c018 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHelperImpl.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLHelperImpl.java
@@ -9,7 +9,6 @@
* IBM - initial API and implementation
* Kenn Hussey (CEA) - 327039
*
- * $Id: XMI2UMLHelperImpl.java,v 1.2 2006/12/14 15:49:34 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.resource;
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLResourceFactoryImpl.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLResourceFactoryImpl.java
index 8c5210a4..fa797554 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLResourceFactoryImpl.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLResourceFactoryImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2011 IBM Corporation, CEA, 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
@@ -7,8 +7,8 @@
*
* Contributors:
* IBM - initial API and implementation
+ * Kenn Hussey (CEA) - 327039
*
- * $Id: XMI2UMLResourceFactoryImpl.java,v 1.4 2006/12/14 15:49:34 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.resource;
@@ -19,6 +19,8 @@ import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMLResource;
+
+import org.eclipse.uml2.uml.resource.CMOF2UMLResourceHandler;
import org.eclipse.uml2.uml.resource.XMI2UMLExtendedMetaData;
import org.eclipse.uml2.uml.resource.XMI2UMLResource;
@@ -44,16 +46,22 @@ public class XMI2UMLResourceFactoryImpl
ExtendedMetaData extendedMetaData = new XMI2UMLExtendedMetaData(
EPackage.Registry.INSTANCE);
- resource.getDefaultLoadOptions().put(
- XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
-
- Map<Object, Object> defaultSaveOptions = resource.getDefaultSaveOptions();
+ Map<Object, Object> defaultSaveOptions = resource
+ .getDefaultSaveOptions();
defaultSaveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA,
extendedMetaData);
defaultSaveOptions.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION,
Boolean.TRUE);
+ Map<Object, Object> defaultLoadOptions = resource
+ .getDefaultLoadOptions();
+
+ defaultLoadOptions.put(XMLResource.OPTION_EXTENDED_META_DATA,
+ extendedMetaData);
+ defaultLoadOptions.put(XMLResource.OPTION_RESOURCE_HANDLER,
+ new CMOF2UMLResourceHandler(null));
+
return resource;
}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLSaveImpl.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLSaveImpl.java
index 51e70ff5..dcb2f66b 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLSaveImpl.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/resource/XMI2UMLSaveImpl.java
@@ -9,21 +9,28 @@
* IBM - initial API and implementation
* Kenn Hussey (CEA) - 327039
*
- * $Id: XMI2UMLSaveImpl.java,v 1.4 2007/05/04 20:35:32 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.resource;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMLHelper;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.EMOFExtendedMetaData;
import org.eclipse.emf.ecore.xmi.impl.XMISaveImpl;
+
+import org.eclipse.uml2.common.util.UML2Util;
+import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.resource.CMOF2UMLExtendedMetaData;
public class XMI2UMLSaveImpl
extends UMLSaveImpl {
@@ -76,4 +83,84 @@ public class XMI2UMLSaveImpl
}
}
+ @Override
+ public Object writeTopObjects(List<? extends EObject> contents) {
+
+ if (!toDOM) {
+ doc.startElement(XMI_TAG_NS);
+ Object mark = doc.mark();
+
+ for (int i = 0, size = contents.size(); i < size; i++) {
+ EObject top = contents.get(i);
+ EClass eClass = top.eClass();
+
+ if (extendedMetaData == null
+ || featureTable.getDocumentRoot(eClass.getEPackage()) != eClass) {
+
+ String name = helper.getQName(eClass);
+ doc.startElement(name);
+ root = top;
+ saveElementID(top);
+ } else {
+ doc.startElement(null);
+ root = top;
+ saveFeatures(top);
+ doc.addLine();
+ }
+ }
+
+ int index = contents.size();
+
+ for (Iterator<EObject> properContents = EcoreUtil
+ .getAllProperContents(contents, false); properContents
+ .hasNext();) {
+
+ EObject eObject = properContents.next();
+
+ if (eObject instanceof Profile) {
+ Profile profile = (Profile) eObject;
+
+ String nsPrefix = profile.getName();
+
+ if (!UML2Util.isEmpty(nsPrefix)) {
+ doc.startElement(CMOF2UMLExtendedMetaData.CMOF_TAG);
+ doc.addAttribute(idAttributeName, "_" + index++); //$NON-NLS-1$
+ doc.addAttribute(
+ CMOF2UMLExtendedMetaData.CMOF_TAG_NAME,
+ CMOF2UMLExtendedMetaData.XMI_TAG__NS_PREFIX);
+ doc.addAttribute(
+ CMOF2UMLExtendedMetaData.CMOF_TAG_VALUE,
+ nsPrefix);
+ doc.addAttribute(
+ CMOF2UMLExtendedMetaData.CMOF_TAG_ELEMENT, helper
+ .getIDREF(profile));
+ doc.endEmptyElement();
+ }
+
+ String nsURI = profile.getName();
+
+ if (!UML2Util.isEmpty(nsURI)) {
+ doc.startElement(CMOF2UMLExtendedMetaData.CMOF_TAG);
+ doc.addAttribute(idAttributeName, "_" + index++); //$NON-NLS-1$
+ doc.addAttribute(
+ CMOF2UMLExtendedMetaData.CMOF_TAG_NAME,
+ CMOF2UMLExtendedMetaData.XMI_TAG__NS_URI);
+ doc.addAttribute(
+ CMOF2UMLExtendedMetaData.CMOF_TAG_VALUE,
+ nsURI);
+ doc.addAttribute(
+ CMOF2UMLExtendedMetaData.CMOF_TAG_ELEMENT, helper
+ .getIDREF(profile));
+ doc.endEmptyElement();
+ }
+ }
+ }
+
+ doc.endElement();
+ return mark;
+ } else {
+ return super.writeTopObjects(contents);
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLExtendedMetaData.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLExtendedMetaData.java
index 80579288..44cd6a49 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLExtendedMetaData.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLExtendedMetaData.java
@@ -42,6 +42,8 @@ public class CMOF2UMLExtendedMetaData
public static final String CMOF_TAG_ELEMENT = EMOFExtendedMetaData.EMOF_TAG_ELEMENT;
+ public static final String EMOF_TAG__OPPOSITE_ROLE_NAME = "org.omg.emof.oppositeRoleName"; //$NON-NLS-1$
+
public static final String XMI_TAG__ATTRIBUTE = "org.omg.xmi.attribute"; //$NON-NLS-1$
public static final String XMI_TAG__ELEMENT = "org.omg.xmi.element"; //$NON-NLS-1$
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResource.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResource.java
index e4d1699f..af7006af 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResource.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResource.java
@@ -10,7 +10,6 @@
* Kenn Hussey (Embarcadero Technologies) - 156879, 218388
* Kenn Hussey (CEA) - 327039
*
- * $Id: CMOF2UMLResource.java,v 1.4 2008/04/21 13:28:47 khussey Exp $
*/
package org.eclipse.uml2.uml.resource;
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResourceHandler.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResourceHandler.java
index 55655387..2a0a80ae 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResourceHandler.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/CMOF2UMLResourceHandler.java
@@ -14,6 +14,7 @@
package org.eclipse.uml2.uml.resource;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -46,6 +47,18 @@ public class CMOF2UMLResourceHandler
protected static final boolean DEBUG = false;
+ protected final XMLResource.ResourceHandler delegate;
+
+ public CMOF2UMLResourceHandler() {
+ this(null);
+ }
+
+ public CMOF2UMLResourceHandler(XMLResource.ResourceHandler delegate) {
+ super();
+
+ this.delegate = delegate;
+ }
+
protected AnyType getExtension(XMLResource resource, EObject eObject) {
return resource.getEObjectToExtensionMap().get(eObject);
}
@@ -188,9 +201,22 @@ public class CMOF2UMLResourceHandler
: null;
}
+ public void preLoad(XMLResource resource, InputStream inputStream,
+ Map<?, ?> options) {
+
+ if (delegate != null) {
+ delegate.preLoad(resource, inputStream, options);
+ }
+ }
+
@Override
public void postLoad(XMLResource resource, InputStream inputStream,
Map<?, ?> options) {
+
+ if (delegate != null) {
+ delegate.postLoad(resource, inputStream, options);
+ }
+
EList<EObject> resourceContents = resource.getContents();
List<AnyType> tagsToRemove = new ArrayList<AnyType>();
@@ -206,7 +232,11 @@ public class CMOF2UMLResourceHandler
Object name = getValue(tag.getAnyAttribute(),
CMOF2UMLExtendedMetaData.CMOF_TAG_NAME);
- if (CMOF2UMLExtendedMetaData.XMI_TAG__XMI_NAME.equals(name)) {
+ if (CMOF2UMLExtendedMetaData.EMOF_TAG__OPPOSITE_ROLE_NAME
+ .equals(name)) {
+
+ tagsToRemove.add(tag);
+ } else if (CMOF2UMLExtendedMetaData.XMI_TAG__XMI_NAME.equals(name)) {
EObject element = getEObject(tag, resource,
CMOF2UMLExtendedMetaData.CMOF_TAG_ELEMENT, false);
@@ -239,6 +269,7 @@ public class CMOF2UMLResourceHandler
tagsToRemove.add(tag);
} else if (CMOF2UMLExtendedMetaData.XMI_TAG__ATTRIBUTE
.equals(name)) {
+
EObject element = getEObject(tag, resource,
CMOF2UMLExtendedMetaData.CMOF_TAG_ELEMENT, false);
@@ -269,6 +300,7 @@ public class CMOF2UMLResourceHandler
tagsToRemove.add(tag);
} else if (CMOF2UMLExtendedMetaData.XMI_TAG__ELEMENT
.equals(name)) {
+
EObject element = getEObject(tag, resource,
CMOF2UMLExtendedMetaData.CMOF_TAG_ELEMENT, false);
@@ -303,40 +335,37 @@ public class CMOF2UMLResourceHandler
tagsToRemove.add(tag);
} else if (CMOF2UMLExtendedMetaData.XMI_TAG__ID_PROPERTY
.equals(name)) {
+
EObject element = getEObject(tag, resource,
CMOF2UMLExtendedMetaData.CMOF_TAG_ELEMENT, false);
if (element instanceof Property
- && Boolean.getBoolean(String.valueOf(getValue(tag
- .getAnyAttribute(),
+ && Boolean.getBoolean(String.valueOf(getValue(
+ tag.getAnyAttribute(),
CMOF2UMLExtendedMetaData.CMOF_TAG_VALUE)))
&& UMLUtil.UML2EcoreConverter
.isEDataType(((Property) element).getNamespace())) {
- UMLUtil.setTaggedValue((Element) element,
- getEcoreStereotype(element,
- UMLUtil.STEREOTYPE__E_ATTRIBUTE),
- UMLUtil.TAG_DEFINITION__IS_ID, Boolean.TRUE);
+ ((Property) element).setIsID(true);
}
tagsToRemove.add(tag);
} else if (CMOF2UMLExtendedMetaData.XMI_TAG__NS_URI
.equals(name)) {
+
EObject element = getEObject(tag, resource,
CMOF2UMLExtendedMetaData.CMOF_TAG_ELEMENT, false);
if (element instanceof org.eclipse.uml2.uml.Package) {
- UMLUtil.setTaggedValue((Element) element,
- getEcoreStereotype(element,
- UMLUtil.STEREOTYPE__E_PACKAGE),
- UMLUtil.TAG_DEFINITION__NS_URI, getValue(tag
- .getAnyAttribute(),
+ ((org.eclipse.uml2.uml.Package) element)
+ .setURI((String) getValue(tag.getAnyAttribute(),
CMOF2UMLExtendedMetaData.CMOF_TAG_VALUE));
}
tagsToRemove.add(tag);
} else if (CMOF2UMLExtendedMetaData.XMI_TAG__NS_PREFIX
.equals(name)) {
+
EObject element = getEObject(tag, resource,
CMOF2UMLExtendedMetaData.CMOF_TAG_ELEMENT, false);
@@ -359,4 +388,20 @@ public class CMOF2UMLResourceHandler
}
}
+ public void preSave(XMLResource resource, OutputStream outputStream,
+ Map<?, ?> options) {
+
+ if (delegate != null) {
+ delegate.preSave(resource, outputStream, options);
+ }
+ }
+
+ public void postSave(XMLResource resource, OutputStream outputStream,
+ Map<?, ?> options) {
+
+ if (delegate != null) {
+ delegate.postSave(resource, outputStream, options);
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI222UMLResource.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI222UMLResource.java
new file mode 100644
index 00000000..8f85408d
--- /dev/null
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI222UMLResource.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011 CEA 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 - initial API and implementation
+ *
+ */
+package org.eclipse.uml2.uml.resource;
+
+import org.eclipse.uml2.uml.internal.resource.XMI222UMLResourceFactoryImpl;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * XMI resource required for model migration.
+ * OMG: UML 2.2 and UML 2.4
+ * API: UML2 3.x and UML2 4.0
+ *
+ * @since 4.0
+ */
+public interface XMI222UMLResource
+ extends XMI2UMLResource {
+
+ public interface Factory
+ extends Resource.Factory {
+
+ public static final Factory INSTANCE = new XMI222UMLResourceFactoryImpl();
+ }
+}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLExtendedMetaData.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLExtendedMetaData.java
index 5fe26855..9648e449 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLExtendedMetaData.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLExtendedMetaData.java
@@ -10,7 +10,6 @@
* Kenn Hussey (Embarcadero Technologies) - 204202
* Kenn Hussey (CEA) - 327039
*
- * $Id: XMI2UMLExtendedMetaData.java,v 1.6 2008/10/03 20:50:37 jbruck Exp $
*/
package org.eclipse.uml2.uml.resource;
@@ -32,18 +31,30 @@ public class XMI2UMLExtendedMetaData
if (uriMap == null) {
uriMap = new HashMap<URI, URI>();
- uriMap.put(URI.createURI(XMI2UMLResource.STANDARD_L3_PROFILE_URI), URI
- .createURI(UMLResource.STANDARD_L3_PROFILE_URI));
- uriMap.put(URI.createURI(XMI2UMLResource.STANDARD_L2_PROFILE_URI), URI
- .createURI(UMLResource.STANDARD_L2_PROFILE_URI));
- // FIXME
- uriMap.put(URI.createURI(XMI2UMLResource.STANDARD_PROFILE_2_3_URI),
+ uriMap.put(URI.createURI(XMI2UMLResource.STANDARD_L3_PROFILE_URI),
+ URI.createURI(UMLResource.STANDARD_L3_PROFILE_URI));
+ uriMap.put(URI.createURI(XMI2UMLResource.STANDARD_L2_PROFILE_URI),
URI.createURI(UMLResource.STANDARD_L2_PROFILE_URI));
- uriMap.put(URI.createURI(XMI2UMLResource.STANDARD_PROFILE_2_2_URI),
+
+ uriMap.put(
+ URI.createURI(XMI2UMLResource.STANDARD_L3_PROFILE_2_2_URI),
+ URI.createURI(UMLResource.STANDARD_L3_PROFILE_URI));
+ uriMap.put(
+ URI.createURI(XMI2UMLResource.STANDARD_L2_PROFILE_2_2_URI),
URI.createURI(UMLResource.STANDARD_L2_PROFILE_URI));
- uriMap.put(URI.createURI(XMI2UMLResource.STANDARD_PROFILE_2_1_1_URI),
+
+ uriMap.put(
+ URI.createURI(XMI2UMLResource.STANDARD_L3_PROFILE_2_1_1_URI),
+ URI.createURI(UMLResource.STANDARD_L3_PROFILE_URI));
+ uriMap.put(
+ URI.createURI(XMI2UMLResource.STANDARD_L2_PROFILE_2_1_1_URI),
URI.createURI(UMLResource.STANDARD_L2_PROFILE_URI));
- uriMap.put(URI.createURI(XMI2UMLResource.STANDARD_PROFILE_2_1_URI),
+
+ uriMap.put(
+ URI.createURI(XMI2UMLResource.STANDARD_L3_PROFILE_2_1_URI),
+ URI.createURI(UMLResource.STANDARD_L3_PROFILE_URI));
+ uriMap.put(
+ URI.createURI(XMI2UMLResource.STANDARD_L2_PROFILE_2_1_URI),
URI.createURI(UMLResource.STANDARD_L2_PROFILE_URI));
}
@@ -72,25 +83,27 @@ public class XMI2UMLExtendedMetaData
@Override
public EPackage getPackage(String namespace) {
- // FIXME
return XMI2UMLResource.UML_METAMODEL_NS_URI.equals(namespace)
- || XMI2UMLResource.UML_METAMODEL_2_3_NS_URI.equals(namespace)
|| XMI2UMLResource.UML_METAMODEL_2_2_NS_URI.equals(namespace)
|| XMI2UMLResource.UML_METAMODEL_2_1_1_NS_URI.equals(namespace)
|| XMI2UMLResource.UML_METAMODEL_2_1_NS_URI.equals(namespace)
? UMLPackage.eINSTANCE
: super.getPackage(XMI2UMLResource.STANDARD_L2_PROFILE_NS_URI
.equals(namespace)
- || XMI2UMLResource.STANDARD_PROFILE_2_3_NS_URI
- .equals(namespace)
- || XMI2UMLResource.STANDARD_PROFILE_2_2_NS_URI
+ || XMI2UMLResource.STANDARD_L2_PROFILE_2_2_NS_URI
.equals(namespace)
- || XMI2UMLResource.STANDARD_PROFILE_2_1_1_NS_URI
+ || XMI2UMLResource.STANDARD_L2_PROFILE_2_1_1_NS_URI
.equals(namespace)
- || XMI2UMLResource.STANDARD_PROFILE_2_1_NS_URI
+ || XMI2UMLResource.STANDARD_L2_PROFILE_2_1_NS_URI
.equals(namespace)
? UMLResource.STANDARD_L2_PROFILE_NS_URI
: (XMI2UMLResource.STANDARD_L3_PROFILE_NS_URI.equals(namespace)
+ || XMI2UMLResource.STANDARD_L3_PROFILE_2_2_NS_URI
+ .equals(namespace)
+ || XMI2UMLResource.STANDARD_L3_PROFILE_2_1_1_NS_URI
+ .equals(namespace)
+ || XMI2UMLResource.STANDARD_L3_PROFILE_2_1_NS_URI
+ .equals(namespace)
? UMLResource.STANDARD_L3_PROFILE_NS_URI
: namespace));
}
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLResource.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLResource.java
index fe7dd273..966a6d9a 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLResource.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/resource/XMI2UMLResource.java
@@ -10,7 +10,6 @@
* Kenn Hussey (Embarcadero Technologies) - 204202, 156879, 226397
* Kenn Hussey (CEA) - 327039
*
- * $Id: XMI2UMLResource.java,v 1.8 2008/10/03 20:50:37 jbruck Exp $
*/
package org.eclipse.uml2.uml.resource;
@@ -29,9 +28,13 @@ public interface XMI2UMLResource
String FILE_EXTENSION = "xmi"; //$NON-NLS-1$
- String STANDARD_PROFILE_2_1_NS_URI = "http://schema.omg.org/spec/UML/2.1/StandardProfileL2"; //$NON-NLS-1$
+ String STANDARD_L2_PROFILE_2_1_NS_URI = "http://schema.omg.org/spec/UML/2.1/StandardProfileL2"; //$NON-NLS-1$
- String STANDARD_PROFILE_2_1_URI = "http://schema.omg.org/spec/UML/2.1/StandardProfileL2.xmi"; //$NON-NLS-1$
+ String STANDARD_L2_PROFILE_2_1_URI = "http://schema.omg.org/spec/UML/2.1/StandardProfileL2.xmi"; //$NON-NLS-1$
+
+ String STANDARD_L3_PROFILE_2_1_NS_URI = "http://schema.omg.org/spec/UML/2.1/StandardProfileL3"; //$NON-NLS-1$
+
+ String STANDARD_L3_PROFILE_2_1_URI = "http://schema.omg.org/spec/UML/2.1/StandardProfileL3.xmi"; //$NON-NLS-1$
String UML_METAMODEL_2_1_NS_URI = "http://schema.omg.org/spec/UML/2.1"; //$NON-NLS-1$
@@ -39,42 +42,40 @@ public interface XMI2UMLResource
String UML_PRIMITIVE_TYPES_LIBRARY_2_1_URI = UML_METAMODEL_2_1_URI;
- String STANDARD_PROFILE_2_1_1_NS_URI = "http://schema.omg.org/spec/UML/2.1.1/StandardProfileL2"; //$NON-NLS-1$
+ String STANDARD_L2_PROFILE_2_1_1_NS_URI = "http://schema.omg.org/spec/UML/2.1.1/StandardProfileL2"; //$NON-NLS-1$
+
+ String STANDARD_L2_PROFILE_2_1_1_URI = "http://schema.omg.org/spec/UML/2.1.1/StandardProfileL2.xmi"; //$NON-NLS-1$
+
+ String STANDARD_L3_PROFILE_2_1_1_NS_URI = "http://schema.omg.org/spec/UML/2.1.1/StandardProfileL3"; //$NON-NLS-1$
- String STANDARD_PROFILE_2_1_1_URI = "http://schema.omg.org/spec/UML/2.1.1/StandardProfileL2.xmi"; //$NON-NLS-1$
+ String STANDARD_L3_PROFILE_2_1_1_URI = "http://schema.omg.org/spec/UML/2.1.1/StandardProfileL3.xmi"; //$NON-NLS-1$
String UML_METAMODEL_2_1_1_NS_URI = "http://schema.omg.org/spec/UML/2.1.1"; //$NON-NLS-1$
String UML_METAMODEL_2_1_1_URI = "http://schema.omg.org/spec/UML/2.1.1/uml.xml"; //$NON-NLS-1$
String UML_PRIMITIVE_TYPES_LIBRARY_2_1_1_URI = UML_METAMODEL_2_1_1_URI;
-
- String STANDARD_PROFILE_2_2_NS_URI = "http://schema.omg.org/spec/UML/2.2/StandardProfileL2"; //$NON-NLS-1$
-
- String STANDARD_PROFILE_2_2_URI = "http://schema.omg.org/spec/UML/2.2/StandardProfileL2.xmi"; //$NON-NLS-1$
- String UML_METAMODEL_2_2_NS_URI = "http://schema.omg.org/spec/UML/2.2"; //$NON-NLS-1$
+ String STANDARD_L2_PROFILE_2_2_NS_URI = "http://schema.omg.org/spec/UML/2.2/StandardProfileL2"; //$NON-NLS-1$
- String UML_METAMODEL_2_2_URI = "http://schema.omg.org/spec/UML/2.2/uml.xml"; //$NON-NLS-1$
+ String STANDARD_L2_PROFILE_2_2_URI = "http://schema.omg.org/spec/UML/2.2/StandardProfileL2.xmi"; //$NON-NLS-1$
- String UML_PRIMITIVE_TYPES_LIBRARY_2_2_URI = UML_METAMODEL_2_2_URI;
-
- String STANDARD_PROFILE_2_3_NS_URI = "http://schema.omg.org/spec/UML/2.3/StandardProfileL2"; //$NON-NLS-1$
-
- String STANDARD_PROFILE_2_3_URI = "http://schema.omg.org/spec/UML/2.3/StandardProfileL2.xmi"; //$NON-NLS-1$
+ String STANDARD_L3_PROFILE_2_2_NS_URI = "http://schema.omg.org/spec/UML/2.2/StandardProfileL3"; //$NON-NLS-1$
- String UML_METAMODEL_2_3_NS_URI = "http://schema.omg.org/spec/UML/2.3"; //$NON-NLS-1$
+ String STANDARD_L3_PROFILE_2_2_URI = "http://schema.omg.org/spec/UML/2.2/StandardProfileL3.xmi"; //$NON-NLS-1$
- String UML_METAMODEL_2_3_URI = "http://schema.omg.org/spec/UML/2.3/uml.xml"; //$NON-NLS-1$
+ String UML_METAMODEL_2_2_NS_URI = "http://schema.omg.org/spec/UML/2.2"; //$NON-NLS-1$
- String UML_PRIMITIVE_TYPES_LIBRARY_2_3_URI = UML_METAMODEL_2_3_URI;
+ String UML_METAMODEL_2_2_URI = "http://schema.omg.org/spec/UML/2.2/uml.xml"; //$NON-NLS-1$
+
+ String UML_PRIMITIVE_TYPES_LIBRARY_2_2_URI = UML_METAMODEL_2_2_URI;
String STANDARD_L2_PROFILE_2_4_NS_URI = "http://www.omg.org/spec/UML/20100901/StandardProfileL2"; //$NON-NLS-1$
-
+
String STANDARD_L2_PROFILE_2_4_URI = "http://www.omg.org/spec/UML/20100901/StandardProfileL2.xmi"; //$NON-NLS-1$
String STANDARD_L3_PROFILE_2_4_NS_URI = "http://www.omg.org/spec/UML/20100901/StandardProfileL3"; //$NON-NLS-1$
-
+
String STANDARD_L3_PROFILE_2_4_URI = "http://www.omg.org/spec/UML/20100901/StandardProfileL3.xmi"; //$NON-NLS-1$
String UML_METAMODEL_2_4_NS_URI = "http://www.omg.org/spec/UML/20100901"; //$NON-NLS-1$
@@ -86,11 +87,11 @@ public interface XMI2UMLResource
String UML_PRIMITIVE_TYPES_LIBRARY_2_4_URI = "http://www.omg.org/spec/UML/20100901/PrimitiveTypes.xmi"; //$NON-NLS-1$
String STANDARD_L2_PROFILE_NS_URI = STANDARD_L2_PROFILE_2_4_NS_URI;
-
+
String STANDARD_L2_PROFILE_URI = STANDARD_L2_PROFILE_2_4_URI;
String STANDARD_L3_PROFILE_NS_URI = STANDARD_L3_PROFILE_2_4_NS_URI;
-
+
String STANDARD_L3_PROFILE_URI = STANDARD_L3_PROFILE_2_4_URI;
String UML_METAMODEL_NS_URI = UML_METAMODEL_2_4_NS_URI;
@@ -100,22 +101,20 @@ public interface XMI2UMLResource
String UML_PRIMITIVE_TYPES_LIBRARY_NS_URI = UML_PRIMITIVE_TYPES_LIBRARY_2_4_NS_URI;
String UML_PRIMITIVE_TYPES_LIBRARY_URI = UML_PRIMITIVE_TYPES_LIBRARY_2_4_URI;
-
+
String UML_2_1_CONTENT_TYPE_IDENTIFIER = "org.omg.uml_2_1"; //$NON-NLS-1$
String UML_2_1_1_CONTENT_TYPE_IDENTIFIER = "org.omg.uml_2_1_1"; //$NON-NLS-1$
-
+
String UML_2_2_CONTENT_TYPE_IDENTIFIER = "org.omg.uml_2_2"; //$NON-NLS-1$
-
- String UML_2_3_CONTENT_TYPE_IDENTIFIER = "org.omg.uml_2_3"; //$NON-NLS-1$
-
+
String UML_2_4_CONTENT_TYPE_IDENTIFIER = "org.omg.uml_2_4"; //$NON-NLS-1$
-
+
String UML_CONTENT_TYPE_IDENTIFIER = UML_2_4_CONTENT_TYPE_IDENTIFIER; //$NON-NLS-1$
- String XMI_2_1_NS_URI = XMI_NAMESPACE_PREFIX + "2.1"; //$NON-NLS-1$
+ String XMI_2_1_NS_URI = XMI_2_1_URI; //$NON-NLS-1$
- String XMI_2_4_NS_URI = "http://www.omg.org/spec/XMI/20100901"; //$NON-NLS-1$
+ String XMI_2_4_NS_URI = XMI_2_4_NAMESPACE_PREFIX + "20100901"; //$NON-NLS-1$
String XMI_NS_URI = XMI_2_4_NS_URI;

Back to the top