Example usage for javax.resource.cci IndexedRecord getRecordName

List of usage examples for javax.resource.cci IndexedRecord getRecordName

Introduction

In this page you can find the example usage for javax.resource.cci IndexedRecord getRecordName.

Prototype

public String getRecordName();

Source Link

Document

Gets the name of the Record.

Usage

From source file:org.hibersap.execution.jca.JCAMapper.java

public void mapRecordToFunctionMap(final Map<String, Object> functionMap,
        final Map<String, Object> resultRecordMap) {
    LOG.info("mapRecordToFunctionMap() recordMap=" + resultRecordMap);

    for (final Entry<String, Object> entry : resultRecordMap.entrySet()) {
        final Object recordValue = entry.getValue();
        final String recordKey = entry.getKey();

        LOG.debug("mapping " + recordValue.getClass().getName() + ": " + recordKey + "=" + recordValue);

        if (recordValue instanceof MappedRecord) {
            final MappedRecord mappedResultRecord = (MappedRecord) recordValue;
            final Map<String, Object> resultMap = new HashMap<String, Object>();
            resultMap.put(mappedResultRecord.getRecordName(), mappedResultRecord);
            Map<String, Object> export = UnsafeCastHelper.castToMap(functionMap.get(BapiConstants.EXPORT));
            export.put(recordKey, recordValue);
        } else if (recordValue instanceof IndexedRecord) {
            final IndexedRecord indexedResultRecord = (IndexedRecord) recordValue;
            List<Map<String, Object>> table = new ArrayList<Map<String, Object>>();

            for (Object object : indexedResultRecord) {
                MappedRecord mr = (MappedRecord) object;
                final Map<String, Object> line = new HashMap<String, Object>();

                @SuppressWarnings("unchecked")
                Set<String> keys = mr.keySet();

                for (String key : keys) {
                    line.put(key, mr.get(key));
                }/*ww  w. j av a 2  s. c om*/
                table.add(line);
            }

            Map<String, Object> tables = UnsafeCastHelper.castToMap(functionMap.get(BapiConstants.TABLE));
            tables.put(indexedResultRecord.getRecordName(), table);
        } else {
            Map<String, Object> export = UnsafeCastHelper.castToMap(functionMap.get(BapiConstants.EXPORT));
            export.put(recordKey, recordValue);
        }
    }
    LOG.info("mapRecordToFunctionMap() functionMap=" + functionMap);
}