116 lines
3.0 KiB
Plaintext
Executable File
116 lines
3.0 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.parametros;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.faces.bean.ManagedBean;
|
|
import javax.faces.bean.ViewScoped;
|
|
|
|
import com.fp.dto.Request;
|
|
import com.fp.dto.Response;
|
|
import com.fp.dto.query.DtoQuery;
|
|
import com.fp.frontend.controller.AbstractController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.persistence.parmas.param.TarmTipoArmaExplosivo;
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class ImporteTipoArmaExplosivoController extends
|
|
AbstractController<TarmTipoArmaExplosivo> {
|
|
|
|
|
|
public ImporteTipoArmaExplosivoController() throws Exception {
|
|
super(TarmTipoArmaExplosivo.class);
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
super.startQuery();
|
|
|
|
}
|
|
|
|
/**
|
|
* Incializa el controlador, cuando se esta utilizando una pagina que utliza
|
|
* el controlador.
|
|
*/
|
|
private void init() {
|
|
try {
|
|
recperpage = 15; // Cambiar al # reg a mirar.
|
|
lrecord = new ArrayList<>();
|
|
beanalias = "IMPORTETIPOARMAEXPLOSIVO";
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void create() throws Exception {
|
|
super.create();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
try {
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
dto.setOrderby("t.pk");
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(beanalias, dto); // permite adicionar mas de una tabla.
|
|
Request request = callerhelper.getRequest();
|
|
request.setQueryTables(mtables);
|
|
Response resp = callerhelper.executeQuery(request);
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
lrecord = new ArrayList<TarmTipoArmaExplosivo>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
lrecord = (List<TarmTipoArmaExplosivo>) resp.get(beanalias);
|
|
super.postQuery(lrecord);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public void postCommit(Response response) throws Exception {
|
|
super.postCommitGeneric(response, beanalias);
|
|
}
|
|
|
|
|
|
/**
|
|
* Find para encontrar el pk mediante las caracteristicas.
|
|
*/
|
|
public static TarmTipoArmaExplosivo findpk(String longitud, String calibre,
|
|
String clase, String tipoarmaexplosivo,String unidadmedidapeso) {
|
|
try {
|
|
ImporteTipoArmaExplosivoController cc = new ImporteTipoArmaExplosivoController();
|
|
cc.init();
|
|
cc.recperpage = 300;
|
|
cc.addFilter("longitud", longitud);
|
|
cc.addFilter("calibre", calibre);
|
|
cc.addFilter("clase", clase);
|
|
cc.addFilter("tipoarmaexplosivo", tipoarmaexplosivo);
|
|
cc.addFilter("unidadmedidapeso", unidadmedidapeso);
|
|
cc.querydatabase();
|
|
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord.get(0);
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
}
|