JDBCConfigurazioneServizioAzioneServiceSearchImpl.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.IdConfigurazioneServizioAzione;
  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.ConfigurazioneServizioAzioneFieldConverter;
  49. import org.openspcoop2.core.plugins.dao.jdbc.fetch.ConfigurazioneServizioAzioneFetch;
  50. import org.openspcoop2.core.plugins.dao.IDBConfigurazioneServizioServiceSearch;
  51. import org.openspcoop2.core.plugins.ConfigurazioneServizio;
  52. import org.openspcoop2.core.plugins.ConfigurazioneServizioAzione;
  53. import org.openspcoop2.core.plugins.IdConfigurazioneServizio;

  54. /**    
  55.  * JDBCConfigurazioneServizioAzioneServiceSearchImpl
  56.  *
  57.  * @author Poli Andrea (poli@link.it)
  58.  * @author $Author$
  59.  * @version $Rev$, $Date$
  60.  */
  61. public class JDBCConfigurazioneServizioAzioneServiceSearchImpl implements IJDBCServiceSearchWithId<ConfigurazioneServizioAzione, IdConfigurazioneServizioAzione, JDBCServiceManager> {

  62.     private ConfigurazioneServizioAzioneFieldConverter _configurazioneServizioAzioneFieldConverter = null;
  63.     public ConfigurazioneServizioAzioneFieldConverter getConfigurazioneServizioAzioneFieldConverter() {
  64.         if(this._configurazioneServizioAzioneFieldConverter==null){
  65.             this._configurazioneServizioAzioneFieldConverter = new ConfigurazioneServizioAzioneFieldConverter(this.jdbcServiceManager.getJdbcProperties().getDatabaseType());
  66.         }      
  67.         return this._configurazioneServizioAzioneFieldConverter;
  68.     }
  69.     @Override
  70.     public ISQLFieldConverter getFieldConverter() {
  71.         return this.getConfigurazioneServizioAzioneFieldConverter();
  72.     }
  73.    
  74.     private ConfigurazioneServizioAzioneFetch configurazioneServizioAzioneFetch = new ConfigurazioneServizioAzioneFetch();
  75.     public ConfigurazioneServizioAzioneFetch getConfigurazioneServizioAzioneFetch() {
  76.         return this.configurazioneServizioAzioneFetch;
  77.     }
  78.     @Override
  79.     public IJDBCFetch getFetch() {
  80.         return getConfigurazioneServizioAzioneFetch();
  81.     }
  82.    
  83.    
  84.     private JDBCServiceManager jdbcServiceManager = null;

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

  95.     @Override
  96.     public IdConfigurazioneServizioAzione convertToId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneServizioAzione configurazioneServizioAzione) throws NotImplementedException, ServiceException, Exception{
  97.    
  98.         IdConfigurazioneServizioAzione idConfigurazioneServizioAzione = new IdConfigurazioneServizioAzione();
  99.         idConfigurazioneServizioAzione.setAzione(configurazioneServizioAzione.getAzione());
  100.         idConfigurazioneServizioAzione.setIdConfigurazioneServizio(configurazioneServizioAzione.getIdConfigurazioneServizio());
  101.         return idConfigurazioneServizioAzione;

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

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

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

  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 getConfigurazioneServizioAzioneFetch() sul risultato della select per ottenere un oggetto ConfigurazioneServizioAzione
  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.             ConfigurazioneServizioAzione configurazioneServizioAzione = this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour);
  132.             IdConfigurazioneServizioAzione idConfigurazioneServizioAzione = this.convertToId(jdbcProperties,log,connection,sqlQueryObject,configurazioneServizioAzione);
  133.             list.add(idConfigurazioneServizioAzione);
  134.         }

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

  141.         List<ConfigurazioneServizioAzione> list = new ArrayList<ConfigurazioneServizioAzione>();
  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 getConfigurazioneServizioAzioneFetch() sul risultato della select per ottenere un oggetto ConfigurazioneServizioAzione
  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 ConfigurazioneServizioAzione 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.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.model());
  174.        
  175.         sqlQueryObject.addSelectCountField(this.getConfigurazioneServizioAzioneFieldConverter().toTable(ConfigurazioneServizioAzione.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.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.model(),listaQuery);
  181.     }

  182.     @Override
  183.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneServizioAzione id) throws NotFoundException, NotImplementedException, ServiceException,Exception {
  184.        
  185.         Long id_configurazioneServizioAzione = this.findIdConfigurazioneServizioAzione(jdbcProperties, log, connection, sqlQueryObject, id, true);
  186.         return this.inUseEngine(jdbcProperties, log, connection, sqlQueryObject, id_configurazioneServizioAzione);
  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.getConfigurazioneServizioAzioneFieldConverter(), 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.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.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.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.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.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.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.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.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.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.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.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.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.getConfigurazioneServizioAzioneFieldConverter());
  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.getConfigurazioneServizioAzioneFieldConverter());
  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, IdConfigurazioneServizioAzione id, ConfigurazioneServizioAzione 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, ConfigurazioneServizioAzione 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, ConfigurazioneServizioAzione obj, ConfigurazioneServizioAzione imgSaved) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  413.         if(imgSaved==null){
  414.             return;
  415.         }
  416.         obj.setId(imgSaved.getId());
  417.         if(obj.getIdConfigurazioneServizio()!=null &&
  418.                 imgSaved.getIdConfigurazioneServizio()!=null){
  419.             obj.getIdConfigurazioneServizio().setId(imgSaved.getIdConfigurazioneServizio().getId());
  420.         }

  421.     }
  422.    
  423.     @Override
  424.     public ConfigurazioneServizioAzione get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  425.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId), idMappingResolutionBehaviour);
  426.     }
  427.    
  428.     private ConfigurazioneServizioAzione getEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  429.    
  430.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  431.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  432.        
  433.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();
  434.                
  435.         ConfigurazioneServizioAzione configurazioneServizioAzione = new ConfigurazioneServizioAzione();
  436.        

  437.         // Object configurazioneServizioAzione
  438.         ISQLQueryObject sqlQueryObjectGet_configurazioneServizioAzione = sqlQueryObjectGet.newSQLQueryObject();
  439.         sqlQueryObjectGet_configurazioneServizioAzione.setANDLogicOperator(true);
  440.         sqlQueryObjectGet_configurazioneServizioAzione.addFromTable(this.getConfigurazioneServizioAzioneFieldConverter().toTable(ConfigurazioneServizioAzione.model()));
  441.         sqlQueryObjectGet_configurazioneServizioAzione.addSelectField("id");
  442.         sqlQueryObjectGet_configurazioneServizioAzione.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toColumn(ConfigurazioneServizioAzione.model().AZIONE,true));
  443.         sqlQueryObjectGet_configurazioneServizioAzione.addWhereCondition("id=?");

  444.         // Get configurazioneServizioAzione
  445.         configurazioneServizioAzione = (ConfigurazioneServizioAzione) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_configurazioneServizioAzione.createSQLQuery(), jdbcProperties.isShowSql(), ConfigurazioneServizioAzione.model(), this.getConfigurazioneServizioAzioneFetch(),
  446.             new JDBCObject(tableId,Long.class));


  447.         if(idMappingResolutionBehaviour==null ||
  448.             (org.openspcoop2.generic_project.beans.IDMappingBehaviour.ENABLED.equals(idMappingResolutionBehaviour) || org.openspcoop2.generic_project.beans.IDMappingBehaviour.USE_TABLE_ID.equals(idMappingResolutionBehaviour))
  449.         ){
  450.             // Recupero IdConfigurazioneServizio
  451.             ISQLQueryObject sqlQueryObjectGet_idConfigurazioneServizio = sqlQueryObjectGet.newSQLQueryObject();
  452.             sqlQueryObjectGet_idConfigurazioneServizio.addFromTable(this.getConfigurazioneServizioAzioneFieldConverter().toTable(ConfigurazioneServizioAzione.model()));
  453.             sqlQueryObjectGet_idConfigurazioneServizio.addSelectField("id_config_servizio");
  454.             sqlQueryObjectGet_idConfigurazioneServizio.addWhereCondition("id=?");
  455.             sqlQueryObjectGet_idConfigurazioneServizio.setANDLogicOperator(true);
  456.             Long id_idConfigurazioneServizio = (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_idConfigurazioneServizio.createSQLQuery(), jdbcProperties.isShowSql(),Long.class,
  457.                     new JDBCObject(configurazioneServizioAzione.getId(),Long.class));
  458.        
  459.             ConfigurazioneServizio configuraServizio =
  460.                     ((IDBConfigurazioneServizioServiceSearch)this.getServiceManager().getConfigurazioneServizioServiceSearch()).get(id_idConfigurazioneServizio);
  461.             IdConfigurazioneServizio idConfigurazioneServizio = new IdConfigurazioneServizio();
  462.             idConfigurazioneServizio.setAccordo(configuraServizio.getAccordo());
  463.             idConfigurazioneServizio.setTipoSoggettoReferente(configuraServizio.getTipoSoggettoReferente());
  464.             idConfigurazioneServizio.setNomeSoggettoReferente(configuraServizio.getNomeSoggettoReferente());
  465.             idConfigurazioneServizio.setVersione(configuraServizio.getVersione());
  466.             idConfigurazioneServizio.setServizio(configuraServizio.getServizio());
  467.             configurazioneServizioAzione.setIdConfigurazioneServizio(idConfigurazioneServizio);
  468.         }
  469.        
  470.         return configurazioneServizioAzione;  
  471.    
  472.     }
  473.    
  474.     @Override
  475.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  476.         return this._exists(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  477.     }
  478.    
  479.     private boolean _exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  480.    
  481.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  482.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  483.                
  484.         boolean existsConfigurazioneServizioAzione = false;

  485.         sqlQueryObject = sqlQueryObject.newSQLQueryObject();
  486.         sqlQueryObject.setANDLogicOperator(true);

  487.         sqlQueryObject.addFromTable(this.getConfigurazioneServizioAzioneFieldConverter().toTable(ConfigurazioneServizioAzione.model()));
  488.         sqlQueryObject.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toColumn(ConfigurazioneServizioAzione.model().AZIONE,true));
  489.         sqlQueryObject.addWhereCondition("id=?");


  490.         // Exists configurazioneServizioAzione
  491.         existsConfigurazioneServizioAzione = jdbcUtilities.exists(sqlQueryObject.createSQLQuery(), jdbcProperties.isShowSql(),
  492.             new JDBCObject(tableId,Long.class));

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

  521.         // ConfigurazioneServizioAzione.model()
  522.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneServizioAzione.model()),
  523.             utilities.newList(
  524.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneServizioAzione.model()))
  525.             ));

  526.         // ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO
  527.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO),
  528.             utilities.newList(
  529.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO))
  530.             ));
  531.        
  532.         return mapTableToPKColumn;      
  533.     }
  534.    
  535.     @Override
  536.     public List<Long> findAllTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression paginatedExpression) throws ServiceException, NotImplementedException, Exception {
  537.        
  538.         List<Long> list = new ArrayList<Long>();

  539.         sqlQueryObject.setSelectDistinct(true);
  540.         sqlQueryObject.setANDLogicOperator(true);
  541.         sqlQueryObject.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toTable(ConfigurazioneServizioAzione.model())+".id");
  542.         Class<?> objectIdClass = Long.class;
  543.        
  544.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFindAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  545.                                                 this.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.model());
  546.        
  547.         joinEngine(paginatedExpression,sqlQueryObject);
  548.        
  549.         List<Object> listObjects = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.findAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  550.                                                                             this.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.model(), objectIdClass, listaQuery);
  551.         for(Object object: listObjects) {
  552.             list.add((Long)object);
  553.         }

  554.         return list;
  555.        
  556.     }
  557.    
  558.     @Override
  559.     public long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException, Exception {
  560.    
  561.         sqlQueryObject.setSelectDistinct(true);
  562.         sqlQueryObject.setANDLogicOperator(true);
  563.         sqlQueryObject.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toTable(ConfigurazioneServizioAzione.model())+".id");
  564.         Class<?> objectIdClass = Long.class;
  565.        
  566.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFind(jdbcProperties, log, connection, sqlQueryObject, expression,
  567.                                                 this.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.model());
  568.        
  569.         joinEngine(expression,sqlQueryObject);

  570.         Object res = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.find(jdbcProperties, log, connection, sqlQueryObject, expression,
  571.                                                         this.getConfigurazioneServizioAzioneFieldConverter(), ConfigurazioneServizioAzione.model(), objectIdClass, listaQuery);
  572.         if(res!=null && (((Long) res).longValue()>0) ){
  573.             return ((Long) res).longValue();
  574.         }
  575.         else{
  576.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  577.         }
  578.        
  579.     }

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

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

  585.         InUse inUse = new InUse();
  586.         inUse.setInUse(false);
  587.        
  588.         /*
  589.          * TODO: implement code that checks whether the object identified by the id parameter is used by other objects
  590.         */
  591.        
  592.         // Delete this line when you have implemented the method
  593.         int throwNotImplemented = 1;
  594.         if(throwNotImplemented==1){
  595.                 throw new NotImplementedException("NotImplemented");
  596.         }
  597.         // Delete this line when you have implemented the method

  598.         return inUse;

  599.     }
  600.    
  601.     @Override
  602.     public IdConfigurazioneServizioAzione findId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, boolean throwNotFound)
  603.             throws NotFoundException, ServiceException, NotImplementedException, Exception {
  604.        
  605.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  606.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);

  607.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();

  608.          
  609.         // Object _configurazioneServizioAzione
  610.         sqlQueryObjectGet.addFromTable(this.getConfigurazioneServizioAzioneFieldConverter().toTable(ConfigurazioneServizioAzione.model()));
  611.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toColumn(ConfigurazioneServizioAzione.model().AZIONE,true));
  612.         sqlQueryObjectGet.addSelectField("id_config_servizio");
  613.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toColumn(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.TIPO_SOGGETTO_REFERENTE,true));
  614.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toColumn(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.NOME_SOGGETTO_REFERENTE,true));
  615.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toColumn(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.ACCORDO,true));
  616.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toColumn(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.SERVIZIO,true));
  617.         sqlQueryObjectGet.addSelectField(this.getConfigurazioneServizioAzioneFieldConverter().toColumn(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.VERSIONE,true));
  618.         sqlQueryObjectGet.setANDLogicOperator(true);
  619.         sqlQueryObjectGet.addWhereCondition("id=?");

  620.         // Recupero _configurazioneServizioAzione
  621.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_configurazioneServizioAzione = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  622.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(tableId,Long.class)
  623.         };
  624.         List<Class<?>> listaFieldIdReturnType_configurazioneServizioAzione = new ArrayList<Class<?>>();
  625.         listaFieldIdReturnType_configurazioneServizioAzione.add(String.class);
  626.         listaFieldIdReturnType_configurazioneServizioAzione.add(Long.class);
  627.         listaFieldIdReturnType_configurazioneServizioAzione.add(String.class);
  628.         listaFieldIdReturnType_configurazioneServizioAzione.add(String.class);
  629.         listaFieldIdReturnType_configurazioneServizioAzione.add(String.class);
  630.         listaFieldIdReturnType_configurazioneServizioAzione.add(String.class);
  631.         listaFieldIdReturnType_configurazioneServizioAzione.add(Integer.class);
  632.         org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione id_configurazioneServizioAzione = null;
  633.         List<Object> listaFieldId_configurazioneServizioAzione = jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  634.                 listaFieldIdReturnType_configurazioneServizioAzione, searchParams_configurazioneServizioAzione);
  635.         if(listaFieldId_configurazioneServizioAzione==null || listaFieldId_configurazioneServizioAzione.size()<=0){
  636.             if(throwNotFound){
  637.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  638.             }
  639.         }
  640.         else{
  641.             // set _configurazioneServizioAzione
  642.             id_configurazioneServizioAzione = new org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione();
  643.             id_configurazioneServizioAzione.setAzione((String)listaFieldId_configurazioneServizioAzione.get(0));
  644.             Long idConfigurazioneServizio = (Long)listaFieldId_configurazioneServizioAzione.get(1);
  645.             IdConfigurazioneServizio idConf = new IdConfigurazioneServizio();
  646.             idConf.setTipoSoggettoReferente((String)listaFieldId_configurazioneServizioAzione.get(2));
  647.             idConf.setNomeSoggettoReferente((String)listaFieldId_configurazioneServizioAzione.get(3));
  648.             idConf.setAccordo((String)listaFieldId_configurazioneServizioAzione.get(4));
  649.             idConf.setId(idConfigurazioneServizio);
  650.             idConf.setServizio((String)listaFieldId_configurazioneServizioAzione.get(5));
  651.             idConf.setVersione((Integer)listaFieldId_configurazioneServizioAzione.get(6));
  652.             id_configurazioneServizioAzione.setIdConfigurazioneServizio(idConf);
  653.         }
  654.        
  655.         return id_configurazioneServizioAzione;
  656.        
  657.     }

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

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

  688.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();

  689.         // Object _configurazioneServizio
  690.         if(id.getIdConfigurazioneServizio()==null){
  691.             throw new ServiceException("IdConfigurazioneServizio is null");
  692.         }
  693.                
  694.         IExpression expressionSearchConfigurazioneServizio = this.getServiceManager().getConfigurazioneServizioServiceSearch().newExpression();
  695.         expressionSearchConfigurazioneServizio.
  696.                                                     and().
  697.                                                     equals(ConfigurazioneServizio.model().ACCORDO, id.getIdConfigurazioneServizio().getAccordo()).
  698.                                                     equals(ConfigurazioneServizio.model().TIPO_SOGGETTO_REFERENTE, id.getIdConfigurazioneServizio().getTipoSoggettoReferente()).
  699.                                                     equals(ConfigurazioneServizio.model().NOME_SOGGETTO_REFERENTE, id.getIdConfigurazioneServizio().getNomeSoggettoReferente()).
  700.                                                     equals(ConfigurazioneServizio.model().VERSIONE, id.getIdConfigurazioneServizio().getVersione()).
  701.                                                     equals(ConfigurazioneServizio.model().SERVIZIO, id.getIdConfigurazioneServizio().getServizio());
  702.         ConfigurazioneServizio configurazioneServizio = this.getServiceManager().getConfigurazioneServizioServiceSearch().find(expressionSearchConfigurazioneServizio);
  703.         Long id_configurazioneServizio = configurazioneServizio.getId();
  704.        
  705.        
  706.         // Object _configurazioneServizioAzione
  707.         sqlQueryObjectGet.addFromTable(this.getConfigurazioneServizioAzioneFieldConverter().toTable(ConfigurazioneServizioAzione.model()));
  708.         sqlQueryObjectGet.addSelectField("id");
  709.         sqlQueryObjectGet.setANDLogicOperator(true);
  710.         sqlQueryObjectGet.setSelectDistinct(true);
  711.         sqlQueryObjectGet.addWhereCondition("id_config_servizio=?");
  712.         sqlQueryObjectGet.addWhereCondition(ConfigurazioneServizioAzione.model().AZIONE.getFieldName() + "=?");

  713.         // Recupero _configurazioneServizioAzione
  714.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_configurazioneServizioAzione = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  715.                 new JDBCObject( id_configurazioneServizio, Long.class ),
  716.                 new JDBCObject( id.getAzione(), String.class )
  717.         };
  718.         Long id_configurazioneServizioAzione = null;
  719.         try{
  720.             id_configurazioneServizioAzione = (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  721.                         Long.class, searchParams_configurazioneServizioAzione);
  722.         }catch(NotFoundException notFound){
  723.             if(throwNotFound){
  724.                 throw new NotFoundException(notFound);
  725.             }
  726.         }
  727.         if(id_configurazioneServizioAzione==null || id_configurazioneServizioAzione<=0){
  728.             if(throwNotFound){
  729.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  730.             }
  731.         }
  732.        
  733.         return id_configurazioneServizioAzione;
  734.     }
  735. }