From dbc0e6de2753cab730561ca71bc9896000a2c7c7 Mon Sep 17 00:00:00 2001 From: "raffaele.pagano" Date: Thu, 5 Dec 2019 11:32:27 +0100 Subject: [PATCH] Configurazione CNR: gestita, per determinate configurazioni, la contemporanea presenza in tabella sia di record con esercizio 0 che di record con esercizio valido. Gestione aggiornata per variabili: CDR_PERSONALE,CDR_SERVIZIO_ENTE,UO_ACCREDITAMENTO_SAC,UO_DISTINTA_TUTTA_SAC,UO_RAGIONERIA,UO_VERSAMENTO_CORI,UO_VERSAMENTO_CORI_CONTO_BI,UO_VERSAMENTO_CORI_TUTTA_SAC,UO_VERSAMENTO_IVA --- .../expsigladb/Package/CNRCTB020.sql | 10 +- .../expsigladb/Package/CNRCTB020_BODY.sql | 128 +- .../expsigladb/Package/CNRCTB053_BODY.sql | 4 +- .../expsigladb/Package/CNRCTB060_BODY.sql | 6 +- .../expsigladb/Package/CNRCTB061_BODY.sql | 8 +- .../expsigladb/Package/CNRCTB680_BODY.sql | 4 +- .../expsigladb/Procedure/spg_mandato.prc | 2 +- .../View/V_CONS_PDGG_SPE_BIL_IST_DIP_FN.sql | 28 +- .../View/V_CONS_PDGG_SPE_BIL_IST_DIP_FO.sql | 56 +- .../View/V_CONS_PDG_SPE_BIL_IST_DIP_FO.sql | 28 +- .../View/V_CONS_PDG_SPE_PRELIMINARE.sql | 28 +- .../View/V_CONS_PDG_SPE_PRELIMINARE_V.sql | 32 +- .../expsigladb/View/V_PDG_PDG_SAUOP.sql | 72 +- .../config00/bulk/Configurazione_cnrBulk.java | 3 +- .../config00/bulk/Configurazione_cnrHome.java | 160 +- .../comp/Configurazione_cnrComponent.java | 1214 +- .../Configurazione_cnrComponentSession.java | 129 +- ...onfigurazione_cnrComponentSessionBean.java | 924 +- ...nalConfigurazione_cnrComponentSession.java | 820 +- .../doccont00/bp/CRUDDistintaCassiereBP.java | 4824 +++--- .../comp/DistintaCassiereComponent.java | 10 +- .../doccont00/comp/MandatoComponent.java | 13093 ++++++++-------- .../doccont00/comp/ReversaleComponent.java | 7780 +++++---- .../contab/doccont00/comp/SaldoComponent.java | 31 +- .../bulk/V_cons_stato_invio_mandatiHome.java | 254 +- .../V_cons_stato_invio_reversaliHome.java | 252 +- .../doccont00/core/bulk/ObbligazioneHome.java | 3561 +++-- .../intcass/bulk/V_mandato_reversaleBulk.java | 681 +- .../cnr/contab/pdg00/bp/PdGVariazioneBP.java | 6 +- .../comp/CRUDCostoDelDipendenteComponent.java | 653 +- .../pdg00/comp/PdGPreventivoComponent.java | 9710 ++++++------ .../pdg00/comp/PdGVariazioniComponent.java | 31 +- .../CRUDPdgVariazioneGestionaleComponent.java | 3 +- .../CRUDPdgVariazioneRigaGestComponent.java | 35 +- .../bulk/VConsVarCompResHome.java | 12 +- .../varstanz00/bp/CRUDVar_stanz_resBP.java | 7 +- ...ariazioniStanziamentoResiduoComponent.java | 37 +- .../web/rest/resource/util/ToDoResource.java | 6 +- 38 files changed, 22444 insertions(+), 22198 deletions(-) diff --git a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB020.sql b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB020.sql index b19827978b..8a5165b3f8 100644 --- a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB020.sql +++ b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB020.sql @@ -200,11 +200,11 @@ TIPO_ENTE CONSTANT VARCHAR2(10) := 'ENTE'; -- Estrae l'UO del personale leggendola da configurazione CNR - function getUOPersonale return unita_organizzativa%rowtype; + function getUOPersonale(aEs number) return unita_organizzativa%rowtype; -- Estrae il CDR del personale leggendolo da configurazione CNR - function getCDRPersonale return cdr%rowtype; + function getCDRPersonale(aEs number) return cdr%rowtype; -- Estrae il cdr responsabile dell'UO @@ -255,4 +255,10 @@ Function GETDESDIPARTIMENTO (aCd_dip VARCHAR2) return VARCHAR2; function isUOSAC(aUO varchar2) return boolean; function getCdCdrEnte return cdr.cd_centro_responsabilita%type; + + function getCdCDRPersonale(aEs number) return cdr.cd_centro_responsabilita%type; + function getCdUOVersCori(aEs number) return unita_organizzativa.cd_unita_organizzativa%Type; + function getCdUOVersCoriTuttaSAC(aEs number) return unita_organizzativa.cd_unita_organizzativa%Type; + function getCdUOVersCoriContoBI(aEs number) return unita_organizzativa.cd_unita_organizzativa%Type; + function getCdUOVersIVA(aEs number) return unita_organizzativa.cd_unita_organizzativa%Type; end; \ No newline at end of file diff --git a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB020_BODY.sql b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB020_BODY.sql index 4263ea4630..948af06e98 100644 --- a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB020_BODY.sql +++ b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB020_BODY.sql @@ -2,7 +2,7 @@ -- DDL for Package Body CNRCTB020 -------------------------------------------------------- - CREATE OR REPLACE PACKAGE BODY "CNRCTB020" is +CREATE OR REPLACE PACKAGE BODY "CNRCTB020" is function getCDCDSENTE(aEs number) return unita_organizzativa.CD_unita_organizzativa%Type Is @@ -352,7 +352,7 @@ end; begin -- estraggo l'UO di servizio versamento cori (tipo SAC) select * into aUOCDS from unita_organizzativa a where - a.cd_unita_organizzativa = CNRCTB015.GETVAL01PERCHIAVE('UO_SPECIALE','UO_VERSAMENTO_CORI') + a.cd_unita_organizzativa = getCdUOVersCori(aEs) and cd_tipo_unita = TIPO_SAC and exists (select 1 from v_unita_organizzativa_valida where esercizio = aEs @@ -369,7 +369,7 @@ end; begin -- estraggo l'UO di servizio versamento cori unificato per tutta la SAC(tipo SAC) select * into aUOCDS from unita_organizzativa a where - a.cd_unita_organizzativa = CNRCTB015.GETVAL01PERCHIAVE('UO_SPECIALE','UO_VERSAMENTO_CORI_TUTTA_SAC') + a.cd_unita_organizzativa = getCdUOVersCoriTuttaSAC(aEs) and cd_tipo_unita = TIPO_SAC and exists (select 1 from v_unita_organizzativa_valida where esercizio = aEs @@ -386,7 +386,7 @@ end; begin -- estraggo l'UO di servizio versamento cori su Conto Banca d'Ialia select * into aUOCDS from unita_organizzativa a where - a.cd_unita_organizzativa = CNRCTB015.GETVAL01PERCHIAVE('UO_SPECIALE','UO_VERSAMENTO_CORI_CONTO_BI') + a.cd_unita_organizzativa = getCdUOVersCoriContoBI(aEs) and exists (select 1 from v_unita_organizzativa_valida where esercizio = aEs and cd_unita_organizzativa = a.cd_unita_organizzativa); @@ -402,7 +402,7 @@ end; begin -- estraggo l'UO di servizio versamneto IVA (deve essere di tipo SAC) select * into aUOCDS from unita_organizzativa a where - a.cd_unita_organizzativa = CNRCTB015.GETVAL01PERCHIAVE('UO_SPECIALE','UO_VERSAMENTO_IVA') + a.cd_unita_organizzativa = getCdUOVersIVA(aEs) and cd_tipo_unita = TIPO_SAC and exists (select 1 from v_unita_organizzativa_valida where esercizio = aEs @@ -432,12 +432,12 @@ end; return false; end; - function getUOPersonale return unita_organizzativa%rowtype is + function getUOPersonale(aEs number) return unita_organizzativa%rowtype is aUO unita_organizzativa%rowtype; aCDR cdr%rowtype; aCdUo varchar2(30); begin - aCDR:=getCDRPersonale; + aCDR:=getCDRPersonale(aEs); aCdUO:=aCDR.cd_unita_organizzativa; if aCdUo is null then return null; @@ -448,20 +448,20 @@ end; return aUO; end; - function getCDRPersonale return cdr%rowtype is + function getCDRPersonale(aEs number) return cdr%rowtype is + aCdCDR cdr.cd_centro_responsabilita%Type; aCDR cdr%rowtype; - aCdCDR varchar2(30); begin - aCdCDR:=CNRCTB015.GETVAL01PERCHIAVE(0,'CDR_SPECIALE','CDR_PERSONALE'); - if aCdCDR is null then - return null; - end if; - - select * into aCDR from cdr where - cd_centro_responsabilita = aCdCDR; - return aCDR; - end; + aCdCDR := getCdCDRPersonale(aEs); + if aCdCDR is null then + return null; + end if; + select * into aCDR + from cdr + where cd_centro_responsabilita = aCdCDR; + return aCDR; + End; function getCDRResponsabileUO(aUO unita_organizzativa%rowtype) return cdr%rowtype is aCdr cdr%rowtype; @@ -727,4 +727,94 @@ Procedure ins_CDR (aDest CDR%rowtype) is return false; end if; end; -end; + function getCdCDRPersonale(aEs number) return cdr.cd_centro_responsabilita%Type Is + aCdCDR varchar2(30); + noData EXCEPTION; + pragma exception_init(noData,-20020); + begin + Begin + aCdCDR:=CNRCTB015.GETVAL01PERCHIAVE(aEs,'CDR_SPECIALE','CDR_PERSONALE'); + Exception + When noData Then + if aEs=0 Then + IBMERR001.RAISE_ERR_GENERICO('Chiave non trovata in tabella di configurazione cnr: CDR_SPECIALE-CDR_PERSONALE'); + end if; + End; + if aCdCDR is null AND aEs!=0 then + aCdCDR:=CNRCTB015.GETVAL01PERCHIAVE(0,'CDR_SPECIALE','CDR_PERSONALE'); + end if; + return aCdCDR; + end; + function getCdUOVersCori(aEs number) return unita_organizzativa.cd_unita_organizzativa%Type Is + aCdUO varchar2(30); + noData EXCEPTION; + pragma exception_init(noData,-20020); + begin + Begin + aCdUO:=CNRCTB015.GETVAL01PERCHIAVE(aEs,'UO_SPECIALE','UO_VERSAMENTO_CORI'); + Exception + When noData Then + if aEs=0 Then + IBMERR001.RAISE_ERR_GENERICO('Chiave non trovata in tabella di configurazione cnr: UO_SPECIALE-UO_VERSAMENTO_CORI'); + end if; + End; + if aCdUO is null AND aEs!=0 then + aCdUO:=CNRCTB015.GETVAL01PERCHIAVE(0,'UO_SPECIALE','UO_VERSAMENTO_CORI'); + end if; + return aCdUO; + end; + function getCdUOVersCoriTuttaSAC(aEs number) return unita_organizzativa.cd_unita_organizzativa%Type Is + aCdUO varchar2(30); + noData EXCEPTION; + pragma exception_init(noData,-20020); + begin + Begin + aCdUO:=CNRCTB015.GETVAL01PERCHIAVE(aEs,'UO_SPECIALE','UO_VERSAMENTO_CORI_TUTTA_SAC'); + Exception + When noData Then + if aEs=0 Then + IBMERR001.RAISE_ERR_GENERICO('Chiave non trovata in tabella di configurazione cnr: UO_SPECIALE-UO_VERSAMENTO_CORI_TUTTA_SAC'); + end if; + End; + if aCdUO is null AND aEs!=0 then + aCdUO:=CNRCTB015.GETVAL01PERCHIAVE(0,'UO_SPECIALE','UO_VERSAMENTO_CORI_TUTTA_SAC'); + end if; + return aCdUO; + end; + function getCdUOVersCoriContoBI(aEs number) return unita_organizzativa.cd_unita_organizzativa%Type Is + aCdUO varchar2(30); + noData EXCEPTION; + pragma exception_init(noData,-20020); + begin + Begin + aCdUO:=CNRCTB015.GETVAL01PERCHIAVE(aEs,'UO_SPECIALE','UO_VERSAMENTO_CORI_CONTO_BI'); + Exception + When noData Then + if aEs=0 Then + IBMERR001.RAISE_ERR_GENERICO('Chiave non trovata in tabella di configurazione cnr: UO_SPECIALE-UO_VERSAMENTO_CORI_CONTO_BI'); + end if; + End; + if aCdUO is null AND aEs!=0 then + aCdUO:=CNRCTB015.GETVAL01PERCHIAVE(0,'UO_SPECIALE','UO_VERSAMENTO_CORI_CONTO_BI'); + end if; + return aCdUO; + end; + function getCdUOVersIVA(aEs number) return unita_organizzativa.cd_unita_organizzativa%Type Is + aCdUO varchar2(30); + noData EXCEPTION; + pragma exception_init(noData,-20020); + begin + Begin + aCdUO:=CNRCTB015.GETVAL01PERCHIAVE(aEs,'UO_SPECIALE','UO_VERSAMENTO_IVA'); + Exception + When noData Then + if aEs=0 Then + IBMERR001.RAISE_ERR_GENERICO('Chiave non trovata in tabella di configurazione cnr: UO_SPECIALE-UO_VERSAMENTO_IVA'); + end if; + End; + if aCdUO is null AND aEs!=0 then + aCdUO:=CNRCTB015.GETVAL01PERCHIAVE(0,'UO_SPECIALE','UO_VERSAMENTO_IVA'); + end if; + return aCdUO; + end; +end; \ No newline at end of file diff --git a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB053_BODY.sql b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB053_BODY.sql index c96df73a7a..4eb321dcac 100644 --- a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB053_BODY.sql +++ b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB053_BODY.sql @@ -1061,7 +1061,7 @@ begin -- Leggo il CDR del personale e la sua linea SAUOP - aCDRPersonale := CNRCTB020.GETCDRPERSONALE; + aCDRPersonale := CNRCTB020.GETCDRPERSONALE(aEsercizio); aLASAUOP := CNRCTB010.getLASAUOP(aEsercizio, aCDRPersonale.cd_centro_responsabilita); If nvl(recParametriCnr.fl_nuovo_pdg,'N') = 'Y' Then @@ -3005,7 +3005,7 @@ procedure aggiornaLimiteSpesaVAR(aEsercizio number,apg_variazione number,tipo VA Where id_classificazione = aElemento_voce.ID_CLASSIFICAZIONE; -- Leggo il CDR del personale e la sua linea SAUOP - aCDRPersonale := CNRCTB020.GETCDRPERSONALE; + aCDRPersonale := CNRCTB020.GETCDRPERSONALE(aEsercizio); aLASAUOP := CNRCTB010.getLASAUOP(aEsercizio, aCDRPersonale.cd_centro_responsabilita); If aCV.CDR_ACCENTRATORE = aCDRPersonale.CD_CENTRO_RESPONSABILITA Then diff --git a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB060_BODY.sql b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB060_BODY.sql index 529ce6d4f8..6b7e6dd5e3 100644 --- a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB060_BODY.sql +++ b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB060_BODY.sql @@ -153,7 +153,7 @@ -- Leggo il CDR del personale e lock del PDG - aCDRPersonale:=CNRCTB020.GETCDRPERSONALE; + aCDRPersonale:=CNRCTB020.GETCDRPERSONALE(aEsercizio); CNRCTB050.LOCKPDG(aEsercizio, aCDRPersonale.cd_centro_responsabilita); -- Verifico che l'aggregato del CDR del personale NON sia chiuso in stato B @@ -706,7 +706,7 @@ -- Leggo il CDR del personale - aCDRPersonale:=CNRCTB020.GETCDRPERSONALE; + aCDRPersonale:=CNRCTB020.GETCDRPERSONALE(aEsercizio); -- Lock PDG del CDR del personale @@ -808,7 +808,7 @@ -- Leggo il CDR del personale e lock del PDG - aCDRPersonale:=CNRCTB020.GETCDRPERSONALE; + aCDRPersonale:=CNRCTB020.GETCDRPERSONALE(aEsercizio); -- Se il cdr del personale e il CDR in processo devo applicare il controllo a tutti i CDR validi diff --git a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB061_BODY.sql b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB061_BODY.sql index 73b53a893d..a1b3a54388 100644 --- a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB061_BODY.sql +++ b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB061_BODY.sql @@ -108,7 +108,7 @@ Begin -- Leggo il CDR del personale e lock del PDG - aCDRPersonale:=CNRCTB020.GETCDRPERSONALE; + aCDRPersonale:=CNRCTB020.GETCDRPERSONALE(aASSCDPLA.esercizio); -- Leggo la linea di attivita per aggiornare gli importi del PDGP in base alla natura Select * into aLATmp from linea_attivita @@ -147,7 +147,7 @@ Begin -- Leggo il CDR del personale e lock del PDG - aCDRPersonale:=CNRCTB020.GETCDRPERSONALE; + aCDRPersonale:=CNRCTB020.GETCDRPERSONALE(aASSCDPLA.esercizio); -- Leggo la linea di attivita per aggiornare gli importi del PDGP in base alla natura Select * into aLATmp from linea_attivita @@ -319,7 +319,7 @@ -- Leggo il CDR del personale - aCDRPersonale:=CNRCTB020.GETCDRPERSONALE; + aCDRPersonale:=CNRCTB020.GETCDRPERSONALE(aEsercizio); -- Lock del PDG del CDR in processo CNRCTB051.LOCKPDGP(aEsercizio, aCdCdr); @@ -1374,7 +1374,7 @@ -- Leggo il CDR del personale - aCDRPersonale:=CNRCTB020.GETCDRPERSONALE; + aCDRPersonale:=CNRCTB020.GETCDRPERSONALE(aEsercizio); Select count(*) into aNum From ass_cdp_pdgp diff --git a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB680_BODY.sql b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB680_BODY.sql index 79c65401b3..8bc1728a94 100644 --- a/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB680_BODY.sql +++ b/sigla-backend/src/main/resources/expsigladb/Package/CNRCTB680_BODY.sql @@ -532,7 +532,7 @@ end if; aDateCont:=CNRCTB008.getTimestampContabile(aStip.esercizio,aTSNow); - aUOPersonale:=CNRCTB020.GETUOPERSONALE; + aUOPersonale:=CNRCTB020.GETUOPERSONALE(aStip.esercizio); aUOPersonale:=CNRCTB020.GETUOVALIDA(aStip.esercizio,aUOPersonale.cd_unita_organizzativa); aTerzoDivComp:=CNRCTB080.getTerzo(CNRCTB015.GETIM01PERCHIAVE(TERZO_SPECIALE,DIVERSI_STIPENDI)); @@ -815,7 +815,7 @@ end if; aDateCont:=CNRCTB008.getTimestampContabile(aEs,aTSNow); - aUOPersonale:=CNRCTB020.GETUOPERSONALE; + aUOPersonale:=CNRCTB020.GETUOPERSONALE((aStip.esercizio); aUOPersonale:=CNRCTB020.GETUOVALIDA(aStip.esercizio,aUOPersonale.cd_unita_organizzativa); aGen:=null; diff --git a/sigla-backend/src/main/resources/expsigladb/Procedure/spg_mandato.prc b/sigla-backend/src/main/resources/expsigladb/Procedure/spg_mandato.prc index c2f4daa535..178612d44a 100644 --- a/sigla-backend/src/main/resources/expsigladb/Procedure/spg_mandato.prc +++ b/sigla-backend/src/main/resources/expsigladb/Procedure/spg_mandato.prc @@ -337,7 +337,7 @@ if aNum4 > 0 and CNRCTB020.getCDCDSENTE(aMan.esercizio) = aMan.CD_CDS then else -- tesoreria unica -- se la UO ? 000.407 e CD_TIPO_DOCUMENTO_AMM = GEN_CORV_S la modalit? di pagamento deve essere BI - uo := CNRCTB015.GETVAL01PERCHIAVE('UO_SPECIALE','UO_VERSAMENTO_IVA'); + uo := CNRCTB020.getCdUOVersIVA(aEs); select count(*) into aNum4 from diff --git a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDGG_SPE_BIL_IST_DIP_FN.sql b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDGG_SPE_BIL_IST_DIP_FN.sql index 394f5b1667..f363368fb5 100644 --- a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDGG_SPE_BIL_IST_DIP_FN.sql +++ b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDGG_SPE_BIL_IST_DIP_FN.sql @@ -62,12 +62,7 @@ From CDR, CDR CDR_ASS, PROGETTO_GEST MODU, PROGETTO_GEST COMM, PROGETTO_GEST P From PDG_MODULO_SPESE_GEST PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - NVL(CLA.CDR_ACCENTRATORE, 'xxx') != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') And + NVL(CLA.CDR_ACCENTRATORE, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) And AREA.CD_TIPO_UNITA != 'AREA' And PDG_SPE.FL_SOLA_LETTURA = 'N' Group By PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, @@ -92,18 +87,8 @@ From CDR, CDR CDR_ASS, PROGETTO_GEST MODU, PROGETTO_GEST COMM, PROGETTO_GEST P From PDG_MODULO_SPESE_GEST PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - NVL(CLA.CDR_ACCENTRATORE, 'xxx') = (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 AND - CD_UNITA_FUNZIONALE = '*' AND - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' AND - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') AND - PDG_SPE.CD_CDR_ASSEGNATARIO != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 AND - CD_UNITA_FUNZIONALE = '*' AND - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' AND - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') AND + NVL(CLA.CDR_ACCENTRATORE, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) AND + PDG_SPE.CD_CDR_ASSEGNATARIO != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) AND AREA.CD_TIPO_UNITA != 'AREA' AND PDG_SPE.FL_SOLA_LETTURA = 'Y' Group BY PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, @@ -149,12 +134,7 @@ From CDR, CDR CDR_ASS, PROGETTO_GEST MODU, PROGETTO_GEST COMM, PROGETTO_GEST P From PDG_MODULO_SPESE_GEST PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - NVL(PDG_SPE.CD_CDR_ASSEGNATARIO, 'xxx') = (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 AND - CD_UNITA_FUNZIONALE = '*' AND - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' AND - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') + NVL(PDG_SPE.CD_CDR_ASSEGNATARIO, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) Group BY PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, CD_CLASSIFICAZIONE, DS_CLASSIFICAZIONE, NR_LIVELLO, CD_LIVELLO1, CD_LIVELLO2, CD_LIVELLO3, CD_LIVELLO4, CD_LIVELLO5, CD_LIVELLO6, CD_LIVELLO7, PDG_SPE.CD_CDR_ASSEGNATARIO, PDG_SPE.CD_LINEA_ATTIVITA, diff --git a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDGG_SPE_BIL_IST_DIP_FO.sql b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDGG_SPE_BIL_IST_DIP_FO.sql index c7d84fb6af..ae9e40233b 100644 --- a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDGG_SPE_BIL_IST_DIP_FO.sql +++ b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDGG_SPE_BIL_IST_DIP_FO.sql @@ -63,12 +63,7 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE_GEST PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - NVL(CLA.CDR_ACCENTRATORE, 'xxx') != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') And + NVL(CLA.CDR_ACCENTRATORE, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) And AREA.CD_TIPO_UNITA != 'AREA' And PDG_SPE.FL_SOLA_LETTURA = 'N' Group By PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, @@ -93,18 +88,8 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE_GEST PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - NVL(CLA.CDR_ACCENTRATORE, 'xxx') = (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 AND - CD_UNITA_FUNZIONALE = '*' AND - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' AND - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') AND - PDG_SPE.CD_CDR_ASSEGNATARIO != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 AND - CD_UNITA_FUNZIONALE = '*' AND - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' AND - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') AND + NVL(CLA.CDR_ACCENTRATORE, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) AND + PDG_SPE.CD_CDR_ASSEGNATARIO != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) AND AREA.CD_TIPO_UNITA != 'AREA' AND PDG_SPE.FL_SOLA_LETTURA = 'Y' Group BY PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, @@ -150,12 +135,7 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE_GEST PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - NVL(PDG_SPE.CD_CDR_ASSEGNATARIO, 'xxx') = (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 AND - CD_UNITA_FUNZIONALE = '*' AND - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' AND - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') + NVL(PDG_SPE.CD_CDR_ASSEGNATARIO, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) Group BY PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, CD_CLASSIFICAZIONE, DS_CLASSIFICAZIONE, NR_LIVELLO, CD_LIVELLO1, CD_LIVELLO2, CD_LIVELLO3, CD_LIVELLO4, CD_LIVELLO5, CD_LIVELLO6, CD_LIVELLO7, PDG_SPE.CD_CDR_ASSEGNATARIO, PDG_SPE.CD_LINEA_ATTIVITA, @@ -239,12 +219,7 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE_GEST PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - NVL(CLA.CDR_ACCENTRATORE, 'xxx') != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') And + NVL(CLA.CDR_ACCENTRATORE, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) And AREA.CD_TIPO_UNITA != 'AREA' And PDG_SPE.FL_SOLA_LETTURA = 'N' Group By PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, @@ -269,18 +244,8 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE_GEST PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - NVL(CLA.CDR_ACCENTRATORE, 'xxx') = (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 AND - CD_UNITA_FUNZIONALE = '*' AND - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' AND - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') AND - PDG_SPE.CD_CDR_ASSEGNATARIO != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 AND - CD_UNITA_FUNZIONALE = '*' AND - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' AND - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') AND + NVL(CLA.CDR_ACCENTRATORE, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) AND + PDG_SPE.CD_CDR_ASSEGNATARIO != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) AND AREA.CD_TIPO_UNITA != 'AREA' AND PDG_SPE.FL_SOLA_LETTURA = 'Y' Group BY PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, @@ -326,12 +291,7 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE_GEST PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - NVL(PDG_SPE.CD_CDR_ASSEGNATARIO, 'xxx') = (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 AND - CD_UNITA_FUNZIONALE = '*' AND - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' AND - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') + NVL(PDG_SPE.CD_CDR_ASSEGNATARIO, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) Group BY PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, CD_CLASSIFICAZIONE, DS_CLASSIFICAZIONE, NR_LIVELLO, CD_LIVELLO1, CD_LIVELLO2, CD_LIVELLO3, CD_LIVELLO4, CD_LIVELLO5, CD_LIVELLO6, CD_LIVELLO7, PDG_SPE.CD_CDR_ASSEGNATARIO, PDG_SPE.CD_LINEA_ATTIVITA, diff --git a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_BIL_IST_DIP_FO.sql b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_BIL_IST_DIP_FO.sql index d60304b9f3..7c0a61f876 100644 --- a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_BIL_IST_DIP_FO.sql +++ b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_BIL_IST_DIP_FO.sql @@ -59,12 +59,7 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') And + Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) And AREA.CD_TIPO_UNITA != 'AREA' Group By PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, CD_CLASSIFICAZIONE, DS_CLASSIFICAZIONE, NR_LIVELLO, CD_LIVELLO1, CD_LIVELLO2, CD_LIVELLO3, CD_LIVELLO4, CD_LIVELLO5, CD_LIVELLO6, CD_LIVELLO7,PDG_SPE.CD_COFOG,PDG_SPE.CD_MISSIONE @@ -101,12 +96,7 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - Nvl(CLA.CDR_ACCENTRATORE, 'xxx') = (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') + Nvl(CLA.CDR_ACCENTRATORE, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) Group By PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, CD_CLASSIFICAZIONE, DS_CLASSIFICAZIONE, NR_LIVELLO, CD_LIVELLO1, CD_LIVELLO2, CD_LIVELLO3, CD_LIVELLO4, CD_LIVELLO5, CD_LIVELLO6, CD_LIVELLO7,PDG_SPE.CD_COFOG,PDG_SPE.CD_MISSIONE Union All -- ANNO 2 E 3 @@ -193,12 +183,7 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') And + Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) And AREA.CD_TIPO_UNITA != 'AREA' Group By PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, CD_CLASSIFICAZIONE, DS_CLASSIFICAZIONE, NR_LIVELLO, CD_LIVELLO1, CD_LIVELLO2, CD_LIVELLO3, CD_LIVELLO4, CD_LIVELLO5, CD_LIVELLO6, CD_LIVELLO7,PDG_SPE.CD_COFOG,PDG_SPE.CD_MISSIONE @@ -235,12 +220,7 @@ From PARAMETRI_CNR PAR, From PDG_MODULO_SPESE PDG_SPE, V_CLASSIFICAZIONE_VOCI CLA, UNITA_ORGANIZZATIVA AREA Where PDG_SPE.ID_CLASSIFICAZIONE = CLA.ID_CLASSIFICAZIONE AND PDG_SPE.CD_CDS_AREA = AREA.CD_UNITA_ORGANIZZATIVA AND - Nvl(CLA.CDR_ACCENTRATORE, 'xxx') = (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') + Nvl(CLA.CDR_ACCENTRATORE, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) Group By PDG_SPE.ESERCIZIO, PDG_SPE.CD_CENTRO_RESPONSABILITA, PDG_SPE.PG_PROGETTO, CD_CLASSIFICAZIONE, DS_CLASSIFICAZIONE, NR_LIVELLO, CD_LIVELLO1, CD_LIVELLO2, CD_LIVELLO3, CD_LIVELLO4, CD_LIVELLO5, CD_LIVELLO6, CD_LIVELLO7,PDG_SPE.CD_COFOG,PDG_SPE.CD_MISSIONE Union All -- ANNO 2 E 3 diff --git a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_PRELIMINARE.sql b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_PRELIMINARE.sql index a95e875ab8..225022dee5 100644 --- a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_PRELIMINARE.sql +++ b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_PRELIMINARE.sql @@ -87,12 +87,7 @@ Where --Join tra COMMESSA e PROGETTO COMM.ESERCIZIO_PROGETTO_PADRE = PROG.ESERCIZIO And COMM.PG_PROGETTO_PADRE = PROG.PG_PROGETTO And - Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') And + Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) And AREA.CD_TIPO_UNITA != 'AREA' Union All -- AREE Select PDG_SPE.ESERCIZIO, @@ -148,12 +143,7 @@ Where --Join tra COMMESSA e PROGETTO COMM.ESERCIZIO_PROGETTO_PADRE = PROG.ESERCIZIO And COMM.PG_PROGETTO_PADRE = PROG.PG_PROGETTO And - Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') And + Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) And AREA.CD_TIPO_UNITA = 'AREA' Union All -- SPESE ACCENTRATE NON PERSONALE Select PDG_SPE.ESERCIZIO, @@ -206,12 +196,7 @@ Where --Join tra COMMESSA e PROGETTO COMM.ESERCIZIO_PROGETTO_PADRE = PROG.ESERCIZIO And COMM.PG_PROGETTO_PADRE = PROG.PG_PROGETTO And - Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') + Nvl(CLA.CDR_ACCENTRATORE, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) Union All -- TRATTAMENTO ECONOMICO DEL PERSONALE Select PDG_SPE.ESERCIZIO, Decode(unita_organizzativa.CD_TIPO_UNITA, 'SAC', '13',to_char(nvl(p.peso,1000))) PESO_DIP, @@ -266,12 +251,7 @@ Where --Join tra COMMESSA e PROGETTO COMM.ESERCIZIO_PROGETTO_PADRE = PROG.ESERCIZIO And COMM.PG_PROGETTO_PADRE = PROG.PG_PROGETTO And - Nvl(CLA.CDR_ACCENTRATORE, 'xxx') = (Select VAL01 - From CONFIGURAZIONE_CNR - Where ESERCIZIO = 0 And - CD_UNITA_FUNZIONALE = '*' And - CD_CHIAVE_PRIMARIA = 'CDR_SPECIALE' And - CD_CHIAVE_SECONDARIA = 'CDR_PERSONALE') + Nvl(CLA.CDR_ACCENTRATORE, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) Union All -- ANNO 2 E 3 Select PDG_SPE.ESERCIZIO, Decode(unita_organizzativa.CD_TIPO_UNITA, 'SAC', '13',to_char(nvl(p.peso,1000))) PESO_DIP, diff --git a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_PRELIMINARE_V.sql b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_PRELIMINARE_V.sql index 74d249d0d3..d6caef7bb6 100644 --- a/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_PRELIMINARE_V.sql +++ b/sigla-backend/src/main/resources/expsigladb/View/V_CONS_PDG_SPE_PRELIMINARE_V.sql @@ -112,13 +112,7 @@ --Join tra COMMESSA e PROGETTO comm.esercizio_progetto_padre = prog.esercizio AND comm.pg_progetto_padre = prog.pg_progetto - AND NVL (cla.cdr_accentratore, 'xxx') != - (SELECT val01 - FROM configurazione_cnr - WHERE esercizio = 0 - AND cd_unita_funzionale = '*' - AND cd_chiave_primaria = 'CDR_SPECIALE' - AND cd_chiave_secondaria = 'CDR_PERSONALE') + AND NVL (cla.cdr_accentratore, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) AND area.cd_tipo_unita != 'AREA' and voce.id_classificazione=cla.id_classificazione UNION ALL -- AREE @@ -197,13 +191,7 @@ --Join tra COMMESSA e PROGETTO comm.esercizio_progetto_padre = prog.esercizio AND comm.pg_progetto_padre = prog.pg_progetto - AND NVL (cla.cdr_accentratore, 'xxx') != - (SELECT val01 - FROM configurazione_cnr - WHERE esercizio = 0 - AND cd_unita_funzionale = '*' - AND cd_chiave_primaria = 'CDR_SPECIALE' - AND cd_chiave_secondaria = 'CDR_PERSONALE') + AND NVL (cla.cdr_accentratore, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) AND area.cd_tipo_unita = 'AREA' and voce.id_classificazione=cla.id_classificazione UNION ALL -- SPESE ACCENTRATE NON PERSONALE @@ -275,13 +263,7 @@ --Join tra COMMESSA e PROGETTO comm.esercizio_progetto_padre = prog.esercizio AND comm.pg_progetto_padre = prog.pg_progetto - AND NVL (cla.cdr_accentratore, 'xxx') != - (SELECT val01 - FROM configurazione_cnr - WHERE esercizio = 0 - AND cd_unita_funzionale = '*' - AND cd_chiave_primaria = 'CDR_SPECIALE' - AND cd_chiave_secondaria = 'CDR_PERSONALE') + AND NVL (cla.cdr_accentratore, 'xxx') != CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) and voce.id_classificazione=cla.id_classificazione UNION ALL -- TRATTAMENTO ECONOMICO DEL PERSONALE SELECT pdg_spe.esercizio, @@ -367,13 +349,7 @@ --Join tra COMMESSA e PROGETTO comm.esercizio_progetto_padre = prog.esercizio AND comm.pg_progetto_padre = prog.pg_progetto - AND NVL (cla.cdr_accentratore, 'xxx') = - (SELECT val01 - FROM configurazione_cnr - WHERE esercizio = 0 - AND cd_unita_funzionale = '*' - AND cd_chiave_primaria = 'CDR_SPECIALE' - AND cd_chiave_secondaria = 'CDR_PERSONALE') + AND NVL (cla.cdr_accentratore, 'xxx') = CNRCTB020.getCdCDRPersonale(PDG_SPE.ESERCIZIO) and voce.id_classificazione=cla.id_classificazione UNION ALL -- ANNO 2 E 3 SELECT pdg_spe.esercizio, diff --git a/sigla-backend/src/main/resources/expsigladb/View/V_PDG_PDG_SAUOP.sql b/sigla-backend/src/main/resources/expsigladb/View/V_PDG_PDG_SAUOP.sql index 7132d3bf06..3f11e3b435 100644 --- a/sigla-backend/src/main/resources/expsigladb/View/V_PDG_PDG_SAUOP.sql +++ b/sigla-backend/src/main/resources/expsigladb/View/V_PDG_PDG_SAUOP.sql @@ -2,46 +2,42 @@ -- DDL for View V_PDG_PDG_SAUOP -------------------------------------------------------- - CREATE OR REPLACE FORCE VIEW "V_PDG_PDG_SAUOP" ("ESERCIZIO", "CD_CENTRO_RESPONSABILITA", "STATO", "ANNOTAZIONI", "FL_RIBALTATO_SU_AREA", "DACR", "UTCR", "DUVA", "UTUV", "PG_VER_REC") AS - select --- --- Date: 05/12/2001 --- Version: 1.2 --- --- Ritorna la testata del PdG del CdR che gestisce le page del personale --- La vista non verifica la validita dell'STO --- --- History: --- --- Date: 18/10/2001 + CREATE OR REPLACE FORCE VIEW "V_PDG_PDG_SAUOP" ("ESERCIZIO", "CD_CENTRO_RESPONSABILITA", "STATO", "ANNOTAZIONI", "FL_RIBALTATO_SU_AREA", "DACR", "UTCR", "DUVA", "UTUV", "PG_VER_REC") AS + select +-- +-- Date: 05/12/2001 +-- Version: 1.2 +-- +-- Ritorna la testata del PdG del CdR che gestisce le page del personale +-- La vista non verifica la validita dell'STO +-- +-- History: +-- +-- Date: 18/10/2001 -- Version: 1.0 -- Creazione --- --- Date: 08/11/2001 --- Version: 1.1 --- Eliminazione esercizio da STO --- --- Date: 05/12/2001 --- Version: 1.2 --- Cambiata entry in CONFIGURAZIONE CNR per identificazione CDR gestione personale --- --- Body: --- -pdg.ESERCIZIO, -pdg.CD_CENTRO_RESPONSABILITA, -pdg.STATO, pdg.ANNOTAZIONI, -pdg.FL_RIBALTATO_SU_AREA, -pdg.DACR, pdg.UTCR, -pdg.DUVA, -pdg.UTUV, -pdg.PG_VER_REC -from - configurazione_cnr conf, - pdg_preventivo pdg -where conf.cd_chiave_primaria = 'CDR_SPECIALE' -and conf.cd_chiave_secondaria = 'CDR_PERSONALE' -and conf.esercizio = 0 -and pdg.CD_CENTRO_RESPONSABILITA = conf.val01; +-- +-- Date: 08/11/2001 +-- Version: 1.1 +-- Eliminazione esercizio da STO +-- +-- Date: 05/12/2001 +-- Version: 1.2 +-- Cambiata entry in CONFIGURAZIONE CNR per identificazione CDR gestione personale +-- +-- Body: +-- +pdg.ESERCIZIO, +pdg.CD_CENTRO_RESPONSABILITA, +pdg.STATO, pdg.ANNOTAZIONI, +pdg.FL_RIBALTATO_SU_AREA, +pdg.DACR, pdg.UTCR, +pdg.DUVA, +pdg.UTUV, +pdg.PG_VER_REC +from + pdg_preventivo pdg +where pdg.CD_CENTRO_RESPONSABILITA = CNRCTB020.getCdCDRPersonale(pdg.ESERCIZIO); COMMENT ON TABLE "V_PDG_PDG_SAUOP" IS 'Ritorna la testata del PdG del CdR che gestisce le page del personale La vista non verifica la validita dell''STO'; diff --git a/sigla-ejb/src/main/java/it/cnr/contab/config00/bulk/Configurazione_cnrBulk.java b/sigla-ejb/src/main/java/it/cnr/contab/config00/bulk/Configurazione_cnrBulk.java index 0619d843f6..204b557f22 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/config00/bulk/Configurazione_cnrBulk.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/config00/bulk/Configurazione_cnrBulk.java @@ -58,7 +58,7 @@ public class Configurazione_cnrBulk extends Configurazione_cnrBase { public final static String PK_UO_SPECIALE = "UO_SPECIALE"; public final static String SK_UO_ACCREDITAMENTO_SAC = "UO_ACCREDITAMENTO_SAC"; - public final static String SK_UO_DISTINTA_SAC = "UO_DISTINTA_SAC"; + public final static String SK_UO_DISTINTA_TUTTA_SAC = "UO_DISTINTA_TUTTA_SAC"; public final static String SK_UO_RAGIONERIA = "UO_RAGIONERIA"; public final static String PK_PDG_VARIAZIONE = "PDG_VARIAZIONE"; @@ -69,6 +69,7 @@ public class Configurazione_cnrBulk extends Configurazione_cnrBase { public final static String PK_CDR_SPECIALE = "CDR_SPECIALE"; public final static String SK_CDR_PERSONALE = "CDR_PERSONALE"; + public final static String SK_CDR_SERVIZIO_ENTE = "CDR_SERVIZIO_ENTE"; public final static String PK_FATTURAZIONE_ELETTRONICA = "FATTURAZIONE_ELETTRONICA"; diff --git a/sigla-ejb/src/main/java/it/cnr/contab/config00/bulk/Configurazione_cnrHome.java b/sigla-ejb/src/main/java/it/cnr/contab/config00/bulk/Configurazione_cnrHome.java index d0a512a5c3..99aada4a47 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/config00/bulk/Configurazione_cnrHome.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/config00/bulk/Configurazione_cnrHome.java @@ -17,6 +17,7 @@ package it.cnr.contab.config00.bulk; +import it.cnr.contab.utenze00.bp.CNRUserContext; import it.cnr.jada.UserContext; import it.cnr.jada.bulk.BulkHome; import it.cnr.jada.comp.ComponentException; @@ -26,8 +27,10 @@ import java.math.BigDecimal; import java.util.List; +import java.util.Optional; public class Configurazione_cnrHome extends BulkHome { + public static final Integer ANNI_ALL = 0; public static final String ASTERISCO = "*"; /** @@ -84,22 +87,155 @@ public java.util.List findTipoVariazioniEnteStanz_res() throws PersistencyExcept return fetchAll(sql); } - public boolean isUOSpecialeTuttaSAC(String cdUnitaOrganizzativa) throws PersistencyException { - SQLBuilder sql = createSQLBuilder(); - sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, new Integer(0)); - sql.addClause("AND", "cd_unita_funzionale", SQLBuilder.EQUALS, "*"); - sql.addClause("AND", "cd_chiave_primaria", SQLBuilder.EQUALS, Configurazione_cnrBulk.PK_UO_SPECIALE); - sql.addClause("AND", "cd_chiave_secondaria", SQLBuilder.EQUALS, "UO_DISTINTA_TUTTA_SAC"); - final List list = fetchAll(sql); - return list.stream() - .filter(configurazione_cnrBulk -> configurazione_cnrBulk.getVal01().equals(cdUnitaOrganizzativa)) - .findAny().isPresent(); + /** + * Indica se la uo indicata è proprio quella speciale tutta sac + * + * @param esercizio l'esercizio di ricerca - Lasciare vuoto per ricercare il parametro generale (esercizio=0). + * @param cdUnitaOrganizzativa l'unità organizzativa di cui si chiede se si tratta della Uo Speciale Tutta SAC + * @return boolean + * @throws PersistencyException + */ + public boolean isUOSpecialeDistintaTuttaSAC(Integer esercizio, String cdUnitaOrganizzativa) throws PersistencyException { + return Optional.ofNullable(this.getUoDistintaTuttaSac(esercizio)) + .filter(uoDistintaTuttaSac -> uoDistintaTuttaSac.equals(cdUnitaOrganizzativa)) + .isPresent(); } - + + /** + * Ritorna il record puntuale richiesto sulla base dei parametri indicati. + *

ATTENZIONE: in questo metodo viene ricercato puntualmente il record con l'esercizio indicato

+ *

Se si desidera avere, in caso di assenza, il record con esercizio=0 utilizzare il metodo {@link #getConfigurazione(UserContext,String,String,String)} o il + * metodo {@link #getConfigurazione(Integer,String,String,String)}

+ * + * @param esercizio l'esercizio di ricerca - Lasciare vuoto per ricercare il parametro generale (esercizio=0). + * @param unita_funzionale Unità funzionale - Lasciare vuoto per ricercare il parametro generale (unita_funzionale='*'). + * @param chiave_primaria Chiave Primaria - Campo Obbligatorio + * @param chiave_secondaria Chiave Secondaria - Lasciare vuoto per ricercare il parametro generale (chiave_secondaria='*') + * @return il record ConfigurazioneCNR richiesto sulla base dei parametri indicati + * @throws PersistencyException + */ public Configurazione_cnrBulk getConfigurazioneCnrBulk(Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws PersistencyException { if (esercizio == null) esercizio = new Integer(0); if (unita_funzionale == null) unita_funzionale = ASTERISCO; if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; return (Configurazione_cnrBulk) getHomeCache().getHome(Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - } + } + + /** + * Ritorna il record richiesto sulla base dei parametri indicati. + *

ATTENZIONE: in questo metodo viene ricercato prima il record con esercizio di scrivania prelevato dallo Usercontext e, + * in caso di assenza, viene ricercato il record con anno=0

+ *

Se si desidera avere il record puntuale per i parametri impostati utilizzare il metodo {@link #getConfigurazioneCnrBulk(Integer,String,String,String)}

+ * + * @param userContext lo UserContext da cui recupera l'esercizio di scrivania + * @param unita_funzionale Unità funzionale - Lasciare vuoto per ricercare il parametro generale (unita_funzionale='*'). + * @param chiave_primaria Chiave Primaria - Campo Obbligatorio + * @param chiave_secondaria Chiave Secondaria - Lasciare vuoto per ricercare il parametro generale (chiave_secondaria='*') + * @return il record ConfigurazioneCNR richiesto sulla base dei parametri indicati + * @throws PersistencyException + */ + public Configurazione_cnrBulk getConfigurazione(UserContext userContext, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws PersistencyException { + return getConfigurazione(CNRUserContext.getEsercizio(userContext),unita_funzionale,chiave_primaria, chiave_secondaria); + } + + /** + * Ritorna il record richiesto sulla base dei parametri indicati. + *

ATTENZIONE: in questo metodo viene ricercato prima il record con l'esercizio indicato e, in caso di assenza, viene ricercato il record con esercizio=0

+ *

Se si desidera avere il record puntuale per i parametri impostati utilizzare il metodo {@link #getConfigurazioneCnrBulk(Integer,String,String,String)}

+ * + * @param esercizio l'esercizio di ricerca - se non esistono configurazioni per l'esercizio indicato viene cercata la configurazione con esercizio=0 + * @param unita_funzionale Unità funzionale - Lasciare vuoto per ricercare il parametro generale (unita_funzionale='*'). + * @param chiave_primaria Chiave Primaria - Campo Obbligatorio + * @param chiave_secondaria Chiave Secondaria - Lasciare vuoto per ricercare il parametro generale (chiave_secondaria='*') + * @return il record ConfigurazioneCNR richiesto sulla base dei parametri indicati + * @throws PersistencyException + */ + public Configurazione_cnrBulk getConfigurazione(Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws PersistencyException { + Configurazione_cnrBulk config = null; + if (Optional.ofNullable(esercizio).isPresent()) + config = getConfigurazioneCnrBulk(esercizio,unita_funzionale,chiave_primaria,chiave_secondaria); + if (!Optional.ofNullable(config).isPresent() && Optional.ofNullable(esercizio).filter(ese->!ese.equals(ANNI_ALL)).isPresent()) + config = getConfigurazioneCnrBulk(ANNI_ALL,unita_funzionale,chiave_primaria,chiave_secondaria); + return config; + } + + /** + * Ritorna il codice uo della Ragioneria + *

chiave_primaria: UO_SPECIALE + *

chiave_secondaria: UO_RAGIONERIA + * + * @param esercizio l'esercizio di ricerca - se non esistono configurazioni per l'esercizio indicato viene cercata la configurazione con esercizio=0 + * @return String - il codice uo della Ragioneria + * @throws PersistencyException + */ + public String getUoRagioneria(Integer esercizio) throws PersistencyException { + return Optional.ofNullable( + this.getConfigurazione(esercizio,null,Configurazione_cnrBulk.PK_UO_SPECIALE, Configurazione_cnrBulk.SK_UO_RAGIONERIA)) + .map(Configurazione_cnrBulk::getVal01) + .orElse(null); + } + + /** + * Ritorna il codice cdr del personale + *

chiave_primaria: CDR_SPECIALE + *

chiave_secondaria: CDR_PERSONALE + * + * @param esercizio l'esercizio di ricerca - se non esistono configurazioni per l'esercizio indicato viene cercata la configurazione con esercizio=0 + * @return String - il codice cdr del personale + * @throws PersistencyException + */ + public String getCdrPersonale(Integer esercizio) throws PersistencyException { + return Optional.ofNullable( + this.getConfigurazione(esercizio,null,Configurazione_cnrBulk.PK_CDR_SPECIALE, Configurazione_cnrBulk.SK_CDR_PERSONALE)) + .map(Configurazione_cnrBulk::getVal01) + .orElse(null); + } + + /** + * Ritorna il codice cdr servizio ente + *

chiave_primaria: CDR_SPECIALE + *

chiave_secondaria: CDR_SERVIZIO_ENTE + * + * @param esercizio l'esercizio di ricerca - se non esistono configurazioni per l'esercizio indicato viene cercata la configurazione con esercizio=0 + * @return String - il codice cdr servizio ente + * @throws PersistencyException + */ + public String getCdrServizioEnte(Integer esercizio) throws PersistencyException { + return Optional.ofNullable( + this.getConfigurazione(esercizio,null,Configurazione_cnrBulk.PK_CDR_SPECIALE, Configurazione_cnrBulk.SK_CDR_SERVIZIO_ENTE)) + .map(Configurazione_cnrBulk::getVal01) + .orElse(null); + } + + /** + * Ritorna il codice uo di Accreditamento Sac + *

chiave_primaria: UO_SPECIALE + *

chiave_secondaria: UO_RAGIONERIA + * + * @param esercizio l'esercizio di ricerca - se non esistono configurazioni per l'esercizio indicato viene cercata la configurazione con esercizio=0 + * @return String - il codice uo di Accreditamento Sac + * @throws PersistencyException + */ + public String getUoAccreditamentoSac(Integer esercizio) throws PersistencyException { + return Optional.ofNullable( + this.getConfigurazione(esercizio,null,Configurazione_cnrBulk.PK_UO_SPECIALE, Configurazione_cnrBulk.SK_UO_ACCREDITAMENTO_SAC)) + .map(Configurazione_cnrBulk::getVal01) + .orElse(null); + } + + /** + * Ritorna il codice uo distinta tutta sac + *

chiave_primaria: UO_SPECIALE + *

chiave_secondaria: UO_DISTINTA_TUTTA_SAC + * + * @param esercizio l'esercizio di ricerca - se non esistono configurazioni per l'esercizio indicato viene cercata la configurazione con esercizio=0 + * @return String - il codice codice uo distinta tutta sac + * @throws PersistencyException + */ + public String getUoDistintaTuttaSac(Integer esercizio) throws PersistencyException { + return Optional.ofNullable( + this.getConfigurazione(esercizio,null,Configurazione_cnrBulk.PK_UO_SPECIALE, Configurazione_cnrBulk.SK_UO_DISTINTA_TUTTA_SAC)) + .map(Configurazione_cnrBulk::getVal01) + .orElse(null); + } } diff --git a/sigla-ejb/src/main/java/it/cnr/contab/config00/comp/Configurazione_cnrComponent.java b/sigla-ejb/src/main/java/it/cnr/contab/config00/comp/Configurazione_cnrComponent.java index 3d51838139..4c2ce8f9be 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/config00/comp/Configurazione_cnrComponent.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/config00/comp/Configurazione_cnrComponent.java @@ -1,573 +1,641 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package it.cnr.contab.config00.comp; - -import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; -import it.cnr.contab.config00.bulk.Configurazione_cnrKey; -import it.cnr.contab.utenze00.bp.CNRUserContext; -import it.cnr.jada.UserContext; -import it.cnr.jada.bulk.BulkHome; -import it.cnr.jada.comp.ComponentException; -import it.cnr.jada.persistency.PersistencyError; -import it.cnr.jada.persistency.PersistencyException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.time.LocalDateTime; -import java.util.Optional; - -public class Configurazione_cnrComponent extends it.cnr.jada.comp.GenericComponent implements IConfigurazione_cnrMgr, Cloneable, Serializable { - - private transient final static Logger logger = LoggerFactory.getLogger(Configurazione_cnrComponent.class); - - public static final String ASTERISCO = "*"; - - public Configurazione_cnrComponent() { - - /*Default constructor*/ - - - } - - /** - * esercizio nullo - * PreCondition: - * esercizio = null - * PostCondition: - * Effettua la ricerca usando la condizione SQL esercizio = '*' - * unita funzionale nulla - * PreCondition: - * unita_funzionale = null - * PostCondition: - * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' - * chiave secondaria nulla - * PreCondition: - * chiave_secondaria = null - * PostCondition: - * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' - * Normale - * PreCondition: - * Viene richiesto un istanza di Configurazioe_cnrBulk dalle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito un'istanza di Configurazione_cnrBulk o null se la ricerca non restituisce nulla - */ - public Configurazione_cnrBulk getConfigurazione(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { - try { - if (esercizio == null) esercizio = new Integer(0); - if (unita_funzionale == null) unita_funzionale = ASTERISCO; - if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; - return (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * esercizio nullo - * PreCondition: - * esercizio = null - * PostCondition: - * Effettua la ricerca usando la condizione SQL esercizio = '*' - * unita funzionale nulla - * PreCondition: - * unita_funzionale = null - * PostCondition: - * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' - * chiave secondaria nulla - * PreCondition: - * chiave_secondaria = null - * PostCondition: - * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public Timestamp getDt01(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { - try { - if (esercizio == null) esercizio = new Integer(0); - if (unita_funzionale == null) unita_funzionale = ASTERISCO; - if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - if (bulk == null) return null; - return bulk.getDt01(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public Timestamp getDt01(UserContext userContext, String chiave_primaria) throws ComponentException { - try { - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); - if (bulk == null) return null; - return bulk.getDt01(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * esercizio nullo - * PreCondition: - * esercizio = null - * PostCondition: - * Effettua la ricerca usando la condizione SQL esercizio = '*' - * unita funzionale nulla - * PreCondition: - * unita_funzionale = null - * PostCondition: - * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' - * chiave secondaria nulla - * PreCondition: - * chiave_secondaria = null - * PostCondition: - * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public Timestamp getDt02(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { - try { - if (esercizio == null) esercizio = new Integer(0); - if (unita_funzionale == null) unita_funzionale = ASTERISCO; - if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - if (bulk == null) return null; - return bulk.getDt02(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public Timestamp getDt02(UserContext userContext, String chiave_primaria) throws ComponentException { - try { - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); - if (bulk == null) return null; - return bulk.getDt02(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * esercizio nullo - * PreCondition: - * esercizio = null - * PostCondition: - * Effettua la ricerca usando la condizione SQL esercizio = '*' - * unita funzionale nulla - * PreCondition: - * unita_funzionale = null - * PostCondition: - * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' - * chiave secondaria nulla - * PreCondition: - * chiave_secondaria = null - * PostCondition: - * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public BigDecimal getIm01(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { - try { - if (esercizio == null) esercizio = new Integer(0); - if (unita_funzionale == null) unita_funzionale = ASTERISCO; - if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - if (bulk == null) return null; - return bulk.getIm01(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public BigDecimal getIm01(UserContext userContext, String chiave_primaria) throws ComponentException { - try { - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); - if (bulk == null) return null; - return bulk.getIm01(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * esercizio nullo - * PreCondition: - * esercizio = null - * PostCondition: - * Effettua la ricerca usando la condizione SQL esercizio = '*' - * unita funzionale nulla - * PreCondition: - * unita_funzionale = null - * PostCondition: - * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' - * chiave secondaria nulla - * PreCondition: - * chiave_secondaria = null - * PostCondition: - * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public BigDecimal getIm02(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { - try { - if (esercizio == null) esercizio = new Integer(0); - if (unita_funzionale == null) unita_funzionale = ASTERISCO; - if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - if (bulk == null) return null; - return bulk.getIm02(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public BigDecimal getIm02(UserContext userContext, String chiave_primaria) throws ComponentException { - try { - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); - if (bulk == null) return null; - return bulk.getIm02(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * esercizio nullo - * PreCondition: - * esercizio = null - * PostCondition: - * Effettua la ricerca usando la condizione SQL esercizio = '*' - * unita funzionale nulla - * PreCondition: - * unita_funzionale = null - * PostCondition: - * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' - * chiave secondaria nulla - * PreCondition: - * chiave_secondaria = null - * PostCondition: - * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public String getVal01(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { - try { - if (esercizio == null) esercizio = new Integer(0); - if (unita_funzionale == null) unita_funzionale = ASTERISCO; - if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - if (bulk == null) return null; - return bulk.getVal01(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public String getVal01(UserContext userContext, String chiave_primaria) throws ComponentException { - try { - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); - if (bulk == null) return null; - return bulk.getVal01(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * esercizio nullo - * PreCondition: - * esercizio = null - * PostCondition: - * Effettua la ricerca usando la condizione SQL esercizio = '*' - * unita funzionale nulla - * PreCondition: - * unita_funzionale = null - * PostCondition: - * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' - * chiave secondaria nulla - * PreCondition: - * chiave_secondaria = null - * PostCondition: - * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public String getVal02(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { - try { - if (esercizio == null) esercizio = new Integer(0); - if (unita_funzionale == null) unita_funzionale = ASTERISCO; - if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - if (bulk == null) return null; - return bulk.getVal02(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public String getVal02(UserContext userContext, String chiave_primaria) throws ComponentException { - try { - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); - if (bulk == null) return null; - return bulk.getVal02(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * esercizio nullo - * PreCondition: - * esercizio = null - * PostCondition: - * Effettua la ricerca usando la condizione SQL esercizio = '*' - * unita funzionale nulla - * PreCondition: - * unita_funzionale = null - * PostCondition: - * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' - * chiave secondaria nulla - * PreCondition: - * chiave_secondaria = null - * PostCondition: - * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public String getVal03(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { - try { - if (esercizio == null) esercizio = new Integer(0); - if (unita_funzionale == null) unita_funzionale = ASTERISCO; - if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - if (bulk == null) return null; - return bulk.getVal03(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public String getVal03(UserContext userContext, String chiave_primaria) throws ComponentException { - try { - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); - if (bulk == null) return null; - return bulk.getVal03(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * esercizio nullo - * PreCondition: - * esercizio = null - * PostCondition: - * Effettua la ricerca usando la condizione SQL esercizio = '*' - * unita funzionale nulla - * PreCondition: - * unita_funzionale = null - * PostCondition: - * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' - * chiave secondaria nulla - * PreCondition: - * chiave_secondaria = null - * PostCondition: - * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public String getVal04(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { - try { - if (esercizio == null) esercizio = new Integer(0); - if (unita_funzionale == null) unita_funzionale = ASTERISCO; - if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); - if (bulk == null) return null; - return bulk.getVal04(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - /** - * Normale - * PreCondition: - * Viene richiesto il valore del campo val01 delle costanti cnr - * PostCondition: - * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null - */ - public String getVal04(UserContext userContext, String chiave_primaria) throws ComponentException { - try { - Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); - if (bulk == null) return null; - return bulk.getVal04(); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - - public Boolean isAttivoOrdini(UserContext userContext) throws ComponentException { - try { - Configurazione_cnrKey configurazioneCnrKey = new Configurazione_cnrKey( - Configurazione_cnrBulk.PK_ORDINI, - Configurazione_cnrBulk.SK_GESTIONE_ORDINI, - ASTERISCO, - CNRUserContext.getEsercizio(userContext)); - return findConfigurazioneOrdini(userContext, configurazioneCnrKey) - .orElseGet(() -> { - try { - return findConfigurazioneOrdini(userContext, configurazioneCnrKey.esercizio(0)) - .orElse(Boolean.FALSE); - } catch (PersistencyException|ComponentException e) { - throw new PersistencyError(e); - } - }); - } catch (PersistencyException e) { - throw handleException(e); - } - } - - private Optional findConfigurazioneOrdini(UserContext userContext, Configurazione_cnrKey configurazioneCnrKey) throws PersistencyException, ComponentException { - final BulkHome home = getHome(userContext, Configurazione_cnrBulk.class); - return Optional.ofNullable(home.findByPrimaryKey(configurazioneCnrKey)) - .filter(Configurazione_cnrBulk.class::isInstance) - .map(Configurazione_cnrBulk.class::cast) - .map(bulk -> Boolean.valueOf(bulk.getVal01())); - } - - public void shutdowHook(UserContext userContext) throws ComponentException { - logger.info("shutdow hook"); - final BulkHome home = getHome(userContext, Configurazione_cnrBulk.class); - try { - Configurazione_cnrBulk configurazione_cnrBulk = new Configurazione_cnrBulk( - Configurazione_cnrBulk.PK_EMAIL_PEC, - Configurazione_cnrBulk.SK_SDI, - ASTERISCO, - new Integer(0)); - Optional.ofNullable(home.findByPrimaryKey(configurazione_cnrBulk)) - .filter(Configurazione_cnrBulk.class::isInstance) - .map(Configurazione_cnrBulk.class::cast) - .filter(bulk -> bulk.getVal04().equalsIgnoreCase("Y")) - .ifPresent(bulk -> { - bulk.setVal04("N"); - bulk.setToBeUpdated(); - try { - home.update(bulk, userContext); - } catch (PersistencyException e) { - throw new RuntimeException(e); - } - }); - Configurazione_cnrBulk flussoOrdinativi = new Configurazione_cnrBulk( - Configurazione_cnrBulk.PK_FLUSSO_ORDINATIVI, - Configurazione_cnrBulk.SK_ATTIVO_SIOPEPLUS, - ASTERISCO, - LocalDateTime.now().getYear()); - Optional.ofNullable(home.findByPrimaryKey(flussoOrdinativi)) - .filter(Configurazione_cnrBulk.class::isInstance) - .map(Configurazione_cnrBulk.class::cast) - .filter(bulk -> bulk.getVal04().equalsIgnoreCase("Y")) - .ifPresent(bulk -> { - bulk.setVal04("N"); - bulk.setToBeUpdated(); - try { - home.update(bulk, userContext); - } catch (PersistencyException e) { - throw new RuntimeException(e); - } - }); - - } catch (PersistencyException e) { - throw handleException(e); - } - } -} +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package it.cnr.contab.config00.comp; + +import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; +import it.cnr.contab.config00.bulk.Configurazione_cnrKey; +import it.cnr.contab.utenze00.bp.CNRUserContext; +import it.cnr.jada.UserContext; +import it.cnr.jada.bulk.BulkHome; +import it.cnr.jada.comp.ComponentException; +import it.cnr.jada.persistency.PersistencyError; +import it.cnr.jada.persistency.PersistencyException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.util.Optional; + +public class Configurazione_cnrComponent extends it.cnr.jada.comp.GenericComponent implements IConfigurazione_cnrMgr, Cloneable, Serializable { + + private transient final static Logger logger = LoggerFactory.getLogger(Configurazione_cnrComponent.class); + + public static final String ASTERISCO = "*"; + + public Configurazione_cnrComponent() { + + /*Default constructor*/ + + + } + + /** + * esercizio nullo + * PreCondition: + * esercizio = null + * PostCondition: + * Effettua la ricerca usando la condizione SQL esercizio = '*' + * unita funzionale nulla + * PreCondition: + * unita_funzionale = null + * PostCondition: + * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' + * chiave secondaria nulla + * PreCondition: + * chiave_secondaria = null + * PostCondition: + * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' + * Normale + * PreCondition: + * Viene richiesto un istanza di Configurazioe_cnrBulk dalle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito un'istanza di Configurazione_cnrBulk o null se la ricerca non restituisce nulla + */ + public Configurazione_cnrBulk getConfigurazione(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { + try { + if (esercizio == null) esercizio = new Integer(0); + if (unita_funzionale == null) unita_funzionale = ASTERISCO; + if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; + return (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * esercizio nullo + * PreCondition: + * esercizio = null + * PostCondition: + * Effettua la ricerca usando la condizione SQL esercizio = '*' + * unita funzionale nulla + * PreCondition: + * unita_funzionale = null + * PostCondition: + * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' + * chiave secondaria nulla + * PreCondition: + * chiave_secondaria = null + * PostCondition: + * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public Timestamp getDt01(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { + try { + if (esercizio == null) esercizio = new Integer(0); + if (unita_funzionale == null) unita_funzionale = ASTERISCO; + if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); + if (bulk == null) return null; + return bulk.getDt01(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public Timestamp getDt01(UserContext userContext, String chiave_primaria) throws ComponentException { + try { + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); + if (bulk == null) return null; + return bulk.getDt01(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * esercizio nullo + * PreCondition: + * esercizio = null + * PostCondition: + * Effettua la ricerca usando la condizione SQL esercizio = '*' + * unita funzionale nulla + * PreCondition: + * unita_funzionale = null + * PostCondition: + * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' + * chiave secondaria nulla + * PreCondition: + * chiave_secondaria = null + * PostCondition: + * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public Timestamp getDt02(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { + try { + if (esercizio == null) esercizio = new Integer(0); + if (unita_funzionale == null) unita_funzionale = ASTERISCO; + if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); + if (bulk == null) return null; + return bulk.getDt02(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public Timestamp getDt02(UserContext userContext, String chiave_primaria) throws ComponentException { + try { + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); + if (bulk == null) return null; + return bulk.getDt02(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * esercizio nullo + * PreCondition: + * esercizio = null + * PostCondition: + * Effettua la ricerca usando la condizione SQL esercizio = '*' + * unita funzionale nulla + * PreCondition: + * unita_funzionale = null + * PostCondition: + * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' + * chiave secondaria nulla + * PreCondition: + * chiave_secondaria = null + * PostCondition: + * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public BigDecimal getIm01(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { + try { + if (esercizio == null) esercizio = new Integer(0); + if (unita_funzionale == null) unita_funzionale = ASTERISCO; + if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); + if (bulk == null) return null; + return bulk.getIm01(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public BigDecimal getIm01(UserContext userContext, String chiave_primaria) throws ComponentException { + try { + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); + if (bulk == null) return null; + return bulk.getIm01(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * esercizio nullo + * PreCondition: + * esercizio = null + * PostCondition: + * Effettua la ricerca usando la condizione SQL esercizio = '*' + * unita funzionale nulla + * PreCondition: + * unita_funzionale = null + * PostCondition: + * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' + * chiave secondaria nulla + * PreCondition: + * chiave_secondaria = null + * PostCondition: + * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public BigDecimal getIm02(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { + try { + if (esercizio == null) esercizio = new Integer(0); + if (unita_funzionale == null) unita_funzionale = ASTERISCO; + if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); + if (bulk == null) return null; + return bulk.getIm02(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public BigDecimal getIm02(UserContext userContext, String chiave_primaria) throws ComponentException { + try { + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); + if (bulk == null) return null; + return bulk.getIm02(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * esercizio nullo + * PreCondition: + * esercizio = null + * PostCondition: + * Effettua la ricerca usando la condizione SQL esercizio = '*' + * unita funzionale nulla + * PreCondition: + * unita_funzionale = null + * PostCondition: + * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' + * chiave secondaria nulla + * PreCondition: + * chiave_secondaria = null + * PostCondition: + * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public String getVal01(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { + try { + if (esercizio == null) esercizio = new Integer(0); + if (unita_funzionale == null) unita_funzionale = ASTERISCO; + if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); + if (bulk == null) return null; + return bulk.getVal01(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public String getVal01(UserContext userContext, String chiave_primaria) throws ComponentException { + try { + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); + if (bulk == null) return null; + return bulk.getVal01(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * esercizio nullo + * PreCondition: + * esercizio = null + * PostCondition: + * Effettua la ricerca usando la condizione SQL esercizio = '*' + * unita funzionale nulla + * PreCondition: + * unita_funzionale = null + * PostCondition: + * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' + * chiave secondaria nulla + * PreCondition: + * chiave_secondaria = null + * PostCondition: + * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public String getVal02(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { + try { + if (esercizio == null) esercizio = new Integer(0); + if (unita_funzionale == null) unita_funzionale = ASTERISCO; + if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); + if (bulk == null) return null; + return bulk.getVal02(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public String getVal02(UserContext userContext, String chiave_primaria) throws ComponentException { + try { + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); + if (bulk == null) return null; + return bulk.getVal02(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * esercizio nullo + * PreCondition: + * esercizio = null + * PostCondition: + * Effettua la ricerca usando la condizione SQL esercizio = '*' + * unita funzionale nulla + * PreCondition: + * unita_funzionale = null + * PostCondition: + * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' + * chiave secondaria nulla + * PreCondition: + * chiave_secondaria = null + * PostCondition: + * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public String getVal03(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { + try { + if (esercizio == null) esercizio = new Integer(0); + if (unita_funzionale == null) unita_funzionale = ASTERISCO; + if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); + if (bulk == null) return null; + return bulk.getVal03(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public String getVal03(UserContext userContext, String chiave_primaria) throws ComponentException { + try { + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); + if (bulk == null) return null; + return bulk.getVal03(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * esercizio nullo + * PreCondition: + * esercizio = null + * PostCondition: + * Effettua la ricerca usando la condizione SQL esercizio = '*' + * unita funzionale nulla + * PreCondition: + * unita_funzionale = null + * PostCondition: + * Effettua la ricerca con la codizione SQL cd_unita_funzionale = '*' + * chiave secondaria nulla + * PreCondition: + * chiave_secondaria = null + * PostCondition: + * Effettua la ricerca usando la clausola SQL chiave_secondaria = '*' + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public String getVal04(UserContext userContext, Integer esercizio, String unita_funzionale, String chiave_primaria, String chiave_secondaria) throws ComponentException { + try { + if (esercizio == null) esercizio = new Integer(0); + if (unita_funzionale == null) unita_funzionale = ASTERISCO; + if (chiave_secondaria == null) chiave_secondaria = ASTERISCO; + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, chiave_secondaria, unita_funzionale, esercizio)); + if (bulk == null) return null; + return bulk.getVal04(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + /** + * Normale + * PreCondition: + * Viene richiesto il valore del campo val01 delle costanti cnr + * PostCondition: + * Viene effettuata una ricerca sulla tabella CONFIGURAZIONE_CNR con le chiavi specificate e viene restituito il valore del campo; se non viene trovato nessun record restituisce null + */ + public String getVal04(UserContext userContext, String chiave_primaria) throws ComponentException { + try { + Configurazione_cnrBulk bulk = (Configurazione_cnrBulk) getHome(userContext, Configurazione_cnrBulk.class).findByPrimaryKey(new it.cnr.contab.config00.bulk.Configurazione_cnrKey(chiave_primaria, ASTERISCO, ASTERISCO, new Integer(0))); + if (bulk == null) return null; + return bulk.getVal04(); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + + public Boolean isAttivoOrdini(UserContext userContext) throws ComponentException { + try { + Configurazione_cnrKey configurazioneCnrKey = new Configurazione_cnrKey( + Configurazione_cnrBulk.PK_ORDINI, + Configurazione_cnrBulk.SK_GESTIONE_ORDINI, + ASTERISCO, + CNRUserContext.getEsercizio(userContext)); + return findConfigurazioneOrdini(userContext, configurazioneCnrKey) + .orElseGet(() -> { + try { + return findConfigurazioneOrdini(userContext, configurazioneCnrKey.esercizio(0)) + .orElse(Boolean.FALSE); + } catch (PersistencyException|ComponentException e) { + throw new PersistencyError(e); + } + }); + } catch (PersistencyException e) { + throw handleException(e); + } + } + + private Optional findConfigurazioneOrdini(UserContext userContext, Configurazione_cnrKey configurazioneCnrKey) throws PersistencyException, ComponentException { + final BulkHome home = getHome(userContext, Configurazione_cnrBulk.class); + return Optional.ofNullable(home.findByPrimaryKey(configurazioneCnrKey)) + .filter(Configurazione_cnrBulk.class::isInstance) + .map(Configurazione_cnrBulk.class::cast) + .map(bulk -> Boolean.valueOf(bulk.getVal01())); + } + + /** + * Ritorna il codice uo della Ragioneria + *

chiave_primaria: UO_SPECIALE + *

chiave_secondaria: UO_RAGIONERIA + * + * @param esercizio l'esercizio di ricerca - se non esistono configurazioni per l'esercizio indicato viene cercata la configurazione con esercizio=0 + * @return String - il codice uo della Ragioneria + * @throws ComponentException, PersistencyException + */ + public String getUoRagioneria(UserContext userContext, Integer esercizio) throws ComponentException { + try { + return ((Configurazione_cnrHome) getHome(userContext, Configurazione_cnrBulk.class)).getUoRagioneria(esercizio); + }catch (PersistencyException e){ + throw handleException(e); + } + } + + /** + * Ritorna il codice cdr del personale + *

chiave_primaria: ELEMENTO_VOCE_SPECIALE + *

chiave_secondaria: TEMPO_IND_SU_PROGETTI_FINANZIATI + * + * @param esercizio l'esercizio di ricerca - se non esistono configurazioni per l'esercizio indicato viene cercata la configurazione con esercizio=0 + * @return String - il codice cdr del personale + * @throws ComponentException + */ + public String getCdrPersonale(UserContext userContext, Integer esercizio) throws ComponentException { + try { + return ((Configurazione_cnrHome) getHome(userContext, Configurazione_cnrBulk.class)).getCdrPersonale(esercizio); + }catch (PersistencyException e){ + throw handleException(e); + } + } + + /** + * Ritorna il codice uo distinta tutta sac + *

chiave_primaria: UO_SPECIALE + *

chiave_secondaria: UO_DISTINTA_TUTTA_SAC + * + * @param esercizio l'esercizio di ricerca - se non esistono configurazioni per l'esercizio indicato viene cercata la configurazione con esercizio=0 + * @return String - il codice codice uo distinta tutta sac + * @throws PersistencyException + */ + public String getUoDistintaTuttaSac(UserContext userContext, Integer esercizio) throws ComponentException { + try { + return ((Configurazione_cnrHome)getHome(userContext, Configurazione_cnrBulk.class)).getUoDistintaTuttaSac(esercizio); + }catch (PersistencyException e){ + throw handleException(e); + } + } + + /** + * Indica se la uo indicata è proprio quella speciale tutta sac + * + * @param esercizio l'esercizio di ricerca - Lasciare vuoto per ricercare il parametro generale (esercizio=0). + * @param cdUnitaOrganizzativa l'unità organizzativa di cui si chiede se si tratta della Uo Speciale Tutta SAC + * @return Boolean + * @throws PersistencyException + */ + public Boolean isUOSpecialeDistintaTuttaSAC(UserContext userContext, Integer esercizio, String cdUnitaOrganizzativa) throws ComponentException { + try { + return ((Configurazione_cnrHome)getHome(userContext, Configurazione_cnrBulk.class)).isUOSpecialeDistintaTuttaSAC(esercizio,cdUnitaOrganizzativa); + }catch (PersistencyException e){ + throw handleException(e); + } + } + + public void shutdowHook(UserContext userContext) throws ComponentException { + logger.info("shutdow hook"); + final BulkHome home = getHome(userContext, Configurazione_cnrBulk.class); + try { + Configurazione_cnrBulk configurazione_cnrBulk = new Configurazione_cnrBulk( + Configurazione_cnrBulk.PK_EMAIL_PEC, + Configurazione_cnrBulk.SK_SDI, + ASTERISCO, + new Integer(0)); + Optional.ofNullable(home.findByPrimaryKey(configurazione_cnrBulk)) + .filter(Configurazione_cnrBulk.class::isInstance) + .map(Configurazione_cnrBulk.class::cast) + .filter(bulk -> bulk.getVal04().equalsIgnoreCase("Y")) + .ifPresent(bulk -> { + bulk.setVal04("N"); + bulk.setToBeUpdated(); + try { + home.update(bulk, userContext); + } catch (PersistencyException e) { + throw new RuntimeException(e); + } + }); + Configurazione_cnrBulk flussoOrdinativi = new Configurazione_cnrBulk( + Configurazione_cnrBulk.PK_FLUSSO_ORDINATIVI, + Configurazione_cnrBulk.SK_ATTIVO_SIOPEPLUS, + ASTERISCO, + LocalDateTime.now().getYear()); + Optional.ofNullable(home.findByPrimaryKey(flussoOrdinativi)) + .filter(Configurazione_cnrBulk.class::isInstance) + .map(Configurazione_cnrBulk.class::cast) + .filter(bulk -> bulk.getVal04().equalsIgnoreCase("Y")) + .ifPresent(bulk -> { + bulk.setVal04("N"); + bulk.setToBeUpdated(); + try { + home.update(bulk, userContext); + } catch (PersistencyException e) { + throw new RuntimeException(e); + } + }); + + } catch (PersistencyException e) { + throw handleException(e); + } + } +} diff --git a/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/Configurazione_cnrComponentSession.java b/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/Configurazione_cnrComponentSession.java index 1140ef5b3a..e1bcb0f72d 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/Configurazione_cnrComponentSession.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/Configurazione_cnrComponentSession.java @@ -1,59 +1,70 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package it.cnr.contab.config00.ejb; - -import javax.ejb.Remote; - -@Remote -public interface Configurazione_cnrComponentSession extends it.cnr.jada.ejb.GenericComponentSession { - it.cnr.contab.config00.bulk.Configurazione_cnrBulk getConfigurazione(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; - - java.lang.Boolean isAttivoOrdini(it.cnr.jada.UserContext param0) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; -} +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package it.cnr.contab.config00.ejb; + +import it.cnr.jada.UserContext; +import it.cnr.jada.comp.ComponentException; + +import javax.ejb.Remote; + +@Remote +public interface Configurazione_cnrComponentSession extends it.cnr.jada.ejb.GenericComponentSession { + it.cnr.contab.config00.bulk.Configurazione_cnrBulk getConfigurazione(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.Boolean isAttivoOrdini(it.cnr.jada.UserContext param0) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getCdrPersonale(it.cnr.jada.UserContext param0, java.lang.Integer param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getUoRagioneria(it.cnr.jada.UserContext param0, java.lang.Integer param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.String getUoDistintaTuttaSac(it.cnr.jada.UserContext param0, java.lang.Integer param1) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; + + java.lang.Boolean isUOSpecialeDistintaTuttaSAC(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2) throws it.cnr.jada.comp.ComponentException, java.rmi.RemoteException; +} \ No newline at end of file diff --git a/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/Configurazione_cnrComponentSessionBean.java b/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/Configurazione_cnrComponentSessionBean.java index c6bbef3dd0..39f92baef9 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/Configurazione_cnrComponentSessionBean.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/Configurazione_cnrComponentSessionBean.java @@ -1,424 +1,500 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package it.cnr.contab.config00.ejb; - -import it.cnr.contab.config00.comp.Configurazione_cnrComponent; -import it.cnr.jada.UserContext; -import it.cnr.jada.action.AdminUserContext; -import it.cnr.jada.comp.ComponentException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.ejb.EJBException; -import javax.ejb.Remove; -import javax.ejb.Stateless; -import java.util.UUID; - -@Stateless(name = "CNRCONFIG00_EJB_Configurazione_cnrComponentSession") -public class Configurazione_cnrComponentSessionBean extends it.cnr.jada.ejb.GenericComponentSessionBean implements Configurazione_cnrComponentSession { - private it.cnr.contab.config00.comp.Configurazione_cnrComponent componentObj; - private transient final static Logger logger = LoggerFactory.getLogger(Configurazione_cnrComponentSessionBean.class); - - public static Configurazione_cnrComponentSessionBean newInstance() throws EJBException { - return new Configurazione_cnrComponentSessionBean(); - } - - public void ejbActivate() throws EJBException { - } - - public void ejbPassivate() throws EJBException { - } - - @Remove - public void ejbRemove() throws EJBException { - try { - shutdowHook(); - } catch (ComponentException e) { - logger.error("ERROR while shutdow hook", e); - } - componentObj.release(); - } - - @PostConstruct - public void ejbCreate() { - componentObj = new it.cnr.contab.config00.comp.Configurazione_cnrComponent(); - } - - public void shutdowHook() throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException{ - UserContext param0 = new AdminUserContext(UUID.randomUUID().toString()); - pre_component_invocation(param0, componentObj); - try { - componentObj.shutdowHook(param0); - component_invocation_succes(param0, componentObj); - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public it.cnr.contab.config00.bulk.Configurazione_cnrBulk getConfigurazione(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - it.cnr.contab.config00.bulk.Configurazione_cnrBulk result = componentObj.getConfigurazione(param0, param1, param2, param3, param4); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.sql.Timestamp result = componentObj.getDt01(param0, param1, param2, param3, param4); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.sql.Timestamp result = componentObj.getDt01(param0, param1); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.sql.Timestamp result = componentObj.getDt02(param0, param1, param2, param3, param4); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.sql.Timestamp result = componentObj.getDt02(param0, param1); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.math.BigDecimal result = componentObj.getIm01(param0, param1, param2, param3, param4); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.math.BigDecimal result = componentObj.getIm01(param0, param1); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.math.BigDecimal result = componentObj.getIm02(param0, param1, param2, param3, param4); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.math.BigDecimal result = componentObj.getIm02(param0, param1); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.lang.String result = componentObj.getVal01(param0, param1, param2, param3, param4); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.lang.String result = componentObj.getVal01(param0, param1); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.lang.String result = componentObj.getVal02(param0, param1, param2, param3, param4); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.lang.String result = componentObj.getVal02(param0, param1); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.lang.String result = componentObj.getVal03(param0, param1, param2, param3, param4); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.lang.String result = componentObj.getVal03(param0, param1); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.lang.String result = componentObj.getVal04(param0, param1, param2, param3, param4); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.lang.String result = componentObj.getVal04(param0, param1); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } - - public Boolean isAttivoOrdini(UserContext param0) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { - pre_component_invocation(param0, componentObj); - try { - java.lang.Boolean result = componentObj.isAttivoOrdini(param0); - component_invocation_succes(param0, componentObj); - return result; - } catch (it.cnr.jada.comp.NoRollbackException e) { - component_invocation_succes(param0, componentObj); - throw e; - } catch (it.cnr.jada.comp.ComponentException e) { - component_invocation_failure(param0, componentObj); - throw e; - } catch (RuntimeException e) { - throw uncaughtRuntimeException(param0, componentObj, e); - } catch (Error e) { - throw uncaughtError(param0, componentObj, e); - } - } -} +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package it.cnr.contab.config00.ejb; + +import it.cnr.contab.config00.comp.Configurazione_cnrComponent; +import it.cnr.jada.UserContext; +import it.cnr.jada.action.AdminUserContext; +import it.cnr.jada.comp.ComponentException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.ejb.EJBException; +import javax.ejb.Remove; +import javax.ejb.Stateless; +import java.util.UUID; + +@Stateless(name = "CNRCONFIG00_EJB_Configurazione_cnrComponentSession") +public class Configurazione_cnrComponentSessionBean extends it.cnr.jada.ejb.GenericComponentSessionBean implements Configurazione_cnrComponentSession { + private it.cnr.contab.config00.comp.Configurazione_cnrComponent componentObj; + private transient final static Logger logger = LoggerFactory.getLogger(Configurazione_cnrComponentSessionBean.class); + + public static Configurazione_cnrComponentSessionBean newInstance() throws EJBException { + return new Configurazione_cnrComponentSessionBean(); + } + + public void ejbActivate() throws EJBException { + } + + public void ejbPassivate() throws EJBException { + } + + @Remove + public void ejbRemove() throws EJBException { + try { + shutdowHook(); + } catch (ComponentException e) { + logger.error("ERROR while shutdow hook", e); + } + componentObj.release(); + } + + @PostConstruct + public void ejbCreate() { + componentObj = new it.cnr.contab.config00.comp.Configurazione_cnrComponent(); + } + + public void shutdowHook() throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException{ + UserContext param0 = new AdminUserContext(UUID.randomUUID().toString()); + pre_component_invocation(param0, componentObj); + try { + componentObj.shutdowHook(param0); + component_invocation_succes(param0, componentObj); + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public it.cnr.contab.config00.bulk.Configurazione_cnrBulk getConfigurazione(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + it.cnr.contab.config00.bulk.Configurazione_cnrBulk result = componentObj.getConfigurazione(param0, param1, param2, param3, param4); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.sql.Timestamp result = componentObj.getDt01(param0, param1, param2, param3, param4); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.sql.Timestamp result = componentObj.getDt01(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.sql.Timestamp result = componentObj.getDt02(param0, param1, param2, param3, param4); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.sql.Timestamp result = componentObj.getDt02(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.math.BigDecimal result = componentObj.getIm01(param0, param1, param2, param3, param4); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.math.BigDecimal result = componentObj.getIm01(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.math.BigDecimal result = componentObj.getIm02(param0, param1, param2, param3, param4); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.math.BigDecimal result = componentObj.getIm02(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getVal01(param0, param1, param2, param3, param4); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getVal01(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getVal02(param0, param1, param2, param3, param4); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getVal02(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getVal03(param0, param1, param2, param3, param4); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getVal03(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getVal04(param0, param1, param2, param3, param4); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.String param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getVal04(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public Boolean isAttivoOrdini(UserContext param0) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.Boolean result = componentObj.isAttivoOrdini(param0); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getCdrPersonale(it.cnr.jada.UserContext param0, java.lang.Integer param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getCdrPersonale(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getUoRagioneria(it.cnr.jada.UserContext param0, java.lang.Integer param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getUoRagioneria(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public java.lang.String getUoDistintaTuttaSac(it.cnr.jada.UserContext param0, java.lang.Integer param1) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.String result = componentObj.getUoDistintaTuttaSac(param0, param1); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } + + public Boolean isUOSpecialeDistintaTuttaSAC(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2) throws it.cnr.jada.comp.ComponentException, javax.ejb.EJBException { + pre_component_invocation(param0, componentObj); + try { + java.lang.Boolean result = componentObj.isUOSpecialeDistintaTuttaSAC(param0,param1,param2); + component_invocation_succes(param0, componentObj); + return result; + } catch (it.cnr.jada.comp.NoRollbackException e) { + component_invocation_succes(param0, componentObj); + throw e; + } catch (it.cnr.jada.comp.ComponentException e) { + component_invocation_failure(param0, componentObj); + throw e; + } catch (RuntimeException e) { + throw uncaughtRuntimeException(param0, componentObj, e); + } catch (Error e) { + throw uncaughtError(param0, componentObj, e); + } + } +} \ No newline at end of file diff --git a/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/TransactionalConfigurazione_cnrComponentSession.java b/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/TransactionalConfigurazione_cnrComponentSession.java index 31fe635285..69ae264f16 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/TransactionalConfigurazione_cnrComponentSession.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/config00/ejb/TransactionalConfigurazione_cnrComponentSession.java @@ -1,372 +1,448 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package it.cnr.contab.config00.ejb; - -import java.rmi.RemoteException; - -public class TransactionalConfigurazione_cnrComponentSession extends it.cnr.jada.ejb.TransactionalCRUDComponentSession implements Configurazione_cnrComponentSession { - public it.cnr.contab.config00.bulk.Configurazione_cnrBulk getConfigurazione(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (it.cnr.contab.config00.bulk.Configurazione_cnrBulk) invoke("getConfigurazione", new Object[]{ - param0, - param1, - param2, - param3, - param4}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.sql.Timestamp) invoke("getDt01", new Object[]{ - param0, - param1, - param2, - param3, - param4}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.sql.Timestamp) invoke("getDt01", new Object[]{ - param0, - param1}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.sql.Timestamp) invoke("getDt02", new Object[]{ - param0, - param1, - param2, - param3, - param4}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.sql.Timestamp) invoke("getDt02", new Object[]{ - param0, - param1}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.math.BigDecimal) invoke("getIm01", new Object[]{ - param0, - param1, - param2, - param3, - param4}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.math.BigDecimal) invoke("getIm01", new Object[]{ - param0, - param1}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.math.BigDecimal) invoke("getIm02", new Object[]{ - param0, - param1, - param2, - param3, - param4}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.math.BigDecimal) invoke("getIm02", new Object[]{ - param0, - param1}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.lang.String) invoke("getVal01", new Object[]{ - param0, - param1, - param2, - param3, - param4}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.lang.String) invoke("getVal01", new Object[]{ - param0, - param1}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.lang.String) invoke("getVal02", new Object[]{ - param0, - param1, - param2, - param3, - param4}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.lang.String) invoke("getVal02", new Object[]{ - param0, - param1}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.lang.String) invoke("getVal03", new Object[]{ - param0, - param1, - param2, - param3, - param4}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.lang.String) invoke("getVal03", new Object[]{ - param0, - param1}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.lang.String) invoke("getVal04", new Object[]{ - param0, - param1, - param2, - param3, - param4}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.lang.String) invoke("getVal04", new Object[]{ - param0, - param1}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } - - public java.lang.Boolean isAttivoOrdini(it.cnr.jada.UserContext param0) throws RemoteException, it.cnr.jada.comp.ComponentException { - try { - return (java.lang.Boolean) invoke("isAttivoOrdini", new Object[]{ - param0}); - } catch (java.rmi.RemoteException e) { - throw e; - } catch (java.lang.reflect.InvocationTargetException e) { - try { - throw e.getTargetException(); - } catch (it.cnr.jada.comp.ComponentException ex) { - throw ex; - } catch (Throwable ex) { - throw new java.rmi.RemoteException("Uncaugth exception", ex); - } - } - } -} +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package it.cnr.contab.config00.ejb; + +import it.cnr.jada.UserContext; +import it.cnr.jada.comp.ComponentException; + +import java.rmi.RemoteException; + +public class TransactionalConfigurazione_cnrComponentSession extends it.cnr.jada.ejb.TransactionalCRUDComponentSession implements Configurazione_cnrComponentSession { + public it.cnr.contab.config00.bulk.Configurazione_cnrBulk getConfigurazione(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (it.cnr.contab.config00.bulk.Configurazione_cnrBulk) invoke("getConfigurazione", new Object[]{ + param0, + param1, + param2, + param3, + param4}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.sql.Timestamp) invoke("getDt01", new Object[]{ + param0, + param1, + param2, + param3, + param4}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.sql.Timestamp getDt01(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.sql.Timestamp) invoke("getDt01", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.sql.Timestamp) invoke("getDt02", new Object[]{ + param0, + param1, + param2, + param3, + param4}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.sql.Timestamp getDt02(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.sql.Timestamp) invoke("getDt02", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.math.BigDecimal) invoke("getIm01", new Object[]{ + param0, + param1, + param2, + param3, + param4}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.math.BigDecimal getIm01(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.math.BigDecimal) invoke("getIm01", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.math.BigDecimal) invoke("getIm02", new Object[]{ + param0, + param1, + param2, + param3, + param4}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.math.BigDecimal getIm02(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.math.BigDecimal) invoke("getIm02", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getVal01", new Object[]{ + param0, + param1, + param2, + param3, + param4}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getVal01(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getVal01", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getVal02", new Object[]{ + param0, + param1, + param2, + param3, + param4}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getVal02(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getVal02", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getVal03", new Object[]{ + param0, + param1, + param2, + param3, + param4}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getVal03(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getVal03", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2, java.lang.String param3, java.lang.String param4) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getVal04", new Object[]{ + param0, + param1, + param2, + param3, + param4}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getVal04(it.cnr.jada.UserContext param0, java.lang.String param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getVal04", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.Boolean isAttivoOrdini(it.cnr.jada.UserContext param0) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.Boolean) invoke("isAttivoOrdini", new Object[]{ + param0}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getCdrPersonale(it.cnr.jada.UserContext param0, java.lang.Integer param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getCdrPersonale", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getUoRagioneria(it.cnr.jada.UserContext param0, java.lang.Integer param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getUoRagioneria", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.String getUoDistintaTuttaSac(it.cnr.jada.UserContext param0, java.lang.Integer param1) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.String) invoke("getUoDistintaTuttaSac", new Object[]{ + param0, + param1}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } + + public java.lang.Boolean isUOSpecialeDistintaTuttaSAC(it.cnr.jada.UserContext param0, java.lang.Integer param1, java.lang.String param2) throws RemoteException, it.cnr.jada.comp.ComponentException { + try { + return (java.lang.Boolean) invoke("isUOSpecialeDistintaTuttaSAC", new Object[]{ + param0, + param1, + param2}); + } catch (java.rmi.RemoteException e) { + throw e; + } catch (java.lang.reflect.InvocationTargetException e) { + try { + throw e.getTargetException(); + } catch (it.cnr.jada.comp.ComponentException ex) { + throw ex; + } catch (Throwable ex) { + throw new java.rmi.RemoteException("Uncaugth exception", ex); + } + } + } +} diff --git a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/bp/CRUDDistintaCassiereBP.java b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/bp/CRUDDistintaCassiereBP.java index ea71fb0269..81c92122a3 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/bp/CRUDDistintaCassiereBP.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/bp/CRUDDistintaCassiereBP.java @@ -1,2415 +1,2409 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package it.cnr.contab.doccont00.bp; - -import it.cnr.contab.anagraf00.core.bulk.AnagraficoBulk; -import it.cnr.contab.anagraf00.core.bulk.BancaBulk; -import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; -import it.cnr.contab.config00.bulk.Parametri_cnrBulk; -import it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession; -import it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk; -import it.cnr.contab.cori00.ejb.Liquid_coriComponentSession; -import it.cnr.contab.doccont00.comp.DateServices; -import it.cnr.contab.doccont00.core.bulk.MandatoBulk; -import it.cnr.contab.doccont00.core.bulk.ReversaleBulk; -import it.cnr.contab.doccont00.ejb.DistintaCassiereComponentSession; -import it.cnr.contab.doccont00.intcass.bulk.Distinta_cassiereBulk; -import it.cnr.contab.doccont00.intcass.bulk.StatoTrasmissione; -import it.cnr.contab.doccont00.intcass.bulk.VDocumentiFlussoBulk; -import it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk; -import it.cnr.contab.doccont00.intcass.xmlbnl.FlussoOrdinativi; -import it.cnr.contab.doccont00.intcass.xmlbnl.Mandato; -import it.cnr.contab.doccont00.intcass.xmlbnl.Mandato.InformazioniBeneficiario.Classificazione; -import it.cnr.contab.doccont00.intcass.xmlbnl.ObjectFactory; -import it.cnr.contab.doccont00.intcass.xmlbnl.Reversale; -import it.cnr.contab.doccont00.service.DocumentiContabiliService; -import it.cnr.contab.firma.bulk.FirmaOTPBulk; -import it.cnr.contab.reports.bp.OfflineReportPrintBP; -import it.cnr.contab.reports.bulk.Print_spoolerBulk; -import it.cnr.contab.reports.bulk.Print_spooler_paramBulk; -import it.cnr.contab.reports.bulk.Report; -import it.cnr.contab.reports.service.PrintService; -import it.cnr.contab.service.SpringUtil; -import it.cnr.contab.utente00.ejb.UtenteComponentSession; -import it.cnr.contab.utenze00.bp.CNRUserContext; -import it.cnr.contab.utenze00.bulk.AbilitatoFirma; -import it.cnr.contab.utenze00.bulk.CNRUserInfo; -import it.cnr.contab.utenze00.bulk.UtenteFirmaDettaglioBulk; -import it.cnr.contab.util.*; -import it.cnr.contab.util00.bp.AllegatiCRUDBP; -import it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk; -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.OggettoBulk; -import it.cnr.jada.comp.ApplicationException; -import it.cnr.jada.comp.ComponentException; -import it.cnr.jada.ejb.CRUDComponentSession; -import it.cnr.jada.persistency.sql.CompoundFindClause; -import it.cnr.jada.util.RemoteIterator; -import it.cnr.jada.util.action.AbstractPrintBP; -import it.cnr.jada.util.action.RemoteDetailCRUDController; -import it.cnr.jada.util.ejb.EJBCommonServices; -import it.cnr.jada.util.jsp.Button; -import it.cnr.jada.util.jsp.JSPUtils; -import it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceClient; -import it.cnr.si.firmadigitale.firma.arss.ArubaSignServiceException; -import it.cnr.si.firmadigitale.firma.arss.stub.XmlSignatureType; -import it.cnr.si.siopeplus.exception.SIOPEPlusServiceUnavailable; -import it.cnr.si.siopeplus.model.Risultato; -import it.cnr.si.siopeplus.service.OrdinativiSiopePlusService; -import it.cnr.si.spring.storage.MimeTypes; -import it.cnr.si.spring.storage.StorageException; -import it.cnr.si.spring.storage.StorageObject; -import it.cnr.si.spring.storage.StorageService; -import it.cnr.si.spring.storage.bulk.StorageFile; -import it.cnr.si.spring.storage.config.StoragePropertyNames; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xml.sax.SAXException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.jsp.PageContext; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; -import javax.xml.datatype.DatatypeConstants; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; -import java.io.*; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.rmi.RemoteException; -import java.text.Format; -import java.text.SimpleDateFormat; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Collectors; - -/** - * Business Process che gestisce le attività di CRUD per l'entita' Distinta - * Cassiere - * - * @version 1.1 by Aurelio D'Amico [08/11/2006] conversione stampa Crystal in - * Jasper Reports - */ -public class CRUDDistintaCassiereBP extends AllegatiCRUDBP { - private transient final static Logger logger = LoggerFactory.getLogger(CRUDDistintaCassiereBP.class); - private static final DateTimeFormatter formatterDate = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - private static final DateTimeFormatter formatterTime = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"); - private final RemoteDetailCRUDController distintaCassDet = new RemoteDetailCRUDController( - "DistintaCassDet", - it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk.class, - "distinta_cassiere_detColl", - "CNRDOCCONT00_EJB_DistintaCassiereComponentSession", this); - private final RemoteDetailCRUDController distinteCassCollegateDet = new RemoteDetailCRUDController( - "DistinteCassCollegateDet", - it.cnr.contab.doccont00.intcass.bulk.V_mandato_reversaleBulk.class, - "distinte_cassiere_detCollegateColl", - "CNRDOCCONT00_EJB_DistintaCassiereComponentSession", this); - public boolean elencoConUo; - public Boolean flusso; - public Boolean sepa; - public Boolean annulli; - protected DocumentiContabiliService documentiContabiliService; - protected OrdinativiSiopePlusService ordinativiSiopePlusService; - protected String controlloCodiceFiscale; - protected String tagCup; - protected String formatoflusso; - private Parametri_cnrBulk parametriCnr; - private boolean attivoSiopeplus; - private String file; - private Unita_organizzativaBulk uoSrivania; - private UtenteFirmaDettaglioBulk firmatarioDistinta; - - public CRUDDistintaCassiereBP() { - super("Tn"); - - } - - public CRUDDistintaCassiereBP(String function) { - super(function + "Tn"); - - } - - protected it.cnr.jada.util.jsp.Button[] createToolbar() { - Button[] toolbar = super.createToolbar(); - List"); - } - } - } catch (ApplicationException e) { - } - return super.completeBulkRowByRow(userContext, persistent); - } - - public SQLBuilder selectByClauseForNonAcqisiti(UserContext usercontext, V_cons_stato_invio_mandatiBulk v_cons_stato_invio_mandatiBulk, - CompoundFindClause compoundfindclause) throws PersistencyException { - SQLBuilder sqlBuilder = createSQLBuilder(); - if (compoundfindclause == null) { - if (v_cons_stato_invio_mandatiBulk != null) - compoundfindclause = v_cons_stato_invio_mandatiBulk.buildFindClauses(null); - } else { - compoundfindclause = CompoundFindClause.and(compoundfindclause, v_cons_stato_invio_mandatiBulk.buildFindClauses(Boolean.FALSE)); - } - sqlBuilder.addClause(compoundfindclause); - Configurazione_cnrHome configurazione_cnrHome = Optional.ofNullable(getHomeCache().getHome(Configurazione_cnrBulk.class)) - .filter(Configurazione_cnrHome.class::isInstance) - .map(Configurazione_cnrHome.class::cast) - .orElseThrow(() -> new PersistenceException("Home Configurazione_cnrHome non trovata!")); - Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHomeCache().getHome(Unita_organizzativa_enteBulk.class).findAll().get(0); - // Se uo 999.000 in scrivania: visualizza tutto l'elenco e se uo speciale - if (!((CNRUserContext) usercontext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa()) && - !configurazione_cnrHome.isUOSpecialeTuttaSAC(CNRUserContext.getCd_unita_organizzativa(usercontext))){ - sqlBuilder.addSQLClause("AND","CD_CDS",SQLBuilder.EQUALS,CNRUserContext.getCd_cds(usercontext)); - } - sqlBuilder.addClause(FindClause.AND, "esercizio", SQLBuilder.EQUALS, CNRUserContext.getEsercizio(usercontext)); - sqlBuilder.addClause(FindClause.AND, "esitoOperazione", SQLBuilder.EQUALS, EsitoOperazione.NON_ACQUISITO.value()); - sqlBuilder.addClause(FindClause.AND, "stato", SQLBuilder.NOT_EQUALS, MandatoBulk.STATO_MANDATO_ANNULLATO); - return sqlBuilder; - } +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* +* Created by Generator 1.0 +* Date 17/03/2006 +*/ +package it.cnr.contab.doccont00.consultazioni.bulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; +import it.cnr.contab.config00.sto.bulk.Unita_organizzativa_enteBulk; +import it.cnr.contab.doccont00.core.bulk.MandatoBulk; +import it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk; +import it.cnr.contab.doccont00.service.ContabiliService; +import it.cnr.contab.service.SpringUtil; +import it.cnr.contab.utenze00.bp.CNRUserContext; +import it.cnr.contab.util.enumeration.EsitoOperazione; +import it.cnr.jada.UserContext; +import it.cnr.jada.bulk.BulkHome; +import it.cnr.jada.comp.ApplicationException; +import it.cnr.jada.persistency.PersistencyException; +import it.cnr.jada.persistency.Persistent; +import it.cnr.jada.persistency.PersistentCache; +import it.cnr.jada.persistency.sql.CompoundFindClause; +import it.cnr.jada.persistency.sql.FindClause; +import it.cnr.jada.persistency.sql.SQLBuilder; + +import javax.persistence.PersistenceException; +import java.util.List; +import java.util.Optional; + +public class V_cons_stato_invio_mandatiHome extends BulkHome { + + private static final long serialVersionUID = 1L; + private ContabiliService contabiliService; + + public V_cons_stato_invio_mandatiHome(java.sql.Connection conn) { + super(V_cons_stato_invio_mandatiBulk.class, conn); + contabiliService = SpringUtil.getBean("contabiliService", + ContabiliService.class); + } + public V_cons_stato_invio_mandatiHome(java.sql.Connection conn, PersistentCache persistentCache) { + super(V_cons_stato_invio_mandatiBulk.class, conn, persistentCache); + contabiliService = SpringUtil.getBean("contabiliService", + ContabiliService.class); + } + + public SQLBuilder selectByClause(UserContext usercontext, CompoundFindClause compoundfindclause) throws PersistencyException + { + Configurazione_cnrHome configurazione_cnrHome = Optional.ofNullable(getHomeCache().getHome(Configurazione_cnrBulk.class)) + .filter(Configurazione_cnrHome.class::isInstance) + .map(Configurazione_cnrHome.class::cast) + .orElseThrow(() -> new PersistenceException("Home Configurazione_cnrHome non trovata!")); + + SQLBuilder sql = super.selectByClause(usercontext, compoundfindclause); + sql.addSQLClause("AND","ESERCIZIO",SQLBuilder.EQUALS,CNRUserContext.getEsercizio(usercontext)); + Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHomeCache().getHome(Unita_organizzativa_enteBulk.class).findAll().get(0); + // Se uo 999.000 in scrivania: visualizza tutto l'elenco e se uo speciale + if (!((CNRUserContext) usercontext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa()) && + !configurazione_cnrHome.isUOSpecialeDistintaTuttaSAC(CNRUserContext.getEsercizio(usercontext),CNRUserContext.getCd_unita_organizzativa(usercontext))){ + sql.addSQLClause("AND","CD_CDS",SQLBuilder.EQUALS,CNRUserContext.getCd_cds(usercontext)); + } + return sql; + } + @Override + public Persistent completeBulkRowByRow(UserContext userContext, + Persistent persistent) throws PersistencyException { + V_cons_stato_invio_mandatiBulk cons = (V_cons_stato_invio_mandatiBulk)persistent; + List nodeRefs; + try { + nodeRefs = contabiliService.getNodeRefContabile(cons.getEsercizio().intValue(), cons.getCd_cds(), cons.getPg_mandato(), Numerazione_doc_contBulk.TIPO_MAN); + if (nodeRefs != null && !nodeRefs.isEmpty()){ + if (((CNRUserContext) userContext).isFromBootstrap()) { + cons.setContabile(""); + } else { + cons.setContabile(""); + } + } + } catch (ApplicationException e) { + } + return super.completeBulkRowByRow(userContext, persistent); + } + + public SQLBuilder selectByClauseForNonAcqisiti(UserContext usercontext, V_cons_stato_invio_mandatiBulk v_cons_stato_invio_mandatiBulk, + CompoundFindClause compoundfindclause) throws PersistencyException { + SQLBuilder sqlBuilder = createSQLBuilder(); + if (compoundfindclause == null) { + if (v_cons_stato_invio_mandatiBulk != null) + compoundfindclause = v_cons_stato_invio_mandatiBulk.buildFindClauses(null); + } else { + compoundfindclause = CompoundFindClause.and(compoundfindclause, v_cons_stato_invio_mandatiBulk.buildFindClauses(Boolean.FALSE)); + } + sqlBuilder.addClause(compoundfindclause); + Configurazione_cnrHome configurazione_cnrHome = Optional.ofNullable(getHomeCache().getHome(Configurazione_cnrBulk.class)) + .filter(Configurazione_cnrHome.class::isInstance) + .map(Configurazione_cnrHome.class::cast) + .orElseThrow(() -> new PersistenceException("Home Configurazione_cnrHome non trovata!")); + Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHomeCache().getHome(Unita_organizzativa_enteBulk.class).findAll().get(0); + // Se uo 999.000 in scrivania: visualizza tutto l'elenco e se uo speciale + if (!((CNRUserContext) usercontext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa()) && + !configurazione_cnrHome.isUOSpecialeDistintaTuttaSAC(CNRUserContext.getEsercizio(usercontext),CNRUserContext.getCd_unita_organizzativa(usercontext))){ + sqlBuilder.addSQLClause(FindClause.AND,"CD_CDS",SQLBuilder.EQUALS,CNRUserContext.getCd_cds(usercontext)); + } + sqlBuilder.addClause(FindClause.AND, "esercizio", SQLBuilder.EQUALS, CNRUserContext.getEsercizio(usercontext)); + sqlBuilder.addClause(FindClause.AND, "esitoOperazione", SQLBuilder.EQUALS, EsitoOperazione.NON_ACQUISITO.value()); + sqlBuilder.addClause(FindClause.AND, "stato", SQLBuilder.NOT_EQUALS, MandatoBulk.STATO_MANDATO_ANNULLATO); + return sqlBuilder; + } } \ No newline at end of file diff --git a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/consultazioni/bulk/V_cons_stato_invio_reversaliHome.java b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/consultazioni/bulk/V_cons_stato_invio_reversaliHome.java index c3aefc660f..39ebd54a5f 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/consultazioni/bulk/V_cons_stato_invio_reversaliHome.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/consultazioni/bulk/V_cons_stato_invio_reversaliHome.java @@ -1,127 +1,127 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -/* -* Created by Generator 1.0 -* Date 27/04/2006 -*/ -package it.cnr.contab.doccont00.consultazioni.bulk; -import java.util.List; -import java.util.Optional; - -import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; -import it.cnr.contab.config00.bulk.Configurazione_cnrHome; -import it.cnr.contab.config00.sto.bulk.Unita_organizzativa_enteBulk; -import it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk; -import it.cnr.contab.doccont00.core.bulk.ReversaleBulk; -import it.cnr.contab.doccont00.service.ContabiliService; -import it.cnr.contab.service.SpringUtil; -import it.cnr.contab.utenze00.bp.CNRUserContext; -import it.cnr.contab.util.enumeration.EsitoOperazione; -import it.cnr.jada.UserContext; -import it.cnr.jada.bulk.BulkHome; -import it.cnr.jada.comp.ApplicationException; -import it.cnr.jada.persistency.PersistencyException; -import it.cnr.jada.persistency.Persistent; -import it.cnr.jada.persistency.PersistentCache; -import it.cnr.jada.persistency.sql.CompoundFindClause; -import it.cnr.jada.persistency.sql.FindClause; -import it.cnr.jada.persistency.sql.SQLBuilder; - -import javax.persistence.PersistenceException; - -public class V_cons_stato_invio_reversaliHome extends BulkHome { - private ContabiliService contabiliService; - - public V_cons_stato_invio_reversaliHome(java.sql.Connection conn) { - super(V_cons_stato_invio_reversaliBulk.class, conn); - contabiliService = SpringUtil.getBean("contabiliService", - ContabiliService.class); - } - public V_cons_stato_invio_reversaliHome(java.sql.Connection conn, PersistentCache persistentCache) { - super(V_cons_stato_invio_reversaliBulk.class, conn, persistentCache); - contabiliService = SpringUtil.getBean("contabiliService", - ContabiliService.class); - } - public SQLBuilder selectByClause(UserContext usercontext, CompoundFindClause compoundfindclause) throws PersistencyException - { - Configurazione_cnrHome configurazione_cnrHome = Optional.ofNullable(getHomeCache().getHome(Configurazione_cnrBulk.class)) - .filter(Configurazione_cnrHome.class::isInstance) - .map(Configurazione_cnrHome.class::cast) - .orElseThrow(() -> new PersistenceException("Home Configurazione_cnrHome non trovata!")); - - SQLBuilder sql = super.selectByClause(usercontext, compoundfindclause); - sql.addSQLClause("AND","ESERCIZIO",sql.EQUALS,CNRUserContext.getEsercizio(usercontext)); - Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHomeCache().getHome(Unita_organizzativa_enteBulk.class).findAll().get(0); - // Se uo 999.000 in scrivania: visualizza tutto l'elenco - if (!((CNRUserContext) usercontext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa()) && - !configurazione_cnrHome.isUOSpecialeTuttaSAC(CNRUserContext.getCd_unita_organizzativa(usercontext))){ - sql.addSQLClause("AND","CD_CDS",SQLBuilder.EQUALS,CNRUserContext.getCd_cds(usercontext)); - } - return sql; - } - @Override - public Persistent completeBulkRowByRow(UserContext userContext, - Persistent persistent) throws PersistencyException { - V_cons_stato_invio_reversaliBulk cons = (V_cons_stato_invio_reversaliBulk)persistent; - List nodeRefs; - try { - nodeRefs = contabiliService.getNodeRefContabile(cons.getEsercizio().intValue(), cons.getCd_cds(), cons.getPg_reversale(), Numerazione_doc_contBulk.TIPO_REV); - if (nodeRefs != null && !nodeRefs.isEmpty()){ - if (((CNRUserContext) userContext).isFromBootstrap()) { - cons.setContabile(""); - } else { - cons.setContabile(""); - } - } - } catch (ApplicationException e) { - } - return super.completeBulkRowByRow(userContext, persistent); - } - - - public SQLBuilder selectByClauseForNonAcqisiti(UserContext usercontext, V_cons_stato_invio_reversaliBulk v_cons_stato_invio_reversaliBulk, - CompoundFindClause compoundfindclause) throws PersistencyException { - SQLBuilder sqlBuilder = createSQLBuilder(); - if (compoundfindclause == null) { - if (v_cons_stato_invio_reversaliBulk != null) - compoundfindclause = v_cons_stato_invio_reversaliBulk.buildFindClauses(null); - } else { - compoundfindclause = CompoundFindClause.and(compoundfindclause, v_cons_stato_invio_reversaliBulk.buildFindClauses(Boolean.FALSE)); - } - sqlBuilder.addClause(compoundfindclause); - Configurazione_cnrHome configurazione_cnrHome = Optional.ofNullable(getHomeCache().getHome(Configurazione_cnrBulk.class)) - .filter(Configurazione_cnrHome.class::isInstance) - .map(Configurazione_cnrHome.class::cast) - .orElseThrow(() -> new PersistenceException("Home Configurazione_cnrHome non trovata!")); - Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHomeCache().getHome(Unita_organizzativa_enteBulk.class).findAll().get(0); - // Se uo 999.000 in scrivania: visualizza tutto l'elenco e se uo speciale - if (!((CNRUserContext) usercontext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa()) && - !configurazione_cnrHome.isUOSpecialeTuttaSAC(CNRUserContext.getCd_unita_organizzativa(usercontext))){ - sqlBuilder.addSQLClause("AND","CD_CDS",SQLBuilder.EQUALS,CNRUserContext.getCd_cds(usercontext)); - } - sqlBuilder.addClause(FindClause.AND, "esercizio", SQLBuilder.EQUALS, CNRUserContext.getEsercizio(usercontext)); - sqlBuilder.addClause(FindClause.AND, "esitoOperazione", SQLBuilder.EQUALS, EsitoOperazione.NON_ACQUISITO.value()); - sqlBuilder.addClause(FindClause.AND, "stato", SQLBuilder.NOT_EQUALS, ReversaleBulk.STATO_REVERSALE_ANNULLATO); - return sqlBuilder; - } +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* +* Created by Generator 1.0 +* Date 27/04/2006 +*/ +package it.cnr.contab.doccont00.consultazioni.bulk; +import java.util.List; +import java.util.Optional; + +import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; +import it.cnr.contab.config00.sto.bulk.Unita_organizzativa_enteBulk; +import it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk; +import it.cnr.contab.doccont00.core.bulk.ReversaleBulk; +import it.cnr.contab.doccont00.service.ContabiliService; +import it.cnr.contab.service.SpringUtil; +import it.cnr.contab.utenze00.bp.CNRUserContext; +import it.cnr.contab.util.enumeration.EsitoOperazione; +import it.cnr.jada.UserContext; +import it.cnr.jada.bulk.BulkHome; +import it.cnr.jada.comp.ApplicationException; +import it.cnr.jada.persistency.PersistencyException; +import it.cnr.jada.persistency.Persistent; +import it.cnr.jada.persistency.PersistentCache; +import it.cnr.jada.persistency.sql.CompoundFindClause; +import it.cnr.jada.persistency.sql.FindClause; +import it.cnr.jada.persistency.sql.SQLBuilder; + +import javax.persistence.PersistenceException; + +public class V_cons_stato_invio_reversaliHome extends BulkHome { + private ContabiliService contabiliService; + + public V_cons_stato_invio_reversaliHome(java.sql.Connection conn) { + super(V_cons_stato_invio_reversaliBulk.class, conn); + contabiliService = SpringUtil.getBean("contabiliService", + ContabiliService.class); + } + public V_cons_stato_invio_reversaliHome(java.sql.Connection conn, PersistentCache persistentCache) { + super(V_cons_stato_invio_reversaliBulk.class, conn, persistentCache); + contabiliService = SpringUtil.getBean("contabiliService", + ContabiliService.class); + } + public SQLBuilder selectByClause(UserContext usercontext, CompoundFindClause compoundfindclause) throws PersistencyException + { + Configurazione_cnrHome configurazione_cnrHome = Optional.ofNullable(getHomeCache().getHome(Configurazione_cnrBulk.class)) + .filter(Configurazione_cnrHome.class::isInstance) + .map(Configurazione_cnrHome.class::cast) + .orElseThrow(() -> new PersistenceException("Home Configurazione_cnrHome non trovata!")); + + SQLBuilder sql = super.selectByClause(usercontext, compoundfindclause); + sql.addSQLClause(FindClause.AND,"ESERCIZIO",SQLBuilder.EQUALS,CNRUserContext.getEsercizio(usercontext)); + Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHomeCache().getHome(Unita_organizzativa_enteBulk.class).findAll().get(0); + // Se uo 999.000 in scrivania: visualizza tutto l'elenco + if (!((CNRUserContext) usercontext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa()) && + !configurazione_cnrHome.isUOSpecialeDistintaTuttaSAC(CNRUserContext.getEsercizio(usercontext),CNRUserContext.getCd_unita_organizzativa(usercontext))){ + sql.addSQLClause(FindClause.AND,"CD_CDS",SQLBuilder.EQUALS,CNRUserContext.getCd_cds(usercontext)); + } + return sql; + } + @Override + public Persistent completeBulkRowByRow(UserContext userContext, + Persistent persistent) throws PersistencyException { + V_cons_stato_invio_reversaliBulk cons = (V_cons_stato_invio_reversaliBulk)persistent; + List nodeRefs; + try { + nodeRefs = contabiliService.getNodeRefContabile(cons.getEsercizio().intValue(), cons.getCd_cds(), cons.getPg_reversale(), Numerazione_doc_contBulk.TIPO_REV); + if (nodeRefs != null && !nodeRefs.isEmpty()){ + if (((CNRUserContext) userContext).isFromBootstrap()) { + cons.setContabile(""); + } else { + cons.setContabile(""); + } + } + } catch (ApplicationException e) { + } + return super.completeBulkRowByRow(userContext, persistent); + } + + + public SQLBuilder selectByClauseForNonAcqisiti(UserContext usercontext, V_cons_stato_invio_reversaliBulk v_cons_stato_invio_reversaliBulk, + CompoundFindClause compoundfindclause) throws PersistencyException { + SQLBuilder sqlBuilder = createSQLBuilder(); + if (compoundfindclause == null) { + if (v_cons_stato_invio_reversaliBulk != null) + compoundfindclause = v_cons_stato_invio_reversaliBulk.buildFindClauses(null); + } else { + compoundfindclause = CompoundFindClause.and(compoundfindclause, v_cons_stato_invio_reversaliBulk.buildFindClauses(Boolean.FALSE)); + } + sqlBuilder.addClause(compoundfindclause); + Configurazione_cnrHome configurazione_cnrHome = Optional.ofNullable(getHomeCache().getHome(Configurazione_cnrBulk.class)) + .filter(Configurazione_cnrHome.class::isInstance) + .map(Configurazione_cnrHome.class::cast) + .orElseThrow(() -> new PersistenceException("Home Configurazione_cnrHome non trovata!")); + Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHomeCache().getHome(Unita_organizzativa_enteBulk.class).findAll().get(0); + // Se uo 999.000 in scrivania: visualizza tutto l'elenco e se uo speciale + if (!((CNRUserContext) usercontext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa()) && + !configurazione_cnrHome.isUOSpecialeDistintaTuttaSAC(CNRUserContext.getEsercizio(usercontext),CNRUserContext.getCd_unita_organizzativa(usercontext))){ + sqlBuilder.addSQLClause(FindClause.AND,"CD_CDS",SQLBuilder.EQUALS,CNRUserContext.getCd_cds(usercontext)); + } + sqlBuilder.addClause(FindClause.AND, "esercizio", SQLBuilder.EQUALS, CNRUserContext.getEsercizio(usercontext)); + sqlBuilder.addClause(FindClause.AND, "esitoOperazione", SQLBuilder.EQUALS, EsitoOperazione.NON_ACQUISITO.value()); + sqlBuilder.addClause(FindClause.AND, "stato", SQLBuilder.NOT_EQUALS, ReversaleBulk.STATO_REVERSALE_ANNULLATO); + return sqlBuilder; + } } \ No newline at end of file diff --git a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/core/bulk/ObbligazioneHome.java b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/core/bulk/ObbligazioneHome.java index 47029b76ca..54c5286414 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/core/bulk/ObbligazioneHome.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/core/bulk/ObbligazioneHome.java @@ -1,1785 +1,1776 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package it.cnr.contab.doccont00.core.bulk; - -import java.math.BigDecimal; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import it.cnr.contab.anagraf00.core.bulk.AnagraficoBulk; -import it.cnr.contab.anagraf00.core.bulk.TerzoBulk; -import it.cnr.contab.anagraf00.core.bulk.TerzoHome; -import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; -import it.cnr.contab.config00.bulk.Parametri_cnrBulk; -import it.cnr.contab.config00.latt.bulk.WorkpackageBulk; -import it.cnr.contab.config00.pdcfin.bulk.Elemento_voceBulk; -import it.cnr.contab.config00.pdcfin.bulk.Elemento_voceHome; -import it.cnr.contab.config00.pdcfin.bulk.IVoceBilancioBulk; -import it.cnr.contab.config00.pdcfin.bulk.Voce_fBulk; -import it.cnr.contab.config00.sto.bulk.CdrBulk; -import it.cnr.contab.config00.sto.bulk.CdsBulk; -import it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome; -import it.cnr.contab.doccont00.ejb.NumTempDocContComponentSession; -import it.cnr.contab.pdg00.bulk.Pdg_preventivo_detBulk; -import it.cnr.contab.pdg01.bulk.Pdg_modulo_spese_gestBulk; -import it.cnr.jada.UserContext; -import it.cnr.jada.bulk.BulkHome; -import it.cnr.jada.bulk.BulkList; -import it.cnr.jada.bulk.OggettoBulk; -import it.cnr.jada.comp.ApplicationException; -import it.cnr.jada.comp.ComponentException; -import it.cnr.jada.persistency.IntrospectionException; -import it.cnr.jada.persistency.PersistencyException; -import it.cnr.jada.persistency.PersistentCache; -import it.cnr.jada.persistency.sql.CompoundFindClause; -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.util.ejb.EJBCommonServices; - - -public class ObbligazioneHome extends BulkHome { -public ObbligazioneHome(Class clazz, java.sql.Connection conn) { - super(clazz,conn); -} -public ObbligazioneHome(Class clazz, java.sql.Connection conn,PersistentCache persistentCache) { - super(clazz,conn,persistentCache); -} -/** - * - * Costruisce un ObbligazioneHome - * - * @param conn La java.sql.Connection su cui vengono effettuate le operazione di persistenza - */ -public ObbligazioneHome(java.sql.Connection conn) { - super(ObbligazioneBulk.class,conn); -} -/** - * - * Costruisce un ObbligazioneHome - * - * @param conn La java.sql.Connection su cui vengono effettuate le operazione di persistenza - * @param persistentCache La PersistentCache in cui vengono cachati gli oggetti persistenti caricati da questo Home - */ -public ObbligazioneHome(java.sql.Connection conn,PersistentCache persistentCache) { - super(ObbligazioneBulk.class,conn,persistentCache); -} -/** - * - * - * - * @param obbligazioneTemporanea - * @param pg - * @throws IntrospectionException - * @throws PersistencyException - */ -public void confirmObbligazioneTemporanea( - UserContext userContext, - ObbligazioneBulk obbligazioneTemporanea, - Long pg) - throws IntrospectionException,PersistencyException { - - confirmObbligazioneTemporanea(userContext, obbligazioneTemporanea, pg, true); -} -/** - * - * - * - * @param obbligazioneTemporanea - * @param pg - * @throws IntrospectionException - * @throws PersistencyException - */ -public void confirmObbligazioneTemporanea( - UserContext userContext, - ObbligazioneBulk obbligazioneTemporanea, - Long pg, - boolean deleteTemp) - throws IntrospectionException,PersistencyException { - - if (pg == null) - throw new PersistencyException("Impossibile ottenere un progressivo definitivo per l'impegno inserita!"); - - LoggableStatement ps = null; - java.io.StringWriter sql = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sql); - String condition = " WHERE CD_CDS = ? AND ESERCIZIO = ? AND ESERCIZIO_ORIGINALE = ? AND PG_OBBLIGAZIONE = ?"; - String condition_s = " WHERE CD_CDS = ? AND ESERCIZIO = ? AND ESERCIZIO_ORIGINALE = ? AND PG_OBBLIGAZIONE = ? AND PG_STORICO_ = ?"; - try { - pw.write("INSERT INTO " + EJBCommonServices.getDefaultSchema() + getColumnMap().getTableName() + " ("); - pw.write(getPersistenColumnNamesReplacingWith(this, null).toString()); - pw.write(") SELECT "); - pw.write(getPersistenColumnNamesReplacingWith( - this, - new String[][]{ {"PG_OBBLIGAZIONE", "?"} }).toString()); - pw.write(" FROM " + EJBCommonServices.getDefaultSchema() + getColumnMap().getTableName()); - pw.write(condition); - pw.flush(); - - ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); - pw.close(); - ps.setLong(1, pg.longValue()); - ps.setString(2, obbligazioneTemporanea.getCd_cds()); - ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); - ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); - ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); - - ps.execute(); - } catch (java.sql.SQLException e) { - throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); - } finally { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - /* Aggiorno lo storico se presente */ - try { - sql = new java.io.StringWriter(); - pw = new java.io.PrintWriter(sql); - pw.write("UPDATE " + EJBCommonServices.getDefaultSchema() +"OBBLIGAZIONE_S SET "); - pw.write("PG_OBBLIGAZIONE = ? "); - pw.write(condition_s); - pw.flush(); - - ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); - pw.close(); - ps.setLong(1, pg.longValue()); - ps.setString(2, obbligazioneTemporanea.getCd_cds()); - ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); - ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); - ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); - ps.setLong(6, obbligazioneTemporanea.getPg_ver_rec().longValue()); - ps.execute(); - } catch (java.sql.SQLException e) { - throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); - } finally { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - - try { - sql = new java.io.StringWriter(); - pw = new java.io.PrintWriter(sql); - Obbligazione_scadenzarioHome scadHome = (Obbligazione_scadenzarioHome)getHomeCache().getHome(Obbligazione_scadenzarioBulk.class); - pw.write("INSERT INTO " + EJBCommonServices.getDefaultSchema() + scadHome.getColumnMap().getTableName() + " ("); - pw.write(getPersistenColumnNamesReplacingWith(scadHome, null).toString()); - pw.write(") SELECT "); - pw.write(getPersistenColumnNamesReplacingWith( - scadHome, - new String[][]{ {"PG_OBBLIGAZIONE", "?"} }).toString()); - pw.write(" FROM " + EJBCommonServices.getDefaultSchema() + scadHome.getColumnMap().getTableName()); - pw.write(condition); - pw.flush(); - ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); - pw.close(); - ps.setLong(1, pg.longValue()); - ps.setString(2, obbligazioneTemporanea.getCd_cds()); - ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); - ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); - ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); - - ps.execute(); - } catch (java.sql.SQLException e) { - throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); - } finally { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - /* Aggiorno lo storico se presente */ - try { - sql = new java.io.StringWriter(); - pw = new java.io.PrintWriter(sql); - pw.write("UPDATE " + EJBCommonServices.getDefaultSchema() +"OBBLIGAZIONE_SCADENZARIO_S SET "); - pw.write("PG_OBBLIGAZIONE = ? "); - pw.write(condition_s); - pw.flush(); - - ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); - pw.close(); - ps.setLong(1, pg.longValue()); - ps.setString(2, obbligazioneTemporanea.getCd_cds()); - ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); - ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); - ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); - ps.setLong(6, obbligazioneTemporanea.getPg_ver_rec().longValue()); - ps.execute(); - } catch (java.sql.SQLException e) { - throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); - } finally { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - - try { - sql = new java.io.StringWriter(); - pw = new java.io.PrintWriter(sql); - Obbligazione_scad_voceHome scadVoceHome = (Obbligazione_scad_voceHome)getHomeCache().getHome(Obbligazione_scad_voceBulk.class); - pw.write("INSERT INTO " + EJBCommonServices.getDefaultSchema() + scadVoceHome.getColumnMap().getTableName() + " ("); - pw.write(getPersistenColumnNamesReplacingWith(scadVoceHome, null).toString()); - pw.write(") SELECT "); - pw.write(getPersistenColumnNamesReplacingWith( - scadVoceHome, - new String[][]{ {"PG_OBBLIGAZIONE", "?"} }).toString()); - pw.write(" FROM " + EJBCommonServices.getDefaultSchema() + scadVoceHome.getColumnMap().getTableName()); - pw.write(condition); - pw.flush(); - ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); - pw.close(); - ps.setLong(1, pg.longValue()); - ps.setString(2, obbligazioneTemporanea.getCd_cds()); - ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); - ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); - ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); - ps.execute(); - } catch (java.sql.SQLException e) { - throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); - } finally { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - /* Aggiorno lo storico se presente */ - try { - sql = new java.io.StringWriter(); - pw = new java.io.PrintWriter(sql); - pw.write("UPDATE " + EJBCommonServices.getDefaultSchema() +"OBBLIGAZIONE_SCAD_VOCE_S SET "); - pw.write("PG_OBBLIGAZIONE = ? "); - pw.write(condition_s); - pw.flush(); - - ps =new LoggableStatement( getConnection(),sql.toString(),true,this.getClass()); - pw.close(); - ps.setLong(1, pg.longValue()); - ps.setString(2, obbligazioneTemporanea.getCd_cds()); - ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); - ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); - ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); - ps.setLong(6, obbligazioneTemporanea.getPg_ver_rec().longValue()); - ps.execute(); - } catch (java.sql.SQLException e) { - throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); - } finally { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - if (deleteTemp) { - delete(obbligazioneTemporanea, userContext); - obbligazioneTemporanea.setPg_obbligazione(pg); - } -} -/** - * Metodo per cercare i capitoli di spesa del Cds dell'obbligazione. - * - * @param obbligazione ObbligazioneBulk l'obbligazione - * - * @return i capitoli di spesa definiti per il Cds dell'obbligazione - */ -public java.util.List findCapitoliDiSpesaCds( ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - PersistentHome parCNRHome = getHomeCache().getHome(Parametri_cnrBulk.class); - Parametri_cnrBulk parCNR = (Parametri_cnrBulk)parCNRHome.findByPrimaryKey(new Parametri_cnrBulk(obbligazione.getEsercizio())); - - if (parCNR.getFl_nuovo_pdg()) - return Arrays.asList(obbligazione.getElemento_voce()); - - PersistentHome evHome = getHomeCache().getHome(Voce_fBulk.class); - SQLBuilder sql = evHome.createSQLBuilder(); - sql.addClause("AND","ti_appartenenza",sql.EQUALS, Elemento_voceHome.APPARTENENZA_CDS ); - sql.addClause("AND","ti_gestione",sql.EQUALS, Elemento_voceHome.GESTIONE_SPESE ); - if (obbligazione.getCds().getCd_tipo_unita() == null) - obbligazione.setCds((CdsBulk)getHomeCache().getHome(obbligazione.getCds()).findByPrimaryKey(obbligazione.getCds())); - if ( obbligazione.getCds().getCd_tipo_unita().equalsIgnoreCase( it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC)) - sql.addClause("AND","ti_voce",sql.EQUALS, Elemento_voceHome.TIPO_ARTICOLO ); - else - sql.addClause("AND","ti_voce",sql.EQUALS, Elemento_voceHome.TIPO_CAPITOLO ); - sql.addClause("AND","cd_parte",sql.EQUALS, Elemento_voceHome.PARTE_1 ); - sql.addClause("AND","esercizio",sql.EQUALS, obbligazione.getEsercizio()); - if ( obbligazione.getCds().getCd_tipo_unita().equalsIgnoreCase( it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC)) - sql.addClause("AND","cd_centro_responsabilita", sql.LIKE, obbligazione.getUnita_organizzativa().getCd_unita_organizzativa() + ".%" ); - else - sql.addClause("AND","cd_unita_organizzativa", sql.EQUALS, obbligazione.getUnita_organizzativa().getCd_unita_organizzativa() ); - sql.addClause("AND","cd_titolo_capitolo", sql.EQUALS, obbligazione.getElemento_voce().getCd_elemento_voce() ); - return evHome.fetchAll(sql); -} -/** - * - * - * - * @param capitoliList - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public java.util.List findCdr( List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - try - { - int size = capitoliList.size() ; - - if ( size == 0 ) - return Collections.EMPTY_LIST; - - String statement = - "SELECT DISTINCT B.* FROM " + - EJBCommonServices.getDefaultSchema() + - "V_PDG_OBBLIGAZIONE_SPE A, " + - EJBCommonServices.getDefaultSchema() + - "CDR B " + - "WHERE " + - "(A.CATEGORIA_DETTAGLIO = ? OR " + - "A.CATEGORIA_DETTAGLIO = ?) AND " + - "A.ESERCIZIO = ? AND " + - "A.ESERCIZIO_RES = ? AND " + - "A.TI_APPARTENENZA = ? AND " + - "A.TI_GESTIONE = ? AND " + - "A.CD_ELEMENTO_VOCE = ? AND " + -// "B.ESERCIZIO = ? AND " + - "B.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA AND " + - "B.CD_UNITA_ORGANIZZATIVA = ? AND " ; - - statement = statement.concat( "( A.CD_FUNZIONE = ? "); - for ( int t = 1 ; t < size; t++ ) - statement = statement.concat("OR A.CD_FUNZIONE = ? "); - - statement = statement.concat( " ) "); - - LoggableStatement ps =new LoggableStatement( getConnection(), statement ,true,this.getClass()); - try - { - IVoceBilancioBulk capitolo = (IVoceBilancioBulk) capitoliList.iterator().next(); - - ps.setString( 1, Pdg_preventivo_detBulk.CAT_SINGOLO ); - ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); - ps.setObject( 3, capitolo.getEsercizio() ); - ps.setObject( 4, obbligazione.getEsercizio_originale() ); - ps.setString( 5, Elemento_voceHome.APPARTENENZA_CDS ); - ps.setString( 6, Elemento_voceHome.GESTIONE_SPESE ); - ps.setString( 7, capitolo.getCd_titolo_capitolo() ); - if (capitolo instanceof Voce_fBulk) - ps.setString( 8, ((Voce_fBulk)capitolo).getCd_unita_organizzativa() ); - else - ps.setString( 8, obbligazione.getCd_unita_organizzativa() ); - - Iterator i = capitoliList.iterator(); - ps.setString( 9, ((IVoceBilancioBulk)i.next()).getCd_funzione() ); - for ( int j = 10; i.hasNext(); j++ ) - ps.setString( j, ((IVoceBilancioBulk)i.next()).getCd_funzione() ); - - ResultSet rs = ps.executeQuery(); - try - { - PersistentHome cdrHome = getHomeCache().getHome(CdrBulk.class); - return cdrHome.fetchAll( cdrHome.createBroker(ps, rs )); - } - catch( Exception e ) - { - throw new PersistencyException( e ); - } - finally - { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } - catch( SQLException e ) - { - throw new PersistencyException( e ); - } - finally - { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - } - catch ( SQLException e ) - { - throw new PersistencyException( e ); - } -} -/** - * - * - * - * @param capitoliList - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public java.util.List findCdrPerSAC( List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - - try - { - int sizeCapitoli = capitoliList.size() ; - - if ( sizeCapitoli == 0 ) - return Collections.EMPTY_LIST; - - PersistentHome parCNRHome = getHomeCache().getHome(Parametri_cnrBulk.class); - Parametri_cnrBulk parCNR = (Parametri_cnrBulk)parCNRHome.findByPrimaryKey(new Parametri_cnrBulk(obbligazione.getEsercizio())); - - String statement = - "SELECT DISTINCT B.* FROM " + - EJBCommonServices.getDefaultSchema() + - "V_PDG_OBBLIGAZIONE_SPE A, " + - EJBCommonServices.getDefaultSchema() + - "CDR B " + - "WHERE " + - "(A.CATEGORIA_DETTAGLIO = ? OR " + - "A.CATEGORIA_DETTAGLIO = ? OR " + - "(A.CATEGORIA_DETTAGLIO = ? AND A.CD_CENTRO_RESPONSABILITA = ? )) AND " + - "A.ESERCIZIO = ? AND " + - "A.ESERCIZIO_RES = ? AND " + - "A.TI_APPARTENENZA = ? AND " + - "A.TI_GESTIONE = ? AND " + - "A.CD_ELEMENTO_VOCE = ? AND " + -// "B.ESERCIZIO = ? AND " + - "B.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA AND " ; - - if (parCNR.getFl_nuovo_pdg()) { - statement = statement.concat( "( (A.CD_FUNZIONE = ? AND B.CD_UNITA_ORGANIZZATIVA = ? ) " ); - for ( int t = 1 ; t < sizeCapitoli; t++ ) - statement = statement.concat( "OR (A.CD_FUNZIONE = ? AND B.CD_UNITA_ORGANIZZATIVA = ? ) " ); - } else { - statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) " ); - for ( int t = 1 ; t < sizeCapitoli; t++ ) - statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) "); - } - statement = statement.concat( " ) "); - -// statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) " ); -// for ( int t = 1 ; t < sizeCapitoli; t++ ) -// statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) "); -// statement = statement.concat( " ) "); - - //java.sql.PreparedStatement ps = getConnection().prepareStatement( statement ); - LoggableStatement ps = null; - Connection conn = getConnection(); - ps = new LoggableStatement(conn,statement,true,this.getClass()); - - try - { - IVoceBilancioBulk capitolo = (IVoceBilancioBulk) capitoliList.iterator().next(); - - ps.setString( 1, Pdg_preventivo_detBulk.CAT_SINGOLO ); - ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); - ps.setString( 3, Pdg_modulo_spese_gestBulk.CAT_STIPENDI ); - ps.setString( 4,this.recupero_cdr_speciale_stipendi()); - ps.setObject( 5, capitolo.getEsercizio() ); - ps.setObject( 6, obbligazione.getEsercizio_originale() ); - ps.setString( 7, Elemento_voceHome.APPARTENENZA_CDS ); - ps.setString( 8, Elemento_voceHome.GESTIONE_SPESE ); - ps.setString( 9, capitolo.getCd_titolo_capitolo() ); - - int j = 10; - Iterator i = capitoliList.iterator(); - capitolo = (IVoceBilancioBulk) i.next(); - ps.setString( j++, capitolo.getCd_funzione() ); - if (capitolo instanceof Voce_fBulk) - ps.setString( j++, ((Voce_fBulk)capitolo).getCd_centro_responsabilita() ); - else - ps.setString( j++, obbligazione.getCd_unita_organizzativa() ); - - for ( ; i.hasNext(); ) - { - capitolo = (IVoceBilancioBulk) i.next(); - ps.setString( j++, capitolo.getCd_funzione() ); - if (capitolo instanceof Voce_fBulk) - ps.setString( j++, ((Voce_fBulk)capitolo).getCd_centro_responsabilita() ); - else - ps.setString( j++, obbligazione.getCd_unita_organizzativa() ); - } - - ResultSet rs = ps.executeQuery(); - try - { - PersistentHome cdrHome = getHomeCache().getHome(CdrBulk.class); - return cdrHome.fetchAll( cdrHome.createBroker(ps, rs )); - } - catch( Exception e ) - { - throw new PersistencyException( e ); - } - finally - { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } - catch( SQLException e ) - { - throw new PersistencyException( e ); - } - finally - { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - } - catch ( SQLException e ) - { - throw new PersistencyException( e ); - } -} -/** - * - * - * - * @param capitoliList - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public java.util.List findCdrPerSpesePerCostiAltrui( List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - - try - { - int size = capitoliList.size() ; - - if ( size == 0 ) - return Collections.EMPTY_LIST; - - String statement = - "SELECT DISTINCT B.* FROM " + - EJBCommonServices.getDefaultSchema() + - "V_PDG_OBBLIGAZIONE_SPE A, " + - EJBCommonServices.getDefaultSchema() + - "CDR B, " + - EJBCommonServices.getDefaultSchema() + - "CDR C " + - "WHERE " + - "(A.CATEGORIA_DETTAGLIO = ? OR " + - "A.CATEGORIA_DETTAGLIO = ?) AND " + - "A.STATO = ? AND " + - "A.ESERCIZIO = ? AND " + - "A.ESERCIZIO_RES = ? AND " + - "A.TI_APPARTENENZA_CLGS = ? AND " + - "A.TI_GESTIONE_CLGS = ? AND " + - "A.CD_ELEMENTO_VOCE_CLGS = ? AND " + - "B.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA AND " + - "C.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA_CLGS AND " + - "C.CD_UNITA_ORGANIZZATIVA = ? AND " ; - - statement = statement.concat( "( A.CD_FUNZIONE = ? "); - for ( int t = 1 ; t < size; t++ ) - statement = statement.concat("OR A.CD_FUNZIONE = ? "); - - statement = statement.concat( " ) "); - - LoggableStatement ps = new LoggableStatement(getConnection(),statement,true ,this.getClass()); - try - { - Voce_fBulk capitolo = (Voce_fBulk) capitoliList.iterator().next(); - - ps.setString( 1, Pdg_preventivo_detBulk.CAT_SCARICO ); - ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); - ps.setString( 3, Pdg_preventivo_detBulk.ST_CONFERMA ); - ps.setObject( 4, capitolo.getEsercizio() ); - ps.setObject( 5, obbligazione.getEsercizio_originale() ); - ps.setString( 6, Elemento_voceHome.APPARTENENZA_CDS ); - ps.setString( 7, Elemento_voceHome.GESTIONE_SPESE ); - ps.setString( 8, capitolo.getCd_titolo_capitolo() ); - ps.setString( 9, capitolo.getCd_unita_organizzativa() ); - - Iterator i = capitoliList.iterator(); - ps.setString( 10, ((Voce_fBulk)i.next()).getCd_funzione() ); - for ( int j = 11; i.hasNext(); j++ ) - ps.setString( j, ((Voce_fBulk)i.next()).getCd_funzione() ); - - ResultSet rs = ps.executeQuery(); - try - { - PersistentHome cdrHome = getHomeCache().getHome(CdrBulk.class); - return cdrHome.fetchAll( cdrHome.createBroker( ps, rs )); - } - catch( Exception e ) - { - throw new PersistencyException( e ); - } - finally - { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } - catch( Exception e ) - { - throw new PersistencyException( e ); - } - finally - { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - } - catch ( SQLException e ) - { - throw new PersistencyException( e ); - } -} -/** - * - * - * - * @param capitoliList - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public java.util.List findCdrPerSpesePerCostiAltruiPerSAC( List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - - try - { - int sizeCapitoli = capitoliList.size() ; - - if ( sizeCapitoli == 0 ) - return Collections.EMPTY_LIST; - - String statement = - "SELECT DISTINCT B.* FROM " + - EJBCommonServices.getDefaultSchema() + - "V_PDG_OBBLIGAZIONE_SPE A, " + - EJBCommonServices.getDefaultSchema() + - "CDR B, " + - EJBCommonServices.getDefaultSchema() + - "CDR C " + - "WHERE " + - "(A.CATEGORIA_DETTAGLIO = ? OR " + - "A.CATEGORIA_DETTAGLIO = ?) AND " + - "A.STATO = ? AND " + - "A.ESERCIZIO = ? AND " + - "A.ESERCIZIO_RES = ? AND " + - "A.TI_APPARTENENZA_CLGS = ? AND " + - "A.TI_GESTIONE_CLGS = ? AND " + - "A.CD_ELEMENTO_VOCE_CLGS = ? AND " + - "B.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA AND " + - "C.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA_CLGS AND " ; - - statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA_CLGS = ? ) " ); - for ( int t = 1 ; t < sizeCapitoli; t++ ) - statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA_CLGS = ? ) "); - statement = statement.concat( " ) "); - - LoggableStatement ps = new LoggableStatement(getConnection(),statement,true,this.getClass()); - try - { - Voce_fBulk capitolo = (Voce_fBulk) capitoliList.iterator().next(); - - ps.setString( 1, Pdg_preventivo_detBulk.CAT_SCARICO ); - ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); - ps.setString( 3, Pdg_preventivo_detBulk.ST_CONFERMA ); - ps.setObject( 4, capitolo.getEsercizio() ); - ps.setObject( 5, obbligazione.getEsercizio_originale() ); - ps.setString( 6, Elemento_voceHome.APPARTENENZA_CDS ); - ps.setString( 7, Elemento_voceHome.GESTIONE_SPESE ); - ps.setString( 8, capitolo.getCd_titolo_capitolo() ); - - int j = 9; - Iterator i = capitoliList.iterator(); - capitolo = (Voce_fBulk) i.next(); - ps.setString( j++, capitolo.getCd_funzione() ); - ps.setString( j++, capitolo.getCd_centro_responsabilita() ); - - for ( ; i.hasNext(); ) - { - capitolo = (Voce_fBulk) i.next(); - ps.setString( j++, capitolo.getCd_funzione() ); - ps.setString( j++, capitolo.getCd_centro_responsabilita() ); - } - - ResultSet rs = ps.executeQuery(); - try - { - PersistentHome cdrHome = getHomeCache().getHome(CdrBulk.class); - return cdrHome.fetchAll( cdrHome.createBroker( ps, rs )); - } - catch( Exception e ) - { - throw new PersistencyException( e ); - } - finally - { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } - catch( SQLException e ) - { - throw new PersistencyException( e ); - } - finally - { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - } - catch ( SQLException e ) - { - throw new PersistencyException( e ); - } -} -/** - * - * - * - * @param obbligazione - * @return - * @throws PersistencyException - */ -public Timestamp findDataUltimaObbligazionePerCds( ObbligazioneBulk obbligazione ) throws PersistencyException -{ - try - { - LoggableStatement ps = new LoggableStatement(getConnection(), - "SELECT TRUNC(MAX(DT_REGISTRAZIONE)) " + - "FROM " + - it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + - "OBBLIGAZIONE WHERE " + - "ESERCIZIO = ? AND CD_CDS = ? AND CD_TIPO_DOCUMENTO_CONT = ? AND FL_PGIRO = ?" , - true,this.getClass()); - try - { - ps.setObject( 1, obbligazione.getEsercizio() ); - ps.setString( 2, obbligazione.getCds().getCd_unita_organizzativa() ); - ps.setString( 3, obbligazione.getCd_tipo_documento_cont()); - if ( obbligazione.getFl_pgiro().booleanValue() ) - ps.setString( 4, "Y" ); - else - ps.setString( 4, "N" ); - - - ResultSet rs = ps.executeQuery(); - try - { - if(rs.next()) - return rs.getTimestamp(1); - else - return null; - } - catch( SQLException e ) - { - throw new PersistencyException( e ); - } - finally - { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } - catch( SQLException e ) - { - throw new PersistencyException( e ); - } - finally - { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - } - catch ( SQLException e ) - { - throw new PersistencyException( e ); - } -} -/** - * - * - * - * @param cdrList - * @param capitoliList - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public java.util.List findLineeAttivita( List cdrList, List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - try - { - String statement = - "SELECT DISTINCT A.* FROM " + - EJBCommonServices.getDefaultSchema() + - "V_PDG_OBBLIGAZIONE_SPE A " + - "WHERE " + - "(A.CATEGORIA_DETTAGLIO = ? OR " + - "A.CATEGORIA_DETTAGLIO = ?) AND " + - "A.ESERCIZIO = ? AND " + - "A.ESERCIZIO_RES = ? AND " + - "A.TI_APPARTENENZA = ? AND " + - "A.TI_GESTIONE = ? AND " + - "A.CD_ELEMENTO_VOCE = ? AND "; - - int size = cdrList.size() ; - - if ( size == 0 ) - return Collections.EMPTY_LIST; - - statement = statement.concat( "( A.CD_CENTRO_RESPONSABILITA = ? " ); - for ( int t = 1 ; t < size; t++ ) - statement = statement.concat("OR A.CD_CENTRO_RESPONSABILITA = ? "); - statement = statement.concat( " ) AND "); - - size = capitoliList.size() ; - if ( size == 0 ) - return Collections.EMPTY_LIST; - - statement = statement.concat( "( A.CD_FUNZIONE = ? "); - for ( int t = 1 ; t < size; t++ ) - statement = statement.concat("OR A.CD_FUNZIONE = ? "); - - statement = statement.concat( " ) "); - - LoggableStatement ps = new LoggableStatement(getConnection(), statement,true,this.getClass()); - try - { - IVoceBilancioBulk capitolo = (IVoceBilancioBulk) capitoliList.iterator().next(); - - ps.setString( 1, Pdg_preventivo_detBulk.CAT_SINGOLO ); - ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); - ps.setObject( 3, capitolo.getEsercizio() ); - ps.setObject( 4, obbligazione.getEsercizio_originale() ); - ps.setString( 5, Elemento_voceHome.APPARTENENZA_CDS ); - ps.setString( 6, Elemento_voceHome.GESTIONE_SPESE ); - ps.setString( 7, capitolo.getCd_titolo_capitolo() ); - - Iterator i = cdrList.iterator(); - ps.setString( 8, ((CdrBulk)i.next()).getCd_centro_responsabilita() ); - int j = 8; - while( i.hasNext() ) - ps.setString( ++j, ((CdrBulk)i.next()).getCd_centro_responsabilita() ); - - i = capitoliList.iterator(); - ps.setString( ++j, ((IVoceBilancioBulk)i.next()).getCd_funzione() ); - while ( i.hasNext() ) - ps.setString( ++j, ((IVoceBilancioBulk)i.next()).getCd_funzione() ); - - ResultSet rs = ps.executeQuery(); - try - { - PersistentHome pdgHome = getHomeCache().getHome(V_pdg_obbligazione_speBulk.class); - return pdgHome.fetchAll( pdgHome.createBroker( ps,rs )); - } - catch( Exception e ) - { - throw new PersistencyException( e ); - } - finally - { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } - catch( SQLException e ) - { - throw new PersistencyException( e ); - } - finally - { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - } - catch ( SQLException e ) - { - throw new PersistencyException( e ); - } -} -/** - * - * - * - * @param cdrList - * @param capitoliList - * @param uoDiScrivania - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public java.util.List findLineeAttivitaPerSpesePerCostiAltrui( List cdrList, List capitoliList, String uoDiScrivania, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - try - { - String statement = - "SELECT DISTINCT A.* FROM " + - EJBCommonServices.getDefaultSchema() + - "V_PDG_OBBLIGAZIONE_SPE A " + - "WHERE " + - "(A.CATEGORIA_DETTAGLIO = ? OR " + - "A.CATEGORIA_DETTAGLIO = ?) AND " + - "A.STATO = ? AND " + - "A.ESERCIZIO = ? AND " + - "A.ESERCIZIO_RES = ? AND " + - "A.TI_APPARTENENZA_CLGS = ? AND " + - "A.TI_GESTIONE_CLGS = ? AND " + - "A.CD_ELEMENTO_VOCE_CLGS = ? AND " + - "A.CD_CENTRO_RESPONSABILITA_CLGS LIKE ? AND "; - - int size = cdrList.size() ; - - if ( size == 0 ) - return Collections.EMPTY_LIST; - - statement = statement.concat( "( A.CD_CENTRO_RESPONSABILITA = ? " ); - for ( int t = 1 ; t < size; t++ ) - statement = statement.concat("OR A.CD_CENTRO_RESPONSABILITA = ? "); - statement = statement.concat( " ) AND "); - - size = capitoliList.size() ; - if ( size == 0 ) - return Collections.EMPTY_LIST; - - statement = statement.concat( "( A.CD_FUNZIONE = ? "); - for ( int t = 1 ; t < size; t++ ) - statement = statement.concat("OR A.CD_FUNZIONE = ? "); - - statement = statement.concat( " ) "); - - LoggableStatement ps = new LoggableStatement(getConnection(), statement ,true,this.getClass()); - try - { - Voce_fBulk capitolo = (Voce_fBulk) capitoliList.iterator().next(); - - ps.setString( 1, Pdg_preventivo_detBulk.CAT_SCARICO ); - ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); - ps.setString( 3, Pdg_preventivo_detBulk.ST_CONFERMA ); - ps.setObject( 4, capitolo.getEsercizio() ); - ps.setObject( 5, obbligazione.getEsercizio_originale() ); - ps.setString( 6, Elemento_voceHome.APPARTENENZA_CDS ); - ps.setString( 7, Elemento_voceHome.GESTIONE_SPESE ); - ps.setString( 8, capitolo.getCd_titolo_capitolo() ); - ps.setString( 9, uoDiScrivania+".%"); - - Iterator i = cdrList.iterator(); - ps.setString( 10, ((CdrBulk)i.next()).getCd_centro_responsabilita() ); - int j = 10; - while( i.hasNext() ) - ps.setString( ++j, ((CdrBulk)i.next()).getCd_centro_responsabilita() ); - - i = capitoliList.iterator(); - ps.setString( ++j, ((Voce_fBulk)i.next()).getCd_funzione() ); - while ( i.hasNext() ) - ps.setString( ++j, ((Voce_fBulk)i.next()).getCd_funzione() ); - - ResultSet rs = ps.executeQuery(); - try - { - PersistentHome pdgHome = getHomeCache().getHome(V_pdg_obbligazione_speBulk.class); - return pdgHome.fetchAll( pdgHome.createBroker( ps,rs )); - } - catch( Exception e ) - { - throw new PersistencyException( e ); - } - finally - { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } - catch( SQLException e ) - { - throw new PersistencyException( e ); - } - finally - { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - } - catch ( SQLException e ) - { - throw new PersistencyException( e ); - } -} -/** - * - * - * - * @param capitoliList - * @param cdrList - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public java.util.List findLineeAttivitaPerSpesePerCostiAltruiSAC( List capitoliList, List cdrList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - try - { - String statement = - "SELECT DISTINCT A.* FROM " + - EJBCommonServices.getDefaultSchema() + - "V_PDG_OBBLIGAZIONE_SPE A " + - "WHERE " + - "(A.CATEGORIA_DETTAGLIO = ? OR " + - "A.CATEGORIA_DETTAGLIO = ?) AND " + - "A.STATO = ? AND " + - "A.ESERCIZIO = ? AND " + - "A.ESERCIZIO_RES = ? AND " + - "A.TI_APPARTENENZA_CLGS = ? AND " + - "A.TI_GESTIONE_CLGS = ? AND " + - "A.CD_ELEMENTO_VOCE_CLGS = ? AND " ; - - int sizeCapitoli = capitoliList.size() ; - if ( sizeCapitoli == 0 ) - return Collections.EMPTY_LIST; - - int sizeCdr = cdrList.size() ; - if ( sizeCdr == 0 ) - return Collections.EMPTY_LIST; - - - statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA_CLGS = ? ) " ); - for ( int t = 1 ; t < sizeCapitoli; t++ ) - statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA_CLGS = ? ) "); - statement = statement.concat( " ) AND "); - - statement = statement.concat( "( A.CD_CENTRO_RESPONSABILITA = ? " ); - for ( int t = 1 ; t < sizeCdr; t++ ) - statement = statement.concat("OR A.CD_CENTRO_RESPONSABILITA = ? "); - statement = statement.concat( " ) "); - - LoggableStatement ps = new LoggableStatement(getConnection(), statement ,true,this.getClass()); - try - { - Voce_fBulk capitolo = (Voce_fBulk) capitoliList.iterator().next(); - - ps.setString( 1, Pdg_preventivo_detBulk.CAT_SCARICO ); - ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); - ps.setString( 3, Pdg_preventivo_detBulk.ST_CONFERMA ); - ps.setObject( 4, capitolo.getEsercizio() ); - ps.setObject( 5, obbligazione.getEsercizio_originale() ); - ps.setString( 6, Elemento_voceHome.APPARTENENZA_CDS ); - ps.setString( 7, Elemento_voceHome.GESTIONE_SPESE ); - ps.setString( 8, capitolo.getCd_titolo_capitolo() ); - - int j = 9; - Iterator i = capitoliList.iterator(); - capitolo = (Voce_fBulk) i.next(); - ps.setString( j++, capitolo.getCd_funzione() ); - ps.setString( j++, capitolo.getCd_centro_responsabilita() ); - for ( ; i.hasNext(); ) - { - capitolo = (Voce_fBulk) i.next(); - ps.setString( j++, capitolo.getCd_funzione() ); - ps.setString( j++, capitolo.getCd_centro_responsabilita() ); - } - - i = cdrList.iterator(); - CdrBulk cdr = (CdrBulk) i.next(); - ps.setString( j++, cdr.getCd_centro_responsabilita() ); - for ( ; i.hasNext(); ) - { - cdr = (CdrBulk) i.next(); - ps.setString( j++, cdr.getCd_centro_responsabilita() ); - } - - - ResultSet rs = ps.executeQuery(); - try - { - PersistentHome pdgHome = getHomeCache().getHome(V_pdg_obbligazione_speBulk.class); - return pdgHome.fetchAll( pdgHome.createBroker( ps,rs )); - } - catch( Exception e ) - { - throw new PersistencyException( e ); - } - finally - { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } - catch( SQLException e ) - { - throw new PersistencyException( e ); - } - finally - { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - - } - catch ( SQLException e ) - { - throw new PersistencyException( e ); - } -} -/** - * - * - * - * @param capitoliList - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public java.util.List findLineeAttivitaSAC( List cdrList, List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - try - { - String statement = - "SELECT DISTINCT A.* FROM " + - EJBCommonServices.getDefaultSchema() + - "V_PDG_OBBLIGAZIONE_SPE A " + - "WHERE " + - "(A.CATEGORIA_DETTAGLIO = ? OR " + - "(A.CATEGORIA_DETTAGLIO = 'STI' AND A.CD_CENTRO_RESPONSABILITA=CNRCTB015.GETVAL01PERCHIAVE(0,'CDR_SPECIALE','CDR_PERSONALE')) OR " + - "A.CATEGORIA_DETTAGLIO = ?) AND " + - "A.ESERCIZIO = ? AND " + - "A.ESERCIZIO_RES = ? AND " + - "A.TI_APPARTENENZA = ? AND " + - "A.TI_GESTIONE = ? AND " + - "A.CD_ELEMENTO_VOCE = ? AND "; - - int sizeCapitoli = capitoliList.size() ; - if ( sizeCapitoli == 0 ) - return Collections.EMPTY_LIST; - - if (capitoliList.get(0) instanceof Voce_fBulk) { - statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) " ); - for ( int t = 1 ; t < sizeCapitoli; t++ ) - statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) "); - statement = statement.concat( " ) "); - } else { - int sizeCdr = cdrList.size() ; - if ( sizeCdr == 0 ) - return Collections.EMPTY_LIST; - statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) " ); - for ( int t = 1 ; t < sizeCdr; t++ ) - statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) "); - statement = statement.concat( " ) "); - } - - LoggableStatement ps = new LoggableStatement(getConnection(),statement,true,this.getClass()); - try - { - IVoceBilancioBulk capitolo = (IVoceBilancioBulk) capitoliList.iterator().next(); - - ps.setString( 1, Pdg_preventivo_detBulk.CAT_SINGOLO ); - ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); - ps.setObject( 3, capitolo.getEsercizio() ); - ps.setObject( 4, obbligazione.getEsercizio_originale() ); - ps.setString( 5, Elemento_voceHome.APPARTENENZA_CDS ); - ps.setString( 6, Elemento_voceHome.GESTIONE_SPESE ); - ps.setString( 7, capitolo.getCd_titolo_capitolo() ); - - int j = 8; - Iterator i = capitoliList.iterator(); - capitolo = (IVoceBilancioBulk) i.next(); - if (capitolo instanceof Voce_fBulk) { - ps.setString( j++, capitolo.getCd_funzione() ); - ps.setString( j++, ((Voce_fBulk)capitolo).getCd_centro_responsabilita() ); - - for ( ; i.hasNext(); ) - { - capitolo = (Voce_fBulk) i.next(); - ps.setString( j++, capitolo.getCd_funzione() ); - ps.setString( j++, ((Voce_fBulk)capitolo).getCd_centro_responsabilita() ); - } - } else { - //nel caso di capitolo instanceof Elemento_voce nell'iterator capitoliList c'è sempre un solo elemento - //per cui non effettuo il loop sull'iterator capitoliList - for (Iterator iterator = cdrList.iterator(); iterator.hasNext();) { - CdrBulk cdr = (CdrBulk) iterator.next(); - ps.setString( j++, capitolo.getCd_funzione() ); - ps.setString( j++, cdr.getCd_centro_responsabilita() ); - } - } - - ResultSet rs = ps.executeQuery(); - try - { - PersistentHome pdgHome = getHomeCache().getHome(V_pdg_obbligazione_speBulk.class); - return pdgHome.fetchAll( pdgHome.createBroker( ps,rs )); - } - catch( Exception e ) - { - throw new PersistencyException( e ); - } - finally - { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } - catch( SQLException e ) - { - throw new PersistencyException( e ); - } - finally - { - try{ps.close();}catch( java.sql.SQLException e ){}; - } - } - catch ( SQLException e ) - { - throw new PersistencyException( e ); - } -} -/** - * - * - * - * @param obbligazione - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public SQLBuilder findObbligazione_scad_voceDistinctList( ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - PersistentHome osHome = getHomeCache().getHome(Obbligazione_scad_voceBulk.class,"CDR_LINEA_VOCE"); - SQLBuilder sql = osHome.createSQLBuilder(); - sql.resetColumns(); - sql.setDistinctClause(true); - sql.addColumn("CD_VOCE"); - sql.addColumn("CD_CENTRO_RESPONSABILITA"); - sql.addColumn("CD_LINEA_ATTIVITA"); - sql.addSQLClause("AND","CD_CDS",sql.EQUALS, obbligazione.getCds().getCd_unita_organizzativa()); - sql.addSQLClause("AND","ESERCIZIO",sql.EQUALS, obbligazione.getEsercizio()); - sql.addSQLClause("AND","ESERCIZIO_ORIGINALE",sql.EQUALS, obbligazione.getEsercizio_originale()); - sql.addSQLClause("AND","PG_OBBLIGAZIONE",sql.EQUALS, obbligazione.getPg_obbligazione()); - - PersistentHome elemento_voceHome = getHomeCache().getHome(Elemento_voceBulk.class); - SQLBuilder sqlElemento_voce = elemento_voceHome.createSQLBuilder(); - sqlElemento_voce.addSQLClause("AND","ESERCIZIO",sql.EQUALS, obbligazione.getEsercizio()); - sqlElemento_voce.addSQLClause("AND","TI_APPARTENENZA",sql.EQUALS, obbligazione.getTi_appartenenza()); - sqlElemento_voce.addSQLClause("AND","TI_GESTIONE",sql.EQUALS, obbligazione.getTi_gestione()); - sqlElemento_voce.addSQLClause("AND","CD_ELEMENTO_VOCE",sql.EQUALS, obbligazione.getCd_elemento_voce()); - sqlElemento_voce.addSQLClause("AND","FL_LIMITE_ASS_OBBLIG",sql.EQUALS, "Y"); - - PersistentHome workpackage_home = getHomeCache().getHome(WorkpackageBulk.class,"V_LINEA_ATTIVITA_VALIDA"); - SQLBuilder sqlWorkpackage = workpackage_home.createSQLBuilder(); - sqlWorkpackage.addSQLJoin("V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA","OBBLIGAZIONE_SCAD_VOCE.CD_CENTRO_RESPONSABILITA"); - sqlWorkpackage.addSQLJoin("V_LINEA_ATTIVITA_VALIDA.CD_LINEA_ATTIVITA","OBBLIGAZIONE_SCAD_VOCE.CD_LINEA_ATTIVITA"); - sqlWorkpackage.addSQLClause("AND","V_LINEA_ATTIVITA_VALIDA.FL_LIMITE_ASS_OBBLIG",sql.EQUALS, "Y"); - sql.openParenthesis("AND"); - sql.addSQLExistsClause("OR", sqlElemento_voce); - sql.addSQLExistsClause("OR", sqlWorkpackage); - sql.closeParenthesis(); - - return sql; -} -/** - * - * - * - * @param obbligazione - * @return - * @throws IntrospectionException - * @throws PersistencyException - */ -public java.util.List findObbligazione_scadenzarioList( ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException -{ - PersistentHome osHome = getHomeCache().getHome(Obbligazione_scadenzarioBulk.class); - SQLBuilder sql = osHome.createSQLBuilder(); - sql.addClause("AND","cd_cds",sql.EQUALS, obbligazione.getCds().getCd_unita_organizzativa()); - sql.addClause("AND","esercizio",sql.EQUALS, obbligazione.getEsercizio()); - sql.addClause("AND","esercizio_originale",sql.EQUALS, obbligazione.getEsercizio_originale()); - sql.addClause("AND","pg_obbligazione",sql.EQUALS, obbligazione.getPg_obbligazione()); - sql.addOrderBy("dt_scadenza"); - sql.addOrderBy("pg_obbligazione_scadenzario"); - return osHome.fetchAll(sql); -} -/** - * - * - * - * @param obbligazione - * @return - * @throws PersistencyException - * @throws IntrospectionException - */ -public ObbligazioneBulk findObbligazione(ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException -{ - if (obbligazione.isObbligazioneResiduo()) - return findObbligazioneRes(obbligazione); - else if (obbligazione.isObbligazioneResiduoImproprio()) - return findObbligazioneRes_impropria(obbligazione); - else - return findObbligazioneOrd(obbligazione); -} -/** - * - * - * - * @param obbligazione - * @return - * @throws PersistencyException - * @throws IntrospectionException - */ -public ObbligazioneOrdBulk findObbligazioneOrd(ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException -{ - return (ObbligazioneOrdBulk) findByPrimaryKey( new ObbligazioneOrdBulk( obbligazione.getCd_cds(), obbligazione.getEsercizio(),obbligazione.getEsercizio_originale(),obbligazione.getPg_obbligazione())); -} -/** - * - * - * - * @param obbligazione - * @return - * @throws PersistencyException - * @throws IntrospectionException - */ -public ObbligazioneResBulk findObbligazioneRes(ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException -{ - return (ObbligazioneResBulk) findByPrimaryKey( new ObbligazioneResBulk( obbligazione.getCd_cds(), obbligazione.getEsercizio(), obbligazione.getEsercizio_originale(), obbligazione.getPg_obbligazione())); -} -/** - * - * - * - * @param obbligazione - * @return - * @throws PersistencyException - * @throws IntrospectionException - */ -public ObbligazioneRes_impropriaBulk findObbligazioneRes_impropria(ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException -{ - return (ObbligazioneRes_impropriaBulk) findByPrimaryKey( new ObbligazioneRes_impropriaBulk( obbligazione.getCd_cds(), obbligazione.getEsercizio(), obbligazione.getEsercizio_originale(), obbligazione.getPg_obbligazione())); -} -/** - * - * - * - * @param obbligazione - * @return - * @throws PersistencyException - * @throws IntrospectionException - */ -public ImpegnoPGiroBulk findObbligazionePGiro (ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException -{ - return (ImpegnoPGiroBulk) findByPrimaryKey( new ImpegnoPGiroBulk( obbligazione.getCd_cds(), obbligazione.getEsercizio(),obbligazione.getEsercizio_originale(),obbligazione.getPg_obbligazione())); -} -private StringBuffer getPersistenColumnNamesReplacingWith( - BulkHome home, - String[][] fields) - throws PersistencyException { - - java.io.StringWriter columns = new java.io.StringWriter(); - - if (home == null) - throw new PersistencyException("Impossibile ottenere la home per l'aggiornamento dei progressivi temporanei dell'impegno!"); - - java.io.PrintWriter pw = new java.io.PrintWriter(columns); - String[] persistenColumns = home.getColumnMap().getColumnNames(); - for (int i = 0; i < persistenColumns.length; i++) { - String columnName = persistenColumns[i]; - if (fields != null) { - for (int j = 0; j < fields.length; j++) { - String[] field = fields[j]; - if (columnName.equalsIgnoreCase(field[0])) { - columnName = field[1]; - break; - } - } - } - pw.print(columnName); - pw.print((i == persistenColumns.length-1)?"":", "); - } - pw.close(); - return columns.getBuffer(); -} - /** - * Imposta il pg_obbligazione di un oggetto ObbligazioneBulk. - * - * @param obbligazione OggettoBulkBulk - * - * @exception PersistencyException - */ - -public void initializePrimaryKeyForInsert(it.cnr.jada.UserContext userContext,OggettoBulk bulk) throws PersistencyException, ComponentException -{ - try - { - ObbligazioneBulk obbligazione = (ObbligazioneBulk) bulk; - Numerazione_doc_contHome numHome = (Numerazione_doc_contHome) getHomeCache().getHome( Numerazione_doc_contBulk.class ); - Long pg = (!userContext.isTransactional()) ? - numHome.getNextPg(userContext, - obbligazione.getEsercizio(), - obbligazione.getCd_cds(), - obbligazione.getCd_tipo_documento_cont(), - obbligazione.getUser()) : - ((NumTempDocContComponentSession)EJBCommonServices.createEJB( - "CNRDOCCONT00_EJB_NumTempDocContComponentSession", - NumTempDocContComponentSession.class)).getNextTempPg(userContext, obbligazione); - - obbligazione.setPg_obbligazione( pg ); - } catch ( ApplicationException e ) { - throw new ComponentException(e); - } catch ( Throwable e ) { - throw new PersistencyException( e ); - } -} -/** - * Metodo per aggiornare la lista delle nuove linee di attività associate all'obbligazione. - * - * @param obbligazione ObbligazioneBulk l'obbligazione da aggiornare - * - * @return obbligazione ObbligazioneBulk l'obbligazione con la lista delle nuove linee di attività aggiornata - */ -public ObbligazioneBulk refreshNuoveLineeAttivitaColl( UserContext usercontext, ObbligazioneBulk obbligazione ) -{ - - V_pdg_obbligazione_speBulk latt; - boolean found; - it.cnr.contab.doccont00.core.bulk.Linea_attivitaBulk nuovaLatt; - BulkList nuoveLineeAttivitaColl = new BulkList(); - - - //l'imputazione finanziaria e' sempre di testata: seleziono i dettagli di una qualsiasi scadenza con importo != 0 per - // individuare l'elenco delle linee di attivita selezionate per l'intera obbligazione - - Obbligazione_scadenzarioBulk scadenza = null; - for ( Iterator i = obbligazione.getObbligazione_scadenzarioColl().iterator(); i.hasNext(); ) - { - scadenza = (Obbligazione_scadenzarioBulk) i.next(); - if ( scadenza.getIm_scadenza().compareTo( new BigDecimal(0)) > 0 ) - break; - } - - - for ( Iterator s = scadenza.getObbligazione_scad_voceColl().iterator(); s.hasNext(); ) - { - Obbligazione_scad_voceBulk osv = (Obbligazione_scad_voceBulk) s.next(); - found = false; - - for ( Iterator l = obbligazione.getLineeAttivitaSelezionateColl().iterator(); l.hasNext(); ) - { - latt = (V_pdg_obbligazione_speBulk) l.next(); - if ( osv.getCd_centro_responsabilita().equals( latt.getCd_centro_responsabilita() ) && - osv.getCd_linea_attivita().equals( latt.getCd_linea_attivita() ) ) - found = true; - } - if (!found) - { - nuovaLatt = new it.cnr.contab.doccont00.core.bulk.Linea_attivitaBulk(); - - try{ - PersistentHome laHome = getHomeCache().getHome(WorkpackageBulk.class, "V_LINEA_ATTIVITA_VALIDA", "it.cnr.contab.doccont00.comp.AccertamentoComponent.find.linea_att"); - nuovaLatt.setLinea_att((WorkpackageBulk)laHome.findByPrimaryKey(osv.getLinea_attivita())); - getHomeCache().fetchAll(usercontext); - } catch(Exception e) { - nuovaLatt.setLinea_att(osv.getLinea_attivita()); - } - - if ( osv.getObbligazione_scadenzario().getIm_scadenza().compareTo( new BigDecimal(0)) == 0 ) - { - double nrDettagli = scadenza.getObbligazione_scad_voceColl().size(); - nuovaLatt.setPrcImputazioneFin( new BigDecimal(100).divide( new BigDecimal( nrDettagli), 2, BigDecimal.ROUND_HALF_UP) ); - } - else - nuovaLatt.setPrcImputazioneFin( osv.getIm_voce().multiply( new BigDecimal(100)).divide( osv.getObbligazione_scadenzario().getIm_scadenza(), 2, BigDecimal.ROUND_HALF_UP )); - nuovaLatt.setObbligazione( obbligazione ); - nuoveLineeAttivitaColl.add( nuovaLatt ); - - } - } - - if ( obbligazione.getLineeAttivitaSelezionateColl().size() == 0 ) - { - //non esistono latt da pdg --> e'necessario quadrare - BigDecimal totPrc = new BigDecimal(0); - for ( Iterator i = nuoveLineeAttivitaColl.iterator(); i.hasNext(); ) - { - nuovaLatt = (it.cnr.contab.doccont00.core.bulk.Linea_attivitaBulk) i.next(); - totPrc = totPrc.add( nuovaLatt.getPrcImputazioneFin()); - } - if ( totPrc.compareTo( new BigDecimal(100)) != 0 && !nuoveLineeAttivitaColl.isEmpty()) - { - nuovaLatt = (it.cnr.contab.doccont00.core.bulk.Linea_attivitaBulk)nuoveLineeAttivitaColl.get(0); - nuovaLatt.setPrcImputazioneFin( nuovaLatt.getPrcImputazioneFin().add( new BigDecimal(100).subtract( totPrc))); - } - } - obbligazione.setNuoveLineeAttivitaColl( nuoveLineeAttivitaColl ); - return obbligazione; -} -/* -- obbligazione non associata a documenti amministartivi: viene selezionato un qualsiasi terzo di tipo CREDITORE - o ENTRAMBI -- se l'obbligazione è associata a documenti amministrativi e era gia' stato impostato un terzo: la selezione prevede - tutti i terzi con tipo entità = DIVERSI di tipo CREDITORE/ENTRAMBI più il terzo già selezionato -- se l'obbligazione è associata a documenti amministrativi e non era gia' stato impostato un terzo: la selezione prevede - tutti i terzi con tipo entità = DIVERSI di tipo CREDITORE/ENTRAMBI -*/ -public SQLBuilder selectCreditoreByClause( ObbligazioneBulk bulk, TerzoHome home, TerzoBulk terzo,CompoundFindClause clause) throws java.lang.reflect.InvocationTargetException,IllegalAccessException, it.cnr.jada.persistency.PersistencyException -{ - - SQLBuilder sql = getHomeCache().getHome(TerzoBulk.class , "V_TERZO_CF_PI").createSQLBuilder(); - - if ( terzo.getCd_precedente() != null ) - sql.addSQLClause("AND","CD_PRECEDENTE",sql.EQUALS, terzo.getCd_precedente() ); - - if ( !bulk.isAssociataADocAmm() ) //obbligazione non associata a documenti amministrativi - { - sql.openParenthesis( "AND"); - sql.addSQLClause("AND","TI_TERZO",sql.EQUALS, terzo.CREDITORE ); - sql.addSQLClause("OR","TI_TERZO",sql.EQUALS, terzo.ENTRAMBI ); - sql.closeParenthesis(); - if (bulk.getCd_terzo()!=null) - sql.addSQLClause("AND", "V_TERZO_CF_PI.CD_TERZO", sql.EQUALS, bulk.getCd_terzo()); - sql.addSQLClause( "AND", "(V_TERZO_CF_PI.DT_FINE_RAPPORTO >= SYSDATE OR V_TERZO_CF_PI.DT_FINE_RAPPORTO IS NULL)"); - sql.addClause( clause ); - if ( terzo.getAnagrafico() != null ) - { - if ( terzo.getAnagrafico().getCodice_fiscale() != null || terzo.getAnagrafico().getPartita_iva() != null ) - { //aggiungo join su anagrafico - sql.addTableToHeader("ANAGRAFICO"); - sql.addSQLJoin( "V_TERZO_CF_PI.CD_ANAG", "ANAGRAFICO.CD_ANAG"); - } - if ( terzo.getAnagrafico().getCodice_fiscale() != null) - sql.addSQLClause("AND","ANAGRAFICO.CODICE_FISCALE",sql.EQUALS, terzo.getAnagrafico().getCodice_fiscale() ); - if ( terzo.getAnagrafico().getPartita_iva() != null ) - sql.addSQLClause("AND","ANAGRAFICO.PARTITA_IVA",sql.EQUALS, terzo.getAnagrafico().getPartita_iva() ); - } - } - else //obbligazione associata a documenti amministrativi - { - sql.setHeader("select distinct V_TERZO_CF_PI.*"); - sql.addTableToHeader("ANAGRAFICO"); - sql.openParenthesis( "AND"); - sql.addSQLClause("AND","V_TERZO_CF_PI.TI_TERZO",sql.EQUALS, terzo.CREDITORE ); - sql.addSQLClause("OR","V_TERZO_CF_PI.TI_TERZO",sql.EQUALS, terzo.ENTRAMBI ); - sql.closeParenthesis(); - sql.addSQLClause( "AND", "(V_TERZO_CF_PI.DT_FINE_RAPPORTO >= SYSDATE OR V_TERZO_CF_PI.DT_FINE_RAPPORTO IS NULL)"); - sql.addClause( clause ); - sql.openParenthesis( "AND"); - sql.openParenthesis( "AND"); - sql.addSQLClause("AND", "V_TERZO_CF_PI.CD_ANAG = ANAGRAFICO.CD_ANAG"); - sql.addSQLClause("AND", "ANAGRAFICO.TI_ENTITA", sql.EQUALS, AnagraficoBulk.DIVERSI); - sql.closeParenthesis(); - sql.addSQLClause("OR", "V_TERZO_CF_PI.CD_TERZO", sql.EQUALS, bulk.getCd_terzo_iniziale()); - sql.closeParenthesis(); - if ( terzo.getAnagrafico() != null ) - { - if ( terzo.getAnagrafico().getCodice_fiscale() != null ) - sql.addSQLClause("AND","ANAGRAFICO.CODICE_FISCALE",sql.EQUALS, terzo.getAnagrafico().getCodice_fiscale() ); - if ( terzo.getAnagrafico().getPartita_iva() != null ) - sql.addSQLClause("AND","ANAGRAFICO.PARTITA_IVA",sql.EQUALS, terzo.getAnagrafico().getPartita_iva() ); - } - - } - return sql; - /* - if ( !bulk.isAssociataADocAmm() && - bulk.getCrudStatus() != bulk.TO_BE_CREATED && - bulk.getCrudStatus() != bulk.UNDEFINED ) //obbligazione non associata a documenti amministrativi e in fase di modifica - { - if ( bulk.getCd_terzo() != null ) //terzo già selezionato - { - sql.setStatement( - "select distinct A.* from " + - it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "TERZO A " + - " where " + - "(A.TI_TERZO = '" + terzo.CREDITORE + "' OR " + - "A.TI_TERZO = '" + terzo.ENTRAMBI + "') AND " + - "A.CD_TERZO = " + bulk.getCd_terzo() + - "AND (DT_FINE_RAPPORTO >= SYSDATE OR DT_FINE_RAPPORTO IS NULL)"); - } - else - { - sql.setStatement( - "select A.* from " + - it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "TERZO A" + - " where " + - "(A.TI_TERZO = '" + terzo.CREDITORE + "' OR " + - "A.TI_TERZO = '" + terzo.ENTRAMBI + "')" + - "AND (DT_FINE_RAPPORTO >= SYSDATE OR DT_FINE_RAPPORTO IS NULL)"); - } - } - else if ( bulk.isAssociataADocAmm() && - bulk.getCrudStatus() != bulk.TO_BE_CREATED && - bulk.getCrudStatus() != bulk.UNDEFINED )//obbligazione associata a documenti amministrativi e in fase di modifica - { - if ( bulk.getCd_terzo() != null ) //utente ha specificato il codice terzo - { - sql.setStatement( - "select distinct A.* from " + - it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "TERZO A, " + - it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "ANAGRAFICO B " + - " where " + - "(A.TI_TERZO = '" + terzo.CREDITORE + "' OR " + - "A.TI_TERZO = '" + terzo.ENTRAMBI + "') AND " + - "((A.CD_ANAG = B.CD_ANAG " + - "AND B.TI_ENTITA = '" + AnagraficoBulk.DIVERSI + "' ) " + - "OR A.CD_TERZO = '" + bulk.getCd_terzo_iniziale() + "') " + - "AND A.CD_TERZO = '" + bulk.getCd_terzo() + "' " + - "AND (A.DT_FINE_RAPPORTO >= SYSDATE OR A.DT_FINE_RAPPORTO IS NULL)"); - - } - else //utente non ha specificato il codice terzo - { - sql.setStatement( - "select distinct A.* from " + - it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "TERZO A, " + - it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "ANAGRAFICO B " + - " where " + - "(A.TI_TERZO = '" + terzo.CREDITORE + "' OR " + - "A.TI_TERZO = '" + terzo.ENTRAMBI + "') AND " + - "((A.CD_ANAG = B.CD_ANAG " + - "AND B.TI_ENTITA = '" + AnagraficoBulk.DIVERSI + "' ) " + - "OR A.CD_TERZO = '" + bulk.getCd_terzo_iniziale() + "') " + - "AND (A.DT_FINE_RAPPORTO >= SYSDATE OR A.DT_FINE_RAPPORTO IS NULL)"); - } - } - else - { - sql.openParenthesis( "AND"); - sql.addSQLClause("AND","TI_TERZO",sql.EQUALS, terzo.CREDITORE ); - sql.addSQLClause("OR","TI_TERZO",sql.EQUALS, terzo.ENTRAMBI ); - sql.closeParenthesis(); - sql.addSQLClause( "AND", "(DT_FINE_RAPPORTO >= SYSDATE OR DT_FINE_RAPPORTO IS NULL)"); - if ( bulk.getCd_terzo() != null ) //terzo già selezionato - { - sql.addSQLClause("AND","CD_TERZO",sql.EQUALS, bulk.getCd_terzo()); - } - sql.addClause( clause ); - } - return sql; - */ -} -/** - * Metodo per cercare la voce del piano dei conti definita per Cnr o Cds dell'obbligazione. - * - * @param bulk ObbligazioneBulk il contesto (obbligazione) in cui viene fatta la ricerca dell'elemento voce - * @param home istanza di Elemento_voceHome - * @param bulkClause OggettoBulk elemento voce su cui viene fatta la ricerca - * @param clause CompoundFindClause le clausole della selezione - * - * @return sql il risultato della selezione - * - */ -public SQLBuilder selectElemento_voceByClause( ObbligazioneBulk bulk, Elemento_voceHome home, Elemento_voceBulk bulkClause,CompoundFindClause clause) throws java.lang.reflect.InvocationTargetException,IllegalAccessException, it.cnr.jada.persistency.PersistencyException -{ - PersistentHome parCNRHome = getHomeCache().getHome(Parametri_cnrBulk.class); - Parametri_cnrBulk parCNR = (Parametri_cnrBulk)parCNRHome.findByPrimaryKey(new Parametri_cnrBulk(bulk.getEsercizio())); - - SQLBuilder sql = home.createSQLBuilder(); - if ( bulk instanceof ObbligazioneOrdBulk || bulk instanceof ObbligazioneResBulk || - bulk instanceof ObbligazioneRes_impropriaBulk || bulk instanceof ImpegnoBulk) - { - sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, bulk.getEsercizio() ); - sql.addClause("AND", "ti_appartenenza", SQLBuilder.EQUALS, home.APPARTENENZA_CDS ); - sql.addClause("AND", "ti_gestione", SQLBuilder.EQUALS, home.GESTIONE_SPESE ); - sql.addClause("AND", "ti_elemento_voce", SQLBuilder.EQUALS, home.TIPO_CAPITOLO ); - // selezionando solo la parte 1 e' implicito che non siano partite di giro (fl_pgiro='N') - if (parCNR==null || !parCNR.getFl_nuovo_pdg()) - sql.addClause("AND", "cd_parte", SQLBuilder.EQUALS, home.PARTE_1 ); - if ( bulk.getCds() != null && bulk.getCds().getCd_tipo_unita()!=null && !bulk.getCds().getCd_tipo_unita().equalsIgnoreCase( Tipo_unita_organizzativaHome.TIPO_UO_SAC ) ) - sql.addClause("AND", "fl_voce_sac", SQLBuilder.EQUALS, new Boolean( false) ); - sql.addClause( clause ); - } - -/* else if ( bulk instanceof ObbligazionePGiroBulk ) - { - sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, bulk.getEsercizio() ); - sql.addClause("AND", "ti_appartenenza", SQLBuilder.EQUALS, home.APPARTENENZA_CDS ); - sql.addClause("AND", "ti_gestione", SQLBuilder.EQUALS, home.GESTIONE_SPESE ); - sql.addClause("AND", "ti_elemento_voce", SQLBuilder.EQUALS, home.TIPO_CAPITOLO ); - sql.addClause("AND", "cd_parte", SQLBuilder.EQUALS, home.PARTE_2 ); - sql.addClause("AND", "fl_partita_giro", SQLBuilder.EQUALS, new Boolean(true) ); - sql.addClause( clause ); - }*/ - - /* non usato perchè ridefinito nella sottoclasse ImpegnoPGiroHome, ma viene usato per ImpegnoPGiroResiduo */ - else if ( bulk instanceof ImpegnoPGiroBulk ) - { - sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, bulk.getEsercizio() ); - if ( ((ImpegnoPGiroBulk) bulk).getCd_tipo_documento_cont().equals( Numerazione_doc_contBulk.TIPO_IMP)) - sql.addClause("AND", "ti_appartenenza", SQLBuilder.EQUALS, home.APPARTENENZA_CNR ); - else // == OBB_PGIRO - sql.addClause("AND", "ti_appartenenza", SQLBuilder.EQUALS, home.APPARTENENZA_CDS ); - sql.addClause("AND", "ti_gestione", SQLBuilder.EQUALS, home.GESTIONE_SPESE ); - sql.addClause("AND", "ti_elemento_voce", SQLBuilder.EQUALS, home.TIPO_CAPITOLO ); - if (!parCNR.getFl_nuovo_pdg()) - sql.addClause("AND", "cd_parte", SQLBuilder.EQUALS, home.PARTE_2 ); - sql.addClause("AND", "fl_partita_giro", SQLBuilder.EQUALS, new Boolean(true) ); - if ( bulk.getCds() != null && bulk.getCds().getCd_tipo_unita()!=null && !bulk.getCds().getCd_tipo_unita().equalsIgnoreCase( Tipo_unita_organizzativaHome.TIPO_UO_SAC ) ) - sql.addClause("AND", "fl_voce_sac", SQLBuilder.EQUALS, new Boolean( false) ); - sql.addClause( clause ); - } - if (bulk instanceof ObbligazioneResBulk || bulk instanceof ObbligazioneRes_impropriaBulk||bulk instanceof ImpegnoPGiroResiduoBulk) - sql.addClause("AND", "fl_solo_competenza", SQLBuilder.EQUALS, new Boolean( false) ); - else - sql.addClause("AND", "fl_solo_residuo", SQLBuilder.EQUALS, new Boolean( false) ); - if (bulk instanceof ObbligazioneRes_impropriaBulk) - sql.addClause("AND", "fl_azzera_residui", SQLBuilder.EQUALS, new Boolean( false) ); - - //Select che serve per limitare la visualizzazione alle sole voci di bilancio che hanno avuto almeno uno stanziamento - try { - SQLBuilder sqlAssestato = new SQLBuilder(); - sqlAssestato.addTableToHeader("VOCE_F_SALDI_CDR_LINEA"); - sqlAssestato.setHeader(String.valueOf("SELECT 1")); - sqlAssestato.addSQLJoin("VOCE_F_SALDI_CDR_LINEA.ESERCIZIO","ELEMENTO_VOCE.ESERCIZIO"); - sqlAssestato.addSQLJoin("VOCE_F_SALDI_CDR_LINEA.TI_APPARTENENZA","ELEMENTO_VOCE.TI_APPARTENENZA"); - sqlAssestato.addSQLJoin("VOCE_F_SALDI_CDR_LINEA.TI_GESTIONE","ELEMENTO_VOCE.TI_GESTIONE"); - sqlAssestato.addSQLJoin("VOCE_F_SALDI_CDR_LINEA.CD_ELEMENTO_VOCE","ELEMENTO_VOCE.CD_ELEMENTO_VOCE"); - - sqlAssestato.openParenthesis(FindClause.AND); - sqlAssestato.addSQLClause(FindClause.OR, "ELEMENTO_VOCE.FL_LIMITE_ASS_OBBLIG", SQLBuilder.EQUALS, "N" ); - sqlAssestato.addSQLClause(FindClause.OR, "(nvl(VOCE_F_SALDI_CDR_LINEA.IM_STANZ_INIZIALE_A1,0)+nvl(VOCE_F_SALDI_CDR_LINEA.VARIAZIONI_PIU,0)-nvl(VOCE_F_SALDI_CDR_LINEA.VARIAZIONI_MENO,0))", SQLBuilder.GREATER, 0); - sqlAssestato.addSQLClause(FindClause.OR, "(nvl(VOCE_F_SALDI_CDR_LINEA.IM_STANZ_RES_IMPROPRIO,0)+nvl(VOCE_F_SALDI_CDR_LINEA.VAR_PIU_STANZ_RES_IMP,0)-nvl(VOCE_F_SALDI_CDR_LINEA.VAR_MENO_STANZ_RES_IMP,0) + nvl(VOCE_F_SALDI_CDR_LINEA.VAR_MENO_OBBL_RES_PRO,0)-nvl(VOCE_F_SALDI_CDR_LINEA.VAR_PIU_OBBL_RES_PRO,0))", SQLBuilder.GREATER, 0); - sqlAssestato.closeParenthesis(); - - if (bulk.getListaVociSelezionabili() != null && !bulk.getListaVociSelezionabili().isEmpty()) { - sql.openParenthesis("AND"); - for (Elemento_voceBulk voce : bulk.getListaVociSelezionabili()){ - sql.openParenthesis("OR"); - sql.addSQLClause("AND","ELEMENTO_VOCE.CD_ELEMENTO_VOCE",sql.EQUALS, voce.getCd_elemento_voce()); - sql.addSQLClause("AND","ELEMENTO_VOCE.TI_APPARTENENZA",sql.EQUALS, voce.getTi_appartenenza()); - sql.addSQLClause("AND","ELEMENTO_VOCE.TI_GESTIONE",sql.EQUALS, voce.getTi_gestione()); - sql.addSQLClause("AND","ELEMENTO_VOCE.ESERCIZIO",sql.EQUALS, voce.getEsercizio()); - sql.closeParenthesis(); - - } - sql.closeParenthesis(); - } - - SQLBuilder sqlstrOrg = new SQLBuilder(); - sqlstrOrg.addTableToHeader("V_STRUTTURA_ORGANIZZATIVA"); - sqlstrOrg.setHeader(String.valueOf("SELECT 1")); - sqlstrOrg.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.CD_CENTRO_RESPONSABILITA","VOCE_F_SALDI_CDR_LINEA.CD_CENTRO_RESPONSABILITA"); - sqlstrOrg.addSQLClause(FindClause.AND,"V_STRUTTURA_ORGANIZZATIVA.CD_UNITA_ORGANIZZATIVA",SQLBuilder.EQUALS, bulk.getUnita_organizzativa().getCd_unita_organizzativa()); - - sqlAssestato.addSQLExistsClause(FindClause.AND, sqlstrOrg); - - sql.openParenthesis(FindClause.AND); - sql.addClause(FindClause.OR, "fl_limite_ass_obblig", SQLBuilder.EQUALS, Boolean.FALSE ); - sql.addSQLExistsClause(FindClause.OR, sqlAssestato); - sql.closeParenthesis(); - } catch (IntrospectionException e) { - e.printStackTrace(); - } - - return sql; - -} -public String recupero_cdr_speciale_stipendi() throws PersistencyException { - Configurazione_cnrBulk conf_cnr=null; - - PersistentHome home = getHomeCache().getHome(Configurazione_cnrBulk.class); - SQLBuilder sql = home.createSQLBuilder(); - sql.addSQLClause("AND","ESERCIZIO",sql.EQUALS,new Integer(0)); - sql.addSQLClause("AND","CD_CHIAVE_PRIMARIA",sql.EQUALS,Configurazione_cnrBulk.PK_CDR_SPECIALE); - sql.addSQLClause("AND","CD_CHIAVE_SECONDARIA",sql.EQUALS,Configurazione_cnrBulk.SK_CDR_PERSONALE); - List voci=home.fetchAll(sql); - if(voci!=null && !voci.isEmpty()) - conf_cnr=(Configurazione_cnrBulk)voci.get(0); - else - return null; - return conf_cnr.getVal01(); -} -/** - * Ritorna tutti le obbligazioni uguali al bulk indipendentemente dall'esercizio - * comprensivo di quello indicato nel bulk - * - */ -public SQLBuilder selectAllEqualsObbligazioniByClause( ObbligazioneBulk bulk, ObbligazioneHome home,OggettoBulk bulkClause,CompoundFindClause clause) throws java.lang.reflect.InvocationTargetException,IllegalAccessException, it.cnr.jada.persistency.PersistencyException -{ - SQLBuilder sql = this.createSQLBuilder(); - sql.addClause(FindClause.AND, "cd_cds", SQLBuilder.EQUALS, bulk.getCd_cds() ); - sql.addClause(FindClause.AND, "esercizio_originale", SQLBuilder.EQUALS, bulk.getEsercizio_originale() ); - sql.addClause(FindClause.AND, "pg_obbligazione", SQLBuilder.EQUALS, bulk.getPg_obbligazione() ); - sql.addClause( clause ); - return sql; -} -} +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package it.cnr.contab.doccont00.core.bulk; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.*; + +import it.cnr.contab.anagraf00.core.bulk.AnagraficoBulk; +import it.cnr.contab.anagraf00.core.bulk.TerzoBulk; +import it.cnr.contab.anagraf00.core.bulk.TerzoHome; +import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; +import it.cnr.contab.config00.bulk.Parametri_cnrBulk; +import it.cnr.contab.config00.latt.bulk.WorkpackageBulk; +import it.cnr.contab.config00.pdcfin.bulk.Elemento_voceBulk; +import it.cnr.contab.config00.pdcfin.bulk.Elemento_voceHome; +import it.cnr.contab.config00.pdcfin.bulk.IVoceBilancioBulk; +import it.cnr.contab.config00.pdcfin.bulk.Voce_fBulk; +import it.cnr.contab.config00.sto.bulk.CdrBulk; +import it.cnr.contab.config00.sto.bulk.CdsBulk; +import it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome; +import it.cnr.contab.doccont00.ejb.NumTempDocContComponentSession; +import it.cnr.contab.pdg00.bulk.Pdg_preventivo_detBulk; +import it.cnr.contab.pdg01.bulk.Pdg_modulo_spese_gestBulk; +import it.cnr.contab.utenze00.bp.CNRUserContext; +import it.cnr.jada.UserContext; +import it.cnr.jada.bulk.BulkHome; +import it.cnr.jada.bulk.BulkList; +import it.cnr.jada.bulk.OggettoBulk; +import it.cnr.jada.comp.ApplicationException; +import it.cnr.jada.comp.ApplicationRuntimeException; +import it.cnr.jada.comp.ComponentException; +import it.cnr.jada.persistency.IntrospectionException; +import it.cnr.jada.persistency.PersistencyException; +import it.cnr.jada.persistency.PersistentCache; +import it.cnr.jada.persistency.sql.CompoundFindClause; +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.util.ejb.EJBCommonServices; + + +public class ObbligazioneHome extends BulkHome { +public ObbligazioneHome(Class clazz, java.sql.Connection conn) { + super(clazz,conn); +} +public ObbligazioneHome(Class clazz, java.sql.Connection conn,PersistentCache persistentCache) { + super(clazz,conn,persistentCache); +} +/** + * + * Costruisce un ObbligazioneHome + * + * @param conn La java.sql.Connection su cui vengono effettuate le operazione di persistenza + */ +public ObbligazioneHome(java.sql.Connection conn) { + super(ObbligazioneBulk.class,conn); +} +/** + * + * Costruisce un ObbligazioneHome + * + * @param conn La java.sql.Connection su cui vengono effettuate le operazione di persistenza + * @param persistentCache La PersistentCache in cui vengono cachati gli oggetti persistenti caricati da questo Home + */ +public ObbligazioneHome(java.sql.Connection conn,PersistentCache persistentCache) { + super(ObbligazioneBulk.class,conn,persistentCache); +} +/** + * + * + * + * @param obbligazioneTemporanea + * @param pg + * @throws IntrospectionException + * @throws PersistencyException + */ +public void confirmObbligazioneTemporanea( + UserContext userContext, + ObbligazioneBulk obbligazioneTemporanea, + Long pg) + throws IntrospectionException,PersistencyException { + + confirmObbligazioneTemporanea(userContext, obbligazioneTemporanea, pg, true); +} +/** + * + * + * + * @param obbligazioneTemporanea + * @param pg + * @throws IntrospectionException + * @throws PersistencyException + */ +public void confirmObbligazioneTemporanea( + UserContext userContext, + ObbligazioneBulk obbligazioneTemporanea, + Long pg, + boolean deleteTemp) + throws IntrospectionException,PersistencyException { + + if (pg == null) + throw new PersistencyException("Impossibile ottenere un progressivo definitivo per l'impegno inserita!"); + + LoggableStatement ps = null; + java.io.StringWriter sql = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sql); + String condition = " WHERE CD_CDS = ? AND ESERCIZIO = ? AND ESERCIZIO_ORIGINALE = ? AND PG_OBBLIGAZIONE = ?"; + String condition_s = " WHERE CD_CDS = ? AND ESERCIZIO = ? AND ESERCIZIO_ORIGINALE = ? AND PG_OBBLIGAZIONE = ? AND PG_STORICO_ = ?"; + try { + pw.write("INSERT INTO " + EJBCommonServices.getDefaultSchema() + getColumnMap().getTableName() + " ("); + pw.write(getPersistenColumnNamesReplacingWith(this, null).toString()); + pw.write(") SELECT "); + pw.write(getPersistenColumnNamesReplacingWith( + this, + new String[][]{ {"PG_OBBLIGAZIONE", "?"} }).toString()); + pw.write(" FROM " + EJBCommonServices.getDefaultSchema() + getColumnMap().getTableName()); + pw.write(condition); + pw.flush(); + + ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); + pw.close(); + ps.setLong(1, pg.longValue()); + ps.setString(2, obbligazioneTemporanea.getCd_cds()); + ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); + ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); + ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); + + ps.execute(); + } catch (java.sql.SQLException e) { + throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); + } finally { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + /* Aggiorno lo storico se presente */ + try { + sql = new java.io.StringWriter(); + pw = new java.io.PrintWriter(sql); + pw.write("UPDATE " + EJBCommonServices.getDefaultSchema() +"OBBLIGAZIONE_S SET "); + pw.write("PG_OBBLIGAZIONE = ? "); + pw.write(condition_s); + pw.flush(); + + ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); + pw.close(); + ps.setLong(1, pg.longValue()); + ps.setString(2, obbligazioneTemporanea.getCd_cds()); + ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); + ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); + ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); + ps.setLong(6, obbligazioneTemporanea.getPg_ver_rec().longValue()); + ps.execute(); + } catch (java.sql.SQLException e) { + throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); + } finally { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + + try { + sql = new java.io.StringWriter(); + pw = new java.io.PrintWriter(sql); + Obbligazione_scadenzarioHome scadHome = (Obbligazione_scadenzarioHome)getHomeCache().getHome(Obbligazione_scadenzarioBulk.class); + pw.write("INSERT INTO " + EJBCommonServices.getDefaultSchema() + scadHome.getColumnMap().getTableName() + " ("); + pw.write(getPersistenColumnNamesReplacingWith(scadHome, null).toString()); + pw.write(") SELECT "); + pw.write(getPersistenColumnNamesReplacingWith( + scadHome, + new String[][]{ {"PG_OBBLIGAZIONE", "?"} }).toString()); + pw.write(" FROM " + EJBCommonServices.getDefaultSchema() + scadHome.getColumnMap().getTableName()); + pw.write(condition); + pw.flush(); + ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); + pw.close(); + ps.setLong(1, pg.longValue()); + ps.setString(2, obbligazioneTemporanea.getCd_cds()); + ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); + ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); + ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); + + ps.execute(); + } catch (java.sql.SQLException e) { + throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); + } finally { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + /* Aggiorno lo storico se presente */ + try { + sql = new java.io.StringWriter(); + pw = new java.io.PrintWriter(sql); + pw.write("UPDATE " + EJBCommonServices.getDefaultSchema() +"OBBLIGAZIONE_SCADENZARIO_S SET "); + pw.write("PG_OBBLIGAZIONE = ? "); + pw.write(condition_s); + pw.flush(); + + ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); + pw.close(); + ps.setLong(1, pg.longValue()); + ps.setString(2, obbligazioneTemporanea.getCd_cds()); + ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); + ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); + ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); + ps.setLong(6, obbligazioneTemporanea.getPg_ver_rec().longValue()); + ps.execute(); + } catch (java.sql.SQLException e) { + throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); + } finally { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + + try { + sql = new java.io.StringWriter(); + pw = new java.io.PrintWriter(sql); + Obbligazione_scad_voceHome scadVoceHome = (Obbligazione_scad_voceHome)getHomeCache().getHome(Obbligazione_scad_voceBulk.class); + pw.write("INSERT INTO " + EJBCommonServices.getDefaultSchema() + scadVoceHome.getColumnMap().getTableName() + " ("); + pw.write(getPersistenColumnNamesReplacingWith(scadVoceHome, null).toString()); + pw.write(") SELECT "); + pw.write(getPersistenColumnNamesReplacingWith( + scadVoceHome, + new String[][]{ {"PG_OBBLIGAZIONE", "?"} }).toString()); + pw.write(" FROM " + EJBCommonServices.getDefaultSchema() + scadVoceHome.getColumnMap().getTableName()); + pw.write(condition); + pw.flush(); + ps = new LoggableStatement(getConnection(),sql.toString(),true,this.getClass()); + pw.close(); + ps.setLong(1, pg.longValue()); + ps.setString(2, obbligazioneTemporanea.getCd_cds()); + ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); + ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); + ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); + ps.execute(); + } catch (java.sql.SQLException e) { + throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); + } finally { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + /* Aggiorno lo storico se presente */ + try { + sql = new java.io.StringWriter(); + pw = new java.io.PrintWriter(sql); + pw.write("UPDATE " + EJBCommonServices.getDefaultSchema() +"OBBLIGAZIONE_SCAD_VOCE_S SET "); + pw.write("PG_OBBLIGAZIONE = ? "); + pw.write(condition_s); + pw.flush(); + + ps =new LoggableStatement( getConnection(),sql.toString(),true,this.getClass()); + pw.close(); + ps.setLong(1, pg.longValue()); + ps.setString(2, obbligazioneTemporanea.getCd_cds()); + ps.setInt(3, obbligazioneTemporanea.getEsercizio().intValue()); + ps.setInt(4, obbligazioneTemporanea.getEsercizio_originale().intValue()); + ps.setLong(5, obbligazioneTemporanea.getPg_obbligazione().longValue()); + ps.setLong(6, obbligazioneTemporanea.getPg_ver_rec().longValue()); + ps.execute(); + } catch (java.sql.SQLException e) { + throw it.cnr.jada.persistency.sql.SQLExceptionHandler.getInstance().handleSQLException(e,obbligazioneTemporanea); + } finally { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + if (deleteTemp) { + delete(obbligazioneTemporanea, userContext); + obbligazioneTemporanea.setPg_obbligazione(pg); + } +} +/** + * Metodo per cercare i capitoli di spesa del Cds dell'obbligazione. + * + * @param obbligazione ObbligazioneBulk l'obbligazione + * + * @return i capitoli di spesa definiti per il Cds dell'obbligazione + */ +public java.util.List findCapitoliDiSpesaCds( ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + PersistentHome parCNRHome = getHomeCache().getHome(Parametri_cnrBulk.class); + Parametri_cnrBulk parCNR = (Parametri_cnrBulk)parCNRHome.findByPrimaryKey(new Parametri_cnrBulk(obbligazione.getEsercizio())); + + if (parCNR.getFl_nuovo_pdg()) + return Arrays.asList(obbligazione.getElemento_voce()); + + PersistentHome evHome = getHomeCache().getHome(Voce_fBulk.class); + SQLBuilder sql = evHome.createSQLBuilder(); + sql.addClause("AND","ti_appartenenza",sql.EQUALS, Elemento_voceHome.APPARTENENZA_CDS ); + sql.addClause("AND","ti_gestione",sql.EQUALS, Elemento_voceHome.GESTIONE_SPESE ); + if (obbligazione.getCds().getCd_tipo_unita() == null) + obbligazione.setCds((CdsBulk)getHomeCache().getHome(obbligazione.getCds()).findByPrimaryKey(obbligazione.getCds())); + if ( obbligazione.getCds().getCd_tipo_unita().equalsIgnoreCase( it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC)) + sql.addClause("AND","ti_voce",sql.EQUALS, Elemento_voceHome.TIPO_ARTICOLO ); + else + sql.addClause("AND","ti_voce",sql.EQUALS, Elemento_voceHome.TIPO_CAPITOLO ); + sql.addClause("AND","cd_parte",sql.EQUALS, Elemento_voceHome.PARTE_1 ); + sql.addClause("AND","esercizio",sql.EQUALS, obbligazione.getEsercizio()); + if ( obbligazione.getCds().getCd_tipo_unita().equalsIgnoreCase( it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC)) + sql.addClause("AND","cd_centro_responsabilita", sql.LIKE, obbligazione.getUnita_organizzativa().getCd_unita_organizzativa() + ".%" ); + else + sql.addClause("AND","cd_unita_organizzativa", sql.EQUALS, obbligazione.getUnita_organizzativa().getCd_unita_organizzativa() ); + sql.addClause("AND","cd_titolo_capitolo", sql.EQUALS, obbligazione.getElemento_voce().getCd_elemento_voce() ); + return evHome.fetchAll(sql); +} +/** + * + * + * + * @param capitoliList + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public java.util.List findCdr( List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + try + { + int size = capitoliList.size() ; + + if ( size == 0 ) + return Collections.EMPTY_LIST; + + String statement = + "SELECT DISTINCT B.* FROM " + + EJBCommonServices.getDefaultSchema() + + "V_PDG_OBBLIGAZIONE_SPE A, " + + EJBCommonServices.getDefaultSchema() + + "CDR B " + + "WHERE " + + "(A.CATEGORIA_DETTAGLIO = ? OR " + + "A.CATEGORIA_DETTAGLIO = ?) AND " + + "A.ESERCIZIO = ? AND " + + "A.ESERCIZIO_RES = ? AND " + + "A.TI_APPARTENENZA = ? AND " + + "A.TI_GESTIONE = ? AND " + + "A.CD_ELEMENTO_VOCE = ? AND " + +// "B.ESERCIZIO = ? AND " + + "B.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA AND " + + "B.CD_UNITA_ORGANIZZATIVA = ? AND " ; + + statement = statement.concat( "( A.CD_FUNZIONE = ? "); + for ( int t = 1 ; t < size; t++ ) + statement = statement.concat("OR A.CD_FUNZIONE = ? "); + + statement = statement.concat( " ) "); + + LoggableStatement ps =new LoggableStatement( getConnection(), statement ,true,this.getClass()); + try + { + IVoceBilancioBulk capitolo = (IVoceBilancioBulk) capitoliList.iterator().next(); + + ps.setString( 1, Pdg_preventivo_detBulk.CAT_SINGOLO ); + ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); + ps.setObject( 3, capitolo.getEsercizio() ); + ps.setObject( 4, obbligazione.getEsercizio_originale() ); + ps.setString( 5, Elemento_voceHome.APPARTENENZA_CDS ); + ps.setString( 6, Elemento_voceHome.GESTIONE_SPESE ); + ps.setString( 7, capitolo.getCd_titolo_capitolo() ); + if (capitolo instanceof Voce_fBulk) + ps.setString( 8, ((Voce_fBulk)capitolo).getCd_unita_organizzativa() ); + else + ps.setString( 8, obbligazione.getCd_unita_organizzativa() ); + + Iterator i = capitoliList.iterator(); + ps.setString( 9, ((IVoceBilancioBulk)i.next()).getCd_funzione() ); + for ( int j = 10; i.hasNext(); j++ ) + ps.setString( j, ((IVoceBilancioBulk)i.next()).getCd_funzione() ); + + ResultSet rs = ps.executeQuery(); + try + { + PersistentHome cdrHome = getHomeCache().getHome(CdrBulk.class); + return cdrHome.fetchAll( cdrHome.createBroker(ps, rs )); + } + catch( Exception e ) + { + throw new PersistencyException( e ); + } + finally + { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } + catch( SQLException e ) + { + throw new PersistencyException( e ); + } + finally + { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + } + catch ( SQLException e ) + { + throw new PersistencyException( e ); + } +} +/** + * + * + * + * @param capitoliList + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public java.util.List findCdrPerSAC( List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + + try + { + int sizeCapitoli = capitoliList.size() ; + + if ( sizeCapitoli == 0 ) + return Collections.EMPTY_LIST; + + PersistentHome parCNRHome = getHomeCache().getHome(Parametri_cnrBulk.class); + Parametri_cnrBulk parCNR = (Parametri_cnrBulk)parCNRHome.findByPrimaryKey(new Parametri_cnrBulk(obbligazione.getEsercizio())); + + String statement = + "SELECT DISTINCT B.* FROM " + + EJBCommonServices.getDefaultSchema() + + "V_PDG_OBBLIGAZIONE_SPE A, " + + EJBCommonServices.getDefaultSchema() + + "CDR B " + + "WHERE " + + "(A.CATEGORIA_DETTAGLIO = ? OR " + + "A.CATEGORIA_DETTAGLIO = ? OR " + + "(A.CATEGORIA_DETTAGLIO = ? AND A.CD_CENTRO_RESPONSABILITA = ? )) AND " + + "A.ESERCIZIO = ? AND " + + "A.ESERCIZIO_RES = ? AND " + + "A.TI_APPARTENENZA = ? AND " + + "A.TI_GESTIONE = ? AND " + + "A.CD_ELEMENTO_VOCE = ? AND " + +// "B.ESERCIZIO = ? AND " + + "B.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA AND " ; + + if (parCNR.getFl_nuovo_pdg()) { + statement = statement.concat( "( (A.CD_FUNZIONE = ? AND B.CD_UNITA_ORGANIZZATIVA = ? ) " ); + for ( int t = 1 ; t < sizeCapitoli; t++ ) + statement = statement.concat( "OR (A.CD_FUNZIONE = ? AND B.CD_UNITA_ORGANIZZATIVA = ? ) " ); + } else { + statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) " ); + for ( int t = 1 ; t < sizeCapitoli; t++ ) + statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) "); + } + statement = statement.concat( " ) "); + +// statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) " ); +// for ( int t = 1 ; t < sizeCapitoli; t++ ) +// statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) "); +// statement = statement.concat( " ) "); + + //java.sql.PreparedStatement ps = getConnection().prepareStatement( statement ); + LoggableStatement ps = null; + Connection conn = getConnection(); + ps = new LoggableStatement(conn,statement,true,this.getClass()); + + try + { + IVoceBilancioBulk capitolo = (IVoceBilancioBulk) capitoliList.iterator().next(); + + ps.setString( 1, Pdg_preventivo_detBulk.CAT_SINGOLO ); + ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); + ps.setString( 3, Pdg_modulo_spese_gestBulk.CAT_STIPENDI ); + ps.setString( 4, ((Configurazione_cnrHome)getHomeCache().getHome(Configurazione_cnrBulk.class)).getCdrPersonale(capitolo.getEsercizio())); + ps.setObject( 5, capitolo.getEsercizio() ); + ps.setObject( 6, obbligazione.getEsercizio_originale() ); + ps.setString( 7, Elemento_voceHome.APPARTENENZA_CDS ); + ps.setString( 8, Elemento_voceHome.GESTIONE_SPESE ); + ps.setString( 9, capitolo.getCd_titolo_capitolo() ); + + int j = 10; + Iterator i = capitoliList.iterator(); + capitolo = (IVoceBilancioBulk) i.next(); + ps.setString( j++, capitolo.getCd_funzione() ); + if (capitolo instanceof Voce_fBulk) + ps.setString( j++, ((Voce_fBulk)capitolo).getCd_centro_responsabilita() ); + else + ps.setString( j++, obbligazione.getCd_unita_organizzativa() ); + + for ( ; i.hasNext(); ) + { + capitolo = (IVoceBilancioBulk) i.next(); + ps.setString( j++, capitolo.getCd_funzione() ); + if (capitolo instanceof Voce_fBulk) + ps.setString( j++, ((Voce_fBulk)capitolo).getCd_centro_responsabilita() ); + else + ps.setString( j++, obbligazione.getCd_unita_organizzativa() ); + } + + ResultSet rs = ps.executeQuery(); + try + { + PersistentHome cdrHome = getHomeCache().getHome(CdrBulk.class); + return cdrHome.fetchAll( cdrHome.createBroker(ps, rs )); + } + catch( Exception e ) + { + throw new PersistencyException( e ); + } + finally + { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } + catch( SQLException e ) + { + throw new PersistencyException( e ); + } + finally + { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + } + catch ( SQLException e ) + { + throw new PersistencyException( e ); + } +} +/** + * + * + * + * @param capitoliList + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public java.util.List findCdrPerSpesePerCostiAltrui( List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + + try + { + int size = capitoliList.size() ; + + if ( size == 0 ) + return Collections.EMPTY_LIST; + + String statement = + "SELECT DISTINCT B.* FROM " + + EJBCommonServices.getDefaultSchema() + + "V_PDG_OBBLIGAZIONE_SPE A, " + + EJBCommonServices.getDefaultSchema() + + "CDR B, " + + EJBCommonServices.getDefaultSchema() + + "CDR C " + + "WHERE " + + "(A.CATEGORIA_DETTAGLIO = ? OR " + + "A.CATEGORIA_DETTAGLIO = ?) AND " + + "A.STATO = ? AND " + + "A.ESERCIZIO = ? AND " + + "A.ESERCIZIO_RES = ? AND " + + "A.TI_APPARTENENZA_CLGS = ? AND " + + "A.TI_GESTIONE_CLGS = ? AND " + + "A.CD_ELEMENTO_VOCE_CLGS = ? AND " + + "B.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA AND " + + "C.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA_CLGS AND " + + "C.CD_UNITA_ORGANIZZATIVA = ? AND " ; + + statement = statement.concat( "( A.CD_FUNZIONE = ? "); + for ( int t = 1 ; t < size; t++ ) + statement = statement.concat("OR A.CD_FUNZIONE = ? "); + + statement = statement.concat( " ) "); + + LoggableStatement ps = new LoggableStatement(getConnection(),statement,true ,this.getClass()); + try + { + Voce_fBulk capitolo = (Voce_fBulk) capitoliList.iterator().next(); + + ps.setString( 1, Pdg_preventivo_detBulk.CAT_SCARICO ); + ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); + ps.setString( 3, Pdg_preventivo_detBulk.ST_CONFERMA ); + ps.setObject( 4, capitolo.getEsercizio() ); + ps.setObject( 5, obbligazione.getEsercizio_originale() ); + ps.setString( 6, Elemento_voceHome.APPARTENENZA_CDS ); + ps.setString( 7, Elemento_voceHome.GESTIONE_SPESE ); + ps.setString( 8, capitolo.getCd_titolo_capitolo() ); + ps.setString( 9, capitolo.getCd_unita_organizzativa() ); + + Iterator i = capitoliList.iterator(); + ps.setString( 10, ((Voce_fBulk)i.next()).getCd_funzione() ); + for ( int j = 11; i.hasNext(); j++ ) + ps.setString( j, ((Voce_fBulk)i.next()).getCd_funzione() ); + + ResultSet rs = ps.executeQuery(); + try + { + PersistentHome cdrHome = getHomeCache().getHome(CdrBulk.class); + return cdrHome.fetchAll( cdrHome.createBroker( ps, rs )); + } + catch( Exception e ) + { + throw new PersistencyException( e ); + } + finally + { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } + catch( Exception e ) + { + throw new PersistencyException( e ); + } + finally + { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + } + catch ( SQLException e ) + { + throw new PersistencyException( e ); + } +} +/** + * + * + * + * @param capitoliList + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public java.util.List findCdrPerSpesePerCostiAltruiPerSAC( List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + + try + { + int sizeCapitoli = capitoliList.size() ; + + if ( sizeCapitoli == 0 ) + return Collections.EMPTY_LIST; + + String statement = + "SELECT DISTINCT B.* FROM " + + EJBCommonServices.getDefaultSchema() + + "V_PDG_OBBLIGAZIONE_SPE A, " + + EJBCommonServices.getDefaultSchema() + + "CDR B, " + + EJBCommonServices.getDefaultSchema() + + "CDR C " + + "WHERE " + + "(A.CATEGORIA_DETTAGLIO = ? OR " + + "A.CATEGORIA_DETTAGLIO = ?) AND " + + "A.STATO = ? AND " + + "A.ESERCIZIO = ? AND " + + "A.ESERCIZIO_RES = ? AND " + + "A.TI_APPARTENENZA_CLGS = ? AND " + + "A.TI_GESTIONE_CLGS = ? AND " + + "A.CD_ELEMENTO_VOCE_CLGS = ? AND " + + "B.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA AND " + + "C.CD_CENTRO_RESPONSABILITA = A.CD_CENTRO_RESPONSABILITA_CLGS AND " ; + + statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA_CLGS = ? ) " ); + for ( int t = 1 ; t < sizeCapitoli; t++ ) + statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA_CLGS = ? ) "); + statement = statement.concat( " ) "); + + LoggableStatement ps = new LoggableStatement(getConnection(),statement,true,this.getClass()); + try + { + Voce_fBulk capitolo = (Voce_fBulk) capitoliList.iterator().next(); + + ps.setString( 1, Pdg_preventivo_detBulk.CAT_SCARICO ); + ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); + ps.setString( 3, Pdg_preventivo_detBulk.ST_CONFERMA ); + ps.setObject( 4, capitolo.getEsercizio() ); + ps.setObject( 5, obbligazione.getEsercizio_originale() ); + ps.setString( 6, Elemento_voceHome.APPARTENENZA_CDS ); + ps.setString( 7, Elemento_voceHome.GESTIONE_SPESE ); + ps.setString( 8, capitolo.getCd_titolo_capitolo() ); + + int j = 9; + Iterator i = capitoliList.iterator(); + capitolo = (Voce_fBulk) i.next(); + ps.setString( j++, capitolo.getCd_funzione() ); + ps.setString( j++, capitolo.getCd_centro_responsabilita() ); + + for ( ; i.hasNext(); ) + { + capitolo = (Voce_fBulk) i.next(); + ps.setString( j++, capitolo.getCd_funzione() ); + ps.setString( j++, capitolo.getCd_centro_responsabilita() ); + } + + ResultSet rs = ps.executeQuery(); + try + { + PersistentHome cdrHome = getHomeCache().getHome(CdrBulk.class); + return cdrHome.fetchAll( cdrHome.createBroker( ps, rs )); + } + catch( Exception e ) + { + throw new PersistencyException( e ); + } + finally + { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } + catch( SQLException e ) + { + throw new PersistencyException( e ); + } + finally + { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + } + catch ( SQLException e ) + { + throw new PersistencyException( e ); + } +} +/** + * + * + * + * @param obbligazione + * @return + * @throws PersistencyException + */ +public Timestamp findDataUltimaObbligazionePerCds( ObbligazioneBulk obbligazione ) throws PersistencyException +{ + try + { + LoggableStatement ps = new LoggableStatement(getConnection(), + "SELECT TRUNC(MAX(DT_REGISTRAZIONE)) " + + "FROM " + + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "OBBLIGAZIONE WHERE " + + "ESERCIZIO = ? AND CD_CDS = ? AND CD_TIPO_DOCUMENTO_CONT = ? AND FL_PGIRO = ?" , + true,this.getClass()); + try + { + ps.setObject( 1, obbligazione.getEsercizio() ); + ps.setString( 2, obbligazione.getCds().getCd_unita_organizzativa() ); + ps.setString( 3, obbligazione.getCd_tipo_documento_cont()); + if ( obbligazione.getFl_pgiro().booleanValue() ) + ps.setString( 4, "Y" ); + else + ps.setString( 4, "N" ); + + + ResultSet rs = ps.executeQuery(); + try + { + if(rs.next()) + return rs.getTimestamp(1); + else + return null; + } + catch( SQLException e ) + { + throw new PersistencyException( e ); + } + finally + { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } + catch( SQLException e ) + { + throw new PersistencyException( e ); + } + finally + { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + } + catch ( SQLException e ) + { + throw new PersistencyException( e ); + } +} +/** + * + * + * + * @param cdrList + * @param capitoliList + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public java.util.List findLineeAttivita( List cdrList, List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + try + { + String statement = + "SELECT DISTINCT A.* FROM " + + EJBCommonServices.getDefaultSchema() + + "V_PDG_OBBLIGAZIONE_SPE A " + + "WHERE " + + "(A.CATEGORIA_DETTAGLIO = ? OR " + + "A.CATEGORIA_DETTAGLIO = ?) AND " + + "A.ESERCIZIO = ? AND " + + "A.ESERCIZIO_RES = ? AND " + + "A.TI_APPARTENENZA = ? AND " + + "A.TI_GESTIONE = ? AND " + + "A.CD_ELEMENTO_VOCE = ? AND "; + + int size = cdrList.size() ; + + if ( size == 0 ) + return Collections.EMPTY_LIST; + + statement = statement.concat( "( A.CD_CENTRO_RESPONSABILITA = ? " ); + for ( int t = 1 ; t < size; t++ ) + statement = statement.concat("OR A.CD_CENTRO_RESPONSABILITA = ? "); + statement = statement.concat( " ) AND "); + + size = capitoliList.size() ; + if ( size == 0 ) + return Collections.EMPTY_LIST; + + statement = statement.concat( "( A.CD_FUNZIONE = ? "); + for ( int t = 1 ; t < size; t++ ) + statement = statement.concat("OR A.CD_FUNZIONE = ? "); + + statement = statement.concat( " ) "); + + LoggableStatement ps = new LoggableStatement(getConnection(), statement,true,this.getClass()); + try + { + IVoceBilancioBulk capitolo = (IVoceBilancioBulk) capitoliList.iterator().next(); + + ps.setString( 1, Pdg_preventivo_detBulk.CAT_SINGOLO ); + ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); + ps.setObject( 3, capitolo.getEsercizio() ); + ps.setObject( 4, obbligazione.getEsercizio_originale() ); + ps.setString( 5, Elemento_voceHome.APPARTENENZA_CDS ); + ps.setString( 6, Elemento_voceHome.GESTIONE_SPESE ); + ps.setString( 7, capitolo.getCd_titolo_capitolo() ); + + Iterator i = cdrList.iterator(); + ps.setString( 8, ((CdrBulk)i.next()).getCd_centro_responsabilita() ); + int j = 8; + while( i.hasNext() ) + ps.setString( ++j, ((CdrBulk)i.next()).getCd_centro_responsabilita() ); + + i = capitoliList.iterator(); + ps.setString( ++j, ((IVoceBilancioBulk)i.next()).getCd_funzione() ); + while ( i.hasNext() ) + ps.setString( ++j, ((IVoceBilancioBulk)i.next()).getCd_funzione() ); + + ResultSet rs = ps.executeQuery(); + try + { + PersistentHome pdgHome = getHomeCache().getHome(V_pdg_obbligazione_speBulk.class); + return pdgHome.fetchAll( pdgHome.createBroker( ps,rs )); + } + catch( Exception e ) + { + throw new PersistencyException( e ); + } + finally + { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } + catch( SQLException e ) + { + throw new PersistencyException( e ); + } + finally + { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + } + catch ( SQLException e ) + { + throw new PersistencyException( e ); + } +} +/** + * + * + * + * @param cdrList + * @param capitoliList + * @param uoDiScrivania + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public java.util.List findLineeAttivitaPerSpesePerCostiAltrui( List cdrList, List capitoliList, String uoDiScrivania, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + try + { + String statement = + "SELECT DISTINCT A.* FROM " + + EJBCommonServices.getDefaultSchema() + + "V_PDG_OBBLIGAZIONE_SPE A " + + "WHERE " + + "(A.CATEGORIA_DETTAGLIO = ? OR " + + "A.CATEGORIA_DETTAGLIO = ?) AND " + + "A.STATO = ? AND " + + "A.ESERCIZIO = ? AND " + + "A.ESERCIZIO_RES = ? AND " + + "A.TI_APPARTENENZA_CLGS = ? AND " + + "A.TI_GESTIONE_CLGS = ? AND " + + "A.CD_ELEMENTO_VOCE_CLGS = ? AND " + + "A.CD_CENTRO_RESPONSABILITA_CLGS LIKE ? AND "; + + int size = cdrList.size() ; + + if ( size == 0 ) + return Collections.EMPTY_LIST; + + statement = statement.concat( "( A.CD_CENTRO_RESPONSABILITA = ? " ); + for ( int t = 1 ; t < size; t++ ) + statement = statement.concat("OR A.CD_CENTRO_RESPONSABILITA = ? "); + statement = statement.concat( " ) AND "); + + size = capitoliList.size() ; + if ( size == 0 ) + return Collections.EMPTY_LIST; + + statement = statement.concat( "( A.CD_FUNZIONE = ? "); + for ( int t = 1 ; t < size; t++ ) + statement = statement.concat("OR A.CD_FUNZIONE = ? "); + + statement = statement.concat( " ) "); + + LoggableStatement ps = new LoggableStatement(getConnection(), statement ,true,this.getClass()); + try + { + Voce_fBulk capitolo = (Voce_fBulk) capitoliList.iterator().next(); + + ps.setString( 1, Pdg_preventivo_detBulk.CAT_SCARICO ); + ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); + ps.setString( 3, Pdg_preventivo_detBulk.ST_CONFERMA ); + ps.setObject( 4, capitolo.getEsercizio() ); + ps.setObject( 5, obbligazione.getEsercizio_originale() ); + ps.setString( 6, Elemento_voceHome.APPARTENENZA_CDS ); + ps.setString( 7, Elemento_voceHome.GESTIONE_SPESE ); + ps.setString( 8, capitolo.getCd_titolo_capitolo() ); + ps.setString( 9, uoDiScrivania+".%"); + + Iterator i = cdrList.iterator(); + ps.setString( 10, ((CdrBulk)i.next()).getCd_centro_responsabilita() ); + int j = 10; + while( i.hasNext() ) + ps.setString( ++j, ((CdrBulk)i.next()).getCd_centro_responsabilita() ); + + i = capitoliList.iterator(); + ps.setString( ++j, ((Voce_fBulk)i.next()).getCd_funzione() ); + while ( i.hasNext() ) + ps.setString( ++j, ((Voce_fBulk)i.next()).getCd_funzione() ); + + ResultSet rs = ps.executeQuery(); + try + { + PersistentHome pdgHome = getHomeCache().getHome(V_pdg_obbligazione_speBulk.class); + return pdgHome.fetchAll( pdgHome.createBroker( ps,rs )); + } + catch( Exception e ) + { + throw new PersistencyException( e ); + } + finally + { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } + catch( SQLException e ) + { + throw new PersistencyException( e ); + } + finally + { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + } + catch ( SQLException e ) + { + throw new PersistencyException( e ); + } +} +/** + * + * + * + * @param capitoliList + * @param cdrList + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public java.util.List findLineeAttivitaPerSpesePerCostiAltruiSAC( List capitoliList, List cdrList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + try + { + String statement = + "SELECT DISTINCT A.* FROM " + + EJBCommonServices.getDefaultSchema() + + "V_PDG_OBBLIGAZIONE_SPE A " + + "WHERE " + + "(A.CATEGORIA_DETTAGLIO = ? OR " + + "A.CATEGORIA_DETTAGLIO = ?) AND " + + "A.STATO = ? AND " + + "A.ESERCIZIO = ? AND " + + "A.ESERCIZIO_RES = ? AND " + + "A.TI_APPARTENENZA_CLGS = ? AND " + + "A.TI_GESTIONE_CLGS = ? AND " + + "A.CD_ELEMENTO_VOCE_CLGS = ? AND " ; + + int sizeCapitoli = capitoliList.size() ; + if ( sizeCapitoli == 0 ) + return Collections.EMPTY_LIST; + + int sizeCdr = cdrList.size() ; + if ( sizeCdr == 0 ) + return Collections.EMPTY_LIST; + + + statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA_CLGS = ? ) " ); + for ( int t = 1 ; t < sizeCapitoli; t++ ) + statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA_CLGS = ? ) "); + statement = statement.concat( " ) AND "); + + statement = statement.concat( "( A.CD_CENTRO_RESPONSABILITA = ? " ); + for ( int t = 1 ; t < sizeCdr; t++ ) + statement = statement.concat("OR A.CD_CENTRO_RESPONSABILITA = ? "); + statement = statement.concat( " ) "); + + LoggableStatement ps = new LoggableStatement(getConnection(), statement ,true,this.getClass()); + try + { + Voce_fBulk capitolo = (Voce_fBulk) capitoliList.iterator().next(); + + ps.setString( 1, Pdg_preventivo_detBulk.CAT_SCARICO ); + ps.setString( 2, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); + ps.setString( 3, Pdg_preventivo_detBulk.ST_CONFERMA ); + ps.setObject( 4, capitolo.getEsercizio() ); + ps.setObject( 5, obbligazione.getEsercizio_originale() ); + ps.setString( 6, Elemento_voceHome.APPARTENENZA_CDS ); + ps.setString( 7, Elemento_voceHome.GESTIONE_SPESE ); + ps.setString( 8, capitolo.getCd_titolo_capitolo() ); + + int j = 9; + Iterator i = capitoliList.iterator(); + capitolo = (Voce_fBulk) i.next(); + ps.setString( j++, capitolo.getCd_funzione() ); + ps.setString( j++, capitolo.getCd_centro_responsabilita() ); + for ( ; i.hasNext(); ) + { + capitolo = (Voce_fBulk) i.next(); + ps.setString( j++, capitolo.getCd_funzione() ); + ps.setString( j++, capitolo.getCd_centro_responsabilita() ); + } + + i = cdrList.iterator(); + CdrBulk cdr = (CdrBulk) i.next(); + ps.setString( j++, cdr.getCd_centro_responsabilita() ); + for ( ; i.hasNext(); ) + { + cdr = (CdrBulk) i.next(); + ps.setString( j++, cdr.getCd_centro_responsabilita() ); + } + + + ResultSet rs = ps.executeQuery(); + try + { + PersistentHome pdgHome = getHomeCache().getHome(V_pdg_obbligazione_speBulk.class); + return pdgHome.fetchAll( pdgHome.createBroker( ps,rs )); + } + catch( Exception e ) + { + throw new PersistencyException( e ); + } + finally + { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } + catch( SQLException e ) + { + throw new PersistencyException( e ); + } + finally + { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + + } + catch ( SQLException e ) + { + throw new PersistencyException( e ); + } +} +/** + * + * + * + * @param capitoliList + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public java.util.List findLineeAttivitaSAC( List cdrList, List capitoliList, ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + try + { + String statement = + "SELECT DISTINCT A.* FROM " + + EJBCommonServices.getDefaultSchema() + + "V_PDG_OBBLIGAZIONE_SPE A " + + "WHERE " + + "(A.CATEGORIA_DETTAGLIO = ? OR " + + "(A.CATEGORIA_DETTAGLIO = 'STI' AND A.CD_CENTRO_RESPONSABILITA = ? ) OR " + + "A.CATEGORIA_DETTAGLIO = ?) AND " + + "A.ESERCIZIO = ? AND " + + "A.ESERCIZIO_RES = ? AND " + + "A.TI_APPARTENENZA = ? AND " + + "A.TI_GESTIONE = ? AND " + + "A.CD_ELEMENTO_VOCE = ? AND "; + + int sizeCapitoli = capitoliList.size() ; + if ( sizeCapitoli == 0 ) + return Collections.EMPTY_LIST; + + if (capitoliList.get(0) instanceof Voce_fBulk) { + statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) " ); + for ( int t = 1 ; t < sizeCapitoli; t++ ) + statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) "); + statement = statement.concat( " ) "); + } else { + int sizeCdr = cdrList.size() ; + if ( sizeCdr == 0 ) + return Collections.EMPTY_LIST; + statement = statement.concat( "( (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) " ); + for ( int t = 1 ; t < sizeCdr; t++ ) + statement = statement.concat("OR (A.CD_FUNZIONE = ? AND A.CD_CENTRO_RESPONSABILITA = ? ) "); + statement = statement.concat( " ) "); + } + + LoggableStatement ps = new LoggableStatement(getConnection(),statement,true,this.getClass()); + try + { + IVoceBilancioBulk capitolo = (IVoceBilancioBulk) capitoliList.iterator().next(); + + Optional optCdrPersonale = Optional.ofNullable(((Configurazione_cnrHome) getHomeCache().getHome(Configurazione_cnrBulk.class)) + .getCdrPersonale(capitolo.getEsercizio())); + if (!optCdrPersonale.isPresent()) + throw new RuntimeException("Non è possibile individuare il codice CDR del Personale per l'esercizio "+capitolo.getEsercizio()+"."); + + ps.setString( 1, Pdg_preventivo_detBulk.CAT_SINGOLO ); + ps.setString( 2, optCdrPersonale.get() ); + ps.setString( 3, Pdg_modulo_spese_gestBulk.CAT_DIRETTA ); + ps.setObject( 4, capitolo.getEsercizio() ); + ps.setObject( 5, obbligazione.getEsercizio_originale() ); + ps.setString( 6, Elemento_voceHome.APPARTENENZA_CDS ); + ps.setString( 7, Elemento_voceHome.GESTIONE_SPESE ); + ps.setString( 8, capitolo.getCd_titolo_capitolo() ); + + int j = 8; + Iterator i = capitoliList.iterator(); + capitolo = (IVoceBilancioBulk) i.next(); + if (capitolo instanceof Voce_fBulk) { + ps.setString( j++, capitolo.getCd_funzione() ); + ps.setString( j++, ((Voce_fBulk)capitolo).getCd_centro_responsabilita() ); + + for ( ; i.hasNext(); ) + { + capitolo = (Voce_fBulk) i.next(); + ps.setString( j++, capitolo.getCd_funzione() ); + ps.setString( j++, ((Voce_fBulk)capitolo).getCd_centro_responsabilita() ); + } + } else { + //nel caso di capitolo instanceof Elemento_voce nell'iterator capitoliList c'è sempre un solo elemento + //per cui non effettuo il loop sull'iterator capitoliList + for (Iterator iterator = cdrList.iterator(); iterator.hasNext();) { + CdrBulk cdr = (CdrBulk) iterator.next(); + ps.setString( j++, capitolo.getCd_funzione() ); + ps.setString( j++, cdr.getCd_centro_responsabilita() ); + } + } + + ResultSet rs = ps.executeQuery(); + try + { + PersistentHome pdgHome = getHomeCache().getHome(V_pdg_obbligazione_speBulk.class); + return pdgHome.fetchAll( pdgHome.createBroker( ps,rs )); + } + catch( Exception e ) + { + throw new PersistencyException( e ); + } + finally + { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } + catch( SQLException e ) + { + throw new PersistencyException( e ); + } + finally + { + try{ps.close();}catch( java.sql.SQLException e ){}; + } + } + catch ( SQLException e ) + { + throw new PersistencyException( e ); + } +} +/** + * + * + * + * @param obbligazione + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public SQLBuilder findObbligazione_scad_voceDistinctList( ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + PersistentHome osHome = getHomeCache().getHome(Obbligazione_scad_voceBulk.class,"CDR_LINEA_VOCE"); + SQLBuilder sql = osHome.createSQLBuilder(); + sql.resetColumns(); + sql.setDistinctClause(true); + sql.addColumn("CD_VOCE"); + sql.addColumn("CD_CENTRO_RESPONSABILITA"); + sql.addColumn("CD_LINEA_ATTIVITA"); + sql.addSQLClause("AND","CD_CDS",sql.EQUALS, obbligazione.getCds().getCd_unita_organizzativa()); + sql.addSQLClause("AND","ESERCIZIO",sql.EQUALS, obbligazione.getEsercizio()); + sql.addSQLClause("AND","ESERCIZIO_ORIGINALE",sql.EQUALS, obbligazione.getEsercizio_originale()); + sql.addSQLClause("AND","PG_OBBLIGAZIONE",sql.EQUALS, obbligazione.getPg_obbligazione()); + + PersistentHome elemento_voceHome = getHomeCache().getHome(Elemento_voceBulk.class); + SQLBuilder sqlElemento_voce = elemento_voceHome.createSQLBuilder(); + sqlElemento_voce.addSQLClause("AND","ESERCIZIO",sql.EQUALS, obbligazione.getEsercizio()); + sqlElemento_voce.addSQLClause("AND","TI_APPARTENENZA",sql.EQUALS, obbligazione.getTi_appartenenza()); + sqlElemento_voce.addSQLClause("AND","TI_GESTIONE",sql.EQUALS, obbligazione.getTi_gestione()); + sqlElemento_voce.addSQLClause("AND","CD_ELEMENTO_VOCE",sql.EQUALS, obbligazione.getCd_elemento_voce()); + sqlElemento_voce.addSQLClause("AND","FL_LIMITE_ASS_OBBLIG",sql.EQUALS, "Y"); + + PersistentHome workpackage_home = getHomeCache().getHome(WorkpackageBulk.class,"V_LINEA_ATTIVITA_VALIDA"); + SQLBuilder sqlWorkpackage = workpackage_home.createSQLBuilder(); + sqlWorkpackage.addSQLJoin("V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA","OBBLIGAZIONE_SCAD_VOCE.CD_CENTRO_RESPONSABILITA"); + sqlWorkpackage.addSQLJoin("V_LINEA_ATTIVITA_VALIDA.CD_LINEA_ATTIVITA","OBBLIGAZIONE_SCAD_VOCE.CD_LINEA_ATTIVITA"); + sqlWorkpackage.addSQLClause("AND","V_LINEA_ATTIVITA_VALIDA.FL_LIMITE_ASS_OBBLIG",sql.EQUALS, "Y"); + sql.openParenthesis("AND"); + sql.addSQLExistsClause("OR", sqlElemento_voce); + sql.addSQLExistsClause("OR", sqlWorkpackage); + sql.closeParenthesis(); + + return sql; +} +/** + * + * + * + * @param obbligazione + * @return + * @throws IntrospectionException + * @throws PersistencyException + */ +public java.util.List findObbligazione_scadenzarioList( ObbligazioneBulk obbligazione ) throws IntrospectionException,PersistencyException +{ + PersistentHome osHome = getHomeCache().getHome(Obbligazione_scadenzarioBulk.class); + SQLBuilder sql = osHome.createSQLBuilder(); + sql.addClause("AND","cd_cds",sql.EQUALS, obbligazione.getCds().getCd_unita_organizzativa()); + sql.addClause("AND","esercizio",sql.EQUALS, obbligazione.getEsercizio()); + sql.addClause("AND","esercizio_originale",sql.EQUALS, obbligazione.getEsercizio_originale()); + sql.addClause("AND","pg_obbligazione",sql.EQUALS, obbligazione.getPg_obbligazione()); + sql.addOrderBy("dt_scadenza"); + sql.addOrderBy("pg_obbligazione_scadenzario"); + return osHome.fetchAll(sql); +} +/** + * + * + * + * @param obbligazione + * @return + * @throws PersistencyException + * @throws IntrospectionException + */ +public ObbligazioneBulk findObbligazione(ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException +{ + if (obbligazione.isObbligazioneResiduo()) + return findObbligazioneRes(obbligazione); + else if (obbligazione.isObbligazioneResiduoImproprio()) + return findObbligazioneRes_impropria(obbligazione); + else + return findObbligazioneOrd(obbligazione); +} +/** + * + * + * + * @param obbligazione + * @return + * @throws PersistencyException + * @throws IntrospectionException + */ +public ObbligazioneOrdBulk findObbligazioneOrd(ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException +{ + return (ObbligazioneOrdBulk) findByPrimaryKey( new ObbligazioneOrdBulk( obbligazione.getCd_cds(), obbligazione.getEsercizio(),obbligazione.getEsercizio_originale(),obbligazione.getPg_obbligazione())); +} +/** + * + * + * + * @param obbligazione + * @return + * @throws PersistencyException + * @throws IntrospectionException + */ +public ObbligazioneResBulk findObbligazioneRes(ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException +{ + return (ObbligazioneResBulk) findByPrimaryKey( new ObbligazioneResBulk( obbligazione.getCd_cds(), obbligazione.getEsercizio(), obbligazione.getEsercizio_originale(), obbligazione.getPg_obbligazione())); +} +/** + * + * + * + * @param obbligazione + * @return + * @throws PersistencyException + * @throws IntrospectionException + */ +public ObbligazioneRes_impropriaBulk findObbligazioneRes_impropria(ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException +{ + return (ObbligazioneRes_impropriaBulk) findByPrimaryKey( new ObbligazioneRes_impropriaBulk( obbligazione.getCd_cds(), obbligazione.getEsercizio(), obbligazione.getEsercizio_originale(), obbligazione.getPg_obbligazione())); +} +/** + * + * + * + * @param obbligazione + * @return + * @throws PersistencyException + * @throws IntrospectionException + */ +public ImpegnoPGiroBulk findObbligazionePGiro (ObbligazioneBulk obbligazione) throws it.cnr.jada.persistency.PersistencyException, it.cnr.jada.persistency.IntrospectionException +{ + return (ImpegnoPGiroBulk) findByPrimaryKey( new ImpegnoPGiroBulk( obbligazione.getCd_cds(), obbligazione.getEsercizio(),obbligazione.getEsercizio_originale(),obbligazione.getPg_obbligazione())); +} +private StringBuffer getPersistenColumnNamesReplacingWith( + BulkHome home, + String[][] fields) + throws PersistencyException { + + java.io.StringWriter columns = new java.io.StringWriter(); + + if (home == null) + throw new PersistencyException("Impossibile ottenere la home per l'aggiornamento dei progressivi temporanei dell'impegno!"); + + java.io.PrintWriter pw = new java.io.PrintWriter(columns); + String[] persistenColumns = home.getColumnMap().getColumnNames(); + for (int i = 0; i < persistenColumns.length; i++) { + String columnName = persistenColumns[i]; + if (fields != null) { + for (int j = 0; j < fields.length; j++) { + String[] field = fields[j]; + if (columnName.equalsIgnoreCase(field[0])) { + columnName = field[1]; + break; + } + } + } + pw.print(columnName); + pw.print((i == persistenColumns.length-1)?"":", "); + } + pw.close(); + return columns.getBuffer(); +} + /** + * Imposta il pg_obbligazione di un oggetto ObbligazioneBulk. + * + * @param bulk OggettoBulk + * + * @exception PersistencyException + */ + +public void initializePrimaryKeyForInsert(it.cnr.jada.UserContext userContext,OggettoBulk bulk) throws PersistencyException, ComponentException +{ + try + { + ObbligazioneBulk obbligazione = (ObbligazioneBulk) bulk; + Numerazione_doc_contHome numHome = (Numerazione_doc_contHome) getHomeCache().getHome( Numerazione_doc_contBulk.class ); + Long pg = (!userContext.isTransactional()) ? + numHome.getNextPg(userContext, + obbligazione.getEsercizio(), + obbligazione.getCd_cds(), + obbligazione.getCd_tipo_documento_cont(), + obbligazione.getUser()) : + ((NumTempDocContComponentSession)EJBCommonServices.createEJB( + "CNRDOCCONT00_EJB_NumTempDocContComponentSession", + NumTempDocContComponentSession.class)).getNextTempPg(userContext, obbligazione); + + obbligazione.setPg_obbligazione( pg ); + } catch ( ApplicationException e ) { + throw new ComponentException(e); + } catch ( Throwable e ) { + throw new PersistencyException( e ); + } +} +/** + * Metodo per aggiornare la lista delle nuove linee di attività associate all'obbligazione. + * + * @param obbligazione ObbligazioneBulk l'obbligazione da aggiornare + * + * @return obbligazione ObbligazioneBulk l'obbligazione con la lista delle nuove linee di attività aggiornata + */ +public ObbligazioneBulk refreshNuoveLineeAttivitaColl( UserContext usercontext, ObbligazioneBulk obbligazione ) +{ + + V_pdg_obbligazione_speBulk latt; + boolean found; + it.cnr.contab.doccont00.core.bulk.Linea_attivitaBulk nuovaLatt; + BulkList nuoveLineeAttivitaColl = new BulkList(); + + + //l'imputazione finanziaria e' sempre di testata: seleziono i dettagli di una qualsiasi scadenza con importo != 0 per + // individuare l'elenco delle linee di attivita selezionate per l'intera obbligazione + + Obbligazione_scadenzarioBulk scadenza = null; + for ( Iterator i = obbligazione.getObbligazione_scadenzarioColl().iterator(); i.hasNext(); ) + { + scadenza = (Obbligazione_scadenzarioBulk) i.next(); + if ( scadenza.getIm_scadenza().compareTo( new BigDecimal(0)) > 0 ) + break; + } + + + for ( Iterator s = scadenza.getObbligazione_scad_voceColl().iterator(); s.hasNext(); ) + { + Obbligazione_scad_voceBulk osv = (Obbligazione_scad_voceBulk) s.next(); + found = false; + + for ( Iterator l = obbligazione.getLineeAttivitaSelezionateColl().iterator(); l.hasNext(); ) + { + latt = (V_pdg_obbligazione_speBulk) l.next(); + if ( osv.getCd_centro_responsabilita().equals( latt.getCd_centro_responsabilita() ) && + osv.getCd_linea_attivita().equals( latt.getCd_linea_attivita() ) ) + found = true; + } + if (!found) + { + nuovaLatt = new it.cnr.contab.doccont00.core.bulk.Linea_attivitaBulk(); + + try{ + PersistentHome laHome = getHomeCache().getHome(WorkpackageBulk.class, "V_LINEA_ATTIVITA_VALIDA", "it.cnr.contab.doccont00.comp.AccertamentoComponent.find.linea_att"); + nuovaLatt.setLinea_att((WorkpackageBulk)laHome.findByPrimaryKey(osv.getLinea_attivita())); + getHomeCache().fetchAll(usercontext); + } catch(Exception e) { + nuovaLatt.setLinea_att(osv.getLinea_attivita()); + } + + if ( osv.getObbligazione_scadenzario().getIm_scadenza().compareTo( new BigDecimal(0)) == 0 ) + { + double nrDettagli = scadenza.getObbligazione_scad_voceColl().size(); + nuovaLatt.setPrcImputazioneFin( new BigDecimal(100).divide( new BigDecimal( nrDettagli), 2, BigDecimal.ROUND_HALF_UP) ); + } + else + nuovaLatt.setPrcImputazioneFin( osv.getIm_voce().multiply( new BigDecimal(100)).divide( osv.getObbligazione_scadenzario().getIm_scadenza(), 2, BigDecimal.ROUND_HALF_UP )); + nuovaLatt.setObbligazione( obbligazione ); + nuoveLineeAttivitaColl.add( nuovaLatt ); + + } + } + + if ( obbligazione.getLineeAttivitaSelezionateColl().size() == 0 ) + { + //non esistono latt da pdg --> e'necessario quadrare + BigDecimal totPrc = new BigDecimal(0); + for ( Iterator i = nuoveLineeAttivitaColl.iterator(); i.hasNext(); ) + { + nuovaLatt = (it.cnr.contab.doccont00.core.bulk.Linea_attivitaBulk) i.next(); + totPrc = totPrc.add( nuovaLatt.getPrcImputazioneFin()); + } + if ( totPrc.compareTo( new BigDecimal(100)) != 0 && !nuoveLineeAttivitaColl.isEmpty()) + { + nuovaLatt = (it.cnr.contab.doccont00.core.bulk.Linea_attivitaBulk)nuoveLineeAttivitaColl.get(0); + nuovaLatt.setPrcImputazioneFin( nuovaLatt.getPrcImputazioneFin().add( new BigDecimal(100).subtract( totPrc))); + } + } + obbligazione.setNuoveLineeAttivitaColl( nuoveLineeAttivitaColl ); + return obbligazione; +} +/* +- obbligazione non associata a documenti amministartivi: viene selezionato un qualsiasi terzo di tipo CREDITORE + o ENTRAMBI +- se l'obbligazione è associata a documenti amministrativi e era gia' stato impostato un terzo: la selezione prevede + tutti i terzi con tipo entità = DIVERSI di tipo CREDITORE/ENTRAMBI più il terzo già selezionato +- se l'obbligazione è associata a documenti amministrativi e non era gia' stato impostato un terzo: la selezione prevede + tutti i terzi con tipo entità = DIVERSI di tipo CREDITORE/ENTRAMBI +*/ +public SQLBuilder selectCreditoreByClause( ObbligazioneBulk bulk, TerzoHome home, TerzoBulk terzo,CompoundFindClause clause) throws java.lang.reflect.InvocationTargetException,IllegalAccessException, it.cnr.jada.persistency.PersistencyException +{ + + SQLBuilder sql = getHomeCache().getHome(TerzoBulk.class , "V_TERZO_CF_PI").createSQLBuilder(); + + if ( terzo.getCd_precedente() != null ) + sql.addSQLClause("AND","CD_PRECEDENTE",sql.EQUALS, terzo.getCd_precedente() ); + + if ( !bulk.isAssociataADocAmm() ) //obbligazione non associata a documenti amministrativi + { + sql.openParenthesis( "AND"); + sql.addSQLClause("AND","TI_TERZO",sql.EQUALS, terzo.CREDITORE ); + sql.addSQLClause("OR","TI_TERZO",sql.EQUALS, terzo.ENTRAMBI ); + sql.closeParenthesis(); + if (bulk.getCd_terzo()!=null) + sql.addSQLClause("AND", "V_TERZO_CF_PI.CD_TERZO", sql.EQUALS, bulk.getCd_terzo()); + sql.addSQLClause( "AND", "(V_TERZO_CF_PI.DT_FINE_RAPPORTO >= SYSDATE OR V_TERZO_CF_PI.DT_FINE_RAPPORTO IS NULL)"); + sql.addClause( clause ); + if ( terzo.getAnagrafico() != null ) + { + if ( terzo.getAnagrafico().getCodice_fiscale() != null || terzo.getAnagrafico().getPartita_iva() != null ) + { //aggiungo join su anagrafico + sql.addTableToHeader("ANAGRAFICO"); + sql.addSQLJoin( "V_TERZO_CF_PI.CD_ANAG", "ANAGRAFICO.CD_ANAG"); + } + if ( terzo.getAnagrafico().getCodice_fiscale() != null) + sql.addSQLClause("AND","ANAGRAFICO.CODICE_FISCALE",sql.EQUALS, terzo.getAnagrafico().getCodice_fiscale() ); + if ( terzo.getAnagrafico().getPartita_iva() != null ) + sql.addSQLClause("AND","ANAGRAFICO.PARTITA_IVA",sql.EQUALS, terzo.getAnagrafico().getPartita_iva() ); + } + } + else //obbligazione associata a documenti amministrativi + { + sql.setHeader("select distinct V_TERZO_CF_PI.*"); + sql.addTableToHeader("ANAGRAFICO"); + sql.openParenthesis( "AND"); + sql.addSQLClause("AND","V_TERZO_CF_PI.TI_TERZO",sql.EQUALS, terzo.CREDITORE ); + sql.addSQLClause("OR","V_TERZO_CF_PI.TI_TERZO",sql.EQUALS, terzo.ENTRAMBI ); + sql.closeParenthesis(); + sql.addSQLClause( "AND", "(V_TERZO_CF_PI.DT_FINE_RAPPORTO >= SYSDATE OR V_TERZO_CF_PI.DT_FINE_RAPPORTO IS NULL)"); + sql.addClause( clause ); + sql.openParenthesis( "AND"); + sql.openParenthesis( "AND"); + sql.addSQLClause("AND", "V_TERZO_CF_PI.CD_ANAG = ANAGRAFICO.CD_ANAG"); + sql.addSQLClause("AND", "ANAGRAFICO.TI_ENTITA", sql.EQUALS, AnagraficoBulk.DIVERSI); + sql.closeParenthesis(); + sql.addSQLClause("OR", "V_TERZO_CF_PI.CD_TERZO", sql.EQUALS, bulk.getCd_terzo_iniziale()); + sql.closeParenthesis(); + if ( terzo.getAnagrafico() != null ) + { + if ( terzo.getAnagrafico().getCodice_fiscale() != null ) + sql.addSQLClause("AND","ANAGRAFICO.CODICE_FISCALE",sql.EQUALS, terzo.getAnagrafico().getCodice_fiscale() ); + if ( terzo.getAnagrafico().getPartita_iva() != null ) + sql.addSQLClause("AND","ANAGRAFICO.PARTITA_IVA",sql.EQUALS, terzo.getAnagrafico().getPartita_iva() ); + } + + } + return sql; + /* + if ( !bulk.isAssociataADocAmm() && + bulk.getCrudStatus() != bulk.TO_BE_CREATED && + bulk.getCrudStatus() != bulk.UNDEFINED ) //obbligazione non associata a documenti amministrativi e in fase di modifica + { + if ( bulk.getCd_terzo() != null ) //terzo già selezionato + { + sql.setStatement( + "select distinct A.* from " + + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "TERZO A " + + " where " + + "(A.TI_TERZO = '" + terzo.CREDITORE + "' OR " + + "A.TI_TERZO = '" + terzo.ENTRAMBI + "') AND " + + "A.CD_TERZO = " + bulk.getCd_terzo() + + "AND (DT_FINE_RAPPORTO >= SYSDATE OR DT_FINE_RAPPORTO IS NULL)"); + } + else + { + sql.setStatement( + "select A.* from " + + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "TERZO A" + + " where " + + "(A.TI_TERZO = '" + terzo.CREDITORE + "' OR " + + "A.TI_TERZO = '" + terzo.ENTRAMBI + "')" + + "AND (DT_FINE_RAPPORTO >= SYSDATE OR DT_FINE_RAPPORTO IS NULL)"); + } + } + else if ( bulk.isAssociataADocAmm() && + bulk.getCrudStatus() != bulk.TO_BE_CREATED && + bulk.getCrudStatus() != bulk.UNDEFINED )//obbligazione associata a documenti amministrativi e in fase di modifica + { + if ( bulk.getCd_terzo() != null ) //utente ha specificato il codice terzo + { + sql.setStatement( + "select distinct A.* from " + + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "TERZO A, " + + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "ANAGRAFICO B " + + " where " + + "(A.TI_TERZO = '" + terzo.CREDITORE + "' OR " + + "A.TI_TERZO = '" + terzo.ENTRAMBI + "') AND " + + "((A.CD_ANAG = B.CD_ANAG " + + "AND B.TI_ENTITA = '" + AnagraficoBulk.DIVERSI + "' ) " + + "OR A.CD_TERZO = '" + bulk.getCd_terzo_iniziale() + "') " + + "AND A.CD_TERZO = '" + bulk.getCd_terzo() + "' " + + "AND (A.DT_FINE_RAPPORTO >= SYSDATE OR A.DT_FINE_RAPPORTO IS NULL)"); + + } + else //utente non ha specificato il codice terzo + { + sql.setStatement( + "select distinct A.* from " + + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "TERZO A, " + + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "ANAGRAFICO B " + + " where " + + "(A.TI_TERZO = '" + terzo.CREDITORE + "' OR " + + "A.TI_TERZO = '" + terzo.ENTRAMBI + "') AND " + + "((A.CD_ANAG = B.CD_ANAG " + + "AND B.TI_ENTITA = '" + AnagraficoBulk.DIVERSI + "' ) " + + "OR A.CD_TERZO = '" + bulk.getCd_terzo_iniziale() + "') " + + "AND (A.DT_FINE_RAPPORTO >= SYSDATE OR A.DT_FINE_RAPPORTO IS NULL)"); + } + } + else + { + sql.openParenthesis( "AND"); + sql.addSQLClause("AND","TI_TERZO",sql.EQUALS, terzo.CREDITORE ); + sql.addSQLClause("OR","TI_TERZO",sql.EQUALS, terzo.ENTRAMBI ); + sql.closeParenthesis(); + sql.addSQLClause( "AND", "(DT_FINE_RAPPORTO >= SYSDATE OR DT_FINE_RAPPORTO IS NULL)"); + if ( bulk.getCd_terzo() != null ) //terzo già selezionato + { + sql.addSQLClause("AND","CD_TERZO",sql.EQUALS, bulk.getCd_terzo()); + } + sql.addClause( clause ); + } + return sql; + */ +} +/** + * Metodo per cercare la voce del piano dei conti definita per Cnr o Cds dell'obbligazione. + * + * @param bulk ObbligazioneBulk il contesto (obbligazione) in cui viene fatta la ricerca dell'elemento voce + * @param home istanza di Elemento_voceHome + * @param bulkClause OggettoBulk elemento voce su cui viene fatta la ricerca + * @param clause CompoundFindClause le clausole della selezione + * + * @return sql il risultato della selezione + * + */ +public SQLBuilder selectElemento_voceByClause( ObbligazioneBulk bulk, Elemento_voceHome home, Elemento_voceBulk bulkClause,CompoundFindClause clause) throws java.lang.reflect.InvocationTargetException,IllegalAccessException, it.cnr.jada.persistency.PersistencyException +{ + PersistentHome parCNRHome = getHomeCache().getHome(Parametri_cnrBulk.class); + Parametri_cnrBulk parCNR = (Parametri_cnrBulk)parCNRHome.findByPrimaryKey(new Parametri_cnrBulk(bulk.getEsercizio())); + + SQLBuilder sql = home.createSQLBuilder(); + if ( bulk instanceof ObbligazioneOrdBulk || bulk instanceof ObbligazioneResBulk || + bulk instanceof ObbligazioneRes_impropriaBulk || bulk instanceof ImpegnoBulk) + { + sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, bulk.getEsercizio() ); + sql.addClause("AND", "ti_appartenenza", SQLBuilder.EQUALS, home.APPARTENENZA_CDS ); + sql.addClause("AND", "ti_gestione", SQLBuilder.EQUALS, home.GESTIONE_SPESE ); + sql.addClause("AND", "ti_elemento_voce", SQLBuilder.EQUALS, home.TIPO_CAPITOLO ); + // selezionando solo la parte 1 e' implicito che non siano partite di giro (fl_pgiro='N') + if (parCNR==null || !parCNR.getFl_nuovo_pdg()) + sql.addClause("AND", "cd_parte", SQLBuilder.EQUALS, home.PARTE_1 ); + if ( bulk.getCds() != null && bulk.getCds().getCd_tipo_unita()!=null && !bulk.getCds().getCd_tipo_unita().equalsIgnoreCase( Tipo_unita_organizzativaHome.TIPO_UO_SAC ) ) + sql.addClause("AND", "fl_voce_sac", SQLBuilder.EQUALS, new Boolean( false) ); + sql.addClause( clause ); + } + +/* else if ( bulk instanceof ObbligazionePGiroBulk ) + { + sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, bulk.getEsercizio() ); + sql.addClause("AND", "ti_appartenenza", SQLBuilder.EQUALS, home.APPARTENENZA_CDS ); + sql.addClause("AND", "ti_gestione", SQLBuilder.EQUALS, home.GESTIONE_SPESE ); + sql.addClause("AND", "ti_elemento_voce", SQLBuilder.EQUALS, home.TIPO_CAPITOLO ); + sql.addClause("AND", "cd_parte", SQLBuilder.EQUALS, home.PARTE_2 ); + sql.addClause("AND", "fl_partita_giro", SQLBuilder.EQUALS, new Boolean(true) ); + sql.addClause( clause ); + }*/ + + /* non usato perchè ridefinito nella sottoclasse ImpegnoPGiroHome, ma viene usato per ImpegnoPGiroResiduo */ + else if ( bulk instanceof ImpegnoPGiroBulk ) + { + sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, bulk.getEsercizio() ); + if ( ((ImpegnoPGiroBulk) bulk).getCd_tipo_documento_cont().equals( Numerazione_doc_contBulk.TIPO_IMP)) + sql.addClause("AND", "ti_appartenenza", SQLBuilder.EQUALS, home.APPARTENENZA_CNR ); + else // == OBB_PGIRO + sql.addClause("AND", "ti_appartenenza", SQLBuilder.EQUALS, home.APPARTENENZA_CDS ); + sql.addClause("AND", "ti_gestione", SQLBuilder.EQUALS, home.GESTIONE_SPESE ); + sql.addClause("AND", "ti_elemento_voce", SQLBuilder.EQUALS, home.TIPO_CAPITOLO ); + if (!parCNR.getFl_nuovo_pdg()) + sql.addClause("AND", "cd_parte", SQLBuilder.EQUALS, home.PARTE_2 ); + sql.addClause("AND", "fl_partita_giro", SQLBuilder.EQUALS, new Boolean(true) ); + if ( bulk.getCds() != null && bulk.getCds().getCd_tipo_unita()!=null && !bulk.getCds().getCd_tipo_unita().equalsIgnoreCase( Tipo_unita_organizzativaHome.TIPO_UO_SAC ) ) + sql.addClause("AND", "fl_voce_sac", SQLBuilder.EQUALS, new Boolean( false) ); + sql.addClause( clause ); + } + if (bulk instanceof ObbligazioneResBulk || bulk instanceof ObbligazioneRes_impropriaBulk||bulk instanceof ImpegnoPGiroResiduoBulk) + sql.addClause("AND", "fl_solo_competenza", SQLBuilder.EQUALS, new Boolean( false) ); + else + sql.addClause("AND", "fl_solo_residuo", SQLBuilder.EQUALS, new Boolean( false) ); + if (bulk instanceof ObbligazioneRes_impropriaBulk) + sql.addClause("AND", "fl_azzera_residui", SQLBuilder.EQUALS, new Boolean( false) ); + + //Select che serve per limitare la visualizzazione alle sole voci di bilancio che hanno avuto almeno uno stanziamento + try { + SQLBuilder sqlAssestato = new SQLBuilder(); + sqlAssestato.addTableToHeader("VOCE_F_SALDI_CDR_LINEA"); + sqlAssestato.setHeader(String.valueOf("SELECT 1")); + sqlAssestato.addSQLJoin("VOCE_F_SALDI_CDR_LINEA.ESERCIZIO","ELEMENTO_VOCE.ESERCIZIO"); + sqlAssestato.addSQLJoin("VOCE_F_SALDI_CDR_LINEA.TI_APPARTENENZA","ELEMENTO_VOCE.TI_APPARTENENZA"); + sqlAssestato.addSQLJoin("VOCE_F_SALDI_CDR_LINEA.TI_GESTIONE","ELEMENTO_VOCE.TI_GESTIONE"); + sqlAssestato.addSQLJoin("VOCE_F_SALDI_CDR_LINEA.CD_ELEMENTO_VOCE","ELEMENTO_VOCE.CD_ELEMENTO_VOCE"); + + sqlAssestato.openParenthesis(FindClause.AND); + sqlAssestato.addSQLClause(FindClause.OR, "ELEMENTO_VOCE.FL_LIMITE_ASS_OBBLIG", SQLBuilder.EQUALS, "N" ); + sqlAssestato.addSQLClause(FindClause.OR, "(nvl(VOCE_F_SALDI_CDR_LINEA.IM_STANZ_INIZIALE_A1,0)+nvl(VOCE_F_SALDI_CDR_LINEA.VARIAZIONI_PIU,0)-nvl(VOCE_F_SALDI_CDR_LINEA.VARIAZIONI_MENO,0))", SQLBuilder.GREATER, 0); + sqlAssestato.addSQLClause(FindClause.OR, "(nvl(VOCE_F_SALDI_CDR_LINEA.IM_STANZ_RES_IMPROPRIO,0)+nvl(VOCE_F_SALDI_CDR_LINEA.VAR_PIU_STANZ_RES_IMP,0)-nvl(VOCE_F_SALDI_CDR_LINEA.VAR_MENO_STANZ_RES_IMP,0) + nvl(VOCE_F_SALDI_CDR_LINEA.VAR_MENO_OBBL_RES_PRO,0)-nvl(VOCE_F_SALDI_CDR_LINEA.VAR_PIU_OBBL_RES_PRO,0))", SQLBuilder.GREATER, 0); + sqlAssestato.closeParenthesis(); + + if (bulk.getListaVociSelezionabili() != null && !bulk.getListaVociSelezionabili().isEmpty()) { + sql.openParenthesis("AND"); + for (Elemento_voceBulk voce : bulk.getListaVociSelezionabili()){ + sql.openParenthesis("OR"); + sql.addSQLClause("AND","ELEMENTO_VOCE.CD_ELEMENTO_VOCE",sql.EQUALS, voce.getCd_elemento_voce()); + sql.addSQLClause("AND","ELEMENTO_VOCE.TI_APPARTENENZA",sql.EQUALS, voce.getTi_appartenenza()); + sql.addSQLClause("AND","ELEMENTO_VOCE.TI_GESTIONE",sql.EQUALS, voce.getTi_gestione()); + sql.addSQLClause("AND","ELEMENTO_VOCE.ESERCIZIO",sql.EQUALS, voce.getEsercizio()); + sql.closeParenthesis(); + + } + sql.closeParenthesis(); + } + + SQLBuilder sqlstrOrg = new SQLBuilder(); + sqlstrOrg.addTableToHeader("V_STRUTTURA_ORGANIZZATIVA"); + sqlstrOrg.setHeader(String.valueOf("SELECT 1")); + sqlstrOrg.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.CD_CENTRO_RESPONSABILITA","VOCE_F_SALDI_CDR_LINEA.CD_CENTRO_RESPONSABILITA"); + sqlstrOrg.addSQLClause(FindClause.AND,"V_STRUTTURA_ORGANIZZATIVA.CD_UNITA_ORGANIZZATIVA",SQLBuilder.EQUALS, bulk.getUnita_organizzativa().getCd_unita_organizzativa()); + + sqlAssestato.addSQLExistsClause(FindClause.AND, sqlstrOrg); + + sql.openParenthesis(FindClause.AND); + sql.addClause(FindClause.OR, "fl_limite_ass_obblig", SQLBuilder.EQUALS, Boolean.FALSE ); + sql.addSQLExistsClause(FindClause.OR, sqlAssestato); + sql.closeParenthesis(); + } catch (IntrospectionException e) { + e.printStackTrace(); + } + + return sql; + +} +/** + * Ritorna tutti le obbligazioni uguali al bulk indipendentemente dall'esercizio + * comprensivo di quello indicato nel bulk + * + */ +public SQLBuilder selectAllEqualsObbligazioniByClause( ObbligazioneBulk bulk, ObbligazioneHome home,OggettoBulk bulkClause,CompoundFindClause clause) throws java.lang.reflect.InvocationTargetException,IllegalAccessException, it.cnr.jada.persistency.PersistencyException +{ + SQLBuilder sql = this.createSQLBuilder(); + sql.addClause(FindClause.AND, "cd_cds", SQLBuilder.EQUALS, bulk.getCd_cds() ); + sql.addClause(FindClause.AND, "esercizio_originale", SQLBuilder.EQUALS, bulk.getEsercizio_originale() ); + sql.addClause(FindClause.AND, "pg_obbligazione", SQLBuilder.EQUALS, bulk.getPg_obbligazione() ); + sql.addClause( clause ); + return sql; +} +} diff --git a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/intcass/bulk/V_mandato_reversaleBulk.java b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/intcass/bulk/V_mandato_reversaleBulk.java index d1d5f1f48b..33f35ebca8 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/doccont00/intcass/bulk/V_mandato_reversaleBulk.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/doccont00/intcass/bulk/V_mandato_reversaleBulk.java @@ -1,340 +1,341 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package it.cnr.contab.doccont00.intcass.bulk; - -import it.cnr.contab.anagraf00.core.bulk.TerzoBulk; -import it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession; -import it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk; -import it.cnr.contab.doccont00.core.bulk.MandatoBulk; -import it.cnr.contab.doccont00.core.bulk.Mandato_rigaIBulk; -import it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk; -import it.cnr.contab.doccont00.core.bulk.ReversaleBulk; -import it.cnr.contab.service.SpringUtil; -import it.cnr.contab.spring.service.StorePath; -import it.cnr.contab.util.enumeration.EsitoOperazione; -import it.cnr.contab.util.enumeration.TipoDebitoSIOPE; -import it.cnr.si.spring.storage.StorageService; -import it.cnr.si.spring.storage.annotation.StoragePolicy; -import it.cnr.si.spring.storage.annotation.StorageProperty; -import it.cnr.si.spring.storage.annotation.StorageType; -import it.cnr.contab.utenze00.bp.CNRUserContext; -import it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk; -import it.cnr.contab.util00.bulk.storage.AllegatoParentBulk; -import it.cnr.jada.action.ActionContext; -import it.cnr.jada.bulk.BulkCollection; -import it.cnr.jada.bulk.BulkList; -import it.cnr.jada.bulk.OggettoBulk; -import it.cnr.jada.comp.ComponentException; - -import java.rmi.RemoteException; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -@StorageType(name="D:doccont:document") -public class V_mandato_reversaleBulk extends V_mandato_reversaleBase implements AllegatoParentBulk, StatoTrasmissione{ - TerzoBulk terzo = new TerzoBulk(); - Unita_organizzativaBulk uo = new Unita_organizzativaBulk(); - boolean stato_trasmissioneToBeUpdated = false; - - // PG_DISTINTA DECIMAL(10,0) NOT NULL (PK) - private java.lang.Long pg_distinta; - private String documento; - private BulkList archivioAllegati = new BulkList(); - protected BulkList mandato_rigaColl = new BulkList(); - - public final static java.util.Dictionary cd_tipo_documento_contKeys; - static - { - cd_tipo_documento_contKeys = new java.util.Hashtable(); - cd_tipo_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_MAN, "Mandato"); - cd_tipo_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_REV, "Reversale"); - } - - public final static java.util.Dictionary ti_documento_contKeys; - static - { - ti_documento_contKeys = new it.cnr.jada.util.OrderedHashtable(); - ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.TIPO_PAGAMENTO, "Pagamento"); - ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.TIPO_ACCREDITAMENTO, "Accreditamento"); - ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.ReversaleBulk.TIPO_REGOLAM_SOSPESO, "Regolamento Sospeso"); - ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.ReversaleBulk.TIPO_REGOLARIZZAZIONE, "Regolarizzazione"); - ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.ReversaleBulk.TIPO_TRASFERIMENTO, "Trasferimento"); - ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.ReversaleBulk.TIPO_INCASSO, "Incasso"); - } - - public final static java.util.Dictionary statoKeys; - static - { - statoKeys = new it.cnr.jada.util.OrderedHashtable(); - statoKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_MANDATO_ANNULLATO, "Annullato"); - statoKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_MANDATO_EMESSO, "Emesso"); - statoKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_MANDATO_PAGATO, "Pagato/Incassato"); - } - public final static java.util.Dictionary stato_trasmissioneKeys; - static - { - stato_trasmissioneKeys = new it.cnr.jada.util.OrderedHashtable(); - stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_NON_INSERITO, "Non inserito in distinta"); - stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_PREDISPOSTO, "Predisposto alla Firma"); - stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_PRIMA_FIRMA, "Prima Firma"); - stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_INSERITO, "Inserito in distinta"); - stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_TRASMESSO, "Trasmesso"); - stato_trasmissioneKeys.put(StatoTrasmissione.ALL, "Tutti"); - - } - - public final static java.util.Dictionary ti_cc_biKeys; - static - { - ti_cc_biKeys = new it.cnr.jada.util.OrderedHashtable(); - ti_cc_biKeys.put(it.cnr.contab.doccont00.core.bulk.SospesoBulk.TIPO_CC, "C/C"); - ti_cc_biKeys.put(it.cnr.contab.doccont00.core.bulk.SospesoBulk.TIPO_BANCA_ITALIA, "Banca d'Italia"); - } - - public final static Map tipoDebitoSIOPEKeys = Arrays.asList(TipoDebitoSIOPE.values()) - .stream() - .collect(Collectors.toMap( - TipoDebitoSIOPE::value, - TipoDebitoSIOPE::label, - (oldValue, newValue) -> oldValue, - Hashtable::new - )); - - public final static Map esito_OperazioneKeys = Arrays.asList(EsitoOperazione.values()) - .stream() - .collect(Collectors.toMap( - EsitoOperazione::value, - EsitoOperazione::label, - (oldValue, newValue) -> oldValue, - Hashtable::new - )); - - public V_mandato_reversaleBulk() { - super(); - } - public V_mandato_reversaleBulk( Integer esercizio, String cd_tipo_documento_cont, String cd_cds, Long pg_documento_cont) { - super( esercizio, cd_tipo_documento_cont, cd_cds, pg_documento_cont ); - } - public Integer getCd_terzo() { - TerzoBulk terzo = this.getTerzo(); - if (terzo == null) - return null; - return terzo.getCd_terzo(); - } - @StoragePolicy(name="P:strorg:uo", property=@StorageProperty(name="strorguo:codice")) - public java.lang.String getCd_unita_organizzativa() { - Unita_organizzativaBulk uo = this.getUo(); - if (uo == null) - return null; - return uo.getCd_unita_organizzativa(); - } - @StoragePolicy(name="P:strorg:uo", property=@StorageProperty(name="strorguo:descrizione")) - public java.lang.String getDs_unita_organizzativa() { - Unita_organizzativaBulk uo = this.getUo(); - if (uo == null) - return null; - return uo.getDs_unita_organizzativa(); - } - - /** - * @return it.cnr.contab.anagraf00.core.bulk.TerzoBulk - */ - public it.cnr.contab.anagraf00.core.bulk.TerzoBulk getTerzo() { - return terzo; - } - /** - * @return it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk - */ - public it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk getUo() { - return uo; - } - /** - * Inizializza l'Oggetto Bulk per la ricerca. - * @param bp Il Business Process in uso - * @param context Il contesto dell'azione - * @return OggettoBulk L'oggetto bulk inizializzato - */ - public OggettoBulk initializeForSearch(it.cnr.jada.util.action.CRUDBP bp,it.cnr.jada.action.ActionContext context) - { - setEsercizio( ((CNRUserContext)context.getUserContext()).getEsercizio() ); - - try { - if (!isUoDistintaTuttaSac(context)) - setUo(it.cnr.contab.utenze00.bulk.CNRUserInfo.getUnita_organizzativa(context)); - } catch (ComponentException e) { - throw new it.cnr.jada.DetailedRuntimeException(e); - } catch (RemoteException e1) { - throw new it.cnr.jada.DetailedRuntimeException(e1); - } - - return this; - } - // l'oggetto è un Mandato - public boolean isMandato() { - return Numerazione_doc_contBulk.TIPO_MAN.equals( getCd_tipo_documento_cont()); - } - // l'oggetto è un Mandato di Accreditamento - public boolean isMandatoAccreditamento() { - return Numerazione_doc_contBulk.TIPO_MAN.equals( getCd_tipo_documento_cont()) && - MandatoBulk.TIPO_ACCREDITAMENTO.equals( getTi_documento_cont()); - } - // l'oggetto è una Reversale - public boolean isReversale() { - return Numerazione_doc_contBulk.TIPO_REV.equals( getCd_tipo_documento_cont()); - } - //l'oggetto è una Reversale di Trasferimento - public boolean isReversaleTrasferimento() { - return Numerazione_doc_contBulk.TIPO_REV.equals( getCd_tipo_documento_cont()) && - ReversaleBulk.TIPO_TRASFERIMENTO.equals( getTi_documento_cont()); - } - public boolean isROTerzo() - { - return terzo == null || terzo.getCrudStatus() == NORMAL; - } - public boolean isStato_trasmissioneToBeUpdated() { - return stato_trasmissioneToBeUpdated; - } - public void setCd_terzo(Integer cd_terzo) { - this.getTerzo().setCd_terzo(cd_terzo); - } - public void setCd_unita_organizzativa(String cd_uo) { - this.getUo().setCd_unita_organizzativa(cd_uo); - } - public void setStato_trasmissioneToBeUpdated(boolean newStato_trasmissioneToBeUpdated) { - stato_trasmissioneToBeUpdated = newStato_trasmissioneToBeUpdated; - } - /** - * @param newTerzo it.cnr.contab.anagraf00.core.bulk.TerzoBulk - */ - public void setTerzo(it.cnr.contab.anagraf00.core.bulk.TerzoBulk newTerzo) { - terzo = newTerzo; - } - /** - * @param newUo it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk - */ - public void setUo(it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk newUo) { - uo = newUo; - } - public boolean isUoDistintaTuttaSac(ActionContext context) throws ComponentException, RemoteException{ - Configurazione_cnrComponentSession sess = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession"); - if (sess.getVal01(context.getUserContext(), new Integer(0), null, "UO_SPECIALE", "UO_DISTINTA_TUTTA_SAC").equals(it.cnr.contab.utenze00.bulk.CNRUserInfo.getUnita_organizzativa(context).getCd_unita_organizzativa())) - { - return true; - } - return false; - } - /* - * Getter dell'attributo pg_distinta - */ - public java.lang.Long getPg_distinta() { - return pg_distinta; - } - /* - * Setter dell'attributo pg_distinta - */ - public void setPg_distinta(java.lang.Long pg_distinta) { - this.pg_distinta = pg_distinta; - } - - public String getCMISFolderName() { - String suffix = getCd_tipo_documento_cont().equalsIgnoreCase(it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_MAN) ? "Mandato n." : "Reversale n."; - suffix = suffix.concat(String.valueOf(getPg_documento_cont())); - return suffix; - } - - @Override - public String toString() { - return getCMISFolderName(); - } - - public String getStorePath() { - return Arrays.asList( - SpringUtil.getBean(StorePath.class).getPathComunicazioniDal(), - getCd_unita_organizzativa(), - getCd_tipo_documento_cont().equals(Numerazione_doc_contBulk.TIPO_MAN)?"Mandati":"Reversali", - Optional.ofNullable(getEsercizio()) - .map(esercizio -> String.valueOf(esercizio)) - .orElse("0"), - getCMISFolderName() - ).stream().collect( - Collectors.joining(StorageService.SUFFIX) - ); - } - - public String getCMISName() { - return (getCd_tipo_documento_cont().equalsIgnoreCase(Numerazione_doc_contBulk.TIPO_MAN) ? "Mandato n. " : "Reversale n. ") - + getPg_documento_cont() + - (Optional.ofNullable(getStato()) - .filter(stato -> stato.equals(MandatoBulk.STATO_MANDATO_ANNULLATO)) - .map(s -> " A.pdf") - .orElse(".pdf")); - - } - - public String getReportName() { - return getCd_tipo_documento_cont().equalsIgnoreCase(Numerazione_doc_contBulk.TIPO_MAN) ? "/doccont/doccont/vpg_man_rev_ass.jasper" : "/doccont/doccont/vpg_reversale.jasper"; - } - - public String getDocumento() { - return documento; - } - public void setDocumento(String documento) { - this.documento = documento; - } - - public BulkCollection[] getBulkLists() { - return new it.cnr.jada.bulk.BulkCollection[] { - archivioAllegati }; - } - public AllegatoGenericoBulk removeFromArchivioAllegati(int index) { - return getArchivioAllegati().remove(index); - } - public int addToArchivioAllegati(AllegatoGenericoBulk allegato) { - archivioAllegati.add(allegato); - return archivioAllegati.size()-1; - } - public BulkList getArchivioAllegati() { - return archivioAllegati; - } - public void setArchivioAllegati( - BulkList archivioAllegati) { - this.archivioAllegati = archivioAllegati; - } - public String getCssClassTi_cc_bi(){ - if(getTi_cc_bi().compareTo("B")==0) - return "TableColumnRedBold"; - else - return null; - } - - /** - * @return it.cnr.jada.bulk.BulkList - */ - public it.cnr.jada.bulk.BulkList getMandato_rigaColl() { - return mandato_rigaColl; - } - /** - * @param newMandato_rigaColl it.cnr.jada.bulk.BulkList - */ - public void setMandato_rigaColl(it.cnr.jada.bulk.BulkList newMandato_rigaColl) { - mandato_rigaColl = newMandato_rigaColl; - } -} +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package it.cnr.contab.doccont00.intcass.bulk; + +import it.cnr.contab.anagraf00.core.bulk.TerzoBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; +import it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession; +import it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk; +import it.cnr.contab.doccont00.core.bulk.MandatoBulk; +import it.cnr.contab.doccont00.core.bulk.Mandato_rigaIBulk; +import it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk; +import it.cnr.contab.doccont00.core.bulk.ReversaleBulk; +import it.cnr.contab.service.SpringUtil; +import it.cnr.contab.spring.service.StorePath; +import it.cnr.contab.util.Utility; +import it.cnr.contab.util.enumeration.EsitoOperazione; +import it.cnr.contab.util.enumeration.TipoDebitoSIOPE; +import it.cnr.si.spring.storage.StorageService; +import it.cnr.si.spring.storage.annotation.StoragePolicy; +import it.cnr.si.spring.storage.annotation.StorageProperty; +import it.cnr.si.spring.storage.annotation.StorageType; +import it.cnr.contab.utenze00.bp.CNRUserContext; +import it.cnr.contab.util00.bulk.storage.AllegatoGenericoBulk; +import it.cnr.contab.util00.bulk.storage.AllegatoParentBulk; +import it.cnr.jada.action.ActionContext; +import it.cnr.jada.bulk.BulkCollection; +import it.cnr.jada.bulk.BulkList; +import it.cnr.jada.bulk.OggettoBulk; +import it.cnr.jada.comp.ComponentException; + +import java.rmi.RemoteException; +import java.util.Arrays; +import java.util.Hashtable; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +@StorageType(name="D:doccont:document") +public class V_mandato_reversaleBulk extends V_mandato_reversaleBase implements AllegatoParentBulk, StatoTrasmissione{ + TerzoBulk terzo = new TerzoBulk(); + Unita_organizzativaBulk uo = new Unita_organizzativaBulk(); + boolean stato_trasmissioneToBeUpdated = false; + + // PG_DISTINTA DECIMAL(10,0) NOT NULL (PK) + private java.lang.Long pg_distinta; + private String documento; + private BulkList archivioAllegati = new BulkList(); + protected BulkList mandato_rigaColl = new BulkList(); + + public final static java.util.Dictionary cd_tipo_documento_contKeys; + static + { + cd_tipo_documento_contKeys = new java.util.Hashtable(); + cd_tipo_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_MAN, "Mandato"); + cd_tipo_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_REV, "Reversale"); + } + + public final static java.util.Dictionary ti_documento_contKeys; + static + { + ti_documento_contKeys = new it.cnr.jada.util.OrderedHashtable(); + ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.TIPO_PAGAMENTO, "Pagamento"); + ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.TIPO_ACCREDITAMENTO, "Accreditamento"); + ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.ReversaleBulk.TIPO_REGOLAM_SOSPESO, "Regolamento Sospeso"); + ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.ReversaleBulk.TIPO_REGOLARIZZAZIONE, "Regolarizzazione"); + ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.ReversaleBulk.TIPO_TRASFERIMENTO, "Trasferimento"); + ti_documento_contKeys.put(it.cnr.contab.doccont00.core.bulk.ReversaleBulk.TIPO_INCASSO, "Incasso"); + } + + public final static java.util.Dictionary statoKeys; + static + { + statoKeys = new it.cnr.jada.util.OrderedHashtable(); + statoKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_MANDATO_ANNULLATO, "Annullato"); + statoKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_MANDATO_EMESSO, "Emesso"); + statoKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_MANDATO_PAGATO, "Pagato/Incassato"); + } + public final static java.util.Dictionary stato_trasmissioneKeys; + static + { + stato_trasmissioneKeys = new it.cnr.jada.util.OrderedHashtable(); + stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_NON_INSERITO, "Non inserito in distinta"); + stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_PREDISPOSTO, "Predisposto alla Firma"); + stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_PRIMA_FIRMA, "Prima Firma"); + stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_INSERITO, "Inserito in distinta"); + stato_trasmissioneKeys.put(it.cnr.contab.doccont00.core.bulk.MandatoBulk.STATO_TRASMISSIONE_TRASMESSO, "Trasmesso"); + stato_trasmissioneKeys.put(StatoTrasmissione.ALL, "Tutti"); + + } + + public final static java.util.Dictionary ti_cc_biKeys; + static + { + ti_cc_biKeys = new it.cnr.jada.util.OrderedHashtable(); + ti_cc_biKeys.put(it.cnr.contab.doccont00.core.bulk.SospesoBulk.TIPO_CC, "C/C"); + ti_cc_biKeys.put(it.cnr.contab.doccont00.core.bulk.SospesoBulk.TIPO_BANCA_ITALIA, "Banca d'Italia"); + } + + public final static Map tipoDebitoSIOPEKeys = Arrays.asList(TipoDebitoSIOPE.values()) + .stream() + .collect(Collectors.toMap( + TipoDebitoSIOPE::value, + TipoDebitoSIOPE::label, + (oldValue, newValue) -> oldValue, + Hashtable::new + )); + + public final static Map esito_OperazioneKeys = Arrays.asList(EsitoOperazione.values()) + .stream() + .collect(Collectors.toMap( + EsitoOperazione::value, + EsitoOperazione::label, + (oldValue, newValue) -> oldValue, + Hashtable::new + )); + + public V_mandato_reversaleBulk() { + super(); + } + public V_mandato_reversaleBulk( Integer esercizio, String cd_tipo_documento_cont, String cd_cds, Long pg_documento_cont) { + super( esercizio, cd_tipo_documento_cont, cd_cds, pg_documento_cont ); + } + public Integer getCd_terzo() { + TerzoBulk terzo = this.getTerzo(); + if (terzo == null) + return null; + return terzo.getCd_terzo(); + } + @StoragePolicy(name="P:strorg:uo", property=@StorageProperty(name="strorguo:codice")) + public java.lang.String getCd_unita_organizzativa() { + Unita_organizzativaBulk uo = this.getUo(); + if (uo == null) + return null; + return uo.getCd_unita_organizzativa(); + } + @StoragePolicy(name="P:strorg:uo", property=@StorageProperty(name="strorguo:descrizione")) + public java.lang.String getDs_unita_organizzativa() { + Unita_organizzativaBulk uo = this.getUo(); + if (uo == null) + return null; + return uo.getDs_unita_organizzativa(); + } + + /** + * @return it.cnr.contab.anagraf00.core.bulk.TerzoBulk + */ + public it.cnr.contab.anagraf00.core.bulk.TerzoBulk getTerzo() { + return terzo; + } + /** + * @return it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk + */ + public it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk getUo() { + return uo; + } + /** + * Inizializza l'Oggetto Bulk per la ricerca. + * @param bp Il Business Process in uso + * @param context Il contesto dell'azione + * @return OggettoBulk L'oggetto bulk inizializzato + */ + public OggettoBulk initializeForSearch(it.cnr.jada.util.action.CRUDBP bp,it.cnr.jada.action.ActionContext context) + { + setEsercizio( ((CNRUserContext)context.getUserContext()).getEsercizio() ); + + try { + if (!isUoDistintaTuttaSac(context)) + setUo(it.cnr.contab.utenze00.bulk.CNRUserInfo.getUnita_organizzativa(context)); + } catch (ComponentException e) { + throw new it.cnr.jada.DetailedRuntimeException(e); + } catch (RemoteException e1) { + throw new it.cnr.jada.DetailedRuntimeException(e1); + } + + return this; + } + // l'oggetto è un Mandato + public boolean isMandato() { + return Numerazione_doc_contBulk.TIPO_MAN.equals( getCd_tipo_documento_cont()); + } + // l'oggetto è un Mandato di Accreditamento + public boolean isMandatoAccreditamento() { + return Numerazione_doc_contBulk.TIPO_MAN.equals( getCd_tipo_documento_cont()) && + MandatoBulk.TIPO_ACCREDITAMENTO.equals( getTi_documento_cont()); + } + // l'oggetto è una Reversale + public boolean isReversale() { + return Numerazione_doc_contBulk.TIPO_REV.equals( getCd_tipo_documento_cont()); + } + //l'oggetto è una Reversale di Trasferimento + public boolean isReversaleTrasferimento() { + return Numerazione_doc_contBulk.TIPO_REV.equals( getCd_tipo_documento_cont()) && + ReversaleBulk.TIPO_TRASFERIMENTO.equals( getTi_documento_cont()); + } + public boolean isROTerzo() + { + return terzo == null || terzo.getCrudStatus() == NORMAL; + } + public boolean isStato_trasmissioneToBeUpdated() { + return stato_trasmissioneToBeUpdated; + } + public void setCd_terzo(Integer cd_terzo) { + this.getTerzo().setCd_terzo(cd_terzo); + } + public void setCd_unita_organizzativa(String cd_uo) { + this.getUo().setCd_unita_organizzativa(cd_uo); + } + public void setStato_trasmissioneToBeUpdated(boolean newStato_trasmissioneToBeUpdated) { + stato_trasmissioneToBeUpdated = newStato_trasmissioneToBeUpdated; + } + /** + * @param newTerzo it.cnr.contab.anagraf00.core.bulk.TerzoBulk + */ + public void setTerzo(it.cnr.contab.anagraf00.core.bulk.TerzoBulk newTerzo) { + terzo = newTerzo; + } + /** + * @param newUo it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk + */ + public void setUo(it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk newUo) { + uo = newUo; + } + public boolean isUoDistintaTuttaSac(ActionContext context) throws ComponentException, RemoteException{ + return Utility.createConfigurazioneCnrComponentSession().isUOSpecialeDistintaTuttaSAC( + context.getUserContext(), + CNRUserContext.getEsercizio(context.getUserContext()), + it.cnr.contab.utenze00.bulk.CNRUserInfo.getUnita_organizzativa(context).getCd_unita_organizzativa()); + } + /* + * Getter dell'attributo pg_distinta + */ + public java.lang.Long getPg_distinta() { + return pg_distinta; + } + /* + * Setter dell'attributo pg_distinta + */ + public void setPg_distinta(java.lang.Long pg_distinta) { + this.pg_distinta = pg_distinta; + } + + public String getCMISFolderName() { + String suffix = getCd_tipo_documento_cont().equalsIgnoreCase(it.cnr.contab.doccont00.core.bulk.Numerazione_doc_contBulk.TIPO_MAN) ? "Mandato n." : "Reversale n."; + suffix = suffix.concat(String.valueOf(getPg_documento_cont())); + return suffix; + } + + @Override + public String toString() { + return getCMISFolderName(); + } + + public String getStorePath() { + return Arrays.asList( + SpringUtil.getBean(StorePath.class).getPathComunicazioniDal(), + getCd_unita_organizzativa(), + getCd_tipo_documento_cont().equals(Numerazione_doc_contBulk.TIPO_MAN)?"Mandati":"Reversali", + Optional.ofNullable(getEsercizio()) + .map(esercizio -> String.valueOf(esercizio)) + .orElse("0"), + getCMISFolderName() + ).stream().collect( + Collectors.joining(StorageService.SUFFIX) + ); + } + + public String getCMISName() { + return (getCd_tipo_documento_cont().equalsIgnoreCase(Numerazione_doc_contBulk.TIPO_MAN) ? "Mandato n. " : "Reversale n. ") + + getPg_documento_cont() + + (Optional.ofNullable(getStato()) + .filter(stato -> stato.equals(MandatoBulk.STATO_MANDATO_ANNULLATO)) + .map(s -> " A.pdf") + .orElse(".pdf")); + + } + + public String getReportName() { + return getCd_tipo_documento_cont().equalsIgnoreCase(Numerazione_doc_contBulk.TIPO_MAN) ? "/doccont/doccont/vpg_man_rev_ass.jasper" : "/doccont/doccont/vpg_reversale.jasper"; + } + + public String getDocumento() { + return documento; + } + public void setDocumento(String documento) { + this.documento = documento; + } + + public BulkCollection[] getBulkLists() { + return new it.cnr.jada.bulk.BulkCollection[] { + archivioAllegati }; + } + public AllegatoGenericoBulk removeFromArchivioAllegati(int index) { + return getArchivioAllegati().remove(index); + } + public int addToArchivioAllegati(AllegatoGenericoBulk allegato) { + archivioAllegati.add(allegato); + return archivioAllegati.size()-1; + } + public BulkList getArchivioAllegati() { + return archivioAllegati; + } + public void setArchivioAllegati( + BulkList archivioAllegati) { + this.archivioAllegati = archivioAllegati; + } + public String getCssClassTi_cc_bi(){ + if(getTi_cc_bi().compareTo("B")==0) + return "TableColumnRedBold"; + else + return null; + } + + /** + * @return it.cnr.jada.bulk.BulkList + */ + public it.cnr.jada.bulk.BulkList getMandato_rigaColl() { + return mandato_rigaColl; + } + /** + * @param newMandato_rigaColl it.cnr.jada.bulk.BulkList + */ + public void setMandato_rigaColl(it.cnr.jada.bulk.BulkList newMandato_rigaColl) { + mandato_rigaColl = newMandato_rigaColl; + } +} diff --git a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/bp/PdGVariazioneBP.java b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/bp/PdGVariazioneBP.java index 1d36c68f1b..94c910738a 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/bp/PdGVariazioneBP.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/bp/PdGVariazioneBP.java @@ -176,10 +176,8 @@ protected void initialize(it.cnr.jada.action.ActionContext context) throws it.cn if (Optional.ofNullable(annoFrom).isPresent()) setAnnoFromPianoEconomico(annoFrom.intValue()); - Configurazione_cnrBulk config = configSession.getConfigurazione(context.getUserContext(), CNRUserContext.getEsercizio(context.getUserContext()), null, Configurazione_cnrBulk.PK_UO_SPECIALE, Configurazione_cnrBulk.SK_UO_RAGIONERIA); - if (config==null) - config = configSession.getConfigurazione(context.getUserContext(), null, null, Configurazione_cnrBulk.PK_UO_SPECIALE, Configurazione_cnrBulk.SK_UO_RAGIONERIA); - setUoRagioneria(Optional.ofNullable(config).map(Configurazione_cnrBulk::getVal01).map(uoRagioneria->uoRagioneria.equals(getCentro_responsabilita_scrivania().getCd_unita_organizzativa())).orElse(Boolean.FALSE)); + String uoRagioneria = Utility.createConfigurazioneCnrComponentSession().getUoRagioneria(context.getUserContext(),CNRUserContext.getEsercizio(context.getUserContext())); + setUoRagioneria(Optional.ofNullable(uoRagioneria).map(el->el.equals(getCentro_responsabilita_scrivania().getCd_unita_organizzativa())).orElse(Boolean.FALSE)); } catch (ComponentException e) { throw handleException(e); } catch (RemoteException e) { diff --git a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/CRUDCostoDelDipendenteComponent.java b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/CRUDCostoDelDipendenteComponent.java index ad137d4663..590dc1242d 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/CRUDCostoDelDipendenteComponent.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/CRUDCostoDelDipendenteComponent.java @@ -1,326 +1,327 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package it.cnr.contab.pdg00.comp; - -import java.sql.PreparedStatement; -import java.util.List; - -import it.cnr.contab.config00.esercizio.bulk.*; -import it.cnr.contab.config00.ejb.*; -import it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk; -import it.cnr.contab.utenze00.bulk.*; -import it.cnr.contab.config00.sto.bulk.*; -import it.cnr.contab.doccont00.core.bulk.MandatoBulk; -import it.cnr.contab.doccont00.core.bulk.ObbligazioneBulk; -import it.cnr.contab.doccont00.core.bulk.ObbligazioneHome; -import it.cnr.contab.doccont00.core.bulk.Stampa_registro_accertamentiBulk; -import it.cnr.contab.doccont00.tabrif.bulk.Tipo_bolloBulk; -import it.cnr.contab.pdg00.cdip.bulk.*; -import it.cnr.contab.utenze00.bp.*; -import it.cnr.jada.*; -import it.cnr.jada.bulk.*; -import it.cnr.jada.comp.*; -import it.cnr.jada.persistency.PersistencyException; -import it.cnr.jada.persistency.sql.*; - -public class CRUDCostoDelDipendenteComponent extends it.cnr.jada.comp.CRUDComponent implements ICRUDCostoDelDipendenteMgr { -/** - * CostoDelDipendenteComponent constructor comment. - */ -public CRUDCostoDelDipendenteComponent() { - super(); -} -/* - * Pre-post-conditions: - * - * Nome: Dipendente non modificabile - * Pre: Viene richiesta l'inizializzazione per modifica dei costi del dipendente. - * Per la matricola specificata esiste già una ripartizione dei costi. - * Post: Viene impostato a false il flag "modificabile" del V_dipendenteBulk restituito - * Nome: Tutti i controlli superati - * Pre: Viene richiesta l'inizializzazione per modifica dei costi del dipendente. - * Nessuna delle altre pre-condizioni è verificata. - * Post: Viene caricato un oggetto V_dipendenteBulk per la matricola specificata e l'elenco - * dei costi per voce del pdc (Costo_del_dipendenteBulk) - */ - -protected void initializeKeysAndOptionsInto(UserContext usercontext, OggettoBulk oggettobulk) throws ComponentException{ - if (oggettobulk instanceof Stipendi_cofi_coriBulk) - { - try { - Stipendi_cofiHome stipendi_cofiHome = (Stipendi_cofiHome)getHome(usercontext, it.cnr.contab.pdg00.cdip.bulk.Stipendi_cofiBulk.class); - java.util.Collection stipendi_cofi; - stipendi_cofi = stipendi_cofiHome.findStipendiCofiAnno(usercontext); - ((Stipendi_cofi_coriBulk)oggettobulk).setTipoStipendi_cofi(stipendi_cofi); - ((Stipendi_cofi_coriBulk)oggettobulk).setEsercizio(CNRUserContext.getEsercizio(usercontext)); - } catch (PersistencyException e) { - throw new ComponentException(e); - } - } - if (oggettobulk instanceof Stipendi_cofi_obb_scadBulk) - { - try { - Stipendi_cofiHome stipendi_cofiHome = (Stipendi_cofiHome)getHome(usercontext, it.cnr.contab.pdg00.cdip.bulk.Stipendi_cofiBulk.class); - java.util.Collection stipendi_cofi; - stipendi_cofi = stipendi_cofiHome.findStipendiCofiAnno(usercontext); - ((Stipendi_cofi_obb_scadBulk)oggettobulk).setTipoStipendi_cofi(stipendi_cofi); - ((Stipendi_cofi_obb_scadBulk)oggettobulk).setEsercizio(CNRUserContext.getEsercizio(usercontext)); - } catch (PersistencyException e) { - throw new ComponentException(e); - } - } - super.initializeKeysAndOptionsInto(usercontext,oggettobulk); -} -public Stipendi_cofiVirtualBulk caricaDettagliFiltrati(UserContext userContext,OggettoBulk bulk, CompoundFindClause clause) throws ComponentException{ - try { - Stipendi_cofiVirtualBulk stipendi_cofiVirtual = (Stipendi_cofiVirtualBulk)bulk; - BulkHome home = getHome(userContext,Stipendi_cofi_obbBulk.class); - SQLBuilder sql = home.createSQLBuilder(); - sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); - sql.addClause(clause); - stipendi_cofiVirtual.setStipendi_obbligazioni(new BulkList(home.fetchAll(sql))); - return stipendi_cofiVirtual; - } catch (PersistencyException e) { - throw new ComponentException(e); - } -} - -public OggettoBulk inizializzaBulkPerModifica(UserContext userContext,OggettoBulk bulk) throws it.cnr.jada.comp.ComponentException { - if (bulk instanceof Stipendi_cofi_coriBulk || bulk instanceof Stipendi_cofi_obb_scadBulk ) - return super.inizializzaBulkPerModifica(userContext,bulk); - - if (bulk instanceof Stipendi_cofiVirtualBulk) - { - Stipendi_cofiVirtualBulk stipendi_cofiVirtual = (Stipendi_cofiVirtualBulk)bulk; - - BulkHome home = getHome(userContext,Stipendi_cofi_obbBulk.class); - SQLBuilder sql = home.createSQLBuilder(); - sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); - sql.addClause("AND","esercizio_obbligazione",sql.EQUALS,stipendi_cofiVirtual.getObbligazioni().getEsercizio()); - sql.addClause("AND","cd_cds_obbligazione",sql.EQUALS,stipendi_cofiVirtual.getObbligazioni().getCd_cds()); - sql.addClause("AND","esercizio_ori_obbligazione",sql.EQUALS,stipendi_cofiVirtual.getObbligazioni().getEsercizio_originale()); - sql.addClause("AND","pg_obbligazione",sql.EQUALS,stipendi_cofiVirtual.getObbligazioni().getPg_obbligazione()); - try { - stipendi_cofiVirtual.setStipendi_obbligazioni(new BulkList(home.fetchAll(sql))); - getHomeCache(userContext).fetchAll(userContext); - return stipendi_cofiVirtual; - } catch (PersistencyException e) { - throw new ComponentException(e); - } - } - - try { - V_dipendenteBulk dipendente = (V_dipendenteBulk)bulk; - - BulkHome home = getHome(userContext,Costo_del_dipendenteBulk.class); - SQLBuilder sql = home.createSQLBuilder(); - sql.addClause("AND","id_matricola",sql.EQUALS,dipendente.getId_matricola()); - sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); - sql.addClause("AND","mese",sql.EQUALS,dipendente.getMese()); - dipendente.setCosti_per_elemento_voce(new BulkList(home.fetchAll(sql))); - getHomeCache(userContext).fetchAll(userContext); - - boolean modificabile = isDipendenteModificabile(userContext,dipendente.getId_matricola(),dipendente.getMese()); - - if (modificabile) { - UtenteBulk utente = (UtenteBulk)getHome(userContext,UtenteBulk.class).findByPrimaryKey(new it.cnr.contab.utenze00.bulk.UtenteBulk(userContext.getUser())); - Configurazione_cnrComponentSession config = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession"); - modificabile = config.getVal01(userContext,null,null,"CDR_SPECIALE","CDR_PERSONALE").equals(it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cdr(userContext)); - } - - if (!modificabile) - return asRO(dipendente,"Importi non modificabili per questa matricola."); - - return dipendente; - } catch(Throwable e) { - throw handleException(e); - } -} -/** - * Testa se la matricola specificata possiede una ripartizione dei costi nell'esercizio di - * scrivania. - */ -private boolean isDipendenteModificabile(UserContext userContext,String matricola,Integer mese) throws it.cnr.jada.comp.ComponentException { - try { - SQLBuilder sql_exists = getHome(userContext,Ass_cdp_laBulk.class).createSQLBuilder(); - sql_exists.addClause("AND","id_matricola",sql_exists.EQUALS,matricola); - sql_exists.addClause("AND","esercizio",sql_exists.EQUALS,CNRUserContext.getEsercizio(userContext)); - sql_exists.addClause("AND","mese",sql_exists.EQUALS,mese); - if (sql_exists.executeExistsQuery(getConnection(userContext))) - return false; - sql_exists = getHome(userContext,Ass_cdp_uoBulk.class).createSQLBuilder(); - sql_exists.addClause("AND","id_matricola",sql_exists.EQUALS,matricola); - sql_exists.addClause("AND","esercizio",sql_exists.EQUALS,CNRUserContext.getEsercizio(userContext)); - sql_exists.addClause("AND","mese",sql_exists.EQUALS,mese); - if (sql_exists.executeExistsQuery(getConnection(userContext))) - return false; - return true; - } catch(java.sql.SQLException e) { - throw handleException(e); - } -} -protected boolean isEsercizioChiuso(UserContext userContext,Unita_organizzativaBulk uo) throws ComponentException { - try { - if (uo.getCd_unita_padre() == null) - uo = (Unita_organizzativaBulk)getHome(userContext,uo).findByPrimaryKey(uo); - EsercizioHome home = (EsercizioHome)getHome(userContext,EsercizioBulk.class); - return home.isEsercizioChiuso(userContext,CNRUserContext.getEsercizio(userContext),uo.getCd_unita_padre()); - } catch(it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } -} -/** - * Mette un lock su tutti i record di COSTI_DEL_DIPENDENTE per la matricola specificata - */ -private void lockMatricola(UserContext userContext,String id_matricola,Integer mese) throws ComponentException, BusyResourceException { - try { - SQLBuilder sql = getHome(userContext,Costo_del_dipendenteBulk.class).createSQLBuilder(); - sql.addSQLClause("AND","ESERCIZIO",sql.EQUALS,it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); - sql.addSQLClause("AND","ID_MATRICOLA",sql.EQUALS,id_matricola); - sql.addSQLClause("AND","MESE",sql.EQUALS,mese); - sql.setForUpdate(true); - LoggableStatement stm = sql.prepareStatement(getConnection(userContext)); - try { - java.sql.ResultSet rs = stm.executeQuery(); - while (rs.next()); - } finally { - try{stm.close();}catch( java.sql.SQLException e ){}; - } - } catch(java.sql.SQLException e) { - throw new BusyResourceException(); - } -} -/* - * Pre-post-conditions: - * - * Nome: Dipendente non modificabile - * Pre: Viene richiesta la modifica dei costi del dipendente ma per la matricola specificata - * esiste già una ripartizione dei costi. - * Post: Viene generata una ApplicationException con il messaggio: "Dipendente non modificabile perchè è già stata fatta una ripartizione dei costi." - * Nome: Unità organizzativa del dipendente modificata - * Pre: Viene richiesta la modifica dei costi del dipendente ed è stata modificata - * l'unità organizzativa di appartenenza. - * Post: Viene eliminata la matricola specificata dalla tabella COSTO_DEL_DIPENDENTE e - * vengono inseriti nuovi record nella stessa tabella con la nuova u.o - * Nome: Tutti i controlli superati - * Pre: Viene richiesta la modifica dei costi del dipendente. - * Nessuna delle altre pre-condizioni è verificata. - * Post: Vengono salvati i costi del dipendente. - */ -public OggettoBulk modificaConBulk(UserContext userContext,OggettoBulk bulk) throws it.cnr.jada.comp.ComponentException { - if (bulk instanceof Stipendi_cofi_coriBulk || bulk instanceof Stipendi_cofi_obb_scadBulk - || bulk instanceof Stipendi_cofiVirtualBulk) - return super.modificaConBulk(userContext,bulk); - try { - V_dipendenteBulk dipendente = (V_dipendenteBulk)bulk; - - if (!isDipendenteModificabile(userContext,dipendente.getId_matricola(),dipendente.getMese())) - throw new ApplicationException("Dipendente non modificabile perchè è già stata fatta una ripartizione dei costi."); - if (dipendente.getUnita_organizzativa() == null || - dipendente.getUnita_organizzativa().getCrudStatus() != dipendente.NORMAL) - throw new ApplicationException("E' necessario specificare una unità organizzativa."); - - // 05/09/2003 - // Aggiunto controllo sulla chiusura dell'esercizio - if (isEsercizioChiuso(userContext,dipendente.getUnita_organizzativa())) - throw new ApplicationException("Importi non modificabili ad esercizio chiuso."); - - lockMatricola(userContext,dipendente.getId_matricola(),dipendente.getMese()); - V_dipendenteBulk dipendente_orig = (V_dipendenteBulk)getHome(userContext,dipendente).findByPrimaryKey(dipendente); - - for (java.util.Iterator i = dipendente.getCosti_per_elemento_voce().iterator();i.hasNext();) - checkSQLConstraints(userContext,(Costo_del_dipendenteBulk)i.next()); - - if (dipendente_orig.getUnita_organizzativa() != null && - dipendente_orig.getCd_unita_organizzativa().equals(dipendente.getCd_unita_organizzativa())) { - makeBulkListPersistent(userContext,dipendente.getCosti_per_elemento_voce()); - } else { - if (isEsercizioChiuso(userContext,dipendente_orig.getUnita_organizzativa())) - throw new ApplicationException("Non è possibile modificare l'unità organizzativa della matricola perchè l'esercizio è chiuso."); - - for (java.util.Iterator i = dipendente.getCosti_per_elemento_voce().iterator();i.hasNext();) { - Costo_del_dipendenteBulk cdd = (Costo_del_dipendenteBulk)i.next(); - deleteBulk(userContext,cdd); - cdd.setCd_unita_organizzativa(dipendente.getCd_unita_organizzativa()); - cdd.setUser(CNRUserContext.getUser(userContext)); - insertBulk(userContext,cdd); - } - } - return bulk; - } catch(Throwable e) { - throw handleException(e); - } -} -protected Query select(UserContext userContext,CompoundFindClause clauses,OggettoBulk bulk) throws ComponentException, it.cnr.jada.persistency.PersistencyException { - if (bulk instanceof Stipendi_cofi_coriBulk || bulk instanceof Stipendi_cofi_obb_scadBulk){ - if (clauses == null) { - if (bulk != null) - clauses = bulk.buildFindClauses(null); - } - SQLBuilder sql = getHome(userContext,bulk).selectByClause(clauses); - sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); - return sql; - } - if (bulk instanceof Stipendi_cofiVirtualBulk){ - if (clauses == null) { - if (bulk != null) - clauses = bulk.buildFindClauses(null); - } - Stipendi_cofiVirtualBulk stipendi_cofiVirtual = (Stipendi_cofiVirtualBulk)bulk; - SQLBuilder sql = getHome(userContext,Stipendi_cofi_obbBulk.class).selectByClause(clauses); - sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); - BulkHome home = getHome(userContext,Stipendi_cofi_obbBulk.class); - stipendi_cofiVirtual.setStipendi_obbligazioni(new BulkList(home.fetchAll(sql))); - getHomeCache(userContext).fetchAll(userContext); - return sql; - } - if (clauses == null) { - if (bulk != null) - clauses = bulk.buildFindClauses(null); - } else - clauses = it.cnr.jada.persistency.sql.CompoundFindClause.and(clauses,bulk.buildFindClauses(Boolean.FALSE)); - if (clauses == null || !clauses.iterator().hasNext()) - throw new ApplicationException("E' necessario specificare almeno una clausola di ricerca."); - SQLBuilder sql = getHome(userContext,bulk).selectByClause(clauses); - V_dipendenteBulk dipendente = (V_dipendenteBulk)bulk; - sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); - if (dipendente.getMese() == null) - sql.addClause("AND","mese",sql.NOT_EQUALS,new Integer(0)); - return sql; -} -public SQLBuilder selectStipendi_cofi_obbByClause(UserContext userContext, Stipendi_cofi_obb_scadBulk obb_scad, Stipendi_cofi_obbBulk obb, CompoundFindClause clauses) throws ComponentException { - - Stipendi_cofi_obbHome home = (Stipendi_cofi_obbHome)getHome(userContext, Stipendi_cofi_obbBulk.class); - SQLBuilder sql = home.createSQLBuilder(); - sql.addClause("AND", "esercizio", sql.EQUALS, obb_scad.getEsercizio()); - sql.addClause(clauses); - return sql; -} - -public SQLBuilder selectObbligazioniByClause(UserContext userContext, Stipendi_cofi_obbBulk stiObb, ObbligazioneBulk obb, CompoundFindClause clauses) throws ComponentException { - - ObbligazioneHome home = (ObbligazioneHome)getHome(userContext, ObbligazioneBulk.class); - SQLBuilder sql = home.createSQLBuilder(); - sql.addTableToHeader("UNITA_ORGANIZZATIVA"); - sql.addSQLJoin("OBBLIGAZIONE.CD_CDS","UNITA_ORGANIZZATIVA.CD_UNITA_ORGANIZZATIVA"); - sql.addSQLClause("AND", "esercizio", sql.EQUALS, stiObb.getEsercizio()); - sql.addSQLClause("AND", "UNITA_ORGANIZZATIVA.CD_TIPO_UNITA", sql.EQUALS, it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC ); - sql.addClause(clauses); - return sql; -} -} +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package it.cnr.contab.pdg00.comp; + +import java.sql.PreparedStatement; +import java.util.List; +import java.util.Optional; + +import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; +import it.cnr.contab.config00.esercizio.bulk.*; +import it.cnr.contab.config00.ejb.*; +import it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk; +import it.cnr.contab.utenze00.bulk.*; +import it.cnr.contab.config00.sto.bulk.*; +import it.cnr.contab.doccont00.core.bulk.MandatoBulk; +import it.cnr.contab.doccont00.core.bulk.ObbligazioneBulk; +import it.cnr.contab.doccont00.core.bulk.ObbligazioneHome; +import it.cnr.contab.doccont00.core.bulk.Stampa_registro_accertamentiBulk; +import it.cnr.contab.doccont00.tabrif.bulk.Tipo_bolloBulk; +import it.cnr.contab.pdg00.cdip.bulk.*; +import it.cnr.contab.utenze00.bp.*; +import it.cnr.jada.*; +import it.cnr.jada.bulk.*; +import it.cnr.jada.comp.*; +import it.cnr.jada.persistency.PersistencyException; +import it.cnr.jada.persistency.sql.*; + +public class CRUDCostoDelDipendenteComponent extends it.cnr.jada.comp.CRUDComponent implements ICRUDCostoDelDipendenteMgr { +/** + * CostoDelDipendenteComponent constructor comment. + */ +public CRUDCostoDelDipendenteComponent() { + super(); +} +/* + * Pre-post-conditions: + * + * Nome: Dipendente non modificabile + * Pre: Viene richiesta l'inizializzazione per modifica dei costi del dipendente. + * Per la matricola specificata esiste già una ripartizione dei costi. + * Post: Viene impostato a false il flag "modificabile" del V_dipendenteBulk restituito + * Nome: Tutti i controlli superati + * Pre: Viene richiesta l'inizializzazione per modifica dei costi del dipendente. + * Nessuna delle altre pre-condizioni è verificata. + * Post: Viene caricato un oggetto V_dipendenteBulk per la matricola specificata e l'elenco + * dei costi per voce del pdc (Costo_del_dipendenteBulk) + */ + +protected void initializeKeysAndOptionsInto(UserContext usercontext, OggettoBulk oggettobulk) throws ComponentException{ + if (oggettobulk instanceof Stipendi_cofi_coriBulk) + { + try { + Stipendi_cofiHome stipendi_cofiHome = (Stipendi_cofiHome)getHome(usercontext, it.cnr.contab.pdg00.cdip.bulk.Stipendi_cofiBulk.class); + java.util.Collection stipendi_cofi; + stipendi_cofi = stipendi_cofiHome.findStipendiCofiAnno(usercontext); + ((Stipendi_cofi_coriBulk)oggettobulk).setTipoStipendi_cofi(stipendi_cofi); + ((Stipendi_cofi_coriBulk)oggettobulk).setEsercizio(CNRUserContext.getEsercizio(usercontext)); + } catch (PersistencyException e) { + throw new ComponentException(e); + } + } + if (oggettobulk instanceof Stipendi_cofi_obb_scadBulk) + { + try { + Stipendi_cofiHome stipendi_cofiHome = (Stipendi_cofiHome)getHome(usercontext, it.cnr.contab.pdg00.cdip.bulk.Stipendi_cofiBulk.class); + java.util.Collection stipendi_cofi; + stipendi_cofi = stipendi_cofiHome.findStipendiCofiAnno(usercontext); + ((Stipendi_cofi_obb_scadBulk)oggettobulk).setTipoStipendi_cofi(stipendi_cofi); + ((Stipendi_cofi_obb_scadBulk)oggettobulk).setEsercizio(CNRUserContext.getEsercizio(usercontext)); + } catch (PersistencyException e) { + throw new ComponentException(e); + } + } + super.initializeKeysAndOptionsInto(usercontext,oggettobulk); +} +public Stipendi_cofiVirtualBulk caricaDettagliFiltrati(UserContext userContext,OggettoBulk bulk, CompoundFindClause clause) throws ComponentException{ + try { + Stipendi_cofiVirtualBulk stipendi_cofiVirtual = (Stipendi_cofiVirtualBulk)bulk; + BulkHome home = getHome(userContext,Stipendi_cofi_obbBulk.class); + SQLBuilder sql = home.createSQLBuilder(); + sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); + sql.addClause(clause); + stipendi_cofiVirtual.setStipendi_obbligazioni(new BulkList(home.fetchAll(sql))); + return stipendi_cofiVirtual; + } catch (PersistencyException e) { + throw new ComponentException(e); + } +} + +public OggettoBulk inizializzaBulkPerModifica(UserContext userContext,OggettoBulk bulk) throws it.cnr.jada.comp.ComponentException { + if (bulk instanceof Stipendi_cofi_coriBulk || bulk instanceof Stipendi_cofi_obb_scadBulk ) + return super.inizializzaBulkPerModifica(userContext,bulk); + + if (bulk instanceof Stipendi_cofiVirtualBulk) + { + Stipendi_cofiVirtualBulk stipendi_cofiVirtual = (Stipendi_cofiVirtualBulk)bulk; + + BulkHome home = getHome(userContext,Stipendi_cofi_obbBulk.class); + SQLBuilder sql = home.createSQLBuilder(); + sql.addClause(FindClause.AND,"esercizio",SQLBuilder.EQUALS,CNRUserContext.getEsercizio(userContext)); + sql.addClause(FindClause.AND,"esercizio_obbligazione",SQLBuilder.EQUALS,stipendi_cofiVirtual.getObbligazioni().getEsercizio()); + sql.addClause(FindClause.AND,"cd_cds_obbligazione",SQLBuilder.EQUALS,stipendi_cofiVirtual.getObbligazioni().getCd_cds()); + sql.addClause(FindClause.AND,"esercizio_ori_obbligazione",SQLBuilder.EQUALS,stipendi_cofiVirtual.getObbligazioni().getEsercizio_originale()); + sql.addClause(FindClause.AND,"pg_obbligazione",SQLBuilder.EQUALS,stipendi_cofiVirtual.getObbligazioni().getPg_obbligazione()); + try { + stipendi_cofiVirtual.setStipendi_obbligazioni(new BulkList(home.fetchAll(sql))); + getHomeCache(userContext).fetchAll(userContext); + return stipendi_cofiVirtual; + } catch (PersistencyException e) { + throw new ComponentException(e); + } + } + + try { + V_dipendenteBulk dipendente = (V_dipendenteBulk)bulk; + + BulkHome home = getHome(userContext,Costo_del_dipendenteBulk.class); + SQLBuilder sql = home.createSQLBuilder(); + sql.addClause(FindClause.AND,"id_matricola",SQLBuilder.EQUALS,dipendente.getId_matricola()); + sql.addClause(FindClause.AND,"esercizio",SQLBuilder.EQUALS,CNRUserContext.getEsercizio(userContext)); + sql.addClause(FindClause.AND,"mese",SQLBuilder.EQUALS,dipendente.getMese()); + dipendente.setCosti_per_elemento_voce(new BulkList(home.fetchAll(sql))); + getHomeCache(userContext).fetchAll(userContext); + + boolean modificabile = isDipendenteModificabile(userContext,dipendente.getId_matricola(),dipendente.getMese()); + + if (modificabile) + modificabile = Optional.ofNullable(((Configurazione_cnrHome)getHome(userContext, Configurazione_cnrBulk.class)).getCdrPersonale(CNRUserContext.getEsercizio(userContext))) + .filter(cdrPersonale->cdrPersonale.equals(CNRUserContext.getCd_cdr(userContext))).isPresent(); + + if (!modificabile) + return asRO(dipendente,"Importi non modificabili per questa matricola."); + + return dipendente; + } catch(Throwable e) { + throw handleException(e); + } +} +/** + * Testa se la matricola specificata possiede una ripartizione dei costi nell'esercizio di + * scrivania. + */ +private boolean isDipendenteModificabile(UserContext userContext,String matricola,Integer mese) throws it.cnr.jada.comp.ComponentException { + try { + SQLBuilder sql_exists = getHome(userContext,Ass_cdp_laBulk.class).createSQLBuilder(); + sql_exists.addClause("AND","id_matricola",sql_exists.EQUALS,matricola); + sql_exists.addClause("AND","esercizio",sql_exists.EQUALS,CNRUserContext.getEsercizio(userContext)); + sql_exists.addClause("AND","mese",sql_exists.EQUALS,mese); + if (sql_exists.executeExistsQuery(getConnection(userContext))) + return false; + sql_exists = getHome(userContext,Ass_cdp_uoBulk.class).createSQLBuilder(); + sql_exists.addClause("AND","id_matricola",sql_exists.EQUALS,matricola); + sql_exists.addClause("AND","esercizio",sql_exists.EQUALS,CNRUserContext.getEsercizio(userContext)); + sql_exists.addClause("AND","mese",sql_exists.EQUALS,mese); + if (sql_exists.executeExistsQuery(getConnection(userContext))) + return false; + return true; + } catch(java.sql.SQLException e) { + throw handleException(e); + } +} +protected boolean isEsercizioChiuso(UserContext userContext,Unita_organizzativaBulk uo) throws ComponentException { + try { + if (uo.getCd_unita_padre() == null) + uo = (Unita_organizzativaBulk)getHome(userContext,uo).findByPrimaryKey(uo); + EsercizioHome home = (EsercizioHome)getHome(userContext,EsercizioBulk.class); + return home.isEsercizioChiuso(userContext,CNRUserContext.getEsercizio(userContext),uo.getCd_unita_padre()); + } catch(it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } +} +/** + * Mette un lock su tutti i record di COSTI_DEL_DIPENDENTE per la matricola specificata + */ +private void lockMatricola(UserContext userContext,String id_matricola,Integer mese) throws ComponentException, BusyResourceException { + try { + SQLBuilder sql = getHome(userContext,Costo_del_dipendenteBulk.class).createSQLBuilder(); + sql.addSQLClause("AND","ESERCIZIO",sql.EQUALS,it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + sql.addSQLClause("AND","ID_MATRICOLA",sql.EQUALS,id_matricola); + sql.addSQLClause("AND","MESE",sql.EQUALS,mese); + sql.setForUpdate(true); + LoggableStatement stm = sql.prepareStatement(getConnection(userContext)); + try { + java.sql.ResultSet rs = stm.executeQuery(); + while (rs.next()); + } finally { + try{stm.close();}catch( java.sql.SQLException e ){}; + } + } catch(java.sql.SQLException e) { + throw new BusyResourceException(); + } +} +/* + * Pre-post-conditions: + * + * Nome: Dipendente non modificabile + * Pre: Viene richiesta la modifica dei costi del dipendente ma per la matricola specificata + * esiste già una ripartizione dei costi. + * Post: Viene generata una ApplicationException con il messaggio: "Dipendente non modificabile perchè è già stata fatta una ripartizione dei costi." + * Nome: Unità organizzativa del dipendente modificata + * Pre: Viene richiesta la modifica dei costi del dipendente ed è stata modificata + * l'unità organizzativa di appartenenza. + * Post: Viene eliminata la matricola specificata dalla tabella COSTO_DEL_DIPENDENTE e + * vengono inseriti nuovi record nella stessa tabella con la nuova u.o + * Nome: Tutti i controlli superati + * Pre: Viene richiesta la modifica dei costi del dipendente. + * Nessuna delle altre pre-condizioni è verificata. + * Post: Vengono salvati i costi del dipendente. + */ +public OggettoBulk modificaConBulk(UserContext userContext,OggettoBulk bulk) throws it.cnr.jada.comp.ComponentException { + if (bulk instanceof Stipendi_cofi_coriBulk || bulk instanceof Stipendi_cofi_obb_scadBulk + || bulk instanceof Stipendi_cofiVirtualBulk) + return super.modificaConBulk(userContext,bulk); + try { + V_dipendenteBulk dipendente = (V_dipendenteBulk)bulk; + + if (!isDipendenteModificabile(userContext,dipendente.getId_matricola(),dipendente.getMese())) + throw new ApplicationException("Dipendente non modificabile perchè è già stata fatta una ripartizione dei costi."); + if (dipendente.getUnita_organizzativa() == null || + dipendente.getUnita_organizzativa().getCrudStatus() != dipendente.NORMAL) + throw new ApplicationException("E' necessario specificare una unità organizzativa."); + + // 05/09/2003 + // Aggiunto controllo sulla chiusura dell'esercizio + if (isEsercizioChiuso(userContext,dipendente.getUnita_organizzativa())) + throw new ApplicationException("Importi non modificabili ad esercizio chiuso."); + + lockMatricola(userContext,dipendente.getId_matricola(),dipendente.getMese()); + V_dipendenteBulk dipendente_orig = (V_dipendenteBulk)getHome(userContext,dipendente).findByPrimaryKey(dipendente); + + for (java.util.Iterator i = dipendente.getCosti_per_elemento_voce().iterator();i.hasNext();) + checkSQLConstraints(userContext,(Costo_del_dipendenteBulk)i.next()); + + if (dipendente_orig.getUnita_organizzativa() != null && + dipendente_orig.getCd_unita_organizzativa().equals(dipendente.getCd_unita_organizzativa())) { + makeBulkListPersistent(userContext,dipendente.getCosti_per_elemento_voce()); + } else { + if (isEsercizioChiuso(userContext,dipendente_orig.getUnita_organizzativa())) + throw new ApplicationException("Non è possibile modificare l'unità organizzativa della matricola perchè l'esercizio è chiuso."); + + for (java.util.Iterator i = dipendente.getCosti_per_elemento_voce().iterator();i.hasNext();) { + Costo_del_dipendenteBulk cdd = (Costo_del_dipendenteBulk)i.next(); + deleteBulk(userContext,cdd); + cdd.setCd_unita_organizzativa(dipendente.getCd_unita_organizzativa()); + cdd.setUser(CNRUserContext.getUser(userContext)); + insertBulk(userContext,cdd); + } + } + return bulk; + } catch(Throwable e) { + throw handleException(e); + } +} +protected Query select(UserContext userContext,CompoundFindClause clauses,OggettoBulk bulk) throws ComponentException, it.cnr.jada.persistency.PersistencyException { + if (bulk instanceof Stipendi_cofi_coriBulk || bulk instanceof Stipendi_cofi_obb_scadBulk){ + if (clauses == null) { + if (bulk != null) + clauses = bulk.buildFindClauses(null); + } + SQLBuilder sql = getHome(userContext,bulk).selectByClause(clauses); + sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); + return sql; + } + if (bulk instanceof Stipendi_cofiVirtualBulk){ + if (clauses == null) { + if (bulk != null) + clauses = bulk.buildFindClauses(null); + } + Stipendi_cofiVirtualBulk stipendi_cofiVirtual = (Stipendi_cofiVirtualBulk)bulk; + SQLBuilder sql = getHome(userContext,Stipendi_cofi_obbBulk.class).selectByClause(clauses); + sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); + BulkHome home = getHome(userContext,Stipendi_cofi_obbBulk.class); + stipendi_cofiVirtual.setStipendi_obbligazioni(new BulkList(home.fetchAll(sql))); + getHomeCache(userContext).fetchAll(userContext); + return sql; + } + if (clauses == null) { + if (bulk != null) + clauses = bulk.buildFindClauses(null); + } else + clauses = it.cnr.jada.persistency.sql.CompoundFindClause.and(clauses,bulk.buildFindClauses(Boolean.FALSE)); + if (clauses == null || !clauses.iterator().hasNext()) + throw new ApplicationException("E' necessario specificare almeno una clausola di ricerca."); + SQLBuilder sql = getHome(userContext,bulk).selectByClause(clauses); + V_dipendenteBulk dipendente = (V_dipendenteBulk)bulk; + sql.addClause("AND","esercizio",sql.EQUALS,CNRUserContext.getEsercizio(userContext)); + if (dipendente.getMese() == null) + sql.addClause("AND","mese",sql.NOT_EQUALS,new Integer(0)); + return sql; +} +public SQLBuilder selectStipendi_cofi_obbByClause(UserContext userContext, Stipendi_cofi_obb_scadBulk obb_scad, Stipendi_cofi_obbBulk obb, CompoundFindClause clauses) throws ComponentException { + + Stipendi_cofi_obbHome home = (Stipendi_cofi_obbHome)getHome(userContext, Stipendi_cofi_obbBulk.class); + SQLBuilder sql = home.createSQLBuilder(); + sql.addClause("AND", "esercizio", sql.EQUALS, obb_scad.getEsercizio()); + sql.addClause(clauses); + return sql; +} + +public SQLBuilder selectObbligazioniByClause(UserContext userContext, Stipendi_cofi_obbBulk stiObb, ObbligazioneBulk obb, CompoundFindClause clauses) throws ComponentException { + + ObbligazioneHome home = (ObbligazioneHome)getHome(userContext, ObbligazioneBulk.class); + SQLBuilder sql = home.createSQLBuilder(); + sql.addTableToHeader("UNITA_ORGANIZZATIVA"); + sql.addSQLJoin("OBBLIGAZIONE.CD_CDS","UNITA_ORGANIZZATIVA.CD_UNITA_ORGANIZZATIVA"); + sql.addSQLClause("AND", "esercizio", sql.EQUALS, stiObb.getEsercizio()); + sql.addSQLClause("AND", "UNITA_ORGANIZZATIVA.CD_TIPO_UNITA", sql.EQUALS, it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC ); + sql.addClause(clauses); + return sql; +} +} diff --git a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/PdGPreventivoComponent.java b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/PdGPreventivoComponent.java index aeb05c21a1..8a46dda6df 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/PdGPreventivoComponent.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/PdGPreventivoComponent.java @@ -1,4857 +1,4855 @@ -/* - * Copyright (C) 2019 Consiglio Nazionale delle Ricerche - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package it.cnr.contab.pdg00.comp; -import it.cnr.contab.utenze00.bulk.*; -import it.cnr.contab.messaggio00.bulk.MessaggioBulk; -import it.cnr.contab.messaggio00.bulk.MessaggioHome; -import it.cnr.contab.prevent00.bulk.Pdg_aggregatoBulk; -import it.cnr.contab.prevent00.bulk.Bilancio_preventivoBulk; -import it.cnr.contab.anagraf00.core.bulk.TerzoBulk; -import it.cnr.contab.coepcoan00.core.bulk.Chiusura_coepBulk; -import it.cnr.contab.coepcoan00.core.bulk.Chiusura_coepHome; -import it.cnr.contab.config00.sto.bulk.CdsBulk; -import it.cnr.contab.config00.sto.bulk.CdsHome; -import it.cnr.contab.config00.sto.bulk.DipartimentoBulk; -import it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome; -import it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk; -import it.cnr.contab.config00.sto.bulk.Unita_organizzativa_enteBulk; -import it.cnr.contab.config00.sto.bulk.V_struttura_organizzativaBulk; -import it.cnr.contab.config00.sto.bulk.V_struttura_organizzativaHome; -import it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession; -import it.cnr.contab.config00.latt.bulk.WorkpackageBulk; -import it.cnr.contab.config00.pdcfin.bulk.*; -import it.cnr.contab.config00.sto.bulk.CdrBulk; -import it.cnr.contab.pdg00.bulk.*; -import it.cnr.contab.pdg00.cdip.bulk.Ass_pdg_variazione_cdrBulk; -import it.cnr.contab.pdg00.cdip.bulk.Ass_pdg_variazione_cdrHome; -import it.cnr.contab.pdg00.cdip.bulk.Stampa_rendiconto_finanziarioVBulk; -import it.cnr.contab.prevent00.bulk.Pdg_aggregato_etr_detBulk; -import it.cnr.contab.prevent00.bulk.Pdg_aggregato_spe_detBulk; -import it.cnr.contab.progettiric00.core.bulk.ProgettoBulk; -import it.cnr.contab.progettiric00.core.bulk.ProgettoHome; - -import it.cnr.contab.utenze00.bp.CNRUserContext; -import it.cnr.contab.utenze00.bulk.UtenteHome; -import it.cnr.contab.config00.sto.bulk.Unita_organizzativaHome; -import it.cnr.jada.UserContext; -import it.cnr.jada.bulk.*; -import it.cnr.jada.comp.ApplicationException; -import it.cnr.jada.comp.ComponentException; -import it.cnr.jada.comp.IPrintMgr; -import it.cnr.jada.persistency.IntrospectionException; -import it.cnr.jada.persistency.PersistencyException; -import it.cnr.jada.persistency.sql.*; -import it.cnr.jada.util.ejb.EJBCommonServices; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.util.Optional; -import java.util.Vector; - - -public class PdGPreventivoComponent extends PdGComponent implements it.cnr.jada.comp.ICRUDMgr, IPdGPreventivoTestataMgr, IPdGPreventivoDettagliMgr, IPrintMgr, Cloneable,Serializable { - - private static final java.math.BigDecimal ZERO = new java.math.BigDecimal(0); - - - - public PdGPreventivoComponent() - { - - /*Default constructor*/ - - - } -//^^@@ -/** - * default - * PreCondition: - * Viene richiesto l'annullamento dello scarico dei costi del dipendente per un pdg - * PostCondition: - * Viene invocata la stored procedure ORACLEannullaCDPSuPdg - */ -//^^@@ - public Pdg_preventivoBulk annullaCDPSuPdg(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ApplicationException, it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB060.annullaCDPSuPdg(?,?,?)}",false,this.getClass()); - cs.setObject( 1, pdg.getEsercizio() ); - cs.setString( 2, pdg.getCd_centro_responsabilita()); - cs.setObject( 3, userContext.getUser()); - try { - lockBulk(userContext,pdg); - cs.executeQuery(); - return caricaPdg(userContext,pdg.getCentro_responsabilita()); - } catch (Throwable e) { - throw handleException(pdg,e); - } finally { - cs.close(); - } - } catch (java.sql.SQLException e) { - throw handleSQLException(e); - } - } - -/** - * Utente AC - * PreCondition: - * l'utente appartiene al CDR Amministrazione Centrale - * PostCondition: - * Viene restituito un istanza di Pdg_preventivoBulk per il CDR 00 dell UO CDS SAC e l'elenco di tutti i CDR che possiedono PDG - * Tutti i controlli superati - * PreCondition: - * Nessun'altra precondizione verificata - * PostCondition: - * Viene restituito un'istanza di Pdg_preventivoBulk che per il CDR specificato più l'elenco dei CDR con livello di responsabilià inferiore al CDR specificato (listaCdrPdGPerUtente) - * Utente associato a CDR senza PDG - * PreCondition: - * Il cdr dell'utente non possiede un PDG - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il CdR non ha un piano di gestione associato!" - */ - -public Pdg_preventivoBulk caricaPdg (UserContext userContext,CdrBulk cdr) throws ComponentException { - try { - - if(cdr == null) - cdr = cdrFromUserContext(userContext); - int livelloResponsabilita = getLivelloResponsabilitaCDR(userContext, cdr); - - if(livelloResponsabilita == LV_AC) - cdr = ((it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext,CdrBulk.class)).findCdrSAC(it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); - - Pdg_preventivoBulk preventivo = new Pdg_preventivoBulk(); - -// preventivo.setCentro_responsabilita(new CdrBulk()); - - preventivo.setCentro_responsabilita(cdr); - -// preventivo.getCentro_responsabilita().setCd_centro_responsabilita(cdr.getCd_centro_responsabilita()); - preventivo.setEsercizio( - ((it.cnr.contab.utenze00.bp.CNRUserContext)userContext).getEsercizio() - ); - - try { - preventivo = (Pdg_preventivoBulk)getHome(userContext,preventivo).findByPrimaryKey(preventivo); - } catch (it.cnr.jada.persistency.PersistencyException e) { - throw new it.cnr.jada.comp.ComponentException(e); - } - - if (preventivo == null) - throw new it.cnr.jada.comp.ApplicationException("Piano di gestione non ancora aperto."); - - preventivo.setStatiKeys(loadStatiKeys(userContext, preventivo)); - -// preventivo.setElencoCdR(listaCdrPdGPerUtente(userContext)); - - getHomeCache(userContext).fetchAll(userContext); - - return preventivo; - } catch(PersistencyException e) { - throw handleException(e); - } -} - -/** - * Controllo di chiusura del pdg aggregato - * PreCondition: - * L'invocazione della stored procedure CNRCTB050.checkAggregatoChiuso ritorna 'Y' - * PostCondition: - * Lascia uscire true - * Tutti i controlli superati - * PreCondition: - * L'invocazione della stored procedure CNRCTB050.checkAggregatoChiuso ritorna 'N' - * PostCondition: - * Ritorna un'eccezione - */ -private void controllaAggregatoChiuso(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB050.checkAggregatoChiuso(?,?)}",false,this.getClass()); - try { - cs.registerOutParameter( 1, java.sql.Types.CHAR ); - cs.setObject( 2, pdg.getEsercizio() ); - cs.setString( 3, pdg.getCd_centro_responsabilita()); - cs.execute(); - if (cs.getString(1).equals("N")) - throw new it.cnr.jada.comp.ApplicationException("Il piano di gestione aggregato non è chiuso. Contattare il CDR di primo livello"); - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} - -private void controllaAggregatoPdgDetPositivo(UserContext userContext, Pdg_preventivoBulk pdg,Pdg_preventivo_detBulk pdg_dett) throws it.cnr.jada.comp.ComponentException { - if (pdg_dett instanceof Pdg_preventivo_etr_detBulk) - controllaAggregatoPdgEtrDetPositivo(userContext,pdg,(Pdg_preventivo_etr_detBulk)pdg_dett); - else if (pdg_dett instanceof Pdg_preventivo_spe_detBulk) - controllaAggregatoPdgSpeDetPositivo(userContext,pdg,(Pdg_preventivo_spe_detBulk)pdg_dett); -} - -private void controllaAggregatoPdgEtrDetPositivo(UserContext userContext, Pdg_preventivoBulk pdg,Pdg_preventivo_etr_detBulk pdg_det) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB075.checkAggrPdgEtrDetPositivo(?, ?, ?, ?, ?, ?, ?, ? )}",false,this.getClass()); - try { - cs.setInt( 1, pdg_det.getEsercizio().intValue() ); - cs.setString( 2, pdg_det.getCd_centro_responsabilita()); - cs.setString( 3, pdg_det.getCd_linea_attivita()); - cs.setString( 4, pdg_det.getTi_appartenenza()); - cs.setString( 5, pdg_det.getTi_gestione()); - cs.setString( 6, pdg_det.getCd_elemento_voce()); - cs.registerOutParameter( 7, java.sql.Types.VARCHAR ); - cs.registerOutParameter( 8, java.sql.Types.DECIMAL); - cs.execute(); - String columnName = cs.getString(7); - if (columnName != null) { - String columnDescription = columnName; - java.math.BigDecimal importo = cs.getBigDecimal(8); - ColumnMapping mapping = getHome(userContext,pdg_det).getColumnMap().getMappingForColumn(columnName); - if (mapping != null) { - FieldProperty property = BulkInfo.getBulkInfo(pdg_det.getClass()).getFieldProperty(mapping.getPropertyName()); - if (property != null) - columnDescription = property.getLabel(); - } - throw new it.cnr.jada.comp.ApplicationException("Si sta tentando di inserire un dettaglio con importi negativi sulla colonna "+columnDescription+", ma il totale per GAE e voce del piano è negativo ("+new it.cnr.contab.util.EuroFormat().format(importo)+")."); - } - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} - -private void controllaAggregatoPdgSpeDetPositivo(UserContext userContext, Pdg_preventivoBulk pdg,Pdg_preventivo_spe_detBulk pdg_det) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs =new LoggableStatement( getConnection( userContext ),"{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB075.checkAggrPdgSpeDetPositivo(?, ?, ?, ?, ?, ?, ?, ?, ? )}",false,this.getClass()); - try { - cs.setInt( 1, pdg_det.getEsercizio().intValue() ); - cs.setString( 2, pdg_det.getCd_centro_responsabilita()); - cs.setString( 3, pdg_det.getCd_linea_attivita()); - cs.setString( 4, pdg_det.getTi_appartenenza()); - cs.setString( 5, pdg_det.getTi_gestione()); - cs.setString( 6, pdg_det.getCd_elemento_voce()); - cs.setLong( 7, pdg_det.getPg_spesa().longValue()); - cs.registerOutParameter( 8, java.sql.Types.VARCHAR ); - cs.registerOutParameter( 9, java.sql.Types.DECIMAL); - cs.execute(); - String columnName = cs.getString(8); - if (columnName != null) { - String columnDescription = columnName; - java.math.BigDecimal importo = cs.getBigDecimal(9); - ColumnMapping mapping = getHome(userContext,pdg_det).getColumnMap().getMappingForColumn(columnName); - if (mapping != null) { - FieldProperty property = BulkInfo.getBulkInfo(pdg_det.getClass()).getFieldProperty(mapping.getPropertyName()); - if (property != null) - columnDescription = property.getLabel(); - } - throw new it.cnr.jada.comp.ApplicationException("Si sta tentando di inserire un dettaglio con importi negativi sulla colonna "+columnDescription+", ma il totale per GAE e voce del piano è negativo ("+new it.cnr.contab.util.EuroFormat().format(importo)+")."); - } - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} - -private void controllaBilancioPreventivoCdsApprovato(UserContext userContext,CdrBulk cdr) throws ComponentException { - try { - Unita_organizzativaBulk uo = (Unita_organizzativaBulk)getHome(userContext,Unita_organizzativaBulk.class).findByPrimaryKey(cdr.getUnita_padre()); - Bilancio_preventivoBulk bilancio = (Bilancio_preventivoBulk)getHome(userContext,Bilancio_preventivoBulk.class).findByPrimaryKey(new Bilancio_preventivoBulk( - uo.getCd_unita_padre(), - it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), - Elemento_voceHome.APPARTENENZA_CDS)); - if (bilancio == null) - throw new it.cnr.jada.comp.ApplicationException("Bilancio preventivo inesistente per il cds "+uo.getCd_unita_padre()); - if (!bilancio.STATO_C.equalsIgnoreCase(bilancio.getStato())) - throw new it.cnr.jada.comp.ApplicationException("Il bilancio preventivo del cds "+uo.getCd_unita_padre()+" deve essere approvato per riaprire il pdg per variazioni"); - } catch(Throwable e) { - throw handleException(e); - } -} -/** - * Verifica che il bilancio preventivo CNR sia approvato - * PreCondition: - * L'invocazione della stored procedure CNRCTB054.isBilancioCNRApprovato ritorna 'N' - * PostCondition: - * Viene segnalato con un'eccezione che il bilancio preventivo CNR non è approvato - * Tutti i controlli superati - * PreCondition: - * L'invocazione della stored procedure CNRCTB054.isBilancioCNRApprovato ritorna 'Y' - * PostCondition: - * Esce senza alcuna eccezione - */ -private void controllaBilPrevCnrApprovato(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB054.isBilancioCNRApprovato(?)}",false,this.getClass()); - try { - cs.registerOutParameter( 1, java.sql.Types.CHAR ); - cs.setObject( 2, pdg.getEsercizio() ); - cs.execute(); - if (cs.getString(1).equals("N")) - throw new it.cnr.jada.comp.ApplicationException("Il bilancio preventivo CNR non risulta ancora approvato"); - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} -/** - * Verifica che tutti i dettagli scaricati verso altra uo o cdr siano stati confermati - * PreCondition: - * L'invocazione della stored procedure CNRCTB050.checkDettScarConfermati ritorna 'N' - * PostCondition: - * Solleva un'eccezione - * Tutti i controlli superati - * PreCondition: - * L'invocazione della stored procedure CNRCTB050.checkDettScarConfermati ritorna 'Y' - * PostCondition: - * Esce senza segnalazioni - */ -private void controllaDettScarConfermati(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB050.checkDettScarConfermati(?,?)}",false,this.getClass()); - try { - cs.registerOutParameter( 1, java.sql.Types.CHAR ); - cs.setObject( 2, pdg.getEsercizio() ); - cs.setString( 3, pdg.getCd_centro_responsabilita()); - cs.execute(); - if (cs.getString(1).equals("N")) - throw new it.cnr.jada.comp.ApplicationException("Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata"); - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} -/** - * Pdg aggregato contiene discrepanze - * PreCondition: - * Le viste V_DPDG_AGGREGATO_ETR_DET_D e V_DPDG_AGGREGATO_SPE_DET_D contengono almeno un record - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Sono presenti importi complessivi non compatibili con i dati impostati dall'ente." - * Tuttti i controlli superati - * PreCondition: - * Nessun'altra precondizione è verificata - * PostCondition: - * Esce senza alcuna eccezione - */ -private void controllaDiscrepanzeAggregato(UserContext userContext,Pdg_preventivoBulk pdg,int livelloResponsabilita) throws ComponentException { - // Controllo della presenza di discrepanze nell'aggregato; va fatto solo per cdr di 1° livello e per le aree - if (livelloResponsabilita == 1 || - isCdrArea(userContext,pdg.getCentro_responsabilita())) { - - controllaDiscrepanzeAggregato(userContext,pdg,Pdg_aggregato_etr_detBulk.class,"V_DPDG_AGGREGATO_ETR_DET_D"); - controllaDiscrepanzeAggregato(userContext,pdg,Pdg_aggregato_spe_detBulk.class,"V_DPDG_AGGREGATO_SPE_DET_D"); - } -} -private void controllaDiscrepanzeAggregato(UserContext userContext,Pdg_preventivoBulk pdg,Class dettagliClass,String vista) throws ComponentException { - try { - PersistentHome home = getHome(userContext,dettagliClass,vista); - it.cnr.jada.persistency.sql.SQLBuilder sql = home.createSQLBuilder(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, pdg.getEsercizio()); - sql.addSQLClause("AND", "CD_CENTRO_RESPONSABILITA", sql.EQUALS, pdg.getCd_centro_responsabilita()); - - if (sql.executeExistsQuery(getConnection(userContext))) - throw new it.cnr.jada.comp.ApplicationException("Sono presenti importi complessivi non compatibili con i dati impostati dall'ente."); - } catch(Throwable e) { - throw handleException(e); - } -} -public boolean controllaDiscrepanzeAggregatoForCons(UserContext userContext,OggettoBulk obj, String vista) throws ComponentException { - try { - Pdg_preventivoBulk pdg = (Pdg_preventivoBulk)obj; - PersistentHome home = null; - if (vista.equals("ETR")) - home = getHome(userContext,it.cnr.contab.pdg00.consultazioni.bulk.V_dpdg_aggregato_etr_det_dBulk.class); - else if (vista.equals("SPE")) - home = getHome(userContext,it.cnr.contab.pdg00.consultazioni.bulk.V_dpdg_aggregato_spe_det_dBulk.class); - else - return false; - it.cnr.jada.persistency.sql.SQLBuilder sql = home.createSQLBuilder(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, pdg.getEsercizio()); - sql.addSQLClause("AND", "CD_CENTRO_RESPONSABILITA", sql.EQUALS, pdg.getCd_centro_responsabilita()); - return sql.executeExistsQuery(getConnection(userContext)); - } catch(Throwable e) { - throw handleException(e); - } -} -/** - * Pdg aggregato contiene discrepanze - * PreCondition: - * Le viste V_DPDG_AGGREGATO_ETR_DET_D e V_DPDG_AGGREGATO_SPE_DET_D contengono almeno un record - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Sono presenti importi complessivi non compatibili con i dati impostati dall'ente." - * Tuttti i controlli superati - * PreCondition: - * Nessun'altra precondizione è verificata - * PostCondition: - * Esce senza alcuna eccezione - */ -private void controllaDiscrepanzeAggregatoPerVariazioni(UserContext userContext,Pdg_preventivoBulk pdg,int livelloResponsabilita) throws ComponentException { - // Controllo della presenza di discrepanze nell'aggregato; va fatto solo per cdr di 1° livello e per le aree - if (livelloResponsabilita == 1 || - isCdrArea(userContext,pdg.getCentro_responsabilita())) { - - controllaDiscrepanzeAggregato(userContext,pdg,Pdg_aggregato_etr_detBulk.class,"V_DPDG_AGGREGATO_ETR_DET_D"); - controllaDiscrepanzeAggregato(userContext,pdg,Pdg_aggregato_spe_detBulk.class,"V_DPDG_AGGREGATO_SPE_DET_D"); - } -} -/** - * Quadratura su insieme linee di attività entrata/spesa - * PreCondition: - * L'invocazione della stored procedure CNRCTB050.checkDiscrepanzeInsiemeLa ritorna 'Y' - * PostCondition: - * Lascia uscire true - * Tutti i controlli superati - * PreCondition: - * L'invocazione della stored procedure CNRCTB050.checkDiscrepanzeInsiemeLa ritorna 'N' - * PostCondition: - * Esce ritornando false - */ -private boolean controllaDiscrepanzeInsiemeLa(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs =new LoggableStatement( getConnection( userContext ),"{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB050.check_discrepanze_insieme_la(?,?)}",false,this.getClass()); - try { - cs.registerOutParameter( 1, java.sql.Types.CHAR ); - cs.setObject( 2, pdg.getEsercizio() ); - cs.setString( 3, pdg.getCd_centro_responsabilita()); - cs.execute(); - return !cs.getString(1).equals("N"); - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} - -/** - * Quadratura fallita - * PreCondition: - * L'invocazione della stored procedure CNRCTB050.checkQuadRicFig genera una eccezione - * PostCondition: - * Lascia uscire l'eccezione - * Tutti i controlli superati - * PreCondition: - * L'invocazione della stored procedure CNRCTB050.checkQuadRicFig va a buon fine - * PostCondition: - * Esce senza alcuna eccezione - */ -private void controllaQuadraturaRicaviFigurativi(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB050.checkQuadRicFig(?,?)}",false,this.getClass()); - try { - cs.registerOutParameter( 1, java.sql.Types.CHAR ); - cs.setObject( 2, pdg.getEsercizio() ); - cs.setString( 3, pdg.getCd_centro_responsabilita()); - cs.execute(); - if (cs.getString(1).equals("N")) - throw new it.cnr.jada.comp.ApplicationException("Mancata quadratura dei ricavi figurativi!"); - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} -/** - * Verifica che lo scarico dei costi del dipendente sia completo - * PreCondition: - * L'invocazione della stored procedure CNRCTB060.checkScaricoCDPCompleto genera una eccezione - * PostCondition: - * Lascia uscire l'eccezione - * Tutti i controlli superati - * PreCondition: - * L'invocazione della stored procedure CNRCTB060.checkScaricoCDPCompleto va a buon fine - * PostCondition: - * Esce senza alcuna eccezione - */ -private void controllaScaricoCDPCompleto(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB060.checkScaricoCDPCompleto(?,?)}",false,this.getClass()); - try { - cs.registerOutParameter( 1, java.sql.Types.CHAR ); - cs.setObject( 2, pdg.getEsercizio() ); - cs.setString( 3, pdg.getCd_centro_responsabilita()); - cs.execute(); - if (cs.getString(1).equals("N")) - throw new it.cnr.jada.comp.ApplicationException("Costi del personale non ancora scaricati completamente!"); - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} - -/** - * Verifica che il pdg aggregato sia nello stato specificato - * PreCondition: - * L'invocazione della stored procedure CNRCTB060.checkStatoAggregato ritorna 'N' - * PostCondition: - * Genera una ApplicationException con il messaggio "Per poter eseguire l'operazione richiesta il piano di gestione aggregato dovrebbe essere in stato X ma attualmente si trova in un altro stato." - * Tutti i controlli superati - * PreCondition: - * Nessun'altra precondizione verificata - * PostCondition: - * Esce senza alcuna eccezione - */ -private void controllaStatoAggregato(UserContext userContext, Pdg_preventivoBulk pdg,String stato) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB050.checkStatoAggregato(?,?,?)}",false,this.getClass()); - try { - cs.registerOutParameter( 1, java.sql.Types.CHAR ); - cs.setObject( 2, pdg.getEsercizio() ); - cs.setString( 3, pdg.getCd_centro_responsabilita()); - cs.setString( 4, stato); - cs.execute(); - if (cs.getString(1).equals("N")) - throw new it.cnr.jada.comp.ApplicationException("Per poter eseguire l'operazione richiesta il piano di gestione aggregato dovrebbe essere in stato "+stato+" ma attualmente si trova in un altro stato."); - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} - -/** - * Esistono pdg dipendenti in stato diverso da quelli specificati - * PreCondition: - * Esiste almeno un pdg figlio del pdg specificato che si trova in uno stato diverso da quelli specificificati - * PostCondition: - * Genera una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Tutti i controlli superati - * PreCondition: - * Nessun'altra precondizione verificata - * PostCondition: - * Esce senza alcuna eccezione - */ -private boolean controllaStatoPdgFigli(UserContext userContext,Pdg_preventivoBulk pdg,String[] stati) throws ComponentException { - try { - it.cnr.jada.bulk.BulkHome home = getHome(userContext, Pdg_preventivoBulk.class); - it.cnr.jada.persistency.sql.SQLBuilder sql = home.createSQLBuilder(); - sql.addTableToHeader("V_PDG_CDR_FIGLI"); - sql.addSQLJoin("PDG_PREVENTIVO.ESERCIZIO","V_PDG_CDR_FIGLI.ESERCIZIO"); - sql.addSQLJoin("PDG_PREVENTIVO.CD_CENTRO_RESPONSABILITA","V_PDG_CDR_FIGLI.CD_CENTRO_RESPONSABILITA"); - sql.addSQLClause("AND", "V_PDG_CDR_FIGLI.ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); - sql.addSQLClause("AND", "V_PDG_CDR_FIGLI.CD_CDR_ROOT", sql.EQUALS, pdg.getCd_centro_responsabilita()); - sql.setForUpdateOf("stato"); - - LoggableStatement stm = sql.prepareStatement(getConnection(userContext)); - try { - java.sql.ResultSet rs = stm.executeQuery(); - try { - while (rs.next()) { - String stato_figlio = rs.getString("STATO"); - boolean trovato = false; - for (int i = 0;!trovato && i < stati.length;i++) - trovato = stati[i].equals(stato_figlio); - - if (!trovato) - throw new it.cnr.jada.comp.ApplicationException("Il pdg del cdr "+rs.getString("CD_CENTRO_RESPONSABILITA")+" è in stato "+stato_figlio+" che non è compatibile con l'operazione richiesta."); - } - } finally { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } finally { - try{stm.close();}catch( java.sql.SQLException e ){}; - } - return true; - } catch(Throwable e) { - throw handleException(e); - } -} - -/** - * Esistono pdg padri in stato diverso da quelli specificati - * PreCondition: - * Esiste almeno un pdg padre del pdg specificato che si trova in uno stato diverso da quelli specificati. - * Se "ricorsivo" è true la ricerca viene fatta su tutti i padri fino all'AC, altrimenti solo sul padre diretto - * PostCondition: - * Genera una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Tutti i controlli superati - * PreCondition: - * Nessun'altra precondizione verificata - * PostCondition: - * Esce senza alcuna eccezione - */ -private boolean controllaStatoPdgPadri(UserContext userContext,Pdg_preventivoBulk pdg,int livelloResponsabilita,boolean ricorsivo,String[] stati) throws ComponentException { - try { - - // Sel il cdr del pdg è di livello 1, o è l'ente o è in un area di ricerca - // non ci sono pdg padri, quindi ritorno true - - if (livelloResponsabilita == LV_CDRI || - livelloResponsabilita == LV_AC || - isCdrArea(userContext,pdg.getCentro_responsabilita())) - return true; - - String cd_cdr = pdg.getCd_centro_responsabilita(); - - do { - - BulkHome home = getHome(userContext, Pdg_preventivoBulk.class, "V_PDG_PDG_PADRE"); - SQLBuilder sql = home.createSQLBuilder(); - - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext )); - sql.addSQLClause("AND", "CD_CDR_ROOT", sql.EQUALS, cd_cdr); - sql.setForUpdateOf("stato"); - - LoggableStatement stm = sql.prepareStatement(getConnection(userContext)); - try { - java.sql.ResultSet rs = stm.executeQuery(); - try { - if (!rs.next()) - return true; - - String stato_padre = rs.getString("STATO"); - cd_cdr = rs.getString("CD_CENTRO_RESPONSABILITA"); - boolean trovato = false; - for (int i = 0;!trovato && i < stati.length;i++) - trovato = stati[i].equals(stato_padre); - - if (!trovato) - throw new it.cnr.jada.comp.ApplicationException("Il pdg del cdr "+cd_cdr+" è in stato "+stato_padre+" che non è compatibile con l'operazione richiesta."); - - } finally { - try{rs.close();}catch( java.sql.SQLException e ){}; - } - } finally { - try{stm.close();}catch( java.sql.SQLException e ){}; - } - } while(ricorsivo); - - return true; - - } catch(Throwable e) { - throw handleException(e); - } -} - -/** - * Imposta gli importi assegnati sul dettaglio di entrata del servente in base - * agli importi valorizzati sul dettaglio di spesa del servito. - * - * @param userContext - * @param servito Chi assegna l'entrata figurativa e sottomette la richiesta di accettazione - * @param servente Chi accetta o meno l'entrata figurativa assegnatagli - */ - - private void copiaImportAltroCDR(UserContext userContext,Pdg_preventivo_spe_detBulk servito,Pdg_preventivo_etr_detBulk servente) throws it.cnr.jada.comp.ComponentException { - - servente.setIm_rb_rse( servito.getIm_rp_css_verso_altro_cdr() ); - - servente.setIm_rd_a2_ricavi( servito.getIm_rab_a2_costi_altro_cdr() ); - - servente.setIm_rf_a3_ricavi( servito.getIm_rai_a3_costi_altro_cdr() ); - - } - -/** - * Imposta gli importi assegnati sul dettaglio di spesa del servente in base - * agli importi valorizzati sul dettaglio di spesa del servito. - * - * @param userContext - * @param servito Chi assegna lo scarico di spesa e sottomette la richiesta di accettazione - * @param servente Chi accetta o meno lo scarico di spesa assegnatagli - */ - - private void copiaImportiAltraUO(UserContext userContext,Pdg_preventivo_spe_detBulk servito,Pdg_preventivo_spe_detBulk servente) throws it.cnr.jada.comp.ComponentException { - if( servito.getIm_rj_ccs_spese_odc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { - servente.setIm_ru_spese_costi_altrui( servito.getIm_rj_ccs_spese_odc_altra_uo() ); - } - - if( servito.getIm_rl_ccs_spese_ogc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { - servente.setIm_ru_spese_costi_altrui( servito.getIm_rl_ccs_spese_ogc_altra_uo() ); - } - - if( servito.getIm_rr_ssc_costi_odc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { - servente.setIm_ru_spese_costi_altrui( servito.getIm_rr_ssc_costi_odc_altra_uo() ); - } - - if( servito.getIm_rt_ssc_costi_ogc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { - servente.setIm_ru_spese_costi_altrui( servito.getIm_rt_ssc_costi_ogc_altra_uo() ); - } - - if( servito.getIm_rad_a2_spese_odc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { - servente.setIm_rag_a2_spese_costi_altrui( servito.getIm_rad_a2_spese_odc_altra_uo() ); - } - - if( servito.getIm_raf_a2_spese_ogc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { - servente.setIm_rag_a2_spese_costi_altrui( servito.getIm_raf_a2_spese_ogc_altra_uo() ); - } - - if( servito.getIm_ram_a3_spese_odc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { - servente.setIm_rap_a3_spese_costi_altrui( servito.getIm_ram_a3_spese_odc_altra_uo() ); - } - - if( servito.getIm_rao_a3_spese_ogc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { - servente.setIm_rap_a3_spese_costi_altrui( servito.getIm_rao_a3_spese_ogc_altra_uo() ); - } - } - -/** - * Tutti i controlli superati - * PreCondition: - * Nessun'altra precondizione è verificata - * PostCondition: - * ll dettaglio viene marcato con CATEGORIA 'SIN', FL_SOLA_LETTURA = false e salvato - * spesa relativa altra UO - * PreCondition: - * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD); il PDG del CDR scelto è aperto (stato uguale a A, B, D o E) - * PostCondition: - * Viene creata nel PDG del cdr scelto (servente) un nuovo dettaglio di spesa valorizzazzato come segue: - * dettaglioServente.esercizio = dettaglioServito.esercizio - * dettaglioServente.cdr = cdrServente - * dettaglioServente.appartenenza = dettaglioServito.appartenenza - * dettaglioServente.gestione = dettaglioServito.gestione - * dettaglioServente.voce = dettaglioServito.voce - * dettaglioServente.clgs = dettaglioServito - * dettaglioServente.CATEGORIA = 'CAR' - * dettaglioServente.STATO = 'X' - * dettaglioServente.lineaDiAttivita = Linea_attivitaComponent.creaLineaAttivitaSAUO(cdrServente,dettaglioServito.lineaDiAttivita) - * dettaglioServente.U = dettaglioServito.J / L / R / T (quello valorizzato) - * dettaglioServente.AG = dettaglioServito.AD / AF (quello valorizzato) - * dettaglioServente.AP = dettaglioServito.AM / AD (quello valorizzato) - * il dettaglio servito viene marcato con CATEGORIA 'SCR', quello servente con categotria 'CAR', e viene messo in STATO 'X' - * PDG servente già chiuso - * PreCondition: - * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato qualche colonna riferita ad un'altro cdr (CLGS != NULL) e il PDG del CDR scelto è già "chiuso" (checkChiusuraPdg genera una Exception) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il PDG del servente è stato già chiuso - * costi senza spese - * PreCondition: - * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato la colonna P, AB o AI ; il PDG del CDR scelto è modificabile (stato A, B, D o E), la voce è "Prestazioni da struttura dell'ente" (isVoceCSSAC() ritorna true) - * PostCondition: - * Viene creata per il cdr servente un nuovo dettaglio di entrata valorizzazzato come segue: - * entrataServente.esercizio = dettaglioServito.esercizio - * entrataServente.cdr = cdrServente - * entrataServente.appartenenza = dettaglioServito.appartenenza - * entrataServente.gestione = dettaglioServito.gestione - * entrataServente.voce = getVoceRicaviFigurativi() - * entrataServente.clgs = dettaglioServito - * entrataServente.CATEGORIA = 'CAR' - * entrataServente.STATO = 'X' - * entrataServente.lineaDiAttivita = Linea_attivitaComponent.creaLineaAttivitaCSSAC(cdrServente,dettaglioServito.lineaDiAttivita) - * entrataServente.B = dettaglioServito.P - * entrataServente.D = dettaglioServito.AB - * entrataServente.F = dettaglioServito.AI - * - * il dettaglio servito viene marcato con CATEGORIA 'SCR' e viene messo in STATO 'X' - * - * costi senza spese, voce non valida - * PreCondition: - * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato la colonna P, AB o AI, la voce NON è "Prestazioni da struttura dell'ente" (isVoceCSSAC() ritorna false) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "La voce del piano dei conti deve essere 'Prestazioni da struttura dell'ente'" - * spesa relativa altra UO, campi non validi - * PreCondition: - * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD) - * sono compilati più di uno alla volta di - * - J, L, R, T - * - AD, AF - * - AM, AD - * oppure sono compilati altri campi non relativi ad altra UO eccetto H/AA/AH - * PostCondition: - * Viene generata una ApplicationException. - * costi senza spese, campi non validi - * PreCondition: - * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato la colonna P, AB o AI e qualche altra colonna non relativa a "costi senza spese verso altro CDR" - * PostCondition: - * Viene generata una ApplicationException. - * spesa relativa altra UO per il personale, linea di attivita non valida - * PreCondition: - * Viene richiesto il salvataggio di una riga di spese del PDG e - * l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD) e - * isVoceSAUOP(dettaglio.voce) e - * il PDG del CDR scelto è aperto (stato uguale a A, B, D o E) - * la linea di attivita ha natura o funzione diverse da uno - * PostCondition: - * Viene generata una eccezione con messaggio: "Le spese per personale devono avere una linea di attività con natura e funzione 1" - * spesa relativa altra UO per il personale - * PreCondition: - * Viene richiesto il salvataggio di una riga di spese del PDG e - * l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD) e - * isVoceSAUOP(dettaglio.voce) = true e - * il PDG del CDR scelto è aperto (stato uguale a A, B, D o E) - * la linea di attivita ha natura o funzione uguale a uno - * PostCondition: - * Viene creata nel PDG del cdr scelto (servente) un nuovo dettaglio di spesa valorizzazzato come segue: - * dettaglioServente.esercizio = dettaglioServito.esercizio - * dettaglioServente.cdr = cdrServente - * dettaglioServente.appartenenza = dettaglioServito.appartenenza - * dettaglioServente.gestione = dettaglioServito.gestione - * dettaglioServente.voce = dettaglioServito.voce - * dettaglioServente.clgs = dettaglioServito - * dettaglioServente.CATEGORIA = 'CAR' - * dettaglioServente.STATO = 'X' - * dettaglioServente.lineaDiAttivita = Linea_attivitaComponent.creaLineaAttivitaSAUOP(cdrServente) - * dettaglioServente.U = dettaglioServito.J / L / R / T (quello valorizzato) - * dettaglioServente.AG = dettaglioServito.AD / AF (quello valorizzato) - * dettaglioServente.AP = dettaglioServito.AM / AD (quello valorizzato) - * il dettaglio servito viene marcato con CATEGORIA 'SCR', quello servente con categotria 'CAR', e viene messo in STATO 'X' - * PDG già chiuso - * PreCondition: - * checkChiusuraPdg genera una eccezione - * PostCondition: - * Viene lasciata uscire l'eccezione - * linea di attività di natura 5, cdr non collegato ad area - * PreCondition: - * Linea di attività con natura 5 e - * CDR afferente ad UO non collegata ad area - * PostCondition: - * Genera una ApplicationException con il messaggio "Non è possibile creare dettagli con natura 5 perchè il CDR non è collegato ad area attraverso la sua unità organizzativa" - * linea di attività di natura 5, cdr area - * PreCondition: - * Linea di attività con natura 5 e - * CDR afferente UO di tipo area - * PostCondition: - * Genera una ApplicationException con il messaggio "Non è possibile creare dettagli con natura 5 perchè il CDR appartiene ad un'area" - * linea di attività di natura 5, scarico verso altra UO/CDR - * PreCondition: - * Linea di attività con natura 5 - * e l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD); il PDG del CDR scelto è aperto (stato uguale a A, B, D o E) o verso altro CDR (P, AB o AI) - * PostCondition: - * Genera una ApplicationException con il messaggio "Non è possibile scaricare costi su altra UO o CDR con natura 5" - * Dettaglio di spesa/entrata con importo negativo - * PreCondition: - * Viene richiesto l'inserimento di un dettaglio di spesa/entrata con importo negativo - * PostCondition: - * Viene generata una ApplicationException con il messaggio "non e' possibile inserire importi negativi" - * linea di attività di natura 5, dettaglio di entrata - * PreCondition: - * Linea di attività con natura 5 e - * il dettaglio specificato è un dettaglio di entrata - * PostCondition: - * Genera un ApplicationException con il messaggio "Non è possibile creare voci di entrata con natura 5" - * dtl costo del personale - CDR non è CDR PERSONALE, CDR_SERVIZIO_ENTE - tempo indeterminato - * PreCondition: - * Il CDR è diverso da CDR PERSONALE e da CDR_SERVIZIO_ENTE. - * Nell'interfaccia stipendi è presente almeno un dettaglio stipendiale contenente la voce di spesa Y diversa da voce TFR (identificata in configurazione). - * Il dipendente specificato nel dettaglio stipendiale, sulla voce Y, è un dipendente a tempo indeterminato. - * PostCondition: - * Creazione/Modifica di dettaglio del PDG di un qualsiasi CDR diverso da CDR DEL PERSONALE e da CDR_SERVIZIO_ENTE, su voce Y diversa da TFR nel caso su Y esista in interfaccia stipendi un dipendente a tempo indeterminato - * Le colonne L e V non saranno imputabile direttamente - * dtl costo del personale - CDR è CDR PERSONALE - tempo indeterminato - * PreCondition: - * Il CDR è uguale a CDR PERSONALE. - * Nell'interfaccia stipendi è presente almeno un dettaglio stipendiale contenente la voce di spesa Y diversa da voce TFR (identificata in configurazione). - * Il dipendente specificato nel dettaglio stipendiale, sulla voce Y, è un dipendente a tempo indeterminato. - * PostCondition: - * Creazione/Modifica di dettaglio del PDG del CDR DEL PERSONALE, su voce Y diversa da TFR nel caso su Y esista in interfaccia stipendi un dipendente a tempo indeterminato. - * La colonna K non sarà imputabile direttamente. - * dtl costo del personale - CDR non è CDR PERSONALE, CDR_SERVIZIO_ENTE - tempo determinato - * PreCondition: - * Il CDR è diverso da CDR PERSONALE e da CDR_SERVIZIO_ENTE. - * Nell'interfaccia stipendi è presente almeno un dettaglio stipendiale contenente la voce di spesa Y diversa da voce TFR (identificata in configurazione). - * Il dipendente specificato nel dettaglio stipendiale, sulla voce Y, è un dipendente a tempo determinato. - * PostCondition: - * Creazione/Modifica di dettaglio del PDG di un qualsiasi CDR diverso da CDR DEL PERSONALE e da CDR_SERVIZIO_ENTE, su voce Y diversa da TFR nel caso su Y esista in interfaccia stipendi un dipendente a tempo determinato - * Le colonne O e V non saranno imputabile direttamente - * dtl costo del personale - CDR è CDR PERSONALE - tempo determinato - * PreCondition: - * Il CDR è uguale a CDR PERSONALE. - * Nell'interfaccia stipendi è presente almeno un dettaglio stipendiale contenente la voce di spesa Y diversa da voce TFR (identificata in configurazione). - * Il dipendente specificato nel dettaglio stipendiale, sulla voce Y, è un dipendente a tempo determinato. - * PostCondition: - * Creazione/Modifica di dettaglio del PDG del CDR DEL PERSONALE, su voce Y diversa da TFR nel caso su Y esista in interfaccia stipendi un dipendente a tempo determinato. - * La colonna O non sarà imputabile direttamente. - * Check imputabilità importi su voci del personale_1 - * PreCondition: - * Il dettaglio è di spesa - * Il conto su cui sto registrando il dettaglio NON è il conto TFR - * Il PDG NON è del personale o quello speciale di servizio ENTE - * La voce specificata nel dettaglio del PDG è presente in COSTO DEL DIPENDENTE su almeno un dipendente a tempo INDETERMINATO - * Le colonne L o V sono valorizzate - * PostCondition: - * Viene generata una eccezione che segnala la non imputabilità sulle colonne L o V - * Check imputabilità importi su voci del personale_2 - * PreCondition: - * Il dettaglio è di spesa - * Il conto su cui sto registrando il dettaglio NON è il conto TFR - * Il PDG NON è del personale o quello speciale di servizio ENTE - * La voce specificata nel dettaglio del PDG è presente in COSTO DEL DIPENDENTE su almeno un dipendente a tempo DETERMINATO - * Le colonne O o V sono valorizzate - * PostCondition: - * Viene generata una eccezione che segnala la non imputabilità sulle colonne O o V - * Check imputabilità importi su voci del personale_3 - * PreCondition: - * Il dettaglio è di spesa - * Il conto su cui sto registrando il dettaglio NON è il conto TFR - * Il PDG è quello del personale - * La voce specificata nel dettaglio del PDG è presente in COSTO DEL DIPENDENTE su almeno un dipendente a tempo INDETERMINATO - * La colonna K è valorizzata - * PostCondition: - * Viene generata una eccezione che segnala la non imputabilità sulla colonna K - * - * Check imputabilità importi su voci del personale_4 - * PreCondition: - * Il dettaglio è di spesa - * Il conto su cui sto registrando il dettaglio NON è il conto TFR - * Il PDG è quello del personale - * La voce specificata nel dettaglio del PDG è presente in COSTO DEL DIPENDENTE su almeno un dipendente a tempo DETERMINATO - * La colonna O è valorizzate - * PostCondition: - * Viene generata una eccezione che segnala la non imputabilità sulla colonna O - * Check imputabilità importi su voci del personale_5 - * PreCondition: - * Il dettaglio è di spesa - * Il conto su cui sto registrando il dettaglio è il conto TFR - * Il PDG NON è del personale o quello speciale di servizio ENTE - * Le colonne O o V sono valorizzate - * - * - * - * PostCondition: - * Viene generata una eccezione che segnala la non imputabilità sulle colonne O o V - * Check imputabilità importi su voci del personale_6 - * PreCondition: - * Il dettaglio è di spesa - * Il conto su cui sto registrando il dettaglio è il conto TFR - * Il PDG è del personale - * La colonna O è valorizzata - * - * PostCondition: - * Viene generata una eccezione che segnala la non imputabilità sulla colonna O - * - */ - -/** - * Prima di eseguire il metodo {@link it.cnr.jada.comp.CRUDComponent#creaConBulk } vengono - * effettuati dei controlli sui dati inseriti. - * - * Nome: Creare un nuovo elemento PdG; - * Pre: Effetuare il salvataggio del PdG con i dati corretti; - * Post: Prima di effettuare il salvataggio avvia il metodo per i controlli. - * - * @param userContext UserContext in uso. - * @param bulk {@link it.cnr.contab.pdg00.bulk.Pdg_preventivo_detBulk } da salvare. - * - * @return {@link it.cnr.contab.pdg00.bulk.Pdg_preventivo_detBulk } salvato - */ - -public OggettoBulk creaConBulk(UserContext userContext,OggettoBulk bulk) throws it.cnr.jada.comp.ComponentException { - Pdg_preventivo_detBulk pdgDett = (Pdg_preventivo_detBulk)bulk; - - try { - Pdg_preventivoBulk pdg = (Pdg_preventivoBulk)getHome(userContext, Pdg_preventivoBulk.class).findAndLock( - new Pdg_preventivoBulk( - pdgDett.getEsercizio(), - pdgDett.getCd_centro_responsabilita())); - - // 05/09/2003 - // Aggiunto controllo sulla chiusura dell'esercizio - if (isEsercizioChiuso(userContext,pdg)) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile creare dettagli del pdg ad esercizio chiuso."); - - init(userContext,pdg,pdgDett); - - super.creaConBulk(userContext,bulk); - - validaVariazione(userContext, bulk); - - /* - * Il controllo che la somma degli importi aggregati sia positiva non deve avvenire - * per i dettagli provenienti da variazione al PDG non ancora in stato approvato - */ - if (!pdgDett.isDaVariazione()) - controllaAggregatoPdgDetPositivo(userContext,pdg,pdgDett); - else - { - Pdg_variazioneBulk pdgVar = (Pdg_variazioneBulk)getHome(userContext, Pdg_variazioneBulk.class).findByPrimaryKey( - new Pdg_variazioneBulk( - pdgDett.getPdg_variazione().getEsercizio(), - pdgDett.getPdg_variazione().getPg_variazione_pdg())); - if (pdgVar.isApprovata()) - controllaAggregatoPdgDetPositivo(userContext,pdg,pdgDett); - } - - return bulk; - } catch(OutdatedResourceException e) { - throw handleException(e); - } catch(PersistencyException e) { - throw handleException(e); - } catch(BusyResourceException e) { - throw handleException(e); - } -} -/** - * default - * PreCondition: - * Viene richiesta la ripartizione delle entrate bil. fin. cnr sulle UO non oggetto diretto di contrattazione con l'ente - * PostCondition: - * Viene invocata la stored procedure CNRCTB055.creaRipartEntrate - */ -private void creaRipartEntrate(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB055.creaRipartEntrate(?,?,?)}",false,this.getClass()); - try { - cs.setObject( 1, pdg.getEsercizio() ); - cs.setString( 2, pdg.getCd_centro_responsabilita()); - cs.setString( 3, userContext.getUser()); - cs.execute(); - } finally { - cs.close(); - } - } catch (Throwable e) { - throw handleException(e); - } -} - -/** - * Genera o modifica un dettaglio di scarico di spesa e il suo collegato - * - * @param userContext - * @param pdgSpe dettaglio del servito - */ - -private Pdg_preventivo_spe_detBulk creaSCRAltraUO(UserContext userContext,Pdg_preventivo_spe_detBulk pdgSpe) throws it.cnr.jada.comp.ComponentException { - - boolean newDett; - - if(!pdgSpe.isROaltra_uo()) { - newDett = true; - } else if(pdgSpe.isToBeUpdated()){ - newDett = false; - } else return pdgSpe; - - Pdg_preventivoBulk pdg = null; - if( isVoceSAUOP(userContext, pdgSpe.getElemento_voce()) ) { - try { - // Modifica del 12/02/2002 - I costi finali pluriennali non rientrano nel controllo - if( // ( pdgSpe.getIm_raa_a2_costi_finali() != null && pdgSpe.getIm_raa_a2_costi_finali().intValue() != 0 ) || - (pdgSpe.getIm_rac_a2_spese_odc().compareTo(ZERO) != 0) - || (pdgSpe.getIm_rae_a2_spese_ogc().compareTo(ZERO) != 0 ) - // || (pdgSpe.getIm_rah_a3_costi_finali().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_ral_a3_spese_odc().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_ran_a3_spese_ogc().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_ri_ccs_spese_odc().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_rm_css_ammortamenti().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_rn_css_rimanenze().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_ro_css_altri_costi().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_rk_ccs_spese_ogc().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_rq_ssc_costi_odc().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_rs_ssc_costi_ogc().compareTo(ZERO) != 0 ) - || (pdgSpe.getIm_rv_pagamenti().compareTo(ZERO) != 0 ) ) - { - throw new it.cnr.jada.comp.ApplicationException("Sono stati valorizzati degli importi non compatibili con lo scarico dei costi del personale."); - } - Pdg_preventivoHome pdgHome = (Pdg_preventivoHome)getHome(userContext,Pdg_preventivoBulk.class, "V_PDG_PDG_SAUOP"); - SQLBuilder sql = pdgHome.createSQLBuilder(); - sql.addClause("AND", "esercizio", sql.EQUALS, pdgSpe.getEsercizio()); - it.cnr.jada.persistency.Broker broker = pdgHome.createBroker(sql); - - if(broker.next()) - pdg = (Pdg_preventivoBulk)broker.fetch(Pdg_preventivoBulk.class); - else - throw new it.cnr.jada.comp.ApplicationException("Il PdG per lo scarico dei costi del personale non disponibile."); - - getHome(userContext,CdrBulk.class).findByPrimaryKey(pdg.getCentro_responsabilita()); - - if(pdg.getCentro_responsabilita().equalsByPrimaryKey( pdgSpe.getCentro_responsabilita() )) - throw new it.cnr.jada.comp.ApplicationException("Il CdR del Personale su di una voce stipendiale non può fare lo scarico dei costi su altra UO."); - - pdgSpe.setAltro_cdr(pdg.getCentro_responsabilita()); - } catch(Throwable e) { - throw new it.cnr.jada.comp.ComponentException(e); - } - } else { - if(pdgSpe.getAltro_cdr() == null) { - throw new it.cnr.jada.comp.ApplicationException("CdR altra UO non indicato"); - } else { - try { - pdg = (Pdg_preventivoBulk)getHome(userContext,Pdg_preventivoBulk.class).findByPrimaryKey( new Pdg_preventivoBulk( pdgSpe.getEsercizio(), pdgSpe.getAltro_cdr().getCd_centro_responsabilita() ) ); - } catch(Throwable e) { - throw new it.cnr.jada.comp.ComponentException(e); - } - } - } - if(pdg == null) - throw new it.cnr.jada.comp.ApplicationException("CdR altra UO non valido"); - - // Controllo chiusura PDG servente se non è una variazione - if (pdgSpe.getPdg_variazione() == null){ - if (pdgSpe.OR_PROPOSTA_VARIAZIONE.equals(pdgSpe.getOrigine())) - checkChiusuraPdgPerVariazioni(userContext,pdg); - else { - checkChiusuraPdg(userContext,pdg, pdgSpe); - - // 23/09/2003 CNRADM - // Aggiunto controllo sullo stato del pdg aggregato del cdr servente: - // se in stato B bisogna bloccare scarichi verso altra UO per garantire - // allineamento del bilancio finanziaro (altrimenti la colonna dei costi - // altrui nel pdg aggregato non viene ricalcolata) - String statoPdgAggregato = getStatoAggregato(userContext,pdg.getEsercizio(),pdg.getCd_centro_responsabilita()); - if (Pdg_aggregatoBulk.STATO_B.equals(statoPdgAggregato)) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile scaricare costi verso altra UO perchè il pdg aggregato del cdr servente è già in stato B"); - } - } - - try { - - Pdg_preventivo_spe_detBulk dettaglioServente; - if(newDett) { - - if( pdgSpe.getAltro_cdr().getCd_unita_organizzativa().equals( pdgSpe.getCentro_responsabilita().getCd_unita_organizzativa() ) ) - throw new it.cnr.jada.comp.ApplicationException("Selezionare un CdR con UO diversa dalla propria!"); - - dettaglioServente = new Pdg_preventivo_spe_detBulk(); - dettaglioServente.setCategoria_dettaglio(pdgSpe.CAT_CARICO); - dettaglioServente.setCentro_responsabilita(pdgSpe.getAltro_cdr()); - dettaglioServente.setCentro_responsabilita_clgs(pdgSpe.getCentro_responsabilita()); - dettaglioServente.setDt_registrazione(getHome(userContext, pdgSpe).getServerTimestamp()); - dettaglioServente.setDescrizione(pdgSpe.getDescrizione()); - dettaglioServente.setElemento_voce(pdgSpe.getElemento_voce()); - dettaglioServente.setElemento_voce_clgs(pdgSpe.getElemento_voce()); - dettaglioServente.setEsercizio(pdgSpe.getEsercizio()); - dettaglioServente.setPdg_variazione(pdgSpe.getPdg_variazione()); - // Creo l'associazione variazione_cdr_uo - if (pdgSpe.getPdg_variazione() != null){ - Ass_pdg_variazione_cdrHome home = (Ass_pdg_variazione_cdrHome)getHome(userContext,Ass_pdg_variazione_cdrBulk.class); - Ass_pdg_variazione_cdrBulk ass_pdg_variazione = new Ass_pdg_variazione_cdrBulk(pdgSpe.getPdg_variazione().getEsercizio(),pdgSpe.getPdg_variazione().getPg_variazione_pdg(),pdgSpe.getAltro_cdr().getCd_centro_responsabilita()); - Ass_pdg_variazione_cdrBulk ass_pdg_variazione_esistente = (Ass_pdg_variazione_cdrBulk)home.findByPrimaryKey(ass_pdg_variazione); - if (ass_pdg_variazione_esistente == null){ - ass_pdg_variazione.setToBeCreated(); - super.creaConBulk(userContext,ass_pdg_variazione); - } - } - // I dettagli di carico sono MODIFICABILI (per la sola parte pagamenti) R137R - // Date: 10/04/2002 - dettaglioServente.setFl_sola_lettura(new Boolean(false)); - dettaglioServente.setLinea_attivita_clgs(pdgSpe.getLinea_attivita()); - dettaglioServente.setOrigine(pdgSpe.getOrigine()); - dettaglioServente.setPg_spesa_clgs(pdgSpe.getPg_spesa()); - dettaglioServente.setUser(userContext.getUser()); - - - if( isVoceSAUOP(userContext, pdgSpe.getElemento_voce()) ) { - dettaglioServente.setLinea_attivita( - ((it.cnr.contab.config00.ejb.Linea_attivitaComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB( - "CNRCONFIG00_EJB_Linea_attivitaComponentSession", - it.cnr.contab.config00.ejb.Linea_attivitaComponentSession.class) - ).creaLineaAttivitaSAUOP( - userContext, - pdg.getCentro_responsabilita() - ) - ); - } else { - dettaglioServente.setLinea_attivita( - ((it.cnr.contab.config00.ejb.Linea_attivitaComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB( - "CNRCONFIG00_EJB_Linea_attivitaComponentSession", - it.cnr.contab.config00.ejb.Linea_attivitaComponentSession.class) - ).creaLineaAttivitaSAUO( - userContext, - pdgSpe.getAltro_cdr(), - pdgSpe.getLinea_attivita() - ) - ); - } - } else { - - try { - dettaglioServente = (Pdg_preventivo_spe_detBulk)getHome(userContext,Pdg_preventivo_spe_detBulk.class).findByPrimaryKey( new Pdg_preventivo_spe_detBulk( - pdgSpe.getCd_centro_responsabilita_clgs(), - pdgSpe.getCd_elemento_voce_clgs(), - pdgSpe.getCd_linea_attivita_clgs(), - pdgSpe.getEsercizio(), - pdgSpe.getPg_spesa_clgs(), - pdgSpe.getTi_appartenenza_clgs(), - pdgSpe.getTi_gestione_clgs()) ); - } catch(Throwable e) { - throw new it.cnr.jada.comp.ComponentException(e); - } - } - - dettaglioServente.setStato(pdgSpe.ST_NESSUNA_AZIONE); - - copiaImportiAltraUO(userContext,pdgSpe,dettaglioServente); - - pdgSpe.setStato(Pdg_preventivo_detBulk.ST_NESSUNA_AZIONE); - - if(newDett) { - if(pdgSpe.isToBeCreated()) - insertBulk(userContext, pdgSpe); - else - updateBulk(userContext, pdgSpe); - - dettaglioServente.completaImportiNulli(); - dettaglioServente.setPg_spesa_clgs(pdgSpe.getPg_spesa()); - insertBulk(userContext, dettaglioServente); - - pdgSpe.setCentro_responsabilita_clgs(dettaglioServente.getCentro_responsabilita()); - pdgSpe.setElemento_voce_clgs(dettaglioServente.getElemento_voce()); - pdgSpe.setLinea_attivita_clgs(dettaglioServente.getLinea_attivita()); - pdgSpe.setPg_spesa_clgs(dettaglioServente.getPg_spesa()); - pdgSpe.setCategoria_dettaglio(dettaglioServente.CAT_SCARICO); - } else { - updateBulk(userContext, dettaglioServente); - } - - updateBulk(userContext, pdgSpe); - - } catch(Throwable e) { - throw handleException(e); - } - - return pdgSpe; -} - -/** - * Genera o modifica un dettaglio di spesa per entrata figurativa e il suo collegato - * - * @param userContext - * @param pdgSpe dettaglio del servito - */ - -private Pdg_preventivo_spe_detBulk creaSCRVersoCdR(UserContext userContext,Pdg_preventivo_spe_detBulk pdgSpe) throws it.cnr.jada.comp.ComponentException { - - boolean newDett; - - if(!pdgSpe.isROaltra_uo()) { - newDett = true; - } else if(pdgSpe.isToBeUpdated()){ - newDett = false; - } else return pdgSpe; - - if(newDett) { - if(!isVoceCSSAC(userContext, pdgSpe.getElemento_voce())) - throw new it.cnr.jada.comp.ApplicationException("La voce del piano dei conti deve essere \"Prestazioni da struttura dell'ente\""); - } - - if (pdgSpe.getIm_raa_a2_costi_finali().compareTo(ZERO) != 0 || - pdgSpe.getIm_rac_a2_spese_odc().compareTo(ZERO) != 0 || - pdgSpe.getIm_rae_a2_spese_ogc().compareTo(ZERO) != 0 || - pdgSpe.getIm_rah_a3_costi_finali().compareTo(ZERO) != 0 || - pdgSpe.getIm_ral_a3_spese_odc().compareTo(ZERO) != 0 || - pdgSpe.getIm_ran_a3_spese_ogc().compareTo(ZERO) != 0 || - pdgSpe.getIm_rh_ccs_costi().compareTo(ZERO) != 0 || - pdgSpe.getIm_ri_ccs_spese_odc().compareTo(ZERO) != 0 || - pdgSpe.getIm_rm_css_ammortamenti().compareTo(ZERO) != 0 || - pdgSpe.getIm_rn_css_rimanenze().compareTo(ZERO) != 0 || - pdgSpe.getIm_ro_css_altri_costi().compareTo(ZERO) != 0 || - pdgSpe.getIm_rk_ccs_spese_ogc().compareTo(ZERO) != 0 || - pdgSpe.getIm_rq_ssc_costi_odc().compareTo(ZERO) != 0 || - pdgSpe.getIm_rs_ssc_costi_ogc().compareTo(ZERO) != 0 || - pdgSpe.getIm_rv_pagamenti().compareTo(ZERO) != 0) - { - throw new it.cnr.jada.comp.ApplicationException("Sono stati valorizzati degli importi non compatibili con il campo 'Verso altro CDR'"); - } - - Pdg_preventivoBulk pdg; - if(pdgSpe.getAltro_cdr() == null) { - throw new it.cnr.jada.comp.ApplicationException("CdR altra UO non indicato"); - } else { - try { - pdg = (Pdg_preventivoBulk)getHome(userContext,Pdg_preventivoBulk.class).findByPrimaryKey(new Pdg_preventivoBulk(pdgSpe.getEsercizio(),pdgSpe.getAltro_cdr().getCd_centro_responsabilita())); - } catch(Throwable e) { - throw new it.cnr.jada.comp.ComponentException(e); - } - } - if(pdg == null) - throw new it.cnr.jada.comp.ApplicationException("CdR altra UO non valido"); - - // Controllo chiusura PDG servente - if (pdgSpe.OR_PROPOSTA_VARIAZIONE.equals(pdgSpe.getOrigine())) - checkChiusuraPdgPerVariazioni(userContext,pdg); - else - checkChiusuraPdg(userContext,pdg,pdgSpe); - - try { - - Pdg_preventivo_etr_detBulk dettaglioServente; - if(newDett) { - dettaglioServente = new Pdg_preventivo_etr_detBulk(); - dettaglioServente.setCategoria_dettaglio(pdgSpe.CAT_CARICO); - dettaglioServente.setCentro_responsabilita(pdgSpe.getAltro_cdr()); - dettaglioServente.setCentro_responsabilita_clgs(pdgSpe.getCentro_responsabilita()); - dettaglioServente.setDt_registrazione(getHome(userContext, pdgSpe).getServerTimestamp()); - dettaglioServente.setDescrizione(pdgSpe.getDescrizione()); - dettaglioServente.setElemento_voce(getVoceRicaviFigurativi(userContext)); - dettaglioServente.setElemento_voce_clgs(pdgSpe.getElemento_voce()); - dettaglioServente.setEsercizio(pdgSpe.getEsercizio()); - dettaglioServente.setFl_sola_lettura(new Boolean(true)); - dettaglioServente.setLinea_attivita_clgs(pdgSpe.getLinea_attivita()); - dettaglioServente.setOrigine(pdgSpe.getOrigine()); - dettaglioServente.setPg_spesa_clgs(pdgSpe.getPg_spesa()); - dettaglioServente.setUser(userContext.getUser()); - - dettaglioServente.setLinea_attivita( - ((it.cnr.contab.config00.ejb.Linea_attivitaComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB( - "CNRCONFIG00_EJB_Linea_attivitaComponentSession", - it.cnr.contab.config00.ejb.Linea_attivitaComponentSession.class) - ).creaLineaAttivitaCSSAC( - userContext, - pdgSpe.getAltro_cdr(), - pdgSpe.getLinea_attivita() - ) - ); - } else { - - try { - dettaglioServente = (Pdg_preventivo_etr_detBulk)getHome(userContext,Pdg_preventivo_etr_detBulk.class).findByPrimaryKey( new Pdg_preventivo_etr_detBulk( - pdgSpe.getCd_centro_responsabilita_clge(), - pdgSpe.getCd_elemento_voce_clge(), - pdgSpe.getCd_linea_attivita_clge(), - pdgSpe.getEsercizio(), - pdgSpe.getPg_entrata_clge(), - pdgSpe.getTi_appartenenza_clge(), - pdgSpe.getTi_gestione_clge() ) ); - } catch(Throwable e) { - throw new it.cnr.jada.comp.ComponentException(e); - } - } - - dettaglioServente.setStato(pdgSpe.ST_NESSUNA_AZIONE); - - copiaImportAltroCDR(userContext,pdgSpe,dettaglioServente); - - pdgSpe.setStato(Pdg_preventivo_detBulk.ST_NESSUNA_AZIONE); - - if(newDett) { - if(pdgSpe.isToBeCreated()) - insertBulk(userContext, pdgSpe); - else - updateBulk(userContext, pdgSpe); - - dettaglioServente.completaImportiNulli(); - dettaglioServente.setPg_spesa_clgs(pdgSpe.getPg_spesa()); - insertBulk(userContext, dettaglioServente); - - pdgSpe.setCentro_responsabilita_clge(dettaglioServente.getCentro_responsabilita()); - pdgSpe.setElemento_voce_clge(dettaglioServente.getElemento_voce()); - pdgSpe.setLinea_attivita_clge(dettaglioServente.getLinea_attivita()); - pdgSpe.setPg_entrata_clge(dettaglioServente.getPg_entrata()); - pdgSpe.setCategoria_dettaglio(dettaglioServente.CAT_SCARICO); - } else { - updateBulk(userContext, dettaglioServente); - } - - updateBulk(userContext, pdgSpe); - - } catch(Throwable e) { - throw new it.cnr.jada.comp.ComponentException(e); - } - return pdgSpe; -} - -//^^@@ -/** - * eliminazione dettagli a partire dalla linea di attivià - * PreCondition: - * Viene richiesta l'eliminazione dei dettagli di spesa ed entrata che corrispondono ad esercizio, CdR e LA indicati. - * PostCondition: - * Vengono lanciate due delete una per i dettagli di spesa ed una per quelli di entrata per i record che soddisfano le condizioni. - */ -//^^@@ - public Pdg_preventivoBulk delDetByLA(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ApplicationException, it.cnr.jada.comp.ComponentException { - - checkChiusuraPdg(userContext, pdg, null); - - CdrBulk cdr = cdrFromUserContext(userContext); - checkLivelloResponsabilita(userContext, cdr, pdg); - - if(pdg.getLinea_attivita_eliminazione() == null || pdg.getLinea_attivita_eliminazione().getCd_linea_attivita() == null) - throw new it.cnr.jada.comp.ApplicationException("GAE indicata per l'eliminazione non valida."); - - try { - String delSpe = "DELETE FROM " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "PDG_PREVENTIVO_SPE_DET WHERE " + - "ESERCIZIO = " + pdg.getEsercizio() + " AND " + - "CD_CENTRO_RESPONSABILITA = '" + pdg.getCd_centro_responsabilita() + "' AND " + - "CD_LINEA_ATTIVITA = '" + pdg.getLinea_attivita_eliminazione().getCd_linea_attivita() + "' AND "+ - "CATEGORIA_DETTAGLIO = '" + Pdg_preventivo_detBulk.CAT_SINGOLO + "'"; - - String delEtr = "DELETE FROM " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "PDG_PREVENTIVO_ETR_DET WHERE " + - "ESERCIZIO = " + pdg.getEsercizio() + " AND " + - "CD_CENTRO_RESPONSABILITA = '" + pdg.getCd_centro_responsabilita() + "' AND " + - "CD_LINEA_ATTIVITA = '" + pdg.getLinea_attivita_eliminazione().getCd_linea_attivita() + "' AND "+ - "CATEGORIA_DETTAGLIO = '" + Pdg_preventivo_detBulk.CAT_SINGOLO + "'"; - - if (Pdg_preventivoBulk.ST_G_APERTURA_PER_VARIAZIONI.equals(pdg.getStato()) || - Pdg_preventivoBulk.ST_H_PRECHIUSURA_PER_VARIAZIONI.equals(pdg.getStato())) { - delSpe = delSpe + " AND ORIGINE = '"+Pdg_preventivo_detBulk.OR_PROPOSTA_VARIAZIONE+"'"; - delEtr = delEtr + " AND ORIGINE = '"+Pdg_preventivo_detBulk.OR_PROPOSTA_VARIAZIONE+"'"; - } - - java.sql.Statement cs = getConnection( userContext ).createStatement(); - try { - lockBulk(userContext,pdg); - if(pdg.getLinea_attivita_eliminazione().getTi_gestione().equals(it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk.TI_GESTIONE_SPESE)) - cs.execute(delSpe); - if(pdg.getLinea_attivita_eliminazione().getTi_gestione().equals(it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk.TI_GESTIONE_ENTRATE)) - cs.execute(delEtr); - return caricaPdg(userContext,pdg.getCentro_responsabilita()); - } catch (Throwable e) { - throw handleException(pdg,e); - } finally { - cs.close(); - } - } catch (java.sql.SQLException e) { - // Gestisce eccezioni SQL specifiche (errori di lock,...) - throw handleSQLException(e); - } - } - -//^^@@ -/** - * PDG non modificabile - * PreCondition: - * checkLivelloResponsabilita(pdg,pdg_det) genera una eccezione - * PostCondition: - * Lascia uscire l'eccezione generata - * Dettaglio scaricato o caricato - * PreCondition: - * CATEGORIA = 'SCR' o 'CAR' - * PostCondition: - * Genera una eccezione con messaggio: "Il dettaglio non può essere eliminato" - * PDG già chiuso - * PreCondition: - * checkChiusuraPdg(pdg_det) genera una eccezione - * PostCondition: - * Lascia uscire l'eccezione generata - * Tutti i controlli superati - * PreCondition: - * Nessun'altra precondizione verificata - * PostCondition: - * Elimina il dettaglio del pdg specificato - */ -//^^@@ - - public void eliminaConBulk (UserContext userContext,OggettoBulk bulk) throws ComponentException { - Pdg_preventivo_detBulk dett = (Pdg_preventivo_detBulk)bulk; - CdrBulk cdr = cdrFromUserContext(userContext); - - Pdg_preventivoBulk pdg = checkChiusuraPdg(userContext,dett); - - // 05/09/2003 - // Aggiunto controllo sulla chiusura dell'esercizio - if (isEsercizioChiuso(userContext,pdg)) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile eliminare dettagli del pdg ad esercizio chiuso."); - - checkLivelloResponsabilita(userContext, cdr, pdg); - - if(dett.getFl_sola_lettura().booleanValue()) - throw new it.cnr.jada.comp.ApplicationException("Il dettaglio non può essere eliminato"); - - if(Pdg_preventivo_detBulk.CAT_SCARICO.equals( dett.getCategoria_dettaglio())&& - dett.getPdg_variazione() == null) - throw new it.cnr.jada.comp.ApplicationException("Il dettaglio è stato scaricato e non può essere eliminato; contattare il CDR servente"); -/* - if(Pdg_preventivo_detBulk.CAT_SCARICO.equals( dett.getCategoria_dettaglio()) && - Pdg_preventivo_detBulk.ST_CONFERMA.equals( dett.getStato() )) - throw new it.cnr.jada.comp.ApplicationException("Il dettaglio è stato confermato dal centro servente e non può essere eliminato; contattare il CDR servente"); -*/ - - if(Pdg_preventivo_detBulk.CAT_CARICO.equals( dett.getCategoria_dettaglio() )) { - // if(Pdg_preventivo_detBulk.ST_NESSUNA_AZIONE.equals( dett.getStato() )) -// throw new it.cnr.jada.comp.ApplicationException("Il dettaglio non è eliminabile fino alla chiusura della contrattazione. Contattare il CDR servente"); - throw new it.cnr.jada.comp.ApplicationException("Il dettaglio è di carico e non può essere eliminato"); -/* - if(Pdg_preventivo_detBulk.ST_CONFERMA.equals( dett.getStato() )) - throw new it.cnr.jada.comp.ApplicationException("Il dettaglio non è eliminabile perchè confermato."); - - Pdg_preventivo_spe_detBulk servente = new Pdg_preventivo_spe_detBulk(); - - servente.setEsercizio(dett.getEsercizio()); - servente.setCentro_responsabilita(dett.getCentro_responsabilita_clgs()); - servente.setElemento_voce(dett.getElemento_voce_clgs()); - servente.setLinea_attivita(dett.getLinea_attivita_clgs()); - servente.setPg_spesa(dett.getPg_spesa_clgs()); - - // Controllo che il pdg servente sia chiuso - checkChiusuraPdg(userContext,servente); - try { - getHome(userContext,servente).delete(servente); - } catch(PersistencyException e) { - throw handleException((OggettoBulk)dett,e); - } -*/ - - } - - super.eliminaConBulk(userContext,bulk); - } - -//^^@@ -/** - * default - * PreCondition: - * Viene richiesto il CDR PERSONALE da configurazione CNR - * PostCondition: - * Restituisce il cdr con il codice specificato in CONFIGURAZIONE_CNR alla voce - * "CDR_SPECIALE" , "CDR_PERSONALE" - */ -//^^@@ - private CdrBulk getCDR_PERSONALE (UserContext userContext) throws ComponentException { - try { - Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); - String aCdCdr = configurazione.getVal01(userContext,null,null,"CDR_SPECIALE","CDR_PERSONALE"); - if(aCdCdr==null) - throw new it.cnr.jada.comp.ApplicationException("Centro di responsabilità del Personale non definito in Configurazione CNR"); - it.cnr.contab.config00.sto.bulk.CdrHome cdrHome = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext,CdrBulk.class, "V_CDR_VALIDO"); - SQLBuilder sql = cdrHome.createSQLBuilder(); - sql.addClause("AND", "esercizio", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); - sql.addClause("AND", "cd_centro_responsabilita", sql.EQUALS, aCdCdr); - it.cnr.jada.persistency.Broker broker = cdrHome.createBroker(sql); - - CdrBulk aCdrBulk; - if(broker.next()) - aCdrBulk = (CdrBulk)broker.fetch(CdrBulk.class); - else - throw new it.cnr.jada.comp.ApplicationException("Il CDR del personale specificato in CONFIGURAZIONE CNR non è stato trovato!"); - - return aCdrBulk; - } catch(Throwable e) { - throw handleException(e); - } - } - -//^^@@ -/** - * default - * PreCondition: - * Viene richiesto il CDR SPECIALE SERVIZIO ENTE da configurazione CNR - * PostCondition: - * Restituisce il cdr con il codice specificato in CONFIGURAZIONE_CNR alla voce - * "CDR_SPECIALE" , "CDR_SERVIZIO_ENTE" - */ -//^^@@ - private CdrBulk getCDR_SERVIZIO_ENTE (UserContext userContext) throws ComponentException { - try { - Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); - String aCdCdr = configurazione.getVal01(userContext,null,null,"CDR_SPECIALE","CDR_SERVIZIO_ENTE"); - if(aCdCdr==null) - throw new it.cnr.jada.comp.ApplicationException("Cdr di Servizio dell'Ente non trovato in Configurazione CNR"); - it.cnr.contab.config00.sto.bulk.CdrHome cdrHome = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext,CdrBulk.class, "V_CDR_VALIDO"); - SQLBuilder sql = cdrHome.createSQLBuilder(); - sql.addClause("AND", "esercizio", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); - sql.addClause("AND", "cd_centro_responsabilita", sql.EQUALS, aCdCdr); - it.cnr.jada.persistency.Broker broker = cdrHome.createBroker(sql); - - CdrBulk aCdrBulk; - if(broker.next()) - aCdrBulk = (CdrBulk)broker.fetch(CdrBulk.class); - else - throw new it.cnr.jada.comp.ApplicationException("Il CDR di servizio per l'ENTE specificato in CONFIGURAZIONE CNR non è stato trovato!"); - - return aCdrBulk; - } catch(Throwable e) { - throw handleException(e); - } - } - -//^^@@ -/** - * default - * PreCondition: - * Viene richiesta la voce di tipo ONERI_CNR da configurazione CNR - * PostCondition: - * Restituisce l'elemento voce con il codice specificato in CONFIGURAZIONE_CNR alla voce - * "ELEMENTO_VOCE_SPECIALE" , "ONERI_CNR" - */ -//^^@@ - private Elemento_voceBulk getVoceONERI_CNR (UserContext userContext) throws ComponentException { - try { - Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); - String aCdOneriCnr=configurazione.getVal01(userContext,it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext),null,"ELEMENTO_VOCE_SPECIALE","ONERI_CNR"); - if(aCdOneriCnr==null) - throw new it.cnr.jada.comp.ApplicationException("Voce Oneri Cnr non definita in CONFIGURAZIONE CNR per l'esercizio corrente"); - return (Elemento_voceBulk)getHome(userContext,Elemento_voceBulk.class).findByPrimaryKey(new Elemento_voceBulk( - aCdOneriCnr, - it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), - Elemento_voceHome.APPARTENENZA_CDS, - Elemento_voceHome.GESTIONE_SPESE - )); - } catch(Throwable e) { - throw handleException(e); - } - } - -//^^@@ -/** - * default - * PreCondition: - * Viene richiesta la voce da assegnare al dettaglio di entrata creato sul PDG del CDR servente nel caso di un costo senza spese - * PostCondition: - * Restituisce l'elemento voce con il codice specificato in CONFIGURAZIONE_CNR alla voce - * "ELEMENTO_VOCE_SPECIALE" , "RICAVO_FIGURATIVO_ALTRO_CDR" - */ -//^^@@ - private Elemento_voceBulk getVoceRicaviFigurativi (UserContext userContext) throws ComponentException { - try { - Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); - String aVoceRicFig = configurazione.getVal01(userContext,it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext),null,"ELEMENTO_VOCE_SPECIALE","RICAVO_FIGURATIVO_ALTRO_CDR"); - if(aVoceRicFig==null) - throw new it.cnr.jada.comp.ApplicationException("Voce del piano \"Ricavo Figurativo\" non presente in configurazione CNR per l'esercizio corrente"); - return (Elemento_voceBulk)getHome(userContext,Elemento_voceBulk.class).findByPrimaryKey(new Elemento_voceBulk( - aVoceRicFig, - it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), - Elemento_voceHome.APPARTENENZA_CNR, - Elemento_voceHome.GESTIONE_ENTRATE - )); - } catch(Throwable e) { - throw handleException(e); - } - } - -//^^@@ -/** - * default - * PreCondition: - * Viene richiesta la voce di tipo TFR da configurazione CNR - * PostCondition: - * Restituisce l'elemento voce con il codice specificato in CONFIGURAZIONE_CNR alla voce - * "ELEMENTO_VOCE_SPECIALE" , "TFR" - */ -//^^@@ - private Elemento_voceBulk getVoceTFR (UserContext userContext) throws ComponentException { - try { - Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); - String aCdTfr=configurazione.getVal01(userContext,it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext),null,"ELEMENTO_VOCE_SPECIALE","TFR"); - if(aCdTfr==null) - throw new it.cnr.jada.comp.ApplicationException("Voce TFR non definita in CONFIGURAZIONE CNR per l'esercizio corrente"); - return (Elemento_voceBulk)getHome(userContext,Elemento_voceBulk.class).findByPrimaryKey(new Elemento_voceBulk( - aCdTfr, - it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), - Elemento_voceHome.APPARTENENZA_CDS, - Elemento_voceHome.GESTIONE_SPESE - )); - } catch(Throwable e) { - throw handleException(e); - } - } - -/** - * Metodo per i controlli da effettuare su un oggetto di tipo {@link it.cnr.contab.pdg00.bulk.PdgGestioneDetPrev } . - * - * Nome: Controlli per inserimento e modifica; - * Pre: Implementare tutti i controlli che garantiscano l'integrita del record rappresentato dall oggetto; - * Post: Verifica che la linea di attività e l'elemento voce non siano nulli. - * - * @param pdg Oggetto da analizzare. - * - * @return L'oggetto controllato. - * - * @throw it.cnr.jada.comp.ComponentException - */ -private void init(UserContext userContext,Pdg_preventivoBulk pdg,Pdg_preventivo_detBulk pdgDett) throws it.cnr.jada.comp.ComponentException { - try { - if(pdgDett.getLinea_attivita() == null || pdgDett.getLinea_attivita().getCd_linea_attivita() == null) - throw new it.cnr.jada.comp.ApplicationException("Il GAE non può essere nullo."); - - if(pdgDett.getElemento_voce() == null || pdgDett.getElemento_voce().getCd_elemento_voce() == null) - throw new it.cnr.jada.comp.ApplicationException("Voce del piano non può essere nulla."); - - // Carico tutti gli oggetti complessi legati al pdg - getHomeCache(userContext).fetchAll(userContext); - - if (pdgDett.getDt_registrazione() == null) - pdgDett.setDt_registrazione(getHome(userContext, (OggettoBulk)pdgDett).getServerTimestamp()); - - if (pdgDett.getOrigine() == null) - pdgDett.setOrigine(pdg.isStatoVariazionePdG() || pdgDett.isDaVariazione()? pdgDett.OR_PROPOSTA_VARIAZIONE : pdgDett.OR_UTENTE); - /** - * Controllo lo stato del PDG solo se il dettaglio non proviene da una variazione - */ - if (!pdgDett.isDaVariazione()) - checkChiusuraPdg(userContext, pdg, pdgDett); - - if (pdg.isStatoVariazionePdG()&& !pdgDett.isOriginePropostaVariazione()) - throw new it.cnr.jada.comp.ApplicationException("Il pdg è aperto per variazioni. E' possibile modificare o inserire solamente proposte di variazione"); - - checkLivelloResponsabilita(userContext, cdrFromUserContext(userContext), pdg); - - pdgDett.completaImportiNulli(); - - if ("5".equals( pdgDett.getLinea_attivita().getNatura().getCd_natura())) { - Unita_organizzativaHome uoHome = (Unita_organizzativaHome)getHome(userContext, Unita_organizzativaBulk.class); - if (uoHome.findAssociazioneUoArea(userContext, pdgDett.getCentro_responsabilita().getUnita_padre()).isEmpty()) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile creare dettagli con natura 5 perchè il CDR non è collegato ad area attraverso la sua unità organizzativa"); - if (isCdrArea(userContext,pdgDett.getCentro_responsabilita())) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile creare dettagli con natura 5 perchè il CDR appartiene ad un'area"); - } - - if(pdgDett instanceof it.cnr.contab.pdg00.bulk.Pdg_preventivo_spe_detBulk) - initSpe(userContext,pdg,(Pdg_preventivo_spe_detBulk)pdgDett); - else if(pdgDett instanceof it.cnr.contab.pdg00.bulk.Pdg_preventivo_etr_detBulk) - initEtr(userContext,pdg,(Pdg_preventivo_etr_detBulk)pdgDett); - } catch(Throwable e) { - throw new it.cnr.jada.comp.ComponentException(e); - } -} - -/** - * Metodo per i controlli da effettuare su un oggetto di tipo {@link it.cnr.contab.pdg00.bulk.PdgGestioneDetPrev } . - * - * Nome: Controlli per inserimento e modifica; - * Pre: Implementare tutti i controlli che garantiscano l'integrita del record rappresentato dall oggetto; - * Post: Verifica che la linea di attività e l'elemento voce non siano nulli. - * - * @param pdg Oggetto da analizzare. - * - * @return L'oggetto controllato. - * - * @throw it.cnr.jada.comp.ComponentException - */ -private OggettoBulk initEtr(UserContext userContext,Pdg_preventivoBulk pdg,Pdg_preventivo_etr_detBulk pdg_det) throws it.cnr.jada.comp.ComponentException { - - - if ("5".equals( pdg_det.getLinea_attivita().getNatura().getCd_natura())) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile creare dettagli di entrata con natura 5"); - - boolean importiNegativi = - (pdg_det.getIm_ra_rce().signum() < 0) || - (pdg_det.getIm_rb_rse().signum() < 0) || - (pdg_det.getIm_rc_esr().signum() < 0) || - (pdg_det.getIm_rd_a2_ricavi().signum() < 0) || - (pdg_det.getIm_re_a2_entrate().signum() < 0) || - (pdg_det.getIm_rf_a3_ricavi().signum() < 0) || - (pdg_det.getIm_rg_a3_entrate().signum() < 0); - - if (pdg.ST_G_APERTURA_PER_VARIAZIONI.equals(pdg.getStato()) || pdg_det.getPdg_variazione() != null) { - boolean importiPositivi = - (pdg_det.getIm_ra_rce().signum() > 0) || - (pdg_det.getIm_rb_rse().signum() > 0) || - (pdg_det.getIm_rc_esr().signum() > 0) || - (pdg_det.getIm_rd_a2_ricavi().signum() > 0) || - (pdg_det.getIm_re_a2_entrate().signum() > 0) || - (pdg_det.getIm_rf_a3_ricavi().signum() > 0) || - (pdg_det.getIm_rg_a3_entrate().signum() > 0); - if (importiPositivi && importiNegativi) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile inserire sia importi positivi che negativi."); - } else if (importiNegativi) { - throw new it.cnr.jada.comp.ApplicationException("Non è possibile inserire importi negativi"); - } - return pdg_det; -} - - /** - * Metodo per i controlli da effettuare su un oggetto di tipo {@link it.cnr.contab.pdg00.bulk.PdgGestioneDetPrev } . - * - * Nome: Controlli per inserimento e modifica; - * Pre: Implementare tutti i controlli che garantiscano l'integrita del record rappresentato dall oggetto; - * Post: Verifica che la linea di attività e l'elemento voce non siano nulli. - * - * @param pdg_det Oggetto da analizzare. - * - * @return L'oggetto controllato. - * - * @throw it.cnr.jada.comp.ComponentException - */ - -private OggettoBulk initSpe(UserContext userContext,Pdg_preventivoBulk pdg,Pdg_preventivo_spe_detBulk pdg_det) throws it.cnr.jada.comp.ComponentException { - - // Controllo che non siano imputati importi negativi - - boolean importiNegativi = - (pdg_det.getIm_raa_a2_costi_finali().signum() < 0) || - (pdg_det.getIm_rab_a2_costi_altro_cdr().signum() < 0) || - (pdg_det.getIm_rac_a2_spese_odc().signum() < 0) || - (pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() < 0) || - (pdg_det.getIm_rae_a2_spese_ogc().signum() < 0) || - (pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() < 0) || - (pdg_det.getIm_rag_a2_spese_costi_altrui().signum() < 0) || - (pdg_det.getIm_rah_a3_costi_finali().signum() < 0) || - (pdg_det.getIm_rai_a3_costi_altro_cdr().signum() < 0) || - (pdg_det.getIm_ral_a3_spese_odc().signum() < 0) || - (pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() < 0) || - (pdg_det.getIm_ran_a3_spese_ogc().signum() < 0) || - (pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() < 0) || - (pdg_det.getIm_rap_a3_spese_costi_altrui().signum() < 0) || - (pdg_det.getIm_rh_ccs_costi().signum() < 0) || - (pdg_det.getIm_ri_ccs_spese_odc().signum() < 0) || - (pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() < 0) || - (pdg_det.getIm_rk_ccs_spese_ogc().signum() < 0) || - (pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() < 0) || - (pdg_det.getIm_rm_css_ammortamenti().signum() < 0) || - (pdg_det.getIm_rn_css_rimanenze().signum() < 0) || - (pdg_det.getIm_ro_css_altri_costi().signum() < 0) || - (pdg_det.getIm_rp_css_verso_altro_cdr().signum() < 0) || - (pdg_det.getIm_rq_ssc_costi_odc().signum() < 0) || - (pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() < 0) || - (pdg_det.getIm_rs_ssc_costi_ogc().signum() < 0) || - (pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() < 0) || - (pdg_det.getIm_ru_spese_costi_altrui().signum() < 0) || - (pdg_det.getIm_rv_pagamenti().signum() < 0); - - if (pdg.ST_G_APERTURA_PER_VARIAZIONI.equals(pdg.getStato()) || pdg_det.getPdg_variazione() != null) { - boolean importiPositivi = - (pdg_det.getIm_raa_a2_costi_finali().signum() > 0) || - (pdg_det.getIm_rab_a2_costi_altro_cdr().signum() > 0) || - (pdg_det.getIm_rac_a2_spese_odc().signum() > 0) || - (pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() > 0) || - (pdg_det.getIm_rae_a2_spese_ogc().signum() > 0) || - (pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() > 0) || - (pdg_det.getIm_rag_a2_spese_costi_altrui().signum() > 0) || - (pdg_det.getIm_rah_a3_costi_finali().signum() > 0) || - (pdg_det.getIm_rai_a3_costi_altro_cdr().signum() > 0) || - (pdg_det.getIm_ral_a3_spese_odc().signum() > 0) || - (pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() > 0) || - (pdg_det.getIm_ran_a3_spese_ogc().signum() > 0) || - (pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() > 0) || - (pdg_det.getIm_rap_a3_spese_costi_altrui().signum() > 0) || - (pdg_det.getIm_rh_ccs_costi().signum() > 0) || - (pdg_det.getIm_ri_ccs_spese_odc().signum() > 0) || - (pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() > 0) || - (pdg_det.getIm_rk_ccs_spese_ogc().signum() > 0) || - (pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() > 0) || - (pdg_det.getIm_rm_css_ammortamenti().signum() > 0) || - (pdg_det.getIm_rn_css_rimanenze().signum() > 0) || - (pdg_det.getIm_ro_css_altri_costi().signum() > 0) || - (pdg_det.getIm_rp_css_verso_altro_cdr().signum() > 0) || - (pdg_det.getIm_rq_ssc_costi_odc().signum() > 0) || - (pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() > 0) || - (pdg_det.getIm_rs_ssc_costi_ogc().signum() > 0) || - (pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() > 0) || - (pdg_det.getIm_ru_spese_costi_altrui().signum() > 0) || - (pdg_det.getIm_rv_pagamenti().signum() > 0); - - if (importiPositivi && importiNegativi) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile inserire sia importi positivi che negativi."); - } else if (importiNegativi) { - throw new it.cnr.jada.comp.ApplicationException("Non è possibile inserire importi negativi"); - } - - // Richiesta CNR 137R - Solo la colonna pagamenti è modificabile per dettagli di PDG di spesa di CARICO del servente - if(pdg_det.getCategoria_dettaglio().equals(pdg_det.CAT_CARICO) && pdg_det.isNotNew()) { - Pdg_preventivo_spe_detBulk aOrigSpe; - try { - aOrigSpe=(Pdg_preventivo_spe_detBulk)getHome(userContext,pdg_det).findByPrimaryKey(pdg_det); - } catch (PersistencyException e) { - throw new it.cnr.jada.comp.ApplicationException("Errore di lettura del dettaglio di carico originale"); - } - if( - - (pdg_det.getIm_rag_a2_spese_costi_altrui().compareTo(pdg_det.getIm_rag_a2_spese_costi_altrui()) != 0) - || (pdg_det.getIm_rap_a3_spese_costi_altrui().compareTo(pdg_det.getIm_rap_a3_spese_costi_altrui()) != 0) - || (pdg_det.getIm_ru_spese_costi_altrui().compareTo(pdg_det.getIm_ru_spese_costi_altrui()) != 0) - - || (pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() != 0) - || (pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() != 0) - || (pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() != 0) - || (pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() != 0) - || (pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() != 0) - || (pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() != 0) - || (pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() != 0) - || (pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() != 0) - - || (pdg_det.getIm_raa_a2_costi_finali().signum() != 0) - || (pdg_det.getIm_rab_a2_costi_altro_cdr().signum() != 0) - || (pdg_det.getIm_rac_a2_spese_odc().signum() != 0) - || (pdg_det.getIm_rae_a2_spese_ogc().signum() != 0) - || (pdg_det.getIm_rah_a3_costi_finali().signum() != 0) - || (pdg_det.getIm_rai_a3_costi_altro_cdr().signum() != 0) - || (pdg_det.getIm_ral_a3_spese_odc().signum() != 0) - || (pdg_det.getIm_ran_a3_spese_ogc().signum() != 0) - || (pdg_det.getIm_rh_ccs_costi().signum() != 0) - || (pdg_det.getIm_ri_ccs_spese_odc().signum() != 0) - || (pdg_det.getIm_rk_ccs_spese_ogc().signum() != 0) - || (pdg_det.getIm_rm_css_ammortamenti().signum() != 0) - || (pdg_det.getIm_rn_css_rimanenze().signum() != 0) - || (pdg_det.getIm_ro_css_altri_costi().signum() != 0) - || (pdg_det.getIm_rp_css_verso_altro_cdr().signum() != 0) - || (pdg_det.getIm_rq_ssc_costi_odc().signum() != 0) - || (pdg_det.getIm_rs_ssc_costi_ogc().signum() != 0) - ) { - throw new it.cnr.jada.comp.ApplicationException("Per i dettagli di carico del servente solo la colonna pagamenti (V) può essere modificata"); - }} - - -//Controllo campi valorizzati - boolean control = false; - if( pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() != 0 ) { - control = true; - } - if( pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() != 0 ) { - if(control) - throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); - else - control = true; - } - if( pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() != 0 ) { - if(control) - throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); - else - control = true; - } - if( pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() != 0 - && - control) - { - throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); - } - - if( pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() != 0 - && pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() != 0 ) { - throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); - } - - if( pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() != 0 - && pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() != 0 ) { - throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); - } - - if( (pdg_det.getIm_rp_css_verso_altro_cdr().signum() != 0 - || pdg_det.getIm_rab_a2_costi_altro_cdr().signum() != 0 - || pdg_det.getIm_rai_a3_costi_altro_cdr().signum() != 0) - && - (pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() != 0 - || pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() != 0 - || pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() != 0 - || pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() != 0 - || pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() != 0 - || pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() != 0 - || pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() != 0 - || pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() != 0) ) - { - throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare campi verso altra UO e verso altro CdR contemporaneamente"); - } - - // Aggiunto controllo di non imputabilità di colonne di scarico (altra UO e CDR) e colonne non di scarico - // eccetto COSTI (H) per la quadratura - - if( ( - pdg_det.getIm_rp_css_verso_altro_cdr().signum() != 0 - || pdg_det.getIm_rab_a2_costi_altro_cdr().signum() != 0 - || pdg_det.getIm_rai_a3_costi_altro_cdr().signum() != 0 - || pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() != 0 - || pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() != 0 - || pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() != 0 - || pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() != 0 - || pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() != 0 - || pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() != 0 - || pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() != 0 - || pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() != 0 - ) - && ( // manca H per questioni di quadratura e costi altrui perchè NON imputabili direttamente - pdg_det.getIm_ri_ccs_spese_odc().signum() != 0 - || pdg_det.getIm_rk_ccs_spese_ogc().signum() != 0 - || pdg_det.getIm_rm_css_ammortamenti().signum() != 0 - || pdg_det.getIm_rn_css_rimanenze().signum() != 0 - || pdg_det.getIm_ro_css_altri_costi().signum() != 0 - || pdg_det.getIm_rq_ssc_costi_odc().signum() != 0 - || pdg_det.getIm_rs_ssc_costi_ogc().signum() != 0 - || pdg_det.getIm_rv_pagamenti().signum() != 0 -// Fix del 2002/02/12 - Come per la colonna H anche le corrispondenti pluriennali sono valorizzabili -// || pdg_det.getIm_raa_a2_costi_finali().signum() != 0 - || pdg_det.getIm_rac_a2_spese_odc().signum() != 0 - || pdg_det.getIm_rae_a2_spese_ogc().signum() != 0 -// || pdg_det.getIm_rah_a3_costi_finali().signum() != 0 - || pdg_det.getIm_ral_a3_spese_odc().signum() != 0 - || pdg_det.getIm_ran_a3_spese_ogc().signum() != 0 - ) - ) - { - throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare campi verso altra UO o CDR e contemporaneamente campi propri"); - } - - if( pdg_det.getAltro_cdr() != null && pdg_det.getAltro_cdr().getCd_centro_responsabilita() != null - && pdg_det.getIm_rp_css_verso_altro_cdr().signum() == 0 - && pdg_det.getIm_rab_a2_costi_altro_cdr().signum() == 0 - && pdg_det.getIm_rai_a3_costi_altro_cdr().signum() == 0 - && pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() == 0 - && pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() == 0 - && pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() == 0 - && pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() == 0 - && pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() == 0 - && pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() == 0 - && pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() == 0 - && pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() == 0 - // Richiesta CNR 137R - Solo la colonna pagamenti è modificabile per dettagli di PDG di spesa di CARICO del servente - && !(pdg_det.getCategoria_dettaglio().equals(pdg_det.CAT_CARICO) && pdg_det.isNotNew()) - ) - { - throw new it.cnr.jada.comp.ApplicationException("Non sono stati impostati importi validi da riferire all'\"Altro CdR\" indicato"); - } - - - if(pdg_det.getIm_rh_ccs_costi().compareTo( - pdg_det.getIm_ri_ccs_spese_odc().add( - pdg_det.getIm_rj_ccs_spese_odc_altra_uo().add( - pdg_det.getIm_rk_ccs_spese_ogc().add( - pdg_det.getIm_rl_ccs_spese_ogc_altra_uo() - ) - ) - ) - ) != 0 - ) - { - throw new it.cnr.jada.comp.ApplicationException("Il campo \"Costi\" non contiene la somma dei campi relativi ai Costi Con Spese"); - } - - - // Controlli sulle colonne nel caso i conti derivino da interfaccia stipendi - - // Leggo CDR e VOCI DEL PIANO COINVOLTE - try { - CdrBulk aCdrPersonaleBulk = getCDR_PERSONALE(userContext); - CdrBulk aCdrServizioEnteBulk = getCDR_SERVIZIO_ENTE(userContext); - Elemento_voceBulk aTFRBulk = getVoceTFR(userContext); - Elemento_voceBulk aONERICNRBulk = getVoceONERI_CNR(userContext); - - Pdg_preventivo_spe_detHome aSpeHome = (Pdg_preventivo_spe_detHome)getHome(userContext, pdg_det.getClass()); - - Vector aV = aSpeHome.getVociStipendiali(userContext, pdg_det); - - if(!pdg_det.getElemento_voce().getCd_elemento_voce().equals(aTFRBulk.getCd_elemento_voce())) { - if( - !(// Su tutti i CDR tranne quello del personale e quello speciale - pdg_det.getCentro_responsabilita().equalsByPrimaryKey(aCdrPersonaleBulk) - || pdg_det.getCentro_responsabilita().equalsByPrimaryKey(aCdrServizioEnteBulk) - ) - ) { - for (int i=0;i B, livello < 3 - * PreCondition: - * statoAttuale = A, nuovoStato = B, livello < 3 - * PostCondition: - * Restituisce true - * A -> C, livello = 3 - * PreCondition: - * statoAttuale = A, nuovoStato = C, livello = 3 - * PostCondition: - * Restituisce true - * B -> C - * PreCondition: - * statoAttuale = B, nuovoStato = C - * PostCondition: - * Restituisce true - * C -> F - * PreCondition: - * statoAttuale = C, nuovoStato = F - * PostCondition: - * Restituisce true - * C -> Ci - * PreCondition: - * statoAttuale = C, nuovoStato = Ci - * PostCondition: - * Restituisce true - * C -> D, livello < 3 - * PreCondition: - * statoAttuale = C, nuovoStato = D, livello < 3 - * PostCondition: - * Restituisce true - * C -> E, livello = 3 - * PreCondition: - * statoAttuale = C, nuovoStato = E, livello = 3 - * PostCondition: - * Restituisce true - * Ci -> C - * PreCondition: - * statoAttuale = Ci, nuovoStato = C - * PostCondition: - * Restituisce true - * A -> B, livello < 3 - * PreCondition: - * statoAttuale = A, nuovoStato = B, livello < 3 - * PostCondition: - * Restituisce true - * D -> C - * PreCondition: - * statoAttuale = D, nuovoStato = C - * PostCondition: - * Restituisce true - * D -> E - * PreCondition: - * statoAttuale = D, nuovoStato = E - * PostCondition: - * Restituisce true - * E -> D, livello < 3 - * PreCondition: - * statoAttuale = E, nuovoStato = D, livello < 3 - * PostCondition: - * Restituisce true - * E -> C, livello = 3 - * PreCondition: - * statoAttuale = E, nuovoStato = C, livello = 3 - * PostCondition: - * Restituisce true - * F -> G - * PreCondition: - * statoAttuale = F, nuovoStato = G - * PostCondition: - * Restituisce true - * G -> H, livello < 3 - * PreCondition: - * statoAttuale = G, nuovoStato = H, livello < 3 - * PostCondition: - * Restituisce true - * G -> M, livello = 3 - * PreCondition: - * statoAttuale = G, nuovoStato = M, livello = 3 - * PostCondition: - * Restituisce true - * H -> M - * PreCondition: - * statoAttuale = H, nuovoStato = M - * PostCondition: - * Restituisce true - * M -> G - * PreCondition: - * statoAttuale = M, nuovoStato = G - * PostCondition: - * Restituisce true - * M -> F - * PreCondition: - * statoAttuale = M, nuovoStato = F - * PostCondition: - * Restituisce true - * Stato non compatibile - * PreCondition: - * Nessun'altra precondizione verificata - * PostCondition: - * Restituisce false - */ -private boolean isStatoCompatibile (String statoAttuale, int livello, String nuovoStato) { - - if( Pdg_preventivoBulk.ST_A_CREAZIONE.equals( statoAttuale ) ) { - if( livello < 3 ) { - return Pdg_preventivoBulk.ST_B_MODIFICA.equals( nuovoStato ); - } else if( livello == 3) { - return Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ); - } - } - - if( Pdg_preventivoBulk.ST_B_MODIFICA.equals( statoAttuale )) { - return Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ); - } - - if( Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( statoAttuale ) ) { - return (Pdg_preventivoBulk.ST_F_CHIUSO_DFNT.equals( nuovoStato ) || - Pdg_preventivoBulk.ST_CX_MODIFICA.equals( nuovoStato ) || - ( livello == 3 && - Pdg_preventivoBulk.ST_E_CHIUSO.equals( nuovoStato )) || - ( livello != 3 && - Pdg_preventivoBulk.ST_D_CHIUSURA_I.equals( nuovoStato )) - ); - } - - if( Pdg_preventivoBulk.ST_C0_MODIFICA_AC.equals( statoAttuale ) - || - Pdg_preventivoBulk.ST_C1_MODIFC_CDRI.equals( statoAttuale ) - || - Pdg_preventivoBulk.ST_C2_MODIFIC_RUO.equals( statoAttuale )) - { - return Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ); - } - - if( Pdg_preventivoBulk.ST_D_CHIUSURA_I.equals( statoAttuale )) { - return (Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ) || - Pdg_preventivoBulk.ST_E_CHIUSO.equals( nuovoStato )); - } - - if( Pdg_preventivoBulk.ST_E_CHIUSO.equals( statoAttuale ) ) { - if( livello == 3) { - return Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ); - } else if( livello < 3) { - return Pdg_preventivoBulk.ST_D_CHIUSURA_I.equals( nuovoStato ); - } - } - - if( Pdg_preventivoBulk.ST_F_CHIUSO_DFNT.equals( statoAttuale )) { - return Pdg_preventivoBulk.ST_G_APERTURA_PER_VARIAZIONI.equals( nuovoStato ); - } - - if( Pdg_preventivoBulk.ST_G_APERTURA_PER_VARIAZIONI.equals( statoAttuale )) { - if( livello == 3) { - return Pdg_preventivoBulk.ST_M_MODIFICATO_PER_VARIAZIONI.equals( nuovoStato ); - } else if( livello < 3) { - return Pdg_preventivoBulk.ST_H_PRECHIUSURA_PER_VARIAZIONI.equals( nuovoStato ); - } - } - - if( Pdg_preventivoBulk.ST_H_PRECHIUSURA_PER_VARIAZIONI.equals( statoAttuale )) { - return Pdg_preventivoBulk.ST_M_MODIFICATO_PER_VARIAZIONI.equals( nuovoStato ); - } - - if( Pdg_preventivoBulk.ST_M_MODIFICATO_PER_VARIAZIONI.equals( statoAttuale )) { - return - Pdg_preventivoBulk.ST_G_APERTURA_PER_VARIAZIONI.equals( nuovoStato ) || - Pdg_preventivoBulk.ST_F_CHIUSO_DFNT.equals( nuovoStato ); - } - - return false; -} - -//^^@@ -/** - * Voce valida - * PreCondition: - * La voce specificata ha codice uguale a quello presente nella tabella CONFIGURAZIONE_CNR alla voce "ELEMENTO_VOCE_SPECIALE" , "PRESTAZIONI_DA_STRUTTURE_DELL_ENTE" - * PostCondition: - * Ritorna false - * Voce non valida - * PreCondition: - * Nessun'altra precondizione verificata - * PostCondition: - * Ritorna false - */ -//^^@@ - private boolean isVoceCSSAC (UserContext userContext,Elemento_voceBulk voce) throws ComponentException { - try { - Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); - return voce.getCd_elemento_voce().equals(configurazione.getVal01(userContext, voce.getEsercizio(),null,"ELEMENTO_VOCE_SPECIALE","PRESTAZIONI_DA_STRUTTURE_DELL_ENTE")); - } catch(javax.ejb.EJBException e) { - throw handleException(e); - } catch(java.rmi.RemoteException e) { - throw handleException(e); - } - } - -//^^@@ -/** - * voce SAUOP - * PreCondition: - * La voce specificata è SAUOP ( fl_voce_personale = Y ) - * - * PostCondition: - * Ritorna true - * Voce non SAUOP - * PreCondition: - * Nessun'altra precondizione verificata - * PostCondition: - * Ritorna false - */ -//^^@@ - private boolean isVoceSAUOP (UserContext userContext,Elemento_voceBulk voce) { - return voce.getFl_voce_personale() != null && voce.getFl_voce_personale().booleanValue(); - } - -//^^@@ -/** - * CDR NRUO - * PreCondition: - * L'utente in userContext appartiene a un CDR NRUO (getLivelloResponsabilità ritorna 3) - * PostCondition: - * Restituisce un SQL builder per selezionare il solo CDR a cui appartiene l'utente - * CDR RUO - * PreCondition: - * L'utente in userContext appartiene a un CDR RUO (getLivelloResponsabilità ritorna 2) - * PostCondition: - * Restituisce un SQL builder per selezionare il CDR di apparteneza più tutti i CDR della sua UO; - * CDR I - * PreCondition: - * L'utente in userContext appartiene a un CDR I (getLivelloResponsabilità ritorna 1) - * PostCondition: - * Restituisce un SQL builder per selezionare il CDR di appartenenza più tutti i CDR della sua UO; se il CDR appartiene alla UOCDS restituisce anche tutti i CDR delle UO che non hanno CDR di I livello. - * AC - * PreCondition: - * L'utente in userContext appartiene è appartiene al CDR AC - * PostCondition: - * Restituisce un SQL builder per selezionare tutti i CDR escluso sè stesso - */ -//^^@@ - - private SQLBuilder listaCdrPdGPerUtente (UserContext userContext) throws it.cnr.jada.comp.ComponentException { - - CdrBulk cdr = cdrFromUserContext(userContext); - int livelloResponsabilita = getLivelloResponsabilitaCDR(userContext, cdr); - - //lista dei CDR visibili all'utente - Vector lista = new Vector(); - -/* - if (livelloResponsabilita == LV_NRUO) { - lista.add(cdr); - return lista; - } -*/ - - it.cnr.contab.config00.sto.bulk.CdrHome home; - it.cnr.jada.persistency.sql.SQLBuilder sql; - - if (livelloResponsabilita == LV_AC) { - home = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext, CdrBulk.class,"V_CDR_VALIDO","none"); - sql = home.createSQLBuilder(); - } else { -// lista.add(cdr); - home = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext, CdrBulk.class, "V_PDG_CDR_FIGLI_PADRE","none"); - sql = home.createSQLBuilder(); - sql.addSQLClause("AND", "CD_CDR_ROOT", sql.EQUALS, cdr.getCd_centro_responsabilita()); - } - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); - - return sql; -// lista.addAll(home.fetchAll(sql)); -// return lista; - } - - - - private SQLBuilder listaCdrPdGPerUtenteIncludeEnte (UserContext userContext) throws it.cnr.jada.comp.ComponentException { - - CdrBulk cdr = cdrFromUserContext(userContext); - Optional.ofNullable(cdr).orElseThrow(()->new ApplicationException("Errore: CDR di Scrivania non individuato!")); - int livelloResponsabilita = getLivelloResponsabilitaCDR(userContext, cdr); - - //lista dei CDR visibili all'utente - Vector lista = new Vector(); - - - it.cnr.contab.config00.sto.bulk.CdrHome home; - it.cnr.jada.persistency.sql.SQLBuilder sql; - - if (livelloResponsabilita == LV_AC) { - home = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext, CdrBulk.class,"V_CDR_VALIDO","none"); - sql = home.createSQLBuilderEsteso(); - } else { - - home = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext, CdrBulk.class, "V_PDG_CDR_FIGLI_PADRE","none"); - sql = home.createSQLBuilderEsteso(); - sql.addSQLClause("AND", "CD_CDR_ROOT", sql.EQUALS, cdr.getCd_centro_responsabilita()); - } - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); - - return sql; -} -//^^@@ -/** - * normale - * PreCondition: - * - * PostCondition: - * Restituisce una lista dei PDG dei CDR il cui valore del livello di responsabilità è maggiore stretto di quello del CDR specificato - */ -//^^@@ - - private java.util.List listaPdGDipendenti (UserContext userContext,Pdg_preventivoBulk pdg) throws ComponentException { - CdrBulk cdr = pdg.getCentro_responsabilita(); - int liv = getLivelloResponsabilitaCDR(userContext, cdr); - if(liv == LV_AC) return null; //AC non ha un PdG per tanto va bloccato - - it.cnr.jada.bulk.BulkHome home; - if(liv == LV_RUO || liv == LV_CDRI) home = getHome(userContext, Pdg_preventivoBulk.class, "V_PDG_PDG_FIGLI"); - else return java.util.Collections.EMPTY_LIST; - it.cnr.jada.persistency.sql.SQLBuilder sql = home.createSQLBuilder(); - - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); - sql.addSQLClause("AND", "CD_CDR_ROOT", sql.EQUALS, cdr.getCd_centro_responsabilita()); - - try { - return new Vector(getHome(userContext,Pdg_preventivoBulk.class).fetchAll(sql)); - } catch(it.cnr.jada.persistency.PersistencyException e) { - throw handleException(e); - } - } - -/** - * Carica la lista degli stati accessibili in base a quello attuale del PdG - */ - - private java.util.Dictionary loadStatiKeys (UserContext userContext,Pdg_preventivoBulk pdg) throws ComponentException { - java.util.Dictionary list = new it.cnr.jada.util.OrderedHashtable(); - - if(pdg != null && pdg.getStato() != null && !pdg.getStato().equals("") ) { - java.util.Enumeration ek = pdg.STATI.keys(); - java.util.Enumeration el = pdg.STATI.elements(); - int livelloCdR = getLivelloResponsabilitaCDR( userContext, pdg.getCentro_responsabilita() ); - while( ek.hasMoreElements() ) { - String sk = (String)ek.nextElement(); - String sl = (String)el.nextElement(); - - if(isStatoCompatibile( pdg.getStato(), livelloCdR, sk ) - || pdg.getStato().equals( sk )) - { - list.put(sk, sl); - } - } - } - - return list; - } - -/** - * Tutti i controlli superati - * PreCondition: - * Nessun'altra precondizione è verificata - * PostCondition: - * Il dettaglio viene salvato - * Dettaglio scaricato, già chiuso - * PreCondition: - * PDG modificabile dall'utente, CATEGORIA = 'SCR', stato != 'X' - * PostCondition: - * Genera una eccezione con messaggio: "Il dettaglio è già stato contrattato e non è più modificabile. Contattare il CDR servito" - * PDG non modificabile - * PreCondition: - * checkLivelloResponsabilita(pdg,pdg_det) genera una eccezione - * PostCondition: - * Lascia uscire l'eccezione generata - * Dettaglio scaricato - * PreCondition: - * PDG modificabile dall'utente, CATEGORIA = 'SCR', stato = 'X' - * PostCondition: - * Salva il dettaglio e modificato lo stato del dettaglio collegato - * Dettaglio caricato entrata - * PreCondition: - * PDG modificabile dall'utente, CATEGORIA = 'CAR' - * PostCondition: - * Genera una ApplicationException con il messaggio "Il dettaglio non è modificabile. Contattare il CDR servente" - * PDG già chiuso - * PreCondition: - * checkChiusuraPdg(pdg_det) genera una eccezione - * PostCondition: - * Lascia uscire l'eccezione generata - * Dettaglio caricato spesa - * PreCondition: - * PDG modificabile dall'utente, CATEGORIA = 'CAR', e viene richiesto di modificare una colonna diversa da colonna pagamenti (V) - * PostCondition: - * Genera una ApplicationException con il messaggio: "Per i dettagli di carico del serevnte solo la colonna pagamenti (V) puo' essere modificata" - */ - -public OggettoBulk modificaConBulk(UserContext userContext,OggettoBulk bulk) throws ComponentException { - Pdg_preventivo_detBulk pdgDett = (Pdg_preventivo_detBulk)bulk; - - if (Pdg_preventivo_detBulk.CAT_SCARICO.equals(pdgDett.getCategoria_dettaglio()) && - !Pdg_preventivo_detBulk.ST_NESSUNA_AZIONE.equals( pdgDett.getStato())) - throw new it.cnr.jada.comp.ApplicationException("Il dettaglio è già stato contrattato e non è più modificabile. Contattare il CDR servito"); - - // Richiesta CNR 137R Solo i dettagli di spesa, sotto certe condizioni, sono modificabili - if(pdgDett instanceof it.cnr.contab.pdg00.bulk.Pdg_preventivo_etr_detBulk && Pdg_preventivo_detBulk.CAT_CARICO.equals( pdgDett.getCategoria_dettaglio())) - throw new it.cnr.jada.comp.ApplicationException("Il dettaglio non è modificabile. Contattare il CDR servente"); - - try { - Pdg_preventivoBulk pdg = (Pdg_preventivoBulk)getHome(userContext, Pdg_preventivoBulk.class).findAndLock( - new Pdg_preventivoBulk( - pdgDett.getEsercizio(), - pdgDett.getCd_centro_responsabilita())); - - // 05/09/2003 - // Aggiunto controllo sulla chiusura dell'esercizio - if (isEsercizioChiuso(userContext,pdg)) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile modificare dettagli del pdg ad esercizio chiuso."); - - init(userContext,pdg,pdgDett); - - super.modificaConBulk(userContext, (OggettoBulk)pdgDett); - - validaVariazione(userContext, bulk); - validaVariazione(userContext, bulk); - - /* - * Il controllo che la somma degli importi aggregati sia positiva non deve avvenire - * per i dettagli provenienti da variazione al PDG non ancora in stato approvato - */ - if (!pdgDett.isDaVariazione()) - controllaAggregatoPdgDetPositivo(userContext,pdg,pdgDett); - else - { - Pdg_variazioneBulk pdgVar = (Pdg_variazioneBulk)getHome(userContext, Pdg_variazioneBulk.class).findByPrimaryKey( - new Pdg_variazioneBulk( - pdgDett.getPdg_variazione().getEsercizio(), - pdgDett.getPdg_variazione().getPg_variazione_pdg())); - if (pdgVar.isApprovata()) - controllaAggregatoPdgDetPositivo(userContext,pdg,pdgDett); - } - - return bulk; - } catch(OutdatedResourceException e) { - throw handleException(e); - } catch(PersistencyException e) { - throw handleException(e); - } catch(BusyResourceException e) { - throw handleException(e); - } -} -/** - * Richiesto cambiamento di stato, Pdg occupato - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg che risulta occupato (lock) - * PostCondition: - * Viene generata una BusyResourceException - * Richiesto cambiamento di stato, nuovo stato non compatibile con lo stato attuale - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg, ma lo stato specificato non è compatibile con lo stato - * attuale del pdg (secondo isStatoCompatibile()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Stato X non compatibile con l'attuale stato Y del Pdg" - * Richiesto cambiamento di stato, livello utente insufficiente - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg, ma il livello dell'utente non è sufficiente per effettuare l'operazione (confrontaLivelloResponsabilita() < 0) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Utente non abilitato ad operare sul PDG" - * Richiesto cambiamento di stato, modifica di stato non riuscita - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg e il passaggio di stato provoca qualche errore applicativo (secondo modificaStatoPdG_X_Y() per - * PostCondition: - * Viene lasciato uscire l'errore generato - * Richiesto cambiamento in stato C, esistono discrepanza sugli insiemi di linee attività - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg, nessuna delle altre precondizioni è verificata ma esistono discrepanze sugli importi entrate/spese legati a insiemi di linee di attività (secondo controllaDiscrepanzeInsiemeLa()) - * PostCondition: - * Viene effettuata la modifica di stato e viene restituito il messaggio di avvertimento "Esistono discrepanze tra gli importi entrate - spese legati ad insieme di l.a. " - * Richiesto cambiamento di stato da C a F - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, nessuna delle altre pecondizioni è verificata - * PostCondition: - * Viene creata la variazione di bilancio automatica per la spalmatura delle entrate CNR (creaRipartEntrate()) - * Normale - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, nessuna delle altre pecondizioni è verificata - * PostCondition: - * Viene creata la variazione di bilancio automatica per la spalmatura delle entrate CNR (creaRipartEntrate()) - */ - -public OggettoBulk modificaStatoPdG (UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { - try { - Pdg_preventivoBulk oldPdg = (Pdg_preventivoBulk)getHome(userContext,pdg).findAndLock(pdg); - - // 05/09/2003 - // Aggiunto controllo sulla chiusura dell'esercizio - if (isEsercizioChiuso(userContext,pdg)) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile modificare lo stato del pdg ad esercizio chiuso."); - - String nuovoStato = pdg.getStato(); - String vecchioStato = oldPdg.getStato(); - int livelloResponsabilitaPdg = getLivelloResponsabilitaCDR(userContext, oldPdg.getCentro_responsabilita()); - // 09/06/2005 - // Aggiunto controllo sul cambiamento di stato da quello finale, obbligo l'utilizzo delle variazioni al PDG - if (vecchioStato.equals(Pdg_preventivoBulk.ST_F_CHIUSO_DFNT)) - throw new it.cnr.jada.comp.ApplicationException("Non è possibile modificare lo stato del pdg poichè è in chiusura definitiva."); - - // Controllo il nuovo stato del pdg è compatibile con lo stato attuale - if( !isStatoCompatibile(vecchioStato, livelloResponsabilitaPdg, nuovoStato) ) - throw new it.cnr.jada.comp.ApplicationException("Stato \"" + nuovoStato + "\" non compatibile con l'attuale stato \"" + vecchioStato + "\" del PdG"); - - CdrBulk cdrUtente = cdrFromUserContext(userContext); - int livelloResponsabilitaUtente = getLivelloResponsabilitaCDR(userContext,cdrUtente); - - // Controllo se il livello di responsabilità dell'utente è sufficiente per cambiare lo stato - // del pdg - if(confrontaLivelloResponsabilita(userContext, cdrUtente,pdg.getCentro_responsabilita(),livelloResponsabilitaUtente,livelloResponsabilitaPdg) < 0) - utenteNonAbilitato(); - - if(pdg.ST_CX_MODIFICA.equals(nuovoStato)) { - if (livelloResponsabilitaUtente == LV_NRUO) - utenteNonAbilitato(); - nuovoStato = Pdg_preventivoBulk.ST_C_CHIUSURA_II + livelloResponsabilitaUtente; - } - - // Invoco il metodo modificaStato_x_y() - it.cnr.jada.util.Introspector.invoke( - this, - "modificaStatoPdG_"+vecchioStato+"_"+nuovoStato, - new Object[] { - userContext, - cdrUtente, - pdg, - oldPdg, - new Integer(livelloResponsabilitaUtente), - new Integer(livelloResponsabilitaPdg) - }); - - oldPdg.setStato(nuovoStato); - oldPdg.setAnnotazioni(pdg.getAnnotazioni()); - oldPdg.setUser(userContext.getUser()); - updateBulk(userContext,oldPdg); - - oldPdg.setStatiKeys(loadStatiKeys(userContext, oldPdg)); - - // Passando da C a F devo creare la variazione di bilancio automatica per spalmatura entrate CNR - // Va fatta qui (non in modificaStatoPdG_C_F perchè lo stato del Pdg deve essere già F - if (Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals(vecchioStato) && - Pdg_preventivoBulk.ST_F_CHIUSO_DFNT.equals(nuovoStato)) { - creaRipartEntrate(userContext, oldPdg); - } - - if (pdg.ST_C_CHIUSURA_II.equals(nuovoStato) && - controllaDiscrepanzeInsiemeLa(userContext,pdg)) - return asMTU(oldPdg,"Esistono discrepanze tra gli importi entrate - spese legati ad insieme di l.a. "); - - return oldPdg; - - } catch(java.lang.reflect.InvocationTargetException e) { - throw handleException(e.getTargetException()); - } catch(Throwable e) { - throw handleException(e); - } -} - -/* - * Richiesto cambiamento di stato da A a B - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da A ad B, pdg dipendenti non chiusi (stato <> C o F) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - */ -public Pdg_preventivoBulk modificaStatoPdG_A_B( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i pdg dipendenti siano in stato C - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II }); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da A a C, stato figli non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, pdg dipendenti non chiusi (stato <> C o F) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da A a C, dettagli scaricati non confermati - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" - * Richiesto cambiamento di stato da A a C, costi del dipendente non scaricati completamente - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, il cdr del pdg è di 1^ livello e i costi del dipendente dell'UO non sono stati scaricati completamente (secondo controllaScaricoCDPCompleto()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Costi del personale non ancora scaricati completamente!" - * Richiesto cambiamento di stato da A a C, i ricavi figurativi non quadrano - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" - * Richiesto cambiamento di stato da A a C - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata - * PostCondition: - * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) - */ -public Pdg_preventivoBulk modificaStatoPdG_A_C( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i pdg dipendenti siano in stato C - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II,pdg.ST_F_CHIUSO_DFNT }); - - // Controllo che i dettagli scaricati su altre UO siano stati confermati - controllaDettScarConfermati(userContext, oldPdg); - - // Controlla che tutti i dipendenti siano stati scaricati completamente sul PIANO DI GESTIONE del CDR di I livello o di AREA per chiudere definitivamente - controllaScaricoCDPCompleto(userContext,pdg); - - // Effettuo i controlli di quadratura dei ricavi figurativi - controllaQuadraturaRicaviFigurativi(userContext,pdg); - - // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area - inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da B a C, stato figli non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, pdg dipendenti non chiusi (stato <> C o F) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da B a C, dettagli scaricati non confermati - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" - * Richiesto cambiamento di stato da B a C, costi del dipendente non scaricati completamente - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, il cdr del pdg è di 1^ livello e i costi del dipendente dell'UO non sono stati scaricati completamente (secondo controllaScaricoCDPCompleto()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Costi del personale non ancora scaricati completamente!" - * Richiesto cambiamento di stato da B a C, i ricavi figurativi non quadrano - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" - * Richiesto cambiamento di stato da B a C - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata - * PostCondition: - * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) - */ -public Pdg_preventivoBulk modificaStatoPdG_B_C( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i pdg dipendenti siano in stato C - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II,pdg.ST_F_CHIUSO_DFNT }); - - // Controllo che i dettagli scaricati su altre UO siano stati confermati - controllaDettScarConfermati(userContext, oldPdg); - - // Controlla che tutti i dipendenti siano stati scaricati completamente sul PIANO DI GESTIONE del CDR di I livello o di AREA per chiudere definitivamente - controllaScaricoCDPCompleto(userContext,pdg); - - // Effettuo i controlli di quadratura dei ricavi figurativi - controllaQuadraturaRicaviFigurativi(userContext,pdg); - - // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area - inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da C a C0, stato figli non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C ad C0, pdg dipendenti non chiusi (stato <> C) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da C a C0, stato padre non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C a C0, pdg padre in stato <> C0 - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da C a C0, livello responsabilità non compatbile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C a C0, l'utente NON appartiene al CDR dell'Amministrazione Centrale - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Utente non abilitato." - */ -public Pdg_preventivoBulk modificaStatoPdG_C_C0( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che l'utente abbia lo stesso livello del Ci richiesto - if(livelloResponsabilitaUtente != LV_AC) - utenteNonAbilitato(); - - // Controllo che il pdg padre sia in stato C0 - controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_C0_MODIFICA_AC }); - - // Controllo che i pdg figli siano in stato C - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II }); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da C a C1 - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C ad C1, pdg dipendenti non chiusi (stato <> C) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da C a C1 - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C a C1, pdg padre in stato <> C1 - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da C a C1, livello responsabilità non compatbile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C a C1, l'utente NON appartiene ad un CDR di 1^ livello - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Utente non abilitato." - */ -public Pdg_preventivoBulk modificaStatoPdG_C_C1( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che l'utente abbia lo stesso livello del Ci richiesto - if(livelloResponsabilitaUtente != LV_CDRI) - utenteNonAbilitato(); - - // Controllo che il pdg padre sia in stato C0 - controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_C1_MODIFC_CDRI }); - - // Controllo che i pdg figli siano in stato C - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II }); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da C a C2 - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C ad C2, pdg dipendenti non chiusi (stato <> C) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da C a C2 - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C a C2, pdg padre in stato <> C2 - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da C a C2, livello responsabilità non compatbile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C a C2, l'utente NON appartiene ad un CDR di 2^ livello (RUO) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Utente non abilitato." - */ -public Pdg_preventivoBulk modificaStatoPdG_C_C2( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che l'utente abbia lo stesso livello del Ci richiesto - if(livelloResponsabilitaUtente != LV_RUO) - utenteNonAbilitato(); - - // Controllo che il pdg padre sia in stato C0 - controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_C2_MODIFIC_RUO }); - - // Controllo che i pdg figli siano in stato C - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II }); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da C a D - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C a D, pdg padre in stato <> E - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - */ -public Pdg_preventivoBulk modificaStatoPdG_C_D( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controlla che il padre sia in stato E - controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_E_CHIUSO }); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da C a E - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C a E, pdg padre in stato <> E - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - */ -public Pdg_preventivoBulk modificaStatoPdG_C_E( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controlla che il padre sia in stato E - controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_E_CHIUSO }); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da C a F, stato figli non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, pdg dipendenti non chiusi (stato <> F) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da C a F, Bilancio Preventivo CNR non approvato - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, il Bilancio Preventivo CNR non è stato approvato (secondo controllaBilPrevCnrApprovato()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il bilancio preventivo CNR non risulta ancora approvato" - * Richiesto cambiamento di stato da C a F, Pdg aggregato aperto - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, il pdg del cdr di 1^ livello è ancora aperto (secondo controllaAggregatoChiuso) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il piano di gestione aggregato non è chiuso. Contattare il CDR di primo livello" - * Richiesto cambiamento di stato da C a F, esistono discrepanze nel Pdg Aggregato - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, il cdr del pdg possiede un pdg aggregato ed esistono discrepanze tra gli importi iniziali e quelli modificati nel pdg aggregato (secondo controllaDiscrepanzeAggregato()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Sono presenti importi complessivi non compatibili con i dati impostati dall'ente." - */ -public Pdg_preventivoBulk modificaStatoPdG_C_F( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i pdg dipendenti siano in stato F - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_F_CHIUSO_DFNT }); - - // Verificare che il bilancio finanziario CNR sia approvato (Richiesta n. 56) - controllaBilPrevCnrApprovato(userContext, pdg); - - // Verificare che l'aggregato sia CHIUSO in stato B - controllaAggregatoChiuso(userContext,pdg); - - // Controllo della presenza di discrepanze nell'aggregato - controllaDiscrepanzeAggregato(userContext,pdg,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da C0 a C, livello responsabilità non compatbile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C0 a C, l'utente NON appartiene al CDR dell'Amministrazione Centrale - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Utente non abilitato." - * Richiesto cambiamento di stato da C0 a C - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C0 a C, nessun'altra precondizione è verificata - * PostCondition: - * Viene invocato modificaStatoPdG_Ci_C - */ -public Pdg_preventivoBulk modificaStatoPdG_C0_C( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - if(livelloResponsabilitaUtente > LV_AC) - utenteNonAbilitato(); - - // Effettuo i controlli comuni a tutti i livelli Ci - modificaStatoPdG_Ci_C(userContext,cdrUtente,pdg,oldPdg,livelloResponsabilitaUtente,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da C1 a C, livello responsabilità non compatbile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C1 a C, l'utente appartiene ad un CDR di livello RUO o NRUO - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Utente non abilitato." - * Richiesto cambiamento di stato da C1 a C - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C1 a C, nessun'altra precondizione è verificata - * PostCondition: - * Viene invocato modificaStatoPdG_Ci_C - */ -public Pdg_preventivoBulk modificaStatoPdG_C1_C( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - if(livelloResponsabilitaUtente > LV_CDRI) - utenteNonAbilitato(); - - // Effettuo i controlli comuni a tutti i livelli Ci - modificaStatoPdG_Ci_C(userContext,cdrUtente,pdg,oldPdg,livelloResponsabilitaUtente,livelloResponsabilitaPdg); - - return pdg; -} -/* - * Richiesto cambiamento di stato da C2 a C, livello responsabilità non compatbile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C2 a C, l'utente appartiene ad un CDR di livello NRUO - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Utente non abilitato." - * Richiesto cambiamento di stato da C2 a C - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C2 a C, nessun'altra precondizione è verificata - * PostCondition: - * Viene invocato modificaStatoPdG_Ci_C - */ -public Pdg_preventivoBulk modificaStatoPdG_C2_C( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - if(livelloResponsabilitaUtente > LV_RUO) - utenteNonAbilitato(); - - // Effettuo i controlli comuni a tutti i livelli Ci - modificaStatoPdG_Ci_C(userContext,cdrUtente,pdg,oldPdg,livelloResponsabilitaUtente,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da Ci a C, stato figli non compatibili - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da C0,C1,C2 ad C, pdg dipendenti non chiusi (stato <> C o F) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da Ci a C, i ricavi figurativi non quadrano - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da Ci a C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" - * Richiesto cambiamento di stato da Ci a C - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da Ci a C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata - * PostCondition: - * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) - */ -public Pdg_preventivoBulk modificaStatoPdG_Ci_C( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i pdg dipendenti siano in stato C - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II,pdg.ST_F_CHIUSO_DFNT }); - - // Controllo che i dettagli scaricati su altre UO siano stati confermati - controllaDettScarConfermati(userContext, oldPdg); - - // Effettuo i controlli di quadratura dei ricavi figurativi - controllaQuadraturaRicaviFigurativi(userContext,pdg); - - // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area - inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da D a C, dettagli scaricati non confermati - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da D a C, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" - * Richiesto cambiamento di stato da D a C, costi del dipendente non scaricati completamente - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da D a C, il cdr del pdg è di 1^ livello e i costi del dipendente dell'UO non sono stati scaricati completamente (secondo controllaScaricoCDPCompleto()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Costi del personale non ancora scaricati completamente!" - * Richiesto cambiamento di stato da D a C, i ricavi figurativi non quadrano - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da D a C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" - * Richiesto cambiamento di stato da D a C - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da D a C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata - * PostCondition: - * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) - */ -public Pdg_preventivoBulk modificaStatoPdG_D_C( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i dettagli scaricati su altre UO siano stati confermati - controllaDettScarConfermati(userContext, oldPdg); - - // Controlla che tutti i dipendenti siano stati scaricati completamente sul PIANO DI GESTIONE del CDR di I livello o di AREA per chiudere definitivamente - controllaScaricoCDPCompleto(userContext,pdg); - - // Effettuo i controlli di quadratura dei ricavi figurativi - controllaQuadraturaRicaviFigurativi(userContext,pdg); - - // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area - inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da D a E, stato padre non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da D a E, pdg padre in stato <> E - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - */ -public Pdg_preventivoBulk modificaStatoPdG_D_E( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controlla che il padre sia in stato E - controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_E_CHIUSO }); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da E a C, dettagli scaricati non confermati - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da E a C, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" - * Richiesto cambiamento di stato da E a C, costi del dipendente non scaricati completamente - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da E a C, il cdr del pdg è di 1^ livello e i costi del dipendente dell'UO non sono stati scaricati completamente (secondo controllaScaricoCDPCompleto()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Costi del personale non ancora scaricati completamente!" - * Richiesto cambiamento di stato da E a C, i ricavi figurativi non quadrano - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da E a C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" - * Richiesto cambiamento di stato da E a C - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da E a C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata - * PostCondition: - * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) - */ -public Pdg_preventivoBulk modificaStatoPdG_E_C( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i dettagli scaricati su altre UO siano stati confermati - controllaDettScarConfermati(userContext, oldPdg); - - // Controlla che tutti i dipendenti siano stati scaricati completamente sul PIANO DI GESTIONE del CDR di I livello o di AREA per chiudere definitivamente - controllaScaricoCDPCompleto(userContext,pdg); - - // Effettuo i controlli di quadratura dei ricavi figurativi - controllaQuadraturaRicaviFigurativi(userContext,pdg); - - // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area - inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da E a D, stato figli non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da E ad D, pdg dipendenti non chiusi (stato <> C o F) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da E a D, dettagli scaricati non confermati - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da E a D, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" - */ -public Pdg_preventivoBulk modificaStatoPdG_E_D( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i pdg dipendenti siano in stato C - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II, pdg.ST_F_CHIUSO_DFNT }); - - // Controllo che i dettagli scaricati su altre UO siano stati confermati - controllaDettScarConfermati(userContext, oldPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da F a G, stato padre non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da F a G, pdg padre in stato <> F o G - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da F a G, Pdg aggregato aperto - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da F a G, il pdg del cdr di 1^ livello è ancora aperto (secondo controllaAggregatoChiuso) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il piano di gestione aggregato non è chiuso. Contattare il CDR di primo livello" - * Richiesto cambiamento di stato da F a G, bilancio preventivo del cds non ancora approvato - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da F a G, il bilancio preventivo del cds a cui appartiene il cdr non è ancora approvato (secondo controllaPreventivoCdsApprovato) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il bilancio preventivo del cds non è approvato." - */ -public Pdg_preventivoBulk modificaStatoPdG_F_G( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i pdg padri siano in stato F o G - controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_F_CHIUSO_DFNT, pdg.ST_G_APERTURA_PER_VARIAZIONI }); - - // Controllo che il pdg aggregato del cdr di 1° livello sia chiuso - controllaAggregatoChiuso(userContext,pdg); - - // Controllo che il preventivo finanziario del cds sia approvato - controllaBilancioPreventivoCdsApprovato(userContext,pdg.getCentro_responsabilita()); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da G a H, stato figli non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da G a H, pdg dipendenti in stato <> F o M - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - */ -public Pdg_preventivoBulk modificaStatoPdG_G_H( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i pdg dipendenti siano in stato F o M - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_F_CHIUSO_DFNT, pdg.ST_M_MODIFICATO_PER_VARIAZIONI }); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da G a M, dettagli scaricati non confermati - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da G a M, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" - * Richiesto cambiamento di stato da G a M, i ricavi figurativi non quadrano - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da G a M, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" - * Richiesto cambiamento di stato da G a M - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da G a M, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata - * PostCondition: - * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) - */ -public Pdg_preventivoBulk modificaStatoPdG_G_M( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i dettagli scaricati su altre UO siano stati confermati - controllaDettScarConfermati(userContext, oldPdg); - - // Effettuo i controlli di quadratura dei ricavi figurativi - controllaQuadraturaRicaviFigurativi(userContext,pdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da H a M, dettagli scaricati non confermati - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da H a M, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" - * Richiesto cambiamento di stato da H a M, i ricavi figurativi non quadrano - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da H a M, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" - * Richiesto cambiamento di stato da H a M - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da H a M, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata - * PostCondition: - * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) - */ -public Pdg_preventivoBulk modificaStatoPdG_H_M( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che i dettagli scaricati su altre UO siano stati confermati - controllaDettScarConfermati(userContext, oldPdg); - - // Effettuo i controlli di quadratura dei ricavi figurativi - controllaQuadraturaRicaviFigurativi(userContext,pdg); - - // Se passo in stato M su un pdg di un cdr di 1^ livello - // e l'aggregato è ancora in stato B, forzo il passaggio dell'aggregato - // in stato M - if (livelloResponsabilitaPdg == 1 || - isCdrArea(userContext,pdg.getCentro_responsabilita())) - try { - Pdg_aggregatoBulk pdg_aggregato = (Pdg_aggregatoBulk)getHome(userContext,Pdg_aggregatoBulk.class).findAndLock(new Pdg_aggregatoBulk(pdg.getCd_centro_responsabilita(),pdg.getEsercizio())); - if (pdg_aggregato.STATO_B.equals(pdg_aggregato.getStato())) { - pdg_aggregato.setStato(pdg_aggregato.STATO_M); - pdg_aggregato.setUser(userContext.getUser()); - getHome(userContext,pdg_aggregato).update(pdg_aggregato, userContext); - } - } catch(OutdatedResourceException e) { - throw handleException(e); - } catch(BusyResourceException e) { - throw handleException(e); - } catch(PersistencyException e) { - throw handleException(e); - } - - // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area - inizializzaAggregatoPDGPerVariazioni(userContext, pdg,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da M a F, stato figli non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da M a F, pdg dipendenti in stato <> F - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da M a F, stato aggregato non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da M a F, il pdg aggregato del cdr di 1^ livello è in stato diverso da E - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Stato del pdg aggregato non compatibile" - * Richiesto cambiamento di stato da M a F, esistono discrepanze nel Pdg Aggregato - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da M ad F, il cdr del pdg possiede un pdg aggregato ed esistono discrepanze tra gli importi iniziali e quelli modificati nel pdg aggregato (secondo controllaDiscrepanzeAggregatoPerVariazioni()) - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Sono presenti importi complessivi non compatibili con i dati impostati dall'ente." - * Richiesto cambiamento di stato da M a F - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da M ad F e nessun'altra precondizione è verificata - * PostCondition: - * Viene invocato trasformDettagliVariazioneInDefinitivi() per convertire i dettagli del pdg da dettagli con origine 'MOD' in dettagli con provenienza 'DIR' - */ -public Pdg_preventivoBulk modificaStatoPdG_M_F( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che il pdg aggregato del cdr di 1° livello sia in stato "E" - controllaStatoAggregato(userContext,pdg,it.cnr.contab.prevent00.bulk.Pdg_aggregatoBulk.STATO_E); - - // Controllo che i pdg dipendenti siano in stato F - controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_F_CHIUSO_DFNT }); - - // Controllo della presenza di discrepanze nell'aggregato - controllaDiscrepanzeAggregatoPerVariazioni(userContext,pdg,livelloResponsabilitaPdg); - - return pdg; -} - -/* - * Richiesto cambiamento di stato da M a G, stato figli non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da M a G, pdg padre in stato <> G - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - * Richiesto cambiamento di stato da M a G, stato padre non compatibile - * PreCondition: - * L'utente ha richiesto il cambiamento di stato di un pdg da M a G, pdg padre in stato <> E - * PostCondition: - * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." - */ -public Pdg_preventivoBulk modificaStatoPdG_M_G( - UserContext userContext, - CdrBulk cdrUtente, - Pdg_preventivoBulk pdg, - Pdg_preventivoBulk oldPdg, - int livelloResponsabilitaUtente, - int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { - - // Controllo che il pdg aggregato del cdr di 1° livello sia in stato "E" - controllaStatoAggregato(userContext,pdg,it.cnr.contab.prevent00.bulk.Pdg_aggregatoBulk.STATO_E); - - // Controllo che il pdg padre sia già in stato "G" - controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_G_APERTURA_PER_VARIAZIONI }); - - return pdg; -} - -//^^@@ -/** - * Tutti controlli superati - * PreCondition: - * Viene richiesto il ribaltamento dei costi del Piano di Gestione del CdR specificato all'area di ricerca a cui afferisce. Il bilancio del CNR è già stato approvato - * PostCondition: - * La procedura Oracle CNRCTB053.ribaltaSuAreaPDG viene eseguita per l'anno di esercizio ed il CdR specificati. - */ -//^^@@ - public Pdg_preventivoBulk ribaltaCostiPdGArea(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ApplicationException, it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB053.ribaltaSuAreaPDG(?,?,?)}",false,this.getClass()); - cs.setObject( 1, pdg.getEsercizio() ); - cs.setString( 2, pdg.getCd_centro_responsabilita()); - cs.setObject( 3, userContext.getUser()); - try { - lockBulk(userContext,pdg); - cs.executeQuery(); - return caricaPdg(userContext,pdg.getCentro_responsabilita()); - } catch (Throwable e) { - throw handleException(pdg,e); - } finally { - cs.close(); - } - } catch (java.sql.SQLException e) { - // Gestisce eccezioni SQL specifiche (errori di lock,...) - throw handleSQLException(e); - } - } - -//^^@@ -/** - * default - * PreCondition: - * Viene richiesto l'esecuzione dello scarico dei costi del dipendente per un pdg - * PostCondition: - * Viene invocata la stored procedure CNRCTB060.scaricaCDPSuPdg - */ -//^^@@ - public Pdg_preventivoBulk scaricaCDPSuPdg(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ApplicationException, it.cnr.jada.comp.ComponentException { - try { - LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() - + "CNRCTB060.scaricaCDPSuPdg(?,?,?)}",false,this.getClass()); - cs.setObject( 1, pdg.getEsercizio() ); - cs.setString( 2, pdg.getCd_centro_responsabilita()); - cs.setObject( 3, userContext.getUser()); - try { - lockBulk(userContext,pdg); - cs.executeQuery(); - return caricaPdg(userContext,pdg.getCentro_responsabilita()); - } catch (Throwable e) { - throw handleException(pdg,e); - } finally { - cs.close(); - } - } catch (java.sql.SQLException e) { - // Gestisce eccezioni SQL specifiche (errori di lock,...) - throw handleSQLException(e); - } -} - -/** - * Filtra i soli dettagli non annullati - */ -protected Query select(UserContext userContext,CompoundFindClause clauses,OggettoBulk bulk) throws ComponentException, it.cnr.jada.persistency.PersistencyException { - Pdg_preventivo_detBulk pdg_det = (Pdg_preventivo_detBulk)bulk; - - SQLBuilder sql = (SQLBuilder)super.select(userContext,clauses,bulk); - - sql.addClause("AND", "stato", sql.NOT_EQUALS, "N"); - - return sql; -} -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco dei centri di responsabilità compatibili per un dettaglio di spesa verso altra UO o di costi senza spese con un elenco di clausole specificate - * PostCondition: - * Viene restituito una query sui centri di spesa con le clausole specificate e una clausola sull'esercizio uguale a quello del dettaglio di spesa specificato - */ -//^^@@ - - public SQLBuilder selectAltro_cdrByClause (UserContext userContext, - Pdg_preventivo_spe_detBulk dettaglio_pdg, - CdrBulk cdr, - CompoundFindClause clause) - throws ComponentException, PersistencyException - { - if (clause == null) clause = ((OggettoBulk)cdr).buildFindClauses(null); - - SQLBuilder sql = getHome(userContext, cdr, "V_CDR_VALIDO").createSQLBuilder(); - sql.addSQLClause("AND", "CD_CENTRO_RESPONSABILITA", sql.NOT_EQUALS, dettaglio_pdg.getCd_centro_responsabilita()); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - - if (clause != null) sql.addClause(clause); - - return sql; - } - /** - * Normale - * PreCondition: - * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente - * PostCondition: - * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato - */ -// ^^@@ - public SQLBuilder selectCdsForPrintByClause (UserContext userContext, - Stampa_vpg_bilancio_riclassVBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException - { - SQLBuilder sql = getHome(userContext, cds.getClass(), "V_CDS_VALIDO").createSQLBuilder(); - sql.addClause( clause ); - sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); - return sql; - } - public SQLBuilder selectCdsForPrintByClause (UserContext userContext, - Stampa_pdg_etr_speVBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException - { - SQLBuilder sql = getHome(userContext, cds.getClass(), "V_CDS_VALIDO").createSQLBuilder(); - sql.addClause( clause ); - sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); - return sql; - } - public SQLBuilder selectCdsForPrintByClause (UserContext userContext, - Stampa_libro_giornaleBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException - { - SQLBuilder sql = getHome(userContext, cds.getClass(), "V_CDS_VALIDO").createSQLBuilder(); - sql.addClause( clause ); - sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); - return sql; - } - - public SQLBuilder selectCdsForPrintByClause (UserContext userContext, Stampa_situazione_analitica_x_GAEBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException - { - SQLBuilder sql = ((CdsHome) getHome(userContext, cds.getClass(),"V_CDS_VALIDO")).createSQLBuilderIncludeEnte(); - sql.addClause( clause ); - - String cd_cds_scrivania = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); - it.cnr.contab.config00.sto.bulk.CdsHome cds_home = (CdsHome)getHome(userContext, CdsBulk.class); - it.cnr.contab.config00.sto.bulk.CdsBulk cds_scrivania = (CdsBulk)cds_home.findByPrimaryKey(new CdsBulk(cd_cds_scrivania)); - - if (cds_scrivania.getCd_tipo_unita().equals(it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_ENTE)){ - sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); - } - else{ - sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); - sql.addSQLClause("AND", "CD_UNITA_ORGANIZZATIVA", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getCd_cds()); - sql.addClause("AND","FL_CDS",sql.EQUALS, new Boolean(true) ); - } - return sql; - } - - public SQLBuilder selectCdsForPrintByClause (UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException - { - SQLBuilder sql = ((CdsHome) getHome(userContext, cds.getClass(),"V_CDS_VALIDO")).createSQLBuilderIncludeEnte(); - sql.addClause( clause ); - - String cd_cds_scrivania = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); - it.cnr.contab.config00.sto.bulk.CdsHome cds_home = (CdsHome)getHome(userContext, CdsBulk.class); - it.cnr.contab.config00.sto.bulk.CdsBulk cds_scrivania = (CdsBulk)cds_home.findByPrimaryKey(new CdsBulk(cd_cds_scrivania)); - - if (cds_scrivania.getCd_tipo_unita().equals(it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_ENTE)){ - sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); - } - else{ - sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); - sql.addSQLClause("AND", "CD_UNITA_ORGANIZZATIVA", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getCd_cds()); - sql.addClause("AND","FL_CDS",sql.EQUALS, new Boolean(true) ); - } - return sql; - } - - public SQLBuilder selectElementoVoceForPrintByClause(UserContext userContext, Stampa_pdg_etr_speVBulk stampa, Elemento_voceBulk elementoVoce, CompoundFindClause clauses) throws ComponentException { - - Elemento_voceHome home = (Elemento_voceHome)getHome(userContext, elementoVoce); - SQLBuilder sql = home.createSQLBuilder(); - sql.addClause("AND","esercizio",sql.EQUALS, CNRUserContext.getEsercizio(userContext)); - sql.addClause("AND","fl_partita_giro", sql.EQUALS, Boolean.FALSE); - sql.addClause("AND","ti_elemento_voce", sql.EQUALS, home.TIPO_CAPITOLO); - sql.addClause("AND","ti_gestione", sql.EQUALS, stampa.getTi_etr_spe()); - if(stampa.getTi_etr_spe().equals(Stampa_pdg_etr_speVBulk.TIPO_ENTRATA)) - sql.addClause("AND","ti_appartenenza", sql.EQUALS, home.APPARTENENZA_CNR); - else - sql.addClause("AND","ti_appartenenza", sql.EQUALS, home.APPARTENENZA_CDS); - sql.addClause(clauses); - return sql; - } - public SQLBuilder selectProgettoForPrintByClause (UserContext userContext, - Stampa_pdg_etr_speVBulk stampa, ProgettoBulk progetto, CompoundFindClause clause) throws ComponentException, PersistencyException - { - ProgettoHome progettohome = (ProgettoHome)getHome(userContext, ProgettoBulk.class,"V_PROGETTO_PADRE"); - SQLBuilder sql = progettohome.createSQLBuilder(); - sql.addClause( clause ); - sql.addSQLClause("AND", "PG_PROGETTO_PADRE", sql.ISNULL,null); - // Se uo 999.000 in scrivania: visualizza tutti i progetti - Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHome( userContext, Unita_organizzativa_enteBulk.class).findAll().get(0); - if (!((CNRUserContext) userContext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa())){ - sql.addSQLExistsClause("AND",progettohome.abilitazioniProgetti(userContext)); - } - return sql; - } - public SQLBuilder selectDipartimentoForPrintByClause (UserContext userContext, - Stampa_pdg_etr_speVBulk stampa, DipartimentoBulk dipartimento, CompoundFindClause clause) throws ComponentException, PersistencyException - { - SQLBuilder sql = getHome(userContext, dipartimento.getClass()).createSQLBuilder(); - java.sql.Timestamp lastDayOfYear = it.cnr.contab.doccont00.comp.DateServices.getLastDayOfYear(CNRUserContext.getEsercizio(userContext)); - sql.addClause("AND", "dt_istituzione", sql.LESS, lastDayOfYear); - sql.openParenthesis("AND"); - sql.addClause("AND", "dt_soppressione", sql.GREATER_EQUALS, lastDayOfYear); - sql.addClause("OR","dt_soppressione",sql.ISNULL,null); - sql.closeParenthesis(); - sql.addClause( clause ); - return sql; - } - public SQLBuilder selectDipartimentoByClause (UserContext userContext, Stampa_rendiconto_finanziarioVBulk stampa, DipartimentoBulk dipartimento, CompoundFindClause clause) throws ComponentException, PersistencyException{ - SQLBuilder sql = getHome(userContext, dipartimento.getClass()).createSQLBuilder(); - java.sql.Timestamp lastDayOfYear = it.cnr.contab.doccont00.comp.DateServices.getLastDayOfYear(CNRUserContext.getEsercizio(userContext)); - sql.addClause("AND", "dt_istituzione", sql.LESS, lastDayOfYear); - sql.openParenthesis("AND"); - sql.addClause("AND", "dt_soppressione", sql.GREATER_EQUALS, lastDayOfYear); - sql.addClause("OR","dt_soppressione",sql.ISNULL,null); - sql.closeParenthesis(); - sql.addClause( clause ); - return sql; - } - public SQLBuilder selectCdsByClause (UserContext userContext,Stampa_rendiconto_finanziarioVBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException{ - SQLBuilder sql = getHome(userContext, cds.getClass(), "V_CDS_VALIDO").createSQLBuilder(); - sql.addClause( clause ); - sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); - return sql; - } - - /** - * Normale - * PreCondition: - * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente - * PostCondition: - * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato - */ -// ^^@@ - public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, - Stampa_vpg_bilancio_riclassVBulk stampa, it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException - { - if (clause == null) clause = uo.buildFindClauses(null); - - SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdsForPrint().getCd_unita_organizzativa()); - - if (clause != null) sql.addClause(clause); - return sql; - } - public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, - Stampa_pdg_etr_speVBulk stampa, it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException - { - if (clause == null) clause = uo.buildFindClauses(null); - - SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdsForPrint().getCd_unita_organizzativa()); - - if (clause != null) sql.addClause(clause); - return sql; - } - public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, - Stampa_libro_giornaleBulk stampa, it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException - { - if (clause == null) clause = uo.buildFindClauses(null); - - SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdsForPrint().getCd_unita_organizzativa()); - - if (clause != null) sql.addClause(clause); - return sql; - } - - public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, - Stampa_situazione_analitica_x_GAEBulk stampa, Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException - { - String cd_cds_scrivania = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); - it.cnr.contab.config00.sto.bulk.CdsHome cds_home = (CdsHome)getHome(userContext, CdsBulk.class); - it.cnr.contab.config00.sto.bulk.CdsBulk cds_scrivania = (CdsBulk)cds_home.findByPrimaryKey(new CdsBulk(cd_cds_scrivania)); - -// if (!cds_scrivania.getCd_tipo_unita().equals(Tipo_unita_organizzativaHome.TIPO_UO_ENTE)){ - if (clause == null) clause = uo.buildFindClauses(null); - - SQLBuilder sql = ((Unita_organizzativaHome) getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA")).createSQLBuilderEsteso(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdCdsForPrint()); - - if (clause != null) sql.addClause(clause); - return sql; - /* } - else { - if(stampa.getCdCdsForPrint().equals(cd_cds_scrivania)){ - if (clause == null) clause = uo.buildFindClauses(null); - - SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - - if (clause != null) sql.addClause(clause); - return sql; - } - else { - if (clause == null) clause = uo.buildFindClauses(null); - - SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdCdsForPrint()); - - if (clause != null) sql.addClause(clause); - return sql; - } - }*/ - - } - - public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException { - String cd_cds_scrivania = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); - it.cnr.contab.config00.sto.bulk.CdsHome cds_home = (CdsHome)getHome(userContext, CdsBulk.class); - it.cnr.contab.config00.sto.bulk.CdsBulk cds_scrivania = (CdsBulk)cds_home.findByPrimaryKey(new CdsBulk(cd_cds_scrivania)); - - if (clause == null) - clause = uo.buildFindClauses(null); - - SQLBuilder sql = ((Unita_organizzativaHome) getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA")).createSQLBuilderEsteso(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdCdsForPrint()!=null?stampa.getCdCdsForPrint():"*"); - - if (clause != null) - sql.addClause(clause); - return sql; - } - - public SQLBuilder selectGaeForPrintByClause(UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, it.cnr.contab.config00.latt.bulk.WorkpackageBulk gae, CompoundFindClause clause) throws ComponentException, PersistencyException { - if (clause == null) - clause = ((OggettoBulk)gae).buildFindClauses(null); - - SQLBuilder sql = getHome(userContext,gae, "V_LINEA_ATTIVITA_VALIDA").createSQLBuilder(); - if (clause != null) - sql.addClause(clause); - - sql.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO", SQLBuilder.EQUALS, CNRUserContext.getEsercizio(userContext)); - - if (stampa.getPgProgettoForPrint()!=null) - sql.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.PG_PROGETTO", SQLBuilder.EQUALS, stampa.getPgProgettoForPrint()); - - if (stampa.getCdResponsabileGaeForPrint()!=null) - sql.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.CD_RESPONSABILE_TERZO", SQLBuilder.EQUALS, stampa.getCdResponsabileGaeForPrint()); - - sql.addTableToHeader("V_STRUTTURA_ORGANIZZATIVA"); - sql.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.ESERCIZIO", "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO"); - sql.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.CD_ROOT", "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA"); - - sql.addSQLClause("AND", "V_STRUTTURA_ORGANIZZATIVA.CD_TIPO_LIVELLO", SQLBuilder.EQUALS, V_struttura_organizzativaHome.LIVELLO_CDR); - sql.addSQLClause("AND", "V_STRUTTURA_ORGANIZZATIVA.CD_UNITA_ORGANIZZATIVA", SQLBuilder.EQUALS, stampa.getCdUoForPrint()); - - return sql; - } - - public SQLBuilder selectResponsabileGaeForPrintByClause(UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, TerzoBulk responsabile, CompoundFindClause clause) throws ComponentException, PersistencyException { - if (clause == null) - clause = ((OggettoBulk)responsabile).buildFindClauses(null); - - SQLBuilder sql = getHome(userContext, responsabile).createSQLBuilder(); - if (clause != null) - sql.addClause(clause); - - SQLBuilder sqlExist = getHome(userContext,WorkpackageBulk.class, "V_LINEA_ATTIVITA_VALIDA").createSQLBuilder(); - sqlExist.addSQLJoin("V_LINEA_ATTIVITA_VALIDA.CD_RESPONSABILE_TERZO", "TERZO.CD_TERZO"); - sqlExist.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO", SQLBuilder.EQUALS, CNRUserContext.getEsercizio(userContext)); - - if (stampa.getPgProgettoForPrint()!=null) - sqlExist.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.PG_PROGETTO", SQLBuilder.EQUALS, stampa.getPgProgettoForPrint()); - - if (stampa.getCdGaeForPrint()!=null) - sqlExist.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.CD_LINEA_ATTIVITA", SQLBuilder.EQUALS, stampa.getCdGaeForPrint()); - - sqlExist.addTableToHeader("V_STRUTTURA_ORGANIZZATIVA"); - sqlExist.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.ESERCIZIO", "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO"); - sqlExist.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.CD_ROOT", "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA"); - - sqlExist.addSQLClause("AND", "V_STRUTTURA_ORGANIZZATIVA.CD_TIPO_LIVELLO", SQLBuilder.EQUALS, V_struttura_organizzativaHome.LIVELLO_CDR); - sqlExist.addSQLClause("AND", "V_STRUTTURA_ORGANIZZATIVA.CD_UNITA_ORGANIZZATIVA", SQLBuilder.EQUALS, stampa.getCdUoForPrint()); - - sql.addSQLExistsClause("AND",sqlExist); - - return sql; - } - -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente - * PostCondition: - * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato - */ -//^^@@ -public SQLBuilder selectCdrForPrintByClause (UserContext userContext, - Stampa_analitica_entrate_ldaBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException -{ - SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); - if(clause != null) - aSQL.addClause(clause); - return aSQL; -} - -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente - * PostCondition: - * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato - */ -//^^@@ -public SQLBuilder selectCdrForPrintByClause (UserContext userContext, - Stampa_analitica_spese_ldaBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException -{ - SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); - if(clause != null) - aSQL.addClause(clause); - return aSQL; -} - -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente - * PostCondition: - * Viene restituito una query sui cdr con le clausole specificate e una clausolOrdineAcqComponentOrdineAcqComponenta sull'esercizio uguale a quello del pdg specificato - */ -//^^@@ -public SQLBuilder selectCdrForPrintByClause (UserContext userContext, - Stampa_sintetica_entrate_ldaBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException -{ - SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); - if(clause != null) - aSQL.addClause(clause); - return aSQL; -} - -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente - * PostCondition: - * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato - */ -//^^@@ -public SQLBuilder selectCdrForPrintByClause (UserContext userContext, - Stampa_sintetica_spese_ldaBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException -{ - SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); - if(clause != null) - aSQL.addClause(clause); - return aSQL; -} - -public SQLBuilder selectCdrForPrintByClause (UserContext userContext, Stampa_situazione_analitica_x_GAEBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException - { - SQLBuilder aSQL = (listaCdrPdGPerUtenteIncludeEnte (userContext)); - if(clause != null) - aSQL.addClause(clause); - aSQL.addSQLClause("AND","CD_UNITA_ORGANIZZATIVA",SQLBuilder.EQUALS,stampa.getCdUoForPrint()); - return aSQL; - } - -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente - * PostCondition: - * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato - */ -//^^@@ -public SQLBuilder selectCdsByClause (UserContext userContext, - StampaRendFinCNRVBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException -{ - it.cnr.contab.config00.sto.bulk.CdsHome home = (it.cnr.contab.config00.sto.bulk.CdsHome)getHome(userContext, it.cnr.contab.config00.sto.bulk.CdsBulk.class); - - SQLBuilder sql = home.createSQLBuilder(); - sql.addClause(clause); - - return sql; -} -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente - * PostCondition: - * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato - */ -//^^@@ - - public SQLBuilder selectCentro_responsabilitaByClause (UserContext userContext, - Pdg_preventivoBulk pdg, - CdrBulk cdr, - CompoundFindClause clause) - throws ComponentException, PersistencyException - { - SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); - if(clause != null) - aSQL.addClause(clause); - return aSQL; - } - -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco degli elementi voce compatibili per il dettaglio di entrata specificato con un elenco di clausole specificate - * PostCondition: - * Viene restituita una query sulla vista V_ELEMENTO_VOCE_PDG_ETR che contiene le clausole specificate più la clausola CD_NATURA = dettaglioSpesa.cd_natura - * Se il CDR non appartiene alla SAC, viene imposta l'ulteriore condizione che la voce del piano non sia riservata SAC - */ - -public SQLBuilder selectElemento_voceByClause(UserContext userContext, - Pdg_preventivo_etr_detBulk dettaglioEntrata, - Elemento_voceBulk elementoVoce, - CompoundFindClause clause) -throws ComponentException, PersistencyException -{ - if (clause == null) clause = ((OggettoBulk)elementoVoce).buildFindClauses(null); - - SQLBuilder sql = getHome(userContext, elementoVoce,"V_ELEMENTO_VOCE_PDG_ETR").createSQLBuilder(); - if(clause != null) sql.addClause(clause); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - - sql.openParenthesis("AND"); - sql.addSQLClause("OR", "FL_PARTITA_GIRO", sql.ISNULL, null); - sql.addSQLClause("OR", "FL_PARTITA_GIRO", sql.EQUALS, "N"); - sql.closeParenthesis(); - - if (dettaglioEntrata.getLinea_attivita() != null) - sql.addSQLClause("AND","CD_NATURA",sql.EQUALS,dettaglioEntrata.getLinea_attivita().getCd_natura()); - if (!dettaglioEntrata.getCentro_responsabilita().getUnita_padre().getCd_tipo_unita().equals(it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC)) - sql.addSQLClause("AND","FL_VOCE_SAC",sql.EQUALS,"N"); - if (dettaglioEntrata.getClassificazione_entrate() != null) { - if (dettaglioEntrata.getClassificazione_entrate().getEsercizio() != null) - sql.addSQLClause("AND","ESERCIZIO_CLA_E",sql.EQUALS,dettaglioEntrata.getClassificazione_entrate().getEsercizio()); - if (dettaglioEntrata.getClassificazione_entrate().getCodice_cla_e() != null) - sql.addSQLClause("AND","COD_CLA_E",sql.EQUALS,dettaglioEntrata.getClassificazione_entrate().getCodice_cla_e()); - } - - if (clause != null) sql.addClause(clause); - - return sql; -} - -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco degli elementi voce compatibili per il dettaglio di spesa specificato con un elenco di clausole specificate - * PostCondition: - * Viene restituita una query sulla vista V_ELEMENTO_VOCE_PDG_SPE che contiene le clausole specificate più la clausola CD_FUNZIONE = dettaglioSpesa.cd_funzione, CD_TIPO_UNITA = dettaglioSpesa.getCentro_responsabilita().getUnita_padre().getCd_tipo_unita() - */ -//^^@@ - - public SQLBuilder selectElemento_voceByClause(UserContext userContext, - Pdg_preventivo_spe_detBulk dettaglioSpesa, - Elemento_voceBulk elementoVoce, - CompoundFindClause clause) - throws ComponentException, PersistencyException - { - if (clause == null) clause = ((OggettoBulk)elementoVoce).buildFindClauses(null); - - SQLBuilder sql = getHome(userContext, elementoVoce,"V_ELEMENTO_VOCE_PDG_SPE").createSQLBuilder(); - if(clause != null) sql.addClause(clause); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - - sql.openParenthesis("AND"); - sql.addSQLClause("OR", "FL_PARTITA_GIRO", sql.ISNULL, null); - sql.addSQLClause("OR", "FL_PARTITA_GIRO", sql.EQUALS, "N"); - sql.closeParenthesis(); - - if (dettaglioSpesa.getLinea_attivita() != null) - sql.addSQLClause("AND","CD_FUNZIONE",sql.EQUALS,dettaglioSpesa.getLinea_attivita().getCd_funzione()); - if ((dettaglioSpesa.getCategoria_economica_finanziaria() != null) && (dettaglioSpesa.getCategoria_economica_finanziaria().getCd_capoconto_fin() != null)) - sql.addSQLClause("AND","CD_CAPOCONTO_FIN",sql.EQUALS,dettaglioSpesa.getCategoria_economica_finanziaria().getCd_capoconto_fin()); - if (dettaglioSpesa.getCentro_responsabilita() != null) - sql.addSQLClause("AND","CD_TIPO_UNITA",sql.EQUALS,dettaglioSpesa.getCentro_responsabilita().getUnita_padre().getCd_tipo_unita()); - if (dettaglioSpesa.getClassificazione_spese() != null) { - if (dettaglioSpesa.getClassificazione_spese().getEsercizio() != null) - sql.addSQLClause("AND","ESERCIZIO_CLA_S",sql.EQUALS,dettaglioSpesa.getClassificazione_spese().getEsercizio()); - if (dettaglioSpesa.getClassificazione_spese().getCodice_cla_s() != null) - sql.addSQLClause("AND","COD_CLA_S",sql.EQUALS,dettaglioSpesa.getClassificazione_spese().getCodice_cla_s()); - } - - if (clause != null) sql.addClause(clause); - - return sql; - } - - public SQLBuilder selectClassificazione_speseByClause(UserContext userContext, - Pdg_preventivo_spe_detBulk dettaglioSpesa, - Classificazione_speseBulk classificazione_spese, - CompoundFindClause clause) - throws ComponentException, PersistencyException - { - Classificazione_speseHome home = (Classificazione_speseHome)getHome(userContext, Classificazione_speseBulk.class); - SQLBuilder sql = home.createSQLBuilder(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); - if(clause != null) - sql.addClause(clause); - - return sql; - } - -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco delle linee di attività utilizzabili dal metodo delDetByLA - * PostCondition: - * Viene restituita una query sulla vista V_LINEA_ATTIVITA_VALIDA per il cdr del pdg specificato. - */ -//^^@@ - public SQLBuilder selectLinea_attivita_eliminazioneByClause(UserContext userContext, - Pdg_preventivoBulk pdg, - it.cnr.contab.config00.latt.bulk.WorkpackageBulk linea_attivita, - CompoundFindClause clause) - throws ComponentException, PersistencyException - { - if (clause == null) clause = ((OggettoBulk)linea_attivita).buildFindClauses(null); - - SQLBuilder sql = getHome(userContext,linea_attivita, "V_LINEA_ATTIVITA_VALIDA").createSQLBuilder(); - if (clause != null) sql.addClause(clause); - - sql.addClause( - "AND", - "cd_centro_responsabilita", - it.cnr.jada.persistency.sql.SQLBuilder.EQUALS, - pdg.getCd_centro_responsabilita() - ); - sql.addSQLClause( - "AND", - "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO", - it.cnr.jada.persistency.sql.SQLBuilder.EQUALS, - it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext) - ); - - return sql; - } - -//^^@@ -/** - * Normale - * PreCondition: - * Viene richiesto l'elenco delle linee di attività compatibili per un dettaglio di spesa con un elenco di clausole specificate - * PostCondition: - * Viene restituito una query sulle linee di attività con le clausole specificate e - * esercizio = dettaglio_pdg.esercizio - * cdr = dettaglio_pdg.cdr - */ -//^^@@ - - public SQLBuilder selectLinea_attivitaByClause(UserContext userContext, - Pdg_preventivo_detBulk dettaglio_pdg, - it.cnr.contab.config00.latt.bulk.WorkpackageBulk linea_attivita, - CompoundFindClause clause) - throws ComponentException, PersistencyException - { - if (clause == null) clause = ((OggettoBulk)linea_attivita).buildFindClauses(null); - - SQLBuilder sql = getHome(userContext,linea_attivita, "V_LINEA_ATTIVITA_VALIDA").createSQLBuilder(); - if (clause != null) sql.addClause(clause); - - sql.addClause( - "AND", - "cd_centro_responsabilita", - it.cnr.jada.persistency.sql.SQLBuilder.EQUALS, - dettaglio_pdg.getCentro_responsabilita().getCd_centro_responsabilita() - ); - - // Date: 20/02/2002 Filtro sulla sezione delle linee di attività in piano di gestione - if(dettaglio_pdg instanceof Pdg_preventivo_spe_detBulk) { - sql.addClause("AND","ti_gestione",it.cnr.jada.persistency.sql.SQLBuilder.EQUALS,it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk.TI_GESTIONE_SPESE); - } else if(dettaglio_pdg instanceof Pdg_preventivo_etr_detBulk) { - sql.addClause("AND","ti_gestione",it.cnr.jada.persistency.sql.SQLBuilder.EQUALS,it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk.TI_GESTIONE_ENTRATE); - } - else { - throw new it.cnr.jada.comp.ApplicationException("Impossibile determinare la sezione entrata/spesa del GAE"); - } - sql.addSQLClause( - "AND", - "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO", - it.cnr.jada.persistency.sql.SQLBuilder.EQUALS, - it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext) - ); - - return sql; - } - -public OggettoBulk stampaConBulk(UserContext aUC, OggettoBulk bulk) throws it.cnr.jada.comp.ComponentException { - - if (bulk instanceof Stampa_spese_ldaBulk) - validateBulkForPrint(aUC, (Stampa_spese_ldaBulk)bulk); - else if (bulk instanceof Stampa_libro_giornaleBulk) - validateBulkForPrint(aUC, (Stampa_libro_giornaleBulk)bulk); - else if (bulk instanceof Stampa_situazione_analitica_x_GAEBulk) - stampaConBulk(aUC, (Stampa_situazione_analitica_x_GAEBulk)bulk); - return bulk; -} - -public OggettoBulk stampaConBulk(UserContext userContext, Stampa_situazione_analitica_x_GAEBulk stampa) throws ComponentException { - if ( stampa.getCdsForPrint()==null || stampa.getCdsForPrint().getCd_proprio_unita()==null) - throw new ApplicationException( "E' necessario selezionare il CDS"); - return stampa; -} - -private void utenteNonAbilitato() throws it.cnr.jada.comp.ApplicationException { - throw new it.cnr.jada.comp.ApplicationException("Utente non abilitato ad operare sul PDG"); -} -/** - * Validazione dell'oggetto in fase di stampa - * -*/ -private void validateBulkForPrint( it.cnr.jada.UserContext userContext, Stampa_spese_ldaBulk stampa) - throws ComponentException { - - try{ - if (stampa.getEsercizio()==null) - throw new ValidationException("Il campo ESERCIZIO e' obbligatorio"); - if (stampa.getCd_cds()==null) - throw new ValidationException("Il campo CDS e' obbligatorio"); - - //if (!stampa.isCdsUOInScrivania() && stampa.getCdUoForPrint() == null) - //throw new ValidationException("Il campo UNITA ORGANIZZATIVA è obbligatorio"); -//// if (it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC.equalsIgnoreCase(uo.getCd_tipo_unita())){ - - } catch(ValidationException ex) { - throw new it.cnr.jada.comp.ApplicationException(ex); - } -} -/** - * Validazione dell'oggetto in fase di stampa - * -*/ -private void validateBulkForPrint(it.cnr.jada.UserContext userContext,Stampa_libro_giornaleBulk stampa)throws ComponentException { - if (stampa.getCdCdsForPrint().equals("*")) - stampa.setIntestazione("Provvisoria"); - else{ - try { - Chiusura_coepHome home = (Chiusura_coepHome)getHome(userContext,Chiusura_coepBulk.class); - Chiusura_coepBulk chiusura_coep = (Chiusura_coepBulk)home.findByPrimaryKey(new Chiusura_coepBulk(stampa.getCdCdsForPrint(),stampa.getEsercizio())); - if (chiusura_coep != null && chiusura_coep.getStato().equals(Chiusura_coepBulk.STATO_CHIUSO_DEFINITIVAMENTE)) - stampa.setIntestazione("Definitiva"); - else - stampa.setIntestazione("Provvisoria"); - - } catch (PersistencyException e) { - throw new ComponentException(e); - } - } -} -public boolean isUoPrincipale(CNRUserContext userContext) throws ComponentException { - try { - Unita_organizzativaHome uom = (Unita_organizzativaHome)getHome(userContext,Unita_organizzativaBulk.class); - Unita_organizzativaBulk uo = (Unita_organizzativaBulk)uom.findByPrimaryKey(new Unita_organizzativaBulk(userContext.getCd_unita_organizzativa())); - return uo.isUoCds(); - } catch (it.cnr.jada.persistency.PersistencyException pe){ - throw new ComponentException(pe); - } -} -private void validaVariazione(UserContext usercontext, OggettoBulk oggettobulk) throws ComponentException -{ - Pdg_preventivo_detBulk pdg_det = (Pdg_preventivo_detBulk)oggettobulk; - boolean diffZeroSpesa = false; - boolean diffZeroEntrata = false; - if (pdg_det.getPdg_variazione() != null){ - try { - Ass_pdg_variazione_cdrHome testataHome = (Ass_pdg_variazione_cdrHome)getHome(usercontext, Ass_pdg_variazione_cdrBulk.class); - Ass_pdg_variazione_cdrBulk ass_pdg = (Ass_pdg_variazione_cdrBulk)testataHome.findByPrimaryKey(new Ass_pdg_variazione_cdrBulk(pdg_det.getEsercizio(), pdg_det.getPdg_variazione().getPg_variazione_pdg(), - pdg_det.getCentro_responsabilita().getCd_centro_responsabilita()),true); - Pdg_variazioneBulk pdg = (Pdg_variazioneBulk)getHome(usercontext,Pdg_variazioneBulk.class).findByPrimaryKey(new Pdg_variazioneBulk(pdg_det.getEsercizio(), pdg_det.getPdg_variazione().getPg_variazione_pdg()),true); - - if (pdg_det instanceof Pdg_preventivo_etr_detBulk){ - if (ass_pdg.getIm_entrata() != null){ - BigDecimal sommaEntrata = ZERO; - for (java.util.Iterator entrate = testataHome.findDettagliEntrata(ass_pdg).iterator();entrate.hasNext();){ - Pdg_preventivo_etr_detBulk etr_det = (Pdg_preventivo_etr_detBulk)entrate.next(); - sommaEntrata = (sommaEntrata.add( - (etr_det.getIm_ra_rce()).add( - (etr_det.getIm_rc_esr())) - )); - } - if(ass_pdg.getIm_entrata().compareTo(sommaEntrata) < 0 && !pdg.isPropostaProvvisoria()) - throw new ApplicationException("La Somma dei dettagli di entrata ("+new it.cnr.contab.util.EuroFormat().format(sommaEntrata)+")"+ - "\n" + " supera la quota di entrata assegnata di "+ - new it.cnr.contab.util.EuroFormat().format(sommaEntrata.subtract(ass_pdg.getIm_entrata()))); - else if (ass_pdg.getIm_entrata().compareTo(sommaEntrata) == 0) - diffZeroEntrata = true; - } - }else if (pdg_det instanceof Pdg_preventivo_spe_detBulk){ - if (ass_pdg.getIm_spesa() != null){ - BigDecimal sommaSpesa = ZERO; - for (java.util.Iterator spese = testataHome.findDettagliSpesa(ass_pdg).iterator();spese.hasNext();){ - Pdg_preventivo_spe_detBulk spesa_det = (Pdg_preventivo_spe_detBulk)spese.next(); - sommaSpesa = (sommaSpesa.add( - (spesa_det.getIm_ri_ccs_spese_odc()).add( - (spesa_det.getIm_rj_ccs_spese_odc_altra_uo()).add( - (spesa_det.getIm_rk_ccs_spese_ogc()).add( - (spesa_det.getIm_rl_ccs_spese_ogc_altra_uo()).add( - (spesa_det.getIm_rq_ssc_costi_odc()).add( - (spesa_det.getIm_rr_ssc_costi_odc_altra_uo()).add( - (spesa_det.getIm_rs_ssc_costi_ogc()).add( - (spesa_det.getIm_rt_ssc_costi_ogc_altra_uo())))))))) - )); - } - if(ass_pdg.getIm_spesa().compareTo(sommaSpesa) < 0 && !pdg.isPropostaProvvisoria()) - throw new ApplicationException("La Somma dei dettagli di spesa ("+new it.cnr.contab.util.EuroFormat().format(sommaSpesa)+")"+ - "\n" + " supera la quota di spesa assegnata di "+ - new it.cnr.contab.util.EuroFormat().format(sommaSpesa.subtract(ass_pdg.getIm_spesa()))); - else if (ass_pdg.getIm_spesa().compareTo(sommaSpesa) == 0) - diffZeroSpesa = true; - } - } - if(diffZeroSpesa || diffZeroEntrata){ - try { - MessaggioHome messHome = (MessaggioHome)getHome(usercontext,MessaggioBulk.class); - UtenteHome utenteHome = (UtenteHome)getHome(usercontext,UtenteBulk.class); - for (java.util.Iterator i= utenteHome.findUtenteByCDRIncludeFirstLevel(pdg.getCd_centro_responsabilita()).iterator();i.hasNext();){ - UtenteBulk utente = (UtenteBulk)i.next(); - MessaggioBulk messaggio = generaMessaggio(usercontext,utente,pdg,ass_pdg,diffZeroSpesa ? "Spesa":"Entrata"); - super.creaConBulk(usercontext, messaggio); - } - } catch (PersistencyException e) { - throw new ComponentException(e); - } catch (IntrospectionException e) { - throw new ComponentException(e); - } - } - } catch (PersistencyException e) { - throw new ComponentException(e); - } catch (IntrospectionException e) { - throw new ComponentException(e); - } - } -} -private MessaggioBulk generaMessaggio(UserContext userContext, UtenteBulk utente, Pdg_variazioneBulk pdg, Ass_pdg_variazione_cdrBulk ass_pdg, String etr_spe) throws ComponentException, PersistencyException{ - MessaggioHome messHome = (MessaggioHome)getHome(userContext,MessaggioBulk.class); - MessaggioBulk messaggio = new MessaggioBulk(); - java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); - messaggio.setPg_messaggio(new Long(messHome.fetchNextSequenceValue(userContext,"CNRSEQ00_PG_MESSAGGIO").longValue())); - messaggio.setCd_utente(utente.getCd_utente()); - messaggio.setPriorita(new Integer(1)); - messaggio.setDs_messaggio(sdf.format(EJBCommonServices.getServerTimestamp()) + " - È stata raggiunta la quota di "+ etr_spe +" assegnata alla Variazione"); - messaggio.setCorpo("Numero variazione:"+pdg.getPg_variazione_pdg()); - messaggio.setCorpo(messaggio.getCorpo() + "\n" + "Il CdR :"+ass_pdg.getCentro_responsabilita().getCd_ds_cdr()+" ha coperto la quota assegnata."); - messaggio.setSoggetto(messaggio.getDs_messaggio()); - messaggio.setToBeCreated(); - return messaggio; -} - -private boolean isCdsEnte(UserContext userContext) throws ComponentException { - try { - Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHome( userContext, Unita_organizzativa_enteBulk.class).findAll().get(0); - if (((CNRUserContext) userContext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa())) - return true; - else - return false; - } catch(Throwable e) { - throw handleException(e); - } -} - -public SQLBuilder selectCentro_responsabilitaByClause (UserContext userContext, - Stampa_situazione_sintetica_x_progettoBulk stampa, - CdrBulk cdr, - CompoundFindClause clause) throws ComponentException, PersistencyException { - SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); - if(clause != null) - aSQL.addClause(clause); - return aSQL; -} - -public SQLBuilder selectProgettoForPrintByClause (UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, ProgettoBulk progetto, CompoundFindClause clause) throws ComponentException, PersistencyException -{ - ProgettoHome progettohome = (ProgettoHome)getHome(userContext, ProgettoBulk.class,"V_PROGETTO_PADRE"); - SQLBuilder sql = progettohome.createSQLBuilder(); - sql.addClause( clause ); - sql.addSQLClause("AND", "V_PROGETTO_PADRE.ESERCIZIO", sql.EQUALS, CNRUserContext.getEsercizio(userContext)); - sql.addSQLClause("AND", "V_PROGETTO_PADRE.TIPO_FASE", sql.EQUALS, ProgettoBulk.TIPO_FASE_NON_DEFINITA); - sql.addSQLClause("AND", "V_PROGETTO_PADRE.LIVELLO", sql.EQUALS, ProgettoBulk.LIVELLO_PROGETTO_SECONDO); - - if (stampa.getGaeForPrint()!=null && stampa.getGaeForPrint().getPg_progetto()!=null) - sql.addSQLClause("AND", "V_PROGETTO_PADRE.PG_PROGETTO", SQLBuilder.EQUALS, stampa.getGaeForPrint().getPg_progetto()); - - // Se uo 999.000 in scrivania: visualizza tutti i progetti - Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHome( userContext, Unita_organizzativa_enteBulk.class).findAll().get(0); - - SQLBuilder sqlAbilitazioni; - if (!((CNRUserContext) userContext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa())){ - sqlAbilitazioni = progettohome.abilitazioniCommesse(userContext); - if (stampa.getCdUoForPrint()!=null) - sqlAbilitazioni.addSQLClause("AND", "V_ABIL_PROGETTI.CD_UNITA_ORGANIZZATIVA", sql.EQUALS, stampa.getCdUoForPrint()); - } else { - ProgettoHome progettoAbilhome = (ProgettoHome)getHome(userContext, ProgettoBulk.class,"V_ABIL_PROGETTI"); - sqlAbilitazioni = progettoAbilhome.createSQLBuilder(); - sqlAbilitazioni.addSQLJoin("V_ABIL_PROGETTI.ESERCIZIO_COMMESSA","V_PROGETTO_PADRE.ESERCIZIO"); - sqlAbilitazioni.addSQLJoin("V_ABIL_PROGETTI.PG_COMMESSA","V_PROGETTO_PADRE.PG_PROGETTO"); - sqlAbilitazioni.addSQLJoin("V_ABIL_PROGETTI.TIPO_FASE_COMMESSA","V_PROGETTO_PADRE.TIPO_FASE"); - sqlAbilitazioni.addSQLClause("AND","V_ABIL_PROGETTI.CD_UNITA_ORGANIZZATIVA",SQLBuilder.EQUALS,stampa.getCdUoForPrint()); - - } - sql.addSQLExistsClause("AND",sqlAbilitazioni); - - return sql; -} - -private void inizializzaBulkPerStampa(UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa) throws ComponentException { - stampa.setEsercizio(it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); - try{ - String cdCds = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); - String cdUo = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_unita_organizzativa(userContext); - - CdsHome cdsHome = (CdsHome)getHome(userContext, CdsBulk.class); - CdsBulk cds = (CdsBulk)cdsHome.findByPrimaryKey(new CdsBulk(cdCds)); - Unita_organizzativaBulk uo = (Unita_organizzativaBulk) getHome( userContext, Unita_organizzativaBulk.class).findByPrimaryKey(new Unita_organizzativaBulk(cdUo)); - Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHome( userContext, Unita_organizzativa_enteBulk.class).findAll().get(0); - - stampa.setCdsForPrintEnabled(true); - stampa.setUoForPrintEnabled(true); - stampa.setProgettoForPrintEnabled(true); - stampa.setGaeForPrintEnabled(true); - stampa.setTi_ordine_stampa(Stampa_situazione_sintetica_x_progettoBulk.TI_ORDINE_GAE_VOCE_ANNO); - - if (!Tipo_unita_organizzativaHome.TIPO_UO_ENTE.equals(uo.getCd_tipo_unita())){ - stampa.setCdsForPrint(cds); - stampa.setCdsForPrintEnabled(false); - if (!uo.getFl_uo_cds().equals(Boolean.TRUE)) { - stampa.setUoForPrint(uo); - stampa.setUoForPrintEnabled(false); - } - } - } catch (it.cnr.jada.persistency.PersistencyException pe){ - throw new ComponentException(pe); - } -} +/* + * Copyright (C) 2019 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package it.cnr.contab.pdg00.comp; +import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; +import it.cnr.contab.utenze00.bulk.*; +import it.cnr.contab.messaggio00.bulk.MessaggioBulk; +import it.cnr.contab.messaggio00.bulk.MessaggioHome; +import it.cnr.contab.prevent00.bulk.Pdg_aggregatoBulk; +import it.cnr.contab.prevent00.bulk.Bilancio_preventivoBulk; +import it.cnr.contab.anagraf00.core.bulk.TerzoBulk; +import it.cnr.contab.coepcoan00.core.bulk.Chiusura_coepBulk; +import it.cnr.contab.coepcoan00.core.bulk.Chiusura_coepHome; +import it.cnr.contab.config00.sto.bulk.CdsBulk; +import it.cnr.contab.config00.sto.bulk.CdsHome; +import it.cnr.contab.config00.sto.bulk.DipartimentoBulk; +import it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome; +import it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk; +import it.cnr.contab.config00.sto.bulk.Unita_organizzativa_enteBulk; +import it.cnr.contab.config00.sto.bulk.V_struttura_organizzativaBulk; +import it.cnr.contab.config00.sto.bulk.V_struttura_organizzativaHome; +import it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession; +import it.cnr.contab.config00.latt.bulk.WorkpackageBulk; +import it.cnr.contab.config00.pdcfin.bulk.*; +import it.cnr.contab.config00.sto.bulk.CdrBulk; +import it.cnr.contab.pdg00.bulk.*; +import it.cnr.contab.pdg00.cdip.bulk.Ass_pdg_variazione_cdrBulk; +import it.cnr.contab.pdg00.cdip.bulk.Ass_pdg_variazione_cdrHome; +import it.cnr.contab.pdg00.cdip.bulk.Stampa_rendiconto_finanziarioVBulk; +import it.cnr.contab.prevent00.bulk.Pdg_aggregato_etr_detBulk; +import it.cnr.contab.prevent00.bulk.Pdg_aggregato_spe_detBulk; +import it.cnr.contab.progettiric00.core.bulk.ProgettoBulk; +import it.cnr.contab.progettiric00.core.bulk.ProgettoHome; + +import it.cnr.contab.utenze00.bp.CNRUserContext; +import it.cnr.contab.utenze00.bulk.UtenteHome; +import it.cnr.contab.config00.sto.bulk.Unita_organizzativaHome; +import it.cnr.jada.UserContext; +import it.cnr.jada.bulk.*; +import it.cnr.jada.comp.ApplicationException; +import it.cnr.jada.comp.ComponentException; +import it.cnr.jada.comp.IPrintMgr; +import it.cnr.jada.persistency.IntrospectionException; +import it.cnr.jada.persistency.PersistencyException; +import it.cnr.jada.persistency.sql.*; +import it.cnr.jada.util.ejb.EJBCommonServices; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.PreparedStatement; +import java.util.Optional; +import java.util.Vector; + + +public class PdGPreventivoComponent extends PdGComponent implements it.cnr.jada.comp.ICRUDMgr, IPdGPreventivoTestataMgr, IPdGPreventivoDettagliMgr, IPrintMgr, Cloneable,Serializable { + + private static final java.math.BigDecimal ZERO = new java.math.BigDecimal(0); + + + + public PdGPreventivoComponent() + { + + /*Default constructor*/ + + + } +//^^@@ +/** + * default + * PreCondition: + * Viene richiesto l'annullamento dello scarico dei costi del dipendente per un pdg + * PostCondition: + * Viene invocata la stored procedure ORACLEannullaCDPSuPdg + */ +//^^@@ + public Pdg_preventivoBulk annullaCDPSuPdg(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ApplicationException, it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB060.annullaCDPSuPdg(?,?,?)}",false,this.getClass()); + cs.setObject( 1, pdg.getEsercizio() ); + cs.setString( 2, pdg.getCd_centro_responsabilita()); + cs.setObject( 3, userContext.getUser()); + try { + lockBulk(userContext,pdg); + cs.executeQuery(); + return caricaPdg(userContext,pdg.getCentro_responsabilita()); + } catch (Throwable e) { + throw handleException(pdg,e); + } finally { + cs.close(); + } + } catch (java.sql.SQLException e) { + throw handleSQLException(e); + } + } + +/** + * Utente AC + * PreCondition: + * l'utente appartiene al CDR Amministrazione Centrale + * PostCondition: + * Viene restituito un istanza di Pdg_preventivoBulk per il CDR 00 dell UO CDS SAC e l'elenco di tutti i CDR che possiedono PDG + * Tutti i controlli superati + * PreCondition: + * Nessun'altra precondizione verificata + * PostCondition: + * Viene restituito un'istanza di Pdg_preventivoBulk che per il CDR specificato più l'elenco dei CDR con livello di responsabilià inferiore al CDR specificato (listaCdrPdGPerUtente) + * Utente associato a CDR senza PDG + * PreCondition: + * Il cdr dell'utente non possiede un PDG + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il CdR non ha un piano di gestione associato!" + */ + +public Pdg_preventivoBulk caricaPdg (UserContext userContext,CdrBulk cdr) throws ComponentException { + try { + + if(cdr == null) + cdr = cdrFromUserContext(userContext); + int livelloResponsabilita = getLivelloResponsabilitaCDR(userContext, cdr); + + if(livelloResponsabilita == LV_AC) + cdr = ((it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext,CdrBulk.class)).findCdrSAC(it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + + Pdg_preventivoBulk preventivo = new Pdg_preventivoBulk(); + +// preventivo.setCentro_responsabilita(new CdrBulk()); + + preventivo.setCentro_responsabilita(cdr); + +// preventivo.getCentro_responsabilita().setCd_centro_responsabilita(cdr.getCd_centro_responsabilita()); + preventivo.setEsercizio( + ((it.cnr.contab.utenze00.bp.CNRUserContext)userContext).getEsercizio() + ); + + try { + preventivo = (Pdg_preventivoBulk)getHome(userContext,preventivo).findByPrimaryKey(preventivo); + } catch (it.cnr.jada.persistency.PersistencyException e) { + throw new it.cnr.jada.comp.ComponentException(e); + } + + if (preventivo == null) + throw new it.cnr.jada.comp.ApplicationException("Piano di gestione non ancora aperto."); + + preventivo.setStatiKeys(loadStatiKeys(userContext, preventivo)); + +// preventivo.setElencoCdR(listaCdrPdGPerUtente(userContext)); + + getHomeCache(userContext).fetchAll(userContext); + + return preventivo; + } catch(PersistencyException e) { + throw handleException(e); + } +} + +/** + * Controllo di chiusura del pdg aggregato + * PreCondition: + * L'invocazione della stored procedure CNRCTB050.checkAggregatoChiuso ritorna 'Y' + * PostCondition: + * Lascia uscire true + * Tutti i controlli superati + * PreCondition: + * L'invocazione della stored procedure CNRCTB050.checkAggregatoChiuso ritorna 'N' + * PostCondition: + * Ritorna un'eccezione + */ +private void controllaAggregatoChiuso(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB050.checkAggregatoChiuso(?,?)}",false,this.getClass()); + try { + cs.registerOutParameter( 1, java.sql.Types.CHAR ); + cs.setObject( 2, pdg.getEsercizio() ); + cs.setString( 3, pdg.getCd_centro_responsabilita()); + cs.execute(); + if (cs.getString(1).equals("N")) + throw new it.cnr.jada.comp.ApplicationException("Il piano di gestione aggregato non è chiuso. Contattare il CDR di primo livello"); + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} + +private void controllaAggregatoPdgDetPositivo(UserContext userContext, Pdg_preventivoBulk pdg,Pdg_preventivo_detBulk pdg_dett) throws it.cnr.jada.comp.ComponentException { + if (pdg_dett instanceof Pdg_preventivo_etr_detBulk) + controllaAggregatoPdgEtrDetPositivo(userContext,pdg,(Pdg_preventivo_etr_detBulk)pdg_dett); + else if (pdg_dett instanceof Pdg_preventivo_spe_detBulk) + controllaAggregatoPdgSpeDetPositivo(userContext,pdg,(Pdg_preventivo_spe_detBulk)pdg_dett); +} + +private void controllaAggregatoPdgEtrDetPositivo(UserContext userContext, Pdg_preventivoBulk pdg,Pdg_preventivo_etr_detBulk pdg_det) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB075.checkAggrPdgEtrDetPositivo(?, ?, ?, ?, ?, ?, ?, ? )}",false,this.getClass()); + try { + cs.setInt( 1, pdg_det.getEsercizio().intValue() ); + cs.setString( 2, pdg_det.getCd_centro_responsabilita()); + cs.setString( 3, pdg_det.getCd_linea_attivita()); + cs.setString( 4, pdg_det.getTi_appartenenza()); + cs.setString( 5, pdg_det.getTi_gestione()); + cs.setString( 6, pdg_det.getCd_elemento_voce()); + cs.registerOutParameter( 7, java.sql.Types.VARCHAR ); + cs.registerOutParameter( 8, java.sql.Types.DECIMAL); + cs.execute(); + String columnName = cs.getString(7); + if (columnName != null) { + String columnDescription = columnName; + java.math.BigDecimal importo = cs.getBigDecimal(8); + ColumnMapping mapping = getHome(userContext,pdg_det).getColumnMap().getMappingForColumn(columnName); + if (mapping != null) { + FieldProperty property = BulkInfo.getBulkInfo(pdg_det.getClass()).getFieldProperty(mapping.getPropertyName()); + if (property != null) + columnDescription = property.getLabel(); + } + throw new it.cnr.jada.comp.ApplicationException("Si sta tentando di inserire un dettaglio con importi negativi sulla colonna "+columnDescription+", ma il totale per GAE e voce del piano è negativo ("+new it.cnr.contab.util.EuroFormat().format(importo)+")."); + } + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} + +private void controllaAggregatoPdgSpeDetPositivo(UserContext userContext, Pdg_preventivoBulk pdg,Pdg_preventivo_spe_detBulk pdg_det) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs =new LoggableStatement( getConnection( userContext ),"{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB075.checkAggrPdgSpeDetPositivo(?, ?, ?, ?, ?, ?, ?, ?, ? )}",false,this.getClass()); + try { + cs.setInt( 1, pdg_det.getEsercizio().intValue() ); + cs.setString( 2, pdg_det.getCd_centro_responsabilita()); + cs.setString( 3, pdg_det.getCd_linea_attivita()); + cs.setString( 4, pdg_det.getTi_appartenenza()); + cs.setString( 5, pdg_det.getTi_gestione()); + cs.setString( 6, pdg_det.getCd_elemento_voce()); + cs.setLong( 7, pdg_det.getPg_spesa().longValue()); + cs.registerOutParameter( 8, java.sql.Types.VARCHAR ); + cs.registerOutParameter( 9, java.sql.Types.DECIMAL); + cs.execute(); + String columnName = cs.getString(8); + if (columnName != null) { + String columnDescription = columnName; + java.math.BigDecimal importo = cs.getBigDecimal(9); + ColumnMapping mapping = getHome(userContext,pdg_det).getColumnMap().getMappingForColumn(columnName); + if (mapping != null) { + FieldProperty property = BulkInfo.getBulkInfo(pdg_det.getClass()).getFieldProperty(mapping.getPropertyName()); + if (property != null) + columnDescription = property.getLabel(); + } + throw new it.cnr.jada.comp.ApplicationException("Si sta tentando di inserire un dettaglio con importi negativi sulla colonna "+columnDescription+", ma il totale per GAE e voce del piano è negativo ("+new it.cnr.contab.util.EuroFormat().format(importo)+")."); + } + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} + +private void controllaBilancioPreventivoCdsApprovato(UserContext userContext,CdrBulk cdr) throws ComponentException { + try { + Unita_organizzativaBulk uo = (Unita_organizzativaBulk)getHome(userContext,Unita_organizzativaBulk.class).findByPrimaryKey(cdr.getUnita_padre()); + Bilancio_preventivoBulk bilancio = (Bilancio_preventivoBulk)getHome(userContext,Bilancio_preventivoBulk.class).findByPrimaryKey(new Bilancio_preventivoBulk( + uo.getCd_unita_padre(), + it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), + Elemento_voceHome.APPARTENENZA_CDS)); + if (bilancio == null) + throw new it.cnr.jada.comp.ApplicationException("Bilancio preventivo inesistente per il cds "+uo.getCd_unita_padre()); + if (!bilancio.STATO_C.equalsIgnoreCase(bilancio.getStato())) + throw new it.cnr.jada.comp.ApplicationException("Il bilancio preventivo del cds "+uo.getCd_unita_padre()+" deve essere approvato per riaprire il pdg per variazioni"); + } catch(Throwable e) { + throw handleException(e); + } +} +/** + * Verifica che il bilancio preventivo CNR sia approvato + * PreCondition: + * L'invocazione della stored procedure CNRCTB054.isBilancioCNRApprovato ritorna 'N' + * PostCondition: + * Viene segnalato con un'eccezione che il bilancio preventivo CNR non è approvato + * Tutti i controlli superati + * PreCondition: + * L'invocazione della stored procedure CNRCTB054.isBilancioCNRApprovato ritorna 'Y' + * PostCondition: + * Esce senza alcuna eccezione + */ +private void controllaBilPrevCnrApprovato(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB054.isBilancioCNRApprovato(?)}",false,this.getClass()); + try { + cs.registerOutParameter( 1, java.sql.Types.CHAR ); + cs.setObject( 2, pdg.getEsercizio() ); + cs.execute(); + if (cs.getString(1).equals("N")) + throw new it.cnr.jada.comp.ApplicationException("Il bilancio preventivo CNR non risulta ancora approvato"); + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} +/** + * Verifica che tutti i dettagli scaricati verso altra uo o cdr siano stati confermati + * PreCondition: + * L'invocazione della stored procedure CNRCTB050.checkDettScarConfermati ritorna 'N' + * PostCondition: + * Solleva un'eccezione + * Tutti i controlli superati + * PreCondition: + * L'invocazione della stored procedure CNRCTB050.checkDettScarConfermati ritorna 'Y' + * PostCondition: + * Esce senza segnalazioni + */ +private void controllaDettScarConfermati(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB050.checkDettScarConfermati(?,?)}",false,this.getClass()); + try { + cs.registerOutParameter( 1, java.sql.Types.CHAR ); + cs.setObject( 2, pdg.getEsercizio() ); + cs.setString( 3, pdg.getCd_centro_responsabilita()); + cs.execute(); + if (cs.getString(1).equals("N")) + throw new it.cnr.jada.comp.ApplicationException("Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata"); + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} +/** + * Pdg aggregato contiene discrepanze + * PreCondition: + * Le viste V_DPDG_AGGREGATO_ETR_DET_D e V_DPDG_AGGREGATO_SPE_DET_D contengono almeno un record + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Sono presenti importi complessivi non compatibili con i dati impostati dall'ente." + * Tuttti i controlli superati + * PreCondition: + * Nessun'altra precondizione è verificata + * PostCondition: + * Esce senza alcuna eccezione + */ +private void controllaDiscrepanzeAggregato(UserContext userContext,Pdg_preventivoBulk pdg,int livelloResponsabilita) throws ComponentException { + // Controllo della presenza di discrepanze nell'aggregato; va fatto solo per cdr di 1° livello e per le aree + if (livelloResponsabilita == 1 || + isCdrArea(userContext,pdg.getCentro_responsabilita())) { + + controllaDiscrepanzeAggregato(userContext,pdg,Pdg_aggregato_etr_detBulk.class,"V_DPDG_AGGREGATO_ETR_DET_D"); + controllaDiscrepanzeAggregato(userContext,pdg,Pdg_aggregato_spe_detBulk.class,"V_DPDG_AGGREGATO_SPE_DET_D"); + } +} +private void controllaDiscrepanzeAggregato(UserContext userContext,Pdg_preventivoBulk pdg,Class dettagliClass,String vista) throws ComponentException { + try { + PersistentHome home = getHome(userContext,dettagliClass,vista); + it.cnr.jada.persistency.sql.SQLBuilder sql = home.createSQLBuilder(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, pdg.getEsercizio()); + sql.addSQLClause("AND", "CD_CENTRO_RESPONSABILITA", sql.EQUALS, pdg.getCd_centro_responsabilita()); + + if (sql.executeExistsQuery(getConnection(userContext))) + throw new it.cnr.jada.comp.ApplicationException("Sono presenti importi complessivi non compatibili con i dati impostati dall'ente."); + } catch(Throwable e) { + throw handleException(e); + } +} +public boolean controllaDiscrepanzeAggregatoForCons(UserContext userContext,OggettoBulk obj, String vista) throws ComponentException { + try { + Pdg_preventivoBulk pdg = (Pdg_preventivoBulk)obj; + PersistentHome home = null; + if (vista.equals("ETR")) + home = getHome(userContext,it.cnr.contab.pdg00.consultazioni.bulk.V_dpdg_aggregato_etr_det_dBulk.class); + else if (vista.equals("SPE")) + home = getHome(userContext,it.cnr.contab.pdg00.consultazioni.bulk.V_dpdg_aggregato_spe_det_dBulk.class); + else + return false; + it.cnr.jada.persistency.sql.SQLBuilder sql = home.createSQLBuilder(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, pdg.getEsercizio()); + sql.addSQLClause("AND", "CD_CENTRO_RESPONSABILITA", sql.EQUALS, pdg.getCd_centro_responsabilita()); + return sql.executeExistsQuery(getConnection(userContext)); + } catch(Throwable e) { + throw handleException(e); + } +} +/** + * Pdg aggregato contiene discrepanze + * PreCondition: + * Le viste V_DPDG_AGGREGATO_ETR_DET_D e V_DPDG_AGGREGATO_SPE_DET_D contengono almeno un record + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Sono presenti importi complessivi non compatibili con i dati impostati dall'ente." + * Tuttti i controlli superati + * PreCondition: + * Nessun'altra precondizione è verificata + * PostCondition: + * Esce senza alcuna eccezione + */ +private void controllaDiscrepanzeAggregatoPerVariazioni(UserContext userContext,Pdg_preventivoBulk pdg,int livelloResponsabilita) throws ComponentException { + // Controllo della presenza di discrepanze nell'aggregato; va fatto solo per cdr di 1° livello e per le aree + if (livelloResponsabilita == 1 || + isCdrArea(userContext,pdg.getCentro_responsabilita())) { + + controllaDiscrepanzeAggregato(userContext,pdg,Pdg_aggregato_etr_detBulk.class,"V_DPDG_AGGREGATO_ETR_DET_D"); + controllaDiscrepanzeAggregato(userContext,pdg,Pdg_aggregato_spe_detBulk.class,"V_DPDG_AGGREGATO_SPE_DET_D"); + } +} +/** + * Quadratura su insieme linee di attività entrata/spesa + * PreCondition: + * L'invocazione della stored procedure CNRCTB050.checkDiscrepanzeInsiemeLa ritorna 'Y' + * PostCondition: + * Lascia uscire true + * Tutti i controlli superati + * PreCondition: + * L'invocazione della stored procedure CNRCTB050.checkDiscrepanzeInsiemeLa ritorna 'N' + * PostCondition: + * Esce ritornando false + */ +private boolean controllaDiscrepanzeInsiemeLa(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs =new LoggableStatement( getConnection( userContext ),"{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB050.check_discrepanze_insieme_la(?,?)}",false,this.getClass()); + try { + cs.registerOutParameter( 1, java.sql.Types.CHAR ); + cs.setObject( 2, pdg.getEsercizio() ); + cs.setString( 3, pdg.getCd_centro_responsabilita()); + cs.execute(); + return !cs.getString(1).equals("N"); + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} + +/** + * Quadratura fallita + * PreCondition: + * L'invocazione della stored procedure CNRCTB050.checkQuadRicFig genera una eccezione + * PostCondition: + * Lascia uscire l'eccezione + * Tutti i controlli superati + * PreCondition: + * L'invocazione della stored procedure CNRCTB050.checkQuadRicFig va a buon fine + * PostCondition: + * Esce senza alcuna eccezione + */ +private void controllaQuadraturaRicaviFigurativi(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB050.checkQuadRicFig(?,?)}",false,this.getClass()); + try { + cs.registerOutParameter( 1, java.sql.Types.CHAR ); + cs.setObject( 2, pdg.getEsercizio() ); + cs.setString( 3, pdg.getCd_centro_responsabilita()); + cs.execute(); + if (cs.getString(1).equals("N")) + throw new it.cnr.jada.comp.ApplicationException("Mancata quadratura dei ricavi figurativi!"); + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} +/** + * Verifica che lo scarico dei costi del dipendente sia completo + * PreCondition: + * L'invocazione della stored procedure CNRCTB060.checkScaricoCDPCompleto genera una eccezione + * PostCondition: + * Lascia uscire l'eccezione + * Tutti i controlli superati + * PreCondition: + * L'invocazione della stored procedure CNRCTB060.checkScaricoCDPCompleto va a buon fine + * PostCondition: + * Esce senza alcuna eccezione + */ +private void controllaScaricoCDPCompleto(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB060.checkScaricoCDPCompleto(?,?)}",false,this.getClass()); + try { + cs.registerOutParameter( 1, java.sql.Types.CHAR ); + cs.setObject( 2, pdg.getEsercizio() ); + cs.setString( 3, pdg.getCd_centro_responsabilita()); + cs.execute(); + if (cs.getString(1).equals("N")) + throw new it.cnr.jada.comp.ApplicationException("Costi del personale non ancora scaricati completamente!"); + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} + +/** + * Verifica che il pdg aggregato sia nello stato specificato + * PreCondition: + * L'invocazione della stored procedure CNRCTB060.checkStatoAggregato ritorna 'N' + * PostCondition: + * Genera una ApplicationException con il messaggio "Per poter eseguire l'operazione richiesta il piano di gestione aggregato dovrebbe essere in stato X ma attualmente si trova in un altro stato." + * Tutti i controlli superati + * PreCondition: + * Nessun'altra precondizione verificata + * PostCondition: + * Esce senza alcuna eccezione + */ +private void controllaStatoAggregato(UserContext userContext, Pdg_preventivoBulk pdg,String stato) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{? = call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB050.checkStatoAggregato(?,?,?)}",false,this.getClass()); + try { + cs.registerOutParameter( 1, java.sql.Types.CHAR ); + cs.setObject( 2, pdg.getEsercizio() ); + cs.setString( 3, pdg.getCd_centro_responsabilita()); + cs.setString( 4, stato); + cs.execute(); + if (cs.getString(1).equals("N")) + throw new it.cnr.jada.comp.ApplicationException("Per poter eseguire l'operazione richiesta il piano di gestione aggregato dovrebbe essere in stato "+stato+" ma attualmente si trova in un altro stato."); + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} + +/** + * Esistono pdg dipendenti in stato diverso da quelli specificati + * PreCondition: + * Esiste almeno un pdg figlio del pdg specificato che si trova in uno stato diverso da quelli specificificati + * PostCondition: + * Genera una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Tutti i controlli superati + * PreCondition: + * Nessun'altra precondizione verificata + * PostCondition: + * Esce senza alcuna eccezione + */ +private boolean controllaStatoPdgFigli(UserContext userContext,Pdg_preventivoBulk pdg,String[] stati) throws ComponentException { + try { + it.cnr.jada.bulk.BulkHome home = getHome(userContext, Pdg_preventivoBulk.class); + it.cnr.jada.persistency.sql.SQLBuilder sql = home.createSQLBuilder(); + sql.addTableToHeader("V_PDG_CDR_FIGLI"); + sql.addSQLJoin("PDG_PREVENTIVO.ESERCIZIO","V_PDG_CDR_FIGLI.ESERCIZIO"); + sql.addSQLJoin("PDG_PREVENTIVO.CD_CENTRO_RESPONSABILITA","V_PDG_CDR_FIGLI.CD_CENTRO_RESPONSABILITA"); + sql.addSQLClause("AND", "V_PDG_CDR_FIGLI.ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + sql.addSQLClause("AND", "V_PDG_CDR_FIGLI.CD_CDR_ROOT", sql.EQUALS, pdg.getCd_centro_responsabilita()); + sql.setForUpdateOf("stato"); + + LoggableStatement stm = sql.prepareStatement(getConnection(userContext)); + try { + java.sql.ResultSet rs = stm.executeQuery(); + try { + while (rs.next()) { + String stato_figlio = rs.getString("STATO"); + boolean trovato = false; + for (int i = 0;!trovato && i < stati.length;i++) + trovato = stati[i].equals(stato_figlio); + + if (!trovato) + throw new it.cnr.jada.comp.ApplicationException("Il pdg del cdr "+rs.getString("CD_CENTRO_RESPONSABILITA")+" è in stato "+stato_figlio+" che non è compatibile con l'operazione richiesta."); + } + } finally { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } finally { + try{stm.close();}catch( java.sql.SQLException e ){}; + } + return true; + } catch(Throwable e) { + throw handleException(e); + } +} + +/** + * Esistono pdg padri in stato diverso da quelli specificati + * PreCondition: + * Esiste almeno un pdg padre del pdg specificato che si trova in uno stato diverso da quelli specificati. + * Se "ricorsivo" è true la ricerca viene fatta su tutti i padri fino all'AC, altrimenti solo sul padre diretto + * PostCondition: + * Genera una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Tutti i controlli superati + * PreCondition: + * Nessun'altra precondizione verificata + * PostCondition: + * Esce senza alcuna eccezione + */ +private boolean controllaStatoPdgPadri(UserContext userContext,Pdg_preventivoBulk pdg,int livelloResponsabilita,boolean ricorsivo,String[] stati) throws ComponentException { + try { + + // Sel il cdr del pdg è di livello 1, o è l'ente o è in un area di ricerca + // non ci sono pdg padri, quindi ritorno true + + if (livelloResponsabilita == LV_CDRI || + livelloResponsabilita == LV_AC || + isCdrArea(userContext,pdg.getCentro_responsabilita())) + return true; + + String cd_cdr = pdg.getCd_centro_responsabilita(); + + do { + + BulkHome home = getHome(userContext, Pdg_preventivoBulk.class, "V_PDG_PDG_PADRE"); + SQLBuilder sql = home.createSQLBuilder(); + + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext )); + sql.addSQLClause("AND", "CD_CDR_ROOT", sql.EQUALS, cd_cdr); + sql.setForUpdateOf("stato"); + + LoggableStatement stm = sql.prepareStatement(getConnection(userContext)); + try { + java.sql.ResultSet rs = stm.executeQuery(); + try { + if (!rs.next()) + return true; + + String stato_padre = rs.getString("STATO"); + cd_cdr = rs.getString("CD_CENTRO_RESPONSABILITA"); + boolean trovato = false; + for (int i = 0;!trovato && i < stati.length;i++) + trovato = stati[i].equals(stato_padre); + + if (!trovato) + throw new it.cnr.jada.comp.ApplicationException("Il pdg del cdr "+cd_cdr+" è in stato "+stato_padre+" che non è compatibile con l'operazione richiesta."); + + } finally { + try{rs.close();}catch( java.sql.SQLException e ){}; + } + } finally { + try{stm.close();}catch( java.sql.SQLException e ){}; + } + } while(ricorsivo); + + return true; + + } catch(Throwable e) { + throw handleException(e); + } +} + +/** + * Imposta gli importi assegnati sul dettaglio di entrata del servente in base + * agli importi valorizzati sul dettaglio di spesa del servito. + * + * @param userContext + * @param servito Chi assegna l'entrata figurativa e sottomette la richiesta di accettazione + * @param servente Chi accetta o meno l'entrata figurativa assegnatagli + */ + + private void copiaImportAltroCDR(UserContext userContext,Pdg_preventivo_spe_detBulk servito,Pdg_preventivo_etr_detBulk servente) throws it.cnr.jada.comp.ComponentException { + + servente.setIm_rb_rse( servito.getIm_rp_css_verso_altro_cdr() ); + + servente.setIm_rd_a2_ricavi( servito.getIm_rab_a2_costi_altro_cdr() ); + + servente.setIm_rf_a3_ricavi( servito.getIm_rai_a3_costi_altro_cdr() ); + + } + +/** + * Imposta gli importi assegnati sul dettaglio di spesa del servente in base + * agli importi valorizzati sul dettaglio di spesa del servito. + * + * @param userContext + * @param servito Chi assegna lo scarico di spesa e sottomette la richiesta di accettazione + * @param servente Chi accetta o meno lo scarico di spesa assegnatagli + */ + + private void copiaImportiAltraUO(UserContext userContext,Pdg_preventivo_spe_detBulk servito,Pdg_preventivo_spe_detBulk servente) throws it.cnr.jada.comp.ComponentException { + if( servito.getIm_rj_ccs_spese_odc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { + servente.setIm_ru_spese_costi_altrui( servito.getIm_rj_ccs_spese_odc_altra_uo() ); + } + + if( servito.getIm_rl_ccs_spese_ogc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { + servente.setIm_ru_spese_costi_altrui( servito.getIm_rl_ccs_spese_ogc_altra_uo() ); + } + + if( servito.getIm_rr_ssc_costi_odc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { + servente.setIm_ru_spese_costi_altrui( servito.getIm_rr_ssc_costi_odc_altra_uo() ); + } + + if( servito.getIm_rt_ssc_costi_ogc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { + servente.setIm_ru_spese_costi_altrui( servito.getIm_rt_ssc_costi_ogc_altra_uo() ); + } + + if( servito.getIm_rad_a2_spese_odc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { + servente.setIm_rag_a2_spese_costi_altrui( servito.getIm_rad_a2_spese_odc_altra_uo() ); + } + + if( servito.getIm_raf_a2_spese_ogc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { + servente.setIm_rag_a2_spese_costi_altrui( servito.getIm_raf_a2_spese_ogc_altra_uo() ); + } + + if( servito.getIm_ram_a3_spese_odc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { + servente.setIm_rap_a3_spese_costi_altrui( servito.getIm_ram_a3_spese_odc_altra_uo() ); + } + + if( servito.getIm_rao_a3_spese_ogc_altra_uo().compareTo(new java.math.BigDecimal(0)) != 0 ) { + servente.setIm_rap_a3_spese_costi_altrui( servito.getIm_rao_a3_spese_ogc_altra_uo() ); + } + } + +/** + * Tutti i controlli superati + * PreCondition: + * Nessun'altra precondizione è verificata + * PostCondition: + * ll dettaglio viene marcato con CATEGORIA 'SIN', FL_SOLA_LETTURA = false e salvato + * spesa relativa altra UO + * PreCondition: + * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD); il PDG del CDR scelto è aperto (stato uguale a A, B, D o E) + * PostCondition: + * Viene creata nel PDG del cdr scelto (servente) un nuovo dettaglio di spesa valorizzazzato come segue: + * dettaglioServente.esercizio = dettaglioServito.esercizio + * dettaglioServente.cdr = cdrServente + * dettaglioServente.appartenenza = dettaglioServito.appartenenza + * dettaglioServente.gestione = dettaglioServito.gestione + * dettaglioServente.voce = dettaglioServito.voce + * dettaglioServente.clgs = dettaglioServito + * dettaglioServente.CATEGORIA = 'CAR' + * dettaglioServente.STATO = 'X' + * dettaglioServente.lineaDiAttivita = Linea_attivitaComponent.creaLineaAttivitaSAUO(cdrServente,dettaglioServito.lineaDiAttivita) + * dettaglioServente.U = dettaglioServito.J / L / R / T (quello valorizzato) + * dettaglioServente.AG = dettaglioServito.AD / AF (quello valorizzato) + * dettaglioServente.AP = dettaglioServito.AM / AD (quello valorizzato) + * il dettaglio servito viene marcato con CATEGORIA 'SCR', quello servente con categotria 'CAR', e viene messo in STATO 'X' + * PDG servente già chiuso + * PreCondition: + * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato qualche colonna riferita ad un'altro cdr (CLGS != NULL) e il PDG del CDR scelto è già "chiuso" (checkChiusuraPdg genera una Exception) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il PDG del servente è stato già chiuso + * costi senza spese + * PreCondition: + * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato la colonna P, AB o AI ; il PDG del CDR scelto è modificabile (stato A, B, D o E), la voce è "Prestazioni da struttura dell'ente" (isVoceCSSAC() ritorna true) + * PostCondition: + * Viene creata per il cdr servente un nuovo dettaglio di entrata valorizzazzato come segue: + * entrataServente.esercizio = dettaglioServito.esercizio + * entrataServente.cdr = cdrServente + * entrataServente.appartenenza = dettaglioServito.appartenenza + * entrataServente.gestione = dettaglioServito.gestione + * entrataServente.voce = getVoceRicaviFigurativi() + * entrataServente.clgs = dettaglioServito + * entrataServente.CATEGORIA = 'CAR' + * entrataServente.STATO = 'X' + * entrataServente.lineaDiAttivita = Linea_attivitaComponent.creaLineaAttivitaCSSAC(cdrServente,dettaglioServito.lineaDiAttivita) + * entrataServente.B = dettaglioServito.P + * entrataServente.D = dettaglioServito.AB + * entrataServente.F = dettaglioServito.AI + * + * il dettaglio servito viene marcato con CATEGORIA 'SCR' e viene messo in STATO 'X' + * + * costi senza spese, voce non valida + * PreCondition: + * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato la colonna P, AB o AI, la voce NON è "Prestazioni da struttura dell'ente" (isVoceCSSAC() ritorna false) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "La voce del piano dei conti deve essere 'Prestazioni da struttura dell'ente'" + * spesa relativa altra UO, campi non validi + * PreCondition: + * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD) + * sono compilati più di uno alla volta di + * - J, L, R, T + * - AD, AF + * - AM, AD + * oppure sono compilati altri campi non relativi ad altra UO eccetto H/AA/AH + * PostCondition: + * Viene generata una ApplicationException. + * costi senza spese, campi non validi + * PreCondition: + * Viene richiesto il salvataggio di una riga di spese del PDG e l'utente ha compilato la colonna P, AB o AI e qualche altra colonna non relativa a "costi senza spese verso altro CDR" + * PostCondition: + * Viene generata una ApplicationException. + * spesa relativa altra UO per il personale, linea di attivita non valida + * PreCondition: + * Viene richiesto il salvataggio di una riga di spese del PDG e + * l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD) e + * isVoceSAUOP(dettaglio.voce) e + * il PDG del CDR scelto è aperto (stato uguale a A, B, D o E) + * la linea di attivita ha natura o funzione diverse da uno + * PostCondition: + * Viene generata una eccezione con messaggio: "Le spese per personale devono avere una linea di attività con natura e funzione 1" + * spesa relativa altra UO per il personale + * PreCondition: + * Viene richiesto il salvataggio di una riga di spese del PDG e + * l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD) e + * isVoceSAUOP(dettaglio.voce) = true e + * il PDG del CDR scelto è aperto (stato uguale a A, B, D o E) + * la linea di attivita ha natura o funzione uguale a uno + * PostCondition: + * Viene creata nel PDG del cdr scelto (servente) un nuovo dettaglio di spesa valorizzazzato come segue: + * dettaglioServente.esercizio = dettaglioServito.esercizio + * dettaglioServente.cdr = cdrServente + * dettaglioServente.appartenenza = dettaglioServito.appartenenza + * dettaglioServente.gestione = dettaglioServito.gestione + * dettaglioServente.voce = dettaglioServito.voce + * dettaglioServente.clgs = dettaglioServito + * dettaglioServente.CATEGORIA = 'CAR' + * dettaglioServente.STATO = 'X' + * dettaglioServente.lineaDiAttivita = Linea_attivitaComponent.creaLineaAttivitaSAUOP(cdrServente) + * dettaglioServente.U = dettaglioServito.J / L / R / T (quello valorizzato) + * dettaglioServente.AG = dettaglioServito.AD / AF (quello valorizzato) + * dettaglioServente.AP = dettaglioServito.AM / AD (quello valorizzato) + * il dettaglio servito viene marcato con CATEGORIA 'SCR', quello servente con categotria 'CAR', e viene messo in STATO 'X' + * PDG già chiuso + * PreCondition: + * checkChiusuraPdg genera una eccezione + * PostCondition: + * Viene lasciata uscire l'eccezione + * linea di attività di natura 5, cdr non collegato ad area + * PreCondition: + * Linea di attività con natura 5 e + * CDR afferente ad UO non collegata ad area + * PostCondition: + * Genera una ApplicationException con il messaggio "Non è possibile creare dettagli con natura 5 perchè il CDR non è collegato ad area attraverso la sua unità organizzativa" + * linea di attività di natura 5, cdr area + * PreCondition: + * Linea di attività con natura 5 e + * CDR afferente UO di tipo area + * PostCondition: + * Genera una ApplicationException con il messaggio "Non è possibile creare dettagli con natura 5 perchè il CDR appartiene ad un'area" + * linea di attività di natura 5, scarico verso altra UO/CDR + * PreCondition: + * Linea di attività con natura 5 + * e l'utente ha compilato qualche colonna relativa a 'spese verso altra UO' (J,L,R,T,AD,AF,AM,AD); il PDG del CDR scelto è aperto (stato uguale a A, B, D o E) o verso altro CDR (P, AB o AI) + * PostCondition: + * Genera una ApplicationException con il messaggio "Non è possibile scaricare costi su altra UO o CDR con natura 5" + * Dettaglio di spesa/entrata con importo negativo + * PreCondition: + * Viene richiesto l'inserimento di un dettaglio di spesa/entrata con importo negativo + * PostCondition: + * Viene generata una ApplicationException con il messaggio "non e' possibile inserire importi negativi" + * linea di attività di natura 5, dettaglio di entrata + * PreCondition: + * Linea di attività con natura 5 e + * il dettaglio specificato è un dettaglio di entrata + * PostCondition: + * Genera un ApplicationException con il messaggio "Non è possibile creare voci di entrata con natura 5" + * dtl costo del personale - CDR non è CDR PERSONALE, CDR_SERVIZIO_ENTE - tempo indeterminato + * PreCondition: + * Il CDR è diverso da CDR PERSONALE e da CDR_SERVIZIO_ENTE. + * Nell'interfaccia stipendi è presente almeno un dettaglio stipendiale contenente la voce di spesa Y diversa da voce TFR (identificata in configurazione). + * Il dipendente specificato nel dettaglio stipendiale, sulla voce Y, è un dipendente a tempo indeterminato. + * PostCondition: + * Creazione/Modifica di dettaglio del PDG di un qualsiasi CDR diverso da CDR DEL PERSONALE e da CDR_SERVIZIO_ENTE, su voce Y diversa da TFR nel caso su Y esista in interfaccia stipendi un dipendente a tempo indeterminato + * Le colonne L e V non saranno imputabile direttamente + * dtl costo del personale - CDR è CDR PERSONALE - tempo indeterminato + * PreCondition: + * Il CDR è uguale a CDR PERSONALE. + * Nell'interfaccia stipendi è presente almeno un dettaglio stipendiale contenente la voce di spesa Y diversa da voce TFR (identificata in configurazione). + * Il dipendente specificato nel dettaglio stipendiale, sulla voce Y, è un dipendente a tempo indeterminato. + * PostCondition: + * Creazione/Modifica di dettaglio del PDG del CDR DEL PERSONALE, su voce Y diversa da TFR nel caso su Y esista in interfaccia stipendi un dipendente a tempo indeterminato. + * La colonna K non sarà imputabile direttamente. + * dtl costo del personale - CDR non è CDR PERSONALE, CDR_SERVIZIO_ENTE - tempo determinato + * PreCondition: + * Il CDR è diverso da CDR PERSONALE e da CDR_SERVIZIO_ENTE. + * Nell'interfaccia stipendi è presente almeno un dettaglio stipendiale contenente la voce di spesa Y diversa da voce TFR (identificata in configurazione). + * Il dipendente specificato nel dettaglio stipendiale, sulla voce Y, è un dipendente a tempo determinato. + * PostCondition: + * Creazione/Modifica di dettaglio del PDG di un qualsiasi CDR diverso da CDR DEL PERSONALE e da CDR_SERVIZIO_ENTE, su voce Y diversa da TFR nel caso su Y esista in interfaccia stipendi un dipendente a tempo determinato + * Le colonne O e V non saranno imputabile direttamente + * dtl costo del personale - CDR è CDR PERSONALE - tempo determinato + * PreCondition: + * Il CDR è uguale a CDR PERSONALE. + * Nell'interfaccia stipendi è presente almeno un dettaglio stipendiale contenente la voce di spesa Y diversa da voce TFR (identificata in configurazione). + * Il dipendente specificato nel dettaglio stipendiale, sulla voce Y, è un dipendente a tempo determinato. + * PostCondition: + * Creazione/Modifica di dettaglio del PDG del CDR DEL PERSONALE, su voce Y diversa da TFR nel caso su Y esista in interfaccia stipendi un dipendente a tempo determinato. + * La colonna O non sarà imputabile direttamente. + * Check imputabilità importi su voci del personale_1 + * PreCondition: + * Il dettaglio è di spesa + * Il conto su cui sto registrando il dettaglio NON è il conto TFR + * Il PDG NON è del personale o quello speciale di servizio ENTE + * La voce specificata nel dettaglio del PDG è presente in COSTO DEL DIPENDENTE su almeno un dipendente a tempo INDETERMINATO + * Le colonne L o V sono valorizzate + * PostCondition: + * Viene generata una eccezione che segnala la non imputabilità sulle colonne L o V + * Check imputabilità importi su voci del personale_2 + * PreCondition: + * Il dettaglio è di spesa + * Il conto su cui sto registrando il dettaglio NON è il conto TFR + * Il PDG NON è del personale o quello speciale di servizio ENTE + * La voce specificata nel dettaglio del PDG è presente in COSTO DEL DIPENDENTE su almeno un dipendente a tempo DETERMINATO + * Le colonne O o V sono valorizzate + * PostCondition: + * Viene generata una eccezione che segnala la non imputabilità sulle colonne O o V + * Check imputabilità importi su voci del personale_3 + * PreCondition: + * Il dettaglio è di spesa + * Il conto su cui sto registrando il dettaglio NON è il conto TFR + * Il PDG è quello del personale + * La voce specificata nel dettaglio del PDG è presente in COSTO DEL DIPENDENTE su almeno un dipendente a tempo INDETERMINATO + * La colonna K è valorizzata + * PostCondition: + * Viene generata una eccezione che segnala la non imputabilità sulla colonna K + * + * Check imputabilità importi su voci del personale_4 + * PreCondition: + * Il dettaglio è di spesa + * Il conto su cui sto registrando il dettaglio NON è il conto TFR + * Il PDG è quello del personale + * La voce specificata nel dettaglio del PDG è presente in COSTO DEL DIPENDENTE su almeno un dipendente a tempo DETERMINATO + * La colonna O è valorizzate + * PostCondition: + * Viene generata una eccezione che segnala la non imputabilità sulla colonna O + * Check imputabilità importi su voci del personale_5 + * PreCondition: + * Il dettaglio è di spesa + * Il conto su cui sto registrando il dettaglio è il conto TFR + * Il PDG NON è del personale o quello speciale di servizio ENTE + * Le colonne O o V sono valorizzate + * + * + * + * PostCondition: + * Viene generata una eccezione che segnala la non imputabilità sulle colonne O o V + * Check imputabilità importi su voci del personale_6 + * PreCondition: + * Il dettaglio è di spesa + * Il conto su cui sto registrando il dettaglio è il conto TFR + * Il PDG è del personale + * La colonna O è valorizzata + * + * PostCondition: + * Viene generata una eccezione che segnala la non imputabilità sulla colonna O + * + */ + +/** + * Prima di eseguire il metodo {@link it.cnr.jada.comp.CRUDComponent#creaConBulk } vengono + * effettuati dei controlli sui dati inseriti. + * + * Nome: Creare un nuovo elemento PdG; + * Pre: Effetuare il salvataggio del PdG con i dati corretti; + * Post: Prima di effettuare il salvataggio avvia il metodo per i controlli. + * + * @param userContext UserContext in uso. + * @param bulk {@link it.cnr.contab.pdg00.bulk.Pdg_preventivo_detBulk } da salvare. + * + * @return {@link it.cnr.contab.pdg00.bulk.Pdg_preventivo_detBulk } salvato + */ + +public OggettoBulk creaConBulk(UserContext userContext,OggettoBulk bulk) throws it.cnr.jada.comp.ComponentException { + Pdg_preventivo_detBulk pdgDett = (Pdg_preventivo_detBulk)bulk; + + try { + Pdg_preventivoBulk pdg = (Pdg_preventivoBulk)getHome(userContext, Pdg_preventivoBulk.class).findAndLock( + new Pdg_preventivoBulk( + pdgDett.getEsercizio(), + pdgDett.getCd_centro_responsabilita())); + + // 05/09/2003 + // Aggiunto controllo sulla chiusura dell'esercizio + if (isEsercizioChiuso(userContext,pdg)) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile creare dettagli del pdg ad esercizio chiuso."); + + init(userContext,pdg,pdgDett); + + super.creaConBulk(userContext,bulk); + + validaVariazione(userContext, bulk); + + /* + * Il controllo che la somma degli importi aggregati sia positiva non deve avvenire + * per i dettagli provenienti da variazione al PDG non ancora in stato approvato + */ + if (!pdgDett.isDaVariazione()) + controllaAggregatoPdgDetPositivo(userContext,pdg,pdgDett); + else + { + Pdg_variazioneBulk pdgVar = (Pdg_variazioneBulk)getHome(userContext, Pdg_variazioneBulk.class).findByPrimaryKey( + new Pdg_variazioneBulk( + pdgDett.getPdg_variazione().getEsercizio(), + pdgDett.getPdg_variazione().getPg_variazione_pdg())); + if (pdgVar.isApprovata()) + controllaAggregatoPdgDetPositivo(userContext,pdg,pdgDett); + } + + return bulk; + } catch(OutdatedResourceException e) { + throw handleException(e); + } catch(PersistencyException e) { + throw handleException(e); + } catch(BusyResourceException e) { + throw handleException(e); + } +} +/** + * default + * PreCondition: + * Viene richiesta la ripartizione delle entrate bil. fin. cnr sulle UO non oggetto diretto di contrattazione con l'ente + * PostCondition: + * Viene invocata la stored procedure CNRCTB055.creaRipartEntrate + */ +private void creaRipartEntrate(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB055.creaRipartEntrate(?,?,?)}",false,this.getClass()); + try { + cs.setObject( 1, pdg.getEsercizio() ); + cs.setString( 2, pdg.getCd_centro_responsabilita()); + cs.setString( 3, userContext.getUser()); + cs.execute(); + } finally { + cs.close(); + } + } catch (Throwable e) { + throw handleException(e); + } +} + +/** + * Genera o modifica un dettaglio di scarico di spesa e il suo collegato + * + * @param userContext + * @param pdgSpe dettaglio del servito + */ + +private Pdg_preventivo_spe_detBulk creaSCRAltraUO(UserContext userContext,Pdg_preventivo_spe_detBulk pdgSpe) throws it.cnr.jada.comp.ComponentException { + + boolean newDett; + + if(!pdgSpe.isROaltra_uo()) { + newDett = true; + } else if(pdgSpe.isToBeUpdated()){ + newDett = false; + } else return pdgSpe; + + Pdg_preventivoBulk pdg = null; + if( isVoceSAUOP(userContext, pdgSpe.getElemento_voce()) ) { + try { + // Modifica del 12/02/2002 - I costi finali pluriennali non rientrano nel controllo + if( // ( pdgSpe.getIm_raa_a2_costi_finali() != null && pdgSpe.getIm_raa_a2_costi_finali().intValue() != 0 ) || + (pdgSpe.getIm_rac_a2_spese_odc().compareTo(ZERO) != 0) + || (pdgSpe.getIm_rae_a2_spese_ogc().compareTo(ZERO) != 0 ) + // || (pdgSpe.getIm_rah_a3_costi_finali().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_ral_a3_spese_odc().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_ran_a3_spese_ogc().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_ri_ccs_spese_odc().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_rm_css_ammortamenti().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_rn_css_rimanenze().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_ro_css_altri_costi().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_rk_ccs_spese_ogc().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_rq_ssc_costi_odc().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_rs_ssc_costi_ogc().compareTo(ZERO) != 0 ) + || (pdgSpe.getIm_rv_pagamenti().compareTo(ZERO) != 0 ) ) + { + throw new it.cnr.jada.comp.ApplicationException("Sono stati valorizzati degli importi non compatibili con lo scarico dei costi del personale."); + } + Pdg_preventivoHome pdgHome = (Pdg_preventivoHome)getHome(userContext,Pdg_preventivoBulk.class, "V_PDG_PDG_SAUOP"); + SQLBuilder sql = pdgHome.createSQLBuilder(); + sql.addClause("AND", "esercizio", sql.EQUALS, pdgSpe.getEsercizio()); + it.cnr.jada.persistency.Broker broker = pdgHome.createBroker(sql); + + if(broker.next()) + pdg = (Pdg_preventivoBulk)broker.fetch(Pdg_preventivoBulk.class); + else + throw new it.cnr.jada.comp.ApplicationException("Il PdG per lo scarico dei costi del personale non disponibile."); + + getHome(userContext,CdrBulk.class).findByPrimaryKey(pdg.getCentro_responsabilita()); + + if(pdg.getCentro_responsabilita().equalsByPrimaryKey( pdgSpe.getCentro_responsabilita() )) + throw new it.cnr.jada.comp.ApplicationException("Il CdR del Personale su di una voce stipendiale non può fare lo scarico dei costi su altra UO."); + + pdgSpe.setAltro_cdr(pdg.getCentro_responsabilita()); + } catch(Throwable e) { + throw new it.cnr.jada.comp.ComponentException(e); + } + } else { + if(pdgSpe.getAltro_cdr() == null) { + throw new it.cnr.jada.comp.ApplicationException("CdR altra UO non indicato"); + } else { + try { + pdg = (Pdg_preventivoBulk)getHome(userContext,Pdg_preventivoBulk.class).findByPrimaryKey( new Pdg_preventivoBulk( pdgSpe.getEsercizio(), pdgSpe.getAltro_cdr().getCd_centro_responsabilita() ) ); + } catch(Throwable e) { + throw new it.cnr.jada.comp.ComponentException(e); + } + } + } + if(pdg == null) + throw new it.cnr.jada.comp.ApplicationException("CdR altra UO non valido"); + + // Controllo chiusura PDG servente se non è una variazione + if (pdgSpe.getPdg_variazione() == null){ + if (pdgSpe.OR_PROPOSTA_VARIAZIONE.equals(pdgSpe.getOrigine())) + checkChiusuraPdgPerVariazioni(userContext,pdg); + else { + checkChiusuraPdg(userContext,pdg, pdgSpe); + + // 23/09/2003 CNRADM + // Aggiunto controllo sullo stato del pdg aggregato del cdr servente: + // se in stato B bisogna bloccare scarichi verso altra UO per garantire + // allineamento del bilancio finanziaro (altrimenti la colonna dei costi + // altrui nel pdg aggregato non viene ricalcolata) + String statoPdgAggregato = getStatoAggregato(userContext,pdg.getEsercizio(),pdg.getCd_centro_responsabilita()); + if (Pdg_aggregatoBulk.STATO_B.equals(statoPdgAggregato)) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile scaricare costi verso altra UO perchè il pdg aggregato del cdr servente è già in stato B"); + } + } + + try { + + Pdg_preventivo_spe_detBulk dettaglioServente; + if(newDett) { + + if( pdgSpe.getAltro_cdr().getCd_unita_organizzativa().equals( pdgSpe.getCentro_responsabilita().getCd_unita_organizzativa() ) ) + throw new it.cnr.jada.comp.ApplicationException("Selezionare un CdR con UO diversa dalla propria!"); + + dettaglioServente = new Pdg_preventivo_spe_detBulk(); + dettaglioServente.setCategoria_dettaglio(pdgSpe.CAT_CARICO); + dettaglioServente.setCentro_responsabilita(pdgSpe.getAltro_cdr()); + dettaglioServente.setCentro_responsabilita_clgs(pdgSpe.getCentro_responsabilita()); + dettaglioServente.setDt_registrazione(getHome(userContext, pdgSpe).getServerTimestamp()); + dettaglioServente.setDescrizione(pdgSpe.getDescrizione()); + dettaglioServente.setElemento_voce(pdgSpe.getElemento_voce()); + dettaglioServente.setElemento_voce_clgs(pdgSpe.getElemento_voce()); + dettaglioServente.setEsercizio(pdgSpe.getEsercizio()); + dettaglioServente.setPdg_variazione(pdgSpe.getPdg_variazione()); + // Creo l'associazione variazione_cdr_uo + if (pdgSpe.getPdg_variazione() != null){ + Ass_pdg_variazione_cdrHome home = (Ass_pdg_variazione_cdrHome)getHome(userContext,Ass_pdg_variazione_cdrBulk.class); + Ass_pdg_variazione_cdrBulk ass_pdg_variazione = new Ass_pdg_variazione_cdrBulk(pdgSpe.getPdg_variazione().getEsercizio(),pdgSpe.getPdg_variazione().getPg_variazione_pdg(),pdgSpe.getAltro_cdr().getCd_centro_responsabilita()); + Ass_pdg_variazione_cdrBulk ass_pdg_variazione_esistente = (Ass_pdg_variazione_cdrBulk)home.findByPrimaryKey(ass_pdg_variazione); + if (ass_pdg_variazione_esistente == null){ + ass_pdg_variazione.setToBeCreated(); + super.creaConBulk(userContext,ass_pdg_variazione); + } + } + // I dettagli di carico sono MODIFICABILI (per la sola parte pagamenti) R137R + // Date: 10/04/2002 + dettaglioServente.setFl_sola_lettura(new Boolean(false)); + dettaglioServente.setLinea_attivita_clgs(pdgSpe.getLinea_attivita()); + dettaglioServente.setOrigine(pdgSpe.getOrigine()); + dettaglioServente.setPg_spesa_clgs(pdgSpe.getPg_spesa()); + dettaglioServente.setUser(userContext.getUser()); + + + if( isVoceSAUOP(userContext, pdgSpe.getElemento_voce()) ) { + dettaglioServente.setLinea_attivita( + ((it.cnr.contab.config00.ejb.Linea_attivitaComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB( + "CNRCONFIG00_EJB_Linea_attivitaComponentSession", + it.cnr.contab.config00.ejb.Linea_attivitaComponentSession.class) + ).creaLineaAttivitaSAUOP( + userContext, + pdg.getCentro_responsabilita() + ) + ); + } else { + dettaglioServente.setLinea_attivita( + ((it.cnr.contab.config00.ejb.Linea_attivitaComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB( + "CNRCONFIG00_EJB_Linea_attivitaComponentSession", + it.cnr.contab.config00.ejb.Linea_attivitaComponentSession.class) + ).creaLineaAttivitaSAUO( + userContext, + pdgSpe.getAltro_cdr(), + pdgSpe.getLinea_attivita() + ) + ); + } + } else { + + try { + dettaglioServente = (Pdg_preventivo_spe_detBulk)getHome(userContext,Pdg_preventivo_spe_detBulk.class).findByPrimaryKey( new Pdg_preventivo_spe_detBulk( + pdgSpe.getCd_centro_responsabilita_clgs(), + pdgSpe.getCd_elemento_voce_clgs(), + pdgSpe.getCd_linea_attivita_clgs(), + pdgSpe.getEsercizio(), + pdgSpe.getPg_spesa_clgs(), + pdgSpe.getTi_appartenenza_clgs(), + pdgSpe.getTi_gestione_clgs()) ); + } catch(Throwable e) { + throw new it.cnr.jada.comp.ComponentException(e); + } + } + + dettaglioServente.setStato(pdgSpe.ST_NESSUNA_AZIONE); + + copiaImportiAltraUO(userContext,pdgSpe,dettaglioServente); + + pdgSpe.setStato(Pdg_preventivo_detBulk.ST_NESSUNA_AZIONE); + + if(newDett) { + if(pdgSpe.isToBeCreated()) + insertBulk(userContext, pdgSpe); + else + updateBulk(userContext, pdgSpe); + + dettaglioServente.completaImportiNulli(); + dettaglioServente.setPg_spesa_clgs(pdgSpe.getPg_spesa()); + insertBulk(userContext, dettaglioServente); + + pdgSpe.setCentro_responsabilita_clgs(dettaglioServente.getCentro_responsabilita()); + pdgSpe.setElemento_voce_clgs(dettaglioServente.getElemento_voce()); + pdgSpe.setLinea_attivita_clgs(dettaglioServente.getLinea_attivita()); + pdgSpe.setPg_spesa_clgs(dettaglioServente.getPg_spesa()); + pdgSpe.setCategoria_dettaglio(dettaglioServente.CAT_SCARICO); + } else { + updateBulk(userContext, dettaglioServente); + } + + updateBulk(userContext, pdgSpe); + + } catch(Throwable e) { + throw handleException(e); + } + + return pdgSpe; +} + +/** + * Genera o modifica un dettaglio di spesa per entrata figurativa e il suo collegato + * + * @param userContext + * @param pdgSpe dettaglio del servito + */ + +private Pdg_preventivo_spe_detBulk creaSCRVersoCdR(UserContext userContext,Pdg_preventivo_spe_detBulk pdgSpe) throws it.cnr.jada.comp.ComponentException { + + boolean newDett; + + if(!pdgSpe.isROaltra_uo()) { + newDett = true; + } else if(pdgSpe.isToBeUpdated()){ + newDett = false; + } else return pdgSpe; + + if(newDett) { + if(!isVoceCSSAC(userContext, pdgSpe.getElemento_voce())) + throw new it.cnr.jada.comp.ApplicationException("La voce del piano dei conti deve essere \"Prestazioni da struttura dell'ente\""); + } + + if (pdgSpe.getIm_raa_a2_costi_finali().compareTo(ZERO) != 0 || + pdgSpe.getIm_rac_a2_spese_odc().compareTo(ZERO) != 0 || + pdgSpe.getIm_rae_a2_spese_ogc().compareTo(ZERO) != 0 || + pdgSpe.getIm_rah_a3_costi_finali().compareTo(ZERO) != 0 || + pdgSpe.getIm_ral_a3_spese_odc().compareTo(ZERO) != 0 || + pdgSpe.getIm_ran_a3_spese_ogc().compareTo(ZERO) != 0 || + pdgSpe.getIm_rh_ccs_costi().compareTo(ZERO) != 0 || + pdgSpe.getIm_ri_ccs_spese_odc().compareTo(ZERO) != 0 || + pdgSpe.getIm_rm_css_ammortamenti().compareTo(ZERO) != 0 || + pdgSpe.getIm_rn_css_rimanenze().compareTo(ZERO) != 0 || + pdgSpe.getIm_ro_css_altri_costi().compareTo(ZERO) != 0 || + pdgSpe.getIm_rk_ccs_spese_ogc().compareTo(ZERO) != 0 || + pdgSpe.getIm_rq_ssc_costi_odc().compareTo(ZERO) != 0 || + pdgSpe.getIm_rs_ssc_costi_ogc().compareTo(ZERO) != 0 || + pdgSpe.getIm_rv_pagamenti().compareTo(ZERO) != 0) + { + throw new it.cnr.jada.comp.ApplicationException("Sono stati valorizzati degli importi non compatibili con il campo 'Verso altro CDR'"); + } + + Pdg_preventivoBulk pdg; + if(pdgSpe.getAltro_cdr() == null) { + throw new it.cnr.jada.comp.ApplicationException("CdR altra UO non indicato"); + } else { + try { + pdg = (Pdg_preventivoBulk)getHome(userContext,Pdg_preventivoBulk.class).findByPrimaryKey(new Pdg_preventivoBulk(pdgSpe.getEsercizio(),pdgSpe.getAltro_cdr().getCd_centro_responsabilita())); + } catch(Throwable e) { + throw new it.cnr.jada.comp.ComponentException(e); + } + } + if(pdg == null) + throw new it.cnr.jada.comp.ApplicationException("CdR altra UO non valido"); + + // Controllo chiusura PDG servente + if (pdgSpe.OR_PROPOSTA_VARIAZIONE.equals(pdgSpe.getOrigine())) + checkChiusuraPdgPerVariazioni(userContext,pdg); + else + checkChiusuraPdg(userContext,pdg,pdgSpe); + + try { + + Pdg_preventivo_etr_detBulk dettaglioServente; + if(newDett) { + dettaglioServente = new Pdg_preventivo_etr_detBulk(); + dettaglioServente.setCategoria_dettaglio(pdgSpe.CAT_CARICO); + dettaglioServente.setCentro_responsabilita(pdgSpe.getAltro_cdr()); + dettaglioServente.setCentro_responsabilita_clgs(pdgSpe.getCentro_responsabilita()); + dettaglioServente.setDt_registrazione(getHome(userContext, pdgSpe).getServerTimestamp()); + dettaglioServente.setDescrizione(pdgSpe.getDescrizione()); + dettaglioServente.setElemento_voce(getVoceRicaviFigurativi(userContext)); + dettaglioServente.setElemento_voce_clgs(pdgSpe.getElemento_voce()); + dettaglioServente.setEsercizio(pdgSpe.getEsercizio()); + dettaglioServente.setFl_sola_lettura(new Boolean(true)); + dettaglioServente.setLinea_attivita_clgs(pdgSpe.getLinea_attivita()); + dettaglioServente.setOrigine(pdgSpe.getOrigine()); + dettaglioServente.setPg_spesa_clgs(pdgSpe.getPg_spesa()); + dettaglioServente.setUser(userContext.getUser()); + + dettaglioServente.setLinea_attivita( + ((it.cnr.contab.config00.ejb.Linea_attivitaComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB( + "CNRCONFIG00_EJB_Linea_attivitaComponentSession", + it.cnr.contab.config00.ejb.Linea_attivitaComponentSession.class) + ).creaLineaAttivitaCSSAC( + userContext, + pdgSpe.getAltro_cdr(), + pdgSpe.getLinea_attivita() + ) + ); + } else { + + try { + dettaglioServente = (Pdg_preventivo_etr_detBulk)getHome(userContext,Pdg_preventivo_etr_detBulk.class).findByPrimaryKey( new Pdg_preventivo_etr_detBulk( + pdgSpe.getCd_centro_responsabilita_clge(), + pdgSpe.getCd_elemento_voce_clge(), + pdgSpe.getCd_linea_attivita_clge(), + pdgSpe.getEsercizio(), + pdgSpe.getPg_entrata_clge(), + pdgSpe.getTi_appartenenza_clge(), + pdgSpe.getTi_gestione_clge() ) ); + } catch(Throwable e) { + throw new it.cnr.jada.comp.ComponentException(e); + } + } + + dettaglioServente.setStato(pdgSpe.ST_NESSUNA_AZIONE); + + copiaImportAltroCDR(userContext,pdgSpe,dettaglioServente); + + pdgSpe.setStato(Pdg_preventivo_detBulk.ST_NESSUNA_AZIONE); + + if(newDett) { + if(pdgSpe.isToBeCreated()) + insertBulk(userContext, pdgSpe); + else + updateBulk(userContext, pdgSpe); + + dettaglioServente.completaImportiNulli(); + dettaglioServente.setPg_spesa_clgs(pdgSpe.getPg_spesa()); + insertBulk(userContext, dettaglioServente); + + pdgSpe.setCentro_responsabilita_clge(dettaglioServente.getCentro_responsabilita()); + pdgSpe.setElemento_voce_clge(dettaglioServente.getElemento_voce()); + pdgSpe.setLinea_attivita_clge(dettaglioServente.getLinea_attivita()); + pdgSpe.setPg_entrata_clge(dettaglioServente.getPg_entrata()); + pdgSpe.setCategoria_dettaglio(dettaglioServente.CAT_SCARICO); + } else { + updateBulk(userContext, dettaglioServente); + } + + updateBulk(userContext, pdgSpe); + + } catch(Throwable e) { + throw new it.cnr.jada.comp.ComponentException(e); + } + return pdgSpe; +} + +//^^@@ +/** + * eliminazione dettagli a partire dalla linea di attivià + * PreCondition: + * Viene richiesta l'eliminazione dei dettagli di spesa ed entrata che corrispondono ad esercizio, CdR e LA indicati. + * PostCondition: + * Vengono lanciate due delete una per i dettagli di spesa ed una per quelli di entrata per i record che soddisfano le condizioni. + */ +//^^@@ + public Pdg_preventivoBulk delDetByLA(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ApplicationException, it.cnr.jada.comp.ComponentException { + + checkChiusuraPdg(userContext, pdg, null); + + CdrBulk cdr = cdrFromUserContext(userContext); + checkLivelloResponsabilita(userContext, cdr, pdg); + + if(pdg.getLinea_attivita_eliminazione() == null || pdg.getLinea_attivita_eliminazione().getCd_linea_attivita() == null) + throw new it.cnr.jada.comp.ApplicationException("GAE indicata per l'eliminazione non valida."); + + try { + String delSpe = "DELETE FROM " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "PDG_PREVENTIVO_SPE_DET WHERE " + + "ESERCIZIO = " + pdg.getEsercizio() + " AND " + + "CD_CENTRO_RESPONSABILITA = '" + pdg.getCd_centro_responsabilita() + "' AND " + + "CD_LINEA_ATTIVITA = '" + pdg.getLinea_attivita_eliminazione().getCd_linea_attivita() + "' AND "+ + "CATEGORIA_DETTAGLIO = '" + Pdg_preventivo_detBulk.CAT_SINGOLO + "'"; + + String delEtr = "DELETE FROM " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + "PDG_PREVENTIVO_ETR_DET WHERE " + + "ESERCIZIO = " + pdg.getEsercizio() + " AND " + + "CD_CENTRO_RESPONSABILITA = '" + pdg.getCd_centro_responsabilita() + "' AND " + + "CD_LINEA_ATTIVITA = '" + pdg.getLinea_attivita_eliminazione().getCd_linea_attivita() + "' AND "+ + "CATEGORIA_DETTAGLIO = '" + Pdg_preventivo_detBulk.CAT_SINGOLO + "'"; + + if (Pdg_preventivoBulk.ST_G_APERTURA_PER_VARIAZIONI.equals(pdg.getStato()) || + Pdg_preventivoBulk.ST_H_PRECHIUSURA_PER_VARIAZIONI.equals(pdg.getStato())) { + delSpe = delSpe + " AND ORIGINE = '"+Pdg_preventivo_detBulk.OR_PROPOSTA_VARIAZIONE+"'"; + delEtr = delEtr + " AND ORIGINE = '"+Pdg_preventivo_detBulk.OR_PROPOSTA_VARIAZIONE+"'"; + } + + java.sql.Statement cs = getConnection( userContext ).createStatement(); + try { + lockBulk(userContext,pdg); + if(pdg.getLinea_attivita_eliminazione().getTi_gestione().equals(it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk.TI_GESTIONE_SPESE)) + cs.execute(delSpe); + if(pdg.getLinea_attivita_eliminazione().getTi_gestione().equals(it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk.TI_GESTIONE_ENTRATE)) + cs.execute(delEtr); + return caricaPdg(userContext,pdg.getCentro_responsabilita()); + } catch (Throwable e) { + throw handleException(pdg,e); + } finally { + cs.close(); + } + } catch (java.sql.SQLException e) { + // Gestisce eccezioni SQL specifiche (errori di lock,...) + throw handleSQLException(e); + } + } + +//^^@@ +/** + * PDG non modificabile + * PreCondition: + * checkLivelloResponsabilita(pdg,pdg_det) genera una eccezione + * PostCondition: + * Lascia uscire l'eccezione generata + * Dettaglio scaricato o caricato + * PreCondition: + * CATEGORIA = 'SCR' o 'CAR' + * PostCondition: + * Genera una eccezione con messaggio: "Il dettaglio non può essere eliminato" + * PDG già chiuso + * PreCondition: + * checkChiusuraPdg(pdg_det) genera una eccezione + * PostCondition: + * Lascia uscire l'eccezione generata + * Tutti i controlli superati + * PreCondition: + * Nessun'altra precondizione verificata + * PostCondition: + * Elimina il dettaglio del pdg specificato + */ +//^^@@ + + public void eliminaConBulk (UserContext userContext,OggettoBulk bulk) throws ComponentException { + Pdg_preventivo_detBulk dett = (Pdg_preventivo_detBulk)bulk; + CdrBulk cdr = cdrFromUserContext(userContext); + + Pdg_preventivoBulk pdg = checkChiusuraPdg(userContext,dett); + + // 05/09/2003 + // Aggiunto controllo sulla chiusura dell'esercizio + if (isEsercizioChiuso(userContext,pdg)) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile eliminare dettagli del pdg ad esercizio chiuso."); + + checkLivelloResponsabilita(userContext, cdr, pdg); + + if(dett.getFl_sola_lettura().booleanValue()) + throw new it.cnr.jada.comp.ApplicationException("Il dettaglio non può essere eliminato"); + + if(Pdg_preventivo_detBulk.CAT_SCARICO.equals( dett.getCategoria_dettaglio())&& + dett.getPdg_variazione() == null) + throw new it.cnr.jada.comp.ApplicationException("Il dettaglio è stato scaricato e non può essere eliminato; contattare il CDR servente"); +/* + if(Pdg_preventivo_detBulk.CAT_SCARICO.equals( dett.getCategoria_dettaglio()) && + Pdg_preventivo_detBulk.ST_CONFERMA.equals( dett.getStato() )) + throw new it.cnr.jada.comp.ApplicationException("Il dettaglio è stato confermato dal centro servente e non può essere eliminato; contattare il CDR servente"); +*/ + + if(Pdg_preventivo_detBulk.CAT_CARICO.equals( dett.getCategoria_dettaglio() )) { + // if(Pdg_preventivo_detBulk.ST_NESSUNA_AZIONE.equals( dett.getStato() )) +// throw new it.cnr.jada.comp.ApplicationException("Il dettaglio non è eliminabile fino alla chiusura della contrattazione. Contattare il CDR servente"); + throw new it.cnr.jada.comp.ApplicationException("Il dettaglio è di carico e non può essere eliminato"); +/* + if(Pdg_preventivo_detBulk.ST_CONFERMA.equals( dett.getStato() )) + throw new it.cnr.jada.comp.ApplicationException("Il dettaglio non è eliminabile perchè confermato."); + + Pdg_preventivo_spe_detBulk servente = new Pdg_preventivo_spe_detBulk(); + + servente.setEsercizio(dett.getEsercizio()); + servente.setCentro_responsabilita(dett.getCentro_responsabilita_clgs()); + servente.setElemento_voce(dett.getElemento_voce_clgs()); + servente.setLinea_attivita(dett.getLinea_attivita_clgs()); + servente.setPg_spesa(dett.getPg_spesa_clgs()); + + // Controllo che il pdg servente sia chiuso + checkChiusuraPdg(userContext,servente); + try { + getHome(userContext,servente).delete(servente); + } catch(PersistencyException e) { + throw handleException((OggettoBulk)dett,e); + } +*/ + + } + + super.eliminaConBulk(userContext,bulk); + } + +//^^@@ +/** + * default + * PreCondition: + * Viene richiesto il CDR PERSONALE da configurazione CNR + * PostCondition: + * Restituisce il cdr con il codice specificato in CONFIGURAZIONE_CNR alla voce + * "CDR_SPECIALE" , "CDR_PERSONALE" + */ +//^^@@ + private CdrBulk getCDR_PERSONALE (UserContext userContext) throws ComponentException { + try { + String aCdCdr = Optional.ofNullable(((Configurazione_cnrHome)getHome(userContext,Configurazione_cnrBulk.class)).getCdrPersonale(CNRUserContext.getEsercizio(userContext))) + .orElseThrow(()->new it.cnr.jada.comp.ApplicationException("Centro di responsabilità del Personale non definito in Configurazione CNR per l'esercizio "+CNRUserContext.getEsercizio(userContext)+".")); + it.cnr.contab.config00.sto.bulk.CdrHome cdrHome = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext,CdrBulk.class, "V_CDR_VALIDO"); + SQLBuilder sql = cdrHome.createSQLBuilder(); + sql.addClause(FindClause.AND, "esercizio", SQLBuilder.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + sql.addClause(FindClause.AND, "cd_centro_responsabilita", SQLBuilder.EQUALS, aCdCdr); + it.cnr.jada.persistency.Broker broker = cdrHome.createBroker(sql); + + CdrBulk aCdrBulk; + if(broker.next()) + aCdrBulk = (CdrBulk)broker.fetch(CdrBulk.class); + else + throw new it.cnr.jada.comp.ApplicationException("Il CDR del personale specificato in CONFIGURAZIONE CNR non è stato trovato!"); + + return aCdrBulk; + } catch(Throwable e) { + throw handleException(e); + } + } + +//^^@@ +/** + * default + * PreCondition: + * Viene richiesto il CDR SPECIALE SERVIZIO ENTE da configurazione CNR + * PostCondition: + * Restituisce il cdr con il codice specificato in CONFIGURAZIONE_CNR alla voce + * "CDR_SPECIALE" , "CDR_SERVIZIO_ENTE" + */ +//^^@@ + private CdrBulk getCDR_SERVIZIO_ENTE (UserContext userContext) throws ComponentException { + try { + String aCdCdr = Optional.ofNullable(((Configurazione_cnrHome)getHome(userContext, Configurazione_cnrBulk.class)).getCdrServizioEnte(CNRUserContext.getEsercizio(userContext))) + .orElseThrow(()->new it.cnr.jada.comp.ApplicationException("Cdr di Servizio dell'Ente non trovato in Configurazione CNR per l'esercizio "+CNRUserContext.getEsercizio(userContext)+".")); + it.cnr.contab.config00.sto.bulk.CdrHome cdrHome = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext,CdrBulk.class, "V_CDR_VALIDO"); + SQLBuilder sql = cdrHome.createSQLBuilder(); + sql.addClause(FindClause.AND, "esercizio", SQLBuilder.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + sql.addClause(FindClause.AND, "cd_centro_responsabilita", SQLBuilder.EQUALS, aCdCdr); + it.cnr.jada.persistency.Broker broker = cdrHome.createBroker(sql); + + CdrBulk aCdrBulk; + if(broker.next()) + aCdrBulk = (CdrBulk)broker.fetch(CdrBulk.class); + else + throw new it.cnr.jada.comp.ApplicationException("Il CDR di servizio per l'ENTE specificato in CONFIGURAZIONE CNR non è stato trovato!"); + + return aCdrBulk; + } catch(Throwable e) { + throw handleException(e); + } + } + +//^^@@ +/** + * default + * PreCondition: + * Viene richiesta la voce di tipo ONERI_CNR da configurazione CNR + * PostCondition: + * Restituisce l'elemento voce con il codice specificato in CONFIGURAZIONE_CNR alla voce + * "ELEMENTO_VOCE_SPECIALE" , "ONERI_CNR" + */ +//^^@@ + private Elemento_voceBulk getVoceONERI_CNR (UserContext userContext) throws ComponentException { + try { + Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); + String aCdOneriCnr=configurazione.getVal01(userContext,it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext),null,"ELEMENTO_VOCE_SPECIALE","ONERI_CNR"); + if(aCdOneriCnr==null) + throw new it.cnr.jada.comp.ApplicationException("Voce Oneri Cnr non definita in CONFIGURAZIONE CNR per l'esercizio corrente"); + return (Elemento_voceBulk)getHome(userContext,Elemento_voceBulk.class).findByPrimaryKey(new Elemento_voceBulk( + aCdOneriCnr, + it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), + Elemento_voceHome.APPARTENENZA_CDS, + Elemento_voceHome.GESTIONE_SPESE + )); + } catch(Throwable e) { + throw handleException(e); + } + } + +//^^@@ +/** + * default + * PreCondition: + * Viene richiesta la voce da assegnare al dettaglio di entrata creato sul PDG del CDR servente nel caso di un costo senza spese + * PostCondition: + * Restituisce l'elemento voce con il codice specificato in CONFIGURAZIONE_CNR alla voce + * "ELEMENTO_VOCE_SPECIALE" , "RICAVO_FIGURATIVO_ALTRO_CDR" + */ +//^^@@ + private Elemento_voceBulk getVoceRicaviFigurativi (UserContext userContext) throws ComponentException { + try { + Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); + String aVoceRicFig = configurazione.getVal01(userContext,it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext),null,"ELEMENTO_VOCE_SPECIALE","RICAVO_FIGURATIVO_ALTRO_CDR"); + if(aVoceRicFig==null) + throw new it.cnr.jada.comp.ApplicationException("Voce del piano \"Ricavo Figurativo\" non presente in configurazione CNR per l'esercizio corrente"); + return (Elemento_voceBulk)getHome(userContext,Elemento_voceBulk.class).findByPrimaryKey(new Elemento_voceBulk( + aVoceRicFig, + it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), + Elemento_voceHome.APPARTENENZA_CNR, + Elemento_voceHome.GESTIONE_ENTRATE + )); + } catch(Throwable e) { + throw handleException(e); + } + } + +//^^@@ +/** + * default + * PreCondition: + * Viene richiesta la voce di tipo TFR da configurazione CNR + * PostCondition: + * Restituisce l'elemento voce con il codice specificato in CONFIGURAZIONE_CNR alla voce + * "ELEMENTO_VOCE_SPECIALE" , "TFR" + */ +//^^@@ + private Elemento_voceBulk getVoceTFR (UserContext userContext) throws ComponentException { + try { + Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); + String aCdTfr=configurazione.getVal01(userContext,it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext),null,"ELEMENTO_VOCE_SPECIALE","TFR"); + if(aCdTfr==null) + throw new it.cnr.jada.comp.ApplicationException("Voce TFR non definita in CONFIGURAZIONE CNR per l'esercizio corrente"); + return (Elemento_voceBulk)getHome(userContext,Elemento_voceBulk.class).findByPrimaryKey(new Elemento_voceBulk( + aCdTfr, + it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), + Elemento_voceHome.APPARTENENZA_CDS, + Elemento_voceHome.GESTIONE_SPESE + )); + } catch(Throwable e) { + throw handleException(e); + } + } + +/** + * Metodo per i controlli da effettuare su un oggetto di tipo {@link it.cnr.contab.pdg00.bulk.Pdg_preventivo_detBulk } . + * + * Nome: Controlli per inserimento e modifica; + * Pre: Implementare tutti i controlli che garantiscano l'integrita del record rappresentato dall oggetto; + * Post: Verifica che la linea di attività e l'elemento voce non siano nulli. + * + * @param pdg Oggetto da analizzare. + * + * @return L'oggetto controllato. + * + * @throw it.cnr.jada.comp.ComponentException + */ +private void init(UserContext userContext,Pdg_preventivoBulk pdg,Pdg_preventivo_detBulk pdgDett) throws it.cnr.jada.comp.ComponentException { + try { + if(pdgDett.getLinea_attivita() == null || pdgDett.getLinea_attivita().getCd_linea_attivita() == null) + throw new it.cnr.jada.comp.ApplicationException("Il GAE non può essere nullo."); + + if(pdgDett.getElemento_voce() == null || pdgDett.getElemento_voce().getCd_elemento_voce() == null) + throw new it.cnr.jada.comp.ApplicationException("Voce del piano non può essere nulla."); + + // Carico tutti gli oggetti complessi legati al pdg + getHomeCache(userContext).fetchAll(userContext); + + if (pdgDett.getDt_registrazione() == null) + pdgDett.setDt_registrazione(getHome(userContext, (OggettoBulk)pdgDett).getServerTimestamp()); + + if (pdgDett.getOrigine() == null) + pdgDett.setOrigine(pdg.isStatoVariazionePdG() || pdgDett.isDaVariazione()? pdgDett.OR_PROPOSTA_VARIAZIONE : pdgDett.OR_UTENTE); + /** + * Controllo lo stato del PDG solo se il dettaglio non proviene da una variazione + */ + if (!pdgDett.isDaVariazione()) + checkChiusuraPdg(userContext, pdg, pdgDett); + + if (pdg.isStatoVariazionePdG()&& !pdgDett.isOriginePropostaVariazione()) + throw new it.cnr.jada.comp.ApplicationException("Il pdg è aperto per variazioni. E' possibile modificare o inserire solamente proposte di variazione"); + + checkLivelloResponsabilita(userContext, cdrFromUserContext(userContext), pdg); + + pdgDett.completaImportiNulli(); + + if ("5".equals( pdgDett.getLinea_attivita().getNatura().getCd_natura())) { + Unita_organizzativaHome uoHome = (Unita_organizzativaHome)getHome(userContext, Unita_organizzativaBulk.class); + if (uoHome.findAssociazioneUoArea(userContext, pdgDett.getCentro_responsabilita().getUnita_padre()).isEmpty()) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile creare dettagli con natura 5 perchè il CDR non è collegato ad area attraverso la sua unità organizzativa"); + if (isCdrArea(userContext,pdgDett.getCentro_responsabilita())) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile creare dettagli con natura 5 perchè il CDR appartiene ad un'area"); + } + + if(pdgDett instanceof it.cnr.contab.pdg00.bulk.Pdg_preventivo_spe_detBulk) + initSpe(userContext,pdg,(Pdg_preventivo_spe_detBulk)pdgDett); + else if(pdgDett instanceof it.cnr.contab.pdg00.bulk.Pdg_preventivo_etr_detBulk) + initEtr(userContext,pdg,(Pdg_preventivo_etr_detBulk)pdgDett); + } catch(Throwable e) { + throw new it.cnr.jada.comp.ComponentException(e); + } +} + +/** + * Metodo per i controlli da effettuare su un oggetto di tipo {@link it.cnr.contab.pdg00.bulk.Pdg_preventivo_etr_detBulk } . + * + * Nome: Controlli per inserimento e modifica; + * Pre: Implementare tutti i controlli che garantiscano l'integrita del record rappresentato dall oggetto; + * Post: Verifica che la linea di attività e l'elemento voce non siano nulli. + * + * @param pdg Oggetto da analizzare. + * + * @return L'oggetto controllato. + * + * @throw it.cnr.jada.comp.ComponentException + */ +private OggettoBulk initEtr(UserContext userContext,Pdg_preventivoBulk pdg,Pdg_preventivo_etr_detBulk pdg_det) throws it.cnr.jada.comp.ComponentException { + + + if ("5".equals( pdg_det.getLinea_attivita().getNatura().getCd_natura())) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile creare dettagli di entrata con natura 5"); + + boolean importiNegativi = + (pdg_det.getIm_ra_rce().signum() < 0) || + (pdg_det.getIm_rb_rse().signum() < 0) || + (pdg_det.getIm_rc_esr().signum() < 0) || + (pdg_det.getIm_rd_a2_ricavi().signum() < 0) || + (pdg_det.getIm_re_a2_entrate().signum() < 0) || + (pdg_det.getIm_rf_a3_ricavi().signum() < 0) || + (pdg_det.getIm_rg_a3_entrate().signum() < 0); + + if (pdg.ST_G_APERTURA_PER_VARIAZIONI.equals(pdg.getStato()) || pdg_det.getPdg_variazione() != null) { + boolean importiPositivi = + (pdg_det.getIm_ra_rce().signum() > 0) || + (pdg_det.getIm_rb_rse().signum() > 0) || + (pdg_det.getIm_rc_esr().signum() > 0) || + (pdg_det.getIm_rd_a2_ricavi().signum() > 0) || + (pdg_det.getIm_re_a2_entrate().signum() > 0) || + (pdg_det.getIm_rf_a3_ricavi().signum() > 0) || + (pdg_det.getIm_rg_a3_entrate().signum() > 0); + if (importiPositivi && importiNegativi) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile inserire sia importi positivi che negativi."); + } else if (importiNegativi) { + throw new it.cnr.jada.comp.ApplicationException("Non è possibile inserire importi negativi"); + } + return pdg_det; +} + + /** + * Metodo per i controlli da effettuare su un oggetto di tipo {@link it.cnr.contab.pdg00.bulk.Pdg_preventivo_spe_detBulk } . + * + * Nome: Controlli per inserimento e modifica; + * Pre: Implementare tutti i controlli che garantiscano l'integrita del record rappresentato dall oggetto; + * Post: Verifica che la linea di attività e l'elemento voce non siano nulli. + * + * @param pdg_det Oggetto da analizzare. + * + * @return L'oggetto controllato. + * + * @throw it.cnr.jada.comp.ComponentException + */ + +private OggettoBulk initSpe(UserContext userContext,Pdg_preventivoBulk pdg,Pdg_preventivo_spe_detBulk pdg_det) throws it.cnr.jada.comp.ComponentException { + + // Controllo che non siano imputati importi negativi + + boolean importiNegativi = + (pdg_det.getIm_raa_a2_costi_finali().signum() < 0) || + (pdg_det.getIm_rab_a2_costi_altro_cdr().signum() < 0) || + (pdg_det.getIm_rac_a2_spese_odc().signum() < 0) || + (pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() < 0) || + (pdg_det.getIm_rae_a2_spese_ogc().signum() < 0) || + (pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() < 0) || + (pdg_det.getIm_rag_a2_spese_costi_altrui().signum() < 0) || + (pdg_det.getIm_rah_a3_costi_finali().signum() < 0) || + (pdg_det.getIm_rai_a3_costi_altro_cdr().signum() < 0) || + (pdg_det.getIm_ral_a3_spese_odc().signum() < 0) || + (pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() < 0) || + (pdg_det.getIm_ran_a3_spese_ogc().signum() < 0) || + (pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() < 0) || + (pdg_det.getIm_rap_a3_spese_costi_altrui().signum() < 0) || + (pdg_det.getIm_rh_ccs_costi().signum() < 0) || + (pdg_det.getIm_ri_ccs_spese_odc().signum() < 0) || + (pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() < 0) || + (pdg_det.getIm_rk_ccs_spese_ogc().signum() < 0) || + (pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() < 0) || + (pdg_det.getIm_rm_css_ammortamenti().signum() < 0) || + (pdg_det.getIm_rn_css_rimanenze().signum() < 0) || + (pdg_det.getIm_ro_css_altri_costi().signum() < 0) || + (pdg_det.getIm_rp_css_verso_altro_cdr().signum() < 0) || + (pdg_det.getIm_rq_ssc_costi_odc().signum() < 0) || + (pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() < 0) || + (pdg_det.getIm_rs_ssc_costi_ogc().signum() < 0) || + (pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() < 0) || + (pdg_det.getIm_ru_spese_costi_altrui().signum() < 0) || + (pdg_det.getIm_rv_pagamenti().signum() < 0); + + if (pdg.ST_G_APERTURA_PER_VARIAZIONI.equals(pdg.getStato()) || pdg_det.getPdg_variazione() != null) { + boolean importiPositivi = + (pdg_det.getIm_raa_a2_costi_finali().signum() > 0) || + (pdg_det.getIm_rab_a2_costi_altro_cdr().signum() > 0) || + (pdg_det.getIm_rac_a2_spese_odc().signum() > 0) || + (pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() > 0) || + (pdg_det.getIm_rae_a2_spese_ogc().signum() > 0) || + (pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() > 0) || + (pdg_det.getIm_rag_a2_spese_costi_altrui().signum() > 0) || + (pdg_det.getIm_rah_a3_costi_finali().signum() > 0) || + (pdg_det.getIm_rai_a3_costi_altro_cdr().signum() > 0) || + (pdg_det.getIm_ral_a3_spese_odc().signum() > 0) || + (pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() > 0) || + (pdg_det.getIm_ran_a3_spese_ogc().signum() > 0) || + (pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() > 0) || + (pdg_det.getIm_rap_a3_spese_costi_altrui().signum() > 0) || + (pdg_det.getIm_rh_ccs_costi().signum() > 0) || + (pdg_det.getIm_ri_ccs_spese_odc().signum() > 0) || + (pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() > 0) || + (pdg_det.getIm_rk_ccs_spese_ogc().signum() > 0) || + (pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() > 0) || + (pdg_det.getIm_rm_css_ammortamenti().signum() > 0) || + (pdg_det.getIm_rn_css_rimanenze().signum() > 0) || + (pdg_det.getIm_ro_css_altri_costi().signum() > 0) || + (pdg_det.getIm_rp_css_verso_altro_cdr().signum() > 0) || + (pdg_det.getIm_rq_ssc_costi_odc().signum() > 0) || + (pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() > 0) || + (pdg_det.getIm_rs_ssc_costi_ogc().signum() > 0) || + (pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() > 0) || + (pdg_det.getIm_ru_spese_costi_altrui().signum() > 0) || + (pdg_det.getIm_rv_pagamenti().signum() > 0); + + if (importiPositivi && importiNegativi) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile inserire sia importi positivi che negativi."); + } else if (importiNegativi) { + throw new it.cnr.jada.comp.ApplicationException("Non è possibile inserire importi negativi"); + } + + // Richiesta CNR 137R - Solo la colonna pagamenti è modificabile per dettagli di PDG di spesa di CARICO del servente + if(pdg_det.getCategoria_dettaglio().equals(pdg_det.CAT_CARICO) && pdg_det.isNotNew()) { + Pdg_preventivo_spe_detBulk aOrigSpe; + try { + aOrigSpe=(Pdg_preventivo_spe_detBulk)getHome(userContext,pdg_det).findByPrimaryKey(pdg_det); + } catch (PersistencyException e) { + throw new it.cnr.jada.comp.ApplicationException("Errore di lettura del dettaglio di carico originale"); + } + if( + + (pdg_det.getIm_rag_a2_spese_costi_altrui().compareTo(pdg_det.getIm_rag_a2_spese_costi_altrui()) != 0) + || (pdg_det.getIm_rap_a3_spese_costi_altrui().compareTo(pdg_det.getIm_rap_a3_spese_costi_altrui()) != 0) + || (pdg_det.getIm_ru_spese_costi_altrui().compareTo(pdg_det.getIm_ru_spese_costi_altrui()) != 0) + + || (pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() != 0) + || (pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() != 0) + || (pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() != 0) + || (pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() != 0) + || (pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() != 0) + || (pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() != 0) + || (pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() != 0) + || (pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() != 0) + + || (pdg_det.getIm_raa_a2_costi_finali().signum() != 0) + || (pdg_det.getIm_rab_a2_costi_altro_cdr().signum() != 0) + || (pdg_det.getIm_rac_a2_spese_odc().signum() != 0) + || (pdg_det.getIm_rae_a2_spese_ogc().signum() != 0) + || (pdg_det.getIm_rah_a3_costi_finali().signum() != 0) + || (pdg_det.getIm_rai_a3_costi_altro_cdr().signum() != 0) + || (pdg_det.getIm_ral_a3_spese_odc().signum() != 0) + || (pdg_det.getIm_ran_a3_spese_ogc().signum() != 0) + || (pdg_det.getIm_rh_ccs_costi().signum() != 0) + || (pdg_det.getIm_ri_ccs_spese_odc().signum() != 0) + || (pdg_det.getIm_rk_ccs_spese_ogc().signum() != 0) + || (pdg_det.getIm_rm_css_ammortamenti().signum() != 0) + || (pdg_det.getIm_rn_css_rimanenze().signum() != 0) + || (pdg_det.getIm_ro_css_altri_costi().signum() != 0) + || (pdg_det.getIm_rp_css_verso_altro_cdr().signum() != 0) + || (pdg_det.getIm_rq_ssc_costi_odc().signum() != 0) + || (pdg_det.getIm_rs_ssc_costi_ogc().signum() != 0) + ) { + throw new it.cnr.jada.comp.ApplicationException("Per i dettagli di carico del servente solo la colonna pagamenti (V) può essere modificata"); + }} + + +//Controllo campi valorizzati + boolean control = false; + if( pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() != 0 ) { + control = true; + } + if( pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() != 0 ) { + if(control) + throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); + else + control = true; + } + if( pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() != 0 ) { + if(control) + throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); + else + control = true; + } + if( pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() != 0 + && + control) + { + throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); + } + + if( pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() != 0 + && pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() != 0 ) { + throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); + } + + if( pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() != 0 + && pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() != 0 ) { + throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare più campi verso altra UO nello stesso anno"); + } + + if( (pdg_det.getIm_rp_css_verso_altro_cdr().signum() != 0 + || pdg_det.getIm_rab_a2_costi_altro_cdr().signum() != 0 + || pdg_det.getIm_rai_a3_costi_altro_cdr().signum() != 0) + && + (pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() != 0 + || pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() != 0 + || pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() != 0 + || pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() != 0 + || pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() != 0 + || pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() != 0 + || pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() != 0 + || pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() != 0) ) + { + throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare campi verso altra UO e verso altro CdR contemporaneamente"); + } + + // Aggiunto controllo di non imputabilità di colonne di scarico (altra UO e CDR) e colonne non di scarico + // eccetto COSTI (H) per la quadratura + + if( ( + pdg_det.getIm_rp_css_verso_altro_cdr().signum() != 0 + || pdg_det.getIm_rab_a2_costi_altro_cdr().signum() != 0 + || pdg_det.getIm_rai_a3_costi_altro_cdr().signum() != 0 + || pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() != 0 + || pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() != 0 + || pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() != 0 + || pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() != 0 + || pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() != 0 + || pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() != 0 + || pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() != 0 + || pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() != 0 + ) + && ( // manca H per questioni di quadratura e costi altrui perchè NON imputabili direttamente + pdg_det.getIm_ri_ccs_spese_odc().signum() != 0 + || pdg_det.getIm_rk_ccs_spese_ogc().signum() != 0 + || pdg_det.getIm_rm_css_ammortamenti().signum() != 0 + || pdg_det.getIm_rn_css_rimanenze().signum() != 0 + || pdg_det.getIm_ro_css_altri_costi().signum() != 0 + || pdg_det.getIm_rq_ssc_costi_odc().signum() != 0 + || pdg_det.getIm_rs_ssc_costi_ogc().signum() != 0 + || pdg_det.getIm_rv_pagamenti().signum() != 0 +// Fix del 2002/02/12 - Come per la colonna H anche le corrispondenti pluriennali sono valorizzabili +// || pdg_det.getIm_raa_a2_costi_finali().signum() != 0 + || pdg_det.getIm_rac_a2_spese_odc().signum() != 0 + || pdg_det.getIm_rae_a2_spese_ogc().signum() != 0 +// || pdg_det.getIm_rah_a3_costi_finali().signum() != 0 + || pdg_det.getIm_ral_a3_spese_odc().signum() != 0 + || pdg_det.getIm_ran_a3_spese_ogc().signum() != 0 + ) + ) + { + throw new it.cnr.jada.comp.ApplicationException("Impossibile valorizzare campi verso altra UO o CDR e contemporaneamente campi propri"); + } + + if( pdg_det.getAltro_cdr() != null && pdg_det.getAltro_cdr().getCd_centro_responsabilita() != null + && pdg_det.getIm_rp_css_verso_altro_cdr().signum() == 0 + && pdg_det.getIm_rab_a2_costi_altro_cdr().signum() == 0 + && pdg_det.getIm_rai_a3_costi_altro_cdr().signum() == 0 + && pdg_det.getIm_rj_ccs_spese_odc_altra_uo().signum() == 0 + && pdg_det.getIm_rl_ccs_spese_ogc_altra_uo().signum() == 0 + && pdg_det.getIm_rr_ssc_costi_odc_altra_uo().signum() == 0 + && pdg_det.getIm_rt_ssc_costi_ogc_altra_uo().signum() == 0 + && pdg_det.getIm_rad_a2_spese_odc_altra_uo().signum() == 0 + && pdg_det.getIm_raf_a2_spese_ogc_altra_uo().signum() == 0 + && pdg_det.getIm_ram_a3_spese_odc_altra_uo().signum() == 0 + && pdg_det.getIm_rao_a3_spese_ogc_altra_uo().signum() == 0 + // Richiesta CNR 137R - Solo la colonna pagamenti è modificabile per dettagli di PDG di spesa di CARICO del servente + && !(pdg_det.getCategoria_dettaglio().equals(pdg_det.CAT_CARICO) && pdg_det.isNotNew()) + ) + { + throw new it.cnr.jada.comp.ApplicationException("Non sono stati impostati importi validi da riferire all'\"Altro CdR\" indicato"); + } + + + if(pdg_det.getIm_rh_ccs_costi().compareTo( + pdg_det.getIm_ri_ccs_spese_odc().add( + pdg_det.getIm_rj_ccs_spese_odc_altra_uo().add( + pdg_det.getIm_rk_ccs_spese_ogc().add( + pdg_det.getIm_rl_ccs_spese_ogc_altra_uo() + ) + ) + ) + ) != 0 + ) + { + throw new it.cnr.jada.comp.ApplicationException("Il campo \"Costi\" non contiene la somma dei campi relativi ai Costi Con Spese"); + } + + + // Controlli sulle colonne nel caso i conti derivino da interfaccia stipendi + + // Leggo CDR e VOCI DEL PIANO COINVOLTE + try { + CdrBulk aCdrPersonaleBulk = getCDR_PERSONALE(userContext); + CdrBulk aCdrServizioEnteBulk = getCDR_SERVIZIO_ENTE(userContext); + Elemento_voceBulk aTFRBulk = getVoceTFR(userContext); + Elemento_voceBulk aONERICNRBulk = getVoceONERI_CNR(userContext); + + Pdg_preventivo_spe_detHome aSpeHome = (Pdg_preventivo_spe_detHome)getHome(userContext, pdg_det.getClass()); + + Vector aV = aSpeHome.getVociStipendiali(userContext, pdg_det); + + if(!pdg_det.getElemento_voce().getCd_elemento_voce().equals(aTFRBulk.getCd_elemento_voce())) { + if( + !(// Su tutti i CDR tranne quello del personale e quello speciale + pdg_det.getCentro_responsabilita().equalsByPrimaryKey(aCdrPersonaleBulk) + || pdg_det.getCentro_responsabilita().equalsByPrimaryKey(aCdrServizioEnteBulk) + ) + ) { + for (int i=0;i B, livello < 3 + * PreCondition: + * statoAttuale = A, nuovoStato = B, livello < 3 + * PostCondition: + * Restituisce true + * A -> C, livello = 3 + * PreCondition: + * statoAttuale = A, nuovoStato = C, livello = 3 + * PostCondition: + * Restituisce true + * B -> C + * PreCondition: + * statoAttuale = B, nuovoStato = C + * PostCondition: + * Restituisce true + * C -> F + * PreCondition: + * statoAttuale = C, nuovoStato = F + * PostCondition: + * Restituisce true + * C -> Ci + * PreCondition: + * statoAttuale = C, nuovoStato = Ci + * PostCondition: + * Restituisce true + * C -> D, livello < 3 + * PreCondition: + * statoAttuale = C, nuovoStato = D, livello < 3 + * PostCondition: + * Restituisce true + * C -> E, livello = 3 + * PreCondition: + * statoAttuale = C, nuovoStato = E, livello = 3 + * PostCondition: + * Restituisce true + * Ci -> C + * PreCondition: + * statoAttuale = Ci, nuovoStato = C + * PostCondition: + * Restituisce true + * A -> B, livello < 3 + * PreCondition: + * statoAttuale = A, nuovoStato = B, livello < 3 + * PostCondition: + * Restituisce true + * D -> C + * PreCondition: + * statoAttuale = D, nuovoStato = C + * PostCondition: + * Restituisce true + * D -> E + * PreCondition: + * statoAttuale = D, nuovoStato = E + * PostCondition: + * Restituisce true + * E -> D, livello < 3 + * PreCondition: + * statoAttuale = E, nuovoStato = D, livello < 3 + * PostCondition: + * Restituisce true + * E -> C, livello = 3 + * PreCondition: + * statoAttuale = E, nuovoStato = C, livello = 3 + * PostCondition: + * Restituisce true + * F -> G + * PreCondition: + * statoAttuale = F, nuovoStato = G + * PostCondition: + * Restituisce true + * G -> H, livello < 3 + * PreCondition: + * statoAttuale = G, nuovoStato = H, livello < 3 + * PostCondition: + * Restituisce true + * G -> M, livello = 3 + * PreCondition: + * statoAttuale = G, nuovoStato = M, livello = 3 + * PostCondition: + * Restituisce true + * H -> M + * PreCondition: + * statoAttuale = H, nuovoStato = M + * PostCondition: + * Restituisce true + * M -> G + * PreCondition: + * statoAttuale = M, nuovoStato = G + * PostCondition: + * Restituisce true + * M -> F + * PreCondition: + * statoAttuale = M, nuovoStato = F + * PostCondition: + * Restituisce true + * Stato non compatibile + * PreCondition: + * Nessun'altra precondizione verificata + * PostCondition: + * Restituisce false + */ +private boolean isStatoCompatibile (String statoAttuale, int livello, String nuovoStato) { + + if( Pdg_preventivoBulk.ST_A_CREAZIONE.equals( statoAttuale ) ) { + if( livello < 3 ) { + return Pdg_preventivoBulk.ST_B_MODIFICA.equals( nuovoStato ); + } else if( livello == 3) { + return Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ); + } + } + + if( Pdg_preventivoBulk.ST_B_MODIFICA.equals( statoAttuale )) { + return Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ); + } + + if( Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( statoAttuale ) ) { + return (Pdg_preventivoBulk.ST_F_CHIUSO_DFNT.equals( nuovoStato ) || + Pdg_preventivoBulk.ST_CX_MODIFICA.equals( nuovoStato ) || + ( livello == 3 && + Pdg_preventivoBulk.ST_E_CHIUSO.equals( nuovoStato )) || + ( livello != 3 && + Pdg_preventivoBulk.ST_D_CHIUSURA_I.equals( nuovoStato )) + ); + } + + if( Pdg_preventivoBulk.ST_C0_MODIFICA_AC.equals( statoAttuale ) + || + Pdg_preventivoBulk.ST_C1_MODIFC_CDRI.equals( statoAttuale ) + || + Pdg_preventivoBulk.ST_C2_MODIFIC_RUO.equals( statoAttuale )) + { + return Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ); + } + + if( Pdg_preventivoBulk.ST_D_CHIUSURA_I.equals( statoAttuale )) { + return (Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ) || + Pdg_preventivoBulk.ST_E_CHIUSO.equals( nuovoStato )); + } + + if( Pdg_preventivoBulk.ST_E_CHIUSO.equals( statoAttuale ) ) { + if( livello == 3) { + return Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals( nuovoStato ); + } else if( livello < 3) { + return Pdg_preventivoBulk.ST_D_CHIUSURA_I.equals( nuovoStato ); + } + } + + if( Pdg_preventivoBulk.ST_F_CHIUSO_DFNT.equals( statoAttuale )) { + return Pdg_preventivoBulk.ST_G_APERTURA_PER_VARIAZIONI.equals( nuovoStato ); + } + + if( Pdg_preventivoBulk.ST_G_APERTURA_PER_VARIAZIONI.equals( statoAttuale )) { + if( livello == 3) { + return Pdg_preventivoBulk.ST_M_MODIFICATO_PER_VARIAZIONI.equals( nuovoStato ); + } else if( livello < 3) { + return Pdg_preventivoBulk.ST_H_PRECHIUSURA_PER_VARIAZIONI.equals( nuovoStato ); + } + } + + if( Pdg_preventivoBulk.ST_H_PRECHIUSURA_PER_VARIAZIONI.equals( statoAttuale )) { + return Pdg_preventivoBulk.ST_M_MODIFICATO_PER_VARIAZIONI.equals( nuovoStato ); + } + + if( Pdg_preventivoBulk.ST_M_MODIFICATO_PER_VARIAZIONI.equals( statoAttuale )) { + return + Pdg_preventivoBulk.ST_G_APERTURA_PER_VARIAZIONI.equals( nuovoStato ) || + Pdg_preventivoBulk.ST_F_CHIUSO_DFNT.equals( nuovoStato ); + } + + return false; +} + +//^^@@ +/** + * Voce valida + * PreCondition: + * La voce specificata ha codice uguale a quello presente nella tabella CONFIGURAZIONE_CNR alla voce "ELEMENTO_VOCE_SPECIALE" , "PRESTAZIONI_DA_STRUTTURE_DELL_ENTE" + * PostCondition: + * Ritorna false + * Voce non valida + * PreCondition: + * Nessun'altra precondizione verificata + * PostCondition: + * Ritorna false + */ +//^^@@ + private boolean isVoceCSSAC (UserContext userContext,Elemento_voceBulk voce) throws ComponentException { + try { + Configurazione_cnrComponentSession configurazione = (Configurazione_cnrComponentSession)it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRCONFIG00_EJB_Configurazione_cnrComponentSession",Configurazione_cnrComponentSession.class); + return voce.getCd_elemento_voce().equals(configurazione.getVal01(userContext, voce.getEsercizio(),null,"ELEMENTO_VOCE_SPECIALE","PRESTAZIONI_DA_STRUTTURE_DELL_ENTE")); + } catch(javax.ejb.EJBException e) { + throw handleException(e); + } catch(java.rmi.RemoteException e) { + throw handleException(e); + } + } + +//^^@@ +/** + * voce SAUOP + * PreCondition: + * La voce specificata è SAUOP ( fl_voce_personale = Y ) + * + * PostCondition: + * Ritorna true + * Voce non SAUOP + * PreCondition: + * Nessun'altra precondizione verificata + * PostCondition: + * Ritorna false + */ +//^^@@ + private boolean isVoceSAUOP (UserContext userContext,Elemento_voceBulk voce) { + return voce.getFl_voce_personale() != null && voce.getFl_voce_personale().booleanValue(); + } + +//^^@@ +/** + * CDR NRUO + * PreCondition: + * L'utente in userContext appartiene a un CDR NRUO (getLivelloResponsabilità ritorna 3) + * PostCondition: + * Restituisce un SQL builder per selezionare il solo CDR a cui appartiene l'utente + * CDR RUO + * PreCondition: + * L'utente in userContext appartiene a un CDR RUO (getLivelloResponsabilità ritorna 2) + * PostCondition: + * Restituisce un SQL builder per selezionare il CDR di apparteneza più tutti i CDR della sua UO; + * CDR I + * PreCondition: + * L'utente in userContext appartiene a un CDR I (getLivelloResponsabilità ritorna 1) + * PostCondition: + * Restituisce un SQL builder per selezionare il CDR di appartenenza più tutti i CDR della sua UO; se il CDR appartiene alla UOCDS restituisce anche tutti i CDR delle UO che non hanno CDR di I livello. + * AC + * PreCondition: + * L'utente in userContext appartiene è appartiene al CDR AC + * PostCondition: + * Restituisce un SQL builder per selezionare tutti i CDR escluso sè stesso + */ +//^^@@ + + private SQLBuilder listaCdrPdGPerUtente (UserContext userContext) throws it.cnr.jada.comp.ComponentException { + + CdrBulk cdr = cdrFromUserContext(userContext); + int livelloResponsabilita = getLivelloResponsabilitaCDR(userContext, cdr); + + //lista dei CDR visibili all'utente + Vector lista = new Vector(); + +/* + if (livelloResponsabilita == LV_NRUO) { + lista.add(cdr); + return lista; + } +*/ + + it.cnr.contab.config00.sto.bulk.CdrHome home; + it.cnr.jada.persistency.sql.SQLBuilder sql; + + if (livelloResponsabilita == LV_AC) { + home = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext, CdrBulk.class,"V_CDR_VALIDO","none"); + sql = home.createSQLBuilder(); + } else { +// lista.add(cdr); + home = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext, CdrBulk.class, "V_PDG_CDR_FIGLI_PADRE","none"); + sql = home.createSQLBuilder(); + sql.addSQLClause("AND", "CD_CDR_ROOT", sql.EQUALS, cdr.getCd_centro_responsabilita()); + } + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + + return sql; +// lista.addAll(home.fetchAll(sql)); +// return lista; + } + + + + private SQLBuilder listaCdrPdGPerUtenteIncludeEnte (UserContext userContext) throws it.cnr.jada.comp.ComponentException { + + CdrBulk cdr = cdrFromUserContext(userContext); + Optional.ofNullable(cdr).orElseThrow(()->new ApplicationException("Errore: CDR di Scrivania non individuato!")); + int livelloResponsabilita = getLivelloResponsabilitaCDR(userContext, cdr); + + //lista dei CDR visibili all'utente + Vector lista = new Vector(); + + + it.cnr.contab.config00.sto.bulk.CdrHome home; + it.cnr.jada.persistency.sql.SQLBuilder sql; + + if (livelloResponsabilita == LV_AC) { + home = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext, CdrBulk.class,"V_CDR_VALIDO","none"); + sql = home.createSQLBuilderEsteso(); + } else { + + home = (it.cnr.contab.config00.sto.bulk.CdrHome)getHome(userContext, CdrBulk.class, "V_PDG_CDR_FIGLI_PADRE","none"); + sql = home.createSQLBuilderEsteso(); + sql.addSQLClause("AND", "CD_CDR_ROOT", sql.EQUALS, cdr.getCd_centro_responsabilita()); + } + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + + return sql; +} +//^^@@ +/** + * normale + * PreCondition: + * + * PostCondition: + * Restituisce una lista dei PDG dei CDR il cui valore del livello di responsabilità è maggiore stretto di quello del CDR specificato + */ +//^^@@ + + private java.util.List listaPdGDipendenti (UserContext userContext,Pdg_preventivoBulk pdg) throws ComponentException { + CdrBulk cdr = pdg.getCentro_responsabilita(); + int liv = getLivelloResponsabilitaCDR(userContext, cdr); + if(liv == LV_AC) return null; //AC non ha un PdG per tanto va bloccato + + it.cnr.jada.bulk.BulkHome home; + if(liv == LV_RUO || liv == LV_CDRI) home = getHome(userContext, Pdg_preventivoBulk.class, "V_PDG_PDG_FIGLI"); + else return java.util.Collections.EMPTY_LIST; + it.cnr.jada.persistency.sql.SQLBuilder sql = home.createSQLBuilder(); + + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + sql.addSQLClause("AND", "CD_CDR_ROOT", sql.EQUALS, cdr.getCd_centro_responsabilita()); + + try { + return new Vector(getHome(userContext,Pdg_preventivoBulk.class).fetchAll(sql)); + } catch(it.cnr.jada.persistency.PersistencyException e) { + throw handleException(e); + } + } + +/** + * Carica la lista degli stati accessibili in base a quello attuale del PdG + */ + + private java.util.Dictionary loadStatiKeys (UserContext userContext,Pdg_preventivoBulk pdg) throws ComponentException { + java.util.Dictionary list = new it.cnr.jada.util.OrderedHashtable(); + + if(pdg != null && pdg.getStato() != null && !pdg.getStato().equals("") ) { + java.util.Enumeration ek = pdg.STATI.keys(); + java.util.Enumeration el = pdg.STATI.elements(); + int livelloCdR = getLivelloResponsabilitaCDR( userContext, pdg.getCentro_responsabilita() ); + while( ek.hasMoreElements() ) { + String sk = (String)ek.nextElement(); + String sl = (String)el.nextElement(); + + if(isStatoCompatibile( pdg.getStato(), livelloCdR, sk ) + || pdg.getStato().equals( sk )) + { + list.put(sk, sl); + } + } + } + + return list; + } + +/** + * Tutti i controlli superati + * PreCondition: + * Nessun'altra precondizione è verificata + * PostCondition: + * Il dettaglio viene salvato + * Dettaglio scaricato, già chiuso + * PreCondition: + * PDG modificabile dall'utente, CATEGORIA = 'SCR', stato != 'X' + * PostCondition: + * Genera una eccezione con messaggio: "Il dettaglio è già stato contrattato e non è più modificabile. Contattare il CDR servito" + * PDG non modificabile + * PreCondition: + * checkLivelloResponsabilita(pdg,pdg_det) genera una eccezione + * PostCondition: + * Lascia uscire l'eccezione generata + * Dettaglio scaricato + * PreCondition: + * PDG modificabile dall'utente, CATEGORIA = 'SCR', stato = 'X' + * PostCondition: + * Salva il dettaglio e modificato lo stato del dettaglio collegato + * Dettaglio caricato entrata + * PreCondition: + * PDG modificabile dall'utente, CATEGORIA = 'CAR' + * PostCondition: + * Genera una ApplicationException con il messaggio "Il dettaglio non è modificabile. Contattare il CDR servente" + * PDG già chiuso + * PreCondition: + * checkChiusuraPdg(pdg_det) genera una eccezione + * PostCondition: + * Lascia uscire l'eccezione generata + * Dettaglio caricato spesa + * PreCondition: + * PDG modificabile dall'utente, CATEGORIA = 'CAR', e viene richiesto di modificare una colonna diversa da colonna pagamenti (V) + * PostCondition: + * Genera una ApplicationException con il messaggio: "Per i dettagli di carico del serevnte solo la colonna pagamenti (V) puo' essere modificata" + */ + +public OggettoBulk modificaConBulk(UserContext userContext,OggettoBulk bulk) throws ComponentException { + Pdg_preventivo_detBulk pdgDett = (Pdg_preventivo_detBulk)bulk; + + if (Pdg_preventivo_detBulk.CAT_SCARICO.equals(pdgDett.getCategoria_dettaglio()) && + !Pdg_preventivo_detBulk.ST_NESSUNA_AZIONE.equals( pdgDett.getStato())) + throw new it.cnr.jada.comp.ApplicationException("Il dettaglio è già stato contrattato e non è più modificabile. Contattare il CDR servito"); + + // Richiesta CNR 137R Solo i dettagli di spesa, sotto certe condizioni, sono modificabili + if(pdgDett instanceof it.cnr.contab.pdg00.bulk.Pdg_preventivo_etr_detBulk && Pdg_preventivo_detBulk.CAT_CARICO.equals( pdgDett.getCategoria_dettaglio())) + throw new it.cnr.jada.comp.ApplicationException("Il dettaglio non è modificabile. Contattare il CDR servente"); + + try { + Pdg_preventivoBulk pdg = (Pdg_preventivoBulk)getHome(userContext, Pdg_preventivoBulk.class).findAndLock( + new Pdg_preventivoBulk( + pdgDett.getEsercizio(), + pdgDett.getCd_centro_responsabilita())); + + // 05/09/2003 + // Aggiunto controllo sulla chiusura dell'esercizio + if (isEsercizioChiuso(userContext,pdg)) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile modificare dettagli del pdg ad esercizio chiuso."); + + init(userContext,pdg,pdgDett); + + super.modificaConBulk(userContext, (OggettoBulk)pdgDett); + + validaVariazione(userContext, bulk); + validaVariazione(userContext, bulk); + + /* + * Il controllo che la somma degli importi aggregati sia positiva non deve avvenire + * per i dettagli provenienti da variazione al PDG non ancora in stato approvato + */ + if (!pdgDett.isDaVariazione()) + controllaAggregatoPdgDetPositivo(userContext,pdg,pdgDett); + else + { + Pdg_variazioneBulk pdgVar = (Pdg_variazioneBulk)getHome(userContext, Pdg_variazioneBulk.class).findByPrimaryKey( + new Pdg_variazioneBulk( + pdgDett.getPdg_variazione().getEsercizio(), + pdgDett.getPdg_variazione().getPg_variazione_pdg())); + if (pdgVar.isApprovata()) + controllaAggregatoPdgDetPositivo(userContext,pdg,pdgDett); + } + + return bulk; + } catch(OutdatedResourceException e) { + throw handleException(e); + } catch(PersistencyException e) { + throw handleException(e); + } catch(BusyResourceException e) { + throw handleException(e); + } +} +/** + * Richiesto cambiamento di stato, Pdg occupato + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg che risulta occupato (lock) + * PostCondition: + * Viene generata una BusyResourceException + * Richiesto cambiamento di stato, nuovo stato non compatibile con lo stato attuale + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg, ma lo stato specificato non è compatibile con lo stato + * attuale del pdg (secondo isStatoCompatibile()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Stato X non compatibile con l'attuale stato Y del Pdg" + * Richiesto cambiamento di stato, livello utente insufficiente + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg, ma il livello dell'utente non è sufficiente per effettuare l'operazione (confrontaLivelloResponsabilita() < 0) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Utente non abilitato ad operare sul PDG" + * Richiesto cambiamento di stato, modifica di stato non riuscita + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg e il passaggio di stato provoca qualche errore applicativo (secondo modificaStatoPdG_X_Y() per + * PostCondition: + * Viene lasciato uscire l'errore generato + * Richiesto cambiamento in stato C, esistono discrepanza sugli insiemi di linee attività + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg, nessuna delle altre precondizioni è verificata ma esistono discrepanze sugli importi entrate/spese legati a insiemi di linee di attività (secondo controllaDiscrepanzeInsiemeLa()) + * PostCondition: + * Viene effettuata la modifica di stato e viene restituito il messaggio di avvertimento "Esistono discrepanze tra gli importi entrate - spese legati ad insieme di l.a. " + * Richiesto cambiamento di stato da C a F + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, nessuna delle altre pecondizioni è verificata + * PostCondition: + * Viene creata la variazione di bilancio automatica per la spalmatura delle entrate CNR (creaRipartEntrate()) + * Normale + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, nessuna delle altre pecondizioni è verificata + * PostCondition: + * Viene creata la variazione di bilancio automatica per la spalmatura delle entrate CNR (creaRipartEntrate()) + */ + +public OggettoBulk modificaStatoPdG (UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ComponentException { + try { + Pdg_preventivoBulk oldPdg = (Pdg_preventivoBulk)getHome(userContext,pdg).findAndLock(pdg); + + // 05/09/2003 + // Aggiunto controllo sulla chiusura dell'esercizio + if (isEsercizioChiuso(userContext,pdg)) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile modificare lo stato del pdg ad esercizio chiuso."); + + String nuovoStato = pdg.getStato(); + String vecchioStato = oldPdg.getStato(); + int livelloResponsabilitaPdg = getLivelloResponsabilitaCDR(userContext, oldPdg.getCentro_responsabilita()); + // 09/06/2005 + // Aggiunto controllo sul cambiamento di stato da quello finale, obbligo l'utilizzo delle variazioni al PDG + if (vecchioStato.equals(Pdg_preventivoBulk.ST_F_CHIUSO_DFNT)) + throw new it.cnr.jada.comp.ApplicationException("Non è possibile modificare lo stato del pdg poichè è in chiusura definitiva."); + + // Controllo il nuovo stato del pdg è compatibile con lo stato attuale + if( !isStatoCompatibile(vecchioStato, livelloResponsabilitaPdg, nuovoStato) ) + throw new it.cnr.jada.comp.ApplicationException("Stato \"" + nuovoStato + "\" non compatibile con l'attuale stato \"" + vecchioStato + "\" del PdG"); + + CdrBulk cdrUtente = cdrFromUserContext(userContext); + int livelloResponsabilitaUtente = getLivelloResponsabilitaCDR(userContext,cdrUtente); + + // Controllo se il livello di responsabilità dell'utente è sufficiente per cambiare lo stato + // del pdg + if(confrontaLivelloResponsabilita(userContext, cdrUtente,pdg.getCentro_responsabilita(),livelloResponsabilitaUtente,livelloResponsabilitaPdg) < 0) + utenteNonAbilitato(); + + if(pdg.ST_CX_MODIFICA.equals(nuovoStato)) { + if (livelloResponsabilitaUtente == LV_NRUO) + utenteNonAbilitato(); + nuovoStato = Pdg_preventivoBulk.ST_C_CHIUSURA_II + livelloResponsabilitaUtente; + } + + // Invoco il metodo modificaStato_x_y() + it.cnr.jada.util.Introspector.invoke( + this, + "modificaStatoPdG_"+vecchioStato+"_"+nuovoStato, + new Object[] { + userContext, + cdrUtente, + pdg, + oldPdg, + new Integer(livelloResponsabilitaUtente), + new Integer(livelloResponsabilitaPdg) + }); + + oldPdg.setStato(nuovoStato); + oldPdg.setAnnotazioni(pdg.getAnnotazioni()); + oldPdg.setUser(userContext.getUser()); + updateBulk(userContext,oldPdg); + + oldPdg.setStatiKeys(loadStatiKeys(userContext, oldPdg)); + + // Passando da C a F devo creare la variazione di bilancio automatica per spalmatura entrate CNR + // Va fatta qui (non in modificaStatoPdG_C_F perchè lo stato del Pdg deve essere già F + if (Pdg_preventivoBulk.ST_C_CHIUSURA_II.equals(vecchioStato) && + Pdg_preventivoBulk.ST_F_CHIUSO_DFNT.equals(nuovoStato)) { + creaRipartEntrate(userContext, oldPdg); + } + + if (pdg.ST_C_CHIUSURA_II.equals(nuovoStato) && + controllaDiscrepanzeInsiemeLa(userContext,pdg)) + return asMTU(oldPdg,"Esistono discrepanze tra gli importi entrate - spese legati ad insieme di l.a. "); + + return oldPdg; + + } catch(java.lang.reflect.InvocationTargetException e) { + throw handleException(e.getTargetException()); + } catch(Throwable e) { + throw handleException(e); + } +} + +/* + * Richiesto cambiamento di stato da A a B + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da A ad B, pdg dipendenti non chiusi (stato <> C o F) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + */ +public Pdg_preventivoBulk modificaStatoPdG_A_B( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i pdg dipendenti siano in stato C + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II }); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da A a C, stato figli non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, pdg dipendenti non chiusi (stato <> C o F) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da A a C, dettagli scaricati non confermati + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" + * Richiesto cambiamento di stato da A a C, costi del dipendente non scaricati completamente + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, il cdr del pdg è di 1^ livello e i costi del dipendente dell'UO non sono stati scaricati completamente (secondo controllaScaricoCDPCompleto()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Costi del personale non ancora scaricati completamente!" + * Richiesto cambiamento di stato da A a C, i ricavi figurativi non quadrano + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" + * Richiesto cambiamento di stato da A a C + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da A ad C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata + * PostCondition: + * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) + */ +public Pdg_preventivoBulk modificaStatoPdG_A_C( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i pdg dipendenti siano in stato C + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II,pdg.ST_F_CHIUSO_DFNT }); + + // Controllo che i dettagli scaricati su altre UO siano stati confermati + controllaDettScarConfermati(userContext, oldPdg); + + // Controlla che tutti i dipendenti siano stati scaricati completamente sul PIANO DI GESTIONE del CDR di I livello o di AREA per chiudere definitivamente + controllaScaricoCDPCompleto(userContext,pdg); + + // Effettuo i controlli di quadratura dei ricavi figurativi + controllaQuadraturaRicaviFigurativi(userContext,pdg); + + // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area + inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da B a C, stato figli non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, pdg dipendenti non chiusi (stato <> C o F) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da B a C, dettagli scaricati non confermati + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" + * Richiesto cambiamento di stato da B a C, costi del dipendente non scaricati completamente + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, il cdr del pdg è di 1^ livello e i costi del dipendente dell'UO non sono stati scaricati completamente (secondo controllaScaricoCDPCompleto()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Costi del personale non ancora scaricati completamente!" + * Richiesto cambiamento di stato da B a C, i ricavi figurativi non quadrano + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" + * Richiesto cambiamento di stato da B a C + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da B a C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata + * PostCondition: + * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) + */ +public Pdg_preventivoBulk modificaStatoPdG_B_C( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i pdg dipendenti siano in stato C + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II,pdg.ST_F_CHIUSO_DFNT }); + + // Controllo che i dettagli scaricati su altre UO siano stati confermati + controllaDettScarConfermati(userContext, oldPdg); + + // Controlla che tutti i dipendenti siano stati scaricati completamente sul PIANO DI GESTIONE del CDR di I livello o di AREA per chiudere definitivamente + controllaScaricoCDPCompleto(userContext,pdg); + + // Effettuo i controlli di quadratura dei ricavi figurativi + controllaQuadraturaRicaviFigurativi(userContext,pdg); + + // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area + inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da C a C0, stato figli non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C ad C0, pdg dipendenti non chiusi (stato <> C) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da C a C0, stato padre non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C a C0, pdg padre in stato <> C0 + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da C a C0, livello responsabilità non compatbile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C a C0, l'utente NON appartiene al CDR dell'Amministrazione Centrale + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Utente non abilitato." + */ +public Pdg_preventivoBulk modificaStatoPdG_C_C0( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che l'utente abbia lo stesso livello del Ci richiesto + if(livelloResponsabilitaUtente != LV_AC) + utenteNonAbilitato(); + + // Controllo che il pdg padre sia in stato C0 + controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_C0_MODIFICA_AC }); + + // Controllo che i pdg figli siano in stato C + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II }); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da C a C1 + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C ad C1, pdg dipendenti non chiusi (stato <> C) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da C a C1 + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C a C1, pdg padre in stato <> C1 + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da C a C1, livello responsabilità non compatbile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C a C1, l'utente NON appartiene ad un CDR di 1^ livello + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Utente non abilitato." + */ +public Pdg_preventivoBulk modificaStatoPdG_C_C1( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che l'utente abbia lo stesso livello del Ci richiesto + if(livelloResponsabilitaUtente != LV_CDRI) + utenteNonAbilitato(); + + // Controllo che il pdg padre sia in stato C0 + controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_C1_MODIFC_CDRI }); + + // Controllo che i pdg figli siano in stato C + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II }); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da C a C2 + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C ad C2, pdg dipendenti non chiusi (stato <> C) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da C a C2 + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C a C2, pdg padre in stato <> C2 + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da C a C2, livello responsabilità non compatbile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C a C2, l'utente NON appartiene ad un CDR di 2^ livello (RUO) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Utente non abilitato." + */ +public Pdg_preventivoBulk modificaStatoPdG_C_C2( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che l'utente abbia lo stesso livello del Ci richiesto + if(livelloResponsabilitaUtente != LV_RUO) + utenteNonAbilitato(); + + // Controllo che il pdg padre sia in stato C0 + controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_C2_MODIFIC_RUO }); + + // Controllo che i pdg figli siano in stato C + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II }); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da C a D + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C a D, pdg padre in stato <> E + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + */ +public Pdg_preventivoBulk modificaStatoPdG_C_D( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controlla che il padre sia in stato E + controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_E_CHIUSO }); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da C a E + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C a E, pdg padre in stato <> E + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + */ +public Pdg_preventivoBulk modificaStatoPdG_C_E( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controlla che il padre sia in stato E + controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_E_CHIUSO }); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da C a F, stato figli non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, pdg dipendenti non chiusi (stato <> F) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da C a F, Bilancio Preventivo CNR non approvato + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, il Bilancio Preventivo CNR non è stato approvato (secondo controllaBilPrevCnrApprovato()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il bilancio preventivo CNR non risulta ancora approvato" + * Richiesto cambiamento di stato da C a F, Pdg aggregato aperto + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, il pdg del cdr di 1^ livello è ancora aperto (secondo controllaAggregatoChiuso) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il piano di gestione aggregato non è chiuso. Contattare il CDR di primo livello" + * Richiesto cambiamento di stato da C a F, esistono discrepanze nel Pdg Aggregato + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C ad F, il cdr del pdg possiede un pdg aggregato ed esistono discrepanze tra gli importi iniziali e quelli modificati nel pdg aggregato (secondo controllaDiscrepanzeAggregato()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Sono presenti importi complessivi non compatibili con i dati impostati dall'ente." + */ +public Pdg_preventivoBulk modificaStatoPdG_C_F( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i pdg dipendenti siano in stato F + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_F_CHIUSO_DFNT }); + + // Verificare che il bilancio finanziario CNR sia approvato (Richiesta n. 56) + controllaBilPrevCnrApprovato(userContext, pdg); + + // Verificare che l'aggregato sia CHIUSO in stato B + controllaAggregatoChiuso(userContext,pdg); + + // Controllo della presenza di discrepanze nell'aggregato + controllaDiscrepanzeAggregato(userContext,pdg,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da C0 a C, livello responsabilità non compatbile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C0 a C, l'utente NON appartiene al CDR dell'Amministrazione Centrale + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Utente non abilitato." + * Richiesto cambiamento di stato da C0 a C + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C0 a C, nessun'altra precondizione è verificata + * PostCondition: + * Viene invocato modificaStatoPdG_Ci_C + */ +public Pdg_preventivoBulk modificaStatoPdG_C0_C( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + if(livelloResponsabilitaUtente > LV_AC) + utenteNonAbilitato(); + + // Effettuo i controlli comuni a tutti i livelli Ci + modificaStatoPdG_Ci_C(userContext,cdrUtente,pdg,oldPdg,livelloResponsabilitaUtente,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da C1 a C, livello responsabilità non compatbile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C1 a C, l'utente appartiene ad un CDR di livello RUO o NRUO + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Utente non abilitato." + * Richiesto cambiamento di stato da C1 a C + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C1 a C, nessun'altra precondizione è verificata + * PostCondition: + * Viene invocato modificaStatoPdG_Ci_C + */ +public Pdg_preventivoBulk modificaStatoPdG_C1_C( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + if(livelloResponsabilitaUtente > LV_CDRI) + utenteNonAbilitato(); + + // Effettuo i controlli comuni a tutti i livelli Ci + modificaStatoPdG_Ci_C(userContext,cdrUtente,pdg,oldPdg,livelloResponsabilitaUtente,livelloResponsabilitaPdg); + + return pdg; +} +/* + * Richiesto cambiamento di stato da C2 a C, livello responsabilità non compatbile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C2 a C, l'utente appartiene ad un CDR di livello NRUO + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Utente non abilitato." + * Richiesto cambiamento di stato da C2 a C + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C2 a C, nessun'altra precondizione è verificata + * PostCondition: + * Viene invocato modificaStatoPdG_Ci_C + */ +public Pdg_preventivoBulk modificaStatoPdG_C2_C( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + if(livelloResponsabilitaUtente > LV_RUO) + utenteNonAbilitato(); + + // Effettuo i controlli comuni a tutti i livelli Ci + modificaStatoPdG_Ci_C(userContext,cdrUtente,pdg,oldPdg,livelloResponsabilitaUtente,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da Ci a C, stato figli non compatibili + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da C0,C1,C2 ad C, pdg dipendenti non chiusi (stato <> C o F) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da Ci a C, i ricavi figurativi non quadrano + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da Ci a C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" + * Richiesto cambiamento di stato da Ci a C + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da Ci a C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata + * PostCondition: + * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) + */ +public Pdg_preventivoBulk modificaStatoPdG_Ci_C( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i pdg dipendenti siano in stato C + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II,pdg.ST_F_CHIUSO_DFNT }); + + // Controllo che i dettagli scaricati su altre UO siano stati confermati + controllaDettScarConfermati(userContext, oldPdg); + + // Effettuo i controlli di quadratura dei ricavi figurativi + controllaQuadraturaRicaviFigurativi(userContext,pdg); + + // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area + inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da D a C, dettagli scaricati non confermati + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da D a C, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" + * Richiesto cambiamento di stato da D a C, costi del dipendente non scaricati completamente + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da D a C, il cdr del pdg è di 1^ livello e i costi del dipendente dell'UO non sono stati scaricati completamente (secondo controllaScaricoCDPCompleto()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Costi del personale non ancora scaricati completamente!" + * Richiesto cambiamento di stato da D a C, i ricavi figurativi non quadrano + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da D a C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" + * Richiesto cambiamento di stato da D a C + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da D a C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata + * PostCondition: + * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) + */ +public Pdg_preventivoBulk modificaStatoPdG_D_C( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i dettagli scaricati su altre UO siano stati confermati + controllaDettScarConfermati(userContext, oldPdg); + + // Controlla che tutti i dipendenti siano stati scaricati completamente sul PIANO DI GESTIONE del CDR di I livello o di AREA per chiudere definitivamente + controllaScaricoCDPCompleto(userContext,pdg); + + // Effettuo i controlli di quadratura dei ricavi figurativi + controllaQuadraturaRicaviFigurativi(userContext,pdg); + + // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area + inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da D a E, stato padre non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da D a E, pdg padre in stato <> E + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + */ +public Pdg_preventivoBulk modificaStatoPdG_D_E( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controlla che il padre sia in stato E + controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_E_CHIUSO }); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da E a C, dettagli scaricati non confermati + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da E a C, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" + * Richiesto cambiamento di stato da E a C, costi del dipendente non scaricati completamente + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da E a C, il cdr del pdg è di 1^ livello e i costi del dipendente dell'UO non sono stati scaricati completamente (secondo controllaScaricoCDPCompleto()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Costi del personale non ancora scaricati completamente!" + * Richiesto cambiamento di stato da E a C, i ricavi figurativi non quadrano + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da E a C, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" + * Richiesto cambiamento di stato da E a C + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da E a C, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata + * PostCondition: + * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) + */ +public Pdg_preventivoBulk modificaStatoPdG_E_C( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i dettagli scaricati su altre UO siano stati confermati + controllaDettScarConfermati(userContext, oldPdg); + + // Controlla che tutti i dipendenti siano stati scaricati completamente sul PIANO DI GESTIONE del CDR di I livello o di AREA per chiudere definitivamente + controllaScaricoCDPCompleto(userContext,pdg); + + // Effettuo i controlli di quadratura dei ricavi figurativi + controllaQuadraturaRicaviFigurativi(userContext,pdg); + + // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area + inizializzaAggregatoPDG(userContext, pdg,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da E a D, stato figli non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da E ad D, pdg dipendenti non chiusi (stato <> C o F) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da E a D, dettagli scaricati non confermati + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da E a D, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" + */ +public Pdg_preventivoBulk modificaStatoPdG_E_D( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i pdg dipendenti siano in stato C + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_C_CHIUSURA_II, pdg.ST_F_CHIUSO_DFNT }); + + // Controllo che i dettagli scaricati su altre UO siano stati confermati + controllaDettScarConfermati(userContext, oldPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da F a G, stato padre non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da F a G, pdg padre in stato <> F o G + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da F a G, Pdg aggregato aperto + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da F a G, il pdg del cdr di 1^ livello è ancora aperto (secondo controllaAggregatoChiuso) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il piano di gestione aggregato non è chiuso. Contattare il CDR di primo livello" + * Richiesto cambiamento di stato da F a G, bilancio preventivo del cds non ancora approvato + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da F a G, il bilancio preventivo del cds a cui appartiene il cdr non è ancora approvato (secondo controllaPreventivoCdsApprovato) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il bilancio preventivo del cds non è approvato." + */ +public Pdg_preventivoBulk modificaStatoPdG_F_G( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i pdg padri siano in stato F o G + controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_F_CHIUSO_DFNT, pdg.ST_G_APERTURA_PER_VARIAZIONI }); + + // Controllo che il pdg aggregato del cdr di 1° livello sia chiuso + controllaAggregatoChiuso(userContext,pdg); + + // Controllo che il preventivo finanziario del cds sia approvato + controllaBilancioPreventivoCdsApprovato(userContext,pdg.getCentro_responsabilita()); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da G a H, stato figli non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da G a H, pdg dipendenti in stato <> F o M + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + */ +public Pdg_preventivoBulk modificaStatoPdG_G_H( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i pdg dipendenti siano in stato F o M + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_F_CHIUSO_DFNT, pdg.ST_M_MODIFICATO_PER_VARIAZIONI }); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da G a M, dettagli scaricati non confermati + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da G a M, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" + * Richiesto cambiamento di stato da G a M, i ricavi figurativi non quadrano + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da G a M, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" + * Richiesto cambiamento di stato da G a M + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da G a M, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata + * PostCondition: + * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) + */ +public Pdg_preventivoBulk modificaStatoPdG_G_M( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i dettagli scaricati su altre UO siano stati confermati + controllaDettScarConfermati(userContext, oldPdg); + + // Effettuo i controlli di quadratura dei ricavi figurativi + controllaQuadraturaRicaviFigurativi(userContext,pdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da H a M, dettagli scaricati non confermati + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da H a M, esiste qualche dettaglio scaricato su altra UO non ancora confermato o annullato (secondo controllaDettScarConfermati()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Esiste qualche spesa scaricata verso altro CDR o UO non ancora confermata o annullata" + * Richiesto cambiamento di stato da H a M, i ricavi figurativi non quadrano + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da H a M, il controllo dei ricavi figurativi non va a buon fine (secondo controllaQuadraturaRicaviFigurativi())) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Mancata quadratura dei ricavi figurativi!" + * Richiesto cambiamento di stato da H a M + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da H a M, il cdr del pdg possiede un pdg aggregato e nessun'altra precondizione verificata + * PostCondition: + * Viene aggiornato il pdg aggregato corrispondente con i totali aggregati del pdg e dei suoi figli (inizializzaAggregatoPDG()) + */ +public Pdg_preventivoBulk modificaStatoPdG_H_M( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che i dettagli scaricati su altre UO siano stati confermati + controllaDettScarConfermati(userContext, oldPdg); + + // Effettuo i controlli di quadratura dei ricavi figurativi + controllaQuadraturaRicaviFigurativi(userContext,pdg); + + // Se passo in stato M su un pdg di un cdr di 1^ livello + // e l'aggregato è ancora in stato B, forzo il passaggio dell'aggregato + // in stato M + if (livelloResponsabilitaPdg == 1 || + isCdrArea(userContext,pdg.getCentro_responsabilita())) + try { + Pdg_aggregatoBulk pdg_aggregato = (Pdg_aggregatoBulk)getHome(userContext,Pdg_aggregatoBulk.class).findAndLock(new Pdg_aggregatoBulk(pdg.getCd_centro_responsabilita(),pdg.getEsercizio())); + if (pdg_aggregato.STATO_B.equals(pdg_aggregato.getStato())) { + pdg_aggregato.setStato(pdg_aggregato.STATO_M); + pdg_aggregato.setUser(userContext.getUser()); + getHome(userContext,pdg_aggregato).update(pdg_aggregato, userContext); + } + } catch(OutdatedResourceException e) { + throw handleException(e); + } catch(BusyResourceException e) { + throw handleException(e); + } catch(PersistencyException e) { + throw handleException(e); + } + + // Aggiorno il pdg aggregato (solo per cdr 1° livello o cdr figli di uo area + inizializzaAggregatoPDGPerVariazioni(userContext, pdg,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da M a F, stato figli non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da M a F, pdg dipendenti in stato <> F + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da M a F, stato aggregato non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da M a F, il pdg aggregato del cdr di 1^ livello è in stato diverso da E + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Stato del pdg aggregato non compatibile" + * Richiesto cambiamento di stato da M a F, esistono discrepanze nel Pdg Aggregato + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da M ad F, il cdr del pdg possiede un pdg aggregato ed esistono discrepanze tra gli importi iniziali e quelli modificati nel pdg aggregato (secondo controllaDiscrepanzeAggregatoPerVariazioni()) + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Sono presenti importi complessivi non compatibili con i dati impostati dall'ente." + * Richiesto cambiamento di stato da M a F + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da M ad F e nessun'altra precondizione è verificata + * PostCondition: + * Viene invocato trasformDettagliVariazioneInDefinitivi() per convertire i dettagli del pdg da dettagli con origine 'MOD' in dettagli con provenienza 'DIR' + */ +public Pdg_preventivoBulk modificaStatoPdG_M_F( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che il pdg aggregato del cdr di 1° livello sia in stato "E" + controllaStatoAggregato(userContext,pdg,it.cnr.contab.prevent00.bulk.Pdg_aggregatoBulk.STATO_E); + + // Controllo che i pdg dipendenti siano in stato F + controllaStatoPdgFigli(userContext,pdg,new String[] { pdg.ST_F_CHIUSO_DFNT }); + + // Controllo della presenza di discrepanze nell'aggregato + controllaDiscrepanzeAggregatoPerVariazioni(userContext,pdg,livelloResponsabilitaPdg); + + return pdg; +} + +/* + * Richiesto cambiamento di stato da M a G, stato figli non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da M a G, pdg padre in stato <> G + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + * Richiesto cambiamento di stato da M a G, stato padre non compatibile + * PreCondition: + * L'utente ha richiesto il cambiamento di stato di un pdg da M a G, pdg padre in stato <> E + * PostCondition: + * Viene generata una ApplicationException con il messaggio "Il pdg del cdr XXX.XXX.XXX è in stato Y che non è compatibile con l'operazione richiesta." + */ +public Pdg_preventivoBulk modificaStatoPdG_M_G( + UserContext userContext, + CdrBulk cdrUtente, + Pdg_preventivoBulk pdg, + Pdg_preventivoBulk oldPdg, + int livelloResponsabilitaUtente, + int livelloResponsabilitaPdg) throws it.cnr.jada.comp.ComponentException { + + // Controllo che il pdg aggregato del cdr di 1° livello sia in stato "E" + controllaStatoAggregato(userContext,pdg,it.cnr.contab.prevent00.bulk.Pdg_aggregatoBulk.STATO_E); + + // Controllo che il pdg padre sia già in stato "G" + controllaStatoPdgPadri(userContext,pdg,livelloResponsabilitaPdg,false,new String[] { pdg.ST_G_APERTURA_PER_VARIAZIONI }); + + return pdg; +} + +//^^@@ +/** + * Tutti controlli superati + * PreCondition: + * Viene richiesto il ribaltamento dei costi del Piano di Gestione del CdR specificato all'area di ricerca a cui afferisce. Il bilancio del CNR è già stato approvato + * PostCondition: + * La procedura Oracle CNRCTB053.ribaltaSuAreaPDG viene eseguita per l'anno di esercizio ed il CdR specificati. + */ +//^^@@ + public Pdg_preventivoBulk ribaltaCostiPdGArea(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ApplicationException, it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ),"{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB053.ribaltaSuAreaPDG(?,?,?)}",false,this.getClass()); + cs.setObject( 1, pdg.getEsercizio() ); + cs.setString( 2, pdg.getCd_centro_responsabilita()); + cs.setObject( 3, userContext.getUser()); + try { + lockBulk(userContext,pdg); + cs.executeQuery(); + return caricaPdg(userContext,pdg.getCentro_responsabilita()); + } catch (Throwable e) { + throw handleException(pdg,e); + } finally { + cs.close(); + } + } catch (java.sql.SQLException e) { + // Gestisce eccezioni SQL specifiche (errori di lock,...) + throw handleSQLException(e); + } + } + +//^^@@ +/** + * default + * PreCondition: + * Viene richiesto l'esecuzione dello scarico dei costi del dipendente per un pdg + * PostCondition: + * Viene invocata la stored procedure CNRCTB060.scaricaCDPSuPdg + */ +//^^@@ + public Pdg_preventivoBulk scaricaCDPSuPdg(UserContext userContext, Pdg_preventivoBulk pdg) throws it.cnr.jada.comp.ApplicationException, it.cnr.jada.comp.ComponentException { + try { + LoggableStatement cs = new LoggableStatement(getConnection( userContext ), "{call " + it.cnr.jada.util.ejb.EJBCommonServices.getDefaultSchema() + + "CNRCTB060.scaricaCDPSuPdg(?,?,?)}",false,this.getClass()); + cs.setObject( 1, pdg.getEsercizio() ); + cs.setString( 2, pdg.getCd_centro_responsabilita()); + cs.setObject( 3, userContext.getUser()); + try { + lockBulk(userContext,pdg); + cs.executeQuery(); + return caricaPdg(userContext,pdg.getCentro_responsabilita()); + } catch (Throwable e) { + throw handleException(pdg,e); + } finally { + cs.close(); + } + } catch (java.sql.SQLException e) { + // Gestisce eccezioni SQL specifiche (errori di lock,...) + throw handleSQLException(e); + } +} + +/** + * Filtra i soli dettagli non annullati + */ +protected Query select(UserContext userContext,CompoundFindClause clauses,OggettoBulk bulk) throws ComponentException, it.cnr.jada.persistency.PersistencyException { + Pdg_preventivo_detBulk pdg_det = (Pdg_preventivo_detBulk)bulk; + + SQLBuilder sql = (SQLBuilder)super.select(userContext,clauses,bulk); + + sql.addClause("AND", "stato", sql.NOT_EQUALS, "N"); + + return sql; +} +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco dei centri di responsabilità compatibili per un dettaglio di spesa verso altra UO o di costi senza spese con un elenco di clausole specificate + * PostCondition: + * Viene restituito una query sui centri di spesa con le clausole specificate e una clausola sull'esercizio uguale a quello del dettaglio di spesa specificato + */ +//^^@@ + + public SQLBuilder selectAltro_cdrByClause (UserContext userContext, + Pdg_preventivo_spe_detBulk dettaglio_pdg, + CdrBulk cdr, + CompoundFindClause clause) + throws ComponentException, PersistencyException + { + if (clause == null) clause = ((OggettoBulk)cdr).buildFindClauses(null); + + SQLBuilder sql = getHome(userContext, cdr, "V_CDR_VALIDO").createSQLBuilder(); + sql.addSQLClause("AND", "CD_CENTRO_RESPONSABILITA", sql.NOT_EQUALS, dettaglio_pdg.getCd_centro_responsabilita()); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + + if (clause != null) sql.addClause(clause); + + return sql; + } + /** + * Normale + * PreCondition: + * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente + * PostCondition: + * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato + */ +// ^^@@ + public SQLBuilder selectCdsForPrintByClause (UserContext userContext, + Stampa_vpg_bilancio_riclassVBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException + { + SQLBuilder sql = getHome(userContext, cds.getClass(), "V_CDS_VALIDO").createSQLBuilder(); + sql.addClause( clause ); + sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); + return sql; + } + public SQLBuilder selectCdsForPrintByClause (UserContext userContext, + Stampa_pdg_etr_speVBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException + { + SQLBuilder sql = getHome(userContext, cds.getClass(), "V_CDS_VALIDO").createSQLBuilder(); + sql.addClause( clause ); + sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); + return sql; + } + public SQLBuilder selectCdsForPrintByClause (UserContext userContext, + Stampa_libro_giornaleBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException + { + SQLBuilder sql = getHome(userContext, cds.getClass(), "V_CDS_VALIDO").createSQLBuilder(); + sql.addClause( clause ); + sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); + return sql; + } + + public SQLBuilder selectCdsForPrintByClause (UserContext userContext, Stampa_situazione_analitica_x_GAEBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException + { + SQLBuilder sql = ((CdsHome) getHome(userContext, cds.getClass(),"V_CDS_VALIDO")).createSQLBuilderIncludeEnte(); + sql.addClause( clause ); + + String cd_cds_scrivania = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); + it.cnr.contab.config00.sto.bulk.CdsHome cds_home = (CdsHome)getHome(userContext, CdsBulk.class); + it.cnr.contab.config00.sto.bulk.CdsBulk cds_scrivania = (CdsBulk)cds_home.findByPrimaryKey(new CdsBulk(cd_cds_scrivania)); + + if (cds_scrivania.getCd_tipo_unita().equals(it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_ENTE)){ + sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); + } + else{ + sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); + sql.addSQLClause("AND", "CD_UNITA_ORGANIZZATIVA", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getCd_cds()); + sql.addClause("AND","FL_CDS",sql.EQUALS, new Boolean(true) ); + } + return sql; + } + + public SQLBuilder selectCdsForPrintByClause (UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException + { + SQLBuilder sql = ((CdsHome) getHome(userContext, cds.getClass(),"V_CDS_VALIDO")).createSQLBuilderIncludeEnte(); + sql.addClause( clause ); + + String cd_cds_scrivania = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); + it.cnr.contab.config00.sto.bulk.CdsHome cds_home = (CdsHome)getHome(userContext, CdsBulk.class); + it.cnr.contab.config00.sto.bulk.CdsBulk cds_scrivania = (CdsBulk)cds_home.findByPrimaryKey(new CdsBulk(cd_cds_scrivania)); + + if (cds_scrivania.getCd_tipo_unita().equals(it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_ENTE)){ + sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); + } + else{ + sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); + sql.addSQLClause("AND", "CD_UNITA_ORGANIZZATIVA", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getCd_cds()); + sql.addClause("AND","FL_CDS",sql.EQUALS, new Boolean(true) ); + } + return sql; + } + + public SQLBuilder selectElementoVoceForPrintByClause(UserContext userContext, Stampa_pdg_etr_speVBulk stampa, Elemento_voceBulk elementoVoce, CompoundFindClause clauses) throws ComponentException { + + Elemento_voceHome home = (Elemento_voceHome)getHome(userContext, elementoVoce); + SQLBuilder sql = home.createSQLBuilder(); + sql.addClause("AND","esercizio",sql.EQUALS, CNRUserContext.getEsercizio(userContext)); + sql.addClause("AND","fl_partita_giro", sql.EQUALS, Boolean.FALSE); + sql.addClause("AND","ti_elemento_voce", sql.EQUALS, home.TIPO_CAPITOLO); + sql.addClause("AND","ti_gestione", sql.EQUALS, stampa.getTi_etr_spe()); + if(stampa.getTi_etr_spe().equals(Stampa_pdg_etr_speVBulk.TIPO_ENTRATA)) + sql.addClause("AND","ti_appartenenza", sql.EQUALS, home.APPARTENENZA_CNR); + else + sql.addClause("AND","ti_appartenenza", sql.EQUALS, home.APPARTENENZA_CDS); + sql.addClause(clauses); + return sql; + } + public SQLBuilder selectProgettoForPrintByClause (UserContext userContext, + Stampa_pdg_etr_speVBulk stampa, ProgettoBulk progetto, CompoundFindClause clause) throws ComponentException, PersistencyException + { + ProgettoHome progettohome = (ProgettoHome)getHome(userContext, ProgettoBulk.class,"V_PROGETTO_PADRE"); + SQLBuilder sql = progettohome.createSQLBuilder(); + sql.addClause( clause ); + sql.addSQLClause("AND", "PG_PROGETTO_PADRE", sql.ISNULL,null); + // Se uo 999.000 in scrivania: visualizza tutti i progetti + Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHome( userContext, Unita_organizzativa_enteBulk.class).findAll().get(0); + if (!((CNRUserContext) userContext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa())){ + sql.addSQLExistsClause("AND",progettohome.abilitazioniProgetti(userContext)); + } + return sql; + } + public SQLBuilder selectDipartimentoForPrintByClause (UserContext userContext, + Stampa_pdg_etr_speVBulk stampa, DipartimentoBulk dipartimento, CompoundFindClause clause) throws ComponentException, PersistencyException + { + SQLBuilder sql = getHome(userContext, dipartimento.getClass()).createSQLBuilder(); + java.sql.Timestamp lastDayOfYear = it.cnr.contab.doccont00.comp.DateServices.getLastDayOfYear(CNRUserContext.getEsercizio(userContext)); + sql.addClause("AND", "dt_istituzione", sql.LESS, lastDayOfYear); + sql.openParenthesis("AND"); + sql.addClause("AND", "dt_soppressione", sql.GREATER_EQUALS, lastDayOfYear); + sql.addClause("OR","dt_soppressione",sql.ISNULL,null); + sql.closeParenthesis(); + sql.addClause( clause ); + return sql; + } + public SQLBuilder selectDipartimentoByClause (UserContext userContext, Stampa_rendiconto_finanziarioVBulk stampa, DipartimentoBulk dipartimento, CompoundFindClause clause) throws ComponentException, PersistencyException{ + SQLBuilder sql = getHome(userContext, dipartimento.getClass()).createSQLBuilder(); + java.sql.Timestamp lastDayOfYear = it.cnr.contab.doccont00.comp.DateServices.getLastDayOfYear(CNRUserContext.getEsercizio(userContext)); + sql.addClause("AND", "dt_istituzione", sql.LESS, lastDayOfYear); + sql.openParenthesis("AND"); + sql.addClause("AND", "dt_soppressione", sql.GREATER_EQUALS, lastDayOfYear); + sql.addClause("OR","dt_soppressione",sql.ISNULL,null); + sql.closeParenthesis(); + sql.addClause( clause ); + return sql; + } + public SQLBuilder selectCdsByClause (UserContext userContext,Stampa_rendiconto_finanziarioVBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException{ + SQLBuilder sql = getHome(userContext, cds.getClass(), "V_CDS_VALIDO").createSQLBuilder(); + sql.addClause( clause ); + sql.addSQLClause("AND", "ESERCIZIO", SQLBuilder.EQUALS, ((it.cnr.contab.utenze00.bp.CNRUserContext) userContext).getEsercizio()); + return sql; + } + + /** + * Normale + * PreCondition: + * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente + * PostCondition: + * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato + */ +// ^^@@ + public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, + Stampa_vpg_bilancio_riclassVBulk stampa, it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException + { + if (clause == null) clause = uo.buildFindClauses(null); + + SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdsForPrint().getCd_unita_organizzativa()); + + if (clause != null) sql.addClause(clause); + return sql; + } + public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, + Stampa_pdg_etr_speVBulk stampa, it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException + { + if (clause == null) clause = uo.buildFindClauses(null); + + SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdsForPrint().getCd_unita_organizzativa()); + + if (clause != null) sql.addClause(clause); + return sql; + } + public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, + Stampa_libro_giornaleBulk stampa, it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException + { + if (clause == null) clause = uo.buildFindClauses(null); + + SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdsForPrint().getCd_unita_organizzativa()); + + if (clause != null) sql.addClause(clause); + return sql; + } + + public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, + Stampa_situazione_analitica_x_GAEBulk stampa, Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException + { + String cd_cds_scrivania = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); + it.cnr.contab.config00.sto.bulk.CdsHome cds_home = (CdsHome)getHome(userContext, CdsBulk.class); + it.cnr.contab.config00.sto.bulk.CdsBulk cds_scrivania = (CdsBulk)cds_home.findByPrimaryKey(new CdsBulk(cd_cds_scrivania)); + +// if (!cds_scrivania.getCd_tipo_unita().equals(Tipo_unita_organizzativaHome.TIPO_UO_ENTE)){ + if (clause == null) clause = uo.buildFindClauses(null); + + SQLBuilder sql = ((Unita_organizzativaHome) getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA")).createSQLBuilderEsteso(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdCdsForPrint()); + + if (clause != null) sql.addClause(clause); + return sql; + /* } + else { + if(stampa.getCdCdsForPrint().equals(cd_cds_scrivania)){ + if (clause == null) clause = uo.buildFindClauses(null); + + SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + + if (clause != null) sql.addClause(clause); + return sql; + } + else { + if (clause == null) clause = uo.buildFindClauses(null); + + SQLBuilder sql = getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA").createSQLBuilder(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdCdsForPrint()); + + if (clause != null) sql.addClause(clause); + return sql; + } + }*/ + + } + + public SQLBuilder selectUoForPrintByClause (CNRUserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, Unita_organizzativaBulk uo, CompoundFindClause clause) throws ComponentException, PersistencyException { + String cd_cds_scrivania = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); + it.cnr.contab.config00.sto.bulk.CdsHome cds_home = (CdsHome)getHome(userContext, CdsBulk.class); + it.cnr.contab.config00.sto.bulk.CdsBulk cds_scrivania = (CdsBulk)cds_home.findByPrimaryKey(new CdsBulk(cd_cds_scrivania)); + + if (clause == null) + clause = uo.buildFindClauses(null); + + SQLBuilder sql = ((Unita_organizzativaHome) getHome(userContext, uo, "V_UNITA_ORGANIZZATIVA_VALIDA")).createSQLBuilderEsteso(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + sql.addSQLClause("AND", "CD_UNITA_PADRE", sql.EQUALS, stampa.getCdCdsForPrint()!=null?stampa.getCdCdsForPrint():"*"); + + if (clause != null) + sql.addClause(clause); + return sql; + } + + public SQLBuilder selectGaeForPrintByClause(UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, it.cnr.contab.config00.latt.bulk.WorkpackageBulk gae, CompoundFindClause clause) throws ComponentException, PersistencyException { + if (clause == null) + clause = ((OggettoBulk)gae).buildFindClauses(null); + + SQLBuilder sql = getHome(userContext,gae, "V_LINEA_ATTIVITA_VALIDA").createSQLBuilder(); + if (clause != null) + sql.addClause(clause); + + sql.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO", SQLBuilder.EQUALS, CNRUserContext.getEsercizio(userContext)); + + if (stampa.getPgProgettoForPrint()!=null) + sql.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.PG_PROGETTO", SQLBuilder.EQUALS, stampa.getPgProgettoForPrint()); + + if (stampa.getCdResponsabileGaeForPrint()!=null) + sql.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.CD_RESPONSABILE_TERZO", SQLBuilder.EQUALS, stampa.getCdResponsabileGaeForPrint()); + + sql.addTableToHeader("V_STRUTTURA_ORGANIZZATIVA"); + sql.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.ESERCIZIO", "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO"); + sql.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.CD_ROOT", "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA"); + + sql.addSQLClause("AND", "V_STRUTTURA_ORGANIZZATIVA.CD_TIPO_LIVELLO", SQLBuilder.EQUALS, V_struttura_organizzativaHome.LIVELLO_CDR); + sql.addSQLClause("AND", "V_STRUTTURA_ORGANIZZATIVA.CD_UNITA_ORGANIZZATIVA", SQLBuilder.EQUALS, stampa.getCdUoForPrint()); + + return sql; + } + + public SQLBuilder selectResponsabileGaeForPrintByClause(UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, TerzoBulk responsabile, CompoundFindClause clause) throws ComponentException, PersistencyException { + if (clause == null) + clause = ((OggettoBulk)responsabile).buildFindClauses(null); + + SQLBuilder sql = getHome(userContext, responsabile).createSQLBuilder(); + if (clause != null) + sql.addClause(clause); + + SQLBuilder sqlExist = getHome(userContext,WorkpackageBulk.class, "V_LINEA_ATTIVITA_VALIDA").createSQLBuilder(); + sqlExist.addSQLJoin("V_LINEA_ATTIVITA_VALIDA.CD_RESPONSABILE_TERZO", "TERZO.CD_TERZO"); + sqlExist.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO", SQLBuilder.EQUALS, CNRUserContext.getEsercizio(userContext)); + + if (stampa.getPgProgettoForPrint()!=null) + sqlExist.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.PG_PROGETTO", SQLBuilder.EQUALS, stampa.getPgProgettoForPrint()); + + if (stampa.getCdGaeForPrint()!=null) + sqlExist.addSQLClause("AND", "V_LINEA_ATTIVITA_VALIDA.CD_LINEA_ATTIVITA", SQLBuilder.EQUALS, stampa.getCdGaeForPrint()); + + sqlExist.addTableToHeader("V_STRUTTURA_ORGANIZZATIVA"); + sqlExist.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.ESERCIZIO", "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO"); + sqlExist.addSQLJoin("V_STRUTTURA_ORGANIZZATIVA.CD_ROOT", "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA"); + + sqlExist.addSQLClause("AND", "V_STRUTTURA_ORGANIZZATIVA.CD_TIPO_LIVELLO", SQLBuilder.EQUALS, V_struttura_organizzativaHome.LIVELLO_CDR); + sqlExist.addSQLClause("AND", "V_STRUTTURA_ORGANIZZATIVA.CD_UNITA_ORGANIZZATIVA", SQLBuilder.EQUALS, stampa.getCdUoForPrint()); + + sql.addSQLExistsClause("AND",sqlExist); + + return sql; + } + +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente + * PostCondition: + * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato + */ +//^^@@ +public SQLBuilder selectCdrForPrintByClause (UserContext userContext, + Stampa_analitica_entrate_ldaBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException +{ + SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); + if(clause != null) + aSQL.addClause(clause); + return aSQL; +} + +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente + * PostCondition: + * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato + */ +//^^@@ +public SQLBuilder selectCdrForPrintByClause (UserContext userContext, + Stampa_analitica_spese_ldaBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException +{ + SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); + if(clause != null) + aSQL.addClause(clause); + return aSQL; +} + +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente + * PostCondition: + * Viene restituito una query sui cdr con le clausole specificate e una clausolOrdineAcqComponentOrdineAcqComponenta sull'esercizio uguale a quello del pdg specificato + */ +//^^@@ +public SQLBuilder selectCdrForPrintByClause (UserContext userContext, + Stampa_sintetica_entrate_ldaBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException +{ + SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); + if(clause != null) + aSQL.addClause(clause); + return aSQL; +} + +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente + * PostCondition: + * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato + */ +//^^@@ +public SQLBuilder selectCdrForPrintByClause (UserContext userContext, + Stampa_sintetica_spese_ldaBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException +{ + SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); + if(clause != null) + aSQL.addClause(clause); + return aSQL; +} + +public SQLBuilder selectCdrForPrintByClause (UserContext userContext, Stampa_situazione_analitica_x_GAEBulk stampa, CdrBulk cdr, CompoundFindClause clause) throws ComponentException, PersistencyException + { + SQLBuilder aSQL = (listaCdrPdGPerUtenteIncludeEnte (userContext)); + if(clause != null) + aSQL.addClause(clause); + aSQL.addSQLClause("AND","CD_UNITA_ORGANIZZATIVA",SQLBuilder.EQUALS,stampa.getCdUoForPrint()); + return aSQL; + } + +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente + * PostCondition: + * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato + */ +//^^@@ +public SQLBuilder selectCdsByClause (UserContext userContext, + StampaRendFinCNRVBulk stampa, it.cnr.contab.config00.sto.bulk.CdsBulk cds, CompoundFindClause clause) throws ComponentException, PersistencyException +{ + it.cnr.contab.config00.sto.bulk.CdsHome home = (it.cnr.contab.config00.sto.bulk.CdsHome)getHome(userContext, it.cnr.contab.config00.sto.bulk.CdsBulk.class); + + SQLBuilder sql = home.createSQLBuilder(); + sql.addClause(clause); + + return sql; +} +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco dei centri di responsabilità compatibili con il livello di responsabilità dell'utente + * PostCondition: + * Viene restituito una query sui cdr con le clausole specificate e una clausola sull'esercizio uguale a quello del pdg specificato + */ +//^^@@ + + public SQLBuilder selectCentro_responsabilitaByClause (UserContext userContext, + Pdg_preventivoBulk pdg, + CdrBulk cdr, + CompoundFindClause clause) + throws ComponentException, PersistencyException + { + SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); + if(clause != null) + aSQL.addClause(clause); + return aSQL; + } + +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco degli elementi voce compatibili per il dettaglio di entrata specificato con un elenco di clausole specificate + * PostCondition: + * Viene restituita una query sulla vista V_ELEMENTO_VOCE_PDG_ETR che contiene le clausole specificate più la clausola CD_NATURA = dettaglioSpesa.cd_natura + * Se il CDR non appartiene alla SAC, viene imposta l'ulteriore condizione che la voce del piano non sia riservata SAC + */ + +public SQLBuilder selectElemento_voceByClause(UserContext userContext, + Pdg_preventivo_etr_detBulk dettaglioEntrata, + Elemento_voceBulk elementoVoce, + CompoundFindClause clause) +throws ComponentException, PersistencyException +{ + if (clause == null) clause = ((OggettoBulk)elementoVoce).buildFindClauses(null); + + SQLBuilder sql = getHome(userContext, elementoVoce,"V_ELEMENTO_VOCE_PDG_ETR").createSQLBuilder(); + if(clause != null) sql.addClause(clause); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + + sql.openParenthesis("AND"); + sql.addSQLClause("OR", "FL_PARTITA_GIRO", sql.ISNULL, null); + sql.addSQLClause("OR", "FL_PARTITA_GIRO", sql.EQUALS, "N"); + sql.closeParenthesis(); + + if (dettaglioEntrata.getLinea_attivita() != null) + sql.addSQLClause("AND","CD_NATURA",sql.EQUALS,dettaglioEntrata.getLinea_attivita().getCd_natura()); + if (!dettaglioEntrata.getCentro_responsabilita().getUnita_padre().getCd_tipo_unita().equals(it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC)) + sql.addSQLClause("AND","FL_VOCE_SAC",sql.EQUALS,"N"); + if (dettaglioEntrata.getClassificazione_entrate() != null) { + if (dettaglioEntrata.getClassificazione_entrate().getEsercizio() != null) + sql.addSQLClause("AND","ESERCIZIO_CLA_E",sql.EQUALS,dettaglioEntrata.getClassificazione_entrate().getEsercizio()); + if (dettaglioEntrata.getClassificazione_entrate().getCodice_cla_e() != null) + sql.addSQLClause("AND","COD_CLA_E",sql.EQUALS,dettaglioEntrata.getClassificazione_entrate().getCodice_cla_e()); + } + + if (clause != null) sql.addClause(clause); + + return sql; +} + +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco degli elementi voce compatibili per il dettaglio di spesa specificato con un elenco di clausole specificate + * PostCondition: + * Viene restituita una query sulla vista V_ELEMENTO_VOCE_PDG_SPE che contiene le clausole specificate più la clausola CD_FUNZIONE = dettaglioSpesa.cd_funzione, CD_TIPO_UNITA = dettaglioSpesa.getCentro_responsabilita().getUnita_padre().getCd_tipo_unita() + */ +//^^@@ + + public SQLBuilder selectElemento_voceByClause(UserContext userContext, + Pdg_preventivo_spe_detBulk dettaglioSpesa, + Elemento_voceBulk elementoVoce, + CompoundFindClause clause) + throws ComponentException, PersistencyException + { + if (clause == null) clause = ((OggettoBulk)elementoVoce).buildFindClauses(null); + + SQLBuilder sql = getHome(userContext, elementoVoce,"V_ELEMENTO_VOCE_PDG_SPE").createSQLBuilder(); + if(clause != null) sql.addClause(clause); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + + sql.openParenthesis("AND"); + sql.addSQLClause("OR", "FL_PARTITA_GIRO", sql.ISNULL, null); + sql.addSQLClause("OR", "FL_PARTITA_GIRO", sql.EQUALS, "N"); + sql.closeParenthesis(); + + if (dettaglioSpesa.getLinea_attivita() != null) + sql.addSQLClause("AND","CD_FUNZIONE",sql.EQUALS,dettaglioSpesa.getLinea_attivita().getCd_funzione()); + if ((dettaglioSpesa.getCategoria_economica_finanziaria() != null) && (dettaglioSpesa.getCategoria_economica_finanziaria().getCd_capoconto_fin() != null)) + sql.addSQLClause("AND","CD_CAPOCONTO_FIN",sql.EQUALS,dettaglioSpesa.getCategoria_economica_finanziaria().getCd_capoconto_fin()); + if (dettaglioSpesa.getCentro_responsabilita() != null) + sql.addSQLClause("AND","CD_TIPO_UNITA",sql.EQUALS,dettaglioSpesa.getCentro_responsabilita().getUnita_padre().getCd_tipo_unita()); + if (dettaglioSpesa.getClassificazione_spese() != null) { + if (dettaglioSpesa.getClassificazione_spese().getEsercizio() != null) + sql.addSQLClause("AND","ESERCIZIO_CLA_S",sql.EQUALS,dettaglioSpesa.getClassificazione_spese().getEsercizio()); + if (dettaglioSpesa.getClassificazione_spese().getCodice_cla_s() != null) + sql.addSQLClause("AND","COD_CLA_S",sql.EQUALS,dettaglioSpesa.getClassificazione_spese().getCodice_cla_s()); + } + + if (clause != null) sql.addClause(clause); + + return sql; + } + + public SQLBuilder selectClassificazione_speseByClause(UserContext userContext, + Pdg_preventivo_spe_detBulk dettaglioSpesa, + Classificazione_speseBulk classificazione_spese, + CompoundFindClause clause) + throws ComponentException, PersistencyException + { + Classificazione_speseHome home = (Classificazione_speseHome)getHome(userContext, Classificazione_speseBulk.class); + SQLBuilder sql = home.createSQLBuilder(); + sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio( userContext ) ); + if(clause != null) + sql.addClause(clause); + + return sql; + } + +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco delle linee di attività utilizzabili dal metodo delDetByLA + * PostCondition: + * Viene restituita una query sulla vista V_LINEA_ATTIVITA_VALIDA per il cdr del pdg specificato. + */ +//^^@@ + public SQLBuilder selectLinea_attivita_eliminazioneByClause(UserContext userContext, + Pdg_preventivoBulk pdg, + it.cnr.contab.config00.latt.bulk.WorkpackageBulk linea_attivita, + CompoundFindClause clause) + throws ComponentException, PersistencyException + { + if (clause == null) clause = ((OggettoBulk)linea_attivita).buildFindClauses(null); + + SQLBuilder sql = getHome(userContext,linea_attivita, "V_LINEA_ATTIVITA_VALIDA").createSQLBuilder(); + if (clause != null) sql.addClause(clause); + + sql.addClause( + "AND", + "cd_centro_responsabilita", + it.cnr.jada.persistency.sql.SQLBuilder.EQUALS, + pdg.getCd_centro_responsabilita() + ); + sql.addSQLClause( + "AND", + "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO", + it.cnr.jada.persistency.sql.SQLBuilder.EQUALS, + it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext) + ); + + return sql; + } + +//^^@@ +/** + * Normale + * PreCondition: + * Viene richiesto l'elenco delle linee di attività compatibili per un dettaglio di spesa con un elenco di clausole specificate + * PostCondition: + * Viene restituito una query sulle linee di attività con le clausole specificate e + * esercizio = dettaglio_pdg.esercizio + * cdr = dettaglio_pdg.cdr + */ +//^^@@ + + public SQLBuilder selectLinea_attivitaByClause(UserContext userContext, + Pdg_preventivo_detBulk dettaglio_pdg, + it.cnr.contab.config00.latt.bulk.WorkpackageBulk linea_attivita, + CompoundFindClause clause) + throws ComponentException, PersistencyException + { + if (clause == null) clause = ((OggettoBulk)linea_attivita).buildFindClauses(null); + + SQLBuilder sql = getHome(userContext,linea_attivita, "V_LINEA_ATTIVITA_VALIDA").createSQLBuilder(); + if (clause != null) sql.addClause(clause); + + sql.addClause( + "AND", + "cd_centro_responsabilita", + it.cnr.jada.persistency.sql.SQLBuilder.EQUALS, + dettaglio_pdg.getCentro_responsabilita().getCd_centro_responsabilita() + ); + + // Date: 20/02/2002 Filtro sulla sezione delle linee di attività in piano di gestione + if(dettaglio_pdg instanceof Pdg_preventivo_spe_detBulk) { + sql.addClause("AND","ti_gestione",it.cnr.jada.persistency.sql.SQLBuilder.EQUALS,it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk.TI_GESTIONE_SPESE); + } else if(dettaglio_pdg instanceof Pdg_preventivo_etr_detBulk) { + sql.addClause("AND","ti_gestione",it.cnr.jada.persistency.sql.SQLBuilder.EQUALS,it.cnr.contab.config00.latt.bulk.Tipo_linea_attivitaBulk.TI_GESTIONE_ENTRATE); + } + else { + throw new it.cnr.jada.comp.ApplicationException("Impossibile determinare la sezione entrata/spesa del GAE"); + } + sql.addSQLClause( + "AND", + "V_LINEA_ATTIVITA_VALIDA.ESERCIZIO", + it.cnr.jada.persistency.sql.SQLBuilder.EQUALS, + it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext) + ); + + return sql; + } + +public OggettoBulk stampaConBulk(UserContext aUC, OggettoBulk bulk) throws it.cnr.jada.comp.ComponentException { + + if (bulk instanceof Stampa_spese_ldaBulk) + validateBulkForPrint(aUC, (Stampa_spese_ldaBulk)bulk); + else if (bulk instanceof Stampa_libro_giornaleBulk) + validateBulkForPrint(aUC, (Stampa_libro_giornaleBulk)bulk); + else if (bulk instanceof Stampa_situazione_analitica_x_GAEBulk) + stampaConBulk(aUC, (Stampa_situazione_analitica_x_GAEBulk)bulk); + return bulk; +} + +public OggettoBulk stampaConBulk(UserContext userContext, Stampa_situazione_analitica_x_GAEBulk stampa) throws ComponentException { + if ( stampa.getCdsForPrint()==null || stampa.getCdsForPrint().getCd_proprio_unita()==null) + throw new ApplicationException( "E' necessario selezionare il CDS"); + return stampa; +} + +private void utenteNonAbilitato() throws it.cnr.jada.comp.ApplicationException { + throw new it.cnr.jada.comp.ApplicationException("Utente non abilitato ad operare sul PDG"); +} +/** + * Validazione dell'oggetto in fase di stampa + * +*/ +private void validateBulkForPrint( it.cnr.jada.UserContext userContext, Stampa_spese_ldaBulk stampa) + throws ComponentException { + + try{ + if (stampa.getEsercizio()==null) + throw new ValidationException("Il campo ESERCIZIO e' obbligatorio"); + if (stampa.getCd_cds()==null) + throw new ValidationException("Il campo CDS e' obbligatorio"); + + //if (!stampa.isCdsUOInScrivania() && stampa.getCdUoForPrint() == null) + //throw new ValidationException("Il campo UNITA ORGANIZZATIVA è obbligatorio"); +//// if (it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome.TIPO_UO_SAC.equalsIgnoreCase(uo.getCd_tipo_unita())){ + + } catch(ValidationException ex) { + throw new it.cnr.jada.comp.ApplicationException(ex); + } +} +/** + * Validazione dell'oggetto in fase di stampa + * +*/ +private void validateBulkForPrint(it.cnr.jada.UserContext userContext,Stampa_libro_giornaleBulk stampa)throws ComponentException { + if (stampa.getCdCdsForPrint().equals("*")) + stampa.setIntestazione("Provvisoria"); + else{ + try { + Chiusura_coepHome home = (Chiusura_coepHome)getHome(userContext,Chiusura_coepBulk.class); + Chiusura_coepBulk chiusura_coep = (Chiusura_coepBulk)home.findByPrimaryKey(new Chiusura_coepBulk(stampa.getCdCdsForPrint(),stampa.getEsercizio())); + if (chiusura_coep != null && chiusura_coep.getStato().equals(Chiusura_coepBulk.STATO_CHIUSO_DEFINITIVAMENTE)) + stampa.setIntestazione("Definitiva"); + else + stampa.setIntestazione("Provvisoria"); + + } catch (PersistencyException e) { + throw new ComponentException(e); + } + } +} +public boolean isUoPrincipale(CNRUserContext userContext) throws ComponentException { + try { + Unita_organizzativaHome uom = (Unita_organizzativaHome)getHome(userContext,Unita_organizzativaBulk.class); + Unita_organizzativaBulk uo = (Unita_organizzativaBulk)uom.findByPrimaryKey(new Unita_organizzativaBulk(userContext.getCd_unita_organizzativa())); + return uo.isUoCds(); + } catch (it.cnr.jada.persistency.PersistencyException pe){ + throw new ComponentException(pe); + } +} +private void validaVariazione(UserContext usercontext, OggettoBulk oggettobulk) throws ComponentException +{ + Pdg_preventivo_detBulk pdg_det = (Pdg_preventivo_detBulk)oggettobulk; + boolean diffZeroSpesa = false; + boolean diffZeroEntrata = false; + if (pdg_det.getPdg_variazione() != null){ + try { + Ass_pdg_variazione_cdrHome testataHome = (Ass_pdg_variazione_cdrHome)getHome(usercontext, Ass_pdg_variazione_cdrBulk.class); + Ass_pdg_variazione_cdrBulk ass_pdg = (Ass_pdg_variazione_cdrBulk)testataHome.findByPrimaryKey(new Ass_pdg_variazione_cdrBulk(pdg_det.getEsercizio(), pdg_det.getPdg_variazione().getPg_variazione_pdg(), + pdg_det.getCentro_responsabilita().getCd_centro_responsabilita()),true); + Pdg_variazioneBulk pdg = (Pdg_variazioneBulk)getHome(usercontext,Pdg_variazioneBulk.class).findByPrimaryKey(new Pdg_variazioneBulk(pdg_det.getEsercizio(), pdg_det.getPdg_variazione().getPg_variazione_pdg()),true); + + if (pdg_det instanceof Pdg_preventivo_etr_detBulk){ + if (ass_pdg.getIm_entrata() != null){ + BigDecimal sommaEntrata = ZERO; + for (java.util.Iterator entrate = testataHome.findDettagliEntrata(ass_pdg).iterator();entrate.hasNext();){ + Pdg_preventivo_etr_detBulk etr_det = (Pdg_preventivo_etr_detBulk)entrate.next(); + sommaEntrata = (sommaEntrata.add( + (etr_det.getIm_ra_rce()).add( + (etr_det.getIm_rc_esr())) + )); + } + if(ass_pdg.getIm_entrata().compareTo(sommaEntrata) < 0 && !pdg.isPropostaProvvisoria()) + throw new ApplicationException("La Somma dei dettagli di entrata ("+new it.cnr.contab.util.EuroFormat().format(sommaEntrata)+")"+ + "\n" + " supera la quota di entrata assegnata di "+ + new it.cnr.contab.util.EuroFormat().format(sommaEntrata.subtract(ass_pdg.getIm_entrata()))); + else if (ass_pdg.getIm_entrata().compareTo(sommaEntrata) == 0) + diffZeroEntrata = true; + } + }else if (pdg_det instanceof Pdg_preventivo_spe_detBulk){ + if (ass_pdg.getIm_spesa() != null){ + BigDecimal sommaSpesa = ZERO; + for (java.util.Iterator spese = testataHome.findDettagliSpesa(ass_pdg).iterator();spese.hasNext();){ + Pdg_preventivo_spe_detBulk spesa_det = (Pdg_preventivo_spe_detBulk)spese.next(); + sommaSpesa = (sommaSpesa.add( + (spesa_det.getIm_ri_ccs_spese_odc()).add( + (spesa_det.getIm_rj_ccs_spese_odc_altra_uo()).add( + (spesa_det.getIm_rk_ccs_spese_ogc()).add( + (spesa_det.getIm_rl_ccs_spese_ogc_altra_uo()).add( + (spesa_det.getIm_rq_ssc_costi_odc()).add( + (spesa_det.getIm_rr_ssc_costi_odc_altra_uo()).add( + (spesa_det.getIm_rs_ssc_costi_ogc()).add( + (spesa_det.getIm_rt_ssc_costi_ogc_altra_uo())))))))) + )); + } + if(ass_pdg.getIm_spesa().compareTo(sommaSpesa) < 0 && !pdg.isPropostaProvvisoria()) + throw new ApplicationException("La Somma dei dettagli di spesa ("+new it.cnr.contab.util.EuroFormat().format(sommaSpesa)+")"+ + "\n" + " supera la quota di spesa assegnata di "+ + new it.cnr.contab.util.EuroFormat().format(sommaSpesa.subtract(ass_pdg.getIm_spesa()))); + else if (ass_pdg.getIm_spesa().compareTo(sommaSpesa) == 0) + diffZeroSpesa = true; + } + } + if(diffZeroSpesa || diffZeroEntrata){ + try { + MessaggioHome messHome = (MessaggioHome)getHome(usercontext,MessaggioBulk.class); + UtenteHome utenteHome = (UtenteHome)getHome(usercontext,UtenteBulk.class); + for (java.util.Iterator i= utenteHome.findUtenteByCDRIncludeFirstLevel(pdg.getCd_centro_responsabilita()).iterator();i.hasNext();){ + UtenteBulk utente = (UtenteBulk)i.next(); + MessaggioBulk messaggio = generaMessaggio(usercontext,utente,pdg,ass_pdg,diffZeroSpesa ? "Spesa":"Entrata"); + super.creaConBulk(usercontext, messaggio); + } + } catch (PersistencyException e) { + throw new ComponentException(e); + } catch (IntrospectionException e) { + throw new ComponentException(e); + } + } + } catch (PersistencyException e) { + throw new ComponentException(e); + } catch (IntrospectionException e) { + throw new ComponentException(e); + } + } +} +private MessaggioBulk generaMessaggio(UserContext userContext, UtenteBulk utente, Pdg_variazioneBulk pdg, Ass_pdg_variazione_cdrBulk ass_pdg, String etr_spe) throws ComponentException, PersistencyException{ + MessaggioHome messHome = (MessaggioHome)getHome(userContext,MessaggioBulk.class); + MessaggioBulk messaggio = new MessaggioBulk(); + java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + messaggio.setPg_messaggio(new Long(messHome.fetchNextSequenceValue(userContext,"CNRSEQ00_PG_MESSAGGIO").longValue())); + messaggio.setCd_utente(utente.getCd_utente()); + messaggio.setPriorita(new Integer(1)); + messaggio.setDs_messaggio(sdf.format(EJBCommonServices.getServerTimestamp()) + " - È stata raggiunta la quota di "+ etr_spe +" assegnata alla Variazione"); + messaggio.setCorpo("Numero variazione:"+pdg.getPg_variazione_pdg()); + messaggio.setCorpo(messaggio.getCorpo() + "\n" + "Il CdR :"+ass_pdg.getCentro_responsabilita().getCd_ds_cdr()+" ha coperto la quota assegnata."); + messaggio.setSoggetto(messaggio.getDs_messaggio()); + messaggio.setToBeCreated(); + return messaggio; +} + +private boolean isCdsEnte(UserContext userContext) throws ComponentException { + try { + Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHome( userContext, Unita_organizzativa_enteBulk.class).findAll().get(0); + if (((CNRUserContext) userContext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa())) + return true; + else + return false; + } catch(Throwable e) { + throw handleException(e); + } +} + +public SQLBuilder selectCentro_responsabilitaByClause (UserContext userContext, + Stampa_situazione_sintetica_x_progettoBulk stampa, + CdrBulk cdr, + CompoundFindClause clause) throws ComponentException, PersistencyException { + SQLBuilder aSQL = (listaCdrPdGPerUtente (userContext)); + if(clause != null) + aSQL.addClause(clause); + return aSQL; +} + +public SQLBuilder selectProgettoForPrintByClause (UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa, ProgettoBulk progetto, CompoundFindClause clause) throws ComponentException, PersistencyException +{ + ProgettoHome progettohome = (ProgettoHome)getHome(userContext, ProgettoBulk.class,"V_PROGETTO_PADRE"); + SQLBuilder sql = progettohome.createSQLBuilder(); + sql.addClause( clause ); + sql.addSQLClause("AND", "V_PROGETTO_PADRE.ESERCIZIO", sql.EQUALS, CNRUserContext.getEsercizio(userContext)); + sql.addSQLClause("AND", "V_PROGETTO_PADRE.TIPO_FASE", sql.EQUALS, ProgettoBulk.TIPO_FASE_NON_DEFINITA); + sql.addSQLClause("AND", "V_PROGETTO_PADRE.LIVELLO", sql.EQUALS, ProgettoBulk.LIVELLO_PROGETTO_SECONDO); + + if (stampa.getGaeForPrint()!=null && stampa.getGaeForPrint().getPg_progetto()!=null) + sql.addSQLClause("AND", "V_PROGETTO_PADRE.PG_PROGETTO", SQLBuilder.EQUALS, stampa.getGaeForPrint().getPg_progetto()); + + // Se uo 999.000 in scrivania: visualizza tutti i progetti + Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHome( userContext, Unita_organizzativa_enteBulk.class).findAll().get(0); + + SQLBuilder sqlAbilitazioni; + if (!((CNRUserContext) userContext).getCd_unita_organizzativa().equals( ente.getCd_unita_organizzativa())){ + sqlAbilitazioni = progettohome.abilitazioniCommesse(userContext); + if (stampa.getCdUoForPrint()!=null) + sqlAbilitazioni.addSQLClause("AND", "V_ABIL_PROGETTI.CD_UNITA_ORGANIZZATIVA", sql.EQUALS, stampa.getCdUoForPrint()); + } else { + ProgettoHome progettoAbilhome = (ProgettoHome)getHome(userContext, ProgettoBulk.class,"V_ABIL_PROGETTI"); + sqlAbilitazioni = progettoAbilhome.createSQLBuilder(); + sqlAbilitazioni.addSQLJoin("V_ABIL_PROGETTI.ESERCIZIO_COMMESSA","V_PROGETTO_PADRE.ESERCIZIO"); + sqlAbilitazioni.addSQLJoin("V_ABIL_PROGETTI.PG_COMMESSA","V_PROGETTO_PADRE.PG_PROGETTO"); + sqlAbilitazioni.addSQLJoin("V_ABIL_PROGETTI.TIPO_FASE_COMMESSA","V_PROGETTO_PADRE.TIPO_FASE"); + sqlAbilitazioni.addSQLClause("AND","V_ABIL_PROGETTI.CD_UNITA_ORGANIZZATIVA",SQLBuilder.EQUALS,stampa.getCdUoForPrint()); + + } + sql.addSQLExistsClause("AND",sqlAbilitazioni); + + return sql; +} + +private void inizializzaBulkPerStampa(UserContext userContext, Stampa_situazione_sintetica_x_progettoBulk stampa) throws ComponentException { + stampa.setEsercizio(it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext)); + try{ + String cdCds = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_cds(userContext); + String cdUo = it.cnr.contab.utenze00.bp.CNRUserContext.getCd_unita_organizzativa(userContext); + + CdsHome cdsHome = (CdsHome)getHome(userContext, CdsBulk.class); + CdsBulk cds = (CdsBulk)cdsHome.findByPrimaryKey(new CdsBulk(cdCds)); + Unita_organizzativaBulk uo = (Unita_organizzativaBulk) getHome( userContext, Unita_organizzativaBulk.class).findByPrimaryKey(new Unita_organizzativaBulk(cdUo)); + Unita_organizzativa_enteBulk ente = (Unita_organizzativa_enteBulk) getHome( userContext, Unita_organizzativa_enteBulk.class).findAll().get(0); + + stampa.setCdsForPrintEnabled(true); + stampa.setUoForPrintEnabled(true); + stampa.setProgettoForPrintEnabled(true); + stampa.setGaeForPrintEnabled(true); + stampa.setTi_ordine_stampa(Stampa_situazione_sintetica_x_progettoBulk.TI_ORDINE_GAE_VOCE_ANNO); + + if (!Tipo_unita_organizzativaHome.TIPO_UO_ENTE.equals(uo.getCd_tipo_unita())){ + stampa.setCdsForPrint(cds); + stampa.setCdsForPrintEnabled(false); + if (!uo.getFl_uo_cds().equals(Boolean.TRUE)) { + stampa.setUoForPrint(uo); + stampa.setUoForPrintEnabled(false); + } + } + } catch (it.cnr.jada.persistency.PersistencyException pe){ + throw new ComponentException(pe); + } +} } \ No newline at end of file diff --git a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/PdGVariazioniComponent.java b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/PdGVariazioniComponent.java index 20fc05407b..38d0d38b21 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/PdGVariazioniComponent.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/pdg00/comp/PdGVariazioniComponent.java @@ -2763,23 +2763,18 @@ private List variazioniPresentiSulDocumentale(UserContext userContext, // per la stampa delle variazioni residuo conto terzi public byte[] lanciaStampa(UserContext userContext, Integer esercizio,Integer pgVariazione, String tipo_variazione) throws PersistencyException, ComponentException, RemoteException, javax.ejb.EJBException { - - SQLBuilder sqlCDR = getHome(userContext, Configurazione_cnrBulk.class).createSQLBuilder(); - sqlCDR.resetColumns(); - sqlCDR.addColumn("VAL01"); - sqlCDR.addSQLClause("AND", "CD_CHIAVE_PRIMARIA", SQLBuilder.EQUALS, Configurazione_cnrBulk.PK_CDR_SPECIALE); - sqlCDR.addSQLClause("AND", "CD_CHIAVE_SECONDARIA", SQLBuilder.EQUALS, Configurazione_cnrBulk.SK_CDR_PERSONALE); + + String cdrPersonale = Optional.ofNullable(((Configurazione_cnrHome)getHome(userContext,Configurazione_cnrBulk.class)).getCdrPersonale(esercizio)) + .orElseThrow(() -> new ComponentException("Non è possibile individuare il codice CDR del Personale per l'esercizio "+esercizio+".")); if (tipo_variazione.equals("R")){ -// it.cnr.contab.varstanz00.bulk.Var_stanz_resHome home = (it.cnr.contab.varstanz00.bulk.Var_stanz_resHome) getHome(userContext, it.cnr.contab.varstanz00.bulk.Var_stanz_resBulk.class); -// SQLBuilder sql = home.createSQLBuilder(); V_var_stanz_resHome home = (V_var_stanz_resHome) getHome(userContext, V_var_stanz_resBulk.class); SQLBuilder sql = home.createSQLBuilder(); - sql.addSQLClause("AND", "ESERCIZIO", sql.EQUALS, esercizio); - sql.addSQLClause("AND", "PG_VARIAZIONE", sql.EQUALS, pgVariazione); - sql.addSQLClause("AND", "CD_CDR_ASSEGNATARIO", sql.EQUALS, sqlCDR); - sql.addSQLClause("AND", "STATO", sql.EQUALS, it.cnr.contab.varstanz00.bulk.Var_stanz_resBulk.STATO_APPROVATA); + sql.addSQLClause(FindClause.AND, "ESERCIZIO", SQLBuilder.EQUALS, esercizio); + sql.addSQLClause(FindClause.AND, "PG_VARIAZIONE", SQLBuilder.EQUALS, pgVariazione); + sql.addSQLClause(FindClause.AND, "CD_CDR_ASSEGNATARIO", SQLBuilder.EQUALS, cdrPersonale); + sql.addSQLClause(FindClause.AND, "STATO", SQLBuilder.EQUALS, it.cnr.contab.varstanz00.bulk.Var_stanz_resBulk.STATO_APPROVATA); java.util.List list = home.fetchAll(sql); if(list.isEmpty()) @@ -2816,16 +2811,16 @@ public byte[] lanciaStampa(UserContext userContext, Integer esercizio,Integer pg Pdg_variazioneHome home = (Pdg_variazioneHome) getHome(userContext, Pdg_variazioneBulk.class); SQLBuilder sql = home.createSQLBuilder(); - sql.addSQLClause("AND", "PDG_VARIAZIONE.ESERCIZIO", SQLBuilder.EQUALS, esercizio); - sql.addSQLClause("AND", "PDG_VARIAZIONE.PG_VARIAZIONE_PDG", SQLBuilder.EQUALS, pgVariazione); + sql.addSQLClause(FindClause.AND, "PDG_VARIAZIONE.ESERCIZIO", SQLBuilder.EQUALS, esercizio); + sql.addSQLClause(FindClause.AND, "PDG_VARIAZIONE.PG_VARIAZIONE_PDG", SQLBuilder.EQUALS, pgVariazione); sql.addTableToHeader("PDG_VARIAZIONE_RIGA_GEST"); - sql.addSQLClause("AND", "PDG_VARIAZIONE_RIGA_GEST.CD_CDR_ASSEGNATARIO", SQLBuilder.EQUALS, sqlCDR); + sql.addSQLClause(FindClause.AND, "PDG_VARIAZIONE_RIGA_GEST.CD_CDR_ASSEGNATARIO", SQLBuilder.EQUALS, cdrPersonale); sql.addSQLJoin("PDG_VARIAZIONE.ESERCIZIO", "PDG_VARIAZIONE_RIGA_GEST.ESERCIZIO"); sql.addSQLJoin("PDG_VARIAZIONE.PG_VARIAZIONE_PDG", "PDG_VARIAZIONE_RIGA_GEST.PG_VARIAZIONE_PDG"); - sql.openParenthesis("AND"); - sql.addSQLClause("AND", "PDG_VARIAZIONE.STATO", SQLBuilder.EQUALS, Pdg_variazioneBulk.STATO_APPROVATA); - sql.addSQLClause("OR", "PDG_VARIAZIONE.STATO", SQLBuilder.EQUALS, Pdg_variazioneBulk.STATO_APPROVAZIONE_FORMALE); + sql.openParenthesis(FindClause.AND); + sql.addSQLClause(FindClause.AND, "PDG_VARIAZIONE.STATO", SQLBuilder.EQUALS, Pdg_variazioneBulk.STATO_APPROVATA); + sql.addSQLClause(FindClause.OR, "PDG_VARIAZIONE.STATO", SQLBuilder.EQUALS, Pdg_variazioneBulk.STATO_APPROVAZIONE_FORMALE); sql.closeParenthesis(); java.util.List list = home.fetchAll(sql); diff --git a/sigla-ejb/src/main/java/it/cnr/contab/pdg01/comp/CRUDPdgVariazioneGestionaleComponent.java b/sigla-ejb/src/main/java/it/cnr/contab/pdg01/comp/CRUDPdgVariazioneGestionaleComponent.java index cfdc4a6d6c..70ea13c174 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/pdg01/comp/CRUDPdgVariazioneGestionaleComponent.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/pdg01/comp/CRUDPdgVariazioneGestionaleComponent.java @@ -37,6 +37,7 @@ import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -700,7 +701,7 @@ protected void validaDettagliEntrataSpesa(UserContext usercontext, OggettoBulk o boolean existDettPersonale = true; String cdrPersonale = null; if (Optional.of(pdg).filter(el->el.isMotivazioneVariazionePersonale()).isPresent()) { - cdrPersonale = Optional.ofNullable(((ObbligazioneHome)getHome(usercontext, ObbligazioneBulk.class)).recupero_cdr_speciale_stipendi()) + cdrPersonale = Optional.ofNullable(((Configurazione_cnrHome)getHome(usercontext,Configurazione_cnrBulk.class)).getCdrPersonale(CNRUserContext.getEsercizio(usercontext))) .orElseThrow(() -> new ComponentException("Non è possibile individuare il codice CDR del Personale.")); existDettPersonale = false; } diff --git a/sigla-ejb/src/main/java/it/cnr/contab/pdg01/comp/CRUDPdgVariazioneRigaGestComponent.java b/sigla-ejb/src/main/java/it/cnr/contab/pdg01/comp/CRUDPdgVariazioneRigaGestComponent.java index 5ca274b13d..723a29f38a 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/pdg01/comp/CRUDPdgVariazioneRigaGestComponent.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/pdg01/comp/CRUDPdgVariazioneRigaGestComponent.java @@ -30,6 +30,7 @@ import javax.ejb.EJBException; import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; import it.cnr.contab.config00.bulk.Parametri_cnrBulk; import it.cnr.contab.config00.bulk.Parametri_cnrHome; import it.cnr.contab.config00.ejb.Parametri_cnrComponentSession; @@ -403,19 +404,12 @@ public SQLBuilder selectLinea_attivitaByClause (UserContext userContext, if (dett.getPdg_variazione().getTipologia_fin() != null) { sql.openParenthesis(FindClause.AND); - sql.addSQLClause(FindClause.OR,"NATURA.TIPO",SQLBuilder.EQUALS,dett.getPdg_variazione().getTipologia_fin()); + sql.addSQLClause(FindClause.OR,"NATURA.TIPO",SQLBuilder.EQUALS,dett.getPdg_variazione().getTipologia_fin()); + + Optional.ofNullable(((Configurazione_cnrHome)getHome(userContext,Configurazione_cnrBulk.class)).getCdrPersonale(CNRUserContext.getEsercizio(userContext))).ifPresent(cdrPersonale->{ + sql.addSQLClause( FindClause.OR, "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA", SQLBuilder.EQUALS, cdrPersonale); + }); - it.cnr.contab.config00.bulk.Configurazione_cnrBulk config = null; - try { - config = Utility.createConfigurazioneCnrComponentSession().getConfigurazione( userContext, null, null, it.cnr.contab.config00.bulk.Configurazione_cnrBulk.PK_CDR_SPECIALE, it.cnr.contab.config00.bulk.Configurazione_cnrBulk.SK_CDR_PERSONALE); - } catch (RemoteException e) { - throw new ComponentException(e); - } catch (EJBException e) { - throw new ComponentException(e); - } - if (config != null){ - sql.addSQLClause( FindClause.OR, "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA", SQLBuilder.EQUALS, config.getVal01()); - } sql.closeParenthesis(); } @@ -491,19 +485,12 @@ public SQLBuilder selectLinea_attivitaByClause (UserContext userContext, */ if (dett.getPdg_variazione().getTipologia_fin() != null) { sql.openParenthesis(FindClause.AND); - sql.addSQLClause(FindClause.OR,"NATURA.TIPO",SQLBuilder.EQUALS,dett.getPdg_variazione().getTipologia_fin()); + sql.addSQLClause(FindClause.OR,"NATURA.TIPO",SQLBuilder.EQUALS,dett.getPdg_variazione().getTipologia_fin()); + + Optional.ofNullable(((Configurazione_cnrHome)getHome(userContext,Configurazione_cnrBulk.class)).getCdrPersonale(CNRUserContext.getEsercizio(userContext))).ifPresent(cdrPersonale->{ + sql.addSQLClause( FindClause.OR, "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA", SQLBuilder.EQUALS, cdrPersonale); + }); - it.cnr.contab.config00.bulk.Configurazione_cnrBulk config = null; - try { - config = Utility.createConfigurazioneCnrComponentSession().getConfigurazione( userContext, null, null, it.cnr.contab.config00.bulk.Configurazione_cnrBulk.PK_CDR_SPECIALE, it.cnr.contab.config00.bulk.Configurazione_cnrBulk.SK_CDR_PERSONALE); - } catch (RemoteException e) { - throw new ComponentException(e); - } catch (EJBException e) { - throw new ComponentException(e); - } - if (config != null){ - sql.addSQLClause( FindClause.OR, "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA", SQLBuilder.EQUALS, config.getVal01()); - } sql.closeParenthesis(); } diff --git a/sigla-ejb/src/main/java/it/cnr/contab/pdg01/consultazioni/bulk/VConsVarCompResHome.java b/sigla-ejb/src/main/java/it/cnr/contab/pdg01/consultazioni/bulk/VConsVarCompResHome.java index d32953678e..b9eec9f035 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/pdg01/consultazioni/bulk/VConsVarCompResHome.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/pdg01/consultazioni/bulk/VConsVarCompResHome.java @@ -21,6 +21,7 @@ */ package it.cnr.contab.pdg01.consultazioni.bulk; import it.cnr.contab.config00.bulk.Configurazione_cnrBulk; +import it.cnr.contab.config00.bulk.Configurazione_cnrHome; import it.cnr.contab.config00.sto.bulk.Unita_organizzativa_enteBulk; import it.cnr.contab.consultazioni.bulk.ConsultazioniRestHome; import it.cnr.contab.utenze00.bp.CNRUserContext; @@ -37,6 +38,7 @@ import java.sql.Connection; import java.util.Enumeration; +import java.util.Optional; public class VConsVarCompResHome extends BulkHome implements ConsultazioniRestHome { private static final long serialVersionUID = 1L; @@ -69,7 +71,6 @@ public SQLBuilder restSelect(UserContext userContext, SQLBuilder sql, CompoundFi Boolean trovataCondizioneCdrPersonale = false; CompoundFindClause newClauses = new CompoundFindClause(); Enumeration e = compoundfindclause.getClauses(); - SQLBuilder sqlCDR = null; while(e.hasMoreElements() ){ FindClause findClause = (FindClause) e.nextElement(); if (findClause instanceof SimpleFindClause){ @@ -78,19 +79,16 @@ public SQLBuilder restSelect(UserContext userContext, SQLBuilder sql, CompoundFi if (clause.getPropertyName() != null && clause.getPropertyName().equals("cdrPersonale") && operator == SQLBuilder.EQUALS && "S".equals((String)clause.getValue())){ trovataCondizioneCdrPersonale = true; - sqlCDR = getHomeCache().getHome(Configurazione_cnrBulk.class).createSQLBuilder(); - sqlCDR.resetColumns(); - sqlCDR.addColumn("VAL01"); - sqlCDR.addSQLClause("AND", "CD_CHIAVE_PRIMARIA", SQLBuilder.EQUALS, Configurazione_cnrBulk.PK_CDR_SPECIALE); - sqlCDR.addSQLClause("AND", "CD_CHIAVE_SECONDARIA", SQLBuilder.EQUALS, Configurazione_cnrBulk.SK_CDR_PERSONALE); } else { newClauses.addClause(clause.getLogicalOperator(), clause.getPropertyName(), clause.getOperator(), clause.getValue()); } } } if (trovataCondizioneCdrPersonale){ + String cdrPersonale = Optional.ofNullable(((Configurazione_cnrHome)getHomeCache().getHome(Configurazione_cnrBulk.class)).getCdrPersonale(CNRUserContext.getEsercizio(userContext))) + .orElseThrow(() -> new ComponentException("Non è possibile individuare il codice CDR del Personale per l'esercizio "+CNRUserContext.getEsercizio(userContext)+".")); sql = selectByClause(userContext, newClauses); - sql.addSQLClause("AND", "CDR_ASSEGN", sql.EQUALS, sqlCDR); + sql.addSQLClause(FindClause.AND, "CDR_ASSEGN", SQLBuilder.EQUALS, cdrPersonale); } } return sql; diff --git a/sigla-ejb/src/main/java/it/cnr/contab/varstanz00/bp/CRUDVar_stanz_resBP.java b/sigla-ejb/src/main/java/it/cnr/contab/varstanz00/bp/CRUDVar_stanz_resBP.java index 09fe1be349..5bbe958d6c 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/varstanz00/bp/CRUDVar_stanz_resBP.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/varstanz00/bp/CRUDVar_stanz_resBP.java @@ -271,11 +271,8 @@ protected void initialize(it.cnr.jada.action.ActionContext context) throws it.cn setAbilitatoModificaDescVariazioni(UtenteBulk.isAbilitatoModificaDescVariazioni(context.getUserContext())); setAttivaGestioneVariazioniTrasferimento(Utility.createParametriEnteComponentSession().getParametriEnte(context.getUserContext()).getFl_variazioni_trasferimento()); - it.cnr.contab.config00.ejb.Configurazione_cnrComponentSession configSession = Utility.createConfigurazioneCnrComponentSession(); - Configurazione_cnrBulk config = configSession.getConfigurazione(context.getUserContext(), CNRUserContext.getEsercizio(context.getUserContext()), null, Configurazione_cnrBulk.PK_UO_SPECIALE, Configurazione_cnrBulk.SK_UO_RAGIONERIA); - if (config==null) - config = configSession.getConfigurazione(context.getUserContext(), null, null, Configurazione_cnrBulk.PK_UO_SPECIALE, Configurazione_cnrBulk.SK_UO_RAGIONERIA); - setUoRagioneria(Optional.ofNullable(config).map(Configurazione_cnrBulk::getVal01).map(uoRagioneria->uoRagioneria.equals(getCentro_responsabilita_scrivania().getCd_unita_organizzativa())).orElse(Boolean.FALSE)); + String uoRagioneria = Utility.createConfigurazioneCnrComponentSession().getUoRagioneria(context.getUserContext(),CNRUserContext.getEsercizio(context.getUserContext())); + setUoRagioneria(Optional.ofNullable(uoRagioneria).map(el->el.equals(getCentro_responsabilita_scrivania().getCd_unita_organizzativa())).orElse(Boolean.FALSE)); } catch (ComponentException e) { throw handleException(e); } catch (RemoteException e) { diff --git a/sigla-ejb/src/main/java/it/cnr/contab/varstanz00/comp/VariazioniStanziamentoResiduoComponent.java b/sigla-ejb/src/main/java/it/cnr/contab/varstanz00/comp/VariazioniStanziamentoResiduoComponent.java index 3b27251ce8..95c62da5d8 100644 --- a/sigla-ejb/src/main/java/it/cnr/contab/varstanz00/comp/VariazioniStanziamentoResiduoComponent.java +++ b/sigla-ejb/src/main/java/it/cnr/contab/varstanz00/comp/VariazioniStanziamentoResiduoComponent.java @@ -342,18 +342,12 @@ public SQLBuilder selectLinea_di_attivitaByClause (UserContext userContext,Var_s sql.addSQLJoin("V_LINEA_ATTIVITA_VALIDA.CD_NATURA","NATURA.CD_NATURA"); if (var_stanz_res_riga.getVar_stanz_res().getTipologia_fin() != null){ sql.openParenthesis("AND"); - sql.addSQLClause("OR","NATURA.TIPO",SQLBuilder.EQUALS,var_stanz_res_riga.getVar_stanz_res().getTipologia_fin()); - it.cnr.contab.config00.bulk.Configurazione_cnrBulk config = null; - try { - config = Utility.createConfigurazioneCnrComponentSession().getConfigurazione( userContext, null, null, it.cnr.contab.config00.bulk.Configurazione_cnrBulk.PK_CDR_SPECIALE, it.cnr.contab.config00.bulk.Configurazione_cnrBulk.SK_CDR_PERSONALE); - } catch (RemoteException e) { - throw new ComponentException(e); - } catch (EJBException e) { - throw new ComponentException(e); - } - if (config != null){ - sql.addSQLClause( "OR", "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA", SQLBuilder.EQUALS, config.getVal01()); - } + sql.addSQLClause("OR","NATURA.TIPO",SQLBuilder.EQUALS,var_stanz_res_riga.getVar_stanz_res().getTipologia_fin()); + + Optional.ofNullable(((Configurazione_cnrHome)getHome(userContext,Configurazione_cnrBulk.class)).getCdrPersonale(CNRUserContext.getEsercizio(userContext))).ifPresent(cdrPersonale->{ + sql.addSQLClause( FindClause.OR, "V_LINEA_ATTIVITA_VALIDA.CD_CENTRO_RESPONSABILITA", SQLBuilder.EQUALS, cdrPersonale); + }); + sql.closeParenthesis(); } // Obbligatorio cofog sulle GAE @@ -398,18 +392,13 @@ public SQLBuilder selectElemento_voceByClause (UserContext userContext,Var_stanz if(!parCnrBulk.getFl_nuovo_pdg()) if (var_stanz_res_riga.getCentroTestata()!=null && var_stanz_res_riga.getCentroTestata().getUnita_padre().getCd_tipo_unita() != null) sql.addSQLClause(FindClause.AND,"V_ELEMENTO_VOCE_PDG_SPE.CD_TIPO_UNITA",SQLBuilder.EQUALS,var_stanz_res_riga.getCentroTestata().getUnita_padre().getCd_tipo_unita()); - - it.cnr.contab.config00.bulk.Configurazione_cnrBulk config = null; - try { - config = Utility.createConfigurazioneCnrComponentSession().getConfigurazione( userContext, null, null, it.cnr.contab.config00.bulk.Configurazione_cnrBulk.PK_CDR_SPECIALE, it.cnr.contab.config00.bulk.Configurazione_cnrBulk.SK_CDR_PERSONALE); - } catch (RemoteException e) { - throw new ComponentException(e); - } catch (EJBException e) { - throw new ComponentException(e); - } - if (config != null && var_stanz_res_riga.getCentroTestata()!=null && var_stanz_res_riga.getCentroTestata().getCd_centro_responsabilita()!=null){ - if( var_stanz_res_riga.getCentroTestata().getCd_centro_responsabilita().compareTo(config.getVal01())!=0) + + if (var_stanz_res_riga.getCentroTestata()!=null && var_stanz_res_riga.getCentroTestata().getCd_centro_responsabilita()!=null){ + Optional.ofNullable(((Configurazione_cnrHome)getHome(userContext,Configurazione_cnrBulk.class)).getCdrPersonale(CNRUserContext.getEsercizio(userContext))) + .filter(cdrPersonale->!cdrPersonale.equals(var_stanz_res_riga.getCentroTestata().getCd_centro_responsabilita())) + .ifPresent(cdrPersonale->{ sql.addSQLClause(FindClause.AND, "FL_VOCE_PERSONALE", SQLBuilder.EQUALS, "N"); + }); } //controllo aggiunto solo per variazioni su anni successivi a quello di attivazione piano economico e per progetti con Piano Economico if (Utility.createParametriEnteComponentSession().isProgettoPianoEconomicoEnabled(userContext, var_stanz_res_riga.getVar_stanz_res().getEsercizio_residuo())) { @@ -594,7 +583,7 @@ public it.cnr.jada.bulk.OggettoBulk salvaDefinitivo(UserContext userContext, it. String cdrPersonale = null; if (Optional.ofNullable(var_stanz_res.getTiMotivazioneVariazione()).isPresent() && var_stanz_res.isMotivazioneVariazionePersonale()) { - cdrPersonale = Optional.ofNullable(((ObbligazioneHome)getHome(userContext, ObbligazioneBulk.class)).recupero_cdr_speciale_stipendi()) + cdrPersonale = Optional.ofNullable(((Configurazione_cnrHome)getHome(userContext,Configurazione_cnrBulk.class)).getCdrPersonale(CNRUserContext.getEsercizio(userContext))) .orElseThrow(() -> new ComponentException("Non è possibile individuare il codice CDR del Personale.")); existDettPersonale = false; } diff --git a/sigla-web/src/main/java/it/cnr/contab/web/rest/resource/util/ToDoResource.java b/sigla-web/src/main/java/it/cnr/contab/web/rest/resource/util/ToDoResource.java index 57ac5694c6..598c5aad92 100644 --- a/sigla-web/src/main/java/it/cnr/contab/web/rest/resource/util/ToDoResource.java +++ b/sigla-web/src/main/java/it/cnr/contab/web/rest/resource/util/ToDoResource.java @@ -431,8 +431,7 @@ public Response single(@Context HttpServletRequest request, ToDoBP toDoBP) { mandatoReversaleBulk.setEsitoOperazione(EsitoOperazione.NON_ACQUISITO.value()); mandatoReversaleBulk.setStato(MandatoBulk.STATO_MANDATO_EMESSO); mandatoReversaleBulk.setStato_trasmissione(MandatoBulk.STATO_TRASMISSIONE_TRASMESSO); - if (!configurazione_cnrComponentSession.getVal01(userContext, new Integer(0), null, - "UO_SPECIALE", "UO_DISTINTA_TUTTA_SAC").equals( + if (!configurazione_cnrComponentSession.isUOSpecialeDistintaTuttaSAC(userContext, CNRUserContext.getEsercizio(userContext), CNRUserContext.getCd_unita_organizzativa(userContext))) { mandatoReversaleBulk.setCd_unita_organizzativa(CNRUserContext.getCd_unita_organizzativa(userContext)); } @@ -474,8 +473,7 @@ public Response single(@Context HttpServletRequest request, ToDoBP toDoBP) { mandatoReversaleBulk.setEsitoOperazione(EsitoOperazione.NON_ACQUISITO.value()); mandatoReversaleBulk.setStato(MandatoBulk.STATO_MANDATO_EMESSO); mandatoReversaleBulk.setStato_trasmissione(MandatoBulk.STATO_TRASMISSIONE_TRASMESSO); - if (!configurazione_cnrComponentSession.getVal01(userContext, new Integer(0), null, - "UO_SPECIALE", "UO_DISTINTA_TUTTA_SAC").equals( + if (!configurazione_cnrComponentSession.isUOSpecialeDistintaTuttaSAC(userContext, CNRUserContext.getEsercizio(userContext), CNRUserContext.getCd_unita_organizzativa(userContext))) { mandatoReversaleBulk.setCd_unita_organizzativa(CNRUserContext.getCd_unita_organizzativa(userContext)); }