use of org.eclipse.persistence.internal.nosql.adapters.nosql.OracleNoSQLRecord in project eclipselink by eclipse-ee4j.
the class OracleNoSQLPlatform method createDatabaseRowFromDOMRecord.
/**
* Allow the platform to handle the creation of the Record for the DOM record.
* Creates a DOM record from the XML data stored as a value in the OracleNoSQLRecord.
*/
@Override
public AbstractRecord createDatabaseRowFromDOMRecord(jakarta.resource.cci.Record record, EISInteraction call, EISAccessor accessor) {
if (record == null) {
return null;
}
EISDOMRecord domRecord = null;
OracleNoSQLRecord noSqlRecord = (OracleNoSQLRecord) record;
if (noSqlRecord.size() == 0) {
return null;
} else if (noSqlRecord.size() == 1) {
domRecord = new EISDOMRecord();
Object value = noSqlRecord.values().iterator().next();
String xml = null;
if (value instanceof byte[]) {
xml = new String((byte[]) value);
} else {
xml = (String) value;
}
if (xml != null) {
domRecord.transformFromXML(xml);
}
} else {
domRecord = new EISDOMRecord();
for (Map.Entry<?, ?> entry : (Set<Map.Entry<?, ?>>) noSqlRecord.entrySet()) {
Object value = entry.getValue();
String xml = null;
if (value instanceof byte[]) {
xml = new String((byte[]) value);
} else {
xml = (String) value;
}
if (xml != null) {
EISDOMRecord dom = new EISDOMRecord();
dom.transformFromXML(xml);
domRecord.put(entry.getKey(), dom);
}
}
}
return domRecord;
}
use of org.eclipse.persistence.internal.nosql.adapters.nosql.OracleNoSQLRecord in project eclipselink by eclipse-ee4j.
the class OracleNoSQLPlatform method setDOMInRecord.
/**
* Stores the XML DOM value into the record.
* XML is stored in Oracle NoSQL but storing the XML text, keyed on the object's {@literal "<dataTypeName>/<id>"}.
*/
@Override
public void setDOMInRecord(Element dom, jakarta.resource.cci.Record record, EISInteraction interaction, EISAccessor accessor) {
OracleNoSQLRecord noSqlRecord = (OracleNoSQLRecord) record;
org.eclipse.persistence.oxm.record.DOMRecord domRecord = new org.eclipse.persistence.oxm.record.DOMRecord(dom);
domRecord.setSession(interaction.getQuery().getSession());
// Create the key from the objects id.
ClassDescriptor descriptor = interaction.getQuery().getDescriptor();
if (descriptor == null) {
throw new EISException("XMLInteraction is only valid for object queries, use MappedIneraction for native queries: " + interaction);
}
Object key = createMajorKey(descriptor, domRecord, interaction, accessor);
noSqlRecord.put(key, domRecord.transformToXML().getBytes());
}
use of org.eclipse.persistence.internal.nosql.adapters.nosql.OracleNoSQLRecord in project eclipselink by eclipse-ee4j.
the class OracleNoSQLPlatform method buildRows.
/**
* Allow the platform to handle record to row conversion.
*/
@Override
public Vector<AbstractRecord> buildRows(jakarta.resource.cci.Record record, EISInteraction interaction, EISAccessor accessor) {
if (record == null) {
return new Vector<>(0);
}
OracleNoSQLRecord output = (OracleNoSQLRecord) record;
if ((output.size() == 1) && (interaction.getQuery().getDescriptor() != null)) {
// Check for a nested mapped record.
Object value = output.values().iterator().next();
if (value instanceof OracleNoSQLRecord) {
Vector<AbstractRecord> rows = new Vector<>(1);
convertRecordBytesToString((OracleNoSQLRecord) value);
rows.add(interaction.buildRow((OracleNoSQLRecord) value, accessor));
return rows;
} else if (value instanceof Collection) {
Vector<AbstractRecord> rows = new Vector<>(((Collection<?>) value).size());
for (Object nestedValue : (Collection<?>) value) {
if (nestedValue instanceof OracleNoSQLRecord) {
rows.add(interaction.buildRow((OracleNoSQLRecord) nestedValue, accessor));
}
}
return rows;
}
}
if (interaction.getQuery().getDescriptor() != null) {
// Check for a map of values.
Vector<AbstractRecord> rows = new Vector<>();
for (Object value : output.values()) {
if (value instanceof OracleNoSQLRecord) {
convertRecordBytesToString((OracleNoSQLRecord) value);
rows.add(interaction.buildRow((OracleNoSQLRecord) value, accessor));
} else if (value instanceof byte[]) {
EISDOMRecord domRecord = new EISDOMRecord();
domRecord.transformFromXML(new String((byte[]) value));
rows.add(domRecord);
}
}
return rows;
}
return interaction.buildRows(record, accessor);
}
use of org.eclipse.persistence.internal.nosql.adapters.nosql.OracleNoSQLRecord in project eclipselink by eclipse-ee4j.
the class OracleNoSQLPlatform method buildRow.
/**
* INTERNAL:
* Allow the platform to handle record to row conversion.
*/
@Override
public AbstractRecord buildRow(jakarta.resource.cci.Record record, EISInteraction interaction, EISAccessor accessor) {
if (record == null) {
return null;
}
OracleNoSQLRecord output = (OracleNoSQLRecord) record;
if ((output.size() == 1) && (interaction.getQuery().getDescriptor() != null)) {
// Check for a nested mapped record.
Object value = output.values().iterator().next();
if (value instanceof OracleNoSQLRecord) {
convertRecordBytesToString((OracleNoSQLRecord) value);
output = (OracleNoSQLRecord) value;
}
}
jakarta.resource.cci.Record result = output;
if (getRecordConverter() != null) {
result = getRecordConverter().converterFromAdapterRecord(output);
}
return interaction.buildRow(result, accessor);
}
use of org.eclipse.persistence.internal.nosql.adapters.nosql.OracleNoSQLRecord in project eclipselink by eclipse-ee4j.
the class OracleNoSQLPlatform method createInputRecord.
/**
* Allow the platform to create the appropriate type of record for the interaction.
* Convert the nested local mapped record to a flat global keyed record.
*/
@Override
public jakarta.resource.cci.Record createInputRecord(EISInteraction interaction, EISAccessor accessor) {
if (interaction instanceof XMLInteraction) {
return super.createInputRecord(interaction, accessor);
}
if (interaction instanceof MappedInteraction) {
MappedRecord input = (MappedRecord) interaction.createInputRecord(accessor);
// Create the key from the objects id.
ClassDescriptor descriptor = interaction.getQuery().getDescriptor();
if (descriptor == null) {
if (getRecordConverter() != null) {
return getRecordConverter().converterToAdapterRecord(input);
}
return input;
}
Object key = createMajorKey(descriptor, new EISMappedRecord(input, accessor), interaction, accessor);
OracleNoSQLRecord record = new OracleNoSQLRecord();
record.put(key, input);
if (getRecordConverter() != null) {
return getRecordConverter().converterToAdapterRecord(record);
}
return record;
} else {
return super.createInputRecord(interaction, accessor);
}
}
Aggregations