List of usage examples for javax.resource.cci RecordFactory createMappedRecord
public MappedRecord createMappedRecord(String recordName) throws ResourceException;
From source file:org.hibersap.execution.jca.JCAMapper.java
public MappedRecord mapFunctionMapValuesToMappedRecord(final String bapiName, final RecordFactory recordFactory, final Map<String, Object> functionMap) throws ResourceException { LOG.info("mapFunctionMapValuesToMappedRecord() functionMap=" + functionMap); MappedRecord mappedInputRecord = recordFactory.createMappedRecord(bapiName); final Map<String, Object> importMap = UnsafeCastHelper.castToMap(functionMap.get(BapiConstants.IMPORT)); mapToMappedRecord(recordFactory, mappedInputRecord, importMap); final Map<String, Object> tableMap = UnsafeCastHelper.castToMap(functionMap.get(BapiConstants.TABLE)); mapToMappedRecord(recordFactory, mappedInputRecord, tableMap); LOG.info("mapFunctionMapValuesToMappedRecord() record=" + mappedInputRecord); return mappedInputRecord; }
From source file:org.hibersap.execution.jca.JCAMapper.java
@SuppressWarnings("unchecked") private void mapToMappedRecord(final RecordFactory recordFactory, final Record record, final Map<String, Object> map) throws ResourceException { for (final String fieldName : map.keySet()) { final Object value = map.get(fieldName); if (Map.class.isAssignableFrom(value.getClass())) { final Map<String, Object> structureMap = UnsafeCastHelper.castToMap(value); final Record structure = recordFactory.createMappedRecord(fieldName); appendToRecord(record, fieldName, structure); mapToMappedRecord(recordFactory, structure, structureMap); } else if (Collection.class.isAssignableFrom(value.getClass())) { final Collection<Map<String, Object>> tableMap = UnsafeCastHelper.castToCollectionOfMaps(value); final IndexedRecord table = recordFactory.createIndexedRecord(fieldName); appendToRecord(record, fieldName, table); int i = 0; for (final Map<String, Object> row : tableMap) { MappedRecord rowRecord = recordFactory.createMappedRecord(fieldName + ":row:" + i); mapToMappedRecord(recordFactory, rowRecord, row); table.add(rowRecord);//from www. j a v a 2 s. c om i++; } } else { appendToRecord(record, fieldName, value); } } }
From source file:org.springframework.jca.cci.core.CciTemplate.java
/** * Create a mapped Record from the ConnectionFactory's RecordFactory. * @param name record name/*w w w .j a va 2 s .c o m*/ * @return the Record * @throws DataAccessException if creation of the Record failed * @see #getRecordFactory(javax.resource.cci.ConnectionFactory) * @see javax.resource.cci.RecordFactory#createMappedRecord(String) */ public MappedRecord createMappedRecord(String name) throws DataAccessException { try { RecordFactory recordFactory = getRecordFactory(obtainConnectionFactory()); return recordFactory.createMappedRecord(name); } catch (NotSupportedException ex) { throw new RecordTypeNotSupportedException("Creation of mapped Record not supported by connector", ex); } catch (ResourceException ex) { throw new CannotCreateRecordException("Creation of mapped Record failed", ex); } }