JDBCConfigurazioneGeneraleServiceImpl.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.core.controllo_traffico.dao.jdbc;

  21. import java.sql.Connection;

  22. import org.openspcoop2.utils.sql.ISQLQueryObject;

  23. import org.slf4j.Logger;

  24. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceCRUDSingleObject;
  25. import org.openspcoop2.generic_project.beans.UpdateField;
  26. import org.openspcoop2.generic_project.beans.UpdateModel;

  27. import org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities;
  28. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject;
  29. import org.openspcoop2.generic_project.exception.NotFoundException;
  30. import org.openspcoop2.generic_project.exception.NotImplementedException;
  31. import org.openspcoop2.generic_project.exception.ServiceException;
  32. import org.openspcoop2.generic_project.expression.IExpression;

  33. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  34. import org.openspcoop2.core.controllo_traffico.Cache;
  35. import org.openspcoop2.core.controllo_traffico.ConfigurazioneControlloTraffico;
  36. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  37. import org.openspcoop2.core.controllo_traffico.ConfigurazioneRateLimiting;
  38. import org.openspcoop2.core.controllo_traffico.ConfigurazioneRateLimitingProprieta;
  39. import org.openspcoop2.core.controllo_traffico.TempiRispostaErogazione;
  40. import org.openspcoop2.core.controllo_traffico.TempiRispostaFruizione;

  41. /**    
  42.  * JDBCConfigurazioneGeneraleServiceImpl
  43.  *
  44.  * @author Poli Andrea (poli@link.it)
  45.  * @author $Author$
  46.  * @version $Rev$, $Date$
  47.  */
  48. public class JDBCConfigurazioneGeneraleServiceImpl extends JDBCConfigurazioneGeneraleServiceSearchImpl
  49.     implements IJDBCServiceCRUDSingleObject<ConfigurazioneGenerale, JDBCServiceManager> {

  50.     @Override
  51.     public void create(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneGenerale configurazioneGenerale, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException,ServiceException,Exception {

  52.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  53.                 new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  54.        
  55.         ISQLQueryObject sqlQueryObjectInsert = sqlQueryObject.newSQLQueryObject();
  56.                


  57.         // Object configurazioneGenerale.getControlloTraffico()
  58.         sqlQueryObjectInsert.addInsertTable(this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO));
  59.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_ENABLED,false),"?");
  60.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_WARNING_ONLY,false),"?");
  61.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_SOGLIA,false),"?");
  62.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE,false),"?");
  63.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE_INCLUDI_DESCRIZIONE,false),"?");
  64.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_ENABLED,false),"?");
  65.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_THRESHOLD,false),"?");
  66.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.CONNECTION_TIMEOUT,false),"?");
  67.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.READ_TIMEOUT,false),"?");
  68.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.TEMPO_MEDIO_RISPOSTA,false),"?");
  69.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.CONNECTION_TIMEOUT,false),"?");
  70.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.READ_TIMEOUT,false),"?");
  71.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.TEMPO_MEDIO_RISPOSTA,false),"?");
  72.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE,false),"?");
  73.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE_INCLUDI_DESCRIZIONE,false),"?");
  74.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.CACHE,false),"?");
  75.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.SIZE,false),"?");
  76.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.ALGORITHM,false),"?");
  77.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.IDLE_TIME,false),"?");
  78.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.LIFE_TIME,false),"?");

  79.         // Insert configurazioneGenerale
  80.         org.openspcoop2.utils.jdbc.IKeyGeneratorObject keyGenerator = this.getConfigurazioneGeneraleFetch().getKeyGeneratorObject(ConfigurazioneGenerale.model());
  81.         long id = jdbcUtilities.insertAndReturnGeneratedKey(sqlQueryObjectInsert, keyGenerator, jdbcProperties.isShowSql(),
  82.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getControlloTraffico().getControlloMaxThreadsEnabled(),ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_ENABLED.getFieldType()),
  83.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getControlloTraffico().getControlloMaxThreadsWarningOnly(),ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_WARNING_ONLY.getFieldType()),
  84.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getControlloTraffico().getControlloMaxThreadsSoglia(),ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_SOGLIA.getFieldType()),
  85.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getControlloTraffico().getControlloMaxThreadsTipoErrore(),ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE.getFieldType()),
  86.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getControlloTraffico().getControlloMaxThreadsTipoErroreIncludiDescrizione(),ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE_INCLUDI_DESCRIZIONE.getFieldType()),
  87.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getControlloTraffico().getControlloCongestioneEnabled(),ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_ENABLED.getFieldType()),
  88.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getControlloTraffico().getControlloCongestioneThreshold(),ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_THRESHOLD.getFieldType()),
  89.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getTempiRispostaFruizione().getConnectionTimeout(),ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.CONNECTION_TIMEOUT.getFieldType()),
  90.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getTempiRispostaFruizione().getReadTimeout(),ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.READ_TIMEOUT.getFieldType()),
  91.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getTempiRispostaFruizione().getTempoMedioRisposta(),ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.TEMPO_MEDIO_RISPOSTA.getFieldType()),
  92.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getTempiRispostaErogazione().getConnectionTimeout(),ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.CONNECTION_TIMEOUT.getFieldType()),
  93.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getTempiRispostaErogazione().getReadTimeout(),ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.READ_TIMEOUT.getFieldType()),
  94.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getTempiRispostaErogazione().getTempoMedioRisposta(),ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.TEMPO_MEDIO_RISPOSTA.getFieldType()),
  95.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getRateLimiting().getTipoErrore(),ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE.getFieldType()),
  96.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getRateLimiting().getTipoErroreIncludiDescrizione(),ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE_INCLUDI_DESCRIZIONE.getFieldType()),
  97.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getCache().getCache(),ConfigurazioneGenerale.model().CACHE.CACHE.getFieldType()),
  98.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getCache().getSize(),ConfigurazioneGenerale.model().CACHE.SIZE.getFieldType()),
  99.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getCache().getAlgorithm(),ConfigurazioneGenerale.model().CACHE.ALGORITHM.getFieldType()),
  100.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getCache().getIdleTime(),ConfigurazioneGenerale.model().CACHE.IDLE_TIME.getFieldType()),
  101.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneGenerale.getCache().getLifeTime(),ConfigurazioneGenerale.model().CACHE.LIFE_TIME.getFieldType())
  102.         );
  103.         configurazioneGenerale.setId(id);

  104.         if(configurazioneGenerale.getRateLimiting().sizeProprietaList()>0) {
  105.             for (ConfigurazioneRateLimitingProprieta prop : configurazioneGenerale.getRateLimiting().getProprietaList()) {
  106.                 this.getServiceManager().getConfigurazioneRateLimitingProprietaService().create(prop);
  107.             }
  108.         }
  109.        
  110.     }

  111.     @Override
  112.     public void update(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneGenerale configurazioneGenerale, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  113.        

  114.    
  115.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  116.                 new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  117.        
  118.         ISQLQueryObject sqlQueryObjectInsert = sqlQueryObject.newSQLQueryObject();
  119.         ISQLQueryObject sqlQueryObjectDelete = sqlQueryObjectInsert.newSQLQueryObject();
  120.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObjectDelete.newSQLQueryObject();
  121.         ISQLQueryObject sqlQueryObjectUpdate = sqlQueryObjectGet.newSQLQueryObject();
  122.        

  123.         ConfigurazioneControlloTraffico configurazioneGenerale_controlloTraffico = configurazioneGenerale.getControlloTraffico();

  124.         // Object configurazioneGenerale_controlloTraffico
  125.         sqlQueryObjectUpdate.setANDLogicOperator(true);
  126.         sqlQueryObjectUpdate.addUpdateTable(this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO));
  127.         boolean isUpdate = true;
  128.         java.util.List<JDBCObject> lstObjects = new java.util.ArrayList<>();
  129.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_ENABLED,false), "?");
  130.         lstObjects.add(new JDBCObject(configurazioneGenerale_controlloTraffico.getControlloMaxThreadsEnabled(), ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_ENABLED.getFieldType()));
  131.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_WARNING_ONLY,false), "?");
  132.         lstObjects.add(new JDBCObject(configurazioneGenerale_controlloTraffico.getControlloMaxThreadsWarningOnly(), ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_WARNING_ONLY.getFieldType()));
  133.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_SOGLIA,false), "?");
  134.         lstObjects.add(new JDBCObject(configurazioneGenerale_controlloTraffico.getControlloMaxThreadsSoglia(), ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_SOGLIA.getFieldType()));
  135.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE,false), "?");
  136.         lstObjects.add(new JDBCObject(configurazioneGenerale_controlloTraffico.getControlloMaxThreadsTipoErrore(), ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE.getFieldType()));
  137.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE_INCLUDI_DESCRIZIONE,false), "?");
  138.         lstObjects.add(new JDBCObject(configurazioneGenerale_controlloTraffico.getControlloMaxThreadsTipoErroreIncludiDescrizione(), ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE_INCLUDI_DESCRIZIONE.getFieldType()));
  139.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_ENABLED,false), "?");
  140.         lstObjects.add(new JDBCObject(configurazioneGenerale_controlloTraffico.getControlloCongestioneEnabled(), ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_ENABLED.getFieldType()));
  141.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_THRESHOLD,false), "?");
  142.         lstObjects.add(new JDBCObject(configurazioneGenerale_controlloTraffico.getControlloCongestioneThreshold(), ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_THRESHOLD.getFieldType()));
  143.         TempiRispostaFruizione configurazioneGenerale_tempiRispostaFruizione = configurazioneGenerale.getTempiRispostaFruizione();
  144.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.CONNECTION_TIMEOUT,false), "?");
  145.         lstObjects.add(new JDBCObject(configurazioneGenerale_tempiRispostaFruizione.getConnectionTimeout(), ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.CONNECTION_TIMEOUT.getFieldType()));
  146.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.READ_TIMEOUT,false), "?");
  147.         lstObjects.add(new JDBCObject(configurazioneGenerale_tempiRispostaFruizione.getReadTimeout(), ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.READ_TIMEOUT.getFieldType()));
  148.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.TEMPO_MEDIO_RISPOSTA,false), "?");
  149.         lstObjects.add(new JDBCObject(configurazioneGenerale_tempiRispostaFruizione.getTempoMedioRisposta(), ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.TEMPO_MEDIO_RISPOSTA.getFieldType()));
  150.         TempiRispostaErogazione configurazioneGenerale_tempiRispostaErogazione = configurazioneGenerale.getTempiRispostaErogazione();
  151.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.CONNECTION_TIMEOUT,false), "?");
  152.         lstObjects.add(new JDBCObject(configurazioneGenerale_tempiRispostaErogazione.getConnectionTimeout(), ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.CONNECTION_TIMEOUT.getFieldType()));
  153.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.READ_TIMEOUT,false), "?");
  154.         lstObjects.add(new JDBCObject(configurazioneGenerale_tempiRispostaErogazione.getReadTimeout(), ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.READ_TIMEOUT.getFieldType()));
  155.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.TEMPO_MEDIO_RISPOSTA,false), "?");
  156.         lstObjects.add(new JDBCObject(configurazioneGenerale_tempiRispostaErogazione.getTempoMedioRisposta(), ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.TEMPO_MEDIO_RISPOSTA.getFieldType()));
  157.         ConfigurazioneRateLimiting configurazioneGenerale_rateLimiting = configurazioneGenerale.getRateLimiting();
  158.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE,false), "?");
  159.         lstObjects.add(new JDBCObject(configurazioneGenerale_rateLimiting.getTipoErrore(), ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE.getFieldType()));
  160.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE_INCLUDI_DESCRIZIONE,false), "?");
  161.         lstObjects.add(new JDBCObject(configurazioneGenerale_rateLimiting.getTipoErroreIncludiDescrizione(), ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE_INCLUDI_DESCRIZIONE.getFieldType()));
  162.         Cache configurazioneGenerale_cache = configurazioneGenerale.getCache();
  163.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.CACHE,false), "?");
  164.         lstObjects.add(new JDBCObject(configurazioneGenerale_cache!=null ? configurazioneGenerale_cache.getCache() : false, ConfigurazioneGenerale.model().CACHE.CACHE.getFieldType()));
  165.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.SIZE,false), "?");
  166.         lstObjects.add(new JDBCObject(configurazioneGenerale_cache!=null ? configurazioneGenerale_cache.getSize() : null, ConfigurazioneGenerale.model().CACHE.SIZE.getFieldType()));
  167.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.ALGORITHM,false), "?");
  168.         lstObjects.add(new JDBCObject(configurazioneGenerale_cache!=null ? configurazioneGenerale_cache.getAlgorithm() : null, ConfigurazioneGenerale.model().CACHE.ALGORITHM.getFieldType()));
  169.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.IDLE_TIME,false), "?");
  170.         lstObjects.add(new JDBCObject(configurazioneGenerale_cache!=null ? configurazioneGenerale_cache.getIdleTime() : null, ConfigurazioneGenerale.model().CACHE.IDLE_TIME.getFieldType()));
  171.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.LIFE_TIME,false), "?");
  172.         lstObjects.add(new JDBCObject(configurazioneGenerale_cache!=null ? configurazioneGenerale_cache.getLifeTime() : null, ConfigurazioneGenerale.model().CACHE.LIFE_TIME.getFieldType()));

  173.         if(isUpdate) {
  174.             // Update configurazioneGenerale
  175.             jdbcUtilities.executeUpdate(sqlQueryObjectUpdate.createSQLUpdate(), jdbcProperties.isShowSql(),
  176.                 lstObjects.toArray(new JDBCObject[]{}));
  177.         }

  178.         this.getServiceManager().getConfigurazioneRateLimitingProprietaService().deleteAll();
  179.         if(configurazioneGenerale.getRateLimiting().sizeProprietaList()>0) {
  180.             for (ConfigurazioneRateLimitingProprieta prop : configurazioneGenerale.getRateLimiting().getProprietaList()) {
  181.                 this.getServiceManager().getConfigurazioneRateLimitingProprietaService().create(prop);
  182.             }
  183.         }

  184.     }
  185.    
  186.     @Override
  187.     public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, UpdateField ... updateFields) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  188.        
  189.         GenericJDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject,
  190.                 this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model()),
  191.                 this.getMapTableToPKColumnEngine(),
  192.                 this.getRootTablePrimaryKeyValuesEngine(jdbcProperties, log, connection, sqlQueryObject),
  193.                 this.getConfigurazioneGeneraleFieldConverter(), this, null, updateFields);
  194.     }
  195.    
  196.     @Override
  197.     public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IExpression condition, UpdateField ... updateFields) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  198.        
  199.         GenericJDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject,
  200.                 this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model()),
  201.                 this.getMapTableToPKColumnEngine(),
  202.                 this.getRootTablePrimaryKeyValuesEngine(jdbcProperties, log, connection, sqlQueryObject),
  203.                 this.getConfigurazioneGeneraleFieldConverter(), this, condition, updateFields);
  204.     }
  205.    
  206.     @Override
  207.     public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, UpdateModel ... updateModels) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  208.        
  209.         GenericJDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject,
  210.                 this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model()),
  211.                 this.getMapTableToPKColumnEngine(),
  212.                 this.getRootTablePrimaryKeyValuesEngine(jdbcProperties, log, connection, sqlQueryObject),
  213.                 this.getConfigurazioneGeneraleFieldConverter(), this, updateModels);
  214.     }  
  215.    
  216.    
  217.     @Override
  218.     public void updateOrCreate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneGenerale configurazioneGenerale, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException,ServiceException,Exception {
  219.    
  220.         if(this.exists(jdbcProperties, log, connection, sqlQueryObject)) {
  221.             this.update(jdbcProperties, log, connection, sqlQueryObject, configurazioneGenerale,idMappingResolutionBehaviour);
  222.         } else {
  223.             this.create(jdbcProperties, log, connection, sqlQueryObject, configurazioneGenerale,idMappingResolutionBehaviour);
  224.         }
  225.        
  226.     }
  227.    
  228.    
  229.     @Override
  230.     public void delete(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneGenerale configurazioneGenerale) throws NotImplementedException,ServiceException,Exception {
  231.        
  232.         this.deleteEngine(jdbcProperties, log, connection, sqlQueryObject);
  233.     }

  234.     private void deleteEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject) throws NotImplementedException,ServiceException,Exception {
  235.    
  236.         // Used by internal elements (if exists)
  237.         @SuppressWarnings("unused")
  238.         Long id = null;
  239.         try{
  240.             id = this.get(jdbcProperties, log, connection, sqlQueryObject,null).getId();        
  241.         }catch(NotFoundException notFound){
  242.             return;
  243.         }

  244.         this.getServiceManager().getConfigurazioneRateLimitingProprietaService().deleteAll();
  245.        
  246.        
  247.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  248.                 new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  249.        
  250.         ISQLQueryObject sqlQueryObjectDelete = sqlQueryObject.newSQLQueryObject();
  251.        

  252.         // Object configurazioneGenerale_controlloTraffico_toDelete
  253.         sqlQueryObjectDelete.setANDLogicOperator(true);
  254.         sqlQueryObjectDelete.addDeleteTable(this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO));

  255.         // Delete configurazioneGenerale
  256.         jdbcUtilities.execute(sqlQueryObjectDelete.createSQLDelete(), jdbcProperties.isShowSql());

  257.     }

  258.    


  259.     // -- DB
  260.    
  261.     @Override
  262.     public void deleteById(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws ServiceException, NotImplementedException, Exception {
  263.         this.deleteEngine(jdbcProperties, log, connection, sqlQueryObject); // long id ignored, object with single instance
  264.     }
  265.    
  266.     @Override
  267.     public int nativeUpdate(JDBCServiceManagerProperties jdbcProperties, Logger log,Connection connection,ISQLQueryObject sqlObject, String sql,Object ... param) throws ServiceException,NotImplementedException, Exception {
  268.    
  269.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.nativeUpdate(jdbcProperties, log, connection, sqlObject,
  270.                                                                                             sql,param);
  271.    
  272.     }
  273. }