diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java index 4b8956b7..d249e14d 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java @@ -506,21 +506,28 @@ public class ValidazionePraticaUtil { DettPratica dettPratica = DettPraticaServiceUtil.getDettPratica(dettPraticaId); IntPratica intPratica = IntPraticaServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); - //boolean ag = true; - /*if (!territorio.getZona().equals("2") && !territorio.getZona().equals("4")) { - ag = Validator.isNotNull(dettPratica.getAg()); - }*/ - - /*boolean aiSensi = AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId()) ? (dettPratica - .getNormDpr01Dep() || dettPratica.getNormDpr02Dep()) - : (dettPratica.getNormDpr01Aut() || dettPratica.getNormDpr02Aut()); - - boolean nelRispetto = dettPratica.getNormDm01() || dettPratica.getNormDm02() - || dettPratica.getNormDm2018();*/ - - /*boolean sismaBonus = !dettPratica.getNormSismaBonus() - || (Validator.isNotNull(dettPratica.getClRischioPreInt()) || Validator.isNotNull(dettPratica - .getClRischioPostInt()));*/ + // boolean ag = true; + /* + * if (!territorio.getZona().equals("2") && + * !territorio.getZona().equals("4")) { ag = + * Validator.isNotNull(dettPratica.getAg()); } + */ + + /* + * boolean aiSensi = + * AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId()) ? + * (dettPratica .getNormDpr01Dep() || dettPratica.getNormDpr02Dep()) : + * (dettPratica.getNormDpr01Aut() || dettPratica.getNormDpr02Aut()); + * + * boolean nelRispetto = dettPratica.getNormDm01() || + * dettPratica.getNormDm02() || dettPratica.getNormDm2018(); + */ + + /* + * boolean sismaBonus = !dettPratica.getNormSismaBonus() || + * (Validator.isNotNull(dettPratica.getClRischioPreInt()) || + * Validator.isNotNull(dettPratica .getClRischioPostInt())); + */ // ADT BUG ID = 17 boolean tipologiaCostruttiva = intPratica.getTipoProcedura().equalsIgnoreCase(Constants.PROCEDURA_C) @@ -528,15 +535,17 @@ public class ValidazionePraticaUtil { || dettPratica.getTcInLegno() || dettPratica.getTcAltro(); boolean intervFinPub = !dettPratica.getIntervFinPub() || Validator.isNotNull(dettPratica.getIntervFinPubDesc()); - boolean controllo = tipologiaCostruttiva - && intervFinPub + boolean controllo = tipologiaCostruttiva && intervFinPub && Validator.isNotNull(dettPratica.getDescLongIntervento()) && Validator.isNotNull(dettPratica.getDestinazione()) - /*&& (dettPratica.getTcNuovaCostruzione() || dettPratica.getTcMiglioramentoSismico() - || dettPratica.getTcAdeguamentoSismico() || dettPratica - .getTcRiparazioneInterventoLocale() - - )*/ + /* + * && (dettPratica.getTcNuovaCostruzione() || + * dettPratica.getTcMiglioramentoSismico() || + * dettPratica.getTcAdeguamentoSismico() || dettPratica + * .getTcRiparazioneInterventoLocale() + * + * ) + */ // && Validator.isNotNull(dettPratica.getDestinazione()) // && Validator.isNotNull(dettPratica.getLocalita()) && Validator.isNotNull(dettPratica.getVia()) @@ -553,11 +562,8 @@ public class ValidazionePraticaUtil { // !"|||".equalsIgnoreCase(dettPratica.getDcParticelle())) ; - // Se è importata da Portos 1 nessun controllo su localizzazione - // geografica - boolean coordinateGeografiche = Validator.isNotNull(intPratica.getOldIntPraticaId()) ? true - : Validator.isNotNull(dettPratica.getLocalizzazioneGeografica()) - && !("|||".equalsIgnoreCase(dettPratica.getLocalizzazioneGeografica())); + boolean coordinateGeografiche = Validator.isNotNull(dettPratica.getLocalizzazioneGeografica()) + && !("|||".equalsIgnoreCase(dettPratica.getLocalizzazioneGeografica())); return controllo && coordinateGeografiche; } @@ -575,18 +581,17 @@ public class ValidazionePraticaUtil { notCompleted.add("ag"); } - /*boolean aiSensi = AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId()) ? (dettPratica - .getNormDpr01Dep() || dettPratica.getNormDpr02Dep()) - : (dettPratica.getNormDpr01Aut() || dettPratica.getNormDpr02Aut()); - if (!aiSensi) { - notCompleted.add("at-least-aiSensi"); - } - - boolean nelRispetto = dettPratica.getNormDm01() || dettPratica.getNormDm02() - || dettPratica.getNormDm2018(); - if (!nelRispetto) { - notCompleted.add("at-least-nelRispetto"); - }*/ + /* + * boolean aiSensi = + * AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId()) ? + * (dettPratica .getNormDpr01Dep() || dettPratica.getNormDpr02Dep()) : + * (dettPratica.getNormDpr01Aut() || dettPratica.getNormDpr02Aut()); if + * (!aiSensi) { notCompleted.add("at-least-aiSensi"); } + * + * boolean nelRispetto = dettPratica.getNormDm01() || + * dettPratica.getNormDm02() || dettPratica.getNormDm2018(); if + * (!nelRispetto) { notCompleted.add("at-least-nelRispetto"); } + */ if (dettPratica.getNormSismaBonus() && Validator.isNull(dettPratica.getClRischioPreInt()) && Validator.isNull(dettPratica.getClRischioPostInt())) { @@ -630,12 +635,6 @@ public class ValidazionePraticaUtil { // notCompleted.add("dp-particelle"); // } - // Se è importata da Portos 1 nessun controllo su localizzazione - // geografica - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - return notCompleted; - } - if (Validator.isNull(dettPratica.getLocalizzazioneGeografica()) || dettPratica.getLocalizzazioneGeografica().startsWith("||")) { notCompleted.add("Localizzazione geografica mancante"); @@ -951,7 +950,8 @@ public class ValidazionePraticaUtil { return controllo; } - //boolean fondazioni = Validator.isNotNull(dettPratica.getDccFondazioni()); + // boolean fondazioni = + // Validator.isNotNull(dettPratica.getDccFondazioni()); boolean elevazioni = (Validator.isNotNull(dettPratica.getDccStruttureEleMuraturePietrame()) || Validator.isNotNull(dettPratica.getDccStruttureEleMuratureLaterizio()) || Validator.isNotNull(dettPratica.getDccStruttureEleMuratureMisto()) || Validator @@ -1004,8 +1004,7 @@ public class ValidazionePraticaUtil { || (Validator.isNotNull(dettPratica.getDccOpereDiRinforzoAltro()) && Validator .isNotNull(dettPratica.getDccOpereDiRinforzoAltroDescrizione())); - return controllo && elevazioni && orizzontamenti && coperture && non_strutturali - && rinforzo; + return controllo && elevazioni && orizzontamenti && coperture && non_strutturali && rinforzo; } private static List notCompletedDescrizioneEdificio(long dettPraticaId) throws PortalException, @@ -1073,10 +1072,10 @@ public class ValidazionePraticaUtil { return notCompleted; } - /*if (Validator.isNull(dettPratica.getDccFondazioni())) { - notCompleted.add("dcc-fondazioni"); - }*/ - + /* + * if (Validator.isNull(dettPratica.getDccFondazioni())) { + * notCompleted.add("dcc-fondazioni"); } + */ boolean elevazioni = (Validator.isNotNull(dettPratica.getDccStruttureEleMuraturePietrame()) || Validator.isNotNull(dettPratica.getDccStruttureEleMuratureLaterizio()) @@ -1163,33 +1162,27 @@ public class ValidazionePraticaUtil { return true; } - boolean formGeologo = false; - // Se da Portos 1 non valido i dati - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - formGeologo = true; - } else { - formGeologo = Validator.isNotNull(dettPratica.getGeoDtRelazione()) - && Validator.isNotNull(dettPratica.getGeoClasseIndagine()) - && Validator.isNotNull(dettPratica.getGeoOperaRilevante()) - && Validator.isNotNull(dettPratica.getGeoCategoriaSottosuolo()) - && Validator.isNotNull(dettPratica.getGeoCategoriaTopografica()) - && Validator.isNotNull(dettPratica.getGeoOpereDiSostegno()) - && Validator.isNotNull(dettPratica.getGeoConsolidamento()) - && Validator.isNotNull(dettPratica.getGeoOpereInSotterranea()) - && Validator.isNotNull(dettPratica.getGeoPericolositaGeologica()) - && Validator.isNotNull(dettPratica.getGeoPericolositaGeomorfica()) - && Validator.isNotNull(dettPratica.getGeoRischioGeomorfologicoPai()) - && Validator.isNotNull(dettPratica.getGeoPericolositaIdraulicaPai()) - && Validator.isNotNull(dettPratica.getGeoRischioIdraulicoPai()) - && Validator.isNotNull(dettPratica.getGeoPericolositaSismica()) - && Validator.isNotNull(dettPratica.getGeoFattibilitaSismica()) - && Validator.isNotNull(dettPratica.getGeoPericolositaIdraulica()) - && Validator.isNotNull(dettPratica.getGeoFattibilitaIdraulica()) - && Validator.isNotNull(dettPratica.getGeoFattibilitaGeologica()) - && Validator.isNotNull(dettPratica.getGeoPresenzaPrescrizioni()) - && Validator.isNotNull(dettPratica.getGeoEvidenzeGeologiche()) - && Validator.isNotNull(dettPratica.getGeoEvidenzeGeomorfiche()); - } + boolean formGeologo = Validator.isNotNull(dettPratica.getGeoDtRelazione()) + && Validator.isNotNull(dettPratica.getGeoClasseIndagine()) + && Validator.isNotNull(dettPratica.getGeoOperaRilevante()) + && Validator.isNotNull(dettPratica.getGeoCategoriaSottosuolo()) + && Validator.isNotNull(dettPratica.getGeoCategoriaTopografica()) + && Validator.isNotNull(dettPratica.getGeoOpereDiSostegno()) + && Validator.isNotNull(dettPratica.getGeoConsolidamento()) + && Validator.isNotNull(dettPratica.getGeoOpereInSotterranea()) + && Validator.isNotNull(dettPratica.getGeoPericolositaGeologica()) + && Validator.isNotNull(dettPratica.getGeoPericolositaGeomorfica()) + && Validator.isNotNull(dettPratica.getGeoRischioGeomorfologicoPai()) + && Validator.isNotNull(dettPratica.getGeoPericolositaIdraulicaPai()) + && Validator.isNotNull(dettPratica.getGeoRischioIdraulicoPai()) + && Validator.isNotNull(dettPratica.getGeoPericolositaSismica()) + && Validator.isNotNull(dettPratica.getGeoFattibilitaSismica()) + && Validator.isNotNull(dettPratica.getGeoPericolositaIdraulica()) + && Validator.isNotNull(dettPratica.getGeoFattibilitaIdraulica()) + && Validator.isNotNull(dettPratica.getGeoFattibilitaGeologica()) + && Validator.isNotNull(dettPratica.getGeoPresenzaPrescrizioni()) + && Validator.isNotNull(dettPratica.getGeoEvidenzeGeologiche()) + && Validator.isNotNull(dettPratica.getGeoEvidenzeGeomorfiche()); List delegheGeologo = DelegaLocalServiceUtil.findByDettPratica_Tipologia_InEsito( dettPraticaId, DelegheUtil.TIPO_GEOLOGO, new String[] { DelegheUtil.STATO_ESEGUITA }, @@ -1202,105 +1195,35 @@ public class ValidazionePraticaUtil { List a14Docs = DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologia( dettPratica.getIntPraticaId(), DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A14, QueryUtil.ALL_POS, QueryUtil.ALL_POS); - boolean a14 = Validator.isNotNull(intPratica.getOldIntPraticaId()) ? true - : (!a14Docs.isEmpty() || !delegheGeologo.isEmpty()); + boolean a14 = !a14Docs.isEmpty() || !delegheGeologo.isEmpty(); if (!a14) { for (DocPratica doc : a14Docs) { // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - - if (!isAllRequiredValid(doc.getTipologia(), dettPratica.getIntPraticaId(), - signatures, - AsseverazioniUtil.getRequiredSubjectsByCodiceDoc(doc.getTipologia()), doc)) { - return false; - } + FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); + List signatures = firme.allSignatures(); + if (!isAllRequiredValid(doc.getTipologia(), dettPratica.getIntPraticaId(), signatures, + AsseverazioniUtil.getRequiredSubjectsByCodiceDoc(doc.getTipologia()), doc)) { + return false; } - } - } - - /*List a05Docs = DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologia( - dettPratica.getIntPraticaId(), DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A05, - QueryUtil.ALL_POS, QueryUtil.ALL_POS);*/ - // ADT BUG ID=20 (A05 SEMPRE OBBLIGATORIO SE NON SETTATO IL CHECK - // SULLA SEZIONE GEOLOGICA - /*if (a05) { - for (DocPratica doc : a05Docs) { - // List signaturesPerSubject = - // getSignaturePerSubject(intPraticaId, signatures, - // TipoSoggettoUtil.GEOLOGO, - // doc.getClassPk()); - // if (signaturesPerSubject.isEmpty()) { - // return false; - // } - - // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - - // ADT BUG ID = 19 - List firmeRichieste = AsseverazioniUtil.getRequiredSubjectsByCodiceDoc(doc - .getTipologia()); - List soggettiInseriti = SoggettoLocalServiceUtil - .findByIntPratica(dettPratica.getIntPraticaId()); - List firmeFiltrate = new ArrayList(); - for (String string : firmeRichieste) { - firmeFiltrate.add(string); - } - boolean DLPresente = false; - for (Soggetto soggetto : soggettiInseriti) { - if (soggetto.getTipologiaSoggetto().equals(TipoSoggettoUtil.DIRETTORE_LAVORI)) { - DLPresente = true; - } - } - if (!DLPresente || !dettPratica.isLavoriPubblici()) { - firmeFiltrate.remove(TipoSoggettoUtil.DIRETTORE_LAVORI); - } - if (!isAllRequiredValid(doc.getTipologia(), dettPratica.getIntPraticaId(), - signatures, firmeFiltrate, doc)) { - return false; - } - - } } - }*/ + } List a06Docs = DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologia( dettPratica.getIntPraticaId(), DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A06, QueryUtil.ALL_POS, QueryUtil.ALL_POS); - boolean a06 = Validator.isNotNull(intPratica.getOldIntPraticaId()) ? true : !a06Docs.isEmpty(); + boolean a06 = !a06Docs.isEmpty(); if (!a06Docs.isEmpty()) { for (DocPratica doc : a06Docs) { - - // List signaturesPerSubject = - // getSignaturePerSubject(intPraticaId, signatures, - // TipoSoggettoUtil.GEOLOGO, - // doc.getClassPk()); - // if (signaturesPerSubject.isEmpty()) { - // return false; - // } - - // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - if (!isA06Valid(dettPratica, dettPratica.getIntPraticaId(), signatures, doc)) { - // Return false if A06 doesn't contain (Progettista - // OR Geologo ) AND Direttore_Lavori - return false; - } + FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); + List signatures = firme.allSignatures(); + if (!isA06Valid(dettPratica, dettPratica.getIntPraticaId(), signatures, doc)) { + // Return false if A06 doesn't contain (Progettista + // OR Geologo ) AND Direttore_Lavori + return false; } } } @@ -1311,24 +1234,10 @@ public class ValidazionePraticaUtil { boolean a15 = true; if (!a15Docs.isEmpty()) { for (DocPratica doc : a15Docs) { - - // List signaturesPerSubject = - // getSignaturePerSubject(intPraticaId, signatures, - // TipoSoggettoUtil.GEOLOGO, - // doc.getClassPk()); - // if (signaturesPerSubject.isEmpty()) { - // return false; - // } - - // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - if (!isA07A15Valid(dettPratica, intPraticaId, signatures, doc)) { - return false; - } + FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); + List signatures = firme.allSignatures(); + if (!isA07A15Valid(dettPratica, intPraticaId, signatures, doc)) { + return false; } } } @@ -1337,24 +1246,17 @@ public class ValidazionePraticaUtil { List a16Docs = DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologie( intPraticaId, tipologiaAllegati.toArray(new String[0]), QueryUtil.ALL_POS, QueryUtil.ALL_POS); - boolean a16 = Validator.isNotNull(intPratica.getOldIntPraticaId()) ? true : !a16Docs.isEmpty(); + boolean a16 = !a16Docs.isEmpty(); if (!a16Docs.isEmpty()) { for (DocPratica doc : a16Docs) { + FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); + List signatures = firme.allSignatures(); - // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - - List signaturesPerSubject = getSignaturePerSubject(intPraticaId, signatures, - TipoSoggettoUtil.GEOLOGO, doc.getClassPk()); - if (signaturesPerSubject.isEmpty()) { - return false; - } + List signaturesPerSubject = getSignaturePerSubject(intPraticaId, signatures, + TipoSoggettoUtil.GEOLOGO, doc.getClassPk()); + if (signaturesPerSubject.isEmpty()) { + return false; } - } } @@ -1382,18 +1284,20 @@ public class ValidazionePraticaUtil { return Collections.emptyList(); } - if (Validator.isNull(intPratica.getOldIntPraticaId())) { - notCompleted.addAll(notCompletedDatiSezionGeologica(dettPraticaId)); - } + notCompleted.addAll(notCompletedDatiSezionGeologica(dettPraticaId)); if (!dettPratica.getNormArt3com3()) { long intPraticaId = dettPratica.getIntPraticaId(); List a14 = DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologia( dettPratica.getIntPraticaId(), DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A14, QueryUtil.ALL_POS, QueryUtil.ALL_POS); - /*List a05 = DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologia( - dettPratica.getIntPraticaId(), DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A05, - QueryUtil.ALL_POS, QueryUtil.ALL_POS);*/ + /* + * List a05 = + * DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologia( + * dettPratica.getIntPraticaId(), + * DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A05, QueryUtil.ALL_POS, + * QueryUtil.ALL_POS); + */ List a06 = DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologia( dettPratica.getIntPraticaId(), DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A06, QueryUtil.ALL_POS, QueryUtil.ALL_POS); @@ -1408,134 +1312,65 @@ public class ValidazionePraticaUtil { dettPraticaId, DelegheUtil.TIPO_GEOLOGO, new String[] { DelegheUtil.STATO_ESEGUITA }, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); - if (a14.isEmpty() && delegheGeologo.isEmpty() - && Validator.isNull(intPratica.getOldIntPraticaId())) { + if (a14.isEmpty() && delegheGeologo.isEmpty()) { notCompleted.add("A14 non presente"); } else { for (DocPratica doc : a14) { // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - - if (!isAllRequiredValid(doc.getTipologia(), dettPratica.getIntPraticaId(), - signatures, - AsseverazioniUtil.getRequiredSubjectsByCodiceDoc(doc.getTipologia()), doc)) { - GenericUtils.addIfnotExist(notCompleted, doc.getTipologia() - + " firme obbligatorie mancanti"); - } + FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); + List signatures = firme.allSignatures(); + if (!isAllRequiredValid(doc.getTipologia(), dettPratica.getIntPraticaId(), signatures, + AsseverazioniUtil.getRequiredSubjectsByCodiceDoc(doc.getTipologia()), doc)) { + GenericUtils.addIfnotExist(notCompleted, doc.getTipologia() + + " firme obbligatorie mancanti"); } } } - /*if (a05.isEmpty() && Validator.isNull(intPratica.getOldIntPraticaId())) { - // if(!dettPratica.isLavoriPubblici()){ - notCompleted.add("A05 non presente"); - // } - } else { - for (DocPratica doc : a05) { - - // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - - // ADT BUG ID = 19 - List firmeRichieste = AsseverazioniUtil.getRequiredSubjectsByCodiceDoc(doc - .getTipologia()); - - List soggettiInseriti = SoggettoLocalServiceUtil - .findByIntPratica(dettPratica.getIntPraticaId()); - List firmeFiltrate = new ArrayList(); - for (String string : firmeRichieste) { - firmeFiltrate.add(string); - } - boolean DLPresente = false; - for (Soggetto soggetto : soggettiInseriti) { - if (soggetto.getTipologiaSoggetto().equals(TipoSoggettoUtil.DIRETTORE_LAVORI)) { - DLPresente = true; - } - } - if (!DLPresente || !dettPratica.isLavoriPubblici()) { - firmeFiltrate.remove(TipoSoggettoUtil.DIRETTORE_LAVORI); - } - - if (!isAllRequiredValid(doc.getTipologia(), dettPratica.getIntPraticaId(), - signatures, firmeFiltrate, doc)) { - - GenericUtils.addIfnotExist(notCompleted, doc.getTipologia() - + " firme obbligatorie mancanti"); - } - } - } - }*/ - - if (a06.isEmpty() && Validator.isNull(intPratica.getOldIntPraticaId())) { + if (a06.isEmpty()) { notCompleted.add("A06 non presente"); } else { for (DocPratica doc : a06) { - - // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - if (!isA06Valid(dettPratica, dettPratica.getIntPraticaId(), signatures, doc)) { - // ADT: bug id=22 - notCompleted.add("A06 firme obbligatorie mancanti "); - } + FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); + List signatures = firme.allSignatures(); + if (!isA06Valid(dettPratica, dettPratica.getIntPraticaId(), signatures, doc)) { + // ADT: bug id=22 + notCompleted.add("A06 firme obbligatorie mancanti "); } } } - if (a15.isEmpty() && Validator.isNull(intPratica.getOldIntPraticaId())) { + if (a15.isEmpty()) { // SECONDO EMAIL DELLA PASOTTI DEL 26 Maggio questo documento // non è obbligatorio // notCompleted.add("A15 non presente"); } else { for (DocPratica doc : a15) { - - // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - if (!isA07A15Valid(dettPratica, intPraticaId, signatures, doc)) { - // ADT: bug id=22 - notCompleted.add("A15 firme obbligatorie mancanti"); - } + FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); + List signatures = firme.allSignatures(); + if (!isA07A15Valid(dettPratica, intPraticaId, signatures, doc)) { + // ADT: bug id=22 + notCompleted.add("A15 firme obbligatorie mancanti"); } } } - if (a16.isEmpty() && Validator.isNull(intPratica.getOldIntPraticaId())) { + if (a16.isEmpty()) { notCompleted.add("Indagini geologiche non presenti"); } else { for (DocPratica doc : a16) { + FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); + List signatures = firme.allSignatures(); - // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - - List signaturesPerSubject = getSignaturePerSubject(intPraticaId, signatures, - TipoSoggettoUtil.GEOLOGO, doc.getClassPk()); - if (signaturesPerSubject.isEmpty()) { - notCompleted.add(LanguageUtil.get(LocaleUtil.getDefault(), - "label-documenti-tipologia-" + doc.getTipologia()) - + " non firmato dal Geologo"); - } + List signaturesPerSubject = getSignaturePerSubject(intPraticaId, signatures, + TipoSoggettoUtil.GEOLOGO, doc.getClassPk()); + if (signaturesPerSubject.isEmpty()) { + notCompleted.add(LanguageUtil.get(LocaleUtil.getDefault(), + "label-documenti-tipologia-" + doc.getTipologia()) + + " non firmato dal Geologo"); } } @@ -1626,15 +1461,19 @@ public class ValidazionePraticaUtil { List notCompleted = new ArrayList<>(); // Allegati obbligatori devono essere presenti - /*int a05 = DocPraticaLocalServiceUtil.countValidTmpByIntPratica_Tipologia( - dettPratica.getIntPraticaId(), DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A05);*/ - - /*int a05 = 0; - if (a05 == 0) { - notCompleted.add(LanguageUtil.get(LocaleUtil.getDefault(), "label-documenti-tipologia-" - + DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A05) - + " non presente"); - }*/ + /* + * int a05 = + * DocPraticaLocalServiceUtil.countValidTmpByIntPratica_Tipologia( + * dettPratica.getIntPraticaId(), + * DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A05); + */ + + /* + * int a05 = 0; if (a05 == 0) { + * notCompleted.add(LanguageUtil.get(LocaleUtil.getDefault(), + * "label-documenti-tipologia-" + + * DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A05) + " non presente"); } + */ // int a06 = // DocPraticaLocalServiceUtil.countValidTmpByIntPratica_Tipologia(dettPratica.getIntPraticaId(), // DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A06); @@ -1672,22 +1511,16 @@ public class ValidazionePraticaUtil { boolean checkA06 = doc.getTipologia().equalsIgnoreCase( DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A06); - // Se da Portos 1 salto validazione - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } else { - FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); - List signatures = firme.allSignatures(); - - List signaturesPerSubject = getSignaturePerSubject(intPraticaId, signatures, - TipoSoggettoUtil.GEOLOGO, doc.getClassPk()); - // ADT : BUG FE ID=14 : CONTROLLO firma geologo A6 disabilitato - if (signaturesPerSubject.isEmpty() && (!checkA06)) { - notCompleted.add(LanguageUtil.get(LocaleUtil.getDefault(), "label-documenti-tipologia-" - + doc.getTipologia()) - + " non firmato dal Geologo"); - } + FirmeBean firme = FirmeUtil.deserialize(doc.getJsonFirmatari()); + List signatures = firme.allSignatures(); + List signaturesPerSubject = getSignaturePerSubject(intPraticaId, signatures, + TipoSoggettoUtil.GEOLOGO, doc.getClassPk()); + // ADT : BUG FE ID=14 : CONTROLLO firma geologo A6 disabilitato + if (signaturesPerSubject.isEmpty() && (!checkA06)) { + notCompleted.add(LanguageUtil.get(LocaleUtil.getDefault(), + "label-documenti-tipologia-" + doc.getTipologia()) + + " non firmato dal Geologo"); } } @@ -1703,9 +1536,6 @@ public class ValidazionePraticaUtil { List tipologiaAllegati = DocumentiPraticaUtil.getDocObbligatoriDomanda(intPratica .getTipoProcedura()); - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocObbligatoriDomandaPortos1()); - } // ASD List appTipologiaSoggetti = TipoSoggettoUtil.getAllSubjects(); @@ -1735,9 +1565,6 @@ public class ValidazionePraticaUtil { boolean contieneDocumenti = false; for (String codiceDoc : tipologiaAllegati) { - if (DocumentiPraticaUtil.getDocObbligatoriDomandaPortos1().contains(codiceDoc)) { - continue; - } if (isDocPraticaRequired(dettPratica, codiceDoc)) { List docs = DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologia( @@ -1749,11 +1576,6 @@ public class ValidazionePraticaUtil { } for (DocPratica doc : docs) { - // Se da Portos 1 non valido allegato - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } - // Se il documento proviene da una dett precedente non viene // controllato perche si presuppone che sia stata gia // verificato @@ -1768,11 +1590,11 @@ public class ValidazionePraticaUtil { GenericUtils.addAllIfnotExist(firmeTotali, signatures); boolean isEnoughOne = AsseverazioniUtil.isEnoughOne(codiceDoc); - /*if (codiceDoc.equalsIgnoreCase(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A00)) { - if (!isA00Valid(dettPratica, signatures)) { - return false; - } - } else */ + /* + * if (codiceDoc.equalsIgnoreCase(DocumentiPraticaUtil. + * TIPOLOGIA_ALLEGATO_A00)) { if (!isA00Valid(dettPratica, + * signatures)) { return false; } } else + */ if (codiceDoc.equalsIgnoreCase(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A06)) { if (!isA06Valid(dettPratica, intPraticaId, signatures, doc)) { // Return false if A06 doesn't contain (Progettista @@ -1819,11 +1641,6 @@ public class ValidazionePraticaUtil { } - // Se da Portos 1 non faccio i controlli successivi - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - return true; - } - // Ogni progettista e direttore dei lavori deve avere apposto almeno una // firma sulla totalità degli allegati if (contieneDocumenti) { @@ -1863,9 +1680,6 @@ public class ValidazionePraticaUtil { List tipologiaAllegati = DocumentiPraticaUtil.getDocObbligatoriDomanda(intPratica .getTipoProcedura()); - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocObbligatoriDomandaPortos1()); - } List tipologiaSoggettiApp = TipoSoggettoUtil.getAllSubjects(); List tipologiaSoggetti = new ArrayList(); @@ -1882,9 +1696,6 @@ public class ValidazionePraticaUtil { List firmeTotali = new ArrayList<>(); for (String codiceDoc : tipologiaAllegati) { - if (DocumentiPraticaUtil.getDocObbligatoriDomandaPortos1().contains(codiceDoc)) { - continue; - } if (isDocPraticaRequired(dettPratica, codiceDoc)) { List docs = DocPraticaLocalServiceUtil.getValidTmpByIntPratica_Tipologia( intPraticaId, codiceDoc, QueryUtil.ALL_POS, QueryUtil.ALL_POS); @@ -1897,12 +1708,6 @@ public class ValidazionePraticaUtil { + codiceDoc)); } for (DocPratica doc : docs) { - - // Se da Portos 1 non valido allegato - if (Validator.isNotNull(doc.getOldDocPraticaId())) { - continue; - } - // Se il documento proviene da una dett precedente non viene // controllato // perche si presuppone che sia stata gia verificato @@ -1916,13 +1721,14 @@ public class ValidazionePraticaUtil { GenericUtils.addAllIfnotExist(firmeTotali, signatures); boolean isEnoughOne = AsseverazioniUtil.isEnoughOne(codiceDoc); - /*if (codiceDoc.equalsIgnoreCase(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A00)) { - if (!isA00Valid(dettPratica, signatures)) { - // Return false if not esente spese + bolli - // ADT: bug id=22 - notCompleted.add("A00 firme obbligatorie mancanti"); - } - } else */ + /* + * if (codiceDoc.equalsIgnoreCase(DocumentiPraticaUtil. + * TIPOLOGIA_ALLEGATO_A00)) { if (!isA00Valid(dettPratica, + * signatures)) { // Return false if not esente spese + + * bolli // ADT: bug id=22 + * notCompleted.add("A00 firme obbligatorie mancanti"); } } + * else + */ if (codiceDoc.equalsIgnoreCase(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A06)) { if (!isA06Valid(dettPratica, intPraticaId, signatures, doc)) { // Return false if A06 doesn't contain (Progettista @@ -1983,11 +1789,6 @@ public class ValidazionePraticaUtil { } } - // Se da Portos 1 non faccio i controlli successivi - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - return notCompleted; - } - // Ogni progettista e direttore dei lavori deve avere apposto almeno una // firma sulla totalità // degli allegati @@ -2040,17 +1841,14 @@ public class ValidazionePraticaUtil { // ADT BUG ID = 5 switch (codiceDoc) { - /*case DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A00: - IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - return false; - } - // ADT BUG ID = 5 - if (isRiparazioneLocale(dettPratica)) { - return false; - } - return !dettPratica.getNormEsenteSpese();*/ - //case DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A05: + /* + * case DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A00: IntPratica + * intPratica = + * IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId + * ()); // ADT BUG ID = 5 if (isRiparazioneLocale(dettPratica)) { return + * false; } return !dettPratica.getNormEsenteSpese(); + */ + // case DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A05: case DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A06: case DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A07: // case DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A14: diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/content/Portal.properties b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/content/Portal.properties index 2b8281d0..882123cd 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/content/Portal.properties +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/content/Portal.properties @@ -816,15 +816,13 @@ label-documenti-tipologia-A01 = A1 - Planimetria generale label-documenti-tipologia-A02 = A2 - Progetto label-documenti-tipologia-A03 = A3 - Relazione tecnica generale label-documenti-tipologia-A04 = A4 - Relazione materiali impiegati -label-documenti-tipologia-A06 = A6 - Relazione idrogeomorfologica / Autorizzazione PAI -label-documenti-tipologia-A07 = A7 - Viarch +label-documenti-tipologia-A05 = A5 - Relazione geologica label-documenti-tipologia-A08 = A8 - Relazione di calcolo label-documenti-tipologia-A09 = A9 - Documentazione fotografica label-documenti-tipologia-A10 = A10 - Particolari costruttivi e sezioni di scavo label-documenti-tipologia-A11 = A11 - Relazione paesaggistica label-documenti-tipologia-A12 = A12 - Titolo di proprietà label-documenti-tipologia-A13 = A13 - Piano di Manutenzione -label-documenti-tipologia-A14 = A14 - Titoli di legittimità label-documenti-tipologia-A15 = A15 - Dichiarazione sulla data di realizzazione delle opere abusive label-documenti-tipologia-A16 = A16 - Copia conforme della domanda di sanatoria depositata al Comune label-documenti-tipologia-A17 = A17 - Certificazione Legge n. 326/2003 @@ -832,21 +830,16 @@ label-documenti-tipologia-A18 = A18 - Copia conforme della dichiarazione deposit label-documenti-tipologia-A19 = A19 - Dichiarazione sul valore delle opere realizzate abusivamente label-documenti-tipologia-A20 = A20 - Visura catastale label-documenti-tipologia-A21 = A21 - Certificato di residenza di tutti i proprietari +label-documenti-tipologia-A22 = A22 - Relazione idrogeomorfologica +label-documenti-tipologia-A23 = A23 - Autorizzazione PAI +label-documenti-tipologia-A24 = A24 - Viarch +label-documenti-tipologia-A25 = A25 - Dichiarazione assenza scavi - sorveglianza / fibra ottica +label-documenti-tipologia-A26 = A26 - Titoli di legittimità +label-documenti-tipologia-A27 = A27 - Dichiarazione collaudo label-documenti-tipologia-A98 = Deleghe label-documenti-tipologia-A99 = Altri label-documenti-tipologia-dnf = Pratica non firmata -label-documenti-tipologia-A0P = Contributo per le spese di istruttoria e di conservazione dei progetti -label-documenti-tipologia-111 = Domanda Firmata -label-documenti-tipologia-111I = Integrazione Firmata - Portos 1 -label-documenti-tipologia-111F = Fine Lavori - Portos 1 -label-documenti-tipologia-111FP = Fine Lavori Parziale - Portos 1 -label-documenti-tipologia-111C = Collaudo - Portos 1 -label-documenti-tipologia-111CP = Collaudo Parziale - Portos 1 -label-documenti-tipologia-111A = Annullamento Domanda -label-documenti-tipologia-CCA = Certificato Calcestruzzo - Portos 1 -label-documenti-tipologia-CAC = Certificato Acciaio - Portos 1 label-documenti-tipologia-Afl = Altri -label-documenti-tipologia-111VS = Documento Variazione Soggetto - Portos 1 label-documenti-tipologia-APM = Ricevuta Pagamento Manuale label-documenti-tipologia-AGL = Giornale dei Lavori diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java index f78b57f1..1b9a6464 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java @@ -31,7 +31,6 @@ import it.tref.liferay.portos.bo.shared.util.DocumentiPraticaUtil; import it.tref.liferay.portos.bo.shared.util.PortletKeys; import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil; -import it.tref.liferay.portos.bo.util.Constants; import it.tref.liferay.portos.bo.util.FilesImporter; import it.tref.liferay.portos.bo.util.PraticaUtil; import it.tref.liferay.portos.bo.util.ValidazionePraticaUtil; @@ -41,7 +40,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -101,654 +99,646 @@ import com.liferay.util.bridges.mvc.MVCPortlet; */ public class FascicoloPortlet extends MVCPortlet { - private Log _log = LogFactoryUtil.getLog(FascicoloPortlet.class); - - @Override - public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { - - HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(request)); - String intPraticaId = httpReq.getParameter("intPraticaId"); - - if (Validator.isNotNull(intPraticaId) && !intPraticaId.equals("")) { - request.setAttribute("intPraticaId", intPraticaId); - } - - super.render(request, response); - } - - public void toggleWorkflow(ActionRequest actionRequest, ActionResponse actionResponse) { - - - ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); - User user = themeDisplay.getUser(); - - boolean attivare = ParamUtil.getBoolean(actionRequest, "avviare"); - boolean sospendere = ParamUtil.getBoolean(actionRequest, "sospendere"); - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); - String stato_pratica= ParamUtil.getString(actionRequest, "seleziona_stato"); - - try { - - IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); - Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); - DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId); - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); - - if (attivare && !sospendere) { - WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), serviceContext.getUserId(), - dettPratica.getDettPraticaId(), serviceContext, true); - - addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), - themeDisplay.getCompanyId(), intPratica.getGroupId(), user, true); - - SessionMessages.add(actionRequest, "success-workflow-ripreso"); - } else if (!attivare && sospendere) { - WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), serviceContext.getUserId(), - dettPratica.getDettPraticaId(), serviceContext, false); - - addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), - themeDisplay.getCompanyId(), intPratica.getGroupId(), user, false); - - SessionMessages.add(actionRequest, "success-workflow-sospeso"); - } else { - SessionErrors.add(actionRequest, "error-workflow-stato-incosistente"); - } - - String redirectURL = ParamUtil.getString(actionRequest, "redirect"); - if (Validator.isNotNull(redirectURL)) { - actionResponse.sendRedirect(redirectURL); - } - - if(!attivare){ - intPratica.setStatoPratica(stato_pratica); - IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, stato_pratica); - } else { - intPratica.setStatoPratica(StatoPraticaConstants.SOTTOPOSTA_A_PARERE); - IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, StatoPraticaConstants.SOTTOPOSTA_A_PARERE); - } - - - IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, intPratica.getCompanyId()); - - } catch (Exception e) { - _log.error("error-workflow-sospeso", e); - SessionErrors.add(actionRequest, attivare ? "error-workflow-sospeso" : "error-workflow-ripreso"); - } - - } - - private void addRowHistoryWorkflowAction(long intPraticaId, long dettPraticaId, long companyId, long groupId, User user, boolean attivato) throws SystemException{ - - HistoryWorkflowAction historyWorkflowAction = HistoryWorkflowActionLocalServiceUtil.createHistoryWorkflowAction( - CounterLocalServiceUtil.increment(HistoryWorkflowAction.class.getName())); - - historyWorkflowAction.setAttivato(attivato); - historyWorkflowAction.setCompanyId(companyId); - historyWorkflowAction.setCreateDate(new Date()); - historyWorkflowAction.setModifiedDate(new Date()); - historyWorkflowAction.setUserId(user.getUserId()); - historyWorkflowAction.setUserName(user.getScreenName()); - historyWorkflowAction.setIntPraticaId(intPraticaId); - historyWorkflowAction.setDettPraticaId(dettPraticaId); - historyWorkflowAction.setGroupId(groupId); - - HistoryWorkflowActionLocalServiceUtil.updateHistoryWorkflowAction(historyWorkflowAction); - - } - - public void toggleSospensione(ActionRequest actionRequest, ActionResponse actionResponse) { - - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); - boolean sospesa = ParamUtil.getBoolean(actionRequest, "sospesa"); - - try { - - IntPraticaServiceUtil.sospendiPratica(intPraticaId, sospesa); - SessionMessages.add(actionRequest, sospesa ? "success-sospesa" : "success-ripresa"); - - } catch (PortalException | SystemException e) { - _log.error("error-workflow-sospeso", e); - SessionErrors.add(actionRequest, sospesa ? "error-sospesa" : "error-ripresa"); - } - - } - - public void cambiaStato(ActionRequest actionRequest, ActionResponse actionResponse) { - - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); - String statoPratica = ParamUtil.getString(actionRequest, "nuovoStatoPratica"); - - _log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId); - try { - _log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId + " NUOVO STATO: " + statoPratica); - IntPraticaServiceUtil.updateStatoPratica(intPraticaId, statoPratica); - SessionMessages.add(actionRequest, "success-cambio-stato"); - } catch (PortalException | SystemException e) { - _log.error("error-workflow-sospeso", e); - SessionErrors.add(actionRequest, "error-cambio-stato"); - } - - } - - public void aggiungiRichiestaParere(ActionRequest actionRequest, ActionResponse actionResponse) { - - long geologoId = ParamUtil.getLong(actionRequest, "geologoId"); - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId"); - long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); - - try { - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); - serviceContext.setCreateDate(new Date()); - serviceContext.setModifiedDate(new Date()); - ParereGeologoServiceUtil.addParereGeologo(geologoId, intPraticaId, dettPraticaId, serviceContext); - } catch (PortalException | SystemException e) { - _log.error("error-workflow-sospeso", e); - SessionErrors.add(actionRequest, "error-aggiunta-richiesta-parere"); - } - } - - public void cambiaTitolare(ActionRequest actionRequest, ActionResponse actionResponse) { - - String nuovoSoggettoCF = ParamUtil.getString(actionRequest, "nuovoSoggettoCF"); - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); - long companyId = ParamUtil.getLong(actionRequest, "companyId"); - - - try { - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); - User user = UserLocalServiceUtil.fetchUserByScreenName(companyId, nuovoSoggettoCF); - if (Validator.isNotNull(user)) { - if (!ValidazionePraticaUtil.praticaInProgress(intPraticaId)) { - _log.info("cambiaTitolare: cfNuovoTitolare " + nuovoSoggettoCF + " intpratica" + intPraticaId); - IntPraticaServiceUtil.cambiaTitolare(intPraticaId, user.getUserId(), serviceContext); - SessionMessages.add(actionRequest, "success-cambio-titolare"); - } else { - SessionErrors.add(actionRequest, "error-cambio-titolare-pratica-in-progress"); - } - } else { - _log.error("[FASCICOLO ACTION - CAMBIO TITOLARE] Nessun utente trovato con company " + companyId - + " e codice fiscale " + nuovoSoggettoCF); - SessionErrors.add(actionRequest, "error-cambio-titolare-no-such-user"); - } - } catch (PortalException | SystemException e) { - _log.error("error-cambio-titolare", e); - SessionErrors.add(actionRequest, "error-cambio-titolare"); - } - - } - - public void searchURL(ActionRequest actionRequest, ActionResponse actionResponse) { - - String numeroProgetto = actionRequest.getParameter("numeroProgetto"); - String protocollo = actionRequest.getParameter("protocollo"); - String tipoPratica = actionRequest.getParameter("tipoPratica"); - String statoPratica = actionRequest.getParameter("statoPratica"); - String committente = actionRequest.getParameter("committente"); - String descInterventoSearch = actionRequest.getParameter("descIntervento"); - String tecnicoIstruttore = actionRequest.getParameter("tecnicoIstruttore"); - String titolareDigitale = actionRequest.getParameter("titolareDigitale"); - String soggettiInterconnessi = actionRequest.getParameter("soggettiInterconnessi"); - String dataRichiestaInizio = actionRequest.getParameter("dataRichiestaInizio"); - String dataRichiestaFine = actionRequest.getParameter("dataRichiestaFine"); - String provincia = actionRequest.getParameter("provincia"); - String praticaAperta = actionRequest.getParameter("praticaAperta"); - String comune = actionRequest.getParameter("comune"); - String tipoIntervento = actionRequest.getParameter("tipoIntervento"); - String indirizzo = actionRequest.getParameter("indirizzo"); - - if (dataRichiestaInizio != null && !dataRichiestaInizio.equals("")) { - String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split("/"); - - int mounth = Integer.valueOf(dataRichiestaInizioSplitted[1]) -1; - - actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]); - actionResponse.setRenderParameter("dataRichiestaInizioMonth", mounth+""); - actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]); - } - - if (dataRichiestaFine != null && !dataRichiestaFine.equals("")) { - String[] dataRichiestaFineSplitted = dataRichiestaFine.split("/"); - - int mounth = Integer.valueOf(dataRichiestaFineSplitted[1]) -1; - - actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]); - actionResponse.setRenderParameter("dataRichiestaFineMonth", mounth+""); - actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]); - } - - - String ufficio = actionRequest.getParameter("ufficio"); - String ordinaPer = actionRequest.getParameter("ordinaPer"); - String ordinaTipo = actionRequest.getParameter("ordinaTipo"); - - if (tipoIntervento != null && !tipoIntervento.equals("")) { - actionResponse.setRenderParameter("tipoIntervento", tipoIntervento); - } - - actionResponse.setRenderParameter("numeroProgetto", numeroProgetto); - actionResponse.setRenderParameter("praticaAperta", praticaAperta); - actionResponse.setRenderParameter("descIntervento", descInterventoSearch); - actionResponse.setRenderParameter("protocollo", protocollo); - actionResponse.setRenderParameter("tipoPratica", tipoPratica); - actionResponse.setRenderParameter("tipoPratica", tipoPratica); - actionResponse.setRenderParameter("statoPratica", statoPratica); - actionResponse.setRenderParameter("committente", committente); - - if(provincia != null && !provincia.equals("")){ - actionResponse.setRenderParameter("provincia", provincia); - } - - if(comune != null && !comune.equals("")){ - actionResponse.setRenderParameter("comune", comune); - } - - actionResponse.setRenderParameter("indirizzo", indirizzo); - - if (tecnicoIstruttore != null && !tecnicoIstruttore.equals("")) { - actionResponse.setRenderParameter("tecnicoIstruttore", tecnicoIstruttore); - } else { - actionResponse.setRenderParameter("tecnicoIstruttore", StringPool.BLANK); - } - - actionResponse.setRenderParameter("titolareDigitale", titolareDigitale); - actionResponse.setRenderParameter("soggettiInterconnessi", soggettiInterconnessi); - actionResponse.setRenderParameter("dataRichiestaInizio", dataRichiestaInizio); - actionResponse.setRenderParameter("dataRichiestaFine", dataRichiestaFine); - - if (ufficio != null && !ufficio.equals("")) { - actionResponse.setRenderParameter("ufficio", ufficio); - } else { - actionResponse.setRenderParameter("ufficio", -1 + ""); - } - - - actionResponse.setRenderParameter("ordinaPer", ordinaPer); - actionResponse.setRenderParameter("ordinaTipo", ordinaTipo); - - } - - public void versiona(ActionRequest actionRequest, ActionResponse actionResponse) { - - long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0); - long companyId = ParamUtil.getLong(actionRequest, "companyId"); - - - try { - DettPraticaServiceUtil.sendToVersioning(dettPraticaId, companyId); - - } catch (PortalException | SystemException | IOException | NoSuchFieldException | SecurityException e) { - _log.error("error-versioning", e); - SessionErrors.add(actionRequest, "error-versioning"); - } - - PortalUtil.copyRequestParameters(actionRequest, actionResponse); - - } - - @Override - public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, - PortletException { - - String id = resourceRequest.getResourceID(); - ServiceContext serviceContext; - try { - serviceContext = ServiceContextFactory.getInstance(resourceRequest); - if ("downloadAllDocPratica".equals(id)) { - - long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); - long classPk = ParamUtil.getLong(resourceRequest, "classPk"); - String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom"); - List docs = new ArrayList<>(); - if (Validator.isNull(comingFrom)) { - docs = DocPraticaLocalServiceUtil.findByClassPk(classPk); - } else { - List tipologieAllegati = new ArrayList(); - if ("page_geologica".equals(comingFrom)) { - tipologieAllegati = DocumentiPraticaUtil.getDocGeologo(); - } else if ("page_allegati".equals(comingFrom)) { - tipologieAllegati = DocumentiPraticaUtil.getDocDomanda(); - IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - tipologieAllegati.addAll(0, DocumentiPraticaUtil.getDocDomandaPortos1()); - } - } else if ("page_fine_lavori".equals(comingFrom)) { - tipologieAllegati = DocumentiPraticaUtil.getDocFineLavori(); - } else if ("page_collaudo".equals(comingFrom)) { - tipologieAllegati = DocumentiPraticaUtil.getDocCollaudo(); - } - docs = - DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId, classPk, tipologieAllegati); - } - - ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter(); - - for (DocPratica doc : docs) { - - InputStream inputStream = null; - try { - if (Validator.isNull(doc.getDlFileEntryId())) { - continue; - } - FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getDlFileEntryId()); - inputStream = - DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(), fileEntry.getVersion(), false); - - // String name = fileEntry.getTitle() + StringPool.PERIOD + fileEntry.getExtension(); - String name = fileEntry.getTitle(); - zipWriter.addEntry(name, inputStream); - } finally { - StreamUtil.cleanUp(inputStream); - } - } - - resourceResponse.reset(); - - File file = zipWriter.getFile(); - byte[] data = Files.readAllBytes(file.toPath()); - - resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP); - resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); - resourceResponse - .addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\""); - resourceResponse.setContentLength(data.length); - - resourceResponse.getPortletOutputStream().write(data); - resourceResponse.getPortletOutputStream().flush(); - resourceResponse.getPortletOutputStream().close(); - - } else if ("importFile".equals(id)) { - - long classPk = ParamUtil.getLong(resourceRequest, "classPk"); - String className = ParamUtil.getString(resourceRequest, "className"); - - FilesImporter.importaFile(classPk, className); - - // if (DocPratica.class.getName().equalsIgnoreCase(className)) { - // DocPratica docPratica = DocPraticaLocalServiceUtil.getDocPratica(classPk); - // if (docPratica.getDlFileEntryId() == 0L && docPratica.getOldDlFileEntryId() != 0L) { - // FilesImporter.handleFileImportDocPratica(docPratica); - // } - // } else if (Avviso.class.getName().equalsIgnoreCase(className)) { - // Avviso avviso = AvvisoLocalServiceUtil.getAvviso(classPk); - // if (avviso.getFileEntryIdBase() == 0L && avviso.getOldFileEntryIdBase() != 0L) { - // FilesImporter.handleFileImportAvviso(avviso, true); - // } - // if (avviso.getFileEntryIdInvio() == 0L && avviso.getOldFileEntryIdInvio() != 0L) { - // FilesImporter.handleFileImportAvviso(avviso, false); - // } - // } else if (Pagamento.class.getName().equalsIgnoreCase(className)) { - // Pagamento pagamento = PagamentoLocalServiceUtil.getPagamento(classPk); - // if (pagamento.getFileEntryId() == 0L && pagamento.getOldFileEntryId() != 0L) { - // FilesImporter.handleFileImportPagamento(pagamento); - // } - // } else if (DocAggiuntiva.class.getName().equalsIgnoreCase(className)) { - // DocAggiuntiva docAggiuntiva = DocAggiuntivaLocalServiceUtil.getDocAggiuntiva(classPk); - // if (docAggiuntiva.getFileEntryId() == 0L && docAggiuntiva.getOldFileEntryId() != 0L) { - // FilesImporter.handleFileImportDocAggiuntiva(docAggiuntiva); - // } - // } else if (AllegatoManuale.class.getName().equalsIgnoreCase(className)) { - // AllegatoManuale allegatoManuale = - // AllegatoManualeLocalServiceUtil.getAllegatoManuale(classPk); - // if (allegatoManuale.getFileEntryId() == 0L && allegatoManuale.getOldFileEntryId() != 0L) - // { - // FilesImporter.handleFileImportAllegatoManuale(allegatoManuale); - // } - // } - - PortletResponseUtil - .write( - resourceResponse, - "

