59 lines
3.6 KiB
Plaintext
Executable File
59 lines
3.6 KiB
Plaintext
Executable File
package com.fp.armas.rules.query.general;
|
|
|
|
import java.util.List;
|
|
|
|
import com.fp.bpm.query.QueryJsf;
|
|
import com.fp.dto.query.QueryRequest;
|
|
import com.fp.dto.rules.QueryRule;
|
|
import com.fp.persistence.commondb.PersistenceHelper;
|
|
import com.fp.persistence.commondb.exception.CommondbException;
|
|
import com.fp.persistence.parmas.soli.TarmArmas;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetailKey;
|
|
|
|
/**
|
|
* Clase que obtiene los datos completos del arma
|
|
* @author dcruz
|
|
*
|
|
*/
|
|
public class ArmasQuery extends QueryRule {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
/**
|
|
* Completa datos del arma
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public QueryRequest process(QueryRequest pRequest) throws Exception {
|
|
QueryJsf query = new QueryJsf();
|
|
query.execute(pRequest);
|
|
List<TarmArmas> armasList = (List<TarmArmas>) pRequest.getResponse().get("ARMAS");
|
|
this.managedResponse(armasList);
|
|
return pRequest;
|
|
}
|
|
|
|
/**
|
|
* Agrega metadata adicional de las armas para mostrar en las consultas
|
|
* @param armasList
|
|
* @throws Exception
|
|
* @throws CommondbException
|
|
*/
|
|
private void managedResponse(List<TarmArmas> armasList) throws CommondbException, Exception{
|
|
for (TarmArmas armas : armasList) {
|
|
//agrego los datos de
|
|
TgeneCatalogDetail clase= TgeneCatalogDetail.find(PersistenceHelper.getEntityManager(), new TgeneCatalogDetailKey(armas.getModifiedData().get("cclase") != null ? armas.getModifiedData().get("cclase").toString() : "", armas.getModifiedData().get("cclasecodigo") != null ? armas.getModifiedData().get("cclasecodigo").toString() : ""));
|
|
armas.modifiedData.put("clase", clase != null ? clase.getDescription():null);
|
|
TgeneCatalogDetail tipoArma= TgeneCatalogDetail.find(PersistenceHelper.getEntityManager(), new TgeneCatalogDetailKey(armas.getModifiedData().get("ctipoarmaexplosivo") != null ? armas.getModifiedData().get("ctipoarmaexplosivo").toString() : "", armas.getModifiedData().get("ctipoarmaexplosivocodigo") != null ? armas.getModifiedData().get("ctipoarmaexplosivocodigo").toString() : ""));
|
|
armas.modifiedData.put("tipoarmaexplosivo", tipoArma != null ? tipoArma.getDescription():null);
|
|
TgeneCatalogDetail unidadMedida= TgeneCatalogDetail.find(PersistenceHelper.getEntityManager(), new TgeneCatalogDetailKey(armas.getModifiedData().get("cunidadmedidapeso") != null ? armas.getModifiedData().get("cunidadmedidapeso").toString():"", armas.getModifiedData().get("cunidadmedidapesocodigo") != null ? armas.getModifiedData().get("cunidadmedidapesocodigo").toString() : ""));
|
|
armas.modifiedData.put("unidadmedidapeso", unidadMedida != null ? unidadMedida.getDescription():null);
|
|
TgeneCatalogDetail calibre= TgeneCatalogDetail.find(PersistenceHelper.getEntityManager(), new TgeneCatalogDetailKey(armas.getModifiedData().get("ccalibre") != null ? armas.getModifiedData().get("ccalibre").toString() : "", armas.getModifiedData().get("ccalibrecodigo") != null ? armas.getModifiedData().get("ccalibrecodigo").toString() : ""));
|
|
armas.modifiedData.put("calibre", calibre != null ? calibre.getDescription() : null);
|
|
TgeneCatalogDetail longitud= TgeneCatalogDetail.find(PersistenceHelper.getEntityManager(), new TgeneCatalogDetailKey(armas.getModifiedData().get("clongitud") != null ? armas.getModifiedData().get("clongitud").toString() : "", armas.getModifiedData().get("clongitudcodigo") != null ? armas.getModifiedData().get("clongitudcodigo").toString() : ""));
|
|
armas.modifiedData.put("longitud", longitud != null ? longitud.getDescription() : null);
|
|
}
|
|
}
|
|
|
|
}
|