Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 219928 Details for
Bug 315464
Ability to convert an orm.xml file into an eclipselink-orm.xml file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
proposed patch
315464_08_15_2012.patch (text/plain), 22.30 KB, created by
Nan Li
on 2012-08-15 17:54:34 EDT
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Nan Li
Created:
2012-08-15 17:54:34 EDT
Size:
22.30 KB
patch
obsolete
>diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.core/plugin.xml >index 7c592c9..2e00e08 100644 >--- a/jpa/plugins/org.eclipse.jpt.jpa.core/plugin.xml >+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/plugin.xml >@@ -81,6 +81,13 @@ > <adapter type="org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription"/> > </factory> > >+ <!-- XmlFile -> JpaPlatformDescription --> >+ <factory >+ adaptableType="org.eclipse.jpt.jpa.core.context.XmlFile" >+ class="org.eclipse.jpt.jpa.core.internal.XmlFileAdapterFactory"> >+ <adapter type="org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription"/> >+ </factory> >+ > </extension> > > >@@ -189,14 +196,14 @@ > id="org.eclipse.jpt.jpa.core.propertyTester.XmlFile" > type="org.eclipse.jpt.jpa.core.context.XmlFile" > namespace="org.eclipse.jpt.jpa.core" >- properties="isLatestSupportedVersion, isNotLatestSupportedVersion" >+ properties="isLatestSupportedVersion, isNotLatestSupportedVersion, isGenericMappingFile" > class="org.eclipse.jpt.jpa.core.internal.context.XmlFilePropertyTester"/> > > <propertyTester > id="org.eclipse.jpt.jpa.core.propertyTester.JptResourceModel" > type="org.eclipse.jpt.common.core.JptResourceModel" > namespace="org.eclipse.jpt.jpa.core" >- properties="isLatestSupportedVersion, isNotLatestSupportedVersion" >+ properties="isLatestSupportedVersion, isNotLatestSupportedVersion, isGenericMappingFile" > class="org.eclipse.jpt.jpa.core.internal.JptResourceModelPropertyTester"/> > > </extension> >diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/XmlFile.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/XmlFile.java >index 6b56be1..951febd 100644 >--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/XmlFile.java >+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/XmlFile.java >@@ -9,8 +9,10 @@ > ******************************************************************************/ > package org.eclipse.jpt.jpa.core.context; > >+import org.eclipse.core.runtime.content.IContentType; > import org.eclipse.jpt.common.utility.internal.Tools; > import org.eclipse.jpt.jpa.core.JpaStructureNode; >+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings; > import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; > > /** >@@ -49,6 +51,11 @@ > * JPA platform. > */ > boolean isLatestSupportedVersion(); >+ >+ /** >+ * Return whether the XML file is a generic mapping file >+ */ >+ boolean isGenericMappingFile(); > > > // ********** XML file root element ********** >@@ -76,6 +83,14 @@ > String latestVersion = xmlFile.getJpaProject().getJpaPlatform().getMostRecentSupportedResourceType(xmlFile.getXmlResource().getContentType()).getVersion(); > return Tools.valuesAreEqual(xmlFileVersion, latestVersion); > } >+ >+ /** >+ * @see #isGenericMappingFile() >+ */ >+ public static boolean isGenericMappingFile(XmlFile xmlFile) { >+ IContentType contentType = xmlFile.getXmlResource().getContentType(); >+ return Tools.valuesAreEqual(contentType, XmlEntityMappings.CONTENT_TYPE); >+ } > > private XmlFile_() { > super(); >diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/JptResourceModelPropertyTester.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/JptResourceModelPropertyTester.java >index 5a136cc..91c7b11 100644 >--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/JptResourceModelPropertyTester.java >+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/JptResourceModelPropertyTester.java >@@ -11,10 +11,12 @@ > > import org.eclipse.core.expressions.PropertyTester; > import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.content.IContentType; > import org.eclipse.jpt.common.core.JptResourceModel; > import org.eclipse.jpt.common.core.JptResourceType; > import org.eclipse.jpt.common.utility.internal.Tools; > import org.eclipse.jpt.jpa.core.JpaProject; >+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings; > > /** > * Property tester for {@link JptResourceModel}. >@@ -25,7 +27,7 @@ > { > public static final String IS_LATEST_SUPPORTED_VERSION = "isLatestSupportedVersion"; //$NON-NLS-1$ > public static final String IS_NOT_LATEST_SUPPORTED_VERSION = "isNotLatestSupportedVersion"; //$NON-NLS-1$ >- >+ public static final String IS_GENERIC_MAPPING_FILE = "isGenericMappingFile"; //$NON-NLS-1$ > > public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { > if (receiver instanceof JptResourceModel) { >@@ -41,6 +43,11 @@ > if (property.equals(IS_LATEST_SUPPORTED_VERSION)) { > boolean expected = (expectedValue == null) ? true : ((Boolean) expectedValue).booleanValue(); > boolean actual = this.isLatestSupportedVersion(resourceModel); >+ return actual == expected; >+ } >+ if (property.equals(IS_GENERIC_MAPPING_FILE)) { >+ boolean expected = (expectedValue == null) ? true : ((Boolean) expectedValue).booleanValue(); >+ boolean actual = this.isGenericMappingFile(resourceModel); > return actual == expected; > } > return false; >@@ -61,6 +68,21 @@ > return Tools.valuesAreEqual(resourceType.getVersion(), latestVersion); > } > >+ private boolean isGenericMappingFile(JptResourceModel resourceModel) { >+ JpaProject jpaProject = this.getJpaProject(resourceModel.getFile().getProject()); >+ if (jpaProject == null) { >+ // if we get to this tester, the JPA project should be there; >+ // so this will probably never happen >+ return true; // effectively disable "upgrade" >+ } >+ JptResourceType resourceType = resourceModel.getResourceType(); >+ if (resourceType == null) { >+ return true; // effectively disable "upgrade" >+ } >+ IContentType contentType = resourceType.getContentType(); >+ return Tools.valuesAreEqual(contentType, XmlEntityMappings.CONTENT_TYPE); >+ } >+ > private JpaProject getJpaProject(IProject project) { > return (JpaProject) project.getAdapter(JpaProject.class); > } >diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/XmlFileAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/XmlFileAdapterFactory.java >new file mode 100644 >index 0000000..444171f >--- /dev/null >+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/XmlFileAdapterFactory.java >@@ -0,0 +1,46 @@ >+package org.eclipse.jpt.jpa.core.internal; >+ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IAdapterFactory; >+import org.eclipse.jpt.jpa.core.JpaPreferences; >+import org.eclipse.jpt.jpa.core.JpaWorkspace; >+import org.eclipse.jpt.jpa.core.context.XmlFile; >+import org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription; >+import org.eclipse.jpt.jpa.core.platform.JpaPlatformManager; >+ >+public class XmlFileAdapterFactory implements IAdapterFactory { >+ private static final Class<?>[] ADAPTER_LIST = new Class[] { >+ JpaPlatformDescription.class >+ }; >+ >+ public Class<?>[] getAdapterList() { >+ return ADAPTER_LIST; >+ } >+ >+ public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) { >+ if (adaptableObject instanceof XmlFile) { >+ return this.getAdapter(((XmlFile) adaptableObject).getXmlResource().getFile(), adapterType); >+ } >+ return null; >+ } >+ >+ private Object getAdapter(IResource resource, Class<?> adapterType) { >+ if (adapterType == JpaPlatformDescription.class) { >+ return this.getJpaPlatformDescription(resource); >+ } >+ return null; >+ } >+ >+ private JpaPlatformDescription getJpaPlatformDescription(IResource resource) { >+ return this.getJpaPlatformManager().getJpaPlatformDescription(JpaPreferences.getJpaPlatformID(resource.getProject())); >+ } >+ >+ private JpaPlatformManager getJpaPlatformManager() { >+ return this.getJpaWorkspace().getJpaPlatformManager(); >+ } >+ >+ private JpaWorkspace getJpaWorkspace() { >+ return (JpaWorkspace) ResourcesPlugin.getWorkspace().getAdapter(JpaWorkspace.class); >+ } >+} >diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/XmlFilePropertyTester.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/XmlFilePropertyTester.java >index df04779..c10cf73 100644 >--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/XmlFilePropertyTester.java >+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/XmlFilePropertyTester.java >@@ -21,7 +21,7 @@ > { > public static final String IS_LATEST_SUPPORTED_VERSION = "isLatestSupportedVersion"; //$NON-NLS-1$ > public static final String IS_NOT_LATEST_SUPPORTED_VERSION = "isNotLatestSupportedVersion"; //$NON-NLS-1$ >- >+ public static final String IS_GENERIC_MAPPING_FILE = "isGenericMappingFile"; //$NON-NLS-1$ > > public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { > if (receiver instanceof XmlFile) { >@@ -39,6 +39,11 @@ > boolean actual = xmlFile.isLatestSupportedVersion(); > return actual == expected; > } >+ if (property.equals(IS_GENERIC_MAPPING_FILE)) { >+ boolean expected = (expectedValue == null) ? true : ((Boolean) expectedValue).booleanValue(); >+ boolean actual =xmlFile.isGenericMappingFile(); >+ return actual == expected; >+ } > return false; > } > } >diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java >index 35f61e1..8aa3e01 100644 >--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java >+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java >@@ -258,6 +258,9 @@ > return Tools.valuesAreEqual(member, file); > } > >+ public boolean isGenericMappingFile() { >+ return XmlFile_.isGenericMappingFile(this); >+ } > > // ********** JpaStructureNode implementation ********** > >@@ -366,4 +369,5 @@ > // since this is the entire file, point to the top of the file > return TextRange.Empty.instance(); > } >+ > } >diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java >index c63ec9f..9952b4e 100644 >--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java >+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java >@@ -196,6 +196,9 @@ > return XmlFile_.isLatestSupportedVersion(this); > } > >+ public boolean isGenericMappingFile() { >+ return XmlFile_.isGenericMappingFile(this); >+ } > > // ********** metamodel ********** > >diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.properties >index cfdfdfd..556e5da 100644 >--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.properties >+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.properties >@@ -37,4 +37,6 @@ > jpaNode = JPA > eclipseLinkNode = EclipseLink > >-addVirtualAttribute = Add Virtual Attribute... >\ No newline at end of file >+addVirtualAttribute = Add Virtual Attribute... >+ >+upgradeToEclipseLinkMappingFile = Upgrade To EclipseLink Mapping File >\ No newline at end of file >diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml >index bcd9013..415e643 100644 >--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml >+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml >@@ -238,6 +238,11 @@ > id="org.eclipse.jpt.jpa.eclipselink.ui.generateDynamicEntities" > name="%generateDynamicEntities"/> > >+ <command >+ id="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile" >+ name="%upgradeToEclipseLinkMappingFile"> >+ </command> >+ > </extension> > > <!-- ***** handlers ***** --> >@@ -273,6 +278,29 @@ > commandId="org.eclipse.jpt.jpa.eclipselink.ui.generateDynamicEntities" > class="org.eclipse.jpt.jpa.eclipselink.ui.internal.commands.GenerateDynamicEntitiesHandler"> > </handler> >+ >+ <handler >+ class="org.eclipse.jpt.jpa.eclipselink.ui.internal.commands.UpgradeToEclipseLinkMappingFileHandler" >+ commandId="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile"> >+ <enabledWhen> >+ <iterate> >+ <or> >+ <adapt >+ type="org.eclipse.jpt.jpa.core.context.XmlFile"> >+ <test >+ property="org.eclipse.jpt.jpa.core.isGenericMappingFile"> >+ </test> >+ </adapt> >+ <adapt >+ type="org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource"> >+ <test >+ property="org.eclipse.jpt.jpa.core.isGenericMappingFile"> >+ </test> >+ </adapt> >+ </or> >+ </iterate> >+ </enabledWhen> >+ </handler> > > </extension> > >@@ -311,6 +339,32 @@ > </with> > </visibleWhen> > </command> >+ >+ <command >+ commandId="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile" >+ style="push"> >+ <visibleWhen> >+ <with >+ variable="selection"> >+ <iterate >+ ifEmpty="false"> >+ <adapt >+ type="org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription"> >+ <test >+ property="org.eclipse.jpt.jpa.core.jpaPlatformGroup" >+ value="eclipselink"> >+ </test> >+ </adapt> >+ <adapt >+ type="org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource"> >+ <test >+ property="org.eclipse.jpt.jpa.core.isGenericMappingFile"> >+ </test> >+ </adapt> >+ </iterate> >+ </with> >+ </visibleWhen> >+ </command> > > </menuContribution> > >@@ -362,6 +416,36 @@ > </command> > > </menuContribution> >+ >+ <!-- contributions for any popup --> >+ <menuContribution >+ locationURI="popup:org.eclipse.ui.popup.any"> >+ <command >+ commandId="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile"> >+ <visibleWhen> >+ <with >+ variable="selection"> >+ <iterate >+ ifEmpty="false"> >+ <adapt >+ type="org.eclipse.jpt.jpa.core.context.XmlFile"> >+ <test >+ property="org.eclipse.jpt.jpa.core.isGenericMappingFile"> >+ </test> >+ </adapt> >+ <adapt >+ type="org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription"> >+ <test >+ property="org.eclipse.jpt.jpa.core.jpaPlatformGroup" >+ value="eclipselink"> >+ </test> >+ </adapt> >+ </iterate> >+ </with> >+ </visibleWhen> >+ </command> >+ >+ </menuContribution> > > > </extension> >diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileHandler.java >new file mode 100644 >index 0000000..0c5cda7 >--- /dev/null >+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileHandler.java >@@ -0,0 +1,139 @@ >+package org.eclipse.jpt.jpa.eclipselink.ui.internal.commands; >+ >+import java.io.File; >+import java.io.IOException; >+import java.util.HashMap; >+import javax.xml.parsers.DocumentBuilder; >+import javax.xml.parsers.DocumentBuilderFactory; >+import javax.xml.parsers.ParserConfigurationException; >+import javax.xml.transform.OutputKeys; >+import javax.xml.transform.Transformer; >+import javax.xml.transform.TransformerConfigurationException; >+import javax.xml.transform.TransformerException; >+import javax.xml.transform.TransformerFactory; >+import javax.xml.transform.dom.DOMSource; >+import javax.xml.transform.stream.StreamResult; >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jpt.common.core.internal.utility.PlatformTools; >+import org.eclipse.jpt.jpa.core.JpaProject; >+import org.eclipse.jpt.jpa.core.context.XmlFile; >+import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; >+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLink; >+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntityMappings; >+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v1_1.EclipseLink1_1; >+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v1_2.EclipseLink1_2; >+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v2_0.EclipseLink2_0; >+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v2_1.EclipseLink2_1; >+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v2_2.EclipseLink2_2; >+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v2_3.EclipseLink2_3; >+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v2_4.EclipseLink2_4; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.w3c.dom.Document; >+import org.w3c.dom.NamedNodeMap; >+import org.w3c.dom.Node; >+import org.w3c.dom.NodeList; >+import org.xml.sax.SAXException; >+ >+public class UpgradeToEclipseLinkMappingFileHandler extends AbstractHandler { >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event); >+ >+ for (Object selectedObject : selection.toArray()) { >+ upgradeToEclipseLinkOrm(selectedObject); >+ } >+ return null; >+ } >+ >+ protected void upgradeToEclipseLinkOrm(Object selectedObject) { >+ JpaXmlResource xmlResource = PlatformTools.getAdapter(selectedObject, JpaXmlResource.class); >+ if (xmlResource == null) { >+ XmlFile xmlFile = PlatformTools.getAdapter(selectedObject, XmlFile.class); >+ if (xmlFile != null) { >+ xmlResource = xmlFile.getXmlResource(); >+ } >+ } >+ if (xmlResource == null) { >+ return; >+ } >+ >+ try { >+ JpaProject jpaProject = this.getJpaProject(xmlResource.getFile().getProject()); >+ String fileLocation = xmlResource.getFile().getRawLocation().toOSString(); >+ String newVersion = jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(XmlEntityMappings.CONTENT_TYPE).getVersion(); >+ >+ >+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); >+ DocumentBuilder builder = factory.newDocumentBuilder(); >+ Document document = builder.parse(new File(fileLocation)); >+ document.setXmlStandalone(true); >+ NodeList nodes = document.getElementsByTagName("entity-mappings"); >+ if (nodes.getLength() > 0) { >+ // we know only one "entity-mappings" element exists in the mapping file >+ Node node = nodes.item(0); >+ NamedNodeMap attributes = node.getAttributes(); >+ attributes.getNamedItem("version").setTextContent(newVersion); >+ attributes.getNamedItem("xmlns").setTextContent(getNamespace()); >+ attributes.getNamedItem("xsi:schemaLocation").setTextContent(buildSchemaLocationString(getNamespace(), getSchemaLocationForVersion(newVersion))); >+ } >+ >+ TransformerFactory transformerFactory = TransformerFactory.newInstance(); >+ Transformer transformer = transformerFactory.newTransformer(); >+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); >+ transformer.transform(new DOMSource(document), new StreamResult(new File(fileLocation))); >+ >+ // refresh the file to load the changes to the editor >+ xmlResource.getFile().refreshLocal(IResource.DEPTH_ZERO, null); >+ } catch (ParserConfigurationException pce) { >+ pce.printStackTrace(); >+ } catch (SAXException sxe) { >+ sxe.printStackTrace(); >+ } catch (IOException ioe) { >+ ioe.printStackTrace(); >+ } catch (TransformerConfigurationException tce) { >+ tce.printStackTrace(); >+ } catch (TransformerException te) { >+ te.printStackTrace(); >+ } catch (CoreException ce) { >+ ce.printStackTrace(); >+ } >+ } >+ >+ private JpaProject getJpaProject(IProject project) { >+ return (JpaProject) project.getAdapter(JpaProject.class); >+ } >+ >+ protected static String buildSchemaLocationString(String namespace, String schemaLocation) { >+ return namespace + ' ' + schemaLocation; >+ } >+ >+ protected String getNamespace() { >+ return EclipseLink.SCHEMA_NAMESPACE; >+ } >+ >+ protected String getSchemaLocationForVersion(String schemaVersion) { >+ return SCHEMA_LOCATIONS.get(schemaVersion); >+ } >+ >+ private static HashMap<String, String> SCHEMA_LOCATIONS = buildSchemaLocations(); >+ >+ private static HashMap<String, String> buildSchemaLocations() { >+ HashMap<String, String> map = new HashMap<String, String>(); >+ map.put(EclipseLink.SCHEMA_VERSION, EclipseLink.SCHEMA_LOCATION); >+ map.put(EclipseLink1_1.SCHEMA_VERSION, EclipseLink1_1.SCHEMA_LOCATION); >+ map.put(EclipseLink1_2.SCHEMA_VERSION, EclipseLink1_2.SCHEMA_LOCATION); >+ map.put(EclipseLink2_0.SCHEMA_VERSION, EclipseLink2_0.SCHEMA_LOCATION); >+ map.put(EclipseLink2_1.SCHEMA_VERSION, EclipseLink2_1.SCHEMA_LOCATION); >+ map.put(EclipseLink2_2.SCHEMA_VERSION, EclipseLink2_2.SCHEMA_LOCATION); >+ map.put(EclipseLink2_3.SCHEMA_VERSION, EclipseLink2_3.SCHEMA_LOCATION); >+ map.put(EclipseLink2_4.SCHEMA_VERSION, EclipseLink2_4.SCHEMA_LOCATION); >+ return map; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
neil.hauge
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 315464
: 219928