javax.resource.cci.IndexedRecord Java Examples
The following examples show how to use
javax.resource.cci.IndexedRecord.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HelloWorldRecordFactoryImpl.java From ci.maven with Apache License 2.0 | 6 votes |
/** * @see RecordFactory#createIndexedRecord(String) */ public IndexedRecord createIndexedRecord(String recordName) throws ResourceException { HelloWorldIndexedRecordImpl record = null; if ((recordName.equals(HelloWorldIndexedRecordImpl.INPUT)) || (recordName.equals(HelloWorldIndexedRecordImpl.OUTPUT))) { record = new HelloWorldIndexedRecordImpl(); record.setRecordName(recordName); } if (record == null) { throw new ResourceException(INVALID_RECORD_NAME); } else { return record; } }
Example #2
Source File: CciTemplateTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testCreateIndexedRecord() throws ResourceException { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); RecordFactory recordFactory = mock(RecordFactory.class); IndexedRecord indexedRecord = mock(IndexedRecord.class); given(connectionFactory.getRecordFactory()).willReturn(recordFactory); given(recordFactory.createIndexedRecord("name")).willReturn(indexedRecord); CciTemplate ct = new CciTemplate(connectionFactory); ct.createIndexedRecord("name"); verify(recordFactory).createIndexedRecord("name"); }
Example #3
Source File: CciTemplateTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testCreateIndexedRecord() throws ResourceException { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); RecordFactory recordFactory = mock(RecordFactory.class); IndexedRecord indexedRecord = mock(IndexedRecord.class); given(connectionFactory.getRecordFactory()).willReturn(recordFactory); given(recordFactory.createIndexedRecord("name")).willReturn(indexedRecord); CciTemplate ct = new CciTemplate(connectionFactory); ct.createIndexedRecord("name"); verify(recordFactory).createIndexedRecord("name"); }
Example #4
Source File: CciTemplateTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testCreateIndexedRecord() throws ResourceException { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); RecordFactory recordFactory = mock(RecordFactory.class); IndexedRecord indexedRecord = mock(IndexedRecord.class); given(connectionFactory.getRecordFactory()).willReturn(recordFactory); given(recordFactory.createIndexedRecord("name")).willReturn(indexedRecord); CciTemplate ct = new CciTemplate(connectionFactory); ct.createIndexedRecord("name"); verify(recordFactory).createIndexedRecord("name"); }
Example #5
Source File: JCAMapper.java From hibersap with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void appendToRecord(final Record record, final String fieldName, final Object value) { if (record instanceof IndexedRecord) { ((IndexedRecord) record).add(value); } else { ((MappedRecord) record).put(fieldName, value); } }
Example #6
Source File: JCAMapper.java From hibersap with Apache License 2.0 | 5 votes |
@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); i++; } } else { appendToRecord(record, fieldName, value); } } }
Example #7
Source File: JCAMapperTest.java From hibersap with Apache License 2.0 | 5 votes |
@Test public void mapToMappedRecord() throws Exception { // map Map<String, Object> functionMap = createFunctionMap(); MappedRecord record = mapper.mapFunctionMapValuesToMappedRecord("BAPI_NAME", recordFactory, functionMap); assertEquals("BAPI_NAME", record.getRecordName()); // check import parameters String importParam1 = (String) record.get("IMPORT_PARAM2"); assertEquals("importParam2", importParam1); int param3 = (Integer) record.get("IMPORT_PARAM3"); assertEquals(3, param3); MappedRecord importStruct = (MappedRecord) record.get("IMPORT_PARAM1"); assertEquals("IMPORT_PARAM1", importStruct.getRecordName()); assertEquals(1, importStruct.get("STRUCT_FIELD1")); assertEquals("structField2", importStruct.get("STRUCT_FIELD2")); // check changing parameters assertThat(record.get("CHANGING_PARAM1")).isEqualTo("changingParam1"); assertThat(record.get("CHANGING_PARAM2")).isEqualTo(2); // check table parameters IndexedRecord tableParam1 = (IndexedRecord) record.get("TABLE_PARAM1"); assertEquals("TABLE_PARAM1", tableParam1.getRecordName()); MappedRecord row1 = (MappedRecord) tableParam1.get(0); assertEquals("tableField1", row1.get("TABLE_FIELD1")); assertEquals(new Date(1), row1.get("TABLE_FIELD2")); assertEquals(1, row1.get("TABLE_FIELD3")); MappedRecord row2 = (MappedRecord) tableParam1.get(1); assertEquals("tableField2", row2.get("TABLE_FIELD1")); assertEquals(new Date(2), row2.get("TABLE_FIELD2")); assertEquals(2, row2.get("TABLE_FIELD3")); }
Example #8
Source File: NotSupportedRecordFactory.java From spring-analysis-note with MIT License | 4 votes |
@Override public IndexedRecord createIndexedRecord(String name) throws ResourceException { throw new NotSupportedException("The RecordFactory facility is not supported by the connector"); }
Example #9
Source File: NotSupportedRecordFactory.java From java-technology-stack with MIT License | 4 votes |
@Override public IndexedRecord createIndexedRecord(String name) throws ResourceException { throw new NotSupportedException("The RecordFactory facility is not supported by the connector"); }
Example #10
Source File: NotSupportedRecordFactory.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public IndexedRecord createIndexedRecord(String name) throws ResourceException { throw new NotSupportedException("The RecordFactory facility is not supported by the connector"); }
Example #11
Source File: NotSupportedRecordFactory.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public IndexedRecord createIndexedRecord(String name) throws ResourceException { throw new NotSupportedException("The RecordFactory facility is not supported by the connector"); }
Example #12
Source File: JCAMapper.java From hibersap with Apache License 2.0 | 4 votes |
public void mapRecordToFunctionMap(final Map<String, Object> functionMap, final Map<String, Object> resultRecordMap, final BapiMapping bapiMapping) { LOG.debug("mapRecordToFunctionMap() recordMap=" + resultRecordMap); for (final Entry<String, Object> entry : resultRecordMap.entrySet()) { final Object recordValue = entry.getValue(); final String recordKey = entry.getKey(); if (recordValue != null) { LOG.debug("mapping " + recordValue.getClass().getName() + ": " + recordKey + "=" + recordValue); } if (recordValue instanceof IndexedRecord) { // Table parameter final IndexedRecord indexedResultRecord = (IndexedRecord) recordValue; List<Map<String, Object>> table = new ArrayList<>(); for (Object object : indexedResultRecord) { MappedRecord mr = (MappedRecord) object; final Map<String, Object> line = new HashMap<>(); @SuppressWarnings("unchecked") Set<String> keys = mr.keySet(); for (String key : keys) { line.put(key, mr.get(key)); } table.add(line); } Map<String, Object> tables = UnsafeCastHelper.castToMap(functionMap.get(TABLE)); tables.put(indexedResultRecord.getRecordName(), table); } else { // Simple parameter or structure parameter (the latter is a MappedRecord which luckily implements Map) String parameterType = getParameterType(recordKey, bapiMapping); if (isNotBlank(parameterType)) { Map<String, Object> export = UnsafeCastHelper.castToMap(functionMap.get(parameterType)); export.put(recordKey, recordValue); } else { LOG.debug("Skipping unmapped parameter: " + recordKey); } } } LOG.debug("mapRecordToFunctionMap() functionMap=" + functionMap); }
Example #13
Source File: JCAMapperTest.java From hibersap with Apache License 2.0 | 4 votes |
@Override public IndexedRecord answer(InvocationOnMock invocation) { String name = invocation.getArgument(0); return new MyIndexedRecord(name); }