JDBCConfigurazioneServizioServiceSearchImpl.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.plugins.dao.jdbc;

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

  24. import java.sql.Connection;

  25. import org.slf4j.Logger;

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

  27. import org.openspcoop2.generic_project.expression.impl.sql.ISQLFieldConverter;
  28. import org.openspcoop2.generic_project.dao.jdbc.utils.IJDBCFetch;
  29. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject;
  30. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceSearchWithId;
  31. import org.openspcoop2.core.plugins.IdConfigurazioneServizio;
  32. import org.openspcoop2.generic_project.utils.UtilsTemplate;
  33. import org.openspcoop2.generic_project.beans.CustomField;
  34. import org.openspcoop2.generic_project.beans.InUse;
  35. import org.openspcoop2.generic_project.beans.IField;
  36. import org.openspcoop2.generic_project.beans.NonNegativeNumber;
  37. import org.openspcoop2.generic_project.beans.UnionExpression;
  38. import org.openspcoop2.generic_project.beans.Union;
  39. import org.openspcoop2.generic_project.beans.FunctionField;
  40. import org.openspcoop2.generic_project.exception.MultipleResultException;
  41. import org.openspcoop2.generic_project.exception.NotFoundException;
  42. import org.openspcoop2.generic_project.exception.NotImplementedException;
  43. import org.openspcoop2.generic_project.exception.ServiceException;
  44. import org.openspcoop2.generic_project.expression.IExpression;
  45. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  46. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;

  47. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  48. import org.openspcoop2.core.plugins.dao.jdbc.converter.ConfigurazioneServizioFieldConverter;
  49. import org.openspcoop2.core.plugins.dao.jdbc.fetch.ConfigurazioneServizioFetch;
  50. import org.openspcoop2.core.plugins.ConfigurazioneServizio;

  51. /**    
  52.  * JDBCConfigurazioneServizioServiceSearchImpl
  53.  *
  54.  * @author Poli Andrea (poli@link.it)
  55.  * @author $Author$
  56.  * @version $Rev$, $Date$
  57.  */
  58. public class JDBCConfigurazioneServizioServiceSearchImpl implements IJDBCServiceSearchWithId<ConfigurazioneServizio, IdConfigurazioneServizio, JDBCServiceManager> {

  59.     private ConfigurazioneServizioFieldConverter _configurazioneServizioFieldConverter = null;
  60.     public ConfigurazioneServizioFieldConverter getConfigurazioneServizioFieldConverter() {
  61.         if(this._configurazioneServizioFieldConverter==null){
  62.             this._configurazioneServizioFieldConverter = new ConfigurazioneServizioFieldConverter(this.jdbcServiceManager.getJdbcProperties().getDatabaseType());
  63.         }      
  64.         return this._configurazioneServizioFieldConverter;
  65.     }
  66.     @Override
  67.     public ISQLFieldConverter getFieldConverter() {
  68.         return this.getConfigurazioneServizioFieldConverter();
  69.     }
  70.    
  71.     private ConfigurazioneServizioFetch configurazioneServizioFetch = new ConfigurazioneServizioFetch();
  72.     public ConfigurazioneServizioFetch getConfigurazioneServizioFetch() {
  73.         return this.configurazioneServizioFetch;
  74.     }
  75.     @Override
  76.     public IJDBCFetch getFetch() {
  77.         return getConfigurazioneServizioFetch();
  78.     }
  79.    
  80.    
  81.     private JDBCServiceManager jdbcServiceManager = null;

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

  92.     @Override
  93.     public IdConfigurazioneServizio convertToId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneServizio configurazioneServizio) throws NotImplementedException, ServiceException, Exception{
  94.    
  95.         IdConfigurazioneServizio idConfigurazioneServizio = new IdConfigurazioneServizio();
  96.         idConfigurazioneServizio.setAccordo(configurazioneServizio.getAccordo());
  97.         idConfigurazioneServizio.setTipoSoggettoReferente(configurazioneServizio.getTipoSoggettoReferente());
  98.         idConfigurazioneServizio.setNomeSoggettoReferente(configurazioneServizio.getNomeSoggettoReferente());
  99.         idConfigurazioneServizio.setVersione(configurazioneServizio.getVersione());
  100.         idConfigurazioneServizio.setServizio(configurazioneServizio.getServizio());
  101.         return idConfigurazioneServizio;

  102.     }
  103.    
  104.     @Override
  105.     public ConfigurazioneServizio get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneServizio id, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {
  106.         Long id_configurazioneServizio = ( (id!=null && id.getId()!=null && id.getId()>0) ? id.getId() : this.findIdConfigurazioneServizio(jdbcProperties, log, connection, sqlQueryObject, id, true));
  107.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, id_configurazioneServizio,idMappingResolutionBehaviour);
  108.        
  109.        
  110.     }
  111.    
  112.     @Override
  113.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneServizio id) throws MultipleResultException, NotImplementedException, ServiceException,Exception {

  114.         Long id_configurazioneServizio = this.findIdConfigurazioneServizio(jdbcProperties, log, connection, sqlQueryObject, id, false);
  115.         return id_configurazioneServizio != null && id_configurazioneServizio > 0;
  116.        
  117.     }
  118.    
  119.     @Override
  120.     public List<IdConfigurazioneServizio> findAllIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException, ServiceException,Exception {

  121.         List<IdConfigurazioneServizio> list = new ArrayList<IdConfigurazioneServizio>();

  122.         // TODO: implementazione non efficiente.
  123.         // Per ottenere una implementazione efficiente:
  124.         // 1. Usare metodo select di questa classe indirizzando esattamente i field necessari a create l'ID logico
  125.         // 2. Usare metodo getConfigurazioneServizioFetch() sul risultato della select per ottenere un oggetto ConfigurazioneServizio
  126.         //    La fetch con la map inserirĂ  nell'oggetto solo i valori estratti
  127.         // 3. Usare metodo convertToId per ottenere l'id

  128.         List<Long> ids = this.findAllTableIds(jdbcProperties, log, connection, sqlQueryObject, expression);
  129.        
  130.         for(Long id: ids) {
  131.             ConfigurazioneServizio configurazioneServizio = this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour);
  132.             IdConfigurazioneServizio idConfigurazioneServizio = this.convertToId(jdbcProperties,log,connection,sqlQueryObject,configurazioneServizio);
  133.             list.add(idConfigurazioneServizio);
  134.         }

  135.         return list;
  136.        
  137.     }
  138.    
  139.     @Override
  140.     public List<ConfigurazioneServizio> findAll(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException, ServiceException,Exception {

  141.         List<ConfigurazioneServizio> list = new ArrayList<ConfigurazioneServizio>();
  142.        
  143.         // TODO: implementazione non efficiente.
  144.         // Per ottenere una implementazione efficiente:
  145.         // 1. Usare metodo select di questa classe indirizzando esattamente i field necessari
  146.         // 2. Usare metodo getConfigurazioneServizioFetch() sul risultato della select per ottenere un oggetto ConfigurazioneServizio
  147.         //    La fetch con la map inserirĂ  nell'oggetto solo i valori estratti

  148.         List<Long> ids = this.findAllTableIds(jdbcProperties, log, connection, sqlQueryObject, expression);
  149.        
  150.         for(Long id: ids) {
  151.             list.add(this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour));
  152.         }

  153.         return list;      
  154.        
  155.     }
  156.    
  157.     @Override
  158.     public ConfigurazioneServizio find(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour)
  159.         throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {

  160.         long id = this.findTableId(jdbcProperties, log, connection, sqlQueryObject, expression);
  161.         if(id>0){
  162.             return this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour);
  163.         }else{
  164.             throw new NotFoundException("Entry with id["+id+"] not found");
  165.         }
  166.        
  167.     }
  168.    
  169.     @Override
  170.     public NonNegativeNumber count(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws NotImplementedException, ServiceException,Exception {
  171.        
  172.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareCount(jdbcProperties, log, connection, sqlQueryObject, expression,
  173.                                                 this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model());
  174.        
  175.         sqlQueryObject.addSelectCountField(this.getConfigurazioneServizioFieldConverter().toTable(ConfigurazioneServizio.model())+".id","tot",true);
  176.        
  177.         joinEngine(expression,sqlQueryObject);
  178.        
  179.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.count(jdbcProperties, log, connection, sqlQueryObject, expression,
  180.                                                                             this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model(),listaQuery);
  181.     }

  182.     @Override
  183.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneServizio id) throws NotFoundException, NotImplementedException, ServiceException,Exception {
  184.        
  185.         Long id_configurazioneServizio = this.findIdConfigurazioneServizio(jdbcProperties, log, connection, sqlQueryObject, id, true);
  186.         return this.inUseEngine(jdbcProperties, log, connection, sqlQueryObject, id_configurazioneServizio);
  187.        
  188.     }

  189.     @Override
  190.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  191.                                                     JDBCPaginatedExpression paginatedExpression, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  192.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  193.                                 paginatedExpression, false, field);
  194.     }
  195.    
  196.     @Override
  197.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  198.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  199.         List<Map<String,Object>> map =
  200.             this.select(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, distinct, new IField[]{field});
  201.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.selectSingleObject(map);
  202.     }
  203.    
  204.     @Override
  205.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  206.                                                     JDBCPaginatedExpression paginatedExpression, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  207.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  208.                                 paginatedExpression, false, field);
  209.     }
  210.    
  211.     @Override
  212.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  213.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  214.        
  215.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,paginatedExpression,field);
  216.         try{
  217.        
  218.             ISQLQueryObject sqlQueryObjectDistinct =
  219.                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(distinct,sqlQueryObject, paginatedExpression, log,
  220.                                                 this.getConfigurazioneServizioFieldConverter(), field);

  221.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, sqlQueryObjectDistinct);
  222.            
  223.         }finally{
  224.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,field);
  225.         }
  226.     }

  227.     @Override
  228.     public Object aggregate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  229.                                                     JDBCExpression expression, FunctionField functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  230.         Map<String,Object> map =
  231.             this.aggregate(jdbcProperties, log, connection, sqlQueryObject, expression, new FunctionField[]{functionField});
  232.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.selectAggregateObject(map,functionField);
  233.     }
  234.    
  235.     @Override
  236.     public Map<String,Object> aggregate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  237.                                                     JDBCExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {                                                  
  238.        
  239.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,expression,functionField);
  240.         try{
  241.             List<Map<String,Object>> list = selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression);
  242.             return list.get(0);
  243.         }finally{
  244.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,expression,functionField);
  245.         }
  246.     }

  247.     @Override
  248.     public List<Map<String,Object>> groupBy(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  249.                                                     JDBCExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  250.        
  251.         if(expression.getGroupByFields().isEmpty()){
  252.             throw new ServiceException("GroupBy conditions not found in expression");
  253.         }
  254.        
  255.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,expression,functionField);
  256.         try{
  257.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression);
  258.         }finally{
  259.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,expression,functionField);
  260.         }
  261.     }
  262.    

  263.     @Override
  264.     public List<Map<String,Object>> groupBy(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  265.                                                     JDBCPaginatedExpression paginatedExpression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  266.        
  267.         if(paginatedExpression.getGroupByFields().isEmpty()){
  268.             throw new ServiceException("GroupBy conditions not found in expression");
  269.         }
  270.        
  271.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,paginatedExpression,functionField);
  272.         try{
  273.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression);
  274.         }finally{
  275.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,functionField);
  276.         }
  277.     }
  278.    
  279.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  280.                                                 IExpression expression) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  281.         return selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression, null);
  282.     }
  283.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  284.                                                 IExpression expression, ISQLQueryObject sqlQueryObjectDistinct) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  285.        
  286.         List<Object> listaQuery = new ArrayList<>();
  287.         List<JDBCObject> listaParams = new ArrayList<>();
  288.         List<Object> returnField = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSelect(jdbcProperties, log, connection, sqlQueryObject,
  289.                                 expression, this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model(),
  290.                                 listaQuery,listaParams);
  291.        
  292.         joinEngine(expression,sqlQueryObject);
  293.        
  294.         List<Map<String,Object>> list = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.select(jdbcProperties, log, connection,
  295.                                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(sqlQueryObject,sqlQueryObjectDistinct),
  296.                                         expression, this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model(),
  297.                                         listaQuery,listaParams,returnField);
  298.         if(list!=null && !list.isEmpty()){
  299.             return list;
  300.         }
  301.         else{
  302.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  303.         }
  304.     }
  305.    
  306.     @Override
  307.     public List<Map<String,Object>> union(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  308.                                                 Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException,Exception {    
  309.        
  310.         List<ISQLQueryObject> sqlQueryObjectInnerList = new ArrayList<>();
  311.         List<JDBCObject> jdbcObjects = new ArrayList<>();
  312.         List<Class<?>> returnClassTypes = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareUnion(jdbcProperties, log, connection, sqlQueryObject,
  313.                                 this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model(),
  314.                                 sqlQueryObjectInnerList, jdbcObjects, union, unionExpression);
  315.        
  316.         if(unionExpression!=null){
  317.             for (int i = 0; i < unionExpression.length; i++) {
  318.                 UnionExpression ue = unionExpression[i];
  319.                 IExpression expression = ue.getExpression();
  320.                 joinEngine(expression,sqlQueryObjectInnerList.get(i));
  321.             }
  322.         }
  323.        
  324.         List<Map<String,Object>> list = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.union(jdbcProperties, log, connection, sqlQueryObject,
  325.                                         this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model(),
  326.                                         sqlQueryObjectInnerList, jdbcObjects, returnClassTypes, union, unionExpression);
  327.         if(list!=null && !list.isEmpty()){
  328.             return list;
  329.         }
  330.         else{
  331.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  332.         }                              
  333.     }
  334.    
  335.     @Override
  336.     public NonNegativeNumber unionCount(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  337.                                                 Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException,Exception {    
  338.        
  339.         List<ISQLQueryObject> sqlQueryObjectInnerList = new ArrayList<>();
  340.         List<JDBCObject> jdbcObjects = new ArrayList<>();
  341.         List<Class<?>> returnClassTypes = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareUnionCount(jdbcProperties, log, connection, sqlQueryObject,
  342.                                 this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model(),
  343.                                 sqlQueryObjectInnerList, jdbcObjects, union, unionExpression);
  344.        
  345.         if(unionExpression!=null){
  346.             for (int i = 0; i < unionExpression.length; i++) {
  347.                 UnionExpression ue = unionExpression[i];
  348.                 IExpression expression = ue.getExpression();
  349.                 joinEngine(expression,sqlQueryObjectInnerList.get(i));
  350.             }
  351.         }
  352.        
  353.         NonNegativeNumber number = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.unionCount(jdbcProperties, log, connection, sqlQueryObject,
  354.                                         this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model(),
  355.                                         sqlQueryObjectInnerList, jdbcObjects, returnClassTypes, union, unionExpression);
  356.         if(number!=null && number.longValue()>=0){
  357.             return number;
  358.         }
  359.         else{
  360.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  361.         }
  362.     }



  363.     // -- ConstructorExpression

  364.     @Override
  365.     public JDBCExpression newExpression(Logger log) throws NotImplementedException, ServiceException {
  366.         try{
  367.             return new JDBCExpression(this.getConfigurazioneServizioFieldConverter());
  368.         }catch(Exception e){
  369.             throw new ServiceException(e);
  370.         }
  371.     }


  372.     @Override
  373.     public JDBCPaginatedExpression newPaginatedExpression(Logger log) throws NotImplementedException, ServiceException {
  374.         try{
  375.             return new JDBCPaginatedExpression(this.getConfigurazioneServizioFieldConverter());
  376.         }catch(Exception e){
  377.             throw new ServiceException(e);
  378.         }
  379.     }
  380.    
  381.     @Override
  382.     public JDBCExpression toExpression(JDBCPaginatedExpression paginatedExpression, Logger log) throws NotImplementedException, ServiceException {
  383.         try{
  384.             return new JDBCExpression(paginatedExpression);
  385.         }catch(Exception e){
  386.             throw new ServiceException(e);
  387.         }
  388.     }

  389.     @Override
  390.     public JDBCPaginatedExpression toPaginatedExpression(JDBCExpression expression, Logger log) throws NotImplementedException, ServiceException {
  391.         try{
  392.             return new JDBCPaginatedExpression(expression);
  393.         }catch(Exception e){
  394.             throw new ServiceException(e);
  395.         }
  396.     }
  397.    
  398.    
  399.    
  400.     // -- DB

  401.     @Override
  402.     public void mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneServizio id, ConfigurazioneServizio obj) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  403.         _mappingTableIds(jdbcProperties,log,connection,sqlQueryObject,obj,
  404.                 this.get(jdbcProperties,log,connection,sqlQueryObject,id,null));
  405.     }
  406.    
  407.     @Override
  408.     public void mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, ConfigurazioneServizio obj) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  409.         _mappingTableIds(jdbcProperties,log,connection,sqlQueryObject,obj,
  410.                 this.get(jdbcProperties,log,connection,sqlQueryObject,tableId,null));
  411.     }
  412.     private void _mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneServizio obj, ConfigurazioneServizio imgSaved) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  413.         if(imgSaved==null){
  414.             return;
  415.         }
  416.         obj.setId(imgSaved.getId());
  417.         if(obj.getConfigurazioneServizioAzioneList()!=null){
  418.             List<org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione> listObj_ = obj.getConfigurazioneServizioAzioneList();
  419.             for(org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione itemObj_ : listObj_){
  420.                 org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione itemAlreadySaved_ = null;
  421.                 if(imgSaved.getConfigurazioneServizioAzioneList()!=null){
  422.                     List<org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione> listImgSaved_ = imgSaved.getConfigurazioneServizioAzioneList();
  423.                     for(org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione itemImgSaved_ : listImgSaved_){
  424.                         boolean objEqualsToImgSaved_ = false;
  425.                         objEqualsToImgSaved_ = org.openspcoop2.generic_project.utils.Utilities.equals(itemObj_.getAzione(),itemImgSaved_.getAzione());
  426.                         if(objEqualsToImgSaved_){
  427.                             itemAlreadySaved_=itemImgSaved_;
  428.                             break;
  429.                         }
  430.                     }
  431.                 }
  432.                 if(itemAlreadySaved_!=null){
  433.                     itemObj_.setId(itemAlreadySaved_.getId());
  434.                     if(itemObj_.getIdConfigurazioneServizio()!=null &&
  435.                             itemAlreadySaved_.getIdConfigurazioneServizio()!=null){
  436.                         itemObj_.getIdConfigurazioneServizio().setId(itemAlreadySaved_.getIdConfigurazioneServizio().getId());
  437.                     }
  438.                 }
  439.             }
  440.         }
  441.              
  442.     }
  443.    
  444.     @Override
  445.     public ConfigurazioneServizio get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  446.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId), idMappingResolutionBehaviour);
  447.     }
  448.    
  449.     private ConfigurazioneServizio getEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  450.    
  451.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  452.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  453.        
  454.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();
  455.                
  456.         ConfigurazioneServizio configurazioneServizio = new ConfigurazioneServizio();
  457.        

  458.         // Object configurazioneServizio
  459.         ISQLQueryObject sqlQueryObjectGet_configurazioneServizio = sqlQueryObjectGet.newSQLQueryObject();
  460.         sqlQueryObjectGet_configurazioneServizio.setANDLogicOperator(true);
  461.         sqlQueryObjectGet_configurazioneServizio.addFromTable(this.getConfigurazioneServizioFieldConverter().toTable(ConfigurazioneServizio.model()));
  462.         sqlQueryObjectGet_configurazioneServizio.addSelectField("id");
  463.         sqlQueryObjectGet_configurazioneServizio.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().ACCORDO,true));
  464.         sqlQueryObjectGet_configurazioneServizio.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().TIPO_SOGGETTO_REFERENTE,true));
  465.         sqlQueryObjectGet_configurazioneServizio.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().NOME_SOGGETTO_REFERENTE,true));
  466.         sqlQueryObjectGet_configurazioneServizio.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().VERSIONE,true));
  467.         sqlQueryObjectGet_configurazioneServizio.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().SERVIZIO,true));
  468.         sqlQueryObjectGet_configurazioneServizio.addWhereCondition("id=?");

  469.         // Get configurazioneServizio
  470.         configurazioneServizio = (ConfigurazioneServizio) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_configurazioneServizio.createSQLQuery(), jdbcProperties.isShowSql(), ConfigurazioneServizio.model(), this.getConfigurazioneServizioFetch(),
  471.             new JDBCObject(tableId,Long.class));



  472.        
  473.         return configurazioneServizio;  
  474.    
  475.     }
  476.    
  477.     @Override
  478.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  479.         return this._exists(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  480.     }
  481.    
  482.     private boolean _exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  483.    
  484.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  485.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  486.                
  487.         boolean existsConfigurazioneServizio = false;

  488.         sqlQueryObject = sqlQueryObject.newSQLQueryObject();
  489.         sqlQueryObject.setANDLogicOperator(true);

  490.         sqlQueryObject.addFromTable(this.getConfigurazioneServizioFieldConverter().toTable(ConfigurazioneServizio.model()));
  491.         sqlQueryObject.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().ACCORDO,true));
  492.         sqlQueryObject.addWhereCondition("id=?");


  493.         // Exists configurazioneServizio
  494.         existsConfigurazioneServizio = jdbcUtilities.exists(sqlQueryObject.createSQLQuery(), jdbcProperties.isShowSql(),
  495.             new JDBCObject(tableId,Long.class));

  496.        
  497.         return existsConfigurazioneServizio;
  498.    
  499.     }
  500.    
  501.     private void joinEngine(IExpression expression, ISQLQueryObject sqlQueryObject) throws NotImplementedException, ServiceException, Exception{
  502.    
  503.         if(expression.inUseModel(ConfigurazioneServizio.model().CONFIGURAZIONE_SERVIZIO_AZIONE,false)){
  504.             String tableName1 = this.getConfigurazioneServizioFieldConverter().toTable(ConfigurazioneServizio.model().CONFIGURAZIONE_SERVIZIO_AZIONE);
  505.             String tableName2 = this.getConfigurazioneServizioFieldConverter().toTable(ConfigurazioneServizio.model());
  506.             sqlQueryObject.addWhereCondition(tableName1+".id_config_servizio="+tableName2+".id");
  507.         }
  508.        
  509.     }
  510.    
  511.     protected java.util.List<Object> getRootTablePrimaryKeyValuesEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneServizio id) throws NotFoundException, ServiceException, NotImplementedException, Exception{
  512.         // Identificativi
  513.         java.util.List<Object> rootTableIdValues = new java.util.ArrayList<>();
  514.         Long longId = this.findIdConfigurazioneServizio(jdbcProperties, log, connection, sqlQueryObject.newSQLQueryObject(), id, true);
  515.         rootTableIdValues.add(longId);
  516.         return rootTableIdValues;
  517.     }
  518.    
  519.     protected Map<String, List<IField>> getMapTableToPKColumnEngine() throws NotImplementedException, Exception{
  520.    
  521.         ConfigurazioneServizioFieldConverter converter = this.getConfigurazioneServizioFieldConverter();
  522.         Map<String, List<IField>> mapTableToPKColumn = new java.util.HashMap<>();
  523.         UtilsTemplate<IField> utilities = new UtilsTemplate<>();

  524.         // ConfigurazioneServizio.model()
  525.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneServizio.model()),
  526.             utilities.newList(
  527.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneServizio.model()))
  528.             ));

  529.         // ConfigurazioneServizio.model().CONFIGURAZIONE_SERVIZIO_AZIONE
  530.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneServizio.model().CONFIGURAZIONE_SERVIZIO_AZIONE),
  531.             utilities.newList(
  532.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneServizio.model().CONFIGURAZIONE_SERVIZIO_AZIONE))
  533.             ));

  534.         // ConfigurazioneServizio.model().CONFIGURAZIONE_SERVIZIO_AZIONE.ID_CONFIGURAZIONE_SERVIZIO
  535.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneServizio.model().CONFIGURAZIONE_SERVIZIO_AZIONE.ID_CONFIGURAZIONE_SERVIZIO),
  536.             utilities.newList(
  537.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneServizio.model().CONFIGURAZIONE_SERVIZIO_AZIONE.ID_CONFIGURAZIONE_SERVIZIO))
  538.             ));
  539.        
  540.         return mapTableToPKColumn;      
  541.     }
  542.    
  543.     @Override
  544.     public List<Long> findAllTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression paginatedExpression) throws ServiceException, NotImplementedException, Exception {
  545.        
  546.         List<Long> list = new ArrayList<Long>();

  547.         sqlQueryObject.setSelectDistinct(true);
  548.         sqlQueryObject.setANDLogicOperator(true);
  549.         sqlQueryObject.addSelectField(this.getConfigurazioneServizioFieldConverter().toTable(ConfigurazioneServizio.model())+".id");
  550.         Class<?> objectIdClass = Long.class;
  551.        
  552.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFindAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  553.                                                 this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model());
  554.        
  555.         joinEngine(paginatedExpression,sqlQueryObject);
  556.        
  557.         List<Object> listObjects = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.findAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  558.                                                                             this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model(), objectIdClass, listaQuery);
  559.         for(Object object: listObjects) {
  560.             list.add((Long)object);
  561.         }

  562.         return list;
  563.        
  564.     }
  565.    
  566.     @Override
  567.     public long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException, Exception {
  568.    
  569.         sqlQueryObject.setSelectDistinct(true);
  570.         sqlQueryObject.setANDLogicOperator(true);
  571.         sqlQueryObject.addSelectField(this.getConfigurazioneServizioFieldConverter().toTable(ConfigurazioneServizio.model())+".id");
  572.         Class<?> objectIdClass = Long.class;
  573.        
  574.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFind(jdbcProperties, log, connection, sqlQueryObject, expression,
  575.                                                 this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model());
  576.        
  577.         joinEngine(expression,sqlQueryObject);

  578.         Object res = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.find(jdbcProperties, log, connection, sqlQueryObject, expression,
  579.                                                         this.getConfigurazioneServizioFieldConverter(), ConfigurazioneServizio.model(), objectIdClass, listaQuery);
  580.         if(res!=null && (((Long) res).longValue()>0) ){
  581.             return ((Long) res).longValue();
  582.         }
  583.         else{
  584.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  585.         }
  586.        
  587.     }

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

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

  593.         InUse inUse = new InUse();
  594.         inUse.setInUse(false);
  595.        
  596.         /*
  597.          * TODO: implement code that checks whether the object identified by the id parameter is used by other objects
  598.         */
  599.        
  600.         // Delete this line when you have implemented the method
  601.         int throwNotImplemented = 1;
  602.         if(throwNotImplemented==1){
  603.                 throw new NotImplementedException("NotImplemented");
  604.         }
  605.         // Delete this line when you have implemented the method

  606.         return inUse;

  607.     }
  608.    
  609.     @Override
  610.     public IdConfigurazioneServizio findId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, boolean throwNotFound)
  611.             throws NotFoundException, ServiceException, NotImplementedException, Exception {
  612.        
  613.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  614.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);

  615.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();
  616.              

  617.         // Object _configurazioneServizio
  618.         sqlQueryObjectGet.addFromTable(this.getConfigurazioneServizioFieldConverter().toTable(ConfigurazioneServizio.model()));
  619.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().TIPO_SOGGETTO_REFERENTE,true));
  620.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().NOME_SOGGETTO_REFERENTE,true));
  621.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().ACCORDO,true));
  622.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().SERVIZIO,true));
  623.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().VERSIONE,true));
  624.         sqlQueryObjectGet.setANDLogicOperator(true);
  625.         sqlQueryObjectGet.addWhereCondition("id=?");

  626.         // Recupero _configurazioneServizio
  627.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_configurazioneServizio = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  628.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(tableId,Long.class)
  629.         };
  630.         List<Class<?>> listaFieldIdReturnType_configurazioneServizio = new ArrayList<Class<?>>();
  631.         listaFieldIdReturnType_configurazioneServizio.add(String.class);
  632.         listaFieldIdReturnType_configurazioneServizio.add(String.class);
  633.         listaFieldIdReturnType_configurazioneServizio.add(String.class);
  634.         listaFieldIdReturnType_configurazioneServizio.add(String.class);
  635.         listaFieldIdReturnType_configurazioneServizio.add(Integer.class);
  636.         org.openspcoop2.core.plugins.IdConfigurazioneServizio id_configurazioneServizio = null;
  637.         List<Object> listaFieldId_configurazioneServizio = jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  638.                 listaFieldIdReturnType_configurazioneServizio, searchParams_configurazioneServizio);
  639.         if(listaFieldId_configurazioneServizio==null || listaFieldId_configurazioneServizio.size()<=0){
  640.             if(throwNotFound){
  641.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  642.             }
  643.         }
  644.         else{
  645.             // set _configurazioneServizio
  646.             id_configurazioneServizio = new org.openspcoop2.core.plugins.IdConfigurazioneServizio();
  647.             id_configurazioneServizio.setTipoSoggettoReferente((String)listaFieldId_configurazioneServizio.get(0));
  648.             id_configurazioneServizio.setNomeSoggettoReferente((String)listaFieldId_configurazioneServizio.get(1));
  649.             id_configurazioneServizio.setAccordo((String)listaFieldId_configurazioneServizio.get(2));
  650.             id_configurazioneServizio.setServizio((String)listaFieldId_configurazioneServizio.get(3));
  651.             id_configurazioneServizio.setVersione((Integer)listaFieldId_configurazioneServizio.get(4));
  652.         }
  653.        
  654.         return id_configurazioneServizio;
  655.        
  656.     }

  657.     @Override
  658.     public Long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneServizio id, boolean throwNotFound)
  659.             throws NotFoundException, ServiceException, NotImplementedException, Exception {
  660.    
  661.         return this.findIdConfigurazioneServizio(jdbcProperties,log,connection,sqlQueryObject,id,throwNotFound);
  662.            
  663.     }
  664.    
  665.     @Override
  666.     public List<List<Object>> nativeQuery(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  667.                                             String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException,Exception{
  668.        
  669.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.nativeQuery(jdbcProperties, log, connection, sqlQueryObject,
  670.                                                                                             sql,returnClassTypes,param);
  671.                                                        
  672.     }
  673.    
  674.     protected Long findIdConfigurazioneServizio(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneServizio id, boolean throwNotFound) throws NotFoundException, ServiceException, NotImplementedException, Exception {

  675.         if(jdbcProperties==null) {
  676.             throw new ServiceException("Param jdbcProperties is null");
  677.         }
  678.         if(sqlQueryObject==null) {
  679.             throw new ServiceException("Param sqlQueryObject is null");
  680.         }
  681.         if(id==null) {
  682.             throw new ServiceException("Param id is null");
  683.         }
  684.        
  685.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  686.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);

  687.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();

  688.         // Object _configurazioneServizio
  689.         sqlQueryObjectGet.addFromTable(this.getConfigurazioneServizioFieldConverter().toTable(ConfigurazioneServizio.model()));
  690.         sqlQueryObjectGet.addSelectField("id");
  691.         sqlQueryObjectGet.setANDLogicOperator(true);
  692.         sqlQueryObjectGet.setSelectDistinct(true);
  693.         sqlQueryObjectGet.addWhereCondition(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().ACCORDO,true)+"=?");
  694.         sqlQueryObjectGet.addWhereCondition(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().TIPO_SOGGETTO_REFERENTE,true)+"=?");
  695.         sqlQueryObjectGet.addWhereCondition(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().NOME_SOGGETTO_REFERENTE,true)+"=?");
  696.         sqlQueryObjectGet.addWhereCondition(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().VERSIONE,true)+"=?");
  697.         sqlQueryObjectGet.addWhereCondition(this.getConfigurazioneServizioFieldConverter().toColumn(ConfigurazioneServizio.model().SERVIZIO,true)+"=?");

  698.         // Recupero _configurazioneServizio
  699.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_configurazioneServizio = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  700.                 new JDBCObject(id.getAccordo(), String.class),
  701.                 new JDBCObject(id.getTipoSoggettoReferente(), String.class),
  702.                 new JDBCObject(id.getNomeSoggettoReferente(), String.class),
  703.                 new JDBCObject(id.getVersione(), String.class),
  704.                 new JDBCObject(id.getServizio(), String.class)
  705.         };
  706.         Long id_configurazioneServizio = null;
  707.         try{
  708.             id_configurazioneServizio = (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  709.                         Long.class, searchParams_configurazioneServizio);
  710.         }catch(NotFoundException notFound){
  711.             if(throwNotFound){
  712.                 throw new NotFoundException(notFound);
  713.             }
  714.         }
  715.         if(id_configurazioneServizio==null || id_configurazioneServizio<=0){
  716.             if(throwNotFound){
  717.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  718.             }
  719.         }
  720.        
  721.         return id_configurazioneServizio;
  722.     }
  723. }