Example usage for javax.resource.cci MappedRecord get

List of usage examples for javax.resource.cci MappedRecord get

Introduction

In this page you can find the example usage for javax.resource.cci MappedRecord get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

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));
                }//  w w w.java 2  s  .  com
                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);
}