/*Create by Murilo Rosa  10/04/2018*/
var mapper = mapperFactory.createMapperMult(["EstProdCplMediap"]);
var result = 1;
try {

	for (var i = 0; i < message.get('listMediaP').size(); i++) {
		let item = message.get('listMediaP').get(i);
		item.put('dtProc', message.get("dtProc"));
		if (message.get('tipo') == 5){
		    let dadosCabecalhoMediaf = mapper.insert('EstProdCplMediap.incluirEstProdCplDemandaProcMediaF', item)
		    
		} else {
		    let dadosCabecalho = mapper.insert('EstProdCplMediap.incluirEstProdCplDemandaProc', item);
		}
		item.put('cdCtr', item.get("cdCtr"));
		let dadosItem = mapper.insert('EstProdCplMediap.incluirEstProdCplDemandaProcCpl', item);
	
	}
	mapper.commit();
	result;
} catch (err) {
    mapper.rollback();
	if (err.code)
		throw JSON.stringify(err);
	else
		throw err;
}