68 lines
2.2 KiB
Plaintext
Executable File
68 lines
2.2 KiB
Plaintext
Executable File
package com.fp.armas.rules.save.inspeccion;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import com.fp.dto.rules.TransactionRule;
|
|
import com.fp.dto.save.SaveRequest;
|
|
import com.fp.persistence.commondb.PersistenceHelper;
|
|
import com.fp.persistence.parmas.ins.TarmPlanificacionInspeccion;
|
|
import com.fp.persistence.parmas.ins.TarmPlanificacionTramite;
|
|
import com.fp.sessionbeans.helper.Sequence;
|
|
|
|
public class PlanificacionInspeccionSave extends TransactionRule {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Override
|
|
public SaveRequest normalProcess(SaveRequest pSaveRequest) throws Exception {
|
|
try {
|
|
TarmPlanificacionInspeccion planificacion=(TarmPlanificacionInspeccion)pSaveRequest.get("PLANIFICACION");
|
|
|
|
@SuppressWarnings({"unchecked" })
|
|
List<TarmPlanificacionTramite> inspecciones=(ArrayList<TarmPlanificacionTramite>)pSaveRequest.get("INSPECCIONES");
|
|
|
|
//Persistiendo la planificacion
|
|
String cplanificacion = null;
|
|
Sequence sequence = new Sequence();
|
|
Integer valor=Integer.valueOf(sequence.getNextValue("CPLANIFICACION").toString());
|
|
if(valor!=null){
|
|
cplanificacion=valor.toString();
|
|
planificacion.setPk(Long.parseLong(cplanificacion));
|
|
PersistenceHelper.getEntityManager().persist(planificacion);
|
|
}
|
|
|
|
pSaveRequest.getResponse().put("CPLANIFICACION", planificacion.getPk());
|
|
|
|
//Persistieno las inspecciones
|
|
for (TarmPlanificacionTramite inspeccion : inspecciones) {
|
|
inspeccion.setCplanificacion(planificacion.getPk());
|
|
|
|
String cplanificaciontramite = null;
|
|
sequence = new Sequence();
|
|
valor=Integer.valueOf(sequence.getNextValue("CPLANIFICACIONTRAMITE").toString());
|
|
if(valor!=null){
|
|
cplanificaciontramite=valor.toString();
|
|
inspeccion.setPk(Long.parseLong(cplanificaciontramite));
|
|
PersistenceHelper.getEntityManager().persist(inspeccion);
|
|
}
|
|
}
|
|
|
|
PersistenceHelper.getEntityManager().flush();
|
|
|
|
} catch (Exception e) {
|
|
return pSaveRequest;
|
|
}
|
|
return pSaveRequest;
|
|
}
|
|
|
|
@Override
|
|
public SaveRequest reverseProcess(SaveRequest arg0) throws Exception {
|
|
|
|
return arg0;
|
|
}
|
|
|
|
|
|
|
|
}
|