From 591ab129fda22125263e32e34b8a702e3c590ea1 Mon Sep 17 00:00:00 2001 From: "marco.spasiano" Date: Tue, 9 Jan 2024 17:41:54 +0100 Subject: [PATCH] Piano di gestione preliminare aggiunta il filtro con la ricerca guidata sui progetti. --- .../cnr/contab/config00/sto/bulk/CdrHome.java | 36 ++++++++++-- .../action/CRUDPdGAggregatoModuloAction.java | 15 ++++- .../bp/CRUDPdGAggregatoModuloBP.java | 55 +++++++++++++++++-- .../prevent01/bulk/Pdg_moduloBulkInfo.xml | 16 ++++++ .../bulk/Pdg_moduloBulkPersistentInfo.xml | 17 ++++++ .../webapp/prevent01/pdg_aggregato_modulo.jsp | 4 +- 6 files changed, 130 insertions(+), 13 deletions(-) diff --git a/sigla-ejb/src/main/java/it/cnr/contab/config00/sto/bulk/CdrHome.java b/sigla-ejb/src/main/java/it/cnr/contab/config00/sto/bulk/CdrHome.java index fb2d525da6..9e116bd662 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/config00/sto/bulk/CdrHome.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/config00/sto/bulk/CdrHome.java @@ -17,8 +17,11 @@ package it.cnr.contab.config00.sto.bulk; +import it.cnr.contab.config00.bulk.Parametri_cnrBulk; +import it.cnr.contab.config00.bulk.Parametri_cnrHome; import it.cnr.contab.prevent01.bulk.Pdg_esercizioBulk; import it.cnr.contab.prevent01.bulk.Pdg_moduloBulk; +import it.cnr.contab.progettiric00.core.bulk.ProgettoBulk; import it.cnr.contab.progettiric00.core.bulk.Progetto_sipBulk; import it.cnr.contab.progettiric00.core.bulk.Progetto_sipHome; import it.cnr.contab.utenze00.bp.CNRUserContext; @@ -26,10 +29,7 @@ import it.cnr.jada.bulk.BulkHome; import it.cnr.jada.comp.ApplicationException; import it.cnr.jada.persistency.*; -import it.cnr.jada.persistency.sql.FindClause; -import it.cnr.jada.persistency.sql.LoggableStatement; -import it.cnr.jada.persistency.sql.PersistentHome; -import it.cnr.jada.persistency.sql.SQLBuilder; +import it.cnr.jada.persistency.sql.*; import java.sql.ResultSet; import java.sql.SQLException; @@ -474,7 +474,35 @@ public boolean verificaEsercizioPreventivo(CdrBulk cdr) throws PersistencyExcept throw new PersistencyException(e); } } + public java.util.List findPdgModuloDettagli(UserContext userContext, CdrBulk testata, CompoundFindClause compoundfindclause) throws IntrospectionException, PersistencyException { + Parametri_cnrHome parCnrhome = (Parametri_cnrHome)getHomeCache().getHome(Parametri_cnrBulk.class); + Parametri_cnrBulk parCnrBulk = (Parametri_cnrBulk)parCnrhome.findByPrimaryKey(new Parametri_cnrBulk(it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ))); + PersistentHome dettHome = getHomeCache().getHome(Pdg_moduloBulk.class); + SQLBuilder sql = dettHome.createSQLBuilder(); + if (Optional.ofNullable(compoundfindclause).isPresent()) { + dettHome = getHomeCache().getHome(Pdg_moduloBulk.class, "CODICE_PROGETTO"); + sql = dettHome.createSQLBuilder(); + sql.generateJoin("progetto", "PROGETTO"); + sql.generateJoin(ProgettoBulk.class, Progetto_sipBulk.class, "progettopadre", "PROGETTOPADRE"); + + sql.addSQLClause(FindClause.AND, "PROGETTO.ESERCIZIO", SQLBuilder.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + sql.addSQLClause(FindClause.AND, "PROGETTO.TIPO_FASE", SQLBuilder.EQUALS, "P"); + sql.addClause(compoundfindclause); + }; + + sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + sql.addClause("AND", "cd_centro_responsabilita", SQLBuilder.EQUALS, testata.getCd_centro_responsabilita()); + + Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHomeCache().getHome(Unita_organizzativa_enteBulk.class).findAll().get(0); + if (!((CNRUserContext) userContext).getCd_unita_organizzativa().equals(ente.getCd_unita_organizzativa())) { + Progetto_sipHome progettohome = (Progetto_sipHome) getHomeCache().getHome(Progetto_sipBulk.class); + sql.addSQLExistsClause("AND", progettohome.abilitazioni(userContext, "PDG_MODULO.PG_PROGETTO", parCnrBulk.getLivelloProgetto())); + } + final List result = dettHome.fetchAll(sql); + getHomeCache().fetchAll(userContext); + return result; + } public java.util.Collection findPdgModuloDettagli(UserContext userContext, CdrBulk testata, Integer livelloProgetto) throws IntrospectionException, PersistencyException { PersistentHome dettHome = getHomeCache().getHome(Pdg_moduloBulk.class); SQLBuilder sql = dettHome.createSQLBuilder(); diff --git a/sigla-ejb/src/main/java/it/cnr/contab/prevent01/action/CRUDPdGAggregatoModuloAction.java b/sigla-ejb/src/main/java/it/cnr/contab/prevent01/action/CRUDPdGAggregatoModuloAction.java index a71ed45e2e..cf34667dd9 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/prevent01/action/CRUDPdGAggregatoModuloAction.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/prevent01/action/CRUDPdGAggregatoModuloAction.java @@ -227,8 +227,19 @@ public Forward doConfermaCompletaProgetto(ActionContext context, int opt) throws return context.findDefaultForward(); } - public Forward doFilterCRUDMain_Dettagli(ActionContext context) { - return context.findDefaultForward(); + public it.cnr.jada.action.Forward doFilterCRUDMain_Dettagli(it.cnr.jada.action.ActionContext context) throws it.cnr.jada.action.BusinessProcessException { + try { + CRUDPdGAggregatoModuloBP _tmp = (CRUDPdGAggregatoModuloBP) context.getBusinessProcess(); + RicercaLiberaBP ricercaliberabp = (RicercaLiberaBP) context.createBusinessProcess("RicercaLibera"); + ricercaliberabp.setFreeSearchSet("prg_liv2"); + ricercaliberabp.setPrototype(new Pdg_moduloBulk()); + context.addHookForward("filter", this, "doBringBackFilter"); + HookForward hookforward = (HookForward) context.findForward("filter"); + hookforward.addParameter("controller", _tmp.getCrudDettagli()); + return context.addBusinessProcess(ricercaliberabp); + } catch (Exception exception) { + return handleException(context, exception); + } } public it.cnr.jada.action.Forward doCambiaStato(it.cnr.jada.action.ActionContext context) throws it.cnr.jada.action.BusinessProcessException { diff --git a/sigla-ejb/src/main/java/it/cnr/contab/prevent01/bp/CRUDPdGAggregatoModuloBP.java b/sigla-ejb/src/main/java/it/cnr/contab/prevent01/bp/CRUDPdGAggregatoModuloBP.java index 5896d9ef5b..64a835d94d 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/prevent01/bp/CRUDPdGAggregatoModuloBP.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/prevent01/bp/CRUDPdGAggregatoModuloBP.java @@ -23,12 +23,16 @@ */ package it.cnr.contab.prevent01.bp; +import java.io.IOException; import java.math.BigDecimal; import java.rmi.RemoteException; import java.util.Iterator; +import java.util.List; import java.util.Optional; import javax.ejb.RemoveException; +import javax.servlet.ServletException; +import javax.servlet.jsp.PageContext; import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; import it.cnr.contab.config00.bulk.Parametri_cnrBulk; @@ -44,13 +48,17 @@ import it.cnr.contab.progettiric00.core.bulk.Progetto_sipBulk; import it.cnr.contab.progettiric00.core.bulk.TipoFinanziamentoBulk; import it.cnr.contab.progettiric00.ejb.ProgettoRicercaPadreComponentSession; +import it.cnr.contab.utente00.ejb.RuoloComponentSession; import it.cnr.contab.utenze00.bp.CNRUserContext; +import it.cnr.contab.utenze00.bp.CRUDRuoloBP; import it.cnr.contab.utenze00.bulk.CNRUserInfo; +import it.cnr.contab.utenze00.bulk.RuoloBulk; import it.cnr.contab.utenze00.bulk.UtenteBulk; import it.cnr.contab.util.Utility; import it.cnr.jada.UserContext; import it.cnr.jada.action.ActionContext; import it.cnr.jada.action.BusinessProcessException; +import it.cnr.jada.action.HttpActionContext; import it.cnr.jada.bulk.BulkList; import it.cnr.jada.bulk.OggettoBulk; import it.cnr.jada.bulk.UserInfo; @@ -66,6 +74,7 @@ import it.cnr.jada.util.action.SimpleDetailCRUDController; import it.cnr.jada.util.ejb.EJBCommonServices; import it.cnr.jada.util.jsp.Button; +import it.cnr.jada.util.jsp.TableCustomizer; /** * @author mincarnato @@ -83,17 +92,43 @@ public class CRUDPdGAggregatoModuloBP extends it.cnr.jada.util.action.SimpleCRUD private boolean isUtenteDirettore; private Progetto_sipBulk progettoForUpdate; private Integer annoFromPianoEconomico; - + private SimpleDetailCRUDController crudDettagli = new SimpleDetailCRUDController( "Dettagli", Pdg_moduloBulk.class, "dettagli", this, false) { + private CompoundFindClause compoundFindClausePdgModulo = null; + + public void setFilter(ActionContext actioncontext, CompoundFindClause compoundfindclause) + { + compoundFindClausePdgModulo = compoundfindclause; + CRUDPdGAggregatoModuloBP bp = (CRUDPdGAggregatoModuloBP) actioncontext.getBusinessProcess(); + CdrBulk cdrBulk = (CdrBulk) bp.getModel(); + try { + cdrBulk.setDettagli(new BulkList(createComponentSession().find( + actioncontext.getUserContext(), + CdrBulk.class, + "findPdgModuloDettagli", + actioncontext.getUserContext(), + cdrBulk, + compoundfindclause))); + bp.setModel(actioncontext, cdrBulk); + } catch (BusinessProcessException e) { + handleException(e); + } catch (ComponentException e) { + handleException(e); + } catch (RemoteException e) { + handleException(e); + } + super.setFilter(actioncontext, compoundfindclause); + } + + @Override + public boolean isFiltered() { + return Optional.ofNullable(compoundFindClausePdgModulo).isPresent(); + } public void validateForDelete(ActionContext context, OggettoBulk detail) throws ValidationException { validaCancellazionePdgModulo(context, (Pdg_moduloBulk)detail); } - public boolean isFiltered() - { - return false; - } public boolean isReadonly() { return super.isReadonly() && !isUtenteAbilitato() && !isCdrPdGPUtilizzabile(); @@ -106,6 +141,16 @@ public boolean isShrinkable() { return super.isShrinkable() && isUtenteAbilitato() && isCdrPdGPUtilizzabile(); } + + @Override + public void writeHTMLTable(PageContext pagecontext, String s, boolean flag, boolean flag1, boolean flag2, String s1, String s2, boolean flag3, TableCustomizer tablecustomizer, List list) throws ServletException, IOException { + super.writeHTMLTable(pagecontext, s, flag, flag1, flag2, s1, s2, flag3, tablecustomizer, list); + if (HttpActionContext.isFromBootstrap(pagecontext)) { + pagecontext.getOut().print(""); + } + } }; public CRUDPdGAggregatoModuloBP() { diff --git a/sigla-ejb/src/main/resources/it/cnr/contab/prevent01/bulk/Pdg_moduloBulkInfo.xml b/sigla-ejb/src/main/resources/it/cnr/contab/prevent01/bulk/Pdg_moduloBulkInfo.xml index 3a4da9bfc6..25c6a766fa 100644 --- a/sigla-ejb/src/main/resources/it/cnr/contab/prevent01/bulk/Pdg_moduloBulkInfo.xml +++ b/sigla-ejb/src/main/resources/it/cnr/contab/prevent01/bulk/Pdg_moduloBulkInfo.xml @@ -453,6 +453,22 @@ enabledOnSearch="false" /> + + + + + + + + + + diff --git a/sigla-web/src/main/webapp/prevent01/pdg_aggregato_modulo.jsp b/sigla-web/src/main/webapp/prevent01/pdg_aggregato_modulo.jsp index 6ae4512de6..81d7e42bd4 100644 --- a/sigla-web/src/main/webapp/prevent01/pdg_aggregato_modulo.jsp +++ b/sigla-web/src/main/webapp/prevent01/pdg_aggregato_modulo.jsp @@ -44,9 +44,9 @@
<% if (bp.getParametriCnr().getFl_nuovo_pdg()) - controller.writeHTMLTable(pageContext,"prg_liv2",true,false,true,"100%","auto;max-height:50vh"); + controller.writeHTMLTable(pageContext,"prg_liv2",true,true,true,"100%","auto;max-height:50vh"); else - controller.writeHTMLTable(pageContext,null,true,false,true,"100%","auto;max-height:50vh"); + controller.writeHTMLTable(pageContext,null,true,true,true,"100%","auto;max-height:50vh"); %>