Skip to content

Instantly share code, notes, and snippets.

@gomezgleonardob
Created December 16, 2019 04:14
Show Gist options
  • Save gomezgleonardob/cad4ac8807ff863e4d999c77a4fe250d to your computer and use it in GitHub Desktop.
Save gomezgleonardob/cad4ac8807ff863e4d999c77a4fe250d to your computer and use it in GitHub Desktop.
clase instantaneo
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.engideveloper.instantaneo.servicios;
import com.engideveloper.enumerador.Respuesta;
import com.engideveloper.enumerador.Transaccion;
import com.engideveloper.instantaneo.modelo.CampoInstantaneo;
import com.engideveloper.instantaneo.modelo.Instantaneo;
import com.engideveloper.modelo.Archivo;
import com.engideveloper.servicios.Servicio;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext;
/**
*
* @author USER
*/
public class InstantaneoServicio extends Servicio {
Respuesta respuesta;
private static String entidad = "Instantaneo";
private static String abreviatura = "ins";
private static String urlAdjunto = "archivos/Instantaneo/Adjunto/";
private String[] idtransaccion;
private String ip;
private String idusuario;
private final List<Instantaneo> objeto;
private final List<Object> detailAuditoria;
private final List<Object> detailAuditoriaCampoCrear;
private final List<Object> detailAuditoriaArhivoCrear;
private final List<Object> detailAuditoriaCampoActualizar;
private final ServletContext contexto;
public InstantaneoServicio(List<Instantaneo> objeto, String[] idtransaccion, String ip, String idusuario, ServletContext contexto) {
super(idtransaccion, ip, idusuario);
this.ip = ip;
this.idtransaccion = idtransaccion;
this.idusuario = idusuario;
this.objeto = objeto;
this.detailAuditoria = new ArrayList<>();
this.detailAuditoriaCampoCrear = new ArrayList<>();
this.detailAuditoriaArhivoCrear = new ArrayList<>();
this.detailAuditoriaCampoActualizar = new ArrayList<>();
this.contexto = contexto;
}
public List listar(String where, String limit, String orderBy, ArrayList<Object> parametros) {
if (orderBy == null || orderBy.equals("")) {
orderBy = abreviatura + "id";
}
return (List<Class<?>>) Cargar("campo_instantaneo", limit, where, orderBy, CampoInstantaneo.class, parametros);
}
public Respuesta crear() throws ClassNotFoundException, NoSuchMethodException {
IniciarTransaccion();
for (Instantaneo objDetalle : this.objeto) {
this.Insertar(objDetalle);
//Campo_Instantaneo
if (objDetalle.getCampoinstantaneo() != null && objDetalle.getCampoinstantaneo().size() > 0) {
for (CampoInstantaneo objetoArray : objDetalle.getCampoinstantaneo()) {
objetoArray.getCampoInstantaneoPK().setProid(objDetalle.getProid());
objetoArray.getCampoInstantaneoPK().setInsid(objDetalle.getInsid());
objetoArray.getCampoInstantaneoPK().setCiuid(objDetalle.getCiuid());
this.Insertar(objetoArray);
this.detailAuditoriaCampoCrear.add(objetoArray);
}
}
this.detailAuditoria.add(objDetalle);
}
respuesta = CerrarTransaccion(Transaccion.crear.getTipo());
if (Respuesta.success000.equals(respuesta)) {
for (Instantaneo objDetalle : this.objeto) {
//Archivo
if (objDetalle.getArchivos() != null) {
for (Archivo instantaneoarchivo : objDetalle.getArchivos()) {
instantaneoarchivo.setArcruta(urlAdjunto);
instantaneoarchivo.setArcestado("Activo");
instantaneoarchivo.setArceliminado("No");
this.Insertar(instantaneoarchivo);
this.InsertarQuery("instantaneo_archivo", "insid,arcid", "'" + objDetalle.getInsid() + "','" + instantaneoarchivo.getArcid() + "'");
}
}
}
}
auditoriaServicio(respuesta, Transaccion.crear, entidad, abreviatura, idusuario, Instantaneo.class, detailAuditoria, this.idtransaccion, this.ip);
auditoriaServicio(respuesta, Transaccion.crear, "Instantaneo", "ins", idusuario, CampoInstantaneo.class, detailAuditoriaCampoCrear, this.idtransaccion, this.ip);
return respuesta;
}
public Respuesta actualizar() throws ClassNotFoundException, NoSuchMethodException {
IniciarTransaccion();
for (Instantaneo objDetalle : this.objeto) {
this.Actualizar(objDetalle);
//Campo_Instantaneo
if (objDetalle.getCampoinstantaneo() != null && objDetalle.getCampoinstantaneo().size() > 0) {
for (CampoInstantaneo objetoArray : objDetalle.getCampoinstantaneo()) {
if (objetoArray.getCampoInstantaneoPK().equals(false)) {
objetoArray.getCampoInstantaneoPK().setProid(objDetalle.getProid());
objetoArray.getCampoInstantaneoPK().setInsid(objDetalle.getInsid());
objetoArray.getCampoInstantaneoPK().setCiuid(objDetalle.getCiuid());
this.Insertar(objetoArray);
this.detailAuditoriaCampoCrear.add(objetoArray);
} else {
this.Actualizar(objetoArray);
this.detailAuditoriaCampoActualizar.add(objetoArray);
}
}
}
this.detailAuditoria.add(objDetalle);
}
respuesta = CerrarTransaccion(Transaccion.actualizar.getTipo());
auditoriaServicio(respuesta, Transaccion.actualizar, entidad, abreviatura, idusuario, Instantaneo.class, detailAuditoria, this.idtransaccion, this.ip);
auditoriaServicio(respuesta, Transaccion.crear, "CampoInstantaneo", "cam", idusuario, CampoInstantaneo.class, detailAuditoriaCampoCrear, this.idtransaccion, this.ip);
return respuesta;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment