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 135408 Details for
Bug 275374
XML DirectCollectionMapping should support lists of lists
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch - calling ConvMgr directly
bug275374_090512.patch (text/plain), 33.74 KB, created by
Rick Barkhouse
on 2009-05-12 14:09:13 EDT
(
hide
)
Description:
Proposed patch - calling ConvMgr directly
Filename:
MIME Type:
Creator:
Rick Barkhouse
Created:
2009-05-12 14:09:13 EDT
Size:
33.74 KB
patch
obsolete
>Index: foundation/org.eclipse.persistence.core/resource/xsd/eclipselink_persistence_map_1.1.xsd >=================================================================== >--- foundation/org.eclipse.persistence.core/resource/xsd/eclipselink_persistence_map_1.1.xsd (revision 4160) >+++ foundation/org.eclipse.persistence.core/resource/xsd/eclipselink_persistence_map_1.1.xsd (working copy) >@@ -3407,7 +3407,8 @@ > <xsd:complexContent mixed="false"> > <xsd:extension base="abstract-composite-direct-collection-mapping"> > <xsd:sequence> >- <xsd:element minOccurs="0" name="is-cdata" type="xsd:boolean" /> >+ <xsd:element minOccurs="0" name="is-cdata" type="xsd:boolean" /> >+ <xsd:element minOccurs="0" name="field-sub-element-class-name" type="xsd:string"/> > </xsd:sequence> > </xsd:extension> > </xsd:complexContent> >Index: foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLCompositeDirectCollectionMappingNodeValue.java >=================================================================== >--- foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLCompositeDirectCollectionMappingNodeValue.java (revision 4160) >+++ foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLCompositeDirectCollectionMappingNodeValue.java (working copy) >@@ -192,13 +192,18 @@ > XMLField xmlField = (XMLField) xmlCompositeDirectCollectionMapping.getField(); > > XMLConversionManager xmlConversionManager = (XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager(); >- if (unmarshalRecord.getTypeQName() != null) { >- Class typeClass = xmlField.getJavaClass(unmarshalRecord.getTypeQName()); >- value = xmlConversionManager.convertObject(value, typeClass, unmarshalRecord.getTypeQName()); >+ >+ if (xmlCompositeDirectCollectionMapping.getFieldSubElementClass() != null) { >+ value = xmlConversionManager.convertStringToList(value, xmlCompositeDirectCollectionMapping.getFieldSubElementClass(), xmlCompositeDirectCollectionMapping.getContainerPolicy()); > } else { >- value = xmlField.convertValueBasedOnSchemaType(value, xmlConversionManager, unmarshalRecord); >+ if (unmarshalRecord.getTypeQName() != null) { >+ Class typeClass = xmlField.getJavaClass(unmarshalRecord.getTypeQName()); >+ value = xmlConversionManager.convertObject(value, typeClass, unmarshalRecord.getTypeQName()); >+ } else { >+ value = xmlField.convertValueBasedOnSchemaType(value, xmlConversionManager, unmarshalRecord); >+ } > } >- >+ > if (xmlCompositeDirectCollectionMapping.hasValueConverter()) { > if (xmlCompositeDirectCollectionMapping.getValueConverter() instanceof XMLConverter) { > value = ((XMLConverter) xmlCompositeDirectCollectionMapping.getValueConverter()).convertDataValueToObjectValue(value, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); >@@ -230,7 +235,12 @@ > if (xmlCompositeDirectCollectionMapping.getValueConverter() instanceof XMLConverter) { > value = ((XMLConverter) xmlCompositeDirectCollectionMapping.getValueConverter()).convertObjectValueToDataValue(value, session, marshalRecord.getMarshaller()); > } else { >- value = xmlCompositeDirectCollectionMapping.getValueConverter().convertObjectValueToDataValue(value, session); >+ if (xmlCompositeDirectCollectionMapping.getFieldSubElementClass() != null) { >+ XMLConversionManager xmlConversionManager = (XMLConversionManager) marshalRecord.getSession().getDatasourcePlatform().getConversionManager(); >+ value = xmlConversionManager.convertListToString(value); >+ } else { >+ value = xmlCompositeDirectCollectionMapping.getValueConverter().convertObjectValueToDataValue(value, session); >+ } > } > } > XMLField xmlField = (XMLField) xmlCompositeDirectCollectionMapping.getField(); >Index: foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLConversionManager.java >=================================================================== >--- foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLConversionManager.java (revision 4160) >+++ foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLConversionManager.java (working copy) >@@ -18,6 +18,7 @@ > import java.sql.Timestamp; > import java.util.ArrayList; > import java.util.Calendar; >+import java.util.Collection; > import java.util.Date; > import java.util.GregorianCalendar; > import java.util.HashMap; >@@ -36,6 +37,7 @@ > import org.eclipse.persistence.exceptions.XMLConversionException; > import org.eclipse.persistence.internal.helper.*; > import org.eclipse.persistence.internal.oxm.conversion.Base64; >+import org.eclipse.persistence.internal.queries.ContainerPolicy; > import org.eclipse.persistence.oxm.XMLConstants; > > /** >@@ -1687,6 +1689,28 @@ > } > return list; > } >+ >+ /** >+ * Convert the given sourceObject (String) to the appropriate collection type specified by the >+ * containerPolicy, using the elementType to properly convert each element of the list. >+ * >+ * @param sourceObject - will always be a string if read from XML >+ * @param elementType - the type of the elements contained in the list >+ * @return - the newly converted object >+ */ >+ public Object convertStringToList(Object sourceObject, Class elementType, ContainerPolicy containerPolicy) throws ConversionException { >+ Collection collection = (Collection) containerPolicy.containerInstance(); >+ >+ if (sourceObject instanceof String) { >+ StringTokenizer tokenizer = new StringTokenizer((String) sourceObject, " "); >+ while (tokenizer.hasMoreElements()) { >+ String token = tokenizer.nextToken(); >+ collection.add(convertObject(token, elementType)); >+ } >+ } >+ >+ return collection; >+ } > > protected String convertListToString(Object sourceObject) throws ConversionException { > String returnString = new String(); >@@ -1694,12 +1718,10 @@ > List list = (List) sourceObject; > for (int i = 0; i < list.size(); i++) { > Object next = list.get(i); >- if (next instanceof String) { > if (i > 0) { > returnString += " "; > } >- returnString = returnString + next; >- } >+ returnString = returnString + convertObjectToString(next); > } > } > return returnString; >Index: foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/EclipseLinkObjectPersistenceRuntimeXMLProject.java >=================================================================== >--- foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/EclipseLinkObjectPersistenceRuntimeXMLProject.java (revision 4160) >+++ foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/EclipseLinkObjectPersistenceRuntimeXMLProject.java (working copy) >@@ -235,5 +235,18 @@ > > return descriptor; > } >- >+ >+ protected ClassDescriptor buildXMLCompositeDirectCollectionMappingDescriptor() { >+ ClassDescriptor descriptor = super.buildXMLCompositeDirectCollectionMappingDescriptor(); >+ >+ XMLDirectMapping fieldSubElementClassNameMapping = new XMLDirectMapping(); >+ fieldSubElementClassNameMapping.setAttributeName("fieldSubElementClassName"); >+ fieldSubElementClassNameMapping.setGetMethodName("getFieldSubElementClassName"); >+ fieldSubElementClassNameMapping.setSetMethodName("setFieldSubElementClassName"); >+ fieldSubElementClassNameMapping.setXPath(getPrimaryNamespaceXPath() + "field-sub-element-class-name"); >+ descriptor.addMapping(fieldSubElementClassNameMapping); >+ >+ return descriptor; >+ } >+ > } >\ No newline at end of file >Index: foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/XMLCompositeDirectCollectionMapping.java >=================================================================== >--- foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/XMLCompositeDirectCollectionMapping.java (revision 4160) >+++ foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/XMLCompositeDirectCollectionMapping.java (working copy) >@@ -12,14 +12,19 @@ > ******************************************************************************/ > package org.eclipse.persistence.oxm.mappings; > >+import java.security.AccessController; >+import java.security.PrivilegedActionException; > import java.util.Enumeration; > import java.util.Vector; > import org.eclipse.persistence.exceptions.DatabaseException; > import org.eclipse.persistence.exceptions.DescriptorException; >+import org.eclipse.persistence.exceptions.ValidationException; > import org.eclipse.persistence.oxm.XMLField; >+import org.eclipse.persistence.internal.oxm.XMLConversionManager; > import org.eclipse.persistence.internal.queries.CollectionContainerPolicy; > import org.eclipse.persistence.internal.queries.ContainerPolicy; > import org.eclipse.persistence.internal.queries.JoinedAttributeManager; >+import org.eclipse.persistence.internal.security.PrivilegedClassForName; > import org.eclipse.persistence.internal.sessions.AbstractRecord; > import org.eclipse.persistence.internal.sessions.AbstractSession; > import org.eclipse.persistence.mappings.converters.TypeConversionConverter; >@@ -215,7 +220,12 @@ > * @since Oracle TopLink 10<i>g</i> Release 2 (10.1.3) > */ > public class XMLCompositeDirectCollectionMapping extends AbstractCompositeDirectCollectionMapping implements XMLMapping { >+ > private boolean isCDATA; >+ >+ private Class fieldSubElementClass = null; >+ private String fieldSubElementClassName = null; >+ > private boolean isWriteOnly; > > public XMLCompositeDirectCollectionMapping() { >@@ -247,6 +257,17 @@ > cp.setContainerClass(cls); > } > } >+ >+ try { >+ if (getFieldSubElementClassName() != null) { >+ ClassLoader loader = session.getDatasourcePlatform().getConversionManager().getLoader(); >+ Class aClass = (Class) AccessController.doPrivileged(new PrivilegedClassForName(getFieldSubElementClassName(), true, loader)); >+ setFieldSubElementClass(aClass); >+ } >+ } catch (PrivilegedActionException pae) { >+ throw ValidationException.classNotFoundWhileConvertingClassNames(getFieldSubElementClassName(), pae.getException()); >+ } >+ > ((XMLField) this.getField()).setIsCDATA(this.isCDATA()); > } > >@@ -293,11 +314,17 @@ > Object result = cp.containerInstance(fieldValues.size()); > for (Enumeration stream = fieldValues.elements(); stream.hasMoreElements();) { > Object element = stream.nextElement(); >- if (hasValueConverter()) { >- if (getValueConverter() instanceof XMLConverter) { >- element = ((XMLConverter) getValueConverter()).convertDataValueToObjectValue(element, executionSession, ((XMLRecord) row).getUnmarshaller()); >- } else { >- element = getValueConverter().convertDataValueToObjectValue(element, executionSession); >+ >+ if (getFieldSubElementClass() != null) { >+ XMLConversionManager xmlConversionManager = (XMLConversionManager) executionSession.getDatasourcePlatform().getConversionManager(); >+ element = xmlConversionManager.convertStringToList(element, getFieldSubElementClass(), getContainerPolicy()); >+ } else { >+ if (hasValueConverter()) { >+ if (getValueConverter() instanceof XMLConverter) { >+ element = ((XMLConverter) getValueConverter()).convertDataValueToObjectValue(element, executionSession, ((XMLRecord) row).getUnmarshaller()); >+ } else { >+ element = getValueConverter().convertDataValueToObjectValue(element, executionSession); >+ } > } > } > cp.addInto(element, result, sourceQuery.getSession()); >@@ -362,7 +389,46 @@ > public boolean isCDATA() { > return isCDATA; > } >- >+ >+ /** >+ * Get the Class name of the elements of this collection's "sub-collection". >+ * Only applicable for DirectCollections of Lists (e.g. ArrayList<ArrayList<Double>>) >+ * @return String the name of the Class of the elements of this collection's "sub-collection" >+ */ >+ public String getFieldSubElementClassName() { >+ return fieldSubElementClassName; >+ } >+ >+ /** >+ * Set the Class name of the elements of this collection's "sub-collection". >+ * Only applicable for DirectCollections of Lists (e.g. ArrayList<ArrayList<Double>>) >+ * @param aClassName the name of the Class of the elements of this collection's "sub-collection" >+ */ >+ public void setFieldSubElementClassName(String aClassName) { >+ fieldSubElementClassName = aClassName; >+ } >+ >+ /** >+ * Get the Class of the elements of this collection's "sub-collection". >+ * Only applicable for DirectCollections of Lists (e.g. ArrayList<ArrayList<Double>>) >+ * @return Class the Class of the elements of this collection's "sub-collection" >+ */ >+ public Class getFieldSubElementClass() { >+ return fieldSubElementClass; >+ } >+ >+ /** >+ * Set the Class of the elements of this collection's "sub-collection". >+ * Only applicable for DirectCollections of Lists (e.g. ArrayList<ArrayList<Double>>) >+ * @param aClass the Class of the elements of this collection's "sub-collection" >+ */ >+ public void setFieldSubElementClass(Class aClass) { >+ this.fieldSubElementClass = aClass; >+ if (this.fieldSubElementClassName == null) { >+ this.fieldSubElementClassName = aClass.getName(); >+ } >+ } >+ > public void setIsWriteOnly(boolean b) { > this.isWriteOnly = b; > } >@@ -384,4 +450,4 @@ > super.preInitialize(session); > } > >-} >+} >\ No newline at end of file >Index: moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml >=================================================================== >--- moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml (revision 0) >+++ moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml (revision 0) >@@ -0,0 +1,4 @@ >+<root> >+ <item>1.2 3.4 5.6</item> >+ <item>-7.8 -9.0 -1.2</item> >+</root> >\ No newline at end of file >Index: moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml >=================================================================== >--- moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml (revision 0) >+++ moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml (revision 0) >@@ -0,0 +1,4 @@ >+<root> >+ <item>1.2 3.4 5.6</item> >+ <item>-7.8 -9.0 -1.2</item> >+</root> >\ No newline at end of file >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/DirectCollectionMappingTestSuite.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/DirectCollectionMappingTestSuite.java (revision 4160) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/DirectCollectionMappingTestSuite.java (working copy) >@@ -44,6 +44,7 @@ > import org.eclipse.persistence.testing.oxm.mappings.directcollection.identifiedbyposition.withgroupingelement.DirectCollectionWithGroupingElementIdentifiedByPositionEmptyTestCases; > import org.eclipse.persistence.testing.oxm.mappings.directcollection.identifiedbyposition.withgroupingelement.DirectCollectionWithGroupingElementIdentifiedByPositionNullTestCases; > import org.eclipse.persistence.testing.oxm.mappings.directcollection.identifiedbyposition.withgroupingelement.DirectCollectionWithGroupingElementIdentifiedByPositionTestCases; >+import org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists.XMLDirectCollectionOfListsTestCases; > import org.eclipse.persistence.testing.oxm.mappings.directcollection.nillable.DirectCollectionIsSetNodeNullPolicyTrueTestCases; > import org.eclipse.persistence.testing.oxm.mappings.directcollection.nillable.DirectCollectionNillableNodeNullPolicyTestCases; > import org.eclipse.persistence.testing.oxm.mappings.directcollection.nillable.DirectCollectionOptionalNodeNullPolicyAttributeTestCases; >@@ -113,6 +114,8 @@ > //suite.addTestSuite(DirectCollectionIsSetNodeNullPolicyTrueTestCases.class);// 3 of 6 pass until implementation set > // UC4-false - n/a > >+ suite.addTestSuite(XMLDirectCollectionOfListsTestCases.class); >+ > return suite; > } > >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java (revision 0) >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * Copyright (c) 1998, 2008 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * rbarkhouse - 2009-05-05 14:32:00 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Iterator; >+ >+public class Root { >+ >+ public ArrayList<ArrayList<Double>> items = new ArrayList<ArrayList<Double>>(); >+ >+ public ArrayList<ArrayList<Double>> getItems() { >+ return this.items; >+ } >+ >+ public boolean equals(Object obj) { >+ if (!(obj instanceof Root)) { >+ return false; >+ } >+ >+ Root otherRoot = (Root) obj; >+ >+ if (this.items.size() != otherRoot.items.size()) { >+ return false; >+ } >+ >+ return this.items.equals(otherRoot.items); >+ } >+ >+} >\ No newline at end of file >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java (revision 0) >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 1998, 2008 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * rbarkhouse - 2009-05-05 14:32:00 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.persistence.oxm.XMLConstants; >+import org.eclipse.persistence.oxm.XMLDescriptor; >+import org.eclipse.persistence.oxm.XMLField; >+import org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping; >+import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping; >+import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; >+import org.eclipse.persistence.sessions.Project; >+ >+public class RootProject extends Project { >+ >+ public RootProject() { >+ addDescriptor(getRootDescriptor()); >+ } >+ >+ private XMLDescriptor getRootDescriptor() { >+ XMLDescriptor descriptor = new XMLDescriptor(); >+ descriptor.setJavaClass(Root.class); >+ descriptor.setDefaultRootElement("root"); >+ >+ XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping(); >+ itemsMapping.setAttributeName("items"); >+ itemsMapping.setXPath("item/text()"); >+ itemsMapping.setFieldElementClass(ArrayList.class); >+ itemsMapping.setFieldSubElementClass(Double.class); >+ itemsMapping.useCollectionClass(ArrayList.class); >+ >+ descriptor.addMapping(itemsMapping); >+ return descriptor; >+ } >+ >+} >\ No newline at end of file >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java (revision 0) >@@ -0,0 +1,57 @@ >+/******************************************************************************* >+ * Copyright (c) 1998, 2008 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * rbarkhouse - 2009-05-05 14:32:00 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; >+ >+import java.lang.reflect.Field; >+import java.lang.reflect.ParameterizedType; >+import java.lang.reflect.Type; >+import java.lang.reflect.TypeVariable; >+import java.util.ArrayList; >+ >+import javax.lang.model.element.TypeParameterElement; >+ >+import org.eclipse.persistence.testing.oxm.mappings.XMLMappingTestCases; >+ >+public class XMLDirectCollectionOfListsTestCases extends XMLMappingTestCases { >+ >+ private final static String XML_RESOURCE = "org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml"; >+ >+ public XMLDirectCollectionOfListsTestCases(String name) throws Exception { >+ super(name); >+ setControlDocument(XML_RESOURCE); >+ setProject(new RootProject()); >+ } >+ >+ protected Object getControlObject() { >+ Root root = new Root(); >+ >+ ArrayList<Double> values1 = new ArrayList<Double>(); >+ values1.add(Double.valueOf(1.2)); >+ values1.add(Double.valueOf(3.4)); >+ values1.add(Double.valueOf(5.6)); >+ >+ ArrayList<Double> values2 = new ArrayList<Double>(); >+ values2.add(Double.valueOf(-7.8)); >+ values2.add(Double.valueOf(-9.0)); >+ values2.add(Double.valueOf(-1.2)); >+ >+ ArrayList<ArrayList<Double>> itemCollection = new ArrayList<ArrayList<Double>>(); >+ itemCollection.add(values1); >+ itemCollection.add(values2); >+ >+ root.items = itemCollection; >+ >+ return root; >+ } >+ >+} >\ No newline at end of file >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java (revision 0) >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * Copyright (c) 1998, 2008 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * rbarkhouse - 2009-05-05 14:32:00 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Iterator; >+ >+public class Root { >+ >+ public ArrayList<ArrayList<Double>> items = new ArrayList<ArrayList<Double>>(); >+ >+ public ArrayList<ArrayList<Double>> getItems() { >+ return this.items; >+ } >+ >+ public boolean equals(Object obj) { >+ if (!(obj instanceof Root)) { >+ return false; >+ } >+ >+ Root otherRoot = (Root) obj; >+ >+ if (this.items.size() != otherRoot.items.size()) { >+ return false; >+ } >+ >+ return this.items.equals(otherRoot.items); >+ } >+ >+} >\ No newline at end of file >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java (revision 0) >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 1998, 2008 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * rbarkhouse - 2009-05-05 14:32:00 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.persistence.oxm.XMLConstants; >+import org.eclipse.persistence.oxm.XMLDescriptor; >+import org.eclipse.persistence.oxm.XMLField; >+import org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping; >+import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping; >+import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; >+import org.eclipse.persistence.sessions.Project; >+ >+public class RootProject extends Project { >+ >+ public RootProject() { >+ addDescriptor(getRootDescriptor()); >+ } >+ >+ private XMLDescriptor getRootDescriptor() { >+ XMLDescriptor descriptor = new XMLDescriptor(); >+ descriptor.setJavaClass(Root.class); >+ descriptor.setDefaultRootElement("root"); >+ >+ XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping(); >+ itemsMapping.setAttributeName("items"); >+ itemsMapping.setXPath("item/text()"); >+ itemsMapping.setFieldElementClass(ArrayList.class); >+ itemsMapping.setFieldSubElementClass(Double.class); >+ itemsMapping.useCollectionClass(ArrayList.class); >+ >+ descriptor.addMapping(itemsMapping); >+ return descriptor; >+ } >+ >+} >\ No newline at end of file >Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java >=================================================================== >--- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java (revision 0) >+++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java (revision 0) >@@ -0,0 +1,57 @@ >+/******************************************************************************* >+ * Copyright (c) 1998, 2008 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * rbarkhouse - 2009-05-05 14:32:00 - initial implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; >+ >+import java.lang.reflect.Field; >+import java.lang.reflect.ParameterizedType; >+import java.lang.reflect.Type; >+import java.lang.reflect.TypeVariable; >+import java.util.ArrayList; >+ >+import javax.lang.model.element.TypeParameterElement; >+ >+import org.eclipse.persistence.testing.oxm.mappings.XMLMappingTestCases; >+ >+public class XMLDirectCollectionOfListsTestCases extends XMLMappingTestCases { >+ >+ private final static String XML_RESOURCE = "org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml"; >+ >+ public XMLDirectCollectionOfListsTestCases(String name) throws Exception { >+ super(name); >+ setControlDocument(XML_RESOURCE); >+ setProject(new RootProject()); >+ } >+ >+ protected Object getControlObject() { >+ Root root = new Root(); >+ >+ ArrayList<Double> values1 = new ArrayList<Double>(); >+ values1.add(Double.valueOf(1.2)); >+ values1.add(Double.valueOf(3.4)); >+ values1.add(Double.valueOf(5.6)); >+ >+ ArrayList<Double> values2 = new ArrayList<Double>(); >+ values2.add(Double.valueOf(-7.8)); >+ values2.add(Double.valueOf(-9.0)); >+ values2.add(Double.valueOf(-1.2)); >+ >+ ArrayList<ArrayList<Double>> itemCollection = new ArrayList<ArrayList<Double>>(); >+ itemCollection.add(values1); >+ itemCollection.add(values2); >+ >+ root.items = itemCollection; >+ >+ return root; >+ } >+ >+} >\ No newline at end of file >Index: moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java >=================================================================== >--- moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java (revision 4160) >+++ moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java (working copy) >@@ -387,6 +387,9 @@ > if(((DatabaseMapping)nestedMapping).isAbstractCompositeCollectionMapping()){ > ((XMLCompositeCollectionMapping)nestedMapping).setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT); > } >+ if (element.isList() && ((DatabaseMapping)nestedMapping).isAbstractCompositeDirectCollectionMapping()) { >+ ((XMLCompositeDirectCollectionMapping)nestedMapping).setFieldSubElementClassName(element.getJavaType().getQualifiedName()); >+ } > }else{ > ((XMLChoiceObjectMapping)mapping).addChoiceElement(xmlField, element.getJavaTypeName()); > XMLMapping nestedMapping = ((XMLChoiceObjectMapping)mapping).getChoiceElementMappings().get(xmlField);
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
Actions:
View
|
Diff
Attachments on
bug 275374
:
135408
|
135671