ConnettoreStatusParams.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.connettori;

  21. import java.util.ArrayList;
  22. import java.util.Arrays;
  23. import java.util.List;
  24. import java.util.Map;
  25. import java.util.Objects;

  26. import org.openspcoop2.core.constants.CostantiDB;
  27. import org.openspcoop2.core.controllo_traffico.constants.TipoPeriodoStatistico;
  28. import org.openspcoop2.message.constants.ServiceBinding;
  29. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationException;
  30. import org.openspcoop2.web.ctrlstat.servlet.ConsoleHelper;
  31. import org.openspcoop2.web.lib.mvc.Costanti;
  32. import org.openspcoop2.web.lib.mvc.DataElement;
  33. import org.openspcoop2.web.lib.mvc.DataElementInfo;
  34. import org.openspcoop2.web.lib.mvc.DataElementType;
  35. import org.openspcoop2.web.lib.mvc.PageData;
  36. import org.openspcoop2.web.lib.mvc.ServletUtils;

  37. /**
  38.  * Classe che contiene i parametri per il connettore Status
  39.  *
  40.  *
  41.  * @author Tommaso Burlon (tommaso.burlon@link.it)
  42.  * @author $Author$
  43.  * @version $Rev$, $Date$
  44.  */

  45. public class ConnettoreStatusParams {  
  46.     private boolean parsingErrors = false;
  47.    
  48.     // parametri connettore status
  49.     private String statusResponseType;
  50.     private Boolean testConnectivity;
  51.     private Boolean testStatistics;
  52.     private String period;
  53.     private Integer periodValue;
  54.     private Integer statLifetime;
  55.    
  56.     private static final String CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_MODI = "ModI";
  57.     private static final String CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_PERSONALIZZATO = "Personalizzato";
  58.    
  59.     private static final List<String> possibleResponseTypeValues = List.of(CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_MODI, CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_PERSONALIZZATO);
  60.     private static final List<String> possibleResponseTypeLabels = List.of(ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_MODI, ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_PERSONALIZZATO);
  61.     private static final List<String> possiblePersonalizedResponseTypeValues = List.of("vuoto", "xml", "json", "text");
  62.     private static final List<String> possiblePersonalizedResponseTypeLabels = List.of(ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_CUSTOM_EMPTY,
  63.             ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_CUSTOM_XML,
  64.             ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_CUSTOM_JSON,
  65.             ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_CUSTOM_TEXT);
  66.     private static final List<String> possiblePeriods = Arrays.asList(TipoPeriodoStatistico.toArray());
  67.    
  68.     private static final String SEPARATOR_VALORE_NON_CORRETTO = ", valore non corretto, possibli valori: ";
  69.    
  70.     private void sendError(PageData pd, String msg) {
  71.         if (pd != null)
  72.             pd.setMessage(msg);
  73.         this.parsingError(true);
  74.     }
  75.    
  76.    
  77.     /**
  78.      * Funzione che server per controllare e riempire i dati del connettore dai parametri
  79.      * @param helper, ConsoleHelper per ottenere tutti i parametri del connettore
  80.      * @param map, equivalente all'helper ma in formato Map
  81.      * @param serviceBinding, tipo di servizio utile per il checking
  82.      * @param pd, PageData utile per riportare gli errori di parsing alla console
  83.      * @throws DriverControlStationException
  84.      */
  85.     protected void fillFrom(ConsoleHelper helper, Map<String, String> map, ServiceBinding serviceBinding, PageData pd) throws DriverControlStationException {
  86.         String responseType = getParameter(helper, map, ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_RESPONSE_TYPE);
  87.         String personalizedType = getParameter(helper, map, ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_RESPONSE_PERSONALIZED);
  88.        
  89.         if (responseType != null && !possibleResponseTypeValues.contains(responseType))
  90.             sendError(pd, ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT + SEPARATOR_VALORE_NON_CORRETTO + String.join(",", possibleResponseTypeValues));
  91.         if (personalizedType != null && !possiblePersonalizedResponseTypeValues.contains(personalizedType))
  92.             sendError(pd, ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT + SEPARATOR_VALORE_NON_CORRETTO + String.join(",", possiblePersonalizedResponseTypeValues));
  93.        
  94.         String type = (responseType == null || responseType.equals(CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_MODI)) ? responseType : personalizedType;
  95.        
  96.         if (serviceBinding != null && serviceBinding.equals(ServiceBinding.SOAP) && type != null && !type.equals(CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_MODI))
  97.             sendError(pd, ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT + " valore non corretto per binding di tipo " + serviceBinding);
  98.            
  99.         String testConnectivityRaw = getParameter(helper, map, ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_TEST_CONNECTIVITY);
  100.         String testStatisticsRaw = getParameter(helper, map, ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_TEST_STATISTICS);
  101.        
  102.        
  103.         Integer periodValueParsed = null;
  104.         Integer statLifetimeParsed = null;
  105.         String periodRaw = null;
  106.         if (ServletUtils.isCheckBoxEnabled(testStatisticsRaw)) {
  107.             periodRaw = getParameter(helper, map, ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_PERIOD);
  108.            
  109.             if (periodRaw != null && !possiblePeriods.contains(periodRaw))
  110.                 sendError(pd, ConnettoriCostanti.LABEL_CONNETTORE_STATUS_PERIOD + SEPARATOR_VALORE_NON_CORRETTO + String.join(",", possiblePeriods));
  111.            
  112.             String periodValueRaw = getParameter(helper, map, ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_PERIOD_VALUE);
  113.             try {
  114.                 if (periodValueRaw != null) {
  115.                     periodValueParsed = Integer.parseInt(periodValueRaw);
  116.                     if (periodValueParsed <= 0)
  117.                         sendError(pd, ConnettoriCostanti.LABEL_CONNETTORE_STATUS_PERIOD + ", accetta solo valori > 0");
  118.                 }
  119.             } catch(NumberFormatException | NullPointerException e) {
  120.                 sendError(pd, ConnettoriCostanti.LABEL_CONNETTORE_STATUS_PERIOD + ", accetta solo valore interi");
  121.             }
  122.            
  123.             String statLifetimeRaw = getParameter(helper, map, ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_STAT_LIFETIME);
  124.             statLifetimeParsed = null;
  125.             try {
  126.                 if (statLifetimeRaw != null && !statLifetimeRaw.equals("")) {
  127.                     statLifetimeParsed = Integer.parseInt(statLifetimeRaw);
  128.                     if (statLifetimeParsed <= 0)
  129.                         sendError(pd, ConnettoriCostanti.LABEL_CONNETTORE_STATUS_STAT_LIFETIME + ", accetta solo valori > 0");
  130.                 }
  131.             } catch(NumberFormatException | NullPointerException e) {
  132.                 sendError(pd, ConnettoriCostanti.LABEL_CONNETTORE_STATUS_STAT_LIFETIME + ", accetta solo valore interi");
  133.             }
  134.         }
  135.        
  136.         this.statusResponseType(type)
  137.             .testConnectivity(testConnectivityRaw == null ? null : ServletUtils.isCheckBoxEnabled(testConnectivityRaw))
  138.             .period(periodRaw)
  139.             .periodValue(periodValueParsed)
  140.             .statLifetime(statLifetimeParsed)
  141.             .testStatistics(testStatisticsRaw == null ?  null : ServletUtils.isCheckBoxEnabled(testStatisticsRaw));
  142.     }
  143.    
  144.     public void updateFromDB(Map<String, String> map) {
  145.         if (map == null)
  146.             return;
  147.        
  148.         String type = map.get(CostantiDB.CONNETTORE_STATUS_RESPONSE_TYPE);
  149.         if (type != null && getStatusResponseType() == null)
  150.             this.statusResponseType(map.get(CostantiDB.CONNETTORE_STATUS_RESPONSE_TYPE));
  151.        
  152.         String connectivity = map.get(CostantiDB.CONNETTORE_STATUS_TEST_CONNECTIVITY);
  153.         if (connectivity != null && isTestConnectivity() == null)
  154.             this.testConnectivity(Boolean.valueOf(connectivity));
  155.        
  156.         String periodRaw = map.get(CostantiDB.CONNETTORE_STATUS_STATISTICAL_PERIOD);
  157.         if (periodRaw != null && getPeriod() == null)
  158.             this.period(periodRaw);
  159.        
  160.         String periodValueRaw = map.get(CostantiDB.CONNETTORE_STATUS_STATISTICAL_PERIOD_VALUE);
  161.         if (periodValueRaw != null && getPeriodValue() == null)
  162.             this.periodValue(Integer.valueOf(periodValueRaw));
  163.        
  164.         String statLifetimeRaw = map.get(CostantiDB.CONNETTORE_STATUS_STAT_LIFETIME);
  165.         if (statLifetimeRaw != null && getStatLifetime() == null)
  166.             this.statLifetime(Integer.valueOf(statLifetimeRaw));
  167.        
  168.         if (this.isTestStatistics() == null)
  169.             this.testStatistics(periodRaw != null);
  170.     }
  171.    
  172.     /**
  173.      * Salva i dati nel DB
  174.      * @param config connettore lato config
  175.      * @param registry connettore lato registry
  176.      */
  177.     protected void fillTo(org.openspcoop2.core.config.Connettore config, org.openspcoop2.core.registry.Connettore registry) {
  178.         this.setCustom(config, registry, true);
  179.         this.setProperty(config, registry, CostantiDB.CONNETTORE_STATUS_RESPONSE_TYPE, getStatusResponseType());
  180.         this.setProperty(config, registry, CostantiDB.CONNETTORE_STATUS_TEST_CONNECTIVITY, Boolean.toString(Objects.requireNonNullElse(isTestConnectivity(), false)));
  181.        
  182.         if (this.isTestStatistics() == Boolean.TRUE) {
  183.             this.setProperty(config, registry, CostantiDB.CONNETTORE_STATUS_STATISTICAL_PERIOD, getPeriod());
  184.             this.setProperty(config, registry, CostantiDB.CONNETTORE_STATUS_STATISTICAL_PERIOD_VALUE, getPeriodValue().toString());
  185.        
  186.             if (this.getStatLifetime() != null) {
  187.                 this.setProperty(config, registry, CostantiDB.CONNETTORE_STATUS_STAT_LIFETIME, getStatLifetime().toString());
  188.             }
  189.         }

  190.     }

  191.     /**
  192.      * Funzione che serve a riempire le maschere nella console
  193.      * @param dati, tutti gli elementi appartenenti alla mascher
  194.      * @param serviceBinding (SOAP, REST)
  195.      * @param postBackViaPost se eseguire il postBack utilizzando Post
  196.      * @return Ritorna la lista di dati aggiornata (ridondante)
  197.      */
  198.     public List<DataElement> getDati(List<DataElement> dati, ServiceBinding serviceBinding, boolean postBackViaPost) {
  199.        
  200.         // elementi per impostare il response type
  201.         DataElement responseTypeSelect = new DataElement();
  202.         responseTypeSelect.setType(DataElementType.SELECT);
  203.         responseTypeSelect.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT);
  204.         responseTypeSelect.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_RESPONSE_TYPE);
  205.         responseTypeSelect.setValues(possibleResponseTypeValues);      
  206.         responseTypeSelect.setLabels(possibleResponseTypeLabels);
  207.        
  208.         DataElementInfo dInfo = new DataElementInfo(ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT);
  209.         dInfo.setHeaderBody(ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO);
  210.         dInfo.setListBody(ConnettoriCostanti.getLabelConnettoreResponseInputDataElementInfoFormati());
  211.         responseTypeSelect.setInfo(dInfo);
  212.        
  213.         DataElement personalizedResponseSelect = new DataElement();
  214.         personalizedResponseSelect.setValues(possiblePersonalizedResponseTypeValues);
  215.         personalizedResponseSelect.setLabels(possiblePersonalizedResponseTypeLabels);
  216.         personalizedResponseSelect.setSelected(possiblePersonalizedResponseTypeValues.get(0));
  217.         personalizedResponseSelect.setValue(possiblePersonalizedResponseTypeValues.get(0));
  218.         personalizedResponseSelect.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_RESPONSE_PERSONALIZED);
  219.        
  220.         dInfo = new DataElementInfo(ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT);
  221.         dInfo.setHeaderBody(ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO);
  222.         dInfo.setListBody(ConnettoriCostanti.getLabelConnettoreResponseInputDataElementInfoFormatiCustom());
  223.         personalizedResponseSelect.setInfo(dInfo);
  224.        
  225.         if (getStatusResponseType() != null && !getStatusResponseType().equals(CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_MODI)) {
  226.             personalizedResponseSelect.setType(DataElementType.SELECT);
  227.             personalizedResponseSelect.setSelected(getStatusResponseType());
  228.             personalizedResponseSelect.setValue(getStatusResponseType());
  229.             responseTypeSelect.setSelected(CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_PERSONALIZZATO);
  230.         } else {
  231.             personalizedResponseSelect.setType(DataElementType.HIDDEN);
  232.             responseTypeSelect.setSelected(CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_MODI);
  233.         }
  234.        
  235.         if (serviceBinding != null && serviceBinding.equals(ServiceBinding.SOAP)) {
  236.             personalizedResponseSelect.setType(DataElementType.HIDDEN);
  237.             responseTypeSelect.setType(DataElementType.TEXT);
  238.             responseTypeSelect.setSelected(CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_MODI);
  239.             responseTypeSelect.setValue(CONNETTORE_RESPONSE_INPUT_DATA_ELEMENT_INFO_FORMATO_MODI);
  240.         }
  241.        
  242.        
  243.         // Verifiche
  244.         DataElement verificheTitle = new DataElement();
  245.         verificheTitle.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_VERIFICHE);
  246.         verificheTitle.setType(DataElementType.SUBTITLE);
  247.        
  248.        
  249.         // elementi per impostare la verifica connettivita
  250.         DataElement connectivityCheckbox = new DataElement();
  251.         connectivityCheckbox.setLabelRight(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_TEST_CONNECTIVITY);
  252.         connectivityCheckbox.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_TEST_CONNECTIVITY);
  253.         connectivityCheckbox.setType(DataElementType.CHECKBOX);
  254.         connectivityCheckbox.setValue(Objects.requireNonNullElse(isTestConnectivity(), Boolean.FALSE).booleanValue() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  255.         connectivityCheckbox.setSelected(Objects.requireNonNullElse(isTestConnectivity(), Boolean.FALSE).booleanValue());
  256.        
  257.         dInfo = new DataElementInfo(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_TEST_CONNECTIVITY);
  258.         dInfo.setBody(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_TEST_CONNECTIVITY_DATA_ELEMENT_INFO);
  259.         connectivityCheckbox.setInfo(dInfo);

  260.                
  261.        
  262.         // elementi per impostare la verifica statistica
  263.         DataElement statCheckbox = new DataElement();
  264.         statCheckbox.setLabelRight(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_TEST_STATISTICS);
  265.         statCheckbox.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_TEST_STATISTICS);
  266.         statCheckbox.setType(DataElementType.CHECKBOX);
  267.         statCheckbox.setValue(this.isTestStatistics() == Boolean.TRUE ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  268.         statCheckbox.setSelected(this.isTestStatistics() == Boolean.TRUE);
  269.        
  270.         dInfo = new DataElementInfo(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_TEST_STATISTICS);
  271.         dInfo.setBody(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_TEST_STATISTICS_DATA_ELEMENT_INFO);
  272.         statCheckbox.setInfo(dInfo);
  273.        
  274.         if(postBackViaPost) {
  275.             responseTypeSelect.setPostBack_viaPOST(true);
  276.             statCheckbox.setPostBack_viaPOST(true);
  277.         }
  278.         else {
  279.             responseTypeSelect.setPostBack(true);
  280.             statCheckbox.setPostBack(true);
  281.         }
  282.        
  283.        
  284.         DataElement intervalTitle = new DataElement();
  285.         intervalTitle.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_OBSERVATION_INTERVAL);
  286.         intervalTitle.setType(DataElementType.SUBTITLE);
  287.        
  288.         dInfo = new DataElementInfo(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_OBSERVATION_INTERVAL);
  289.         dInfo.setBody(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_OBSERVATION_INTERVAL_DATA_ELEMENT_INFO);
  290.         intervalTitle.setInfo(dInfo);
  291.        
  292.         DataElement periodElement = new DataElement();
  293.         periodElement.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_PERIOD);
  294.         periodElement.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_PERIOD);
  295.         periodElement.setValues(possiblePeriods);
  296.         periodElement.setValue(Objects.requireNonNullElse(getPeriod(), TipoPeriodoStatistico.GIORNALIERO.getValue()));
  297.         periodElement.setSelected(getPeriod());
  298.         periodElement.setType(DataElementType.SELECT);
  299.            
  300.         DataElement periodValueElement = new DataElement();
  301.         periodValueElement.setRequired(true);
  302.         periodValueElement.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_OBSERVATION_INTERVAL);
  303.         periodValueElement.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_PERIOD_VALUE);
  304.         periodValueElement.setType(DataElementType.NUMBER);
  305.         periodValueElement.setValue(Objects.requireNonNullElse(getPeriodValue(), 1).toString());
  306.        
  307.         DataElement lifetimeElement = new DataElement();
  308.         lifetimeElement.setType(DataElementType.TEXT_EDIT);
  309.         lifetimeElement.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_STAT_LIFETIME);
  310.         lifetimeElement.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_STATUS_STAT_LIFETIME);
  311.         lifetimeElement.setValue(this.getStatLifetime() == null ? "" : this.getStatLifetime().toString());
  312.            
  313.         dInfo = new DataElementInfo(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_STAT_LIFETIME);
  314.         dInfo.setBody(ConnettoriCostanti.LABEL_CONNETTORE_STATUS_STAT_LIFETIME_DATA_ELEMENT_INFO);
  315.         lifetimeElement.setInfo(dInfo);
  316.        
  317.         if (this.isTestStatistics() != Boolean.TRUE) {
  318.             intervalTitle.setType(DataElementType.HIDDEN);
  319.             periodElement.setType(DataElementType.HIDDEN);
  320.             periodValueElement.setType(DataElementType.HIDDEN);
  321.             lifetimeElement.setType(DataElementType.HIDDEN);
  322.         }
  323.        
  324.         dati.add(responseTypeSelect);
  325.         dati.add(personalizedResponseSelect);
  326.         dati.add(verificheTitle);
  327.         dati.add(connectivityCheckbox);
  328.         dati.add(statCheckbox);
  329.         dati.add(intervalTitle);
  330.         dati.add(periodElement);
  331.         dati.add(periodValueElement);
  332.         dati.add(lifetimeElement);
  333.        
  334.         return dati;
  335.     }
  336.    
  337.    
  338.    
  339.     // funzioni per astrarre concettor di ConsoleHelper e Mappa
  340.     private static String getParameter(ConsoleHelper helper, Map<String, String> map, String key) throws DriverControlStationException {
  341.         return helper == null ? map.get(key) : helper.getParameter(key);
  342.     }
  343.    
  344.     public static ConnettoreStatusParams fillFrom(ConsoleHelper helper) throws DriverControlStationException {
  345.         ConnettoreStatusParams connettoreStatusParams = new ConnettoreStatusParams();
  346.         if (helper != null)
  347.             connettoreStatusParams.fillFrom(helper, null, null, null);
  348.         return connettoreStatusParams;
  349.     }
  350.    
  351.     public static ConnettoreStatusParams check(ConsoleHelper helper, ServiceBinding serviceBinding, PageData pd) throws DriverControlStationException {
  352.         ConnettoreStatusParams connettoreStatusParams = new ConnettoreStatusParams();
  353.         if (helper != null)
  354.             connettoreStatusParams.fillFrom(helper, null, serviceBinding, pd);
  355.         return connettoreStatusParams;
  356.     }
  357.    
  358.     public static ConnettoreStatusParams fillFrom(Map<String, String> map) throws DriverControlStationException {
  359.         ConnettoreStatusParams connettoreStatusParams = new ConnettoreStatusParams();
  360.         if (map != null)
  361.             connettoreStatusParams.fillFrom(null, map, null, null);
  362.         return connettoreStatusParams;
  363.     }
  364.    
  365.     public static ConnettoreStatusParams check(Map<String, String> map, ServiceBinding serviceBinding, PageData pd) throws DriverControlStationException {
  366.         ConnettoreStatusParams connettoreStatusParams = new ConnettoreStatusParams();
  367.         if (map != null)
  368.             connettoreStatusParams.fillFrom(null, map, serviceBinding, pd);
  369.         return connettoreStatusParams;
  370.     }
  371.    
  372.    
  373.     // funzioni per astrarre config e registry
  374.     private void setCustom(org.openspcoop2.core.config.Connettore config, org.openspcoop2.core.registry.Connettore registry, boolean value) {
  375.         if (config != null) {
  376.             config.setCustom(value);
  377.         }
  378.        
  379.         if (registry != null) {
  380.             registry.setCustom(value);
  381.         }
  382.     }
  383.    
  384.     private void setProperty(org.openspcoop2.core.config.Connettore config, org.openspcoop2.core.registry.Connettore registry, String key, String value) {
  385.         if (config != null) {
  386.             org.openspcoop2.core.config.Property prop = new org.openspcoop2.core.config.Property();
  387.             prop.setNome(key);
  388.             prop.setValore(value);
  389.             config.addProperty(prop);
  390.         }
  391.        
  392.         if (registry != null) {
  393.             org.openspcoop2.core.registry.Property prop = new org.openspcoop2.core.registry.Property();
  394.             prop.setNome(key);
  395.             prop.setValore(value);
  396.             registry.addProperty(prop);
  397.         }
  398.     }
  399.    
  400.     public void fillConnettoreConfig(org.openspcoop2.core.config.Connettore connettore) {
  401.         this.fillTo(connettore, null);      
  402.     }
  403.    
  404.     public void fillConnettoreRegistry(org.openspcoop2.core.registry.Connettore connettore) {
  405.         this.fillTo(null, connettore);
  406.     }
  407.    
  408.     // setters and getters
  409.    
  410.     public void addDati(List<DataElement> dati, ServiceBinding serviceBinding, boolean postBackViaPost) {
  411.         getDati(dati, serviceBinding, postBackViaPost);
  412.     }
  413.    
  414.     public void addDatiHidden(List<DataElement> dati, ServiceBinding serviceBinding) {
  415.         List<DataElement> newDati = getDati(new ArrayList<>(), serviceBinding, true);
  416.         for (DataElement de : newDati) {
  417.             de.setType(DataElementType.HIDDEN);
  418.             dati.add(de);
  419.         }
  420.     }
  421.    
  422.     public ConnettoreStatusParams statusResponseType(String statusResponseType) {
  423.         this.statusResponseType = statusResponseType;
  424.         return this;
  425.     }
  426.    
  427.     public String getStatusResponseType() {
  428.         return this.statusResponseType;
  429.     }
  430.    
  431.     public ConnettoreStatusParams testConnectivity(Boolean testConnectivity) {
  432.         this.testConnectivity = testConnectivity;
  433.         return this;
  434.     }
  435.    
  436.     public Boolean isTestConnectivity() {
  437.         return this.testConnectivity;
  438.     }
  439.    
  440.     public ConnettoreStatusParams testStatistics(Boolean testStatistics) {
  441.         this.testStatistics = testStatistics;
  442.         return this;
  443.     }
  444.    
  445.     public Boolean isTestStatistics() {
  446.         return this.testStatistics;
  447.     }
  448.    
  449.     public ConnettoreStatusParams period(String period) {
  450.         this.period = period;
  451.         return this;
  452.     }
  453.    
  454.     public String getPeriod() {
  455.         return this.period;
  456.     }
  457.    
  458.     public ConnettoreStatusParams periodValue(Integer periodValue) {
  459.         this.periodValue = periodValue;
  460.         return this;
  461.     }
  462.    
  463.     public Integer getPeriodValue() {
  464.         return this.periodValue;
  465.     }
  466.    
  467.     private ConnettoreStatusParams parsingError(boolean parsingErrors) {
  468.         this.parsingErrors = parsingErrors;
  469.         return this;
  470.     }
  471.    
  472.     public boolean getParsingErrors() {
  473.         return this.parsingErrors;
  474.     }
  475.    
  476.     public ConnettoreStatusParams statLifetime(Integer statLifetime) {
  477.         this.statLifetime = statLifetime;
  478.         return this;
  479.     }
  480.    
  481.     public Integer getStatLifetime() {
  482.         return this.statLifetime;
  483.     }
  484.        
  485. }