AccordiCooperazioneHelper.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.web.ctrlstat.servlet.ac;

  21. import java.util.ArrayList;
  22. import java.util.Iterator;
  23. import java.util.List;

  24. import javax.servlet.http.HttpServletRequest;
  25. import javax.servlet.http.HttpSession;

  26. import org.apache.commons.lang.StringUtils;
  27. import org.openspcoop2.core.commons.Filtri;
  28. import org.openspcoop2.core.commons.ISearch;
  29. import org.openspcoop2.core.commons.Liste;
  30. import org.openspcoop2.core.commons.SearchUtils;
  31. import org.openspcoop2.core.id.IDAccordoCooperazione;
  32. import org.openspcoop2.core.id.IDSoggetto;
  33. import org.openspcoop2.core.registry.AccordoCooperazione;
  34. import org.openspcoop2.core.registry.AccordoCooperazionePartecipanti;
  35. import org.openspcoop2.core.registry.Documento;
  36. import org.openspcoop2.core.registry.IdSoggetto;
  37. import org.openspcoop2.core.registry.Soggetto;
  38. import org.openspcoop2.core.registry.constants.StatiAccordo;
  39. import org.openspcoop2.protocol.sdk.constants.ArchiveType;
  40. import org.openspcoop2.protocol.sdk.validator.ValidazioneResult;
  41. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  42. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  43. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  44. import org.openspcoop2.web.ctrlstat.servlet.ConsoleHelper;
  45. import org.openspcoop2.web.ctrlstat.servlet.archivi.ArchiviCostanti;
  46. import org.openspcoop2.web.ctrlstat.servlet.archivi.ExporterUtils;
  47. import org.openspcoop2.web.lib.mvc.AreaBottoni;
  48. import org.openspcoop2.web.lib.mvc.Costanti;
  49. import org.openspcoop2.web.lib.mvc.DataElement;
  50. import org.openspcoop2.web.lib.mvc.DataElementType;
  51. import org.openspcoop2.web.lib.mvc.PageData;
  52. import org.openspcoop2.web.lib.mvc.Parameter;
  53. import org.openspcoop2.web.lib.mvc.ServletUtils;
  54. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  55. /**
  56.  * AccordiCooperazioneHelper
  57.  *
  58.  * @author Poli Andrea (apoli@link.it)
  59.  * @author $Author$
  60.  * @version $Rev$, $Date$
  61.  */
  62. public class AccordiCooperazioneHelper  extends ConsoleHelper {

  63.     public AccordiCooperazioneHelper(HttpServletRequest request, PageData pd,
  64.             HttpSession session) throws Exception {
  65.         super(request, pd,  session);
  66.     }
  67.     public AccordiCooperazioneHelper(ControlStationCore core, HttpServletRequest request, PageData pd,
  68.             HttpSession session) throws Exception {
  69.         super(core, request, pd,  session);
  70.     }
  71.    
  72.     // Controlla i dati degli Accordi cooperazione
  73.     public boolean accordiCooperazioneCheckData(TipoOperazione tipoOp, String nome, String descr, String id, String referente, String versione,boolean visibilitaAccordoCooperazione,
  74.             IDAccordoCooperazione idAccordoOLD)
  75.                     throws Exception {

  76.         try{

  77.             int idInt = 0;
  78.             if (tipoOp.equals(TipoOperazione.CHANGE)) {
  79.                 idInt = Integer.parseInt(id);
  80.             }
  81.             if (referente == null) {
  82.                 referente = "";
  83.             }

  84. //          String gestioneWSBL = ServletUtils.getGestioneWSBLFromSession(this.session);
  85. //          if(gestioneWSBL == null){
  86. //              gestioneWSBL = Costanti.CHECK_BOX_DISABLED;
  87. //          }

  88.             // Campi obbligatori
  89.             if (nome==null || nome.equals("")) {
  90.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare un Nome");
  91.                 return false;
  92.             }
  93.             if(referente==null || referente.equals("") || referente.equals("-")){
  94.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare un Soggetto Referente");
  95.                 return false;
  96.             }
  97.             //if(this.core.isBackwardCompatibilityAccordo11()==false){
  98.             if (versione==null || versione.equals("")) {
  99.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare una Versione dell'accordo");
  100.                 return false;
  101.             }
  102.             //}

  103. //          if (gestioneWSBL.equals("yes") && (referente == null || "".equals(referente))) {
  104. //              this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare un Soggetto referente");
  105. //              return false;
  106. //          }

  107.             // Controllo che non ci siano spazi nei campi di testo
  108.             if (nome.indexOf(" ") != -1) {
  109.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  110.                 return false;
  111.             }

  112.             // Il nome deve contenere solo lettere e numeri e '_' '-' '.'
  113.             if(this.checkNCName(nome,AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_NOME)==false){
  114.                 return false;
  115.             }
  116.            
  117.             // lunghezza
  118.             if(this.checkLength255(nome, AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_NOME)==false) {
  119.                 return false;
  120.             }
  121.             if(descr!=null && !"".equals(descr)) {
  122.                 if(this.checkLength255(descr, AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_DESCRIZIONE)==false) {
  123.                     return false;
  124.                 }
  125.             }

  126.             // La versione deve contenere solo lettere e numeri e '.'
  127. //          if (gestioneWSBL.equals("yes")) {
  128.                 /*if (!versione.equals("") && !this.procToCall.isOk("^[1-9]+[\\.][0-9]+[0-9A-Za-z]*$", versione)  && !this.procToCall.isOk("^[0-9]+$",versione)) {
  129.                         this.pd.setMessage("La versione dev'essere scritto come MajorVersion[.MinorVersion*] (MajorVersion [1-9]) (MinorVersion [0-9]) (* [0-9A-Za-z]) ");
  130.                         return false;
  131.                     }*/
  132.                 if (!versione.equals("") && !this.checkNumber(versione,AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_VERSIONE,false)) {
  133.                     return false;
  134.                 }
  135. //          }

  136.             // Controllo che il referente appartenga alla lista di
  137.             // providers disponibili
  138.             //IDSoggetto soggettoReferente = null;
  139.             //if (gestioneWSBL.equals("yes")) {
  140.             Soggetto sRef = null;
  141.             IDSoggetto idSoggettoReferente = null;
  142.             if(referente!=null && !referente.equals("") && !referente.equals("-")){
  143.                 boolean trovatoProv = this.soggettiCore.existsSoggetto(Integer.parseInt(referente));
  144.                 if (!trovatoProv) {
  145.                     this.pd.setMessage("Il Soggetto referente dev'essere scelto tra quelli definiti nel pannello Soggetti");
  146.                     return false;
  147.                 }else{
  148.                     sRef = this.soggettiCore.getSoggettoRegistro(Integer.parseInt(referente));
  149.                     // Visibilita rispetto all'accordo
  150.                     boolean visibile = false;
  151.                     if(visibilitaAccordoCooperazione==visibile){
  152.                         if(sRef.getPrivato()!=null && sRef.getPrivato()==true){
  153.                             this.pd.setMessage("Non e' possibile utilizzare un soggetto referente con visibilita' privata, in un accordo di cooperazione con visibilita' pubblica.");
  154.                             return false;
  155.                         }
  156.                     }
  157.                     idSoggettoReferente = new IDSoggetto(sRef.getTipo(), sRef.getNome());
  158.                 }
  159.             }
  160.             //  }

  161.             // Controllo che non esistano altri accordi con stesso nome
  162.             // Se tipoOp = change, devo fare attenzione a non escludere nome
  163.             // del servizio selezionato
  164.             int idAcc = 0;
  165.             Integer versioneInt = null;
  166.             if(versione!=null){
  167.                 versioneInt = Integer.parseInt(versione);
  168.             }
  169.             IDAccordoCooperazione idAccordo = this.idAccordoCooperazioneFactory.getIDAccordoFromValues(nome,idSoggettoReferente,versioneInt);
  170.             boolean esisteAC = this.acCore.existsAccordoCooperazione(idAccordo);
  171.             AccordoCooperazione ac = null;
  172.             if (esisteAC) {
  173.                 ac = this.acCore.getAccordoCooperazione(idAccordo);
  174.                 idAcc = ac.getId().intValue();
  175.             }
  176.             if ((idAcc != 0) && (tipoOp.equals(TipoOperazione.ADD) || (tipoOp.equals(TipoOperazione.CHANGE) && (idInt != idAcc)))) {
  177.                 this.pd.setMessage("Esiste gi&agrave; un accordo (versione "+versione+") con nome " + nome);
  178.                 return false;
  179.             }

  180.             // Controllo visibilita soggetti partecipanti
  181.             if (tipoOp.equals(TipoOperazione.CHANGE)) {

  182.                 ac = this.acCore.getAccordoCooperazione(idAccordoOLD);

  183.                 if(ac.getPrivato()==null || ac.getPrivato()==false){
  184.                     if(ac.getElencoPartecipanti()!=null){
  185.                         AccordoCooperazionePartecipanti partecipanti = ac.getElencoPartecipanti();
  186.                         for(int i=0;i<partecipanti.sizeSoggettoPartecipanteList(); i++){
  187.                             Soggetto sPartecipante = this.soggettiCore.getSoggettoRegistro(partecipanti.getSoggettoPartecipante(i).getIdSoggetto().intValue());
  188.                             if(sPartecipante.getPrivato()!=null && sPartecipante.getPrivato()){
  189.                                 this.pd.setMessage("Non e' possibile impostare una visibilita' pubblica all'accordo di cooperazione, poiche' possiede un soggetto parcepante ["+sPartecipante.getTipo()+"/"+sPartecipante.getNome()
  190.                                         +"] con visibilita' privata.");
  191.                                 return false;
  192.                             }
  193.                         }
  194.                     }
  195.                 }
  196.             }
  197.            
  198.             AccordoCooperazione accordoCooperazione = new AccordoCooperazione();
  199.             accordoCooperazione.setDescrizione(descr);
  200.             accordoCooperazione.setNome(nome);
  201.             if(versione!=null){
  202.                 accordoCooperazione.setVersione(Integer.parseInt(versione));
  203.             }
  204.             if(sRef!=null){
  205.                 IdSoggetto soggettoReferente = new IdSoggetto();
  206.                 soggettoReferente.setTipo(sRef.getTipo());
  207.                 soggettoReferente.setNome(sRef.getNome());
  208.                 accordoCooperazione.setSoggettoReferente(soggettoReferente);
  209.             }
  210.            
  211.             String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(accordoCooperazione.getSoggettoReferente().getTipo());

  212.             ValidazioneResult v = this.acCore.validazione(accordoCooperazione, this.soggettiCore);
  213.             if(v.isEsito()==false){
  214.                 this.pd.setMessage("[validazione-"+protocollo+"] "+v.getMessaggioErrore());
  215.                 if(v.getException()!=null)
  216.                     this.log.error("[validazione-"+protocollo+"] "+v.getMessaggioErrore(),v.getException());
  217.                 else
  218.                     this.log.error("[validazione-"+protocollo+"] "+v.getMessaggioErrore());
  219.                 return false;
  220.             }  

  221.             return true;
  222.         } catch (Exception e) {
  223.             this.log.error("Exception: " + e.getMessage(), e);
  224.             throw new Exception(e);
  225.         }
  226.     }

  227.     // Prepara la lista di accordi cooperazione
  228.     public void prepareAccordiCooperazioneList(List<AccordoCooperazione> lista, ISearch ricerca) throws Exception {
  229.         try {
  230.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);

  231.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiCooperazioneCostanti.OBJECT_NAME_ACCORDI_COOPERAZIONE);

  232.             int idLista = Liste.ACCORDI_COOPERAZIONE;
  233.             int limit = ricerca.getPageSize(idLista);
  234.             int offset = ricerca.getIndexIniziale(idLista);
  235.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  236.             addFilterProtocol(ricerca, idLista);
  237.            
  238.             if(this.isShowGestioneWorkflowStatoDocumenti()){
  239.                 if(this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()) {
  240.                     String filterStatoAccordo = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_STATO_ACCORDO);
  241.                     this.addFilterStatoAccordo(filterStatoAccordo,false);
  242.                 }
  243.             }
  244.            
  245.             this.pd.setIndex(offset);
  246.             this.pd.setPageSize(limit);
  247.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  248.             // setto la barra del titolo
  249.             List<Parameter> lstParam = new ArrayList<>();

  250.             lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE, AccordiCooperazioneCostanti.SERVLET_NAME_ACCORDI_COOPERAZIONE_LIST));
  251.             if (search.equals("")) {
  252.                 this.pd.setSearchDescription("");
  253.             } else {
  254.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  255.             }

  256.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  257.             // controllo eventuali risultati ricerca
  258.             this.pd.setSearchLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_NOME);
  259.             if (!search.equals("")) {
  260.                 ServletUtils.enabledPageDataSearch(this.pd, AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE, search);
  261.             }

  262.             boolean showProtocolli = this.core.countProtocolli(this.request, this.session)>1;
  263.            
  264. //          String gestioneWSBL = ServletUtils.getGestioneWSBLFromSession(this.session);
  265. //          if(gestioneWSBL == null){
  266. //              gestioneWSBL = Costanti.CHECK_BOX_DISABLED;
  267. //          }

  268.             // setto le label delle colonne
  269.             int totEl = 3;
  270.             if(this.isShowGestioneWorkflowStatoDocumenti()) {
  271.                 if(this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()) {
  272.                     totEl++;
  273.                 }
  274.             }

  275.             // protocolli
  276.             if( showProtocolli ) {
  277.                 totEl++;
  278.             }
  279.                
  280.             String[] labels = new String[totEl];
  281.             labels[0] = AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_NOME;
  282.             //labels[1] = "Descrizione";

  283.             int index = 1;

  284.             if( showProtocolli ) {
  285.                 labels[index] = AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO_COMPACT;
  286.                 index++;
  287.             }
  288.            
  289.             if(this.isShowGestioneWorkflowStatoDocumenti()){
  290.                 if(this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()) {
  291.                     labels[index] = AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_STATO;
  292.                     index++;
  293.                 }
  294.             }

  295.             labels[index] = AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_PARTECIPANTI;
  296.             index++;
  297.             labels[index] = AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ALLEGATI;
  298.             index++;

  299.             this.pd.setLabels(labels);

  300.             // preparo i dati
  301.             List<List<DataElement>> dati = new ArrayList<>();

  302.             if (lista != null) {
  303.                 Iterator<AccordoCooperazione> it = lista.iterator();
  304.                 AccordoCooperazione accordoCooperazione = null;
  305.                 while (it.hasNext()) {
  306.                     accordoCooperazione = it.next();
  307.                     List<DataElement> e = new ArrayList<>();

  308.                     String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(accordoCooperazione.getSoggettoReferente().getTipo());
  309.                    
  310.                     DataElement de = new DataElement();
  311.                     de.setUrl(
  312.                             AccordiCooperazioneCostanti.SERVLET_NAME_ACCORDI_COOPERAZIONE_CHANGE,
  313.                             new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, accordoCooperazione.getId() + ""),
  314.                             new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME, accordoCooperazione.getNome())
  315.                             );
  316.                     //String uriAccordo = this.idAccordoCooperazioneFactory.getUriFromAccordo(accordoCooperazione);
  317.                     de.setValue(this.getLabelIdAccordoCooperazione(accordoCooperazione));
  318.                     de.setIdToRemove("" + accordoCooperazione.getId());
  319.                     de.setToolTip(accordoCooperazione.getDescrizione());
  320.                     e.add(de);

  321.                     /*de = new DataElement();
  322.                         de.setValue(accordoCooperazione.getDescrizione());
  323.                         e.add(de);*/

  324.                     if(showProtocolli) {
  325.                         de = new DataElement();
  326.                         de.setValue(this.getLabelProtocollo(protocollo));
  327.                         e.add(de);
  328.                     }
  329.                    

  330.                     if(this.isShowGestioneWorkflowStatoDocumenti()){
  331.                         if(this.core.isGestioneWorkflowStatoDocumentiVisualizzaStatoLista()) {
  332.                             de = new DataElement();
  333.                             de.setValue(StatiAccordo.upper(accordoCooperazione.getStatoPackage()));
  334.                             e.add(de);
  335.                         }
  336.                     }

  337.                     de = new DataElement();
  338.                     de.setUrl(
  339.                             AccordiCooperazioneCostanti.SERVLET_NAME_AC_PARTECIPANTI_LIST,
  340.                             new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, accordoCooperazione.getId() + ""),
  341.                             new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME, accordoCooperazione.getNome())
  342.                             );
  343.                     if (contaListe) {
  344.                         int numP = 0;
  345.                         if(accordoCooperazione.getElencoPartecipanti()!=null){
  346.                             numP = accordoCooperazione.getElencoPartecipanti().sizeSoggettoPartecipanteList();
  347.                         }
  348.                         ServletUtils.setDataElementVisualizzaLabel(de, (long)numP);
  349.                     } else {
  350.                         ServletUtils.setDataElementVisualizzaLabel(de);
  351.                     }
  352.                     e.add(de);

  353.                     de = new DataElement();
  354.                     de.setUrl(
  355.                             AccordiCooperazioneCostanti.SERVLET_NAME_AC_ALLEGATI_LIST,
  356.                             new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, accordoCooperazione.getId() + ""),
  357.                             new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME, accordoCooperazione.getNome())
  358.                             );
  359.                     if (contaListe) {
  360.                         // BugFix OP-674
  361.                         //List<org.openspcoop2.core.registry.Documento> tmpLista = this.acCore.accordiCoopAllegatiList(accordoCooperazione.getId().intValue(), new Search(true));
  362.                         ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  363.                         this.acCore.accordiCoopAllegatiList(accordoCooperazione.getId().intValue(), searchForCount);
  364.                         //int num = tmpLista.size();
  365.                         int num = searchForCount.getNumEntries(Liste.ACCORDI_COOP_ALLEGATI);
  366.                         ServletUtils.setDataElementVisualizzaLabel(de, (long)  num );

  367.                     } else {
  368.                         ServletUtils.setDataElementVisualizzaLabel(de);
  369.                     }
  370.                     e.add(de);

  371.                     dati.add(e);
  372.                 }
  373.             }

  374.             this.pd.setDati(dati);
  375.             this.pd.setAddButton(true);

  376.             // preparo bottoni
  377.             if(lista!=null && lista.size()>0){
  378.                 if (this.core.isShowPulsantiImportExport()) {
  379.                    
  380.                     ExporterUtils exporterUtils = new ExporterUtils(this.archiviCore);
  381.                     if(exporterUtils.existsAtLeastOneExportMode(ArchiveType.ACCORDO_COOPERAZIONE, this.request, this.session)){
  382.                    
  383.                         List<AreaBottoni> bottoni = new ArrayList<>();
  384.    
  385.                         AreaBottoni ab = new AreaBottoni();
  386.                         List<DataElement> otherbott = new ArrayList<>();
  387.                         DataElement de = new DataElement();
  388.                         de.setValue(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ESPORTA_SELEZIONATI);
  389.                         de.setOnClick(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ESPORTA_SELEZIONATI_CLICK_EVENT);
  390.                         de.setDisabilitaAjaxStatus();
  391.                         otherbott.add(de);
  392.                         ab.setBottoni(otherbott);
  393.                         bottoni.add(ab);
  394.    
  395.                         this.pd.setAreaBottoni(bottoni);
  396.                        
  397.                     }
  398.                 }
  399.             }
  400.         } catch (Exception e) {
  401.             this.log.error("Exception: " + e.getMessage(), e);
  402.             throw new Exception(e);
  403.         }
  404.     }

  405.     // Prepara la lista di partecipanti degli accordi cooperazione
  406.     public  void prepareAccordiPartecipantiList(AccordoCooperazione ac)
  407.             throws Exception {
  408.         try {

  409.             String id = this.getParameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID);
  410.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiCooperazioneCostanti.OBJECT_NAME_AC_PARTECIPANTI,
  411.                     new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, id));

  412.             // setto la barra del titolo
  413.             List<Parameter> lstParam = new ArrayList<>();

  414.             this.pd.setSearchDescription("");
  415.             lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE, AccordiCooperazioneCostanti.SERVLET_NAME_ACCORDI_COOPERAZIONE_LIST));
  416.             lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_PARTECIPANTI_DI + this.idAccordoCooperazioneFactory.getUriFromAccordo(ac), null));

  417.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  418.             // setto le label delle colonne
  419.             String[] labels = { AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_PARTECIPANTE };
  420.             this.pd.setLabels(labels);

  421.             // preparo i dati
  422.             List<List<DataElement>> dati = new ArrayList<>();

  423.             if(ac.getElencoPartecipanti()!=null){
  424.                 AccordoCooperazionePartecipanti partecipanti = ac.getElencoPartecipanti();
  425.                 for (int i = 0; i < partecipanti.sizeSoggettoPartecipanteList(); i++) {
  426.                     IdSoggetto acep = partecipanti.getSoggettoPartecipante(i);

  427.                     List<DataElement> e = new ArrayList<>();

  428.                     DataElement de = new DataElement();
  429.                     de.setValue(acep.getTipo()+"/"+acep.getNome());
  430.                     de.setIdToRemove(""+acep.getId());
  431.                     e.add(de);

  432.                     dati.add(e);
  433.                 }
  434.             }

  435.             this.pd.setDati(dati);
  436.             this.pd.setAddButton(true);
  437.             this.pd.setSearch("off");
  438.         } catch (Exception e) {
  439.             this.log.error("Exception: " + e.getMessage(), e);
  440.             throw new Exception(e);
  441.         }
  442.     }

  443.     public List<DataElement> addAccordiCooperazioneToDati(List<DataElement> dati, String nome, String descr,
  444.             String id, TipoOperazione tipoOp, String referente, String versione, String[] providersList, String[] providersListLabel,
  445.             boolean privato , String stato, String oldStato,
  446.             String tipoProtocollo, List<String> listaTipiProtocollo, boolean used) throws Exception {

  447.         boolean modificheAbilitate = false;
  448.         if( tipoOp.equals(TipoOperazione.ADD) ){
  449.             modificheAbilitate = true;
  450.         }else if(this.isShowGestioneWorkflowStatoDocumenti()==false){
  451.             modificheAbilitate = true;
  452.         }else if(StatiAccordo.finale.toString().equals(oldStato)==false){
  453.             modificheAbilitate = true;
  454.         }


  455.         DataElement de = new DataElement();

  456.         if(TipoOperazione.CHANGE.equals(tipoOp)){
  457.             de.setLabel(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID);
  458.             de.setValue(id);
  459.             de.setType(DataElementType.HIDDEN);
  460.             de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID);
  461.             dati.add(de);

  462.             de = new DataElement();
  463.             de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO);

  464.             if(listaTipiProtocollo != null && listaTipiProtocollo.size() > 1){
  465.             if(!used && modificheAbilitate){
  466.                 de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO);
  467.                 de.setValues(listaTipiProtocollo);
  468.                 de.setSelected(tipoProtocollo);
  469.                 de.setType(DataElementType.SELECT);
  470.                 de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO);
  471.                 de.setPostBack(true);
  472.             }else {
  473.                 de.setValue(tipoProtocollo);
  474.                 de.setType(DataElementType.TEXT);
  475.                 de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO);
  476.             }
  477.             }else {
  478.                 de.setValue(tipoProtocollo);
  479.                 de.setType(DataElementType.HIDDEN);
  480.                 de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO );
  481.             }
  482.             de.setSize(this.getSize());
  483.             dati.add(de);
  484.         }

  485.         // Gestione del tipo protocollo per la maschera add
  486.         if(TipoOperazione.ADD.equals(tipoOp)){
  487.             de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO);
  488.             if(listaTipiProtocollo != null && listaTipiProtocollo.size() > 1 && modificheAbilitate){
  489.                 de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO);
  490.                 de.setValues(listaTipiProtocollo);
  491.                 de.setLabels(this.getLabelsProtocolli(listaTipiProtocollo));
  492.                 de.setSelected(tipoProtocollo);
  493.                 de.setType(DataElementType.SELECT);
  494.                 de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO);
  495.                 de.setPostBack(true);
  496.             }else {
  497.                
  498.                 DataElement deLABEL = new DataElement();
  499.                 deLABEL.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO);
  500.                 deLABEL.setType(DataElementType.TEXT);
  501.                 deLABEL.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  502.                 deLABEL.setValue(this.getLabelProtocollo(tipoProtocollo));
  503.                 dati.add(deLABEL);
  504.                
  505.                 de.setValue(tipoProtocollo);
  506.                 de.setType(DataElementType.HIDDEN);
  507.                 de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO );
  508.             }
  509.             de.setSize(this.getSize());
  510.             dati.add(de);
  511.         }

  512.         de = new DataElement();
  513.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_NOME);
  514.         de.setValue(nome);
  515.         if( modificheAbilitate ){
  516.             de.setType(DataElementType.TEXT_EDIT);
  517.             de.setRequired(true);
  518.         }else{
  519.             de.setType(DataElementType.TEXT);
  520.         }
  521.         //} else {
  522.         //  de.setType(DataElementType.TEXT);
  523.         //}
  524.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME);
  525.         de.setSize(getSize());
  526.         dati.add(de);

  527.         de = new DataElement();
  528.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_DESCRIZIONE);
  529.         de.setValue(descr);
  530.         de.setType(DataElementType.TEXT_EDIT);
  531.         if( !modificheAbilitate && StringUtils.isBlank(descr))
  532.             de.setValue("");
  533.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_DESCRIZIONE);
  534.         de.setSize(getSize());
  535.         dati.add(de);

  536.         de = new DataElement();
  537.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_SOGGETTO_REFERENTE);
  538.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_REFERENTE);
  539.         if (tipoOp.equals(TipoOperazione.ADD)) {

  540. //          if (gestioneWSBL.equals(Costanti.CHECK_BOX_ENABLED)) {
  541.                 // if (tipoOp.equals("add")) {
  542.                 de.setType(DataElementType.SELECT);
  543.                 de.setValues(providersList);
  544.                 de.setLabels(providersListLabel);
  545.                 if (referente != null && !"".equals(referente)) {
  546.                     de.setSelected(referente);
  547.                 }else{
  548.                     de.setSelected("-");
  549.                 }
  550.                 //if(this.core.isBackwardCompatibilityAccordo11()==false){
  551.                 de.setRequired(true);
  552.                 //}
  553.                 // } else {
  554.                 // de.setType(DataElementType.HIDDEN);
  555.                 // de.setValue(referente);
  556.                 // }
  557. //          } else {
  558. //              de.setType(DataElementType.HIDDEN);
  559. //              de.setValue(referente);
  560. //          }
  561.         }else{
  562.             de.setType(DataElementType.HIDDEN);
  563.             de.setValue(referente);
  564.             dati.add(de);

  565.             de = new DataElement();
  566.             de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_SOGGETTO_REFERENTE);
  567.             de.setName(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_SOGGETTO_REFERENTE_12);
  568.             de.setType(DataElementType.TEXT);
  569.             if (referente != null && !"".equals(referente) && !"-".equals(referente)) {
  570.                 Soggetto sogg = this.soggettiCore.getSoggettoRegistro(Integer.parseInt(referente));
  571.                 de.setValue(this.getLabelNomeSoggetto(tipoProtocollo, sogg.getTipo(), sogg.getNome()));
  572.             }else{
  573.                 de.setValue("-");
  574.             }
  575.         }      
  576.         dati.add(de);

  577.         if( modificheAbilitate ){
  578.             de = this.getVersionDataElement(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_VERSIONE,
  579.                     AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_VERSIONE,
  580.                     versione, false);
  581.         }
  582.         else {
  583.             de = new DataElement();
  584.             de.setValue(versione);
  585.             de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_VERSIONE);
  586.             de.setType(DataElementType.TEXT);
  587.         }
  588.         dati.add(de);

  589.         de = new DataElement();
  590.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_PRIVATO);
  591.         de.setValue(privato ? Costanti.CHECK_BOX_ENABLED : "");
  592.         de.setSelected(privato ? Costanti.CHECK_BOX_ENABLED : "");
  593.         if (this.core.isShowFlagPrivato() && modificheAbilitate && this.isModalitaAvanzata()) {
  594.             de.setType(DataElementType.CHECKBOX);
  595.         } else {
  596.             de.setType(DataElementType.HIDDEN);
  597.         }
  598.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PRIVATO);
  599.         de.setSize(getSize());
  600.         dati.add(de);

  601.         if(this.core.isShowFlagPrivato() && !modificheAbilitate && this.isModalitaAvanzata()){
  602.             de = new DataElement();
  603.             de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_VISIBILITA_ACCORDO);
  604.             de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PRIVATO_LABEL);
  605.             if(privato){
  606.                 de.setValue(AccordiCooperazioneCostanti.DEFAULT_VALUE_PARAMETRO_ACCORDI_COOPERAZIONE_VISIBILITA_ACCORDO_PRIVATA);
  607.             }else{
  608.                 de.setValue(AccordiCooperazioneCostanti.DEFAULT_VALUE_PARAMETRO_ACCORDI_COOPERAZIONE_VISIBILITA_ACCORDO_PUBBLICA);
  609.             }
  610.             dati.add(de);
  611.         }


  612.         de = new DataElement();
  613.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_STATO);
  614.         if(this.isShowGestioneWorkflowStatoDocumenti()){
  615.             if( tipoOp.equals(TipoOperazione.ADD)){
  616.                
  617.                 DataElement deLabel = new DataElement();
  618.                 deLabel.setType(DataElementType.TEXT);
  619.                 deLabel.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_STATO);
  620.                 deLabel.setValue(StatiAccordo.upper(StatiAccordo.bozza.toString()));
  621.                 deLabel.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_STATO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  622.                 dati.add(deLabel);
  623.                
  624.                 de.setType(DataElementType.HIDDEN);
  625.                 de.setValue(StatiAccordo.bozza.toString());
  626.             } else if(StatiAccordo.finale.toString().equals(oldStato)==false ){
  627.                 de.setType(DataElementType.SELECT);
  628.                 de.setValues(StatiAccordo.toArray());
  629.                 de.setLabels(StatiAccordo.toLabel());
  630.                 de.setSelected(stato);
  631.             }else{
  632.                
  633.                 DataElement deLabel = new DataElement();
  634.                 deLabel.setType(DataElementType.TEXT);
  635.                 deLabel.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_STATO);
  636.                 deLabel.setValue(StatiAccordo.upper(StatiAccordo.finale.toString()));
  637.                 deLabel.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_STATO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  638.                 dati.add(deLabel);
  639.                
  640.                 de.setType(DataElementType.HIDDEN);
  641.                 de.setValue(StatiAccordo.finale.toString());
  642.             }
  643.         }else{
  644.             de.setType(DataElementType.HIDDEN);
  645.             de.setValue(StatiAccordo.finale.toString());
  646.         }
  647.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_STATO);
  648.         dati.add(de);


  649.         if (tipoOp.equals(TipoOperazione.ADD) == false) {

  650.             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);

  651.             de = new DataElement();
  652.             de.setType(DataElementType.LINK);
  653.             de.setUrl(AccordiCooperazioneCostanti.SERVLET_NAME_AC_PARTECIPANTI_LIST,
  654.                     new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, id+""),
  655.                     new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME, nome));

  656.             if(contaListe){
  657.                 // BugFix OP-674
  658.                 //int num = this.acCore.accordiCoopPartecipantiList(Long.parseLong(id), new Search(true)).size();
  659.                 ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  660.                 this.acCore.accordiCoopPartecipantiList(Long.parseLong(id), searchForCount);
  661.                 int num = searchForCount.getNumEntries(Liste.ACCORDI_COOP_PARTECIPANTI);
  662.                 de.setValue(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_SOGGETTI_PARTECIPANTI +"("+num+")");
  663.             }else{
  664.                 de.setValue(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_SOGGETTI_PARTECIPANTI);
  665.             }
  666.             dati.add(de);

  667.             de = new DataElement();
  668.             de.setType(DataElementType.LINK);
  669.             de.setUrl(
  670.                     AccordiCooperazioneCostanti.SERVLET_NAME_AC_ALLEGATI_LIST,
  671.                     new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, id+""),
  672.                     new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME, nome));
  673.             if(contaListe){
  674.                 // BugFix OP-674
  675.                 //int num = this.acCore.accordiCoopAllegatiList(Integer.parseInt(id), new Search(true)).size();
  676.                 ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  677.                 this.acCore.accordiCoopAllegatiList(Integer.parseInt(id), searchForCount);
  678.                 int num = searchForCount.getNumEntries(Liste.ACCORDI_COOP_ALLEGATI);
  679.                 de.setValue(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ALLEGATI +"("+num+")");
  680.             }else{
  681.                 de.setValue(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ALLEGATI);
  682.             }
  683.             dati.add(de);

  684.         }

  685.         return dati;
  686.     }

  687.     public List<DataElement> addAccordiCooperazioneToDatiAsHidden(List<DataElement> dati, String nome, String descr,
  688.             String id, TipoOperazione tipoOp, String referente, String versione, String[] providersList, String[] providersListLabel,
  689.             boolean privato , String stato, String oldStato,
  690.             String tipoProtocollo, List<String> listaTipiProtocollo, boolean used) throws Exception {

  691. //      boolean modificheAbilitate = false;
  692. //      if( tipoOp.equals(TipoOperazione.ADD) ){
  693. //          modificheAbilitate = true;
  694. //      }else if(this.isShowGestioneWorkflowStatoDocumenti()==false){
  695. //          modificheAbilitate = true;
  696. //      }else if(StatiAccordo.finale.toString().equals(oldStato)==false){
  697. //          modificheAbilitate = true;
  698. //      }

  699.         DataElement de = new DataElement();
  700.         de.setValue(tipoProtocollo);
  701.         de.setType(DataElementType.HIDDEN);
  702.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PROTOCOLLO);
  703.         de.setSize(this.getSize());
  704.         dati.add(de);

  705.         if(TipoOperazione.CHANGE.equals(tipoOp)){
  706.             de = new DataElement();
  707.             de.setLabel(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID);
  708.             de.setValue(id);
  709.             de.setType(DataElementType.HIDDEN);
  710.             de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID);
  711.             dati.add(de);
  712.         }

  713.         de = new DataElement();
  714.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_NOME);
  715.         de.setValue(nome);
  716.         de.setType(DataElementType.HIDDEN);
  717.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME);
  718.         de.setSize(getSize());
  719.         dati.add(de);

  720.         de = new DataElement();
  721.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_DESCRIZIONE);
  722.         de.setValue(descr);
  723.         de.setType(DataElementType.HIDDEN);
  724.         de.setValue(descr);
  725.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_DESCRIZIONE);
  726.         de.setSize(getSize());
  727.         dati.add(de);

  728.         de = new DataElement();
  729.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_SOGGETTO_REFERENTE);
  730.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_REFERENTE);
  731.         if (referente != null && !"".equals(referente) && !"-".equals(referente)) {
  732.             Soggetto sogg = this.soggettiCore.getSoggettoRegistro(Integer.parseInt(referente));
  733.             de.setValue("" +sogg.getId());
  734.         }else{
  735.             de.setValue("-");
  736.         }
  737.         de.setType(DataElementType.HIDDEN);
  738.         dati.add(de);

  739.         de = new DataElement();
  740.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_VERSIONE);
  741.         de.setValue(versione);
  742.         de.setType(DataElementType.HIDDEN);
  743.         //      if( modificheAbilitate ){
  744.         //          //          if (gestioneWSBL.equals(Costanti.CHECK_BOX_ENABLED)){
  745.         //          de.setType(DataElementType.TEXT_EDIT);
  746.         //          //if(this.core.isBackwardCompatibilityAccordo11()==false){
  747.         //          //de.setRequired(true);
  748.         //          // version spinner parte da 1
  749.         //
  750.         //          ServletUtils.setObjectIntoSession(request, session, AccordiCooperazioneCostanti.DEFAULT_VALUE_PARAMETRO_ACCORDI_COOPERAZIONE_VERSION,
  751.         //                  AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_VERSION);
  752.         //          /*}else{
  753.         //                      // version spinner parte da 0
  754.         //                      if(versione==null || "".equals(versione)){
  755.         //                          de.setValue("0");
  756.         //                      }
  757.         //                      ServletUtils.setObjectIntoSession(request, session, "optional", "version");
  758.         //                  }*/
  759.         //          //          }else
  760.         //          //              de.setType(DataElementType.HIDDEN);
  761.         //      }else{
  762.         //          de.setType(DataElementType.TEXT);
  763.         //      }
  764.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_VERSIONE);
  765.         dati.add(de);

  766.         de = new DataElement();
  767.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_PRIVATO);
  768.         de.setValue(privato ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  769.         de.setType(DataElementType.HIDDEN);
  770.         //      de.setSelected(privato ? Costanti.CHECK_BOX_ENABLED : "");
  771.         //      if (this.core.isShowFlagPrivato() && modificheAbilitate && !InterfaceType.STANDARD.equals(ServletUtils.getUserFromSession(this.session).getInterfaceType())) {
  772.         //          de.setType(DataElementType.CHECKBOX);
  773.         //      } else {
  774.         //          de.setType(DataElementType.HIDDEN);
  775.         //      }
  776.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PRIVATO);
  777.         de.setSize(getSize());
  778.         dati.add(de);

  779.         //      if(this.core.isShowFlagPrivato() && !modificheAbilitate && !InterfaceType.STANDARD.equals(ServletUtils.getUserFromSession(this.session).getInterfaceType())){
  780.         de = new DataElement();
  781.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_VISIBILITA_ACCORDO);
  782.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PRIVATO_LABEL);
  783.         de.setType(DataElementType.HIDDEN);
  784.         if(privato){
  785.             de.setValue(AccordiCooperazioneCostanti.DEFAULT_VALUE_PARAMETRO_ACCORDI_COOPERAZIONE_VISIBILITA_ACCORDO_PRIVATA);
  786.         }else{
  787.             de.setValue(AccordiCooperazioneCostanti.DEFAULT_VALUE_PARAMETRO_ACCORDI_COOPERAZIONE_VISIBILITA_ACCORDO_PUBBLICA);
  788.         }
  789.         dati.add(de);
  790.         //      }


  791.         de = new DataElement();
  792.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_STATO);

  793.         //      if(this.isShowGestioneWorkflowStatoDocumenti()){
  794. //          String[] stati = StatiAccordo.toArray();
  795. //          if( tipoOp.equals(TipoOperazione.ADD)){
  796. //              de.setType(DataElementType.TEXT);
  797. //              de.setValue(StatiAccordo.bozza.toString());
  798. //          } else if(StatiAccordo.finale.toString().equals(oldStato)==false ){
  799. //              de.setType(DataElementType.SELECT);
  800. //              de.setValues(stati);
  801. //              de.setSelected(stato);
  802. //          }else{
  803. //              de.setType(DataElementType.TEXT);
  804. //              de.setValue(StatiAccordo.finale.toString());
  805. //          }
  806. //      }else{
  807. //          de.setType(DataElementType.HIDDEN);
  808. //          de.setValue(StatiAccordo.finale.toString());
  809. //      }
  810.         de.setType(DataElementType.HIDDEN);
  811.         de.setValue(stato);
  812.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_STATO);
  813.         dati.add(de);

  814.         return dati;
  815.     }

  816.     public void prepareAccordiCoopPartecipantiList(AccordoCooperazione ac,List<IDSoggetto> lista, ISearch ricerca)
  817.             throws Exception {
  818.         try {
  819.             String id = this.getParameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID);
  820.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiCooperazioneCostanti.OBJECT_NAME_AC_PARTECIPANTI,
  821.                     new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, id));
  822.            
  823.             int idLista = Liste.ACCORDI_COOP_PARTECIPANTI;
  824.             int limit = ricerca.getPageSize(idLista);
  825.             int offset = ricerca.getIndexIniziale(idLista);
  826.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  827.             this.pd.setIndex(offset);
  828.             this.pd.setPageSize(limit);
  829.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  830.             String titleAS = this.getLabelIdAccordoCooperazione(ac);
  831.            
  832.             // setto la barra del titolo
  833.             this.pd.setSearchDescription("");
  834.             List<Parameter> lstParam = new ArrayList<>();
  835.             lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE, AccordiCooperazioneCostanti.SERVLET_NAME_ACCORDI_COOPERAZIONE_LIST));
  836.             if (search.equals("")) {
  837.                 this.pd.setSearchDescription("");
  838.                 lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_PARTECIPANTI_DI + titleAS, null));
  839.             }
  840.             else{
  841.                 lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_PARTECIPANTI_DI + titleAS,
  842.                         AccordiCooperazioneCostanti.SERVLET_NAME_ACCORDI_COOPERAZIONE_LIST));
  843.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  844.             }

  845.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  846.             // controllo eventuali risultati ricerca
  847.             this.pd.setSearchLabel(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_PARTECIPANTE);
  848.             if (!search.equals("")) {
  849.                 ServletUtils.enabledPageDataSearch(this.pd, AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_PARTECIPANTI, search);
  850.             }
  851.            
  852.            
  853.             // setto le label delle colonne
  854.             String[] labels = { AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_PARTECIPANTE };
  855.             this.pd.setLabels(labels);

  856.             // preparo i dati
  857.             List<List<DataElement>> dati = new ArrayList<>();

  858.             for (int i = 0; i < lista.size(); i++) {
  859.                 IDSoggetto idSO = lista.get(i);

  860.                 List<DataElement> e = new ArrayList<>();

  861.                 DataElement de = new DataElement();
  862.                 de.setValue(this.getLabelNomeSoggetto(this.soggettiCore.getProtocolloAssociatoTipoSoggetto(idSO.getTipo()), idSO.getTipo(),idSO.getNome()));
  863.                 de.setIdToRemove(""+idSO.getTipo()+"/"+idSO.getNome());
  864.                 e.add(de);

  865.                 dati.add(e);
  866.             }

  867.             this.pd.setDati(dati);

  868.             if(this.isShowGestioneWorkflowStatoDocumenti() && StatiAccordo.finale.toString().equals(ac.getStatoPackage())){
  869.                 this.pd.setAddButton(false);
  870.                 this.pd.setRemoveButton(false);
  871.                 this.pd.setSelect(false);
  872.             }else{
  873.                 this.pd.setAddButton(true);
  874.                 this.pd.setRemoveButton(true);
  875.                 this.pd.setSelect(true);
  876.             }

  877.         } catch (Exception e) {
  878.             this.log.error("Exception: " + e.getMessage(), e);
  879.             throw new Exception(e);
  880.         }
  881.     }

  882.     public void prepareAccordiCoopAllegatiList(AccordoCooperazione ac, ISearch ricerca, List<Documento> lista) throws Exception {
  883.         try {
  884.             ServletUtils.addListElementIntoSession(this.request, this.session, AccordiCooperazioneCostanti.OBJECT_NAME_AC_ALLEGATI,
  885.                     new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, ""+ac.getId()));


  886.             int idLista = Liste.ACCORDI_COOP_ALLEGATI;
  887.             int limit = ricerca.getPageSize(idLista);
  888.             int offset = ricerca.getIndexIniziale(idLista);
  889.             String search = ServletUtils.getSearchFromSession(ricerca, idLista);

  890.             this.pd.setIndex(offset);
  891.             this.pd.setPageSize(limit);
  892.             this.pd.setNumEntries(ricerca.getNumEntries(idLista));

  893.             String titleAS = this.getLabelIdAccordoCooperazione(ac);
  894.            
  895.             // setto la barra del titolo
  896.             List<Parameter> lstParam = new ArrayList<>();

  897.             lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE, AccordiCooperazioneCostanti.SERVLET_NAME_ACCORDI_COOPERAZIONE_LIST));
  898.             if (search.equals("")) {
  899.                 this.pd.setSearchDescription("");
  900.                 lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ALLEGATI_DI  
  901.                         + titleAS, null));
  902.             } else {
  903.                 lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ALLEGATI_DI  
  904.                         + titleAS,
  905.                         AccordiCooperazioneCostanti.SERVLET_NAME_AC_ALLEGATI_LIST,
  906.                         new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, ac.getId()+ "")
  907.                         ));
  908.                 lstParam.add(new Parameter(Costanti.PAGE_DATA_TITLE_LABEL_RISULTATI_RICERCA, null));
  909.             }

  910.             ServletUtils.setPageDataTitle(this.pd, lstParam);

  911.             // controllo eventuali risultati ricerca
  912.             this.pd.setSearchLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_NOME);
  913.             if (!search.equals("")) {
  914.                 ServletUtils.enabledPageDataSearch(this.pd, AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ALLEGATI, search);
  915.             }

  916.             // setto le label delle colonne
  917.             String[] labels = {
  918.                     AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_NOME,
  919.                     AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_RUOLO  ,
  920.                     AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_TIPO  ,
  921.                     AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_DOCUMENTO  
  922.                     };
  923.             this.pd.setLabels(labels);

  924.             // preparo i dati
  925.             List<List<DataElement>> dati = new ArrayList<>();

  926.             if (lista != null) {
  927.                 Iterator<Documento> it = lista.iterator();
  928.                 while (it.hasNext()) {
  929.                     Documento doc = it.next();

  930.                     List<DataElement> e = new ArrayList<>();

  931.                     DataElement de = new DataElement();
  932.                     de.setUrl(
  933.                             AccordiCooperazioneCostanti.SERVLET_NAME_AC_ALLEGATI_CHANGE,
  934.                             new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ALLEGATO,doc.getId()+""),
  935.                             new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ACCORDO,ac.getId()+""),
  936.                             new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME_DOCUMENTO,doc.getFile())
  937.                            
  938.                          
  939.                             );
  940.                     de.setValue(doc.getFile());
  941.                     de.setIdToRemove(""+doc.getId());
  942.                     e.add(de);

  943.                     de = new DataElement();
  944.                     de.setValue(doc.getRuolo());
  945.                     e.add(de);

  946.                     de = new DataElement();
  947.                     de.setValue(doc.getTipo());
  948.                     e.add(de);

  949.                     de = new DataElement();
  950.                     if(this.core.isShowAllegati()) {
  951.                         de.setUrl(
  952.                                 AccordiCooperazioneCostanti.SERVLET_NAME_AC_ALLEGATI_VIEW,
  953.    
  954.                                 new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ALLEGATO,doc.getId()+""),
  955.                                 new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ACCORDO,ac.getId()+""),
  956.                                 new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME_DOCUMENTO,doc.getFile())
  957.                                 );
  958.                         ServletUtils.setDataElementVisualizzaLabel(de);
  959.                     }
  960.                     else {
  961.                         Parameter pTipoDoc = new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_TIPO_DOCUMENTO, "ac");
  962.                         de.setUrl(
  963.                                 ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  964.                                 new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ALLEGATO,doc.getId()+""),
  965.                                 new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ACCORDO,ac.getId()+""),
  966.                                 new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME_DOCUMENTO,doc.getFile()),
  967.                                 pTipoDoc
  968.                                 );
  969.                         de.setValue(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_DOWNLOAD.toLowerCase());
  970.                         de.setDisabilitaAjaxStatus();
  971.                     }
  972.                     e.add(de);

  973.                     dati.add(e);
  974.                 }
  975.             }

  976.             this.pd.setDati(dati);

  977.             if(this.isShowGestioneWorkflowStatoDocumenti() && StatiAccordo.finale.toString().equals(ac.getStatoPackage())){
  978.                 this.pd.setAddButton(false);
  979.                 this.pd.setRemoveButton(false);
  980.                 this.pd.setSelect(false);
  981.             }else{
  982.                 this.pd.setAddButton(true);
  983.                 this.pd.setRemoveButton(true);
  984.                 this.pd.setSelect(true);
  985.             }

  986.         } catch (Exception e) {
  987.             this.log.error("Exception: " + e.getMessage(), e);
  988.             throw new Exception(e);
  989.         }
  990.     }

  991.     public List<DataElement>  addAllegatiToDati(TipoOperazione tipoOp, String idAllegato, String idAccordo,
  992.             Documento doc, StringBuilder contenutoAllegato, String errore,
  993.             List<DataElement> dati, String statoPackage, boolean editMode) {
  994.         DataElement de = new DataElement();

  995.         de.setValue(idAllegato);
  996.         de.setType(DataElementType.HIDDEN);
  997.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ALLEGATO);
  998.         dati.add(de);

  999.         de = new DataElement();
  1000.         de.setValue(idAccordo);
  1001.         de.setType(DataElementType.HIDDEN);
  1002.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ACCORDO);
  1003.         dati.add(de);

  1004.         de = new DataElement();
  1005.         de.setType(DataElementType.TITLE);
  1006.         de.setLabel(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ALLEGATO);
  1007.         dati.add(de);
  1008.        
  1009.         de = new DataElement();
  1010.         de.setValue(doc.getRuolo());
  1011.         de.setLabel("Ruolo");
  1012.         de.setType(DataElementType.TEXT);
  1013.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_RUOLO);
  1014.         de.setSize(getSize());
  1015.         dati.add(de);

  1016.         de = new DataElement();
  1017.         de.setValue(doc.getFile());
  1018.         de.setLabel("Nome");
  1019.         de.setType(DataElementType.TEXT);
  1020.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME_DOCUMENTO);
  1021.         de.setSize(getSize());
  1022.         dati.add(de);

  1023.         de = new DataElement();
  1024.         de.setValue(doc.getTipo());
  1025.         de.setLabel("Tipo");
  1026.         de.setType(DataElementType.TEXT);
  1027.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_TIPO_FILE);
  1028.         de.setSize(getSize());
  1029.         dati.add(de);

  1030.         if(tipoOp.equals(TipoOperazione.OTHER)){
  1031.             if(this.core.isShowAllegati()) {
  1032.                 if(errore!=null){
  1033.                     de = new DataElement();
  1034.                     de.setValue(errore);
  1035.                     de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_DOCUMENTO);
  1036.                     de.setType(DataElementType.TEXT);
  1037.                     de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_DOCUMENTO  );
  1038.                     de.setSize( getSize());
  1039.                     dati.add(de);
  1040.                 }
  1041.                 else{
  1042.                     de = new DataElement();
  1043.                     de.setLabel("");//AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_DOCUMENTO);
  1044.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  1045.                     de.setValue(contenutoAllegato.toString());
  1046.                     de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_SIZE);
  1047.                     de.setCols(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_API_COLUMNS);
  1048.                     dati.add(de);
  1049.                 }
  1050.             }
  1051.            
  1052.             DataElement saveAs = new DataElement();
  1053.             saveAs.setValue(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_DOWNLOAD);
  1054.             saveAs.setType(DataElementType.LINK);
  1055.             Parameter pIdAccordo = new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ACCORDO, idAccordo);
  1056.             Parameter pIdAllegato = new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ALLEGATO, idAllegato);
  1057.             Parameter pTipoDoc = new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_TIPO_DOCUMENTO, "ac");
  1058.             //          String params = "idAccordo="+idServizio+"&idAllegato="+idAllegato+"&tipoDocumento=asps";
  1059.             saveAs.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT, pIdAccordo, pIdAllegato, pTipoDoc);
  1060.             saveAs.setDisabilitaAjaxStatus();
  1061.             dati.add(saveAs);
  1062.         }

  1063.         if(tipoOp.equals(TipoOperazione.CHANGE)){
  1064.             if(editMode){
  1065.                 if(this.isShowGestioneWorkflowStatoDocumenti() && StatiAccordo.finale.toString().equals(statoPackage)){
  1066.                     this.pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  1067.                 }
  1068.                 else{  
  1069.                     de = new DataElement();
  1070.                     de.setType(DataElementType.FILE);
  1071.                     de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_DOCUMENTO);
  1072.                     de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_THE_FILE);
  1073.                     de.setSize(getSize());
  1074.                     dati.add(de);
  1075.                 }
  1076.             }else{
  1077.                 de = new DataElement();
  1078.                 de.setType(DataElementType.FILE);
  1079.                 de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_DOCUMENTO);
  1080.                 de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_THE_FILE);
  1081.                 de.setSize(getSize());
  1082.                 dati.add(de);
  1083.             }
  1084.         }

  1085.         return dati;
  1086.     }

  1087.     public List<DataElement> addAllegatoToDati(TipoOperazione tipoOp, String idAccordo, String ruolo,
  1088.             String[] ruoli, String[] tipiAmmessi, String[] tipiAmmessiLabel,
  1089.             List<DataElement> dati) {
  1090.         DataElement de = new DataElement();

  1091.         de.setValue(idAccordo);
  1092.         de.setType(DataElementType.HIDDEN);
  1093.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID);
  1094.         dati.add(de);

  1095.         de = new DataElement();
  1096.         de.setType(DataElementType.TITLE);
  1097.         de.setLabel(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ALLEGATO);
  1098.         dati.add(de);
  1099.        
  1100.         de = new DataElement();
  1101.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_RUOLO);
  1102.         de.setType(DataElementType.SELECT);
  1103.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_RUOLO);
  1104.         de.setValues(ruoli);
  1105.         //              de.setOnChange("CambiaTipoDocumento('accordiCoopAllegati')");
  1106.         de.setPostBack(true);
  1107.         de.setSelected(ruolo!=null ? ruolo : "");
  1108.         de.setSize( getSize());
  1109.         dati.add(de);

  1110.         if(tipiAmmessi!=null){
  1111.             de = new DataElement();
  1112.             de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_TIPO);
  1113.             de.setType(DataElementType.SELECT);
  1114.             de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_TIPO_FILE);
  1115.             de.setValues(tipiAmmessi);
  1116.             de.setLabels(tipiAmmessiLabel);
  1117.             de.setSize( getSize());
  1118.             dati.add(de);
  1119.         }

  1120.         de = new DataElement();
  1121.         de.setValue(idAccordo);
  1122.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_DOCUMENTO);
  1123.         de.setType(DataElementType.FILE);
  1124.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_THE_FILE);
  1125.         de.setSize( getSize());
  1126.         dati.add(de);

  1127.         return dati;
  1128.     }

  1129.     public List<DataElement> addPartecipanteToDati(TipoOperazione tipoOp, String id,
  1130.             String[] partecipantiNonInseriti,String[] partecipantiNonInseritiLabels, List<DataElement> dati) {
  1131.        
  1132.         DataElement de = new DataElement();
  1133.         de.setLabel(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_PARTECIPANTE);
  1134.         de.setType(DataElementType.TITLE);
  1135.         dati.add(de);
  1136.        
  1137.         de = new DataElement();
  1138.         de.setValue(id);
  1139.         de.setType(DataElementType.HIDDEN);
  1140.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID);
  1141.         dati.add(de);

  1142.         de = new DataElement();
  1143.         de.setLabel(AccordiCooperazioneCostanti.LABEL_PARAMETRO_ACCORDI_COOPERAZIONE_PARTECIPANTE);
  1144.         de.setValues(partecipantiNonInseriti );
  1145.         de.setLabels(partecipantiNonInseritiLabels );
  1146.         de.setType(DataElementType.SELECT);
  1147.         de.setName(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_PARTECIPANTE);
  1148.         de.setSize(getSize());
  1149.         dati.add(de);

  1150.         return dati;
  1151.     }

  1152. }