diff options
author | Karen Butzke | 2013-02-15 15:22:54 +0000 |
---|---|---|
committer | Karen Butzke | 2013-02-15 15:28:32 +0000 |
commit | 084a62b3ccfbf7d3c76d2e82f6f16704ee992f45 (patch) | |
tree | 1c183a8c3842ad6dc418980c085dcb10faa46284 /common/plugins/org.eclipse.jpt.common.core/model | |
parent | 63766f877bdcdd1ca6659897e97eda090b06c2f6 (diff) | |
download | webtools.dali-084a62b3ccfbf7d3c76d2e82f6f16704ee992f45.tar.gz webtools.dali-084a62b3ccfbf7d3c76d2e82f6f16704ee992f45.tar.xz webtools.dali-084a62b3ccfbf7d3c76d2e82f6f16704ee992f45.zip |
Bug 400841 - update jpa 2.1 schemas for namespace change
Diffstat (limited to 'common/plugins/org.eclipse.jpt.common.core/model')
5 files changed, 170 insertions, 18 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.core/model/common.ecore b/common/plugins/org.eclipse.jpt.common.core/model/common.ecore index 5463a6c9dd..ef2f338f58 100644 --- a/common/plugins/org.eclipse.jpt.common.core/model/common.ecore +++ b/common/plugins/org.eclipse.jpt.common.core/model/common.ecore @@ -4,6 +4,8 @@ <eClassifiers xsi:type="ecore:EClass" name="ERootObjectImpl" abstract="true" eSuperTypes="#//ERootObject"/>
<eClassifiers xsi:type="ecore:EClass" name="ERootObject" abstract="true" interface="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="version" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="namespace" lowerBound="1"
+ eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="schemaLocation" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="impliedVersion" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
diff --git a/common/plugins/org.eclipse.jpt.common.core/model/common.genmodel b/common/plugins/org.eclipse.jpt.common.core/model/common.genmodel index 668ad8b103..48c8e4e5bf 100644 --- a/common/plugins/org.eclipse.jpt.common.core/model/common.genmodel +++ b/common/plugins/org.eclipse.jpt.common.core/model/common.genmodel @@ -13,6 +13,7 @@ <genClasses image="false" ecoreClass="common.ecore#//ERootObjectImpl"/>
<genClasses image="false" ecoreClass="common.ecore#//ERootObject">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute common.ecore#//ERootObject/version"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute common.ecore#//ERootObject/namespace"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute common.ecore#//ERootObject/schemaLocation"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute common.ecore#//ERootObject/impliedVersion"/>
</genClasses>
diff --git a/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/CommonPackage.java b/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/CommonPackage.java index e9cfc1a957..6b3188704e 100644 --- a/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/CommonPackage.java +++ b/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/CommonPackage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Oracle. + * Copyright (c) 2009, 2013 Oracle. * 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 @@ -90,13 +90,22 @@ public class CommonPackage extends EPackageImpl public static final int EROOT_OBJECT__VERSION = 0; /** + * The feature id for the '<em><b>Namespace</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int EROOT_OBJECT__NAMESPACE = 1; + + /** * The feature id for the '<em><b>Schema Location</b></em>' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - public static final int EROOT_OBJECT__SCHEMA_LOCATION = 1; + public static final int EROOT_OBJECT__SCHEMA_LOCATION = 2; /** * The feature id for the '<em><b>Implied Version</b></em>' attribute. @@ -105,7 +114,7 @@ public class CommonPackage extends EPackageImpl * @generated * @ordered */ - public static final int EROOT_OBJECT__IMPLIED_VERSION = 2; + public static final int EROOT_OBJECT__IMPLIED_VERSION = 3; /** * The number of structural features of the '<em>ERoot Object</em>' class. @@ -114,7 +123,7 @@ public class CommonPackage extends EPackageImpl * @generated * @ordered */ - public static final int EROOT_OBJECT_FEATURE_COUNT = 3; + public static final int EROOT_OBJECT_FEATURE_COUNT = 4; /** * The meta object id for the '{@link org.eclipse.jpt.common.core.resource.xml.ERootObjectImpl <em>ERoot Object Impl</em>}' class. @@ -136,6 +145,15 @@ public class CommonPackage extends EPackageImpl public static final int EROOT_OBJECT_IMPL__VERSION = EROOT_OBJECT__VERSION; /** + * The feature id for the '<em><b>Namespace</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int EROOT_OBJECT_IMPL__NAMESPACE = EROOT_OBJECT__NAMESPACE; + + /** * The feature id for the '<em><b>Schema Location</b></em>' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -294,6 +312,21 @@ public class CommonPackage extends EPackageImpl */ public EAttribute getERootObject_SchemaLocation() { + return (EAttribute)eRootObjectEClass.getEStructuralFeatures().get(2); + } + + + /** + * Returns the meta object for the attribute '{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getNamespace <em>Namespace</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Namespace</em>'. + * @see org.eclipse.jpt.common.core.resource.xml.ERootObject#getNamespace() + * @see #getERootObject() + * @generated + */ + public EAttribute getERootObject_Namespace() + { return (EAttribute)eRootObjectEClass.getEStructuralFeatures().get(1); } @@ -309,7 +342,7 @@ public class CommonPackage extends EPackageImpl */ public EAttribute getERootObject_ImpliedVersion() { - return (EAttribute)eRootObjectEClass.getEStructuralFeatures().get(2); + return (EAttribute)eRootObjectEClass.getEStructuralFeatures().get(3); } @@ -349,6 +382,7 @@ public class CommonPackage extends EPackageImpl eRootObjectEClass = createEClass(EROOT_OBJECT); createEAttribute(eRootObjectEClass, EROOT_OBJECT__VERSION); + createEAttribute(eRootObjectEClass, EROOT_OBJECT__NAMESPACE); createEAttribute(eRootObjectEClass, EROOT_OBJECT__SCHEMA_LOCATION); createEAttribute(eRootObjectEClass, EROOT_OBJECT__IMPLIED_VERSION); } @@ -389,6 +423,7 @@ public class CommonPackage extends EPackageImpl initEClass(eRootObjectEClass, ERootObject.class, "ERootObject", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getERootObject_Version(), ecorePackage.getEString(), "version", null, 0, 1, ERootObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getERootObject_Namespace(), ecorePackage.getEString(), "namespace", null, 1, 1, ERootObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getERootObject_SchemaLocation(), ecorePackage.getEString(), "schemaLocation", null, 1, 1, ERootObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getERootObject_ImpliedVersion(), ecorePackage.getEString(), "impliedVersion", null, 0, 1, ERootObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); @@ -447,6 +482,14 @@ public class CommonPackage extends EPackageImpl public static final EAttribute EROOT_OBJECT__SCHEMA_LOCATION = eINSTANCE.getERootObject_SchemaLocation(); /** + * The meta object literal for the '<em><b>Namespace</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute EROOT_OBJECT__NAMESPACE = eINSTANCE.getERootObject_Namespace(); + + /** * The meta object literal for the '<em><b>Implied Version</b></em>' attribute feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> diff --git a/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/ERootObject.java b/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/ERootObject.java index 0117173846..b004923774 100644 --- a/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/ERootObject.java +++ b/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/ERootObject.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. + * Copyright (c) 2009, 2013 Oracle. * 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 @@ -29,6 +29,7 @@ import org.eclipse.jpt.common.core.utility.TextRange; * The following features are supported: * <ul> * <li>{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getVersion <em>Version</em>}</li> + * <li>{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getNamespace <em>Namespace</em>}</li> * <li>{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getSchemaLocation <em>Schema Location</em>}</li> * <li>{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getImpliedVersion <em>Implied Version</em>}</li> * </ul> @@ -94,6 +95,32 @@ public interface ERootObject extends EBaseObject void setSchemaLocation(String value); /** + * Returns the value of the '<em><b>Namespace</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Namespace</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Namespace</em>' attribute. + * @see #setNamespace(String) + * @see org.eclipse.jpt.common.core.resource.xml.CommonPackage#getERootObject_Namespace() + * @model required="true" + * @generated + */ + String getNamespace(); + + /** + * Sets the value of the '{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getNamespace <em>Namespace</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Namespace</em>' attribute. + * @see #getNamespace() + * @generated + */ + void setNamespace(String value); + + /** * Returns the value of the '<em><b>Implied Version</b></em>' attribute. * <!-- begin-user-doc --> * <p> diff --git a/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/ERootObjectImpl.java b/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/ERootObjectImpl.java index 85bb0b1936..1202163db6 100644 --- a/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/ERootObjectImpl.java +++ b/common/plugins/org.eclipse.jpt.common.core/model/src/org/eclipse/jpt/common/core/resource/xml/ERootObjectImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Oracle. + * Copyright (c) 2009, 2013 Oracle. * 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 @@ -63,6 +63,26 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb protected String version = VERSION_EDEFAULT; /** + * The default value of the '{@link #getNamespace() <em>Namespace</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getNamespace() + * @generated + * @ordered + */ + protected static final String NAMESPACE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getNamespace() <em>Namespace</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getNamespace() + * @generated + * @ordered + */ + protected String namespace = NAMESPACE_EDEFAULT; + + /** * The default value of the '{@link #getSchemaLocation() <em>Schema Location</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -164,8 +184,9 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb } public void setDocumentVersion(String newVersion) { - setVersion(newVersion); - setSchemaLocation(getSchemaLocationForVersion(newVersion)); + this.setVersion(newVersion); + this.setNamespace(this.getNamespaceForVersion(newVersion)); + this.setSchemaLocation(this.getSchemaLocationForVersion(newVersion)); } /** @@ -215,6 +236,41 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb } /** + * Returns the value of the '<em><b>Namespace</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Namespace</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Namespace</em>' attribute. + * @see #setNamespace(String) + * @see org.eclipse.jpt.common.core.resource.xml.CommonPackage#getERootObject_Namespace() + * @model required="true" + * @generated + */ + public String getNamespace() + { + return namespace; + } + + /** + * Sets the value of the '{@link org.eclipse.jpt.common.core.resource.xml.ERootObjectImpl#getNamespace <em>Namespace</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Namespace</em>' attribute. + * @see #getNamespace() + * @generated + */ + public void setNamespace(String newNamespace) + { + String oldNamespace = namespace; + namespace = newNamespace; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CommonPackage.EROOT_OBJECT_IMPL__NAMESPACE, oldNamespace, namespace)); + } + + /** * Returns the value of the '<em><b>Implied Version</b></em>' attribute. * <!-- begin-user-doc --> * <p> @@ -261,6 +317,8 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb { case CommonPackage.EROOT_OBJECT_IMPL__VERSION: return getVersion(); + case CommonPackage.EROOT_OBJECT_IMPL__NAMESPACE: + return getNamespace(); case CommonPackage.EROOT_OBJECT_IMPL__SCHEMA_LOCATION: return getSchemaLocation(); case CommonPackage.EROOT_OBJECT_IMPL__IMPLIED_VERSION: @@ -282,6 +340,9 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb case CommonPackage.EROOT_OBJECT_IMPL__VERSION: setVersion((String)newValue); return; + case CommonPackage.EROOT_OBJECT_IMPL__NAMESPACE: + setNamespace((String)newValue); + return; case CommonPackage.EROOT_OBJECT_IMPL__SCHEMA_LOCATION: setSchemaLocation((String)newValue); return; @@ -305,6 +366,9 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb case CommonPackage.EROOT_OBJECT_IMPL__VERSION: setVersion(VERSION_EDEFAULT); return; + case CommonPackage.EROOT_OBJECT_IMPL__NAMESPACE: + setNamespace(NAMESPACE_EDEFAULT); + return; case CommonPackage.EROOT_OBJECT_IMPL__SCHEMA_LOCATION: setSchemaLocation(SCHEMA_LOCATION_EDEFAULT); return; @@ -327,6 +391,8 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb { case CommonPackage.EROOT_OBJECT_IMPL__VERSION: return VERSION_EDEFAULT == null ? version != null : !VERSION_EDEFAULT.equals(version); + case CommonPackage.EROOT_OBJECT_IMPL__NAMESPACE: + return NAMESPACE_EDEFAULT == null ? namespace != null : !NAMESPACE_EDEFAULT.equals(namespace); case CommonPackage.EROOT_OBJECT_IMPL__SCHEMA_LOCATION: return SCHEMA_LOCATION_EDEFAULT == null ? schemaLocation != null : !SCHEMA_LOCATION_EDEFAULT.equals(schemaLocation); case CommonPackage.EROOT_OBJECT_IMPL__IMPLIED_VERSION: @@ -348,6 +414,8 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb StringBuffer result = new StringBuffer(super.toString()); result.append(" (version: "); result.append(version); + result.append(", namespace: "); + result.append(namespace); result.append(", schemaLocation: "); result.append(schemaLocation); result.append(", impliedVersion: "); @@ -366,8 +434,6 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb // **************** version -> schema location mapping ******************** - protected abstract String getNamespace(); - protected abstract HashMap<String, String> schemaLocations(); protected String getSchemaLocationForVersion(String version) { @@ -377,9 +443,18 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb } return schemaLocation; } - - private static String buildSchemaLocationString(String namespace, String schemaLocation) { - return namespace + ' ' + schemaLocation; + + + // **************** version -> namespace mapping ******************** + + protected abstract HashMap<String, String> namespaces(); + + protected String getNamespaceForVersion(String version) { + String namespace = this.namespaces().get(version); + if (namespace == null) { + JptCommonCorePlugin.instance().logError(new Throwable("No namespace defined for version: " + version)); + } + return namespace; } @@ -398,8 +473,11 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb }; } - protected static Translator buildNamespaceTranslator(String namespace) { - return new ConstantAttributeTranslator(XML.NAMESPACE, namespace); + protected static Translator buildNamespaceTranslator() { + return new Translator( + XML.NAMESPACE, + CommonPackage.eINSTANCE.getERootObject_Namespace(), + Translator.DOM_ATTRIBUTE); } protected static Translator buildSchemaNamespaceTranslator() { @@ -407,7 +485,6 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb } protected static Translator buildSchemaLocationTranslator( - final String namespace, final Map<String, String> versionsToSchemaLocations) { return new EnumeratedValueTranslator( @@ -429,7 +506,9 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb @Override public String convertValueToString(Object value, EObject owner) { - return buildSchemaLocationString(namespace, (String) value); + String namespace = ((ERootObject) owner).getNamespace(); + String schemaLocation = (String) value; + return namespace + ' ' + schemaLocation; } }; } |