JDBCConfigurazioneGeneraleServiceSearchImpl.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 java.util.ArrayList;
  23. import java.util.List;
  24. import java.util.Map;

  25. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  26. import org.openspcoop2.core.controllo_traffico.ConfigurazioneRateLimiting;
  27. import org.openspcoop2.core.controllo_traffico.ConfigurazioneRateLimitingProprieta;
  28. import org.openspcoop2.core.controllo_traffico.dao.jdbc.converter.ConfigurazioneGeneraleFieldConverter;
  29. import org.openspcoop2.core.controllo_traffico.dao.jdbc.fetch.ConfigurazioneGeneraleFetch;
  30. import org.openspcoop2.generic_project.beans.CustomField;
  31. import org.openspcoop2.generic_project.beans.IField;
  32. import org.openspcoop2.generic_project.beans.InUse;
  33. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceSearchSingleObject;
  34. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  35. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;
  36. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  37. import org.openspcoop2.generic_project.dao.jdbc.utils.IJDBCFetch;
  38. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject;
  39. import org.openspcoop2.generic_project.exception.MultipleResultException;
  40. import org.openspcoop2.generic_project.exception.NotFoundException;
  41. import org.openspcoop2.generic_project.exception.NotImplementedException;
  42. import org.openspcoop2.generic_project.exception.ServiceException;
  43. import org.openspcoop2.generic_project.expression.IExpression;
  44. import org.openspcoop2.generic_project.expression.IPaginatedExpression;
  45. import org.openspcoop2.generic_project.expression.impl.sql.ISQLFieldConverter;
  46. import org.openspcoop2.generic_project.utils.UtilsTemplate;
  47. import org.openspcoop2.utils.sql.ISQLQueryObject;
  48. import org.slf4j.Logger;

  49. /**    
  50.  * JDBCConfigurazioneGeneraleServiceSearchImpl
  51.  *
  52.  * @author Poli Andrea (poli@link.it)
  53.  * @author $Author$
  54.  * @version $Rev$, $Date$
  55.  */
  56. public class JDBCConfigurazioneGeneraleServiceSearchImpl implements IJDBCServiceSearchSingleObject<ConfigurazioneGenerale, JDBCServiceManager> {

  57.     private ConfigurazioneGeneraleFieldConverter _configurazioneGeneraleFieldConverter = null;
  58.     public ConfigurazioneGeneraleFieldConverter getConfigurazioneGeneraleFieldConverter() {
  59.         if(this._configurazioneGeneraleFieldConverter==null){
  60.             this._configurazioneGeneraleFieldConverter = new ConfigurazioneGeneraleFieldConverter(this.jdbcServiceManager.getJdbcProperties().getDatabaseType());
  61.         }      
  62.         return this._configurazioneGeneraleFieldConverter;
  63.     }
  64.     @Override
  65.     public ISQLFieldConverter getFieldConverter() {
  66.         return this.getConfigurazioneGeneraleFieldConverter();
  67.     }
  68.    
  69.     private ConfigurazioneGeneraleFetch configurazioneGeneraleFetch = new ConfigurazioneGeneraleFetch();
  70.     public ConfigurazioneGeneraleFetch getConfigurazioneGeneraleFetch() {
  71.         return this.configurazioneGeneraleFetch;
  72.     }
  73.     @Override
  74.     public IJDBCFetch getFetch() {
  75.         return getConfigurazioneGeneraleFetch();
  76.     }
  77.    
  78.    
  79.     private JDBCServiceManager jdbcServiceManager = null;

  80.     @Override
  81.     public void setServiceManager(JDBCServiceManager serviceManager) throws ServiceException{
  82.         this.jdbcServiceManager = serviceManager;
  83.     }
  84.    
  85.     @Override
  86.     public JDBCServiceManager getServiceManager() throws ServiceException{
  87.         return this.jdbcServiceManager;
  88.     }
  89.    

  90.    
  91.     @Override
  92.     public ConfigurazioneGenerale get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {
  93.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, null, idMappingResolutionBehaviour);
  94.        
  95.        
  96.     }
  97.    
  98.     @Override
  99.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject) throws MultipleResultException, NotImplementedException, ServiceException,Exception {

  100.         return this._exists(jdbcProperties, log, connection, sqlQueryObject, null);
  101.        
  102.     }
  103.    
  104.    
  105.    
  106.    

  107.     @Override
  108.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject) throws NotFoundException, NotImplementedException, ServiceException,Exception {
  109.        
  110.         return this.inUseEngine(jdbcProperties, log, connection, sqlQueryObject, null);
  111.        
  112.     }

  113.     @Override
  114.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  115.                                                     JDBCPaginatedExpression paginatedExpression, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  116.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  117.                                 paginatedExpression, false, field);
  118.     }
  119.    
  120.     @Override
  121.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  122.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  123.         List<Map<String,Object>> map =
  124.             this.select(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, distinct, new IField[]{field});
  125.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.selectSingleObject(map);
  126.     }
  127.    
  128.     @Override
  129.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  130.                                                     JDBCPaginatedExpression paginatedExpression, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  131.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  132.                                 paginatedExpression, false, field);
  133.     }
  134.    
  135.     @Override
  136.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  137.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  138.        
  139.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,paginatedExpression,field);
  140.         try{
  141.        
  142.             ISQLQueryObject sqlQueryObjectDistinct =
  143.                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(distinct,sqlQueryObject, paginatedExpression, log,
  144.                                                 this.getConfigurazioneGeneraleFieldConverter(), field);

  145.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, sqlQueryObjectDistinct);
  146.            
  147.         }finally{
  148.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,field);
  149.         }
  150.     }

  151.    
  152.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  153.                                                 IExpression expression) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  154.         return selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression, null);
  155.     }
  156.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  157.                                                 IExpression expression, ISQLQueryObject sqlQueryObjectDistinct) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  158.        
  159.         List<Object> listaQuery = new ArrayList<>();
  160.         List<JDBCObject> listaParams = new ArrayList<>();
  161.         List<Object> returnField = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSelect(jdbcProperties, log, connection, sqlQueryObject,
  162.                                 expression, this.getConfigurazioneGeneraleFieldConverter(), ConfigurazioneGenerale.model(),
  163.                                 listaQuery,listaParams);
  164.        
  165.         joinEngine(expression,sqlQueryObject);
  166.        
  167.         List<Map<String,Object>> list = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.select(jdbcProperties, log, connection,
  168.                                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(sqlQueryObject,sqlQueryObjectDistinct),
  169.                                         expression, this.getConfigurazioneGeneraleFieldConverter(), ConfigurazioneGenerale.model(),
  170.                                         listaQuery,listaParams,returnField);
  171.         if(list!=null && !list.isEmpty()){
  172.             return list;
  173.         }
  174.         else{
  175.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  176.         }
  177.     }
  178.    



  179.     // -- ConstructorExpression

  180.     @Override
  181.     public JDBCExpression newExpression(Logger log) throws NotImplementedException, ServiceException {
  182.         try{
  183.             return new JDBCExpression(this.getConfigurazioneGeneraleFieldConverter());
  184.         }catch(Exception e){
  185.             throw new ServiceException(e);
  186.         }
  187.     }


  188.     @Override
  189.     public JDBCPaginatedExpression newPaginatedExpression(Logger log) throws NotImplementedException, ServiceException {
  190.         try{
  191.             return new JDBCPaginatedExpression(this.getConfigurazioneGeneraleFieldConverter());
  192.         }catch(Exception e){
  193.             throw new ServiceException(e);
  194.         }
  195.     }
  196.    
  197.     @Override
  198.     public JDBCExpression toExpression(JDBCPaginatedExpression paginatedExpression, Logger log) throws NotImplementedException, ServiceException {
  199.         try{
  200.             return new JDBCExpression(paginatedExpression);
  201.         }catch(Exception e){
  202.             throw new ServiceException(e);
  203.         }
  204.     }

  205.     @Override
  206.     public JDBCPaginatedExpression toPaginatedExpression(JDBCExpression expression, Logger log) throws NotImplementedException, ServiceException {
  207.         try{
  208.             return new JDBCPaginatedExpression(expression);
  209.         }catch(Exception e){
  210.             throw new ServiceException(e);
  211.         }
  212.     }
  213.    
  214.    
  215.    
  216.     // -- DB

  217.     @Override
  218.     public void mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneGenerale obj) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  219.         _mappingTableIds(jdbcProperties,log,connection,sqlQueryObject,obj,
  220.                 this.get(jdbcProperties,log,connection,sqlQueryObject,null));
  221.     }
  222.     private void _mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneGenerale obj, ConfigurazioneGenerale imgSaved) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  223.         if(imgSaved==null){
  224.             return;
  225.         }
  226.         obj.setId(imgSaved.getId());

  227.     }
  228.    
  229.     @Override
  230.     public ConfigurazioneGenerale get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  231.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId), idMappingResolutionBehaviour);
  232.     }
  233.    
  234.     private ConfigurazioneGenerale getEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  235.    
  236.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  237.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  238.        
  239.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();
  240.                
  241.         ConfigurazioneGenerale configurazioneGenerale = new ConfigurazioneGenerale();
  242.        

  243.         // Object configurazioneGenerale
  244.         sqlQueryObjectGet.setANDLogicOperator(true);
  245.         sqlQueryObjectGet.addFromTable(this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO));
  246.         sqlQueryObjectGet.addSelectField("id");
  247.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_ENABLED,true));
  248.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_WARNING_ONLY,true));
  249.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_SOGLIA,true));
  250.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE,true));
  251.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_TIPO_ERRORE_INCLUDI_DESCRIZIONE,true));
  252.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_ENABLED,true));
  253.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_CONGESTIONE_THRESHOLD,true));
  254.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.CONNECTION_TIMEOUT,true));
  255.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.READ_TIMEOUT,true));
  256.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_FRUIZIONE.TEMPO_MEDIO_RISPOSTA,true));
  257.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.CONNECTION_TIMEOUT,true));
  258.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.READ_TIMEOUT,true));
  259.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().TEMPI_RISPOSTA_EROGAZIONE.TEMPO_MEDIO_RISPOSTA,true));
  260.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE,true));
  261.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().RATE_LIMITING.TIPO_ERRORE_INCLUDI_DESCRIZIONE,true));
  262.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.CACHE,true));
  263.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.SIZE,true));
  264.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.ALGORITHM,true));
  265.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.IDLE_TIME,true));
  266.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CACHE.LIFE_TIME,true));
  267.         // Parameter 'tableId' unused in single instance

  268.         // Get configurazioneGenerale
  269.         configurazioneGenerale = (ConfigurazioneGenerale) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(), ConfigurazioneGenerale.model(), this.getConfigurazioneGeneraleFetch());


  270.         IPaginatedExpression pagExpr = this.getServiceManager().getConfigurazioneRateLimitingProprietaServiceSearch().newPaginatedExpression();
  271.         List<ConfigurazioneRateLimitingProprieta> listProprieta = this.getServiceManager().getConfigurazioneRateLimitingProprietaServiceSearch().findAll(pagExpr);
  272.         if(configurazioneGenerale.getRateLimiting()==null && listProprieta!=null && !listProprieta.isEmpty()) {
  273.             configurazioneGenerale.setRateLimiting(new ConfigurazioneRateLimiting());
  274.         }
  275.         configurazioneGenerale.getRateLimiting().setProprietaList(listProprieta);
  276.        
  277.        
  278.         return configurazioneGenerale;  
  279.    
  280.     }
  281.    
  282.     @Override
  283.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  284.         return this._exists(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  285.     }
  286.    
  287.     private boolean _exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  288.    
  289.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  290.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  291.                
  292.         boolean existsConfigurazioneGenerale = false;

  293.         sqlQueryObject = sqlQueryObject.newSQLQueryObject();
  294.         sqlQueryObject.setANDLogicOperator(true);

  295.         sqlQueryObject.addFromTable(this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model()));
  296.         sqlQueryObject.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toColumn(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO.CONTROLLO_MAX_THREADS_SOGLIA,true));
  297.         // Parameter 'tableId' unused in single instance

  298.         // Exists configurazioneGenerale
  299.         existsConfigurazioneGenerale = jdbcUtilities.exists(sqlQueryObject.createSQLQuery(), jdbcProperties.isShowSql());

  300.        
  301.         return existsConfigurazioneGenerale;
  302.    
  303.     }
  304.    
  305.     private void joinEngine(IExpression expression, ISQLQueryObject sqlQueryObject) throws NotImplementedException, ServiceException, Exception{
  306.    
  307.        
  308.     }
  309.    
  310.     protected java.util.List<Object> getRootTablePrimaryKeyValuesEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject) throws NotFoundException, ServiceException, NotImplementedException, Exception{
  311.         // Identificativi
  312.         java.util.List<Object> rootTableIdValues = new java.util.ArrayList<>();
  313.        
  314.         return rootTableIdValues;
  315.     }
  316.    
  317.     protected Map<String, List<IField>> getMapTableToPKColumnEngine() throws NotImplementedException, Exception{
  318.    
  319.         ConfigurazioneGeneraleFieldConverter converter = this.getConfigurazioneGeneraleFieldConverter();
  320.         Map<String, List<IField>> mapTableToPKColumn = new java.util.HashMap<>();
  321.         UtilsTemplate<IField> utilities = new UtilsTemplate<>();

  322.         // ConfigurazioneGenerale.model()
  323.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneGenerale.model()),
  324.             utilities.newList(
  325.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneGenerale.model()))
  326.             ));

  327.         // ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO
  328.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO),
  329.             utilities.newList(
  330.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneGenerale.model().CONTROLLO_TRAFFICO))
  331.             ));
  332.        
  333.         return mapTableToPKColumn;      
  334.     }
  335.    
  336.     @Override
  337.     public List<Long> findAllTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression paginatedExpression) throws ServiceException, NotImplementedException, Exception {
  338.        
  339.         List<Long> list = new ArrayList<Long>();

  340.         sqlQueryObject.setSelectDistinct(true);
  341.         sqlQueryObject.setANDLogicOperator(true);
  342.         sqlQueryObject.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model())+".id");
  343.         Class<?> objectIdClass = Long.class;
  344.        
  345.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFindAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  346.                                                 this.getConfigurazioneGeneraleFieldConverter(), ConfigurazioneGenerale.model());
  347.        
  348.         joinEngine(paginatedExpression,sqlQueryObject);
  349.        
  350.         List<Object> listObjects = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.findAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  351.                                                                             this.getConfigurazioneGeneraleFieldConverter(), ConfigurazioneGenerale.model(), objectIdClass, listaQuery);
  352.         for(Object object: listObjects) {
  353.             list.add((Long)object);
  354.         }

  355.         return list;
  356.        
  357.     }
  358.    
  359.     @Override
  360.     public long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException, Exception {
  361.    
  362.         sqlQueryObject.setSelectDistinct(true);
  363.         sqlQueryObject.setANDLogicOperator(true);
  364.         sqlQueryObject.addSelectField(this.getConfigurazioneGeneraleFieldConverter().toTable(ConfigurazioneGenerale.model())+".id");
  365.         Class<?> objectIdClass = Long.class;
  366.        
  367.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFind(jdbcProperties, log, connection, sqlQueryObject, expression,
  368.                                                 this.getConfigurazioneGeneraleFieldConverter(), ConfigurazioneGenerale.model());
  369.        
  370.         joinEngine(expression,sqlQueryObject);

  371.         Object res = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.find(jdbcProperties, log, connection, sqlQueryObject, expression,
  372.                                                         this.getConfigurazioneGeneraleFieldConverter(), ConfigurazioneGenerale.model(), objectIdClass, listaQuery);
  373.         if(res!=null && (((Long) res).longValue()>0) ){
  374.             return ((Long) res).longValue();
  375.         }
  376.         else{
  377.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  378.         }
  379.        
  380.     }

  381.     @Override
  382.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws ServiceException, NotFoundException, NotImplementedException, Exception {
  383.         return this.inUseEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  384.     }

  385.     private InUse inUseEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId) throws ServiceException, NotFoundException, NotImplementedException, Exception {

  386.         InUse inUse = new InUse();
  387.         inUse.setInUse(false);
  388.        
  389.         /*
  390.          * TODO: implement code that checks whether the object identified by the id parameter is used by other objects
  391.         */
  392.        
  393.         // Delete this line when you have implemented the method
  394.         int throwNotImplemented = 1;
  395.         if(throwNotImplemented==1){
  396.                 throw new NotImplementedException("NotImplemented");
  397.         }
  398.         // Delete this line when you have implemented the method

  399.         return inUse;

  400.     }
  401.    

  402.    
  403.     @Override
  404.     public List<List<Object>> nativeQuery(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  405.                                             String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException,Exception{
  406.        
  407.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.nativeQuery(jdbcProperties, log, connection, sqlQueryObject,
  408.                                                                                             sql,returnClassTypes,param);
  409.                                                        
  410.     }
  411.    
  412. }