use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.
the class XMLChoiceCollectionMapping method initialize.
@Override
public void initialize(AbstractSession session) throws DescriptorException {
super.initialize(session);
if (this.converter != null) {
this.converter.initialize(this, session);
}
ArrayList<XMLMapping> mappingsList = new ArrayList<>();
mappingsList.addAll(getChoiceElementMappings().values());
for (XMLMapping next : getChoiceElementMappingsByClass().values()) {
if (!(mappingsList.contains(next))) {
mappingsList.add(next);
}
}
if (isAny) {
// anyMapping = new XMLAnyCollectionMapping();
mappingsList.add(anyMapping);
}
Iterator<XMLMapping> mappings = mappingsList.iterator();
while (mappings.hasNext()) {
DatabaseMapping nextMapping = (DatabaseMapping) mappings.next();
Converter converter = null;
if (fieldsToConverters != null) {
converter = fieldsToConverters.get(nextMapping.getField());
}
if (nextMapping.isAbstractCompositeDirectCollectionMapping()) {
XMLConversionManager xmlConversionManager = (XMLConversionManager) session.getDatasourcePlatform().getConversionManager();
QName schemaType = xmlConversionManager.schemaType(((AbstractCompositeDirectCollectionMapping) nextMapping).getAttributeElementClass());
if (schemaType != null) {
((XMLField) nextMapping.getField()).setSchemaType(schemaType);
}
if (converter != null) {
((AbstractCompositeDirectCollectionMapping) nextMapping).setValueConverter(converter);
}
((AbstractCompositeDirectCollectionMapping) nextMapping).setContainerPolicy(getContainerPolicy());
} else if (nextMapping.isAbstractCompositeCollectionMapping()) {
if (converter != null) {
((AbstractCompositeCollectionMapping) nextMapping).setConverter(converter);
}
((AbstractCompositeCollectionMapping) nextMapping).setContainerPolicy(getContainerPolicy());
} else if (nextMapping instanceof XMLBinaryDataCollectionMapping) {
((XMLBinaryDataCollectionMapping) nextMapping).setContainerPolicy(getContainerPolicy());
if (converter != null) {
((XMLBinaryDataCollectionMapping) nextMapping).setValueConverter(converter);
}
} else if (nextMapping instanceof XMLAnyCollectionMapping) {
((XMLAnyCollectionMapping) nextMapping).setContainerPolicy(getContainerPolicy());
if (converter != null && converter instanceof XMLConverter) {
((XMLAnyCollectionMapping) nextMapping).setConverter((XMLConverter) converter);
}
} else {
((XMLCollectionReferenceMapping) nextMapping).setContainerPolicy(getContainerPolicy());
((XMLCollectionReferenceMapping) nextMapping).setReuseContainer(true);
}
nextMapping.initialize(session);
}
}
use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.
the class XMLChoiceObjectMapping method initialize.
@Override
public void initialize(AbstractSession session) throws DescriptorException {
super.initialize(session);
if (this.converter != null) {
this.converter.initialize(this, session);
}
ArrayList<XMLMapping> mappingsList = new ArrayList<>();
mappingsList.addAll(getChoiceElementMappings().values());
for (XMLMapping next : getChoiceElementMappingsByClass().values()) {
if (!(mappingsList.contains(next))) {
mappingsList.add(next);
}
}
Iterator<XMLMapping> mappings = mappingsList.iterator();
while (mappings.hasNext()) {
DatabaseMapping nextMapping = (DatabaseMapping) mappings.next();
Converter converter = null;
if (fieldsToConverters != null) {
converter = fieldsToConverters.get(nextMapping.getField());
}
if (nextMapping.isAbstractDirectMapping()) {
((XMLDirectMapping) nextMapping).setIsWriteOnly(this.isWriteOnly());
if (converter != null) {
((AbstractDirectMapping) nextMapping).setConverter(converter);
}
XMLConversionManager xmlConversionManager = (XMLConversionManager) session.getDatasourcePlatform().getConversionManager();
QName schemaType = xmlConversionManager.schemaType(nextMapping.getAttributeClassification());
if (schemaType != null && ((XMLField) nextMapping.getField()).getSchemaType() == null) {
((XMLField) nextMapping.getField()).setSchemaType(schemaType);
}
} else if (nextMapping instanceof XMLObjectReferenceMapping) {
((XMLObjectReferenceMapping) nextMapping).setIsWriteOnly(this.isWriteOnly);
} else if (nextMapping instanceof XMLBinaryDataMapping) {
((XMLBinaryDataMapping) nextMapping).setIsCDATA(this.isWriteOnly);
if (converter != null) {
((XMLBinaryDataMapping) nextMapping).setConverter(converter);
}
} else {
((XMLCompositeObjectMapping) nextMapping).setIsWriteOnly(this.isWriteOnly());
if (converter != null) {
((AbstractCompositeObjectMapping) nextMapping).setConverter(converter);
}
}
nextMapping.initialize(session);
}
}
use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.
the class DateAndTimeTestCases method testSqlDateToString_dateTime_dstTimeZone.
public void testSqlDateToString_dateTime_dstTimeZone() {
XMLConversionManager xmlConversionManager = (XMLConversionManager) XMLConversionManager.getDefaultXMLManager().clone();
xmlConversionManager.setTimeZone(TimeZone.getTimeZone(CONTROL_DST_TIME_ZONE));
xmlConversionManager.setTimeZoneQualified(true);
java.sql.Date sqlDate = xmlConversionManager.convertObject(CONTROL_DST_INPUT_DATE_TIME, java.sql.Date.class, XMLConstants.DATE_TIME_QNAME);
String testString = xmlConversionManager.convertObject(sqlDate, String.class, XMLConstants.DATE_TIME_QNAME);
assertEquals("2003-08-29T03:00:00" + controlXmlConversionTimeSuffix + "-04:00", testString);
}
use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.
the class DateAndTimeTestCases method testSqlTimestampToString_default_dstTimeZone.
public void testSqlTimestampToString_default_dstTimeZone() {
XMLConversionManager xmlConversionManager = (XMLConversionManager) XMLConversionManager.getDefaultXMLManager().clone();
xmlConversionManager.setTimeZone(TimeZone.getTimeZone(CONTROL_DST_TIME_ZONE));
xmlConversionManager.setTimeZoneQualified(true);
java.sql.Timestamp sqlTimestamp = xmlConversionManager.convertObject(CONTROL_DST_INPUT_DATE_TIME, Timestamp.class, XMLConstants.DATE_TIME_QNAME);
String testString = xmlConversionManager.convertObject(sqlTimestamp, String.class);
assertEquals("2003-08-29T03:00:00" + controlXmlConversionTimeSuffix + "-04:00", testString);
}
use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.
the class DateAndTimeTestCases method testUtilDateToString_dateTime_dstTimeZone.
public void testUtilDateToString_dateTime_dstTimeZone() {
XMLConversionManager xmlConversionManager = (XMLConversionManager) XMLConversionManager.getDefaultXMLManager().clone();
xmlConversionManager.setTimeZone(TimeZone.getTimeZone(CONTROL_DST_TIME_ZONE));
xmlConversionManager.setTimeZoneQualified(true);
java.util.Date utilDate = xmlConversionManager.convertObject(CONTROL_DST_INPUT_DATE_TIME, java.util.Date.class);
String testString = xmlConversionManager.convertObject(utilDate, String.class, XMLConstants.DATE_TIME_QNAME);
assertEquals("2003-08-29T03:00:00" + controlXmlConversionTimeSuffix + "-04:00", testString);
}
Aggregations