JDBCConfigurazionePolicyServiceSearchImpl.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.core.controllo_traffico.dao.jdbc;

  21. import java.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.generic_project.utils.UtilsTemplate;
  32. import org.openspcoop2.generic_project.beans.CustomField;
  33. import org.openspcoop2.generic_project.beans.InUse;
  34. import org.openspcoop2.generic_project.beans.IField;
  35. import org.openspcoop2.generic_project.beans.NonNegativeNumber;
  36. import org.openspcoop2.generic_project.beans.UnionExpression;
  37. import org.openspcoop2.generic_project.beans.Union;
  38. import org.openspcoop2.generic_project.beans.FunctionField;
  39. import org.openspcoop2.generic_project.exception.MultipleResultException;
  40. import org.openspcoop2.generic_project.exception.NotFoundException;
  41. import org.openspcoop2.generic_project.exception.NotImplementedException;
  42. import org.openspcoop2.generic_project.exception.ServiceException;
  43. import org.openspcoop2.generic_project.expression.IExpression;
  44. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  45. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;

  46. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  47. import org.openspcoop2.core.controllo_traffico.ConfigurazionePolicy;
  48. import org.openspcoop2.core.controllo_traffico.IdPolicy;
  49. import org.openspcoop2.core.controllo_traffico.dao.jdbc.converter.ConfigurazionePolicyFieldConverter;
  50. import org.openspcoop2.core.controllo_traffico.dao.jdbc.fetch.ConfigurazionePolicyFetch;

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

  59.     private ConfigurazionePolicyFieldConverter _configurazionePolicyFieldConverter = null;
  60.     public ConfigurazionePolicyFieldConverter getConfigurazionePolicyFieldConverter() {
  61.         if(this._configurazionePolicyFieldConverter==null){
  62.             this._configurazionePolicyFieldConverter = new ConfigurazionePolicyFieldConverter(this.jdbcServiceManager.getJdbcProperties().getDatabaseType());
  63.         }      
  64.         return this._configurazionePolicyFieldConverter;
  65.     }
  66.     @Override
  67.     public ISQLFieldConverter getFieldConverter() {
  68.         return this.getConfigurazionePolicyFieldConverter();
  69.     }
  70.    
  71.     private ConfigurazionePolicyFetch configurazionePolicyFetch = new ConfigurazionePolicyFetch();
  72.     public ConfigurazionePolicyFetch getConfigurazionePolicyFetch() {
  73.         return this.configurazionePolicyFetch;
  74.     }
  75.     @Override
  76.     public IJDBCFetch getFetch() {
  77.         return getConfigurazionePolicyFetch();
  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 IdPolicy convertToId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazionePolicy configurazionePolicy) throws NotImplementedException, ServiceException, Exception{
  94.    
  95.         IdPolicy idConfigurazionePolicy = new IdPolicy();
  96.         idConfigurazionePolicy.setNome(configurazionePolicy.getIdPolicy());
  97.         return idConfigurazionePolicy;
  98.     }
  99.    
  100.     @Override
  101.     public ConfigurazionePolicy get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdPolicy id, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {
  102.         Long id_configurazionePolicy = ( (id!=null && id.getId()!=null && id.getId()>0) ? id.getId() : this.findIdConfigurazionePolicy(jdbcProperties, log, connection, sqlQueryObject, id, true));
  103.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, id_configurazionePolicy,idMappingResolutionBehaviour);
  104.        
  105.        
  106.     }
  107.    
  108.     @Override
  109.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdPolicy id) throws MultipleResultException, NotImplementedException, ServiceException,Exception {

  110.         Long id_configurazionePolicy = this.findIdConfigurazionePolicy(jdbcProperties, log, connection, sqlQueryObject, id, false);
  111.         return id_configurazionePolicy != null && id_configurazionePolicy > 0;
  112.        
  113.     }
  114.    
  115.     @Override
  116.     public List<IdPolicy> findAllIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException, ServiceException,Exception {

  117.         List<IdPolicy> list = new ArrayList<IdPolicy>();

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

  124.         List<Long> ids = this.findAllTableIds(jdbcProperties, log, connection, sqlQueryObject, expression);
  125.        
  126.         for(Long id: ids) {
  127.             ConfigurazionePolicy configurazionePolicy = this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour);
  128.             IdPolicy idConfigurazionePolicy = this.convertToId(jdbcProperties,log,connection,sqlQueryObject,configurazionePolicy);
  129.             list.add(idConfigurazionePolicy);
  130.         }

  131.         return list;
  132.        
  133.     }
  134.    
  135.     @Override
  136.     public List<ConfigurazionePolicy> findAll(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException, ServiceException,Exception {

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

  144.         List<Long> ids = this.findAllTableIds(jdbcProperties, log, connection, sqlQueryObject, expression);
  145.        
  146.         for(Long id: ids) {
  147.             list.add(this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour));
  148.         }

  149.         return list;      
  150.        
  151.     }
  152.    
  153.     @Override
  154.     public ConfigurazionePolicy find(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour)
  155.         throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {

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

  178.     @Override
  179.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdPolicy id) throws NotFoundException, NotImplementedException, ServiceException,Exception {
  180.        
  181.         Long id_configurazionePolicy = this.findIdConfigurazionePolicy(jdbcProperties, log, connection, sqlQueryObject, id, true);
  182.         return this.inUseEngine(jdbcProperties, log, connection, sqlQueryObject, id_configurazionePolicy);
  183.        
  184.     }

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

  217.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, sqlQueryObjectDistinct);
  218.            
  219.         }finally{
  220.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,field);
  221.         }
  222.     }

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

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

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



  359.     // -- ConstructorExpression

  360.     @Override
  361.     public JDBCExpression newExpression(Logger log) throws NotImplementedException, ServiceException {
  362.         try{
  363.             return new JDBCExpression(this.getConfigurazionePolicyFieldConverter());
  364.         }catch(Exception e){
  365.             throw new ServiceException(e);
  366.         }
  367.     }


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

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

  397.     @Override
  398.     public void mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdPolicy id, ConfigurazionePolicy obj) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  399.         _mappingTableIds(jdbcProperties,log,connection,sqlQueryObject,obj,
  400.                 this.get(jdbcProperties,log,connection,sqlQueryObject,id,null));
  401.     }
  402.    
  403.     @Override
  404.     public void mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, ConfigurazionePolicy obj) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  405.         _mappingTableIds(jdbcProperties,log,connection,sqlQueryObject,obj,
  406.                 this.get(jdbcProperties,log,connection,sqlQueryObject,tableId,null));
  407.     }
  408.     private void _mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazionePolicy obj, ConfigurazionePolicy imgSaved) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  409.         if(imgSaved==null){
  410.             return;
  411.         }
  412.         obj.setId(imgSaved.getId());

  413.     }
  414.    
  415.     @Override
  416.     public ConfigurazionePolicy get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  417.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId), idMappingResolutionBehaviour);
  418.     }
  419.    
  420.     private ConfigurazionePolicy getEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  421.    
  422.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  423.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  424.        
  425.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();
  426.                
  427.         ConfigurazionePolicy configurazionePolicy = new ConfigurazionePolicy();
  428.        

  429.         // Object configurazionePolicy
  430.         sqlQueryObjectGet.setANDLogicOperator(true);
  431.         sqlQueryObjectGet.addFromTable(this.getConfigurazionePolicyFieldConverter().toTable(ConfigurazionePolicy.model()));
  432.         sqlQueryObjectGet.addSelectField("id");
  433.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().ID_POLICY,true));
  434.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().BUILT_IN,true));
  435.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().DESCRIZIONE,true));
  436.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().RISORSA,true));
  437.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().SIMULTANEE,true));
  438.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().VALORE,true));
  439.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().VALORE_2,true));
  440.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().VALORE_TIPO_BANDA,true));
  441.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().VALORE_TIPO_LATENZA,true));
  442.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().MODALITA_CONTROLLO,true));
  443.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().TIPO_INTERVALLO_OSSERVAZIONE_REALTIME,true));
  444.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().TIPO_INTERVALLO_OSSERVAZIONE_STATISTICO,true));
  445.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().INTERVALLO_OSSERVAZIONE,true));
  446.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().FINESTRA_OSSERVAZIONE,true));
  447.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().TIPO_APPLICABILITA,true));
  448.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().APPLICABILITA_CON_CONGESTIONE,true));
  449.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().APPLICABILITA_DEGRADO_PRESTAZIONALE,true));
  450.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().DEGRADO_AVG_TIME_MODALITA_CONTROLLO,true));
  451.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().DEGRADO_AVG_TIME_TIPO_INTERVALLO_OSSERVAZIONE_REALTIME,true));
  452.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().DEGRADO_AVG_TIME_TIPO_INTERVALLO_OSSERVAZIONE_STATISTICO,true));
  453.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().DEGRADO_AVG_TIME_INTERVALLO_OSSERVAZIONE,true));
  454.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().DEGRADO_AVG_TIME_FINESTRA_OSSERVAZIONE,true));
  455.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().DEGRADO_AVG_TIME_TIPO_LATENZA,true));
  456.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().APPLICABILITA_STATO_ALLARME,true));
  457.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().ALLARME_NOME,true));
  458.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().ALLARME_STATO,true));
  459.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().ALLARME_NOT_STATO,true));
  460.         sqlQueryObjectGet.addWhereCondition("id=?");

  461.         // Get configurazionePolicy
  462.         configurazionePolicy = (ConfigurazionePolicy) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(), ConfigurazionePolicy.model(), this.getConfigurazionePolicyFetch(),
  463.             new JDBCObject(tableId,Long.class));



  464.        
  465.         return configurazionePolicy;  
  466.    
  467.     }
  468.    
  469.     @Override
  470.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  471.         return this._exists(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  472.     }
  473.    
  474.     private boolean _exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  475.    
  476.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  477.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  478.                
  479.         boolean existsConfigurazionePolicy = false;

  480.         sqlQueryObject = sqlQueryObject.newSQLQueryObject();
  481.         sqlQueryObject.setANDLogicOperator(true);

  482.         sqlQueryObject.addFromTable(this.getConfigurazionePolicyFieldConverter().toTable(ConfigurazionePolicy.model()));
  483.         sqlQueryObject.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().ID_POLICY,true));
  484.         sqlQueryObject.addWhereCondition("id=?");


  485.         // Exists configurazionePolicy
  486.         existsConfigurazionePolicy = jdbcUtilities.exists(sqlQueryObject.createSQLQuery(), jdbcProperties.isShowSql(),
  487.             new JDBCObject(tableId,Long.class));

  488.        
  489.         return existsConfigurazionePolicy;
  490.    
  491.     }
  492.    
  493.     private void joinEngine(IExpression expression, ISQLQueryObject sqlQueryObject) throws NotImplementedException, ServiceException, Exception{
  494.        
  495.     }
  496.    
  497.     protected java.util.List<Object> getRootTablePrimaryKeyValuesEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdPolicy id) throws NotFoundException, ServiceException, NotImplementedException, Exception{
  498.         // Identificativi
  499.         java.util.List<Object> rootTableIdValues = new java.util.ArrayList<>();
  500.         Long longId = this.findIdConfigurazionePolicy(jdbcProperties, log, connection, sqlQueryObject.newSQLQueryObject(), id, true);
  501.         rootTableIdValues.add(longId);
  502.        
  503.         return rootTableIdValues;
  504.     }
  505.    
  506.     protected Map<String, List<IField>> getMapTableToPKColumnEngine() throws NotImplementedException, Exception{
  507.    
  508.         ConfigurazionePolicyFieldConverter converter = this.getConfigurazionePolicyFieldConverter();
  509.         Map<String, List<IField>> mapTableToPKColumn = new java.util.HashMap<>();
  510.         UtilsTemplate<IField> utilities = new UtilsTemplate<>();

  511.         // ConfigurazionePolicy.model()
  512.         mapTableToPKColumn.put(converter.toTable(ConfigurazionePolicy.model()),
  513.             utilities.newList(
  514.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazionePolicy.model()))
  515.             ));
  516.        
  517.         return mapTableToPKColumn;      
  518.     }
  519.    
  520.     @Override
  521.     public List<Long> findAllTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression paginatedExpression) throws ServiceException, NotImplementedException, Exception {
  522.        
  523.         List<Long> list = new ArrayList<Long>();

  524.         sqlQueryObject.setSelectDistinct(true);
  525.         sqlQueryObject.setANDLogicOperator(true);
  526.         sqlQueryObject.addSelectField(this.getConfigurazionePolicyFieldConverter().toTable(ConfigurazionePolicy.model())+".id");
  527.         Class<?> objectIdClass = Long.class;
  528.        
  529.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFindAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  530.                                                 this.getConfigurazionePolicyFieldConverter(), ConfigurazionePolicy.model());
  531.        
  532.         joinEngine(paginatedExpression,sqlQueryObject);
  533.        
  534.         List<Object> listObjects = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.findAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  535.                                                                             this.getConfigurazionePolicyFieldConverter(), ConfigurazionePolicy.model(), objectIdClass, listaQuery);
  536.         for(Object object: listObjects) {
  537.             list.add((Long)object);
  538.         }

  539.         return list;
  540.        
  541.     }
  542.    
  543.     @Override
  544.     public long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException, Exception {
  545.    
  546.         sqlQueryObject.setSelectDistinct(true);
  547.         sqlQueryObject.setANDLogicOperator(true);
  548.         sqlQueryObject.addSelectField(this.getConfigurazionePolicyFieldConverter().toTable(ConfigurazionePolicy.model())+".id");
  549.         Class<?> objectIdClass = Long.class;
  550.        
  551.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFind(jdbcProperties, log, connection, sqlQueryObject, expression,
  552.                                                 this.getConfigurazionePolicyFieldConverter(), ConfigurazionePolicy.model());
  553.        
  554.         joinEngine(expression,sqlQueryObject);

  555.         Object res = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.find(jdbcProperties, log, connection, sqlQueryObject, expression,
  556.                                                         this.getConfigurazionePolicyFieldConverter(), ConfigurazionePolicy.model(), objectIdClass, listaQuery);
  557.         if(res!=null && (((Long) res).longValue()>0) ){
  558.             return ((Long) res).longValue();
  559.         }
  560.         else{
  561.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  562.         }
  563.        
  564.     }

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

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

  570.         InUse inUse = new InUse();
  571.         inUse.setInUse(false);
  572.        
  573.         /*
  574.          * TODO: implement code that checks whether the object identified by the id parameter is used by other objects
  575.         */
  576.        
  577.         // Delete this line when you have implemented the method
  578.         int throwNotImplemented = 1;
  579.         if(throwNotImplemented==1){
  580.                 throw new NotImplementedException("NotImplemented");
  581.         }
  582.         // Delete this line when you have implemented the method

  583.         return inUse;

  584.     }
  585.    
  586.     @Override
  587.     public IdPolicy findId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, boolean throwNotFound)
  588.             throws NotFoundException, ServiceException, NotImplementedException, Exception {
  589.        
  590.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  591.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);

  592.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();
  593.                

  594.         // Object _configurazionePolicy
  595.         sqlQueryObjectGet.addFromTable(this.getConfigurazionePolicyFieldConverter().toTable(ConfigurazionePolicy.model()));
  596.         sqlQueryObjectGet.addSelectField(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().ID_POLICY,true));
  597.         sqlQueryObjectGet.setANDLogicOperator(true);
  598.         sqlQueryObjectGet.addWhereCondition("id=?");

  599.         // Recupero _configurazionePolicy
  600.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_configurazionePolicy = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  601.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(tableId,Long.class)
  602.         };
  603.         List<Class<?>> listaFieldIdReturnType_configurazionePolicy = new ArrayList<Class<?>>();
  604.         listaFieldIdReturnType_configurazionePolicy.add(ConfigurazionePolicy.model().ID_POLICY.getFieldType());
  605.         org.openspcoop2.core.controllo_traffico.IdPolicy id_configurazionePolicy = null;
  606.         List<Object> listaFieldId_configurazionePolicy = jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  607.                 listaFieldIdReturnType_configurazionePolicy, searchParams_configurazionePolicy);
  608.         if(listaFieldId_configurazionePolicy==null || listaFieldId_configurazionePolicy.size()<=0){
  609.             if(throwNotFound){
  610.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  611.             }
  612.         }
  613.         else{
  614.             // set _configurazionePolicy
  615.             id_configurazionePolicy = new org.openspcoop2.core.controllo_traffico.IdPolicy();
  616.             id_configurazionePolicy.setNome((String)listaFieldId_configurazionePolicy.get(0));
  617.         }
  618.        
  619.         return id_configurazionePolicy;
  620.        
  621.     }

  622.     @Override
  623.     public Long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdPolicy id, boolean throwNotFound)
  624.             throws NotFoundException, ServiceException, NotImplementedException, Exception {
  625.    
  626.         return this.findIdConfigurazionePolicy(jdbcProperties,log,connection,sqlQueryObject,id,throwNotFound);
  627.            
  628.     }
  629.    
  630.     @Override
  631.     public List<List<Object>> nativeQuery(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  632.                                             String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException,Exception{
  633.        
  634.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.nativeQuery(jdbcProperties, log, connection, sqlQueryObject,
  635.                                                                                             sql,returnClassTypes,param);
  636.                                                        
  637.     }
  638.    
  639.     protected Long findIdConfigurazionePolicy(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdPolicy id, boolean throwNotFound) throws NotFoundException, ServiceException, NotImplementedException, Exception {

  640.         if(jdbcProperties==null) {
  641.             throw new ServiceException("Param jdbcProperties is null");
  642.         }
  643.         if(sqlQueryObject==null) {
  644.             throw new ServiceException("Param sqlQueryObject is null");
  645.         }
  646.         if(id==null) {
  647.             throw new ServiceException("Param id is null");
  648.         }
  649.        
  650.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  651.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);

  652.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();

  653.         // Object _configurazionePolicy
  654.         sqlQueryObjectGet.addFromTable(this.getConfigurazionePolicyFieldConverter().toTable(ConfigurazionePolicy.model()));
  655.         sqlQueryObjectGet.addSelectField("id");
  656.         // Devono essere mappati nella where condition i metodi dell'oggetto id.getXXX
  657.         sqlQueryObjectGet.setANDLogicOperator(true);
  658.         sqlQueryObjectGet.setSelectDistinct(true);
  659.         sqlQueryObjectGet.addWhereCondition(this.getConfigurazionePolicyFieldConverter().toColumn(ConfigurazionePolicy.model().ID_POLICY,true)+"=?");
  660.        
  661.         // Recupero _configurazionePolicy
  662.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_configurazionePolicy = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  663.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(id.getNome(),String.class),
  664.         };
  665.         Long id_configurazionePolicy = null;
  666.         try{
  667.             id_configurazionePolicy = (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  668.                         Long.class, searchParams_configurazionePolicy);
  669.         }catch(NotFoundException notFound){
  670.             if(throwNotFound){
  671.                 throw new NotFoundException(notFound);
  672.             }
  673.         }
  674.         if(id_configurazionePolicy==null || id_configurazionePolicy<=0){
  675.             if(throwNotFound){
  676.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  677.             }
  678.         }
  679.        
  680.         return id_configurazionePolicy;
  681.     }
  682. }