Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2008-2014 akquinet tech@spree GmbH
*
* This file is part of Hibersap.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibersap.execution.jca;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibersap.bapi.BapiConstants;
import org.hibersap.execution.UnsafeCastHelper;
import javax.resource.ResourceException;
import javax.resource.cci.IndexedRecord;
import javax.resource.cci.MappedRecord;
import javax.resource.cci.Record;
import javax.resource.cci.RecordFactory;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
* @author M. Dahm
*/
public class JCAMapper {
private static final Log LOG = LogFactory.getLog( JCAMapper.class );
public MappedRecord mapFunctionMapValuesToMappedRecord( final String bapiName, final RecordFactory recordFactory, final Map functionMap )
throws ResourceException {
LOG.info( "mapFunctionMapValuesToMappedRecord() functionMap=" + functionMap );
MappedRecord mappedInputRecord = recordFactory.createMappedRecord( bapiName );
final Map importMap = UnsafeCastHelper.castToMap( functionMap.get( BapiConstants.IMPORT ) );
mapToMappedRecord( recordFactory, mappedInputRecord, importMap );
final Map tableMap = UnsafeCastHelper.castToMap( functionMap.get( BapiConstants.TABLE ) );
mapToMappedRecord( recordFactory, mappedInputRecord, tableMap );
LOG.info( "mapFunctionMapValuesToMappedRecord() record=" + mappedInputRecord );
return mappedInputRecord;
}
public void mapRecordToFunctionMap( final Map functionMap, final Map resultRecordMap ) {
LOG.info( "mapRecordToFunctionMap() recordMap=" + resultRecordMap );
for ( final Entry 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 resultMap = new HashMap();
resultMap.put( mappedResultRecord.getRecordName(), mappedResultRecord );
Map export = UnsafeCastHelper.castToMap( functionMap.get( BapiConstants.EXPORT ) );
export.put( recordKey, recordValue );
} else if ( recordValue instanceof IndexedRecord ) {
final IndexedRecord indexedResultRecord = (IndexedRecord) recordValue;
List