Completato

Refresh"); - - } else if ("importAllFascicoloFiles".equals(id)) { - long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); - IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); - - if (Validator.isNull(intPratica)) { - _log.error("error.no.intpratica.exist with intpraticaid=" + intPraticaId); - } - - String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom", "bo"); - InfoFascicolo infoFascicolo = InfoFascicoloLocalServiceUtil.fetchByIntPratica(intPratica.getIntPraticaId()); - if (Validator.isNull(infoFascicolo)) { - infoFascicolo = - InfoFascicoloLocalServiceUtil.addInfoFascicolo(intPratica.getIntPraticaId(), - intPratica.getNumeroProgetto(), serviceContext); - } else { - if (infoFascicolo.getAlreadyImported() && comingFrom.equalsIgnoreCase("fe")) { - _log.error("intpratica.import.file.already-clicked with intpraticaid=" + intPraticaId); - return; - } - } - - User user = UserLocalServiceUtil.fetchUser(serviceContext.getUserId()); - - _log.debug("************** START IMPORT FILES FASCICOLO : " + intPraticaId + " by user" + user.getFullName()); - - List listaDet = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); - for (DettPratica dettPratica : listaDet) { - FilesImporter.importaFilesFascicolo(dettPratica.getDettPraticaId(), DettPratica.class.getName()); - } - - List listaFine = FineLavoriLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, -1, null); - for (FineLavori fineLavori : listaFine) { - FilesImporter.importaFilesFascicolo(fineLavori.getFineLavoriId(), FineLavori.class.getName()); - } - - List listaColl = CollaudoLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, -1, null); - for (Collaudo collaudo : listaColl) { - FilesImporter.importaFilesFascicolo(collaudo.getCollaudoId(), Collaudo.class.getName()); - } - - _log.debug("************** END IMPORT FILES FASCICOLO : " + intPraticaId); - - infoFascicolo.setAlreadyImported(true); - infoFascicolo = InfoFascicoloLocalServiceUtil.updateInfoFascicolo(infoFascicolo); - - PortletResponseUtil - .write( - resourceResponse, - "

Completato

Refresh"); - } else if ("comuni".equals(id)) { - String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId"); - JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); - if (Validator.isNotNull(provinciaId) && !provinciaId.equals("0")) { - List comuniIds = TerritorioLocalServiceUtil.getActiveComuniByCodiceProvincia(provinciaId); - - //ADT BUG-ID=15 Sezione Ricerca / Ordinamento Filtro - List comumeList = new ArrayList(); - for (long comuneId : comuniIds) { - Comune comune = ComuneLocalServiceUtil.getComune(comuneId); - comumeList.add(comune); - } - - Collections.sort(comumeList, new Comparator() { - @Override - public int compare(Comune o1, Comune o2) { - return o1.getDenominazione().compareTo(o2.getDenominazione()); - } - }); - - for (Comune comune : comumeList) { - JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); - jsonObject.put("comuneId", comune.getComuneId()); - jsonObject.put("descLong", comune.getDenominazione()); - - jsonArray.put(jsonObject); - } - } - writeJSON(resourceRequest, resourceResponse, jsonArray); - - } else if("exportRicerca".equals(id)){ - - ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); - Locale locale = themeDisplay.getLocale(); - - User user = themeDisplay.getUser(); - - - String csv = StringPool.BLANK; - - HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); - HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); - - csv = exportSearch(locale, resourceRequest, user); - - ServletResponseUtil.sendFile(request, response, "export_ricerca.csv", csv.getBytes(StringPool.UTF8), - ContentTypes.TEXT_CSV_UTF8); - - }else { - super.serveResource(resourceRequest, resourceResponse); - } - } catch (Exception e) { - _log.error(e, e); - throw new IOException(e); - } - - } - - private String exportSearch(Locale locale, ResourceRequest resourceRequest, User user) { - String method = "exportSearch"; - - HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(resourceRequest); - StringBuilder sb = new StringBuilder(); - - List lista = new ArrayList(); - -// try { - - Hits hits = IntPraticaAdvancedSearch.searchProgettiBO(httpRequest, user, -1, -1); - - for (Document doc : hits.toList()) { - String intPraticaId = doc.get("intPraticaId"); - try { - if (Validator.isNotNull(intPraticaId)) { - IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil.getLong(intPraticaId)); - if (Validator.isNotNull(intPratica)) { - lista.add(intPratica); - } - } - } catch(Throwable e){ - _log.error(method + " IntPraticaLocalServiceUtil.fetchIntPratica IntPraticaId: " + intPraticaId, e); - } - } - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.sorteggiata"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.pratica"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.titolare"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.committenti"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.istruttore"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.statoPratica"))); - sb.append(StringPool.SEMICOLON); - - //ADT BUG-ID=15 Sezione Ricerca / Export csv - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provincia"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.comune"))); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.descrizioneIntervento"))); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - - - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); - - for (IntPratica intPratica : lista) { - - try{ - DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPratica.getIntPraticaId()); - - Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId()); - Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); - - Provincia provincia = - ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia()); - - boolean sorteggiata = SorteggioLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()) != null; - sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No")); - sb.append(StringPool.SEMICOLON); - - String praticaLabel = intPratica.getTitle(locale, true); - sb.append(CSVUtil.encode(praticaLabel)); - sb.append(StringPool.SEMICOLON); - - User titolareUser = UserLocalServiceUtil.getUserById(intPratica.getUserId()); - List titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(lastDettPratica.getIntPraticaId(), lastDettPratica.getCodiceFiscaleDelegatoCommittente()); + private Log _log = LogFactoryUtil.getLog(FascicoloPortlet.class); + + @Override + public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { + + HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil + .getHttpServletRequest(request)); + String intPraticaId = httpReq.getParameter("intPraticaId"); + + if (Validator.isNotNull(intPraticaId) && !intPraticaId.equals("")) { + request.setAttribute("intPraticaId", intPraticaId); + } + + super.render(request, response); + } + + public void toggleWorkflow(ActionRequest actionRequest, ActionResponse actionResponse) { + + ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); + User user = themeDisplay.getUser(); + + boolean attivare = ParamUtil.getBoolean(actionRequest, "avviare"); + boolean sospendere = ParamUtil.getBoolean(actionRequest, "sospendere"); + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); + String stato_pratica = ParamUtil.getString(actionRequest, "seleziona_stato"); + + try { + + IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); + Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); + DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId); + ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + + if (attivare && !sospendere) { + WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), + serviceContext.getUserId(), dettPratica.getDettPraticaId(), serviceContext, true); + + addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), + themeDisplay.getCompanyId(), intPratica.getGroupId(), user, true); + + SessionMessages.add(actionRequest, "success-workflow-ripreso"); + } else if (!attivare && sospendere) { + WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), + serviceContext.getUserId(), dettPratica.getDettPraticaId(), serviceContext, false); + + addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), + themeDisplay.getCompanyId(), intPratica.getGroupId(), user, false); + + SessionMessages.add(actionRequest, "success-workflow-sospeso"); + } else { + SessionErrors.add(actionRequest, "error-workflow-stato-incosistente"); + } + + String redirectURL = ParamUtil.getString(actionRequest, "redirect"); + if (Validator.isNotNull(redirectURL)) { + actionResponse.sendRedirect(redirectURL); + } + + if (!attivare) { + intPratica.setStatoPratica(stato_pratica); + IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, stato_pratica); + } else { + intPratica.setStatoPratica(StatoPraticaConstants.SOTTOPOSTA_A_PARERE); + IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, + StatoPraticaConstants.SOTTOPOSTA_A_PARERE); + } + + IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, intPratica.getCompanyId()); + + } catch (Exception e) { + _log.error("error-workflow-sospeso", e); + SessionErrors.add(actionRequest, attivare ? "error-workflow-sospeso" : "error-workflow-ripreso"); + } + + } + + private void addRowHistoryWorkflowAction(long intPraticaId, long dettPraticaId, long companyId, + long groupId, User user, boolean attivato) throws SystemException { + + HistoryWorkflowAction historyWorkflowAction = HistoryWorkflowActionLocalServiceUtil + .createHistoryWorkflowAction(CounterLocalServiceUtil.increment(HistoryWorkflowAction.class + .getName())); + + historyWorkflowAction.setAttivato(attivato); + historyWorkflowAction.setCompanyId(companyId); + historyWorkflowAction.setCreateDate(new Date()); + historyWorkflowAction.setModifiedDate(new Date()); + historyWorkflowAction.setUserId(user.getUserId()); + historyWorkflowAction.setUserName(user.getScreenName()); + historyWorkflowAction.setIntPraticaId(intPraticaId); + historyWorkflowAction.setDettPraticaId(dettPraticaId); + historyWorkflowAction.setGroupId(groupId); + + HistoryWorkflowActionLocalServiceUtil.updateHistoryWorkflowAction(historyWorkflowAction); + + } + + public void toggleSospensione(ActionRequest actionRequest, ActionResponse actionResponse) { + + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); + boolean sospesa = ParamUtil.getBoolean(actionRequest, "sospesa"); + + try { + + IntPraticaServiceUtil.sospendiPratica(intPraticaId, sospesa); + SessionMessages.add(actionRequest, sospesa ? "success-sospesa" : "success-ripresa"); + + } catch (PortalException | SystemException e) { + _log.error("error-workflow-sospeso", e); + SessionErrors.add(actionRequest, sospesa ? "error-sospesa" : "error-ripresa"); + } + + } + + public void cambiaStato(ActionRequest actionRequest, ActionResponse actionResponse) { + + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); + String statoPratica = ParamUtil.getString(actionRequest, "nuovoStatoPratica"); + + _log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId); + try { + _log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId + " NUOVO STATO: " + statoPratica); + IntPraticaServiceUtil.updateStatoPratica(intPraticaId, statoPratica); + SessionMessages.add(actionRequest, "success-cambio-stato"); + } catch (PortalException | SystemException e) { + _log.error("error-workflow-sospeso", e); + SessionErrors.add(actionRequest, "error-cambio-stato"); + } + + } + + public void aggiungiRichiestaParere(ActionRequest actionRequest, ActionResponse actionResponse) { + + long geologoId = ParamUtil.getLong(actionRequest, "geologoId"); + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId"); + long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); + + try { + ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + serviceContext.setCreateDate(new Date()); + serviceContext.setModifiedDate(new Date()); + ParereGeologoServiceUtil.addParereGeologo(geologoId, intPraticaId, dettPraticaId, serviceContext); + } catch (PortalException | SystemException e) { + _log.error("error-workflow-sospeso", e); + SessionErrors.add(actionRequest, "error-aggiunta-richiesta-parere"); + } + } + + public void cambiaTitolare(ActionRequest actionRequest, ActionResponse actionResponse) { + + String nuovoSoggettoCF = ParamUtil.getString(actionRequest, "nuovoSoggettoCF"); + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); + long companyId = ParamUtil.getLong(actionRequest, "companyId"); + + try { + ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + User user = UserLocalServiceUtil.fetchUserByScreenName(companyId, nuovoSoggettoCF); + if (Validator.isNotNull(user)) { + if (!ValidazionePraticaUtil.praticaInProgress(intPraticaId)) { + _log.info("cambiaTitolare: cfNuovoTitolare " + nuovoSoggettoCF + " intpratica" + + intPraticaId); + IntPraticaServiceUtil.cambiaTitolare(intPraticaId, user.getUserId(), serviceContext); + SessionMessages.add(actionRequest, "success-cambio-titolare"); + } else { + SessionErrors.add(actionRequest, "error-cambio-titolare-pratica-in-progress"); + } + } else { + _log.error("[FASCICOLO ACTION - CAMBIO TITOLARE] Nessun utente trovato con company " + + companyId + " e codice fiscale " + nuovoSoggettoCF); + SessionErrors.add(actionRequest, "error-cambio-titolare-no-such-user"); + } + } catch (PortalException | SystemException e) { + _log.error("error-cambio-titolare", e); + SessionErrors.add(actionRequest, "error-cambio-titolare"); + } + + } + + public void searchURL(ActionRequest actionRequest, ActionResponse actionResponse) { + + String numeroProgetto = actionRequest.getParameter("numeroProgetto"); + String protocollo = actionRequest.getParameter("protocollo"); + String tipoPratica = actionRequest.getParameter("tipoPratica"); + String statoPratica = actionRequest.getParameter("statoPratica"); + String committente = actionRequest.getParameter("committente"); + String descInterventoSearch = actionRequest.getParameter("descIntervento"); + String tecnicoIstruttore = actionRequest.getParameter("tecnicoIstruttore"); + String titolareDigitale = actionRequest.getParameter("titolareDigitale"); + String soggettiInterconnessi = actionRequest.getParameter("soggettiInterconnessi"); + String dataRichiestaInizio = actionRequest.getParameter("dataRichiestaInizio"); + String dataRichiestaFine = actionRequest.getParameter("dataRichiestaFine"); + String provincia = actionRequest.getParameter("provincia"); + String praticaAperta = actionRequest.getParameter("praticaAperta"); + String comune = actionRequest.getParameter("comune"); + String tipoIntervento = actionRequest.getParameter("tipoIntervento"); + String indirizzo = actionRequest.getParameter("indirizzo"); + + if (dataRichiestaInizio != null && !dataRichiestaInizio.equals("")) { + String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split("/"); + + int mounth = Integer.valueOf(dataRichiestaInizioSplitted[1]) - 1; + + actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]); + actionResponse.setRenderParameter("dataRichiestaInizioMonth", mounth + ""); + actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]); + } + + if (dataRichiestaFine != null && !dataRichiestaFine.equals("")) { + String[] dataRichiestaFineSplitted = dataRichiestaFine.split("/"); + + int mounth = Integer.valueOf(dataRichiestaFineSplitted[1]) - 1; + + actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]); + actionResponse.setRenderParameter("dataRichiestaFineMonth", mounth + ""); + actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]); + } + + String ufficio = actionRequest.getParameter("ufficio"); + String ordinaPer = actionRequest.getParameter("ordinaPer"); + String ordinaTipo = actionRequest.getParameter("ordinaTipo"); + + if (tipoIntervento != null && !tipoIntervento.equals("")) { + actionResponse.setRenderParameter("tipoIntervento", tipoIntervento); + } + + actionResponse.setRenderParameter("numeroProgetto", numeroProgetto); + actionResponse.setRenderParameter("praticaAperta", praticaAperta); + actionResponse.setRenderParameter("descIntervento", descInterventoSearch); + actionResponse.setRenderParameter("protocollo", protocollo); + actionResponse.setRenderParameter("tipoPratica", tipoPratica); + actionResponse.setRenderParameter("tipoPratica", tipoPratica); + actionResponse.setRenderParameter("statoPratica", statoPratica); + actionResponse.setRenderParameter("committente", committente); + + if (provincia != null && !provincia.equals("")) { + actionResponse.setRenderParameter("provincia", provincia); + } + + if (comune != null && !comune.equals("")) { + actionResponse.setRenderParameter("comune", comune); + } + + actionResponse.setRenderParameter("indirizzo", indirizzo); + + if (tecnicoIstruttore != null && !tecnicoIstruttore.equals("")) { + actionResponse.setRenderParameter("tecnicoIstruttore", tecnicoIstruttore); + } else { + actionResponse.setRenderParameter("tecnicoIstruttore", StringPool.BLANK); + } + + actionResponse.setRenderParameter("titolareDigitale", titolareDigitale); + actionResponse.setRenderParameter("soggettiInterconnessi", soggettiInterconnessi); + actionResponse.setRenderParameter("dataRichiestaInizio", dataRichiestaInizio); + actionResponse.setRenderParameter("dataRichiestaFine", dataRichiestaFine); + + if (ufficio != null && !ufficio.equals("")) { + actionResponse.setRenderParameter("ufficio", ufficio); + } else { + actionResponse.setRenderParameter("ufficio", -1 + ""); + } + + actionResponse.setRenderParameter("ordinaPer", ordinaPer); + actionResponse.setRenderParameter("ordinaTipo", ordinaTipo); + + } + + public void versiona(ActionRequest actionRequest, ActionResponse actionResponse) { + + long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0); + long companyId = ParamUtil.getLong(actionRequest, "companyId"); + + try { + DettPraticaServiceUtil.sendToVersioning(dettPraticaId, companyId); + + } catch (PortalException | SystemException | IOException | NoSuchFieldException | SecurityException e) { + _log.error("error-versioning", e); + SessionErrors.add(actionRequest, "error-versioning"); + } + + PortalUtil.copyRequestParameters(actionRequest, actionResponse); + + } + + @Override + public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) + throws IOException, PortletException { + + String id = resourceRequest.getResourceID(); + ServiceContext serviceContext; + try { + serviceContext = ServiceContextFactory.getInstance(resourceRequest); + if ("downloadAllDocPratica".equals(id)) { + + long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); + long classPk = ParamUtil.getLong(resourceRequest, "classPk"); + String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom"); + List docs = new ArrayList<>(); + if (Validator.isNull(comingFrom)) { + docs = DocPraticaLocalServiceUtil.findByClassPk(classPk); + } else { + List tipologieAllegati = new ArrayList(); + if ("page_geologica".equals(comingFrom)) { + tipologieAllegati = DocumentiPraticaUtil.getDocGeologo(); + } else if ("page_allegati".equals(comingFrom)) { + tipologieAllegati = DocumentiPraticaUtil.getDocDomanda(); + } else if ("page_fine_lavori".equals(comingFrom)) { + tipologieAllegati = DocumentiPraticaUtil.getDocFineLavori(); + } else if ("page_collaudo".equals(comingFrom)) { + tipologieAllegati = DocumentiPraticaUtil.getDocCollaudo(); + } + docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId, + classPk, tipologieAllegati); + } + + ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter(); + + for (DocPratica doc : docs) { + + InputStream inputStream = null; + try { + if (Validator.isNull(doc.getDlFileEntryId())) { + continue; + } + FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getDlFileEntryId()); + inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(), + fileEntry.getVersion(), false); + + // String name = fileEntry.getTitle() + + // StringPool.PERIOD + fileEntry.getExtension(); + String name = fileEntry.getTitle(); + zipWriter.addEntry(name, inputStream); + } finally { + StreamUtil.cleanUp(inputStream); + } + } + + resourceResponse.reset(); + + File file = zipWriter.getFile(); + byte[] data = Files.readAllBytes(file.toPath()); + + resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP); + resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); + resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + + file.getName() + "\""); + resourceResponse.setContentLength(data.length); + + resourceResponse.getPortletOutputStream().write(data); + resourceResponse.getPortletOutputStream().flush(); + resourceResponse.getPortletOutputStream().close(); + + } else if ("importFile".equals(id)) { + + long classPk = ParamUtil.getLong(resourceRequest, "classPk"); + String className = ParamUtil.getString(resourceRequest, "className"); + + FilesImporter.importaFile(classPk, className); + + PortletResponseUtil + .write(resourceResponse, + "

Completato

Refresh"); + + } else if ("importAllFascicoloFiles".equals(id)) { + long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); + + if (Validator.isNull(intPratica)) { + _log.error("error.no.intpratica.exist with intpraticaid=" + intPraticaId); + } + + String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom", "bo"); + InfoFascicolo infoFascicolo = InfoFascicoloLocalServiceUtil.fetchByIntPratica(intPratica + .getIntPraticaId()); + if (Validator.isNull(infoFascicolo)) { + infoFascicolo = InfoFascicoloLocalServiceUtil.addInfoFascicolo( + intPratica.getIntPraticaId(), intPratica.getNumeroProgetto(), serviceContext); + } else { + if (infoFascicolo.getAlreadyImported() && comingFrom.equalsIgnoreCase("fe")) { + _log.error("intpratica.import.file.already-clicked with intpraticaid=" + intPraticaId); + return; + } + } + + User user = UserLocalServiceUtil.fetchUser(serviceContext.getUserId()); + + _log.debug("************** START IMPORT FILES FASCICOLO : " + intPraticaId + " by user" + + user.getFullName()); + + List listaDet = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); + for (DettPratica dettPratica : listaDet) { + FilesImporter.importaFilesFascicolo(dettPratica.getDettPraticaId(), + DettPratica.class.getName()); + } + + List listaFine = FineLavoriLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, + -1, null); + for (FineLavori fineLavori : listaFine) { + FilesImporter.importaFilesFascicolo(fineLavori.getFineLavoriId(), + FineLavori.class.getName()); + } + + List listaColl = CollaudoLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, -1, + null); + for (Collaudo collaudo : listaColl) { + FilesImporter.importaFilesFascicolo(collaudo.getCollaudoId(), Collaudo.class.getName()); + } + + _log.debug("************** END IMPORT FILES FASCICOLO : " + intPraticaId); + + infoFascicolo.setAlreadyImported(true); + infoFascicolo = InfoFascicoloLocalServiceUtil.updateInfoFascicolo(infoFascicolo); + + PortletResponseUtil + .write(resourceResponse, + "

Completato

Refresh"); + } else if ("comuni".equals(id)) { + String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId"); + JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); + if (Validator.isNotNull(provinciaId) && !provinciaId.equals("0")) { + List comuniIds = TerritorioLocalServiceUtil + .getActiveComuniByCodiceProvincia(provinciaId); + + // ADT BUG-ID=15 Sezione Ricerca / Ordinamento Filtro + List comumeList = new ArrayList(); + for (long comuneId : comuniIds) { + Comune comune = ComuneLocalServiceUtil.getComune(comuneId); + comumeList.add(comune); + } + + Collections.sort(comumeList, new Comparator() { + @Override + public int compare(Comune o1, Comune o2) { + return o1.getDenominazione().compareTo(o2.getDenominazione()); + } + }); + + for (Comune comune : comumeList) { + JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); + jsonObject.put("comuneId", comune.getComuneId()); + jsonObject.put("descLong", comune.getDenominazione()); + + jsonArray.put(jsonObject); + } + } + writeJSON(resourceRequest, resourceResponse, jsonArray); + + } else if ("exportRicerca".equals(id)) { + + ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest + .getAttribute(WebKeys.THEME_DISPLAY); + Locale locale = themeDisplay.getLocale(); + + User user = themeDisplay.getUser(); + + String csv = StringPool.BLANK; + + HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); + HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); + + csv = exportSearch(locale, resourceRequest, user); + + ServletResponseUtil.sendFile(request, response, "export_ricerca.csv", + csv.getBytes(StringPool.UTF8), ContentTypes.TEXT_CSV_UTF8); + + } else { + super.serveResource(resourceRequest, resourceResponse); + } + } catch (Exception e) { + _log.error(e, e); + throw new IOException(e); + } + + } + + private String exportSearch(Locale locale, ResourceRequest resourceRequest, User user) { + String method = "exportSearch"; + + HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(resourceRequest); + StringBuilder sb = new StringBuilder(); + + List lista = new ArrayList(); + + // try { + + Hits hits = IntPraticaAdvancedSearch.searchProgettiBO(httpRequest, user, -1, -1); + + for (Document doc : hits.toList()) { + String intPraticaId = doc.get("intPraticaId"); + try { + if (Validator.isNotNull(intPraticaId)) { + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil + .getLong(intPraticaId)); + if (Validator.isNotNull(intPratica)) { + lista.add(intPratica); + } + } + } catch (Throwable e) { + _log.error(method + " IntPraticaLocalServiceUtil.fetchIntPratica IntPraticaId: " + + intPraticaId, e); + } + } + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.sorteggiata"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.pratica"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.titolare"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.committenti"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.istruttore"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.statoPratica"))); + sb.append(StringPool.SEMICOLON); + + // ADT BUG-ID=15 Sezione Ricerca / Export csv + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.provincia"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.comune"))); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.descrizioneIntervento"))); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + + for (IntPratica intPratica : lista) { + + try { + DettPratica lastDettPratica = DettPraticaLocalServiceUtil + .getLastCompletedByIntPratica(intPratica.getIntPraticaId()); + + Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica + .getTerritorioId()); + Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); + + Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), + territorio.getCodiceProvincia()); + + boolean sorteggiata = SorteggioLocalServiceUtil + .findByIntPratica(intPratica.getIntPraticaId()) != null; + sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No")); + sb.append(StringPool.SEMICOLON); + + String praticaLabel = intPratica.getTitle(locale, true); + sb.append(CSVUtil.encode(praticaLabel)); + sb.append(StringPool.SEMICOLON); + + List titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale( + lastDettPratica.getIntPraticaId(), + lastDettPratica.getCodiceFiscaleDelegatoCommittente()); Soggetto titolare = null; - if(!titolari.isEmpty()){ - titolare = titolari.get(0); + if (!titolari.isEmpty()) { + titolare = titolari.get(0); } - if(titolare != null){ - sb.append(titolare.getTitle()+ " - " +titolare.getCodiceFiscale()); + if (titolare != null) { + sb.append(titolare.getTitle() + " - " + titolare.getCodiceFiscale()); } else { sb.append(""); } - sb.append(StringPool.SEMICOLON); - - - StringBuilder builder = new StringBuilder(); - - List committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto(lastDettPratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE); - for(Soggetto committente : committenti){ - builder.append(committente.getTitle()+" - "+committente.getCodiceFiscale()) - .append(StringPool.COMMA_AND_SPACE); + sb.append(StringPool.SEMICOLON); + + StringBuilder builder = new StringBuilder(); + + List committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto( + lastDettPratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE); + for (Soggetto committente : committenti) { + builder.append(committente.getTitle() + " - " + committente.getCodiceFiscale()).append( + StringPool.COMMA_AND_SPACE); } - if(builder.length()>0) - builder.setLength(builder.length()-12); - + if (builder.length() > 0) + builder.setLength(builder.length() - 12); + sb.append(builder.toString()); - sb.append(StringPool.SEMICOLON); - - User istruttore = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); - if(istruttore!=null){ + sb.append(StringPool.SEMICOLON); + + User istruttore = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); + if (istruttore != null) { sb.append(istruttore.getFullName()); } else { - sb.append(""); + sb.append(""); } - sb.append(StringPool.SEMICOLON); - - sb.append(LanguageUtil.get(locale, PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica))); - sb.append(StringPool.SEMICOLON); - - //ADT BUG-ID=15 Sezione Ricerca / Export csv - sb.append(provincia != null ? provincia.getProvincia() : ""); - sb.append(StringPool.SEMICOLON); - sb.append(comune != null ? comune.getDenominazione() : ""); - sb.append(StringPool.SEMICOLON); - - // sb.append("Territorio: " ).append(comune.getDenominazione()).append(!lastDettPratica.getLocalita().isEmpty() ? "(Loc. "+lastDettPratica.getLocalita()+" ) " : "").append(" - ").append(provincia.getProvincia()); - //ADT BUG-ID=15 Sezione Ricerca / Export csv - Max 30 chars - int MAX_LENGHT_DESCR_INTERVENTO = 30; - sb.append(lastDettPratica.getDescLongIntervento() == null ? "": lastDettPratica.getDescLongIntervento().length() > MAX_LENGHT_DESCR_INTERVENTO ? lastDettPratica.getDescLongIntervento().substring(0, MAX_LENGHT_DESCR_INTERVENTO) : lastDettPratica.getDescLongIntervento()); - sb.append(StringPool.SEMICOLON); - - // Territorio: <%= comune.getDenominazione() %> <%= !lastDettPratica.getLocalita().isEmpty() ? "(Loc. "+lastDettPratica.getLocalita()+" ) " : "" %>- <%= provincia.getProvincia() %>
- // Localizzazione: <%= lastDettPratica.getVia() %>

- // <%= lastDettPratica.getDescLongIntervento() %> - } catch(Throwable e){ - _log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId() : "", e); - } finally{ - sb.append(StringPool.NEW_LINE); - } - } - -// } catch (PortalException e) { -// _log.error(e, e); -// } catch (SystemException e) { -// _log.error(e, e); -// } - - return sb.toString(); - - } + sb.append(StringPool.SEMICOLON); + + sb.append(LanguageUtil.get(locale, + PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica))); + sb.append(StringPool.SEMICOLON); + + // ADT BUG-ID=15 Sezione Ricerca / Export csv + sb.append(provincia != null ? provincia.getProvincia() : ""); + sb.append(StringPool.SEMICOLON); + sb.append(comune != null ? comune.getDenominazione() : ""); + sb.append(StringPool.SEMICOLON); + + // sb.append("Territorio: " + // ).append(comune.getDenominazione()).append(!lastDettPratica.getLocalita().isEmpty() + // ? "(Loc. "+lastDettPratica.getLocalita()+" ) " : + // "").append(" - ").append(provincia.getProvincia()); + // ADT BUG-ID=15 Sezione Ricerca / Export csv - Max 30 chars + int MAX_LENGHT_DESCR_INTERVENTO = 30; + sb.append(lastDettPratica.getDescLongIntervento() == null ? "" : lastDettPratica + .getDescLongIntervento().length() > MAX_LENGHT_DESCR_INTERVENTO ? lastDettPratica + .getDescLongIntervento().substring(0, MAX_LENGHT_DESCR_INTERVENTO) : lastDettPratica + .getDescLongIntervento()); + sb.append(StringPool.SEMICOLON); + + // Territorio: <%= comune.getDenominazione() %> <%= + // !lastDettPratica.getLocalita().isEmpty() ? + // "(Loc. "+lastDettPratica.getLocalita()+" ) " : "" %>- <%= + // provincia.getProvincia() %>
+ // Localizzazione: <%= lastDettPratica.getVia() + // %>

+ // <%= lastDettPratica.getDescLongIntervento() %> + } catch (Throwable e) { + _log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId() + : "", e); + } finally { + sb.append(StringPool.NEW_LINE); + } + } + + // } catch (PortalException e) { + // _log.error(e, e); + // } catch (SystemException e) { + // _log.error(e, e); + // } + + return sb.toString(); + + } } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GenerateProtocolloCSVPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GenerateProtocolloCSVPortlet.java index 5c0598b2..7f7ae290 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GenerateProtocolloCSVPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GenerateProtocolloCSVPortlet.java @@ -38,94 +38,95 @@ import com.liferay.util.bridges.mvc.MVCPortlet; */ public class GenerateProtocolloCSVPortlet extends MVCPortlet { - private static Log _log = LogFactoryUtil.getLog(GenerateProtocolloCSVPortlet.class); + private static Log _log = LogFactoryUtil.getLog(GenerateProtocolloCSVPortlet.class); - public void search(ActionRequest actionRequest, ActionResponse actionResponse) { + public void search(ActionRequest actionRequest, ActionResponse actionResponse) { - String annoRiferimento = actionRequest.getParameter("annoRiferimento"); - String ufficioId = actionRequest.getParameter("ufficio"); - String numeroProtocollo = actionRequest.getParameter("numeroProtocollo"); + String annoRiferimento = actionRequest.getParameter("annoRiferimento"); + String ufficioId = actionRequest.getParameter("ufficio"); + String numeroProtocollo = actionRequest.getParameter("numeroProtocollo"); - actionResponse.setRenderParameter("annoRiferimento", annoRiferimento); - actionResponse.setRenderParameter("ufficio", ufficioId); - actionResponse.setRenderParameter("numeroProtocollo", numeroProtocollo); - } + actionResponse.setRenderParameter("annoRiferimento", annoRiferimento); + actionResponse.setRenderParameter("ufficio", ufficioId); + actionResponse.setRenderParameter("numeroProtocollo", numeroProtocollo); + } - @Override - public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, - PortletException { + @Override + public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) + throws IOException, PortletException { - int ufficioId = ParamUtil.getInteger(resourceRequest, "ufficio", -1); - String anno = ParamUtil.getString(resourceRequest, "annoRiferimento", "0000"); + int ufficioId = ParamUtil.getInteger(resourceRequest, "ufficio", -1); + String anno = ParamUtil.getString(resourceRequest, "annoRiferimento", "0000"); - ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); - User user = themeDisplay.getUser(); + ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); + User user = themeDisplay.getUser(); - String ufficioIds = ""; + String ufficioIds = ""; - try { + try { - if (ufficioId == -1) { - List organizationList = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); - if (organizationList != null && !organizationList.isEmpty()) { - List lista = new ArrayList(); + if (ufficioId == -1) { + List organizationList = OrganizationLocalServiceUtil.getUserOrganizations(user + .getUserId()); + if (organizationList != null && !organizationList.isEmpty()) { + List lista = new ArrayList(); - for (Organization org : organizationList) { - lista.add(GetterUtil.getInteger(org.getGroupId())); - } + for (Organization org : organizationList) { + lista.add(GetterUtil.getInteger(org.getGroupId())); + } - ufficioIds = lista.toString().substring(1, lista.toString().length() - 1); - } - } else { - ufficioIds = "" + ufficioId; - } + ufficioIds = lista.toString().substring(1, lista.toString().length() - 1); + } + } else { + ufficioIds = "" + ufficioId; + } - ufficioIds = ufficioIds.replaceAll(" ", ""); + ufficioIds = ufficioIds.replaceAll(" ", ""); - // String urlCSVService = PortletProps.get("protocollo.cvs.url"); - String urlCSVService = - ConfigurazioneLocalServiceUtil.findByC_ChiaveString(themeDisplay.getCompanyId(), - ConfigurazioneConstants.PROTOCOLLAZIONE_SERVICE_EXPORT_URL); + // String urlCSVService = PortletProps.get("protocollo.cvs.url"); + String urlCSVService = ConfigurazioneLocalServiceUtil.findByC_ChiaveString( + themeDisplay.getCompanyId(), ConfigurazioneConstants.PROTOCOLLAZIONE_SERVICE_EXPORT_URL); - String data = "?anno=" + anno + "&ufficioIds=" + ufficioIds; + String data = "?anno=" + anno + "&ufficioIds=" + ufficioIds; - URL url = new URL(urlCSVService + data); + URL url = new URL(urlCSVService + data); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setDoOutput(true); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setDoOutput(true); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); - if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { - throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); - } + if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { + throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); + } - byte[] bytes = IOUtils.toByteArray(conn.getInputStream()); + byte[] bytes = IOUtils.toByteArray(conn.getInputStream()); - String fileName = "export_protocolli_" + new Date().getTime() + "_.csv"; - String contentType = ContentTypes.TEXT_CSV; + String fileName = "export_protocolli_" + new Date().getTime() + "_.csv"; + String contentType = ContentTypes.TEXT_CSV; - ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length); - bos.write(bytes, 0, bytes.length); + ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length); + bos.write(bytes, 0, bytes.length); - resourceResponse.setContentType(contentType); - resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); - resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + "\"" + fileName + "\""); - resourceResponse.setContentLength(bos.size()); + resourceResponse.setContentType(contentType); + resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); + resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + "\"" + + fileName + "\""); + resourceResponse.setContentLength(bos.size()); - OutputStream out = resourceResponse.getPortletOutputStream(); - bos.writeTo(out); + OutputStream out = resourceResponse.getPortletOutputStream(); + bos.writeTo(out); - out.flush(); - out.close(); + out.flush(); + out.close(); - conn.disconnect(); + conn.disconnect(); - } catch (Exception e) { - _log.error(e, e); - } + } catch (Exception e) { + _log.error(e, e); + } - super.serveResource(resourceRequest, resourceResponse); - } + super.serveResource(resourceRequest, resourceResponse); + } } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaIstruttorePortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaIstruttorePortlet.java index a2c0357a..58683276 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaIstruttorePortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaIstruttorePortlet.java @@ -32,7 +32,6 @@ import javax.portlet.ResourceRequest; import javax.portlet.ResourceResponse; import javax.servlet.http.HttpServletRequest; -import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.json.JSONArray; @@ -59,297 +58,291 @@ import com.liferay.util.bridges.mvc.MVCPortlet; public class GestioneAttivitaIstruttorePortlet extends MVCPortlet { - private static final Log _log = LogFactoryUtil.getLog(GestioneAttivitaIstruttorePortlet.class); - - private static final String[] FIELD_NAMES = {"Tipo Pratica", "Numero Progetto", "Data Pratica", "Comune", - "Provincia", "Stato Pratica", "Committenti", "Direttore Lavori", "Tipologia Intervento", "Aperta", - "Collaudo Previsto", "Data Assegnazione" }; - - private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); - - public void searchURL(ActionRequest actionRequest, ActionResponse actionResponse) { - - String numeroProgetto = ParamUtil.getString(actionRequest, "numeroProgetto"); - String tipoPratica = ParamUtil.getString(actionRequest, "tipoPratica"); - String statoPratica = ParamUtil.getString(actionRequest, "statoPratica"); - String committente = ParamUtil.getString(actionRequest, "committente"); - String soggettiInterconnessi = ParamUtil.getString(actionRequest, "soggettiInterconnessi"); - String direttoreLavori = ParamUtil.getString(actionRequest, "direttoreLavori"); - String dataRichiestaInizio = ParamUtil.getString(actionRequest, "dataRichiestaInizio"); - String dataRichiestaFine = ParamUtil.getString(actionRequest, "dataRichiestaFine"); - String ufficio = ParamUtil.getString(actionRequest, "ufficio"); - String ordinaPer = ParamUtil.getString(actionRequest, "ordinaPer"); - String ordinaTipo = ParamUtil.getString(actionRequest, "ordinaTipo"); - String comune = ParamUtil.getString(actionRequest, "comune"); - String praticaAperta = ParamUtil.getString(actionRequest, "praticaAperta"); - - String interventoTutti = ParamUtil.getString(actionRequest, "interventoTutti"); - String interventoNuovaCostruzione = ParamUtil.getString(actionRequest, "interventoNuovaCostruzione"); - String interventoAdeguamentoSismico = ParamUtil.getString(actionRequest, "interventoAdeguamentoSismico"); - String interventoMiglioramentoSismico = ParamUtil.getString(actionRequest, "interventoMiglioramentoSismico"); - String interventoRiparazioneInterventoLocale = - ParamUtil.getString(actionRequest, "interventoRiparazioneInterventoLocale"); - - actionResponse.setRenderParameter("numeroProgetto", numeroProgetto); - actionResponse.setRenderParameter("tipoPratica", tipoPratica); - actionResponse.setRenderParameter("statoPratica", statoPratica); - actionResponse.setRenderParameter("committente", committente); - actionResponse.setRenderParameter("soggettiInterconnessi", soggettiInterconnessi); - actionResponse.setRenderParameter("direttoreLavori", direttoreLavori); - actionResponse.setRenderParameter("dataRichiestaInizio", dataRichiestaInizio); - actionResponse.setRenderParameter("dataRichiestaFine", dataRichiestaFine); - actionResponse.setRenderParameter("ufficio", ufficio); - actionResponse.setRenderParameter("ordinaPer", ordinaPer); - actionResponse.setRenderParameter("ordinaTipo", ordinaTipo); - actionResponse.setRenderParameter("comune", comune); - actionResponse.setRenderParameter("praticaAperta", praticaAperta); - - actionResponse.setRenderParameter("interventoTutti", interventoTutti); - actionResponse.setRenderParameter("interventoNuovaCostruzione", interventoNuovaCostruzione); - actionResponse.setRenderParameter("interventoAdeguamentoSismico", interventoAdeguamentoSismico); - actionResponse.setRenderParameter("interventoMiglioramentoSismico", interventoMiglioramentoSismico); - actionResponse.setRenderParameter("interventoRiparazioneInterventoLocale", interventoRiparazioneInterventoLocale); - - } - - @Override - public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, - PortletException { - - ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); - - //ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione tutte i record - String resourceId = GetterUtil.getString(resourceRequest.getResourceID()); - boolean isExport = "exportCVS".equals(resourceId); - - HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); - List lista = new ArrayList<>(); - Hits hits = - IntPraticaAdvancedSearch.searchAttivitaIstruttore(request, themeDisplay.getUser(), 0, - //ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione tutte i record - //Bug 33248 - GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)), isExport); - try { - for (Document doc : hits.toList()) { - - String intPraticaId = doc.get("intPraticaId"); - if (Validator.isNotNull(intPraticaId)) { - - IntPratica intPratica; - - intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil.getLong(intPraticaId)); - - if (Validator.isNotNull(intPratica)) { - lista.add(intPratica); - } - } - - } - } catch (PortalException | SystemException e) { - throw new IOException(e); - } - - if (isExport && Validator.isNotNull(lista) && !lista.isEmpty()) { - - StringBuilder sb = new StringBuilder(); - - for (String columnName : FIELD_NAMES) { - sb.append(columnName); - sb.append(StringPool.SEMICOLON); - } - - sb.append(CharPool.NEW_LINE); - sb.append(CharPool.NEW_LINE); - - for (IntPratica pratica : lista) { - - try { - DettPratica lastDettPratica = - DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica.getIntPraticaId()); - - - Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(pratica.getTerritorioId()); - Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); - - Provincia provincia = - ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia()); - - List committenti = - SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto(pratica.getIntPraticaId(), - TipoSoggettoUtil.COMMITTENTE); - List direttoreLavori = - SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto(pratica.getIntPraticaId(), - TipoSoggettoUtil.DIRETTORE_LAVORI); - List collaudatori = - SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto(pratica.getIntPraticaId(), - TipoSoggettoUtil.COLLAUDATORE); - - List fineLavoriList = - FineLavoriLocalServiceUtil.findByIntPraticaId(pratica.getIntPraticaId(), -1, -1, null); - boolean compleatata = false; - for (FineLavori fineLavori : fineLavoriList) { - if (fineLavori.isCompletata() && !fineLavori.isParziale()) { - compleatata = true; - } - } - - boolean collaudoPrevisto = false; - if (collaudatori != null && !collaudatori.isEmpty()) { - collaudoPrevisto = true; - } - - - sb.append(pratica.getTipoPratica()); - sb.append(StringPool.SEMICOLON); - sb.append(pratica.getNumeroProgetto()); - sb.append(StringPool.SEMICOLON); - if (Validator.isNotNull(pratica.getDtPratica())) { - sb.append(sdf.format(pratica.getDtPratica())); - } else { - sb.append(""); - } - sb.append(StringPool.SEMICOLON); - - sb.append(comune.getDenominazione()); - sb.append(StringPool.SEMICOLON); - sb.append(provincia.getProvincia()); - sb.append(StringPool.SEMICOLON); - sb.append(pratica.getStatoPratica()); - sb.append(StringPool.SEMICOLON); - - for (Soggetto soggetto : committenti) { - //ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV -// sb.append(soggetto.getCodiceFiscale().toUpperCase()); - sb.append(soggetto.getDescrizioneCompleta().toUpperCase()); - sb.append(" "); - } - sb.append(StringPool.SEMICOLON); - - for (Soggetto soggetto : direttoreLavori) { - //ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV -// sb.append(soggetto.getCodiceFiscale().toUpperCase()); - sb.append(soggetto.getDescrizioneCompleta().toUpperCase()); - sb.append(" "); - } - sb.append(StringPool.SEMICOLON); - - if (Validator.isNotNull(lastDettPratica)) { - if (lastDettPratica.getTcNuovaCostruzione()) { - sb.append("Nuova Costruzione"); - sb.append(" "); - } - if (lastDettPratica.getTcAdeguamentoSismico()) { - sb.append("Adeguamento Sismico"); - sb.append(" "); - } - if (lastDettPratica.getTcMiglioramentoSismico()) { - sb.append("Miglioramento Sismico"); - sb.append(" "); - } - if (lastDettPratica.getTcRiparazioneInterventoLocale()) { - sb.append("Riparazione Intervento Locale"); - sb.append(" "); - } - } - sb.append(StringPool.SEMICOLON); - - if (compleatata) { - sb.append("SI"); - } else { - sb.append("NO"); - } - sb.append(StringPool.SEMICOLON); - - if (collaudoPrevisto) { - sb.append("SI"); - } else { - sb.append("NO"); - } - sb.append(StringPool.SEMICOLON); - - if (Validator.isNotNull(pratica.getStatusDate())) { - sb.append(sdf.format(pratica.getStatusDate())); - } else { - sb.append(""); - } - sb.append(StringPool.SEMICOLON); - - - } catch (SystemException e) { - _log.error(e, e); - } - - sb.append(CharPool.NEW_LINE); - } - - String fileName = "exportActivity_" + new Date().getTime() + ".csv"; - byte[] bytes = sb.toString().getBytes(); - - String contentType = ContentTypes.TEXT_CSV; - - ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length); - baos.write(bytes, 0, bytes.length); - - resourceResponse.setContentType(contentType); - resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); - resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + "\"" + fileName + "\""); - resourceResponse.setContentLength(baos.size()); - - - OutputStream out = resourceResponse.getPortletOutputStream(); - baos.writeTo(out); - - out.flush(); - out.close(); - - - // PortletResponseUtil.sendFile(resourceRequest, resourceResponse, fileName, bytes, - // contentType); - } - - //ADT BUG-ID=16 Sezione Pratiche Assegnate - User user = themeDisplay.getUser(); - if ("comuniForUfficio".equals(resourceId)) { - String ufficio = ParamUtil.getString(resourceRequest, "ufficioId"); - JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); - List comuni; - if (Validator.isNotNull(ufficio) && !ufficio.equals("0")) { - try { - if(!ufficio.equals("-1")){ - long ufficioId = Long.parseLong(ufficio); - comuni = ComuneLocalServiceUtil.getComuniForOrganizationByUserIdUfficioId(user.getUserId(), ufficioId); - for (Comune comune : comuni) { - JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); - jsonObject.put("comuneId", comune.getComuneId()); - jsonObject.put("descLong", comune.getDenominazione()); - - jsonArray.put(jsonObject); - } - writeJSON(resourceRequest, resourceResponse, jsonArray); - } else { - comuni = ComuneLocalServiceUtil.getComuniForOrganizationByUserId(user.getUserId()); - for (Comune comune : comuni) { - JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); - jsonObject.put("comuneId", comune.getComuneId()); - jsonObject.put("descLong", comune.getDenominazione()); - - jsonArray.put(jsonObject); + private static final Log _log = LogFactoryUtil.getLog(GestioneAttivitaIstruttorePortlet.class); + + private static final String[] FIELD_NAMES = { "Tipo Pratica", "Numero Progetto", "Data Pratica", + "Comune", "Provincia", "Stato Pratica", "Committenti", "Direttore Lavori", + "Tipologia Intervento", "Aperta", "Collaudo Previsto", "Data Assegnazione" }; + + private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + + public void searchURL(ActionRequest actionRequest, ActionResponse actionResponse) { + String numeroProgetto = ParamUtil.getString(actionRequest, "numeroProgetto"); + String tipoPratica = ParamUtil.getString(actionRequest, "tipoPratica"); + String statoPratica = ParamUtil.getString(actionRequest, "statoPratica"); + String committente = ParamUtil.getString(actionRequest, "committente"); + String soggettiInterconnessi = ParamUtil.getString(actionRequest, "soggettiInterconnessi"); + String direttoreLavori = ParamUtil.getString(actionRequest, "direttoreLavori"); + String dataRichiestaInizio = ParamUtil.getString(actionRequest, "dataRichiestaInizio"); + String dataRichiestaFine = ParamUtil.getString(actionRequest, "dataRichiestaFine"); + String ufficio = ParamUtil.getString(actionRequest, "ufficio"); + String ordinaPer = ParamUtil.getString(actionRequest, "ordinaPer"); + String ordinaTipo = ParamUtil.getString(actionRequest, "ordinaTipo"); + String comune = ParamUtil.getString(actionRequest, "comune"); + String praticaAperta = ParamUtil.getString(actionRequest, "praticaAperta"); + + String interventoTutti = ParamUtil.getString(actionRequest, "interventoTutti"); + String interventoNuovaCostruzione = ParamUtil.getString(actionRequest, "interventoNuovaCostruzione"); + String interventoAdeguamentoSismico = ParamUtil.getString(actionRequest, + "interventoAdeguamentoSismico"); + String interventoMiglioramentoSismico = ParamUtil.getString(actionRequest, + "interventoMiglioramentoSismico"); + String interventoRiparazioneInterventoLocale = ParamUtil.getString(actionRequest, + "interventoRiparazioneInterventoLocale"); + + actionResponse.setRenderParameter("numeroProgetto", numeroProgetto); + actionResponse.setRenderParameter("tipoPratica", tipoPratica); + actionResponse.setRenderParameter("statoPratica", statoPratica); + actionResponse.setRenderParameter("committente", committente); + actionResponse.setRenderParameter("soggettiInterconnessi", soggettiInterconnessi); + actionResponse.setRenderParameter("direttoreLavori", direttoreLavori); + actionResponse.setRenderParameter("dataRichiestaInizio", dataRichiestaInizio); + actionResponse.setRenderParameter("dataRichiestaFine", dataRichiestaFine); + actionResponse.setRenderParameter("ufficio", ufficio); + actionResponse.setRenderParameter("ordinaPer", ordinaPer); + actionResponse.setRenderParameter("ordinaTipo", ordinaTipo); + actionResponse.setRenderParameter("comune", comune); + actionResponse.setRenderParameter("praticaAperta", praticaAperta); + + actionResponse.setRenderParameter("interventoTutti", interventoTutti); + actionResponse.setRenderParameter("interventoNuovaCostruzione", interventoNuovaCostruzione); + actionResponse.setRenderParameter("interventoAdeguamentoSismico", interventoAdeguamentoSismico); + actionResponse.setRenderParameter("interventoMiglioramentoSismico", interventoMiglioramentoSismico); + actionResponse.setRenderParameter("interventoRiparazioneInterventoLocale", + interventoRiparazioneInterventoLocale); + + } + + @Override + public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) + throws IOException, PortletException { + + ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); + + // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione + // tutte i record + String resourceId = GetterUtil.getString(resourceRequest.getResourceID()); + boolean isExport = "exportCVS".equals(resourceId); + + HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); + List lista = new ArrayList<>(); + Hits hits = IntPraticaAdvancedSearch.searchAttivitaIstruttore(request, themeDisplay.getUser(), 0, + // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV - Esportazione + // tutte i record + // Bug 33248 + GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)), isExport); + try { + for (Document doc : hits.toList()) { + + String intPraticaId = doc.get("intPraticaId"); + if (Validator.isNotNull(intPraticaId)) { + + IntPratica intPratica; + + intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil.getLong(intPraticaId)); + + if (Validator.isNotNull(intPratica)) { + lista.add(intPratica); } - writeJSON(resourceRequest, resourceResponse, jsonArray); } } + } catch (PortalException | SystemException e) { + throw new IOException(e); + } + + if (isExport && Validator.isNotNull(lista) && !lista.isEmpty()) { + StringBuilder sb = new StringBuilder(); - catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + for (String columnName : FIELD_NAMES) { + sb.append(columnName); + sb.append(StringPool.SEMICOLON); } - } + sb.append(CharPool.NEW_LINE); + sb.append(CharPool.NEW_LINE); + + for (IntPratica pratica : lista) { + + try { + DettPratica lastDettPratica = DettPraticaLocalServiceUtil + .getLastCompletedByIntPratica(pratica.getIntPraticaId()); + + Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(pratica + .getTerritorioId()); + Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); + + Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), + territorio.getCodiceProvincia()); + + List committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto( + pratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE); + List direttoreLavori = SoggettoLocalServiceUtil + .findByIntPratica_TipologiaSoggetto(pratica.getIntPraticaId(), + TipoSoggettoUtil.DIRETTORE_LAVORI); + List collaudatori = SoggettoLocalServiceUtil + .findByIntPratica_TipologiaSoggetto(pratica.getIntPraticaId(), + TipoSoggettoUtil.COLLAUDATORE); + + List fineLavoriList = FineLavoriLocalServiceUtil.findByIntPraticaId( + pratica.getIntPraticaId(), -1, -1, null); + boolean compleatata = false; + for (FineLavori fineLavori : fineLavoriList) { + if (fineLavori.isCompletata() && !fineLavori.isParziale()) { + compleatata = true; + } + } - } + boolean collaudoPrevisto = false; + if (collaudatori != null && !collaudatori.isEmpty()) { + collaudoPrevisto = true; + } + + sb.append(pratica.getTipoPratica()); + sb.append(StringPool.SEMICOLON); + sb.append(pratica.getNumeroProgetto()); + sb.append(StringPool.SEMICOLON); + if (Validator.isNotNull(pratica.getDtPratica())) { + sb.append(sdf.format(pratica.getDtPratica())); + } else { + sb.append(""); + } + sb.append(StringPool.SEMICOLON); + + sb.append(comune.getDenominazione()); + sb.append(StringPool.SEMICOLON); + sb.append(provincia.getProvincia()); + sb.append(StringPool.SEMICOLON); + sb.append(pratica.getStatoPratica()); + sb.append(StringPool.SEMICOLON); + + for (Soggetto soggetto : committenti) { + // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV + // sb.append(soggetto.getCodiceFiscale().toUpperCase()); + sb.append(soggetto.getDescrizioneCompleta().toUpperCase()); + sb.append(" "); + } + sb.append(StringPool.SEMICOLON); - super.serveResource(resourceRequest, resourceResponse); - } + for (Soggetto soggetto : direttoreLavori) { + // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV + // sb.append(soggetto.getCodiceFiscale().toUpperCase()); + sb.append(soggetto.getDescrizioneCompleta().toUpperCase()); + sb.append(" "); + } + sb.append(StringPool.SEMICOLON); + + if (Validator.isNotNull(lastDettPratica)) { + if (lastDettPratica.getTcNuovaCostruzione()) { + sb.append("Nuova Costruzione"); + sb.append(" "); + } + if (lastDettPratica.getTcAdeguamentoSismico()) { + sb.append("Adeguamento Sismico"); + sb.append(" "); + } + if (lastDettPratica.getTcMiglioramentoSismico()) { + sb.append("Miglioramento Sismico"); + sb.append(" "); + } + if (lastDettPratica.getTcRiparazioneInterventoLocale()) { + sb.append("Riparazione Intervento Locale"); + sb.append(" "); + } + } + sb.append(StringPool.SEMICOLON); + + if (compleatata) { + sb.append("SI"); + } else { + sb.append("NO"); + } + sb.append(StringPool.SEMICOLON); + + if (collaudoPrevisto) { + sb.append("SI"); + } else { + sb.append("NO"); + } + sb.append(StringPool.SEMICOLON); + + if (Validator.isNotNull(pratica.getStatusDate())) { + sb.append(sdf.format(pratica.getStatusDate())); + } else { + sb.append(""); + } + sb.append(StringPool.SEMICOLON); + + } catch (SystemException e) { + _log.error(e, e); + } + + sb.append(CharPool.NEW_LINE); + } + + String fileName = "exportActivity_" + new Date().getTime() + ".csv"; + byte[] bytes = sb.toString().getBytes(); + + String contentType = ContentTypes.TEXT_CSV; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length); + baos.write(bytes, 0, bytes.length); + + resourceResponse.setContentType(contentType); + resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); + resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + "\"" + + fileName + "\""); + resourceResponse.setContentLength(baos.size()); + + OutputStream out = resourceResponse.getPortletOutputStream(); + baos.writeTo(out); + + out.flush(); + out.close(); + + // PortletResponseUtil.sendFile(resourceRequest, resourceResponse, + // fileName, bytes, + // contentType); + } + + // ADT BUG-ID=16 Sezione Pratiche Assegnate + User user = themeDisplay.getUser(); + if ("comuniForUfficio".equals(resourceId)) { + String ufficio = ParamUtil.getString(resourceRequest, "ufficioId"); + JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); + List comuni; + if (Validator.isNotNull(ufficio) && !ufficio.equals("0")) { + try { + if (!ufficio.equals("-1")) { + long ufficioId = Long.parseLong(ufficio); + comuni = ComuneLocalServiceUtil.getComuniForOrganizationByUserIdUfficioId( + user.getUserId(), ufficioId); + for (Comune comune : comuni) { + JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); + jsonObject.put("comuneId", comune.getComuneId()); + jsonObject.put("descLong", comune.getDenominazione()); + + jsonArray.put(jsonObject); + } + writeJSON(resourceRequest, resourceResponse, jsonArray); + } else { + comuni = ComuneLocalServiceUtil.getComuniForOrganizationByUserId(user.getUserId()); + for (Comune comune : comuni) { + JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); + jsonObject.put("comuneId", comune.getComuneId()); + jsonObject.put("descLong", comune.getDenominazione()); + + jsonArray.put(jsonObject); + } + writeJSON(resourceRequest, resourceResponse, jsonArray); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + } + super.serveResource(resourceRequest, resourceResponse); + } } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaPortlet.java index d7189cf6..d1cd88ce 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaPortlet.java @@ -88,7 +88,7 @@ public class GestioneAttivitaPortlet extends MVCPortlet { String statoPratica = ParamUtil.getString(actionRequest, "statoPratica"); String committente = ParamUtil.getString(actionRequest, "committente"); String soggettiInterconnessi = ParamUtil.getString(actionRequest, "soggettiInterconnessi"); - //ADT BUG BO ID = 8 + // ADT BUG BO ID = 8 String istruttore = ParamUtil.getString(actionRequest, "istruttore"); String dataRichiestaInizio = ParamUtil.getString(actionRequest, "dataRichiestaInizio"); String dataRichiestaFine = ParamUtil.getString(actionRequest, "dataRichiestaFine"); @@ -102,20 +102,20 @@ public class GestioneAttivitaPortlet extends MVCPortlet { actionResponse.setRenderParameter("tabs1", tabs1); actionResponse.setRenderParameter("numeroProgetto", numeroProgetto); actionResponse.setRenderParameter("protocollo", protocollo); - - //ADT - BUG-11 Aggiunta filtro ricerca - if(Validator.isNotNull(tipoPratica)){ - if("co".equalsIgnoreCase(tipoPratica)){ + + // ADT - BUG-11 Aggiunta filtro ricerca + if (Validator.isNotNull(tipoPratica)) { + if ("co".equalsIgnoreCase(tipoPratica)) { tipoPratica = Constants.TIPO_PRATICA_DEPOSITO; actionResponse.setRenderParameter("controlloObbligatorio", Boolean.TRUE.toString()); - } else if("sorteggio".equalsIgnoreCase(tipoPratica)){ + } else if ("sorteggio".equalsIgnoreCase(tipoPratica)) { tipoPratica = Constants.TIPO_PRATICA_DEPOSITO; actionResponse.setRenderParameter("sorteggiata", Boolean.TRUE.toString()); } - + actionResponse.setRenderParameter("tipoPratica", tipoPratica); } - + actionResponse.setRenderParameter("statoPratica", statoPratica); actionResponse.setRenderParameter("committente", committente); actionResponse.setRenderParameter("soggettiInterconnessi", soggettiInterconnessi); @@ -126,20 +126,20 @@ public class GestioneAttivitaPortlet extends MVCPortlet { if (dataRichiestaInizio != null && !dataRichiestaInizio.equals("")) { String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split("/"); - int mounth = Integer.valueOf(dataRichiestaInizioSplitted[1]) -1; + int mounth = Integer.valueOf(dataRichiestaInizioSplitted[1]) - 1; actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]); - actionResponse.setRenderParameter("dataRichiestaInizioMonth", mounth+""); + actionResponse.setRenderParameter("dataRichiestaInizioMonth", mounth + ""); actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]); } if (dataRichiestaFine != null && !dataRichiestaFine.equals("")) { String[] dataRichiestaFineSplitted = dataRichiestaFine.split("/"); - int mounth = Integer.valueOf(dataRichiestaFineSplitted[1]) -1; + int mounth = Integer.valueOf(dataRichiestaFineSplitted[1]) - 1; actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]); - actionResponse.setRenderParameter("dataRichiestaFineMonth", mounth+""); + actionResponse.setRenderParameter("dataRichiestaFineMonth", mounth + ""); actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]); } @@ -158,7 +158,8 @@ public class GestioneAttivitaPortlet extends MVCPortlet { long istruttoreId = ParamUtil.getLong(actionRequest, "istruttoreId"); try { IntPratica intPratica = IntPraticaServiceUtil.getIntPratica(intPraticaId); - if (Validator.isNotNull(intPratica.getStatusByUserId()) && intPratica.getStatusByUserId() != istruttoreId) { + if (Validator.isNotNull(intPratica.getStatusByUserId()) + && intPratica.getStatusByUserId() != istruttoreId) { IntPraticaServiceUtil.cambiaIstruttore(intPraticaId, controlloPraticaId, istruttoreId); } else { throw new SystemException("cambio istruttore non possibile"); @@ -169,35 +170,45 @@ public class GestioneAttivitaPortlet extends MVCPortlet { } } - // public void assegnamiTask(ActionRequest actionRequest, ActionResponse actionResponse) { + // public void assegnamiTask(ActionRequest actionRequest, ActionResponse + // actionResponse) { // - // long controlloPraticaId = ParamUtil.getLong(actionRequest, "controlloPraticaId"); + // long controlloPraticaId = ParamUtil.getLong(actionRequest, + // "controlloPraticaId"); // long workflowTaskId = ParamUtil.getLong(actionRequest, "workflowTaskId"); // // // try { - // ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + // ServiceContext serviceContext = + // ServiceContextFactory.getInstance(actionRequest); // ControlloPratica controlloPratica = // ControlloPraticaLocalServiceUtil.getControlloPratica(controlloPraticaId); // // IntPratica intPratica = // IntPraticaLocalServiceUtil.getIntPratica(controlloPratica.getIntPraticaId()); - // Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); + // Territorio territorio = + // TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); // IntPraticaPermission.check(PermissionThreadLocal.getPermissionChecker(), // territorio.getGroupId(), // ActionKeys.ASSEGNA_A_ME); // // // WorkflowTask lastWorkflowTask = - // WorkflowUtil.getLastTask(controlloPratica.getCompanyId(), controlloPratica.getGroupId(), null, + // WorkflowUtil.getLastTask(controlloPratica.getCompanyId(), + // controlloPratica.getGroupId(), null, // controlloPratica); - // if (lastWorkflowTask != null && lastWorkflowTask.getWorkflowTaskId() == workflowTaskId + // if (lastWorkflowTask != null && lastWorkflowTask.getWorkflowTaskId() == + // workflowTaskId // && !lastWorkflowTask.getWorkflowTaskAssignees().isEmpty()) { // boolean assegnazionePossibile = false; - // for (WorkflowTaskAssignee workflowTaskAssignee : lastWorkflowTask.getWorkflowTaskAssignees()) { - // if (workflowTaskAssignee.getAssigneeClassName().equalsIgnoreCase(Role.class.getName()) - // && UserGroupRoleLocalServiceUtil.hasUserGroupRole(serviceContext.getUserId(), - // controlloPratica.getGroupId(), workflowTaskAssignee.getAssigneeClassPK(), true)) { + // for (WorkflowTaskAssignee workflowTaskAssignee : + // lastWorkflowTask.getWorkflowTaskAssignees()) { + // if + // (workflowTaskAssignee.getAssigneeClassName().equalsIgnoreCase(Role.class.getName()) + // && + // UserGroupRoleLocalServiceUtil.hasUserGroupRole(serviceContext.getUserId(), + // controlloPratica.getGroupId(), workflowTaskAssignee.getAssigneeClassPK(), + // true)) { // assegnazionePossibile = true; // } // } @@ -207,7 +218,8 @@ public class GestioneAttivitaPortlet extends MVCPortlet { // workflowTaskId, serviceContext.getUserId(), StringPool.BLANK, null, // WorkflowUtil.getWorkflowContext(controlloPratica)); // } else { - // throw new SystemException("assegnazione task non possibile per il ruolo"); + // throw new + // SystemException("assegnazione task non possibile per il ruolo"); // } // } else { // throw new SystemException("assegnazione task non possibile"); @@ -225,14 +237,15 @@ public class GestioneAttivitaPortlet extends MVCPortlet { try { ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); - ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(controlloPraticaId); - IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(controlloPratica.getIntPraticaId()); + ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil + .getControlloPratica(controlloPraticaId); + IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(controlloPratica + .getIntPraticaId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); IntPraticaPermission.check(PermissionThreadLocal.getPermissionChecker(), territorio.getGroupId(), ActionKeys.ASSEGNA_AL_RUOLO); - WorkflowTask lastWorkflowTask = - WorkflowUtil.getLastTask(controlloPratica.getCompanyId(), controlloPratica.getGroupId(), null, - controlloPratica); + WorkflowTask lastWorkflowTask = WorkflowUtil.getLastTask(controlloPratica.getCompanyId(), + controlloPratica.getGroupId(), null, controlloPratica); if (lastWorkflowTask != null && lastWorkflowTask.getWorkflowTaskId() == workflowTaskId && !lastWorkflowTask.getWorkflowTaskAssignees().isEmpty()) { Role role = null; @@ -251,8 +264,9 @@ public class GestioneAttivitaPortlet extends MVCPortlet { break; } - WorkflowTaskManagerUtil.assignWorkflowTaskToRole(controlloPratica.getCompanyId(), serviceContext.getUserId(), - workflowTaskId, role.getRoleId(), StringPool.BLANK, null, WorkflowUtil.getWorkflowContext(controlloPratica)); + WorkflowTaskManagerUtil.assignWorkflowTaskToRole(controlloPratica.getCompanyId(), + serviceContext.getUserId(), workflowTaskId, role.getRoleId(), StringPool.BLANK, null, + WorkflowUtil.getWorkflowContext(controlloPratica)); } else { throw new SystemException("riassegnare al ruolo non possibile"); } @@ -293,8 +307,9 @@ public class GestioneAttivitaPortlet extends MVCPortlet { serviceContext.setCreateDate(new Date()); serviceContext.setModifiedDate(new Date()); if (ParereGeologoLocalServiceUtil.countByIntPraticaIdParereVuoto(intPraticaId) == 0) { - ParereGeologo parereGeologo=ParereGeologoServiceUtil.addParereGeologo(geologoId, intPraticaId, dettPraticaId, serviceContext); - //ADT: aggiunta notifica geologo + ParereGeologo parereGeologo = ParereGeologoServiceUtil.addParereGeologo(geologoId, + intPraticaId, dettPraticaId, serviceContext); + // ADT: aggiunta notifica geologo MailUtil.invioNotificaGeologo(parereGeologo, serviceContext); } else { throw new PortalException("parere geologo gia presente"); @@ -312,20 +327,22 @@ public class GestioneAttivitaPortlet extends MVCPortlet { long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId"); long controlloPraticaId = ParamUtil.getLong(actionRequest, "controlloPraticaId"); long lastDettPraticaId = ParamUtil.getLong(actionRequest, "lastDettPraticaId"); - ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(controlloPraticaId); + ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil + .getControlloPratica(controlloPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); if (lastDettPraticaId != controlloPratica.getDettPraticaId() && intPratica.getStatusByUserId() == serviceContext.getUserId()) { - //ADT: BUG ID=5 - ControlloPraticaLocalServiceUtil.addPraticheAlControlloVarianti(controlloPraticaId, lastDettPraticaId,serviceContext); + // ADT: BUG ID=5 + ControlloPraticaLocalServiceUtil.addPraticheAlControlloVarianti(controlloPraticaId, + lastDettPraticaId, serviceContext); } else { SessionErrors.add(actionRequest, "error-aggiunta-pratiche-al-controllo"); } } @Override - public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, - PortletException { + public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) + throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); Locale locale = themeDisplay.getLocale(); @@ -344,19 +361,21 @@ public class GestioneAttivitaPortlet extends MVCPortlet { csv = exportToCSV(locale, resourceRequest, true, user); } else if (cmd.equals("po")) { csv = exportToCSV(locale, resourceRequest, false, user); - } else if (cmd.equals("exportRicercaMieAttivita") || cmd.equals("exportRicercaMieiRuoli") || cmd.equals("exportRicercaAltreAttivita") || cmd.equals("exportRicercaAttivitaConcluse")) { + } else if (cmd.equals("exportRicercaMieAttivita") || cmd.equals("exportRicercaMieiRuoli") + || cmd.equals("exportRicercaAltreAttivita") || cmd.equals("exportRicercaAttivitaConcluse")) { csv = exportSearch(locale, resourceRequest, user, cmd); - } - //ADT BUG BO ID= 1 SEZIONE ATTIVIT� + } + // ADT BUG BO ID= 1 SEZIONE ATTIVIT� if ("comuniForUfficio".equals(id)) { String ufficio = ParamUtil.getString(resourceRequest, "ufficioId"); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); List comuni; if (Validator.isNotNull(ufficio) && !ufficio.equals("0")) { try { - if(!ufficio.equals("-1")){ + if (!ufficio.equals("-1")) { long ufficioId = Long.parseLong(ufficio); - comuni = ComuneLocalServiceUtil.getComuniForOrganizationByUserIdUfficioId(user.getUserId(), ufficioId); + comuni = ComuneLocalServiceUtil.getComuniForOrganizationByUserIdUfficioId( + user.getUserId(), ufficioId); for (Comune comune : comuni) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("comuneId", comune.getComuneId()); @@ -377,24 +396,18 @@ public class GestioneAttivitaPortlet extends MVCPortlet { writeJSON(resourceRequest, resourceResponse, jsonArray); } - } - - - catch (Exception e) { - // TODO Auto-generated catch block + } catch (Exception e) { e.printStackTrace(); } - } + } } ServletResponseUtil.sendFile(request, response, "export_pratiche.csv", csv.getBytes(StringPool.UTF8), ContentTypes.TEXT_CSV_UTF8); - // super.serveResource(resourceRequest, resourceResponse); } - private String exportSearch(Locale locale, ResourceRequest resourceRequest, User user, String cmd) { HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(resourceRequest); @@ -406,14 +419,14 @@ public class GestioneAttivitaPortlet extends MVCPortlet { Hits hits = null; - if(cmd.equals("exportRicercaMieAttivita")){ - hits = ControlloPraticaAdvancedSearch.searchMieiTask(httpRequest, user, -1, -1); - } else if(cmd.equals("exportRicercaMieiRuoli")){ - hits = ControlloPraticaAdvancedSearch.searchTaskMieiRuoli(httpRequest, user, -1, -1); - } else if(cmd.equals("exportRicercaAltreAttivita")){ - hits = ControlloPraticaAdvancedSearch.searchAltriTask(httpRequest, user, -1, -1); - } else if(cmd.equals("exportRicercaAttivitaConcluse")){ - hits = ControlloPraticaAdvancedSearch.searchTaskConclusi(httpRequest, user, -1, -1); + if (cmd.equals("exportRicercaMieAttivita")) { + hits = ControlloPraticaAdvancedSearch.searchMieiTask(httpRequest, user, -1, -1); + } else if (cmd.equals("exportRicercaMieiRuoli")) { + hits = ControlloPraticaAdvancedSearch.searchTaskMieiRuoli(httpRequest, user, -1, -1); + } else if (cmd.equals("exportRicercaAltreAttivita")) { + hits = ControlloPraticaAdvancedSearch.searchAltriTask(httpRequest, user, -1, -1); + } else if (cmd.equals("exportRicercaAttivitaConcluse")) { + hits = ControlloPraticaAdvancedSearch.searchTaskConclusi(httpRequest, user, -1, -1); } for (Document doc : hits.toList()) { @@ -421,8 +434,8 @@ public class GestioneAttivitaPortlet extends MVCPortlet { String controlloPraticaId = doc.get("controlloPraticaId"); if (Validator.isNotNull(controlloPraticaId)) { - ControlloPratica controlloPratica = - ControlloPraticaLocalServiceUtil.fetchControlloPratica(GetterUtil.getLong(controlloPraticaId)); + ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil + .fetchControlloPratica(GetterUtil.getLong(controlloPraticaId)); if (Validator.isNotNull(controlloPratica)) { lista.add(controlloPratica); } @@ -430,60 +443,72 @@ public class GestioneAttivitaPortlet extends MVCPortlet { } - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.attivita"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.attivita"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.esito"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.esito"))); sb.append(StringPool.SEMICOLON); - - //ADT - BUG-13 Aggiunta colonna Data Esito - //Bug 33264 - if(cmd.equals("exportRicercaAttivitaConcluse")){ - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.dataesito"))); + + // ADT - BUG-13 Aggiunta colonna Data Esito + // Bug 33264 + if (cmd.equals("exportRicercaAttivitaConcluse")) { + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.dataesito"))); sb.append(StringPool.SEMICOLON); } - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.sorteggiata"))); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.sorteggiata"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.pratica"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.pratica"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.istruttore"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.istruttore"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provenienza"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.provenienza"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.avvioprocedimento"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.avvioprocedimento"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provincia"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.provincia"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.gg"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.gg"))); sb.append(StringPool.SEMICOLON); sb.append(StringPool.NEW_LINE); - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); for (ControlloPratica controlloPratica : lista) { - IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(controlloPratica.getIntPraticaId()); + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(controlloPratica + .getIntPraticaId()); - Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId()); + Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica + .getTerritorioId()); Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); - Provincia provincia = - ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia()); + Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), + territorio.getCodiceProvincia()); // Informazioni relative al workflow - WorkflowInstanceLink workflowInstanceLink = - WorkflowInstanceLinkLocalServiceUtil.fetchWorkflowInstanceLink(controlloPratica.getCompanyId(), - controlloPratica.getGroupId(), ControlloPratica.class.getName(), controlloPratica.getPrimaryKey()); + WorkflowInstanceLink workflowInstanceLink = WorkflowInstanceLinkLocalServiceUtil + .fetchWorkflowInstanceLink(controlloPratica.getCompanyId(), + controlloPratica.getGroupId(), ControlloPratica.class.getName(), + controlloPratica.getPrimaryKey()); long workflowInstanceId = workflowInstanceLink.getWorkflowInstanceId(); - WorkflowInstance workflowInstance = - WorkflowInstanceManagerUtil.getWorkflowInstance(controlloPratica.getCompanyId(), workflowInstanceId); + WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance( + controlloPratica.getCompanyId(), workflowInstanceId); - List listaTask = - WorkflowTaskManagerUtil.getWorkflowTasksByWorkflowInstance(controlloPratica.getCompanyId(), null, - workflowInstance.getWorkflowInstanceId(), false, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); + List listaTask = WorkflowTaskManagerUtil.getWorkflowTasksByWorkflowInstance( + controlloPratica.getCompanyId(), null, workflowInstance.getWorkflowInstanceId(), + false, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); WorkflowTask task = null; if (listaTask != null && !listaTask.isEmpty()) { @@ -493,30 +518,33 @@ public class GestioneAttivitaPortlet extends MVCPortlet { String taskName = StringPool.BLANK; if (task != null) { User userTask = UserLocalServiceUtil.fetchUser(task.getAssigneeUserId()); - //Bug 33264 + // Bug 33264 taskName = LanguageUtil.get(getPortletConfig(), locale, task.getName()); if (userTask != null) { taskName += " (" + userTask.getFullName() + ")"; } } else { - //Bug 33264 + // Bug 33264 taskName = LanguageUtil.get(getPortletConfig(), locale, workflowInstance.getState()); } sb.append(CSVUtil.encode(taskName)); sb.append(StringPool.SEMICOLON); - String tipoEsito = ControlloPraticaLocalServiceUtil.getTipoEsito(controlloPratica.getControlloPraticaId()); + String tipoEsito = ControlloPraticaLocalServiceUtil.getTipoEsito(controlloPratica + .getControlloPraticaId()); sb.append(CSVUtil.encode(tipoEsito)); sb.append(StringPool.SEMICOLON); - - //ADT - BUG-13 Aggiunta colonna Data Esito - //Bug 33264 - if(cmd.equals("exportRicercaAttivitaConcluse")){ - sb.append(CSVUtil.encode(controlloPratica.getStatusDate() != null ? sdf.format(controlloPratica.getStatusDate()) : "" )); + + // ADT - BUG-13 Aggiunta colonna Data Esito + // Bug 33264 + if (cmd.equals("exportRicercaAttivitaConcluse")) { + sb.append(CSVUtil.encode(controlloPratica.getStatusDate() != null ? sdf + .format(controlloPratica.getStatusDate()) : "")); sb.append(StringPool.SEMICOLON); } - boolean sorteggiata = SorteggioLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()) != null; + boolean sorteggiata = SorteggioLocalServiceUtil + .findByIntPratica(intPratica.getIntPraticaId()) != null; sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No")); sb.append(StringPool.SEMICOLON); @@ -527,7 +555,7 @@ public class GestioneAttivitaPortlet extends MVCPortlet { String istruttore = "-"; if (intPratica.getStatusByUserId() != 0l) { User istruttoreUser = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); - if (istruttore != null) { + if (istruttoreUser != null) { istruttore = istruttoreUser.getFullName(); } else { istruttore = " [" + intPratica.getStatusByUserId() + "]"; @@ -537,9 +565,9 @@ public class GestioneAttivitaPortlet extends MVCPortlet { sb.append(StringPool.SEMICOLON); StringBuilder provenienzaLabel = new StringBuilder(); - WorkflowTask workflowTask = - WorkflowUtil.getLastCompletedTask(controlloPratica.getCompanyId(), controlloPratica.getGroupId(), null, - controlloPratica); + WorkflowTask workflowTask = WorkflowUtil.getLastCompletedTask( + controlloPratica.getCompanyId(), controlloPratica.getGroupId(), null, + controlloPratica); if (workflowTask != null) { User approvatore = UserLocalServiceUtil.fetchUser(workflowTask.getAssigneeUserId()); @@ -597,38 +625,45 @@ public class GestioneAttivitaPortlet extends MVCPortlet { List listaControlloPratica = new ArrayList(); if (dirigente) { - listaControlloPratica = - ControlloPraticaAdvancedSearch.searchTaskPerEsportazioneDirigente(httpRequest, user, QueryUtil.ALL_POS, - QueryUtil.ALL_POS); + listaControlloPratica = ControlloPraticaAdvancedSearch.searchTaskPerEsportazioneDirigente( + httpRequest, user, QueryUtil.ALL_POS, QueryUtil.ALL_POS); } else { - listaControlloPratica = - ControlloPraticaAdvancedSearch.searchTaskPerEsportazionePO(httpRequest, user, QueryUtil.ALL_POS, - QueryUtil.ALL_POS); + listaControlloPratica = ControlloPraticaAdvancedSearch.searchTaskPerEsportazionePO(httpRequest, + user, QueryUtil.ALL_POS, QueryUtil.ALL_POS); } - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.attivita"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.attivita"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.esito"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.esito"))); sb.append(StringPool.SEMICOLON); - - //ADT - BUG-13 Aggiunta colonna Data Esito - //Bug 33264 - if("Tab_TaskCompletati".equals(currentTab)){ - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.dataesito"))); + + // ADT - BUG-13 Aggiunta colonna Data Esito + // Bug 33264 + if ("Tab_TaskCompletati".equals(currentTab)) { + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.dataesito"))); sb.append(StringPool.SEMICOLON); } - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.sorteggiata"))); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.sorteggiata"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.pratica"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.pratica"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.istruttore"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.istruttore"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provenienza"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.provenienza"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.avvioprocedimento"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.avvioprocedimento"))); sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provincia"))); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.provincia"))); sb.append(StringPool.SEMICOLON); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.gg"))); sb.append(StringPool.SEMICOLON); @@ -641,26 +676,29 @@ public class GestioneAttivitaPortlet extends MVCPortlet { for (ControlloPratica controlloPratica : listaControlloPratica) { - IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(controlloPratica.getIntPraticaId()); + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(controlloPratica + .getIntPraticaId()); - Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId()); + Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica + .getTerritorioId()); Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); - Provincia provincia = - ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia()); + Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), + territorio.getCodiceProvincia()); // Informazioni relative al workflow - WorkflowInstanceLink workflowInstanceLink = - WorkflowInstanceLinkLocalServiceUtil.fetchWorkflowInstanceLink(controlloPratica.getCompanyId(), - controlloPratica.getGroupId(), ControlloPratica.class.getName(), controlloPratica.getPrimaryKey()); + WorkflowInstanceLink workflowInstanceLink = WorkflowInstanceLinkLocalServiceUtil + .fetchWorkflowInstanceLink(controlloPratica.getCompanyId(), + controlloPratica.getGroupId(), ControlloPratica.class.getName(), + controlloPratica.getPrimaryKey()); long workflowInstanceId = workflowInstanceLink.getWorkflowInstanceId(); - WorkflowInstance workflowInstance = - WorkflowInstanceManagerUtil.getWorkflowInstance(controlloPratica.getCompanyId(), workflowInstanceId); + WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance( + controlloPratica.getCompanyId(), workflowInstanceId); - List listaTask = - WorkflowTaskManagerUtil.getWorkflowTasksByWorkflowInstance(controlloPratica.getCompanyId(), null, - workflowInstance.getWorkflowInstanceId(), false, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); + List listaTask = WorkflowTaskManagerUtil.getWorkflowTasksByWorkflowInstance( + controlloPratica.getCompanyId(), null, workflowInstance.getWorkflowInstanceId(), + false, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); WorkflowTask task = null; if (listaTask != null && !listaTask.isEmpty()) { @@ -680,18 +718,20 @@ public class GestioneAttivitaPortlet extends MVCPortlet { sb.append(CSVUtil.encode(taskName)); sb.append(StringPool.SEMICOLON); - String tipoEsito = ControlloPraticaLocalServiceUtil.getTipoEsito(controlloPratica.getControlloPraticaId()); + String tipoEsito = ControlloPraticaLocalServiceUtil.getTipoEsito(controlloPratica + .getControlloPraticaId()); sb.append(CSVUtil.encode(tipoEsito)); sb.append(StringPool.SEMICOLON); - //ADT - BUG-13 Aggiunta colonna Data Esito - //Bug 33264 - if("Tab_TaskCompletati".equals(currentTab)){ + // ADT - BUG-13 Aggiunta colonna Data Esito + // Bug 33264 + if ("Tab_TaskCompletati".equals(currentTab)) { sb.append(CSVUtil.encode(sdf.format(controlloPratica.getStatusDate()))); sb.append(StringPool.SEMICOLON); } - - boolean sorteggiata = SorteggioLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()) != null; + + boolean sorteggiata = SorteggioLocalServiceUtil + .findByIntPratica(intPratica.getIntPraticaId()) != null; sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No")); sb.append(StringPool.SEMICOLON); @@ -702,7 +742,7 @@ public class GestioneAttivitaPortlet extends MVCPortlet { String istruttore = "-"; if (intPratica.getStatusByUserId() != 0l) { User istruttoreUser = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); - if (istruttore != null) { + if (istruttoreUser != null) { istruttore = istruttoreUser.getFullName(); } else { istruttore = " [" + intPratica.getStatusByUserId() + "]"; @@ -712,9 +752,9 @@ public class GestioneAttivitaPortlet extends MVCPortlet { sb.append(StringPool.SEMICOLON); StringBuilder provenienzaLabel = new StringBuilder(); - WorkflowTask workflowTask = - WorkflowUtil.getLastCompletedTask(controlloPratica.getCompanyId(), controlloPratica.getGroupId(), null, - controlloPratica); + WorkflowTask workflowTask = WorkflowUtil.getLastCompletedTask( + controlloPratica.getCompanyId(), controlloPratica.getGroupId(), null, + controlloPratica); if (workflowTask != null) { User approvatore = UserLocalServiceUtil.fetchUser(workflowTask.getAssigneeUserId()); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneFirmePortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneFirmePortlet.java index 279d4a73..eef8a62d 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneFirmePortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneFirmePortlet.java @@ -13,12 +13,9 @@ import it.tref.liferay.portos.bo.service.AvvisoLocalServiceUtil; import it.tref.liferay.portos.bo.service.AvvisoServiceUtil; import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; -import it.tref.liferay.portos.bo.service.TempisticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; import it.tref.liferay.portos.bo.util.Constants; import it.tref.liferay.portos.bo.util.GestioneFirmeUtil; -import it.tref.liferay.portos.bo.util.TempisticaConstants; - import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.PortletException; @@ -61,358 +58,364 @@ import com.liferay.util.bridges.mvc.MVCPortlet; */ public class GestioneFirmePortlet extends MVCPortlet { - private static final Log _log = LogFactoryUtil.getLog(GestioneFirmePortlet.class); - - public void assignaFirma(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException, - SystemException { - - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); - User user = UserLocalServiceUtil.getUser(serviceContext.getUserId()); - long avvisoId = ParamUtil.getLong(actionRequest, "avvisoId"); - - Avviso avviso = AvvisoLocalServiceUtil.getAvviso(avvisoId); - if (GestioneFirmeUtil.userCanSignAvviso(user.getUserId(), avviso.getGroupId(), avviso.getAvvisoId())) { - AvvisoServiceUtil.assegnaFirma(avviso.getAvvisoId(), user.getScreenName()); - PortalUtil.copyRequestParameters(actionRequest, actionResponse); - } else { - SessionErrors.add(actionRequest, "non possibile asssegnazione firma"); - } - } - - public void rilasciaFirma(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException, - SystemException { - - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); - User user = UserLocalServiceUtil.getUser(serviceContext.getUserId()); - long avvisoId = ParamUtil.getLong(actionRequest, "avvisoId"); - Avviso avviso = AvvisoLocalServiceUtil.getAvviso(avvisoId); - AvvisoServiceUtil.rilasciaFirma(avviso.getAvvisoId(), user.getScreenName()); - PortalUtil.copyRequestParameters(actionRequest, actionResponse); - } - - //ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV delle firme - @Override - public void serveResource(ResourceRequest resourceRequest, - ResourceResponse resourceResponse) throws IOException, - PortletException { - - String resourceId = GetterUtil.getString(resourceRequest.getResourceID()); - - if (resourceId.equals("exportCSV")) { - - ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); - - long companyId = themeDisplay.getCompanyId(); - Locale locale = themeDisplay.getLocale(); - User user = themeDisplay.getUser(); - - - String tabs1 = ParamUtil.getString(resourceRequest, "tabs1"); - - try { - - String csv = null; - String fileName = null; - - if("Tab_AvvisiDaFirmare".equals(tabs1)){ - fileName = "firmati"; - csv = exportToCSVAvvisiDaFirmare(companyId, user, locale); - } else if("Tab_AvvisiAltri".equals(tabs1)){ - fileName = "assegnati_altri"; - csv = exportToCSVAvvisiAltri(companyId, user, locale); - } else if("Tab_AvvisiFirme".equals(tabs1)){ - fileName = "da_firmare"; - csv = exportToCSVAvvisiFirme(companyId, user.getScreenName(), locale); - } - - HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); - HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); - - ServletResponseUtil.sendFile(request, response, "export_firme_" + fileName + ".csv", - csv.getBytes(StringPool.UTF8), ContentTypes.TEXT_CSV_UTF8); - - } catch (Exception e) { - throw new IOException(e); - } - - } + private static final Log _log = LogFactoryUtil.getLog(GestioneFirmePortlet.class); + public void assignaFirma(ActionRequest actionRequest, ActionResponse actionResponse) + throws PortalException, SystemException { - super.serveResource(resourceRequest, resourceResponse); - } + ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + User user = UserLocalServiceUtil.getUser(serviceContext.getUserId()); + long avvisoId = ParamUtil.getLong(actionRequest, "avvisoId"); - //ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV delle firme - private String exportToCSVAvvisiFirme(long companyId, String cf, Locale locale) throws Exception { - - Format dateFormat = FastDateFormatFactoryUtil.getDate(locale); - Format dateTimeFormat = FastDateFormatFactoryUtil.getDateTime(locale); - - StringBuilder sb = new StringBuilder(); - - List lista = AvvisoLocalServiceUtil.getAvvisiFirmatiByCF(companyId, cf, QueryUtil.ALL_POS, QueryUtil.ALL_POS); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.progetto"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.protocollo"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.descrizione"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "provincia"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.dataAvviso"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.tipoDocumento"))); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - - for (Iterator iterator = lista.iterator(); iterator.hasNext();) { - Avviso avviso = (Avviso) iterator.next(); - - DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); - IntPratica intPratica = null; - if(Validator.isNotNull(dettPratica)){ - intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); - } else { - intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId()); - } - sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(Validator.isNotNull(dettPratica) ? dettPratica.getProtocollo() : StringPool.BLANK)); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(avviso.getDescLong())); - sb.append(StringPool.SEMICOLON); - - long territorioGroupId = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()).getGroupId(); - long organizationId = GroupLocalServiceUtil.getGroup(territorioGroupId).getOrganizationId(); - String genio = OrganizationLocalServiceUtil.getOrganization(organizationId).getName(); - sb.append(CSVUtil.encode(genio)); - sb.append(StringPool.SEMICOLON); + Avviso avviso = AvvisoLocalServiceUtil.getAvviso(avvisoId); + if (GestioneFirmeUtil.userCanSignAvviso(user.getUserId(), avviso.getGroupId(), avviso.getAvvisoId())) { + AvvisoServiceUtil.assegnaFirma(avviso.getAvvisoId(), user.getScreenName()); + PortalUtil.copyRequestParameters(actionRequest, actionResponse); + } else { + SessionErrors.add(actionRequest, "non possibile asssegnazione firma"); + } + } + + public void rilasciaFirma(ActionRequest actionRequest, ActionResponse actionResponse) + throws PortalException, SystemException { + + ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + User user = UserLocalServiceUtil.getUser(serviceContext.getUserId()); + long avvisoId = ParamUtil.getLong(actionRequest, "avvisoId"); + Avviso avviso = AvvisoLocalServiceUtil.getAvviso(avvisoId); + AvvisoServiceUtil.rilasciaFirma(avviso.getAvvisoId(), user.getScreenName()); + PortalUtil.copyRequestParameters(actionRequest, actionResponse); + } + + // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV delle firme + @Override + public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) + throws IOException, PortletException { + + String resourceId = GetterUtil.getString(resourceRequest.getResourceID()); + + if (resourceId.equals("exportCSV")) { + + ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); + + long companyId = themeDisplay.getCompanyId(); + Locale locale = themeDisplay.getLocale(); + User user = themeDisplay.getUser(); + + String tabs1 = ParamUtil.getString(resourceRequest, "tabs1"); - - sb.append(CSVUtil.encode(dateFormat.format(avviso.getDtAvviso()))); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, avviso.translateTipoDocumento()))); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - } - - return sb.toString(); - } - //ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV delle firme - private String exportToCSVAvvisiAltri(long companyId, User user, Locale locale) throws Exception { - - Format dateFormat = FastDateFormatFactoryUtil.getDate(locale); - Format dateTimeFormat = FastDateFormatFactoryUtil.getDateTime(locale); - - StringBuilder sb = new StringBuilder(); - - long[] gruopIds = new long[0]; - List organizations = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); - for(Organization organization:organizations){ - if(UserGroupRoleLocalServiceUtil.hasUserGroupRole(user.getUserId(), organization.getGroupId(), Constants.ROLE_NAME_FIRMA, true)){ - gruopIds = ArrayUtil.append(gruopIds, organization.getGroupId()); - } - } - - List lista = AvvisoLocalServiceUtil.getAvvisiDaFirmarePrimaFirmaByNotCF(companyId, gruopIds, user.getScreenName(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.progetto"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.protocollo"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.descrizione"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "provincia"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.dataAvviso"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.tipoDocumento"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.firma"))); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - - for (Iterator iterator = lista.iterator(); iterator.hasNext();) { - Avviso avviso = (Avviso) iterator.next(); - - DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); - IntPratica intPratica = null; - if(Validator.isNotNull(dettPratica)){ - intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); - } else { - intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId()); - } - sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(Validator.isNotNull(dettPratica) ? dettPratica.getProtocollo() : StringPool.BLANK)); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(avviso.getDescLong())); - sb.append(StringPool.SEMICOLON); - - long territorioGroupId = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()).getGroupId(); - long organizationId = GroupLocalServiceUtil.getGroup(territorioGroupId).getOrganizationId(); - String genio = OrganizationLocalServiceUtil.getOrganization(organizationId).getName(); - sb.append(CSVUtil.encode(genio)); - sb.append(StringPool.SEMICOLON); - - - sb.append(CSVUtil.encode(dateFormat.format(avviso.getDtAvviso()))); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, avviso.translateTipoDocumento()))); - sb.append(StringPool.SEMICOLON); - - String cf = avviso.getUserCodiceFiscalePrimaFirma(); - User userFirma = UserLocalServiceUtil.fetchUserByScreenName(companyId, cf); - sb.append(CSVUtil.encode(Validator.isNotNull(userFirma) ? userFirma.getFullName() : cf)); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - } - - return sb.toString(); - } - - //ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV delle firme - private String exportToCSVAvvisiDaFirmare(long companyId, User user, Locale locale) throws Exception { - - Format dateFormat = FastDateFormatFactoryUtil.getDate(locale); - Format dateTimeFormat = FastDateFormatFactoryUtil.getDateTime(locale); - - StringBuilder sb = new StringBuilder(); - - List listaLeTueFirme = AvvisoLocalServiceUtil.getAvvisiDaFirmarePrimaFirmaByCF(companyId, user.getScreenName(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); - - sb.append("LE TUE FIRME"); - sb.append(StringPool.NEW_LINE); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.progetto"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.protocollo"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.descrizione"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "provincia"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.dataAvviso"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.tipoDocumento"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.firma"))); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - - for (Iterator iterator = listaLeTueFirme.iterator(); iterator.hasNext();) { - Avviso avviso = (Avviso) iterator.next(); - - DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); - IntPratica intPratica = null; - if(Validator.isNotNull(dettPratica)){ - intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); - } else { - intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId()); - } - sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(Validator.isNotNull(dettPratica) ? dettPratica.getProtocollo() : StringPool.BLANK)); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(avviso.getDescLong())); - sb.append(StringPool.SEMICOLON); - - long territorioGroupId = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()).getGroupId(); - long organizationId = GroupLocalServiceUtil.getGroup(territorioGroupId).getOrganizationId(); - String genio = OrganizationLocalServiceUtil.getOrganization(organizationId).getName(); - sb.append(CSVUtil.encode(genio)); - sb.append(StringPool.SEMICOLON); - - - sb.append(CSVUtil.encode(dateFormat.format(avviso.getDtAvviso()))); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, avviso.translateTipoDocumento()))); - sb.append(StringPool.SEMICOLON); - - String cf = avviso.getUserCodiceFiscalePrimaFirma(); - User userFirma = UserLocalServiceUtil.fetchUserByScreenName(companyId, cf); - sb.append(CSVUtil.encode(Validator.isNotNull(userFirma) ? userFirma.getFullName() : cf)); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - } - - sb.append(StringPool.NEW_LINE); - sb.append(StringPool.NEW_LINE); - - - long[] gruopIds = new long[0]; - List organizations = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); - for(Organization organization:organizations){ - if(UserGroupRoleLocalServiceUtil.hasUserGroupRole(user.getUserId(), organization.getGroupId(), Constants.ROLE_NAME_FIRMA, true)){ - gruopIds = ArrayUtil.append(gruopIds, organization.getGroupId()); - } - } - List listaFirmeAssegnateAlRuolo = AvvisoLocalServiceUtil.getAvvisiDaFirmarePrimaFirma(companyId, gruopIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS); - - sb.append("FIRME ASSEGNATE AL RUOLO"); - sb.append(StringPool.NEW_LINE); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.progetto"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.protocollo"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.descrizione"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "provincia"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.dataAvviso"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.tipoDocumento"))); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - - for (Iterator iterator = listaFirmeAssegnateAlRuolo.iterator(); iterator.hasNext();) { - Avviso avviso = (Avviso) iterator.next(); - - DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); - IntPratica intPratica = null; - if(Validator.isNotNull(dettPratica)){ - intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); - } else { - intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId()); - } - sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(Validator.isNotNull(dettPratica) ? dettPratica.getProtocollo() : StringPool.BLANK)); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(avviso.getDescLong())); - sb.append(StringPool.SEMICOLON); - - long territorioGroupId = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()).getGroupId(); - long organizationId = GroupLocalServiceUtil.getGroup(territorioGroupId).getOrganizationId(); - String genio = OrganizationLocalServiceUtil.getOrganization(organizationId).getName(); - sb.append(CSVUtil.encode(genio)); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(dateFormat.format(avviso.getDtAvviso()))); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, avviso.translateTipoDocumento()))); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - } - - return sb.toString(); - } + try { + + String csv = null; + String fileName = null; + + if ("Tab_AvvisiDaFirmare".equals(tabs1)) { + fileName = "firmati"; + csv = exportToCSVAvvisiDaFirmare(companyId, user, locale); + } else if ("Tab_AvvisiAltri".equals(tabs1)) { + fileName = "assegnati_altri"; + csv = exportToCSVAvvisiAltri(companyId, user, locale); + } else if ("Tab_AvvisiFirme".equals(tabs1)) { + fileName = "da_firmare"; + csv = exportToCSVAvvisiFirme(companyId, user.getScreenName(), locale); + } + + HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); + HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); + + ServletResponseUtil.sendFile(request, response, "export_firme_" + fileName + ".csv", + csv.getBytes(StringPool.UTF8), ContentTypes.TEXT_CSV_UTF8); + + } catch (Exception e) { + throw new IOException(e); + } + + } + + super.serveResource(resourceRequest, resourceResponse); + } + + // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV delle firme + private String exportToCSVAvvisiFirme(long companyId, String cf, Locale locale) throws Exception { + + Format dateFormat = FastDateFormatFactoryUtil.getDate(locale); + StringBuilder sb = new StringBuilder(); + + List lista = AvvisoLocalServiceUtil.getAvvisiFirmatiByCF(companyId, cf, QueryUtil.ALL_POS, + QueryUtil.ALL_POS); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.progetto"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.protocollo"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.descrizione"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "provincia"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.dataAvviso"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.tipoDocumento"))); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + + for (Iterator iterator = lista.iterator(); iterator.hasNext();) { + Avviso avviso = (Avviso) iterator.next(); + + DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); + IntPratica intPratica = null; + if (Validator.isNotNull(dettPratica)) { + intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); + } else { + intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId()); + } + sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(Validator.isNotNull(dettPratica) ? dettPratica.getProtocollo() + : StringPool.BLANK)); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(avviso.getDescLong())); + sb.append(StringPool.SEMICOLON); + + long territorioGroupId = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()) + .getGroupId(); + long organizationId = GroupLocalServiceUtil.getGroup(territorioGroupId).getOrganizationId(); + String genio = OrganizationLocalServiceUtil.getOrganization(organizationId).getName(); + sb.append(CSVUtil.encode(genio)); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(dateFormat.format(avviso.getDtAvviso()))); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + avviso.translateTipoDocumento()))); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + } + + return sb.toString(); + } + + // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV delle firme + private String exportToCSVAvvisiAltri(long companyId, User user, Locale locale) throws Exception { + + Format dateFormat = FastDateFormatFactoryUtil.getDate(locale); + StringBuilder sb = new StringBuilder(); + + long[] gruopIds = new long[0]; + List organizations = OrganizationLocalServiceUtil + .getUserOrganizations(user.getUserId()); + for (Organization organization : organizations) { + if (UserGroupRoleLocalServiceUtil.hasUserGroupRole(user.getUserId(), organization.getGroupId(), + Constants.ROLE_NAME_FIRMA, true)) { + gruopIds = ArrayUtil.append(gruopIds, organization.getGroupId()); + } + } + + List lista = AvvisoLocalServiceUtil.getAvvisiDaFirmarePrimaFirmaByNotCF(companyId, gruopIds, + user.getScreenName(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.progetto"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.protocollo"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.descrizione"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "provincia"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.dataAvviso"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.tipoDocumento"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.firma"))); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + + for (Iterator iterator = lista.iterator(); iterator.hasNext();) { + Avviso avviso = (Avviso) iterator.next(); + + DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); + IntPratica intPratica = null; + if (Validator.isNotNull(dettPratica)) { + intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); + } else { + intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId()); + } + sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(Validator.isNotNull(dettPratica) ? dettPratica.getProtocollo() + : StringPool.BLANK)); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(avviso.getDescLong())); + sb.append(StringPool.SEMICOLON); + + long territorioGroupId = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()) + .getGroupId(); + long organizationId = GroupLocalServiceUtil.getGroup(territorioGroupId).getOrganizationId(); + String genio = OrganizationLocalServiceUtil.getOrganization(organizationId).getName(); + sb.append(CSVUtil.encode(genio)); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(dateFormat.format(avviso.getDtAvviso()))); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + avviso.translateTipoDocumento()))); + sb.append(StringPool.SEMICOLON); + + String cf = avviso.getUserCodiceFiscalePrimaFirma(); + User userFirma = UserLocalServiceUtil.fetchUserByScreenName(companyId, cf); + sb.append(CSVUtil.encode(Validator.isNotNull(userFirma) ? userFirma.getFullName() : cf)); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + } + + return sb.toString(); + } + + // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV delle firme + private String exportToCSVAvvisiDaFirmare(long companyId, User user, Locale locale) throws Exception { + + Format dateFormat = FastDateFormatFactoryUtil.getDate(locale); + StringBuilder sb = new StringBuilder(); + + List listaLeTueFirme = AvvisoLocalServiceUtil.getAvvisiDaFirmarePrimaFirmaByCF(companyId, + user.getScreenName(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); + + sb.append("LE TUE FIRME"); + sb.append(StringPool.NEW_LINE); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.progetto"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.protocollo"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.descrizione"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "provincia"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.dataAvviso"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.tipoDocumento"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.firma"))); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + + for (Iterator iterator = listaLeTueFirme.iterator(); iterator.hasNext();) { + Avviso avviso = (Avviso) iterator.next(); + + DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); + IntPratica intPratica = null; + if (Validator.isNotNull(dettPratica)) { + intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); + } else { + intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId()); + } + sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(Validator.isNotNull(dettPratica) ? dettPratica.getProtocollo() + : StringPool.BLANK)); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(avviso.getDescLong())); + sb.append(StringPool.SEMICOLON); + + long territorioGroupId = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()) + .getGroupId(); + long organizationId = GroupLocalServiceUtil.getGroup(territorioGroupId).getOrganizationId(); + String genio = OrganizationLocalServiceUtil.getOrganization(organizationId).getName(); + sb.append(CSVUtil.encode(genio)); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(dateFormat.format(avviso.getDtAvviso()))); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + avviso.translateTipoDocumento()))); + sb.append(StringPool.SEMICOLON); + + String cf = avviso.getUserCodiceFiscalePrimaFirma(); + User userFirma = UserLocalServiceUtil.fetchUserByScreenName(companyId, cf); + sb.append(CSVUtil.encode(Validator.isNotNull(userFirma) ? userFirma.getFullName() : cf)); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + } + + sb.append(StringPool.NEW_LINE); + sb.append(StringPool.NEW_LINE); + + long[] gruopIds = new long[0]; + List organizations = OrganizationLocalServiceUtil + .getUserOrganizations(user.getUserId()); + for (Organization organization : organizations) { + if (UserGroupRoleLocalServiceUtil.hasUserGroupRole(user.getUserId(), organization.getGroupId(), + Constants.ROLE_NAME_FIRMA, true)) { + gruopIds = ArrayUtil.append(gruopIds, organization.getGroupId()); + } + } + List listaFirmeAssegnateAlRuolo = AvvisoLocalServiceUtil.getAvvisiDaFirmarePrimaFirma( + companyId, gruopIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS); + + sb.append("FIRME ASSEGNATE AL RUOLO"); + sb.append(StringPool.NEW_LINE); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.progetto"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.protocollo"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.descrizione"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "provincia"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.dataAvviso"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.avviso.tipoDocumento"))); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + + for (Iterator iterator = listaFirmeAssegnateAlRuolo.iterator(); iterator.hasNext();) { + Avviso avviso = (Avviso) iterator.next(); + + DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); + IntPratica intPratica = null; + if (Validator.isNotNull(dettPratica)) { + intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); + } else { + intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId()); + } + sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(Validator.isNotNull(dettPratica) ? dettPratica.getProtocollo() + : StringPool.BLANK)); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(avviso.getDescLong())); + sb.append(StringPool.SEMICOLON); + + long territorioGroupId = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()) + .getGroupId(); + long organizationId = GroupLocalServiceUtil.getGroup(territorioGroupId).getOrganizationId(); + String genio = OrganizationLocalServiceUtil.getOrganization(organizationId).getName(); + sb.append(CSVUtil.encode(genio)); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(dateFormat.format(avviso.getDtAvviso()))); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + avviso.translateTipoDocumento()))); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + } + return sb.toString(); + } } - \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/PortosAdministrationPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/PortosAdministrationPortlet.java index fcf4b3c6..d871fd15 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/PortosAdministrationPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/PortosAdministrationPortlet.java @@ -38,12 +38,12 @@ public class PortosAdministrationPortlet extends MVCPortlet { throws SystemException { List esito = new ArrayList(); - esito.add("

Env

"); + esito.add("

Env:

"); for (Map.Entry entry : System.getenv().entrySet()) { esito.add(entry.getKey() + "=" + entry.getValue()); } - esito.add("

Properties

"); + esito.add("

Properties:

"); for (Map.Entry entry : System.getProperties().entrySet()) { esito.add(entry.getKey() + "=" + entry.getValue()); } @@ -51,7 +51,8 @@ public class PortosAdministrationPortlet extends MVCPortlet { } public void inviaComunicazione(ActionRequest actionRequest, ActionResponse actionResponse) { - ThemeDisplay td = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); + // ThemeDisplay td = (ThemeDisplay) + // actionRequest.getAttribute(WebKeys.THEME_DISPLAY); List esito = new ArrayList<>(); actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); } @@ -117,8 +118,7 @@ public class PortosAdministrationPortlet extends MVCPortlet { } - private ServiceContext getServiceContext(ControlloPratica controlloPratica) { - + private static ServiceContext getServiceContext(ControlloPratica controlloPratica) { ServiceContext serviceContext = new ServiceContext(); serviceContext.setCompanyId(controlloPratica.getCompanyId()); serviceContext.setScopeGroupId(controlloPratica.getGroupId()); @@ -126,8 +126,7 @@ public class PortosAdministrationPortlet extends MVCPortlet { return serviceContext; } - private ServiceContext getServiceContext(DettPratica dettPratica) { - + private static ServiceContext getServiceContext(DettPratica dettPratica) { ServiceContext serviceContext = new ServiceContext(); serviceContext.setCompanyId(dettPratica.getCompanyId()); serviceContext.setScopeGroupId(dettPratica.getGroupId()); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/TempistichePortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/TempistichePortlet.java index 653a5dce..f0747bf6 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/TempistichePortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/TempistichePortlet.java @@ -60,293 +60,331 @@ import com.liferay.util.bridges.mvc.MVCPortlet; */ public class TempistichePortlet extends MVCPortlet { - @Override - public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, - PortletException { - - String resourceId = GetterUtil.getString(resourceRequest.getResourceID()); - - if (resourceId.equals("exportCSV") || resourceId.equals("exportAllCSV")) { - - ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); - - long companyId = themeDisplay.getCompanyId(); - long groupId = ParamUtil.getLong(resourceRequest, "groupId", 0l); - Locale locale = themeDisplay.getLocale(); - - String tipoTempistica = ParamUtil.getString(resourceRequest, "tipoTempistica"); - - //ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca - Integer statoPratica = Validator.isNotNull(resourceRequest.getParameter("statoPratica")) && !"".equals(resourceRequest.getParameter("statoPratica")) ? ParamUtil.getInteger(resourceRequest, "statoPratica") : null; - - //ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca - String tipoPratica = ParamUtil.getString(resourceRequest, "tipoPratica"); - String istruttore = ParamUtil.getString(resourceRequest, "istruttore"); - - try { - //ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca - String csv = exportToCSV(companyId, groupId, locale, tipoTempistica, statoPratica, tipoPratica, istruttore, resourceId.equals("exportAllCSV")); - - HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); - HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); - - ServletResponseUtil.sendFile(request, response, "export_scadenze_" + tipoTempistica + ".csv", - csv.getBytes(StringPool.UTF8), ContentTypes.TEXT_CSV_UTF8); - - } catch (Exception e) { - throw new IOException(e); - } - - } else { - super.serveResource(resourceRequest, resourceResponse); - } - } - - //ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca - public void search(ActionRequest actionRequest, ActionResponse actionResponse){ - - String tipoPratica = ParamUtil.getString(actionRequest, "tipoPratica", StringPool.BLANK); - String istruttore = ParamUtil.getString(actionRequest, "istruttore", StringPool.BLANK); - String statoPratica = ParamUtil.getString(actionRequest, "statoPratica", StringPool.BLANK); - - actionResponse.setRenderParameter("tipoPratica", tipoPratica); - actionResponse.setRenderParameter("istruttore", istruttore); - actionResponse.setRenderParameter("statoPratica", statoPratica); - } - - //ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca - private String exportToCSV(long companyId, long groupId, Locale locale, String tipoTempistica, Integer statoPratica, String tipoPratica, String istruttore, boolean isBackCompatibility) throws Exception { - - Format dateFormat = FastDateFormatFactoryUtil.getDate(locale); - Format dateTimeFormat = FastDateFormatFactoryUtil.getDateTime(locale); - - StringBuilder sb = new StringBuilder(); - - if (tipoTempistica.equals(TempisticaConstants.TIPO_PRATICA)) { - //ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca - List tempistiche = isBackCompatibility ? - TempisticaLocalServiceUtil.scadenzePraticheForBackwardCompatibility(companyId, groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS) : - TempisticaLocalServiceUtil.getScadenzePratiche(companyId, groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, statoPratica, tipoPratica, istruttore); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provincia"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.tipopratica"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.progetto"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.istruttore"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.datavidimazione"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.datasorteggio"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.start"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.tempoattivita"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.timerfermo"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza"))); - - sb.append(StringPool.NEW_LINE); - - List alreadyInserted = new ArrayList(); - - for (Object[] tempistica : tempistiche) { - - Long intPraticaId = (Long) tempistica[0]; - Long start = (Long) tempistica[1]; - Long stop = (Long) tempistica[2]; - // Long wait = (Long) tempistica[3]; - Long calcoloTempo = (Long) tempistica[4]; - Integer stato = (Integer) tempistica[5]; - - Long dettPraticaId = 0L; - - DynamicQuery query = DynamicQueryFactoryUtil.forClass(Tempistica.class); - query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId)); - query.add(RestrictionsFactoryUtil.eq("tipo", "P")); - Order defaultOrderDettPrtatica = OrderFactoryUtil.desc("createDate"); - query.addOrder(defaultOrderDettPrtatica); - - List lista = TempisticaLocalServiceUtil.dynamicQuery(query); - if(lista != null && !lista.isEmpty() && lista.size() > 1){ - intPraticaId = lista.get(0).getIntPraticaId(); - dettPraticaId = lista.get(0).getDettPraticaId(); - - stop = lista.get(0).getStop(); - if(alreadyInserted.contains(intPraticaId)){ - continue; - } - - alreadyInserted.add(intPraticaId); - } else { - dettPraticaId = lista.get(0).getDettPraticaId(); - - alreadyInserted.add(intPraticaId); - } - - - // DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(dettPraticaId); - IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); - Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId()); - Provincia provincia = - ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia()); - - sb.append(CSVUtil.encode(provincia.getProvincia())); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "tipo-pratica-"+intPratica.getTipoPratica()))); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); - sb.append(StringPool.SEMICOLON); - - long statusByUserId = intPratica.getStatusByUserId(); - if (Validator.isNotNull(statusByUserId) && intPratica.getStatus() != WorkflowConstants.STATUS_DRAFT) { - try { - User istruttoreUser = UserLocalServiceUtil.getUser(statusByUserId); - sb.append(CSVUtil.encode(istruttoreUser.getFullName() + StringPool.SPACE + StringPool.OPEN_PARENTHESIS - + istruttoreUser.getScreenName() + StringPool.CLOSE_PARENTHESIS)); - } catch (PortalException e) { - } - } - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(dateTimeFormat.format(intPratica.getDtPratica()))); - sb.append(StringPool.SEMICOLON); - - if (Validator.isNotNull(intPratica.getDtSorteggio())) { - sb.append(CSVUtil.encode(dateFormat.format(intPratica.getDtSorteggio()))); - } - sb.append(StringPool.SEMICOLON); - - DynamicQuery queryAvv = DynamicQueryFactoryUtil.forClass(Avviso.class); - queryAvv.add(RestrictionsFactoryUtil.eq("intPraticaId", intPratica.getIntPraticaId())); - queryAvv.add(RestrictionsFactoryUtil.eq("tipoDocumento", "SP")); - queryAvv.add(RestrictionsFactoryUtil.eq("className", DettPratica.class.getName())); - if(dettPraticaId != 0L ){ - queryAvv.add(RestrictionsFactoryUtil.eq("classPk", dettPraticaId)); - } - - Order defaultOrder = OrderFactoryUtil.desc("createDate"); - queryAvv.addOrder(defaultOrder); - - - List listaAvv = AvvisoLocalServiceUtil.dynamicQuery(queryAvv); - if(listaAvv != null && !listaAvv.isEmpty() && listaAvv.get(0).getDtInvio() != null){ - sb.append(CSVUtil.encode(dateFormat.format(listaAvv.get(0).getDtInvio()))); - } else { - sb.append(""); - } - -// sb.append(CSVUtil.encode(dateFormat.format(new Date(start)))); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(String.valueOf(TimeUnit.MILLISECONDS.toDays(calcoloTempo)))); - sb.append(StringPool.SEMICOLON); - - if (Validator.isNotNull(stop)) { - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza.si"))); - sb.append(StringPool.SPACE); - sb.append(CSVUtil.encode(LanguageUtil.format(getPortletConfig(), locale, - "label.scadenzegeniocivile.timer.dal", dateFormat.format(new Date(stop))))); - } else { - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza.no"))); - } - sb.append(StringPool.SEMICOLON); - - if (Validator.isNotNull(stop)) { - sb.append(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza.inattesa")); - } else if (stato.intValue() == TempisticaConstants.STATO_IN_SCADENZA) { - sb.append(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza.inscadenza")); - } else if (stato.intValue() == TempisticaConstants.STATO_SCADUTA) { - sb.append(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza.scaduto")); - } else if (stato.intValue() == TempisticaConstants.STATO_ATTIVA) { - sb.append(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza.attivo")); - } - - sb.append(StringPool.NEW_LINE); - } - - } else if (tipoTempistica.equals(TempisticaConstants.TIPO_INTEGRAZIONE)) { - List tempistiche = - TempisticaLocalServiceUtil.getScadenzeIntegrazioni(companyId, groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, statoPratica); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provincia"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.tipopratica"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.progetto"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.istruttore"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.start"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.tempoattivita"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza"))); - - sb.append(StringPool.NEW_LINE); - - for (Object[] tempistica : tempistiche) { - - Long intPraticaId = (Long) tempistica[0]; - Long start = (Long) tempistica[1]; - Long calcoloTempo = (Long) tempistica[2]; - Integer stato = (Integer) tempistica[3]; - Long dettPraticaId = (Long) tempistica[4]; - - // DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(dettPraticaId); - IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); - Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId()); - Provincia provincia = - ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia()); - - sb.append(CSVUtil.encode(provincia.getProvincia())); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(intPratica.getTipoPratica())); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); - sb.append(StringPool.SEMICOLON); - - long statusByUserId = intPratica.getStatusByUserId(); - if (Validator.isNotNull(statusByUserId) && intPratica.getStatus() != WorkflowConstants.STATUS_DRAFT) { - try { - User istruttoreUser = UserLocalServiceUtil.getUser(statusByUserId); - sb.append(CSVUtil.encode(istruttoreUser.getFullName() + StringPool.SPACE + StringPool.OPEN_PARENTHESIS - + istruttoreUser.getScreenName() + StringPool.CLOSE_PARENTHESIS)); - } catch (PortalException e) { - } - } - sb.append(StringPool.SEMICOLON); - - - List avvisi = - AvvisoLocalServiceUtil.findByClassPk_tipoDocumento(dettPraticaId, StatoPraticaConstants.SOTTOPOSTA_A_PARERE); - if (avvisi.size() > 0 && avvisi.get(0).getDtAvviso() != null) { - sb.append(CSVUtil.encode(dateFormat.format(avvisi.get(0).getDtInvio()))); - } else { - sb.append("-"); - - } - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(String.valueOf(TimeUnit.MILLISECONDS.toDays(calcoloTempo)))); - sb.append(StringPool.SEMICOLON); - - if (stato.intValue() == TempisticaConstants.STATO_SCADUTA) { - sb.append(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza.scaduto")); - } else if (stato.intValue() == TempisticaConstants.STATO_ATTIVA) { - sb.append(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.scadenza.attivo")); - } - - sb.append(StringPool.NEW_LINE); - } - } - - return sb.toString(); - } + @Override + public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) + throws IOException, PortletException { + + String resourceId = GetterUtil.getString(resourceRequest.getResourceID()); + + if (resourceId.equals("exportCSV") || resourceId.equals("exportAllCSV")) { + + ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); + + long companyId = themeDisplay.getCompanyId(); + long groupId = ParamUtil.getLong(resourceRequest, "groupId", 0l); + Locale locale = themeDisplay.getLocale(); + + String tipoTempistica = ParamUtil.getString(resourceRequest, "tipoTempistica"); + + // ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca + Integer statoPratica = Validator.isNotNull(resourceRequest.getParameter("statoPratica")) + && !"".equals(resourceRequest.getParameter("statoPratica")) ? ParamUtil.getInteger( + resourceRequest, "statoPratica") : null; + + // ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca + String tipoPratica = ParamUtil.getString(resourceRequest, "tipoPratica"); + String istruttore = ParamUtil.getString(resourceRequest, "istruttore"); + + try { + // ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca + String csv = exportToCSV(companyId, groupId, locale, tipoTempistica, statoPratica, + tipoPratica, istruttore, resourceId.equals("exportAllCSV")); + + HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); + HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); + + ServletResponseUtil.sendFile(request, response, "export_scadenze_" + tipoTempistica + ".csv", + csv.getBytes(StringPool.UTF8), ContentTypes.TEXT_CSV_UTF8); + + } catch (Exception e) { + throw new IOException(e); + } + + } else { + super.serveResource(resourceRequest, resourceResponse); + } + } + + // ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca + public void search(ActionRequest actionRequest, ActionResponse actionResponse) { + + String tipoPratica = ParamUtil.getString(actionRequest, "tipoPratica", StringPool.BLANK); + String istruttore = ParamUtil.getString(actionRequest, "istruttore", StringPool.BLANK); + String statoPratica = ParamUtil.getString(actionRequest, "statoPratica", StringPool.BLANK); + + actionResponse.setRenderParameter("tipoPratica", tipoPratica); + actionResponse.setRenderParameter("istruttore", istruttore); + actionResponse.setRenderParameter("statoPratica", statoPratica); + } + + // ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca + private String exportToCSV(long companyId, long groupId, Locale locale, String tipoTempistica, + Integer statoPratica, String tipoPratica, String istruttore, boolean isBackCompatibility) + throws Exception { + + Format dateFormat = FastDateFormatFactoryUtil.getDate(locale); + Format dateTimeFormat = FastDateFormatFactoryUtil.getDateTime(locale); + + StringBuilder sb = new StringBuilder(); + + if (tipoTempistica.equals(TempisticaConstants.TIPO_PRATICA)) { + // ADT - BUG-29 - Scadenziario / Creazione Filtri Ricerca + List tempistiche = isBackCompatibility ? TempisticaLocalServiceUtil + .scadenzePraticheForBackwardCompatibility(companyId, groupId, QueryUtil.ALL_POS, + QueryUtil.ALL_POS) : TempisticaLocalServiceUtil.getScadenzePratiche(companyId, + groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, statoPratica, tipoPratica, istruttore); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.provincia"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.tipopratica"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.progetto"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.istruttore"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.datavidimazione"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.datasorteggio"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.start"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.tempoattivita"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.timerfermo"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza"))); + + sb.append(StringPool.NEW_LINE); + + List alreadyInserted = new ArrayList(); + + for (Object[] tempistica : tempistiche) { + + Long intPraticaId = (Long) tempistica[0]; + // Long start = (Long) tempistica[1]; + Long stop = (Long) tempistica[2]; + // Long wait = (Long) tempistica[3]; + Long calcoloTempo = (Long) tempistica[4]; + Integer stato = (Integer) tempistica[5]; + + Long dettPraticaId = 0L; + + DynamicQuery query = DynamicQueryFactoryUtil.forClass(Tempistica.class); + query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId)); + query.add(RestrictionsFactoryUtil.eq("tipo", "P")); + Order defaultOrderDettPrtatica = OrderFactoryUtil.desc("createDate"); + query.addOrder(defaultOrderDettPrtatica); + + List lista = TempisticaLocalServiceUtil.dynamicQuery(query); + if (lista != null && !lista.isEmpty() && lista.size() > 1) { + intPraticaId = lista.get(0).getIntPraticaId(); + dettPraticaId = lista.get(0).getDettPraticaId(); + + stop = lista.get(0).getStop(); + if (alreadyInserted.contains(intPraticaId)) { + continue; + } + + alreadyInserted.add(intPraticaId); + } else { + dettPraticaId = lista.get(0).getDettPraticaId(); + + alreadyInserted.add(intPraticaId); + } + + // DettPratica dettPratica = + // DettPraticaLocalServiceUtil.getDettPratica(dettPraticaId); + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); + Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica + .getTerritorioId()); + Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), + territorio.getCodiceProvincia()); + + sb.append(CSVUtil.encode(provincia.getProvincia())); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "tipo-pratica-" + + intPratica.getTipoPratica()))); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); + sb.append(StringPool.SEMICOLON); + + long statusByUserId = intPratica.getStatusByUserId(); + if (Validator.isNotNull(statusByUserId) + && intPratica.getStatus() != WorkflowConstants.STATUS_DRAFT) { + try { + User istruttoreUser = UserLocalServiceUtil.getUser(statusByUserId); + sb.append(CSVUtil.encode(istruttoreUser.getFullName() + StringPool.SPACE + + StringPool.OPEN_PARENTHESIS + istruttoreUser.getScreenName() + + StringPool.CLOSE_PARENTHESIS)); + } catch (PortalException e) { + } + } + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(dateTimeFormat.format(intPratica.getDtPratica()))); + sb.append(StringPool.SEMICOLON); + + if (Validator.isNotNull(intPratica.getDtSorteggio())) { + sb.append(CSVUtil.encode(dateFormat.format(intPratica.getDtSorteggio()))); + } + sb.append(StringPool.SEMICOLON); + + DynamicQuery queryAvv = DynamicQueryFactoryUtil.forClass(Avviso.class); + queryAvv.add(RestrictionsFactoryUtil.eq("intPraticaId", intPratica.getIntPraticaId())); + queryAvv.add(RestrictionsFactoryUtil.eq("tipoDocumento", "SP")); + queryAvv.add(RestrictionsFactoryUtil.eq("className", DettPratica.class.getName())); + if (dettPraticaId != 0L) { + queryAvv.add(RestrictionsFactoryUtil.eq("classPk", dettPraticaId)); + } + + Order defaultOrder = OrderFactoryUtil.desc("createDate"); + queryAvv.addOrder(defaultOrder); + + List listaAvv = AvvisoLocalServiceUtil.dynamicQuery(queryAvv); + if (listaAvv != null && !listaAvv.isEmpty() && listaAvv.get(0).getDtInvio() != null) { + sb.append(CSVUtil.encode(dateFormat.format(listaAvv.get(0).getDtInvio()))); + } else { + sb.append(""); + } + + // sb.append(CSVUtil.encode(dateFormat.format(new + // Date(start)))); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(String.valueOf(TimeUnit.MILLISECONDS.toDays(calcoloTempo)))); + sb.append(StringPool.SEMICOLON); + + if (Validator.isNotNull(stop)) { + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza.si"))); + sb.append(StringPool.SPACE); + sb.append(CSVUtil.encode(LanguageUtil.format(getPortletConfig(), locale, + "label.scadenzegeniocivile.timer.dal", dateFormat.format(new Date(stop))))); + } else { + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza.no"))); + } + sb.append(StringPool.SEMICOLON); + + if (Validator.isNotNull(stop)) { + sb.append(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza.inattesa")); + } else if (stato.intValue() == TempisticaConstants.STATO_IN_SCADENZA) { + sb.append(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza.inscadenza")); + } else if (stato.intValue() == TempisticaConstants.STATO_SCADUTA) { + sb.append(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza.scaduto")); + } else if (stato.intValue() == TempisticaConstants.STATO_ATTIVA) { + sb.append(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza.attivo")); + } + + sb.append(StringPool.NEW_LINE); + } + + } else if (tipoTempistica.equals(TempisticaConstants.TIPO_INTEGRAZIONE)) { + List tempistiche = TempisticaLocalServiceUtil.getScadenzeIntegrazioni(companyId, + groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, statoPratica); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.provincia"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.tipopratica"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.progetto"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.istruttore"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.start"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.tempoattivita"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza"))); + + sb.append(StringPool.NEW_LINE); + + for (Object[] tempistica : tempistiche) { + + Long intPraticaId = (Long) tempistica[0]; + // Long start = (Long) tempistica[1]; + Long calcoloTempo = (Long) tempistica[2]; + Integer stato = (Integer) tempistica[3]; + Long dettPraticaId = (Long) tempistica[4]; + + // DettPratica dettPratica = + // DettPraticaLocalServiceUtil.getDettPratica(dettPraticaId); + IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); + Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica + .getTerritorioId()); + Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), + territorio.getCodiceProvincia()); + + sb.append(CSVUtil.encode(provincia.getProvincia())); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(intPratica.getTipoPratica())); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(intPratica.getNumeroProgetto())); + sb.append(StringPool.SEMICOLON); + + long statusByUserId = intPratica.getStatusByUserId(); + if (Validator.isNotNull(statusByUserId) + && intPratica.getStatus() != WorkflowConstants.STATUS_DRAFT) { + try { + User istruttoreUser = UserLocalServiceUtil.getUser(statusByUserId); + sb.append(CSVUtil.encode(istruttoreUser.getFullName() + StringPool.SPACE + + StringPool.OPEN_PARENTHESIS + istruttoreUser.getScreenName() + + StringPool.CLOSE_PARENTHESIS)); + } catch (PortalException e) { + } + } + sb.append(StringPool.SEMICOLON); + + List avvisi = AvvisoLocalServiceUtil.findByClassPk_tipoDocumento(dettPraticaId, + StatoPraticaConstants.SOTTOPOSTA_A_PARERE); + if (avvisi.size() > 0 && avvisi.get(0).getDtAvviso() != null) { + sb.append(CSVUtil.encode(dateFormat.format(avvisi.get(0).getDtInvio()))); + } else { + sb.append("-"); + + } + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(String.valueOf(TimeUnit.MILLISECONDS.toDays(calcoloTempo)))); + sb.append(StringPool.SEMICOLON); + + if (stato.intValue() == TempisticaConstants.STATO_SCADUTA) { + sb.append(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza.scaduto")); + } else if (stato.intValue() == TempisticaConstants.STATO_ATTIVA) { + sb.append(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.scadenza.attivo")); + } + + sb.append(StringPool.NEW_LINE); + } + } + + return sb.toString(); + } } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java index 46cf8afc..04c7f37a 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java @@ -70,6 +70,7 @@ import it.tref.liferay.portos.report.shared.util.ReportUtil; import java.io.IOException; import java.io.Serializable; import java.sql.Connection; +import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Calendar; @@ -119,7 +120,6 @@ import com.liferay.portal.kernel.workflow.WorkflowHandlerRegistryUtil; import com.liferay.portal.kernel.workflow.WorkflowInstance; import com.liferay.portal.kernel.workflow.WorkflowTask; import com.liferay.portal.model.Company; -import com.liferay.portal.model.Organization; import com.liferay.portal.model.Role; import com.liferay.portal.model.User; import com.liferay.portal.model.WorkflowInstanceLink; @@ -351,7 +351,45 @@ public class IntPraticaLocalServiceImpl extends IntPraticaLocalServiceBaseImpl { } public List svuotaDatabase(ServiceContext serviceContext) { - List esito = new ArrayList(); + List esito = new ArrayList<>(); + int rows = 0; + try { + Connection connection = DataAccess.getUpgradeOptimizedConnection(); + Statement s = connection.createStatement(); + + long userClassNameId = ClassNameLocalServiceUtil.getClassName(User.class.getName()) + .getClassNameId(); + esito.add("User: " + userClassNameId); + rows = s.executeUpdate("DELETE FROM group_ WHERE groupid IN (SELECT groupid FROM group_ " + + "LEFT JOIN user_ ON group_.classpk=user_.userid WHERE classnameid=" + userClassNameId + + " AND user_.userid IS NULL)"); + esitoLog(esito, "Cancellate " + rows + " righe da group_"); + rows = s.executeUpdate("DELETE FROM contact_ WHERE contactid IN (" + + "SELECT c.contactid FROM contact_ c LEFT JOIN user_ u " + + "ON c.contactid=u.contactid WHERE u.userid IS NULL)"); + esitoLog(esito, "Cancellate " + rows + " righe da contact_"); + rows = s.executeUpdate("DELETE FROM usergroup WHERE usergroupid IN (" + + "SELECT usergroupid FROM usergroup g LEFT JOIN user_ u ON g.userid=u.userid " + + "WHERE u.userid IS NULL)"); + esitoLog(esito, "Cancellate " + rows + " righe da usergroup"); + rows = s.executeUpdate("DELETE FROM usergrouprole WHERE userid IN (" + + "SELECT DISTINCT x.userid FROM usergrouprole x " + + "LEFT JOIN user_ u ON x.userid=u.userid " + "WHERE u.userid IS NULL) OR groupid IN (" + + "SELECT DISTINCT x.groupid FROM usergrouprole x " + + "LEFT JOIN group_ g ON x.groupid=g.groupid " + + "WHERE g.groupid IS NULL) OR roleid IN (" + + "SELECT DISTINCT x.roleid FROM usergrouprole x " + + "LEFT JOIN role_ r ON x.roleid=r.roleid " + "WHERE r.roleid IS NULL)"); + esitoLog(esito, "Cancellate " + rows + " righe da usergrouprole"); + + } catch (SQLException | SystemException e) { + esitoLog(esito, "Interrotto per errore: " + e.getMessage()); + } + return esito; + } + + public List svuotaDatabase2(ServiceContext serviceContext) { + List esito = new ArrayList<>(); try { Connection connection = DataAccess.getUpgradeOptimizedConnection(); Statement statement = connection.createStatement(); @@ -608,8 +646,8 @@ public class IntPraticaLocalServiceImpl extends IntPraticaLocalServiceBaseImpl { + DLSyncConstants.TYPE_FILE + "' AND dlfileentry.fileentryid IS NULL)"); statement.execute("DELETE FROM syncdlobject WHERE syncdlobjectid IN (" + "SELECT syncdlobjectid FROM syncdlobject LEFT JOIN dlfolder " - + "ON syncdlobject.typepk=dlfolder.folderid WHERE type_='" - + DLSyncConstants.TYPE_FOLDER + "' AND dlfolder.folderid IS NULL)"); + + "ON syncdlobject.typepk=dlfolder.folderid WHERE type_='" + DLSyncConstants.TYPE_FOLDER + + "' AND dlfolder.folderid IS NULL)"); // Reset di tutte le cache SingleVMPoolUtil.clear(); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/startup/RoleUpdateAction.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/startup/RoleUpdateAction.java index 69efd208..8f197296 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/startup/RoleUpdateAction.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/startup/RoleUpdateAction.java @@ -21,40 +21,41 @@ import com.liferay.portal.service.UserLocalServiceUtil; public class RoleUpdateAction extends SimpleAction { - private static final Log _log = LogFactoryUtil.getLog(RoleUpdateAction.class); - - public RoleUpdateAction() { - - super(); - } - - public void run(String[] ids) throws ActionException { - - for (String companyId : ids) { - // TODO aggiunta di tutti i ruoli - try { - Role role = RoleLocalServiceUtil.fetchRole(Long.valueOf(companyId), Constants.ROLE_NAME_GEOLOGO); - if (Validator.isNull(role)) { - long userId = UserLocalServiceUtil.getDefaultUserId(Long.valueOf(companyId)); - String className = Role.class.getName(); - long classPK = 0l; - String name = Constants.ROLE_NAME_GEOLOGO; - Map titleMap = new LinkedHashMap(); - titleMap.put(Locale.ITALY, Constants.ROLE_NAME_GEOLOGO); - Map descriptionMap = new LinkedHashMap(); - descriptionMap.put(Locale.ITALY, "E' un geologo"); - int type = RoleConstants.TYPE_REGULAR; - String subtype = null; - ServiceContext serviceContext = null; - RoleLocalServiceUtil.addRole(userId, className, classPK, name, titleMap, descriptionMap, type, subtype, - serviceContext); - _log.info("Aggiunto ruolo " + name); - } - - } catch (PortalException | SystemException e) { - _log.error("Errore durante l'aggiunta di un ruolo", e); - } - } - } + private static final Log _log = LogFactoryUtil.getLog(RoleUpdateAction.class); + + public RoleUpdateAction() { + + super(); + } + + public void run(String[] ids) throws ActionException { + + for (String companyId : ids) { + // TODO aggiunta di tutti i ruoli + try { + Role role = RoleLocalServiceUtil.fetchRole(Long.valueOf(companyId), + Constants.ROLE_NAME_GEOLOGO); + if (Validator.isNull(role)) { + long userId = UserLocalServiceUtil.getDefaultUserId(Long.valueOf(companyId)); + String className = Role.class.getName(); + long classPK = 0l; + String name = Constants.ROLE_NAME_GEOLOGO; + Map titleMap = new LinkedHashMap(); + titleMap.put(Locale.ITALY, Constants.ROLE_NAME_GEOLOGO); + Map descriptionMap = new LinkedHashMap(); + descriptionMap.put(Locale.ITALY, "E' un geologo"); + int type = RoleConstants.TYPE_REGULAR; + String subtype = null; + ServiceContext serviceContext = null; + RoleLocalServiceUtil.addRole(userId, className, classPK, name, titleMap, descriptionMap, + type, subtype, serviceContext); + _log.info("Aggiunto ruolo " + name); + } + + } catch (PortalException | SystemException e) { + _log.error("Errore durante l'aggiunta di un ruolo", e); + } + } + } } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/Constants.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/Constants.java index 1a2722ca..234c9d49 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/Constants.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/Constants.java @@ -1,20 +1,18 @@ package it.tref.liferay.portos.bo.util; public class Constants extends it.tref.liferay.portos.bo.shared.util.Constants { - public static final String NUMERO_PROGETTO_KEY_DB = "numero.progetto.key.db"; - public static final String[] AMMINISTRAZIONE_CSV_HEADERS_COMUNI = {"Codice Regione", "Codice Città Metropolitana", - "Codice Provincia (1)", "Progressivo del Comune (2)", "Codice Comune formato alfanumerico", - "Denominazione in italiano", "Denominazione in tedesco", "Codice Ripartizione Geografica", - "Ripartizione geografica", "Denominazione regione", "Denominazione Città metropolitana", - "Denominazione provincia", "Flag Comune capoluogo di provincia", "Sigla automobilistica", - "Codice Comune formato numerico", "Codice Comune numerico con 110 province (dal 2010 al 2016)", - "Codice Comune numerico con 107 province (dal 2006 al 2009)", - "Codice Comune numerico con 103 province (dal 1995 al 2005)", "Codice Catastale del comune", - "Popolazione legale 2011 (09/10/2011)", "Codice NUTS1 2010", "Codice NUTS2 2010 (3) ", "Codice NUTS3 2010", - "Codice NUTS1 2006", "Codice NUTS2 2006 (3)", "Codice NUTS3 2006"}; - public static final String[] AMMINISTRAZIONE_CSV_HEADERS_PROVINCE = {"codice_provincia", "provincia", "regione", - "sigla" }; - - public static final String PORTOS_BO_SITE_NAME = "Portos BackOffice"; - + public static final String NUMERO_PROGETTO_KEY_DB = "numero.progetto.key.db"; + public static final String[] AMMINISTRAZIONE_CSV_HEADERS_COMUNI = { "Codice Regione", + "Codice Città Metropolitana", "Codice Provincia (1)", "Progressivo del Comune (2)", + "Codice Comune formato alfanumerico", "Denominazione in italiano", "Denominazione in tedesco", + "Codice Ripartizione Geografica", "Ripartizione geografica", "Denominazione regione", + "Denominazione Città metropolitana", "Denominazione provincia", + "Flag Comune capoluogo di provincia", "Sigla automobilistica", "Codice Comune formato numerico", + "Codice Comune numerico con 110 province (dal 2010 al 2016)", + "Codice Comune numerico con 107 province (dal 2006 al 2009)", + "Codice Comune numerico con 103 province (dal 1995 al 2005)", "Codice Catastale del comune", + "Popolazione legale 2011 (09/10/2011)", "Codice NUTS1 2010", "Codice NUTS2 2010 (3) ", + "Codice NUTS3 2010", "Codice NUTS1 2006", "Codice NUTS2 2006 (3)", "Codice NUTS3 2006" }; + public static final String[] AMMINISTRAZIONE_CSV_HEADERS_PROVINCE = { "codice_provincia", "provincia", + "regione", "sigla" }; } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/ContentType.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/ContentType.java index 04e07db2..5fb9e2a4 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/ContentType.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/ContentType.java @@ -2,30 +2,29 @@ package it.tref.liferay.portos.bo.util; public enum ContentType { - PDF("application/pdf"), P7M("application/pkcs7-signature"), P7M_MIME("application/pkcs7-mime"), XDBF( - "application/x-dbf"); + PDF("application/pdf"), P7M("application/pkcs7-signature"), P7M_MIME("application/pkcs7-mime"), XDBF( + "application/x-dbf"); - private String contentType; + private String contentType; - ContentType(String contentType) { - this.contentType = contentType; - } + ContentType(String contentType) { + this.contentType = contentType; + } - public String getContentType() { - return contentType; - } + public String getContentType() { + return contentType; + } - public static ContentType parse(String contentType) { + public static ContentType parse(String contentType) { - for (ContentType value : values()) { - if (value.contentType.equalsIgnoreCase(contentType)) { - return value; - } - } + for (ContentType value : values()) { + if (value.contentType.equalsIgnoreCase(contentType)) { + return value; + } + } - throw new IllegalArgumentException("Invalid value for ContentType: " + contentType); - - } + throw new IllegalArgumentException("Invalid value for ContentType: " + contentType); + } } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/cronologia/view.jsp b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/cronologia/view.jsp index 05e0cb11..c064d7bd 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/cronologia/view.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/cronologia/view.jsp @@ -208,23 +208,6 @@ List historyWorkflowActions = HistoryWorkflowActionLocalServiceUtil.findByIntPratica(intPraticaId, sort); %> - - <% - InfoFascicolo infoFascicolo = InfoFascicoloLocalServiceUtil.fetchByIntPratica(intPratica.getIntPraticaId()); - %> - -
-
- - - - - -
-
-
-
-
diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/header.jsp b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/header.jsp index b5ba1663..dd6414a9 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/header.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/header.jsp @@ -99,14 +99,4 @@
- -
-
- - - - -
-
-
\ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_allegati.jsp b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_allegati.jsp index c7bf1861..65b249fb 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_allegati.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/fascicolo/navigator/page_allegati.jsp @@ -67,9 +67,6 @@
<% List tipologiaAllegati = DocumentiPraticaUtil.getDocDomanda(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocDomandaPortos1()); - } for(String codiceDoc:tipologiaAllegati){ List docPraticas = DocPraticaLocalServiceUtil.findByIntPratica_Tipologia(dettPratica.getIntPraticaId(), codiceDoc, QueryUtil.ALL_POS, QueryUtil.ALL_POS); %> diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/AllegatiPraticaPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/AllegatiPraticaPortlet.java index 2acf9624..89650312 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/AllegatiPraticaPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/AllegatiPraticaPortlet.java @@ -280,9 +280,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet { List tipologieAllegati = DocumentiPraticaUtil.getDocDomanda(); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - tipologieAllegati.addAll(0, DocumentiPraticaUtil.getDocDomandaPortos1()); - } docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPkEqual_Tipologie(intPraticaId, classPk, tipologieAllegati); @@ -293,9 +290,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet { } else if ("page_allegati".equals(comingFrom) || "ad".equals(type)) { tipologieAllegati = DocumentiPraticaUtil.getDocDomanda(); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - tipologieAllegati.addAll(0, DocumentiPraticaUtil.getDocDomandaPortos1()); - } } else if ("page_fine_lavori".equals(comingFrom)) { tipologieAllegati = DocumentiPraticaUtil.getDocFineLavori(); } else if ("page_collaudo".equals(comingFrom)) { diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/util/ReportFascicoloUtil.java b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/util/ReportFascicoloUtil.java index dd161bb2..688da1e5 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/util/ReportFascicoloUtil.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/util/ReportFascicoloUtil.java @@ -435,9 +435,6 @@ public class ReportFascicoloUtil { //ALLEGATI DOMANDA List tipologiaAllegatiDomanda = DocumentiPraticaUtil.getDocDomanda(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegatiDomanda.addAll(DocumentiPraticaUtil.getDocDomandaPortos1()); - } List listaAllegatiDomanda = new ArrayList(); @@ -833,9 +830,6 @@ public class ReportFascicoloUtil { //ALLEGATI DOMANDA List tipologiaAllegatiDomanda = DocumentiPraticaUtil.getDocDomanda(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegatiDomanda.addAll(DocumentiPraticaUtil.getDocDomandaPortos1()); - } List listaAllegatiDomanda = new ArrayList(); @@ -1038,9 +1032,6 @@ public class ReportFascicoloUtil { //ALLEGATI DOMANDA List tipologiaAllegatiDomanda = DocumentiPraticaUtil.getDocFineLavori(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegatiDomanda.addAll(DocumentiPraticaUtil.getDocFineLavoriPortos1()); - } parameters.put("FIRMA_DIRETTORE", MessageFormat.format(LanguageUtil.get(Locale.ITALIAN, "fl-firma-direttore"), direttoreLavori.getNome(), direttoreLavori.getCognome(), direttoreLavori.getCodiceFiscale())); @@ -1266,9 +1257,6 @@ public class ReportFascicoloUtil { //ALLEGATI DOMANDA List tipologiaAllegatiDomanda = DocumentiPraticaUtil.getDocCollaudo(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegatiDomanda.addAll(DocumentiPraticaUtil.getDocCollaudoPortos1()); - } List listaAllegatiDomanda = new ArrayList(); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view.jsp b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view.jsp index 469d2117..32167b08 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view.jsp @@ -163,19 +163,10 @@ tipologiaAllegati = DocumentiPraticaUtil.getDocGeologo(); }else if("page_allegati".equals(comingFrom)){ tipologiaAllegati = DocumentiPraticaUtil.getDocDomanda(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocDomandaPortos1()); - } }else if("page_fine_lavori".equals(comingFrom)){ tipologiaAllegati = DocumentiPraticaUtil.getDocFineLavori(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocFineLavoriPortos1()); - } }else if("page_collaudo".equals(comingFrom)){ tipologiaAllegati = DocumentiPraticaUtil.getDocCollaudo(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocCollaudoPortos1()); - } } %> diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view_accordion.jsp b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view_accordion.jsp index 02475cf8..378dc1a5 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view_accordion.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/allegatipratica/view_accordion.jsp @@ -77,15 +77,9 @@ type="ag"; }else if("allegati_fine_lavori".equals(tipoAllegati)){ tipologiaAllegati = DocumentiPraticaUtil.getDocFineLavori(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocFineLavoriPortos1()); - } type="afl"; }else if("allegati_collaudo".equals(tipoAllegati)){ tipologiaAllegati = DocumentiPraticaUtil.getDocCollaudo(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocCollaudoPortos1()); - } type="acl"; } else{ @@ -93,9 +87,6 @@ //BUG BO ID=9 (ANNULLA ISTANZA) tipologiaAllegati.add(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_ANNULLAMENTO_FASCICOLO); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocDomandaPortos1()); - } type="ad"; } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fascicolo.jsp b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fascicolo.jsp index bfde1107..3b3a5ae8 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fascicolo.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fascicolo.jsp @@ -171,9 +171,6 @@ List sections = Arrays.asList(SezioniUtil.SEZIONE_DETTAGLI_PRINCIPALI, SezioniUtil.SEZIONE_ANAGRAFE_SOGGETTI, SezioniUtil.SEZIONE_DESCRIZIONE_EDIFICIO, SezioniUtil.SEZIONE_GEOLOGICA, SezioniUtil.SEZIONE_ALLEGATI); List tipologiaAllegati = DocumentiPraticaUtil.getDocObbligatori(); - if(Validator.isNotNull(intPratica.getOldIntPraticaId())){ - tipologiaAllegati.addAll(DocumentiPraticaUtil.getDocDomandaPortos1()); - } List tipologiaSoggetti = Arrays.asList(TipoSoggettoUtil.COMMITTENTE, TipoSoggettoUtil.DITTA, TipoSoggettoUtil.PROGETTISTA, TipoSoggettoUtil.DIRETTORE_LAVORI, TipoSoggettoUtil.GEOLOGO, TipoSoggettoUtil.COLLAUDATORE); %> diff --git a/liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/DocumentiPraticaUtil.java b/liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/DocumentiPraticaUtil.java index 30102f63..26a7dcbd 100644 --- a/liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/DocumentiPraticaUtil.java +++ b/liferay-plugins-sdk-6.2/shared/portos-bo-shared/src/it/tref/liferay/portos/bo/shared/util/DocumentiPraticaUtil.java @@ -1,30 +1,20 @@ package it.tref.liferay.portos.bo.shared.util; -import com.liferay.portal.kernel.language.LanguageUtil; - import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import javax.servlet.jsp.PageContext; - public class DocumentiPraticaUtil { - - //public final static String TIPOLOGIA_ALLEGATO_A00 = "A00"; public final static String TIPOLOGIA_ALLEGATO_A01 = "A01"; public final static String TIPOLOGIA_ALLEGATO_A02 = "A02"; public final static String TIPOLOGIA_ALLEGATO_A03 = "A03"; public final static String TIPOLOGIA_ALLEGATO_A04 = "A04"; - //public final static String TIPOLOGIA_ALLEGATO_A05 = "A05"; - public final static String TIPOLOGIA_ALLEGATO_A06 = "A06"; - public final static String TIPOLOGIA_ALLEGATO_A07 = "A07"; + public final static String TIPOLOGIA_ALLEGATO_A05 = "A05"; public final static String TIPOLOGIA_ALLEGATO_A08 = "A08"; public final static String TIPOLOGIA_ALLEGATO_A09 = "A09"; public final static String TIPOLOGIA_ALLEGATO_A10 = "A10"; public final static String TIPOLOGIA_ALLEGATO_A11 = "A11"; public final static String TIPOLOGIA_ALLEGATO_A12 = "A12"; public final static String TIPOLOGIA_ALLEGATO_A13 = "A13"; - public final static String TIPOLOGIA_ALLEGATO_A14 = "A14"; public final static String TIPOLOGIA_ALLEGATO_A15 = "A15"; public final static String TIPOLOGIA_ALLEGATO_A16 = "A16"; public final static String TIPOLOGIA_ALLEGATO_A17 = "A17"; @@ -32,23 +22,16 @@ public class DocumentiPraticaUtil { public final static String TIPOLOGIA_ALLEGATO_A19 = "A19"; public final static String TIPOLOGIA_ALLEGATO_A20 = "A20"; public final static String TIPOLOGIA_ALLEGATO_A21 = "A21"; + public final static String TIPOLOGIA_ALLEGATO_A22 = "A22"; + public final static String TIPOLOGIA_ALLEGATO_A23 = "A23"; + public final static String TIPOLOGIA_ALLEGATO_A24 = "A24"; + public final static String TIPOLOGIA_ALLEGATO_A25 = "A25"; + public final static String TIPOLOGIA_ALLEGATO_A26 = "A26"; + public final static String TIPOLOGIA_ALLEGATO_A27 = "A27"; + public final static String TIPOLOGIA_ALLEGATO_ALTRI = "A99"; public final static String TIPOLOGIA_ALLEGATO_DELEGA = "A98"; - public final static String TIPOLOGIA_ALLEGATO_A00_PORTOS_1 = "A0P"; - public final static String TIPOLOGIA_ALLEGATO_DOMANDA = "111"; - public final static String TIPOLOGIA_ALLEGATO_INTEGRAZIONE_PORTOS_1 = "111I"; - public final static String TIPOLOGIA_ALLEGATO_ANNULLAMENTO_PORTOS_1 = "111A"; - public final static String TIPOLOGIA_ALLEGATO_VARIAZIONE_SOGGETTO_PORTOS_1 = "111VS"; - public final static String TIPOLOGIA_ALLEGATO_FINE_LAVORI = "111F"; - public final static String TIPOLOGIA_ALLEGATO_FINE_LAVORI_PARZIALE = "111FP"; - public final static String TIPOLOGIA_ALLEGATO_COLLAUDO = "111C"; - public final static String TIPOLOGIA_ALLEGATO_COLLAUDO_PARZIALE = "111CP"; - // public final static String TIPOLOGIA_ALLEGATO_DOMANDA_NON_FIRMATA = - // "DNF"; - public final static String TIPOLOGIA_ALLEGATO_CERTIFICATO_CALCESTRUZZO_PORTOS_1 = "CCA"; - public final static String TIPOLOGIA_ALLEGATO_CERTIFICATO_ACCIAIO_PORTOS_1 = "CAC"; - public final static String TIPOLOGIA_ALLEGATO_GIORNALE_LAVORI = "AGL"; public final static String TIPOLOGIA_ALLEGATO_CERTIFICATO_CALCESTRUZZO = "ACC"; public final static String TIPOLOGIA_ALLEGATO_CERTIFICATO_ACCIAIO = "ACA"; @@ -82,55 +65,25 @@ public class DocumentiPraticaUtil { public final static String TIPOLOGIA_ALLEGATO_VARIAZIONE_SOGGETTO = "VS"; public final static String TIPOLOGIA_ALLEGATO_ANNULLAMENTO_FASCICOLO = "AI"; - public static String getDescriptionFromCode(String code, PageContext pageContext) { - - return LanguageUtil.get(pageContext, "label.geniocivilefe.domanda.allegati." + code.toLowerCase()); - } - - public static List getDocConUnicaCopiaPresente() { - List docUnici = new ArrayList(); - //docUnici.add(TIPOLOGIA_ALLEGATO_A00); - docUnici.add(TIPOLOGIA_ALLEGATO_A01); - docUnici.add(TIPOLOGIA_ALLEGATO_A11); - docUnici.add(TIPOLOGIA_ALLEGATO_A12); - docUnici.add(TIPOLOGIA_ALLEGATO_A14); - // docUnici.add(TIPOLOGIA_ALLEGATO_A15_SANATORIA); - // docUnici.add(TIPOLOGIA_ALLEGATO_A16_SANATORIA); - return docUnici; - } - public static List getDocObbligatori() { List docObbligatori = new ArrayList(); - //docObbligatori.add(TIPOLOGIA_ALLEGATO_A00); - // docObbligatori.add(TIPOLOGIA_ALLEGATO_A01); docObbligatori.add(TIPOLOGIA_ALLEGATO_A02); docObbligatori.add(TIPOLOGIA_ALLEGATO_A03); docObbligatori.add(TIPOLOGIA_ALLEGATO_A04); - //docObbligatori.add(TIPOLOGIA_ALLEGATO_A05); - docObbligatori.add(TIPOLOGIA_ALLEGATO_A06); - docObbligatori.add(TIPOLOGIA_ALLEGATO_A07); docObbligatori.add(TIPOLOGIA_ALLEGATO_A08); docObbligatori.add(TIPOLOGIA_ALLEGATO_A09); docObbligatori.add(TIPOLOGIA_ALLEGATO_A10); - // docObbligatori.add(TIPOLOGIA_ALLEGATO_A11); - // docObbligatori.add(TIPOLOGIA_ALLEGATO_A12); docObbligatori.add(TIPOLOGIA_ALLEGATO_A13); - docObbligatori.add(TIPOLOGIA_ALLEGATO_A14); docObbligatori.add(TIPOLOGIA_ALLEGATO_A15); docObbligatori.add(TIPOLOGIA_ALLEGATO_A17); - // docObbligatori.add(TIPOLOGIA_ALLEGATO_ALTRI); docObbligatori.add(TIPOLOGIA_ALLEGATO_DELEGA); return docObbligatori; - } public static List getDocObbligatoriCheck() { List docObbligatoriCheck = new ArrayList(); //docObbligatoriCheck.add(TIPOLOGIA_ALLEGATO_A05); - docObbligatoriCheck.add(TIPOLOGIA_ALLEGATO_A06); - docObbligatoriCheck.add(TIPOLOGIA_ALLEGATO_A07); docObbligatoriCheck.add(TIPOLOGIA_ALLEGATO_A09); - docObbligatoriCheck.add(TIPOLOGIA_ALLEGATO_A14); return docObbligatoriCheck; @@ -143,15 +96,13 @@ public class DocumentiPraticaUtil { doc.add(TIPOLOGIA_ALLEGATO_A02); doc.add(TIPOLOGIA_ALLEGATO_A03); doc.add(TIPOLOGIA_ALLEGATO_A04); - doc.add(TIPOLOGIA_ALLEGATO_A06); - doc.add(TIPOLOGIA_ALLEGATO_A07); + doc.add(TIPOLOGIA_ALLEGATO_A05); doc.add(TIPOLOGIA_ALLEGATO_A08); doc.add(TIPOLOGIA_ALLEGATO_A09); doc.add(TIPOLOGIA_ALLEGATO_A10); doc.add(TIPOLOGIA_ALLEGATO_A11); doc.add(TIPOLOGIA_ALLEGATO_A12); doc.add(TIPOLOGIA_ALLEGATO_A13); - doc.add(TIPOLOGIA_ALLEGATO_A14); doc.add(TIPOLOGIA_ALLEGATO_A15); doc.add(TIPOLOGIA_ALLEGATO_A16); doc.add(TIPOLOGIA_ALLEGATO_A17); @@ -159,6 +110,12 @@ public class DocumentiPraticaUtil { doc.add(TIPOLOGIA_ALLEGATO_A19); doc.add(TIPOLOGIA_ALLEGATO_A20); doc.add(TIPOLOGIA_ALLEGATO_A21); + doc.add(TIPOLOGIA_ALLEGATO_A22); + doc.add(TIPOLOGIA_ALLEGATO_A23); + doc.add(TIPOLOGIA_ALLEGATO_A24); + doc.add(TIPOLOGIA_ALLEGATO_A25); + doc.add(TIPOLOGIA_ALLEGATO_A26); + doc.add(TIPOLOGIA_ALLEGATO_A27); doc.add(TIPOLOGIA_ALLEGATO_ALTRI); doc.add(TIPOLOGIA_ALLEGATO_DELEGA); @@ -182,7 +139,6 @@ public class DocumentiPraticaUtil { } if (tipoProcedura.equalsIgnoreCase(Constants.PROCEDURA_P3)) { - docObbligatori.add(TIPOLOGIA_ALLEGATO_A07); } if (tipoProcedura.equalsIgnoreCase(Constants.PROCEDURA_P4) || @@ -192,13 +148,10 @@ public class DocumentiPraticaUtil { docObbligatori.add(TIPOLOGIA_ALLEGATO_A01); docObbligatori.add(TIPOLOGIA_ALLEGATO_A02); docObbligatori.add(TIPOLOGIA_ALLEGATO_A03); - docObbligatori.add(TIPOLOGIA_ALLEGATO_A06); - docObbligatori.add(TIPOLOGIA_ALLEGATO_A07); docObbligatori.add(TIPOLOGIA_ALLEGATO_A09); docObbligatori.add(TIPOLOGIA_ALLEGATO_A10); docObbligatori.add(TIPOLOGIA_ALLEGATO_A11); docObbligatori.add(TIPOLOGIA_ALLEGATO_A12); - docObbligatori.add(TIPOLOGIA_ALLEGATO_A14); } if (tipoProcedura.equalsIgnoreCase(Constants.PROCEDURA_P8)) { @@ -207,7 +160,6 @@ public class DocumentiPraticaUtil { docObbligatori.add(TIPOLOGIA_ALLEGATO_A03); docObbligatori.add(TIPOLOGIA_ALLEGATO_A09); docObbligatori.add(TIPOLOGIA_ALLEGATO_A12); - docObbligatori.add(TIPOLOGIA_ALLEGATO_A14); docObbligatori.add(TIPOLOGIA_ALLEGATO_A15); } @@ -217,7 +169,6 @@ public class DocumentiPraticaUtil { docObbligatori.add(TIPOLOGIA_ALLEGATO_A03); docObbligatori.add(TIPOLOGIA_ALLEGATO_A09); docObbligatori.add(TIPOLOGIA_ALLEGATO_A12); - docObbligatori.add(TIPOLOGIA_ALLEGATO_A14); docObbligatori.add(TIPOLOGIA_ALLEGATO_A16); docObbligatori.add(TIPOLOGIA_ALLEGATO_A17); docObbligatori.add(TIPOLOGIA_ALLEGATO_A18); @@ -236,9 +187,9 @@ public class DocumentiPraticaUtil { public static List getDocGeologo() { List doc = new ArrayList(); - doc.add(TIPOLOGIA_ALLEGATO_A06); - doc.add(TIPOLOGIA_ALLEGATO_A14); - doc.add(TIPOLOGIA_ALLEGATO_A15); + doc.add(TIPOLOGIA_ALLEGATO_A05); + doc.add(TIPOLOGIA_ALLEGATO_A22); + doc.add(TIPOLOGIA_ALLEGATO_A23); doc.add(TIPOLOGIA_ALLEGATO_GEOLOGO_CAROTAGGIO); doc.add(TIPOLOGIA_ALLEGATO_GEOLOGO_LABORATORIO); @@ -294,7 +245,6 @@ public class DocumentiPraticaUtil { doc.add(TIPOLOGIA_ALLEGATO_A11); doc.add(TIPOLOGIA_ALLEGATO_A12); doc.add(TIPOLOGIA_ALLEGATO_A13); - doc.add(TIPOLOGIA_ALLEGATO_A14); doc.add(TIPOLOGIA_ALLEGATO_GEOLOGO_CAROTAGGIO); doc.add(TIPOLOGIA_ALLEGATO_GEOLOGO_LABORATORIO); @@ -313,7 +263,6 @@ public class DocumentiPraticaUtil { doc.add(TIPOLOGIA_ALLEGATO_GEOLOGO_ALTRO); doc.add(TIPOLOGIA_ALLEGATO_GEOLOGO_VARIE); return doc; - } public static List getDocFineLavori() { @@ -358,67 +307,4 @@ public class DocumentiPraticaUtil { return doc; } - - public static List getDocDomandaPortos1() { - List doc = new ArrayList(); - doc.add(TIPOLOGIA_ALLEGATO_A00_PORTOS_1); - doc.add(TIPOLOGIA_ALLEGATO_DOMANDA); - doc.add(TIPOLOGIA_ALLEGATO_VARIAZIONE_SOGGETTO_PORTOS_1); - doc.add(TIPOLOGIA_ALLEGATO_ANNULLAMENTO_PORTOS_1); - - return doc; - } - - public static List getDocObbligatoriDomandaPortos1() { - List doc = new ArrayList(); - doc.add(TIPOLOGIA_ALLEGATO_A00_PORTOS_1); - doc.add(TIPOLOGIA_ALLEGATO_DOMANDA); - - return doc; - } - - public static List getDocIntegrazionePortos1() { - List doc = new ArrayList(); - doc.add(TIPOLOGIA_ALLEGATO_INTEGRAZIONE_PORTOS_1); - - return doc; - } - - public static List getDocFineLavoriPortos1() { - List doc = new ArrayList(); - doc.add(TIPOLOGIA_ALLEGATO_FINE_LAVORI); - doc.add(TIPOLOGIA_ALLEGATO_FINE_LAVORI_PARZIALE); - doc.add(TIPOLOGIA_ALLEGATO_CERTIFICATO_CALCESTRUZZO_PORTOS_1); - doc.add(TIPOLOGIA_ALLEGATO_CERTIFICATO_ACCIAIO_PORTOS_1); - - return doc; - } - - public static List getDocCollaudoPortos1() { - List doc = new ArrayList(); - doc.add(TIPOLOGIA_ALLEGATO_COLLAUDO); - doc.add(TIPOLOGIA_ALLEGATO_COLLAUDO_PARZIALE); - - return doc; - } - - public static HashMap getDocControllo() { - HashMap docControl = new HashMap(); - //docControl.put(TIPOLOGIA_ALLEGATO_A00, false); - docControl.put(TIPOLOGIA_ALLEGATO_A01, false); - docControl.put(TIPOLOGIA_ALLEGATO_A02, false); - docControl.put(TIPOLOGIA_ALLEGATO_A03, false); - docControl.put(TIPOLOGIA_ALLEGATO_A04, false); - //docControl.put(TIPOLOGIA_ALLEGATO_A05, false); - docControl.put(TIPOLOGIA_ALLEGATO_A06, false); - docControl.put(TIPOLOGIA_ALLEGATO_A07, false); - docControl.put(TIPOLOGIA_ALLEGATO_A08, false); - docControl.put(TIPOLOGIA_ALLEGATO_A09, false); - docControl.put(TIPOLOGIA_ALLEGATO_A10, false); - docControl.put(TIPOLOGIA_ALLEGATO_A13, false); - docControl.put(TIPOLOGIA_ALLEGATO_A14, false); - return docControl; - - } - }