JDBCConfigurazioneFiltroServiceSearch.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 org.openspcoop2.generic_project.dao.IDBServiceUtilities;
  22. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceSearchWithId;
  23. import org.openspcoop2.core.plugins.IdConfigurazioneFiltro;
  24. import org.openspcoop2.generic_project.beans.InUse;
  25. import org.openspcoop2.generic_project.beans.IField;
  26. import org.openspcoop2.generic_project.beans.NonNegativeNumber;
  27. import org.openspcoop2.generic_project.beans.UnionExpression;
  28. import org.openspcoop2.generic_project.beans.Union;
  29. import org.openspcoop2.generic_project.beans.FunctionField;
  30. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  31. import org.openspcoop2.generic_project.exception.ExpressionException;
  32. import org.openspcoop2.generic_project.exception.MultipleResultException;
  33. import org.openspcoop2.generic_project.exception.NotFoundException;
  34. import org.openspcoop2.generic_project.exception.NotImplementedException;
  35. import org.openspcoop2.generic_project.exception.ServiceException;
  36. import org.openspcoop2.generic_project.exception.ValidationException;
  37. import org.openspcoop2.generic_project.expression.IExpression;
  38. import org.openspcoop2.generic_project.expression.IPaginatedExpression;
  39. import org.openspcoop2.generic_project.expression.impl.sql.ISQLFieldConverter;
  40. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  41. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;
  42. import org.openspcoop2.generic_project.dao.jdbc.JDBCProperties;
  43. import org.openspcoop2.generic_project.dao.jdbc.utils.IJDBCFetch;
  44. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBC_SQLObjectFactory;

  45. import org.openspcoop2.core.plugins.ConfigurazioneFiltro;
  46. import org.openspcoop2.core.plugins.dao.IDBConfigurazioneFiltroServiceSearch;
  47. import org.openspcoop2.core.plugins.utils.ProjectInfo;

  48. import java.sql.Connection;
  49. import java.util.List;
  50. import java.util.Map;

  51. import org.slf4j.Logger;
  52. import org.openspcoop2.utils.sql.ISQLQueryObject;

  53. /**    
  54.  * Service can be used to search for the backend objects of type {@link org.openspcoop2.core.plugins.ConfigurazioneFiltro}
  55.  *
  56.  * @author Poli Andrea (poli@link.it)
  57.  * @author $Author$
  58.  * @version $Rev$, $Date$
  59. */
  60. public class JDBCConfigurazioneFiltroServiceSearch implements IDBConfigurazioneFiltroServiceSearch, IDBServiceUtilities<ConfigurazioneFiltro> {


  61.     protected JDBCServiceManagerProperties jdbcProperties = null;
  62.     protected JDBCServiceManager jdbcServiceManager = null;
  63.     protected Logger log = null;
  64.     protected IJDBCServiceSearchWithId<ConfigurazioneFiltro, IdConfigurazioneFiltro, JDBCServiceManager> serviceSearch = null;
  65.     protected JDBC_SQLObjectFactory jdbcSqlObjectFactory = null;
  66.     public JDBCConfigurazioneFiltroServiceSearch(JDBCServiceManager jdbcServiceManager) throws ServiceException {
  67.         this.jdbcServiceManager = jdbcServiceManager;
  68.         this.jdbcProperties = jdbcServiceManager.getJdbcProperties();
  69.         this.log = jdbcServiceManager.getLog();
  70.         String msgInit = JDBCConfigurazioneFiltroServiceSearch.class.getName()+ " initialized";
  71.         this.log.debug(msgInit);
  72.         this.serviceSearch = JDBCProperties.getInstance(org.openspcoop2.core.plugins.dao.jdbc.JDBCServiceManager.class.getPackage(),ProjectInfo.getInstance()).getServiceSearch("configurazioneFiltro");
  73.         this.serviceSearch.setServiceManager(new JDBCLimitedServiceManager(this.jdbcServiceManager));
  74.         this.jdbcSqlObjectFactory = new JDBC_SQLObjectFactory();
  75.     }
  76.    
  77.     protected void logError(Exception e) {
  78.         if(e!=null && this.log!=null) {
  79.             this.log.error(e.getMessage(),e);
  80.         }
  81.     }
  82.     protected void logDebug(Exception e) {
  83.         if(e!=null && this.log!=null) {
  84.             this.log.debug(e.getMessage(),e);
  85.         }
  86.     }
  87.     protected void logJDBCExpression(JDBCExpression jdbcExpression) throws ExpressionException{
  88.         if(this.log!=null) {
  89.             String msgDebug = "sql = "+jdbcExpression.toSql();
  90.             this.log.debug(msgDebug);
  91.         }
  92.     }
  93.     protected void logJDBCPaginatedExpression(JDBCPaginatedExpression jdbcPaginatedExpression) throws ExpressionException{
  94.         if(this.log!=null) {
  95.             String msgDebug = "sql = "+jdbcPaginatedExpression.toSql();
  96.             this.log.debug(msgDebug);
  97.         }
  98.     }
  99.    
  100.     private static final String PARAMETER_TYPE_PREFIX = "Parameter (type:";
  101.        
  102.     private ServiceException newServiceExceptionParameterObjIsNull(){
  103.         return new ServiceException(PARAMETER_TYPE_PREFIX+ConfigurazioneFiltro.class.getName()+") 'obj' is null");
  104.     }
  105.     protected ServiceException newServiceExceptionParameterIdIsNull(){
  106.         return new ServiceException(PARAMETER_TYPE_PREFIX+IdConfigurazioneFiltro.class.getName()+") 'id' is null");
  107.     }
  108.     private ServiceException newServiceExceptionParameterIdMappingResolutionBehaviourIsNull(){
  109.         return new ServiceException(PARAMETER_TYPE_PREFIX+org.openspcoop2.generic_project.beans.IDMappingBehaviour.class.getName()+") 'idMappingResolutionBehaviour' is null");
  110.     }

  111.     protected ServiceException newServiceExceptionParameterExpressionWrongType(IExpression expression){
  112.         return new ServiceException(PARAMETER_TYPE_PREFIX+expression.getClass().getName()+") 'expression' has wrong type, expect "+JDBCExpression.class.getName());
  113.     }
  114.     protected ServiceException newServiceExceptionParameterExpressionIsNull(){
  115.         return new ServiceException(PARAMETER_TYPE_PREFIX+IExpression.class.getName()+") 'expression' is null");
  116.     }
  117.    
  118.     private ServiceException newServiceExceptionParameterPaginatedExpressionIsNull(){
  119.         return new ServiceException(PARAMETER_TYPE_PREFIX+IPaginatedExpression.class.getName()+") 'expression' is null");
  120.     }
  121.     private ServiceException newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated(){
  122.         return new ServiceException(PARAMETER_TYPE_PREFIX+IPaginatedExpression.class.getName()+") 'paginatedExpression' is null");
  123.     }
  124.     private ServiceException newServiceExceptionParameterPaginatedExpressionWrongType(IPaginatedExpression expression){
  125.         return new ServiceException(PARAMETER_TYPE_PREFIX+expression.getClass().getName()+") 'expression' has wrong type, expect "+JDBCPaginatedExpression.class.getName());
  126.     }
  127.     private ServiceException newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(IPaginatedExpression paginatedExpression){
  128.         return new ServiceException(PARAMETER_TYPE_PREFIX+paginatedExpression.getClass().getName()+") 'paginatedExpression' has wrong type, expect "+JDBCPaginatedExpression.class.getName());
  129.     }
  130.    
  131.     private ServiceException newServiceExceptionParameterUnionExpressionIsNull(){
  132.         return new ServiceException(PARAMETER_TYPE_PREFIX+UnionExpression.class.getName()+") 'unionExpression' is null");
  133.     }
  134.    
  135.     private ServiceException newServiceExceptionParameterWithTypeTableIdLessEqualsZero(){
  136.         return new ServiceException(PARAMETER_TYPE_PREFIX+IdConfigurazioneFiltro.class.getName()+") 'tableId' is lessEquals 0");
  137.     }
  138.     private ServiceException newServiceExceptionParameterTableIdLessEqualsZero(){
  139.         return new ServiceException("Parameter 'tableId' is less equals 0");
  140.     }
  141.    
  142.     @Override
  143.     public void validate(ConfigurazioneFiltro configurazioneFiltro) throws ServiceException,
  144.             ValidationException, NotImplementedException {
  145.         org.openspcoop2.generic_project.utils.XSDValidator.validate(configurazioneFiltro, this.log,
  146.                 org.openspcoop2.core.plugins.utils.XSDValidator.getXSDValidator(this.log));
  147.     }
  148.    
  149.     @Override
  150.     public IJDBCFetch getFetch() {
  151.         return this.serviceSearch.getFetch();
  152.     }

  153.     @Override
  154.     public ISQLFieldConverter getFieldConverter() {
  155.         return this.serviceSearch.getFieldConverter();
  156.     }
  157.    
  158.     @Override
  159.     public IdConfigurazioneFiltro convertToId(ConfigurazioneFiltro obj)
  160.             throws ServiceException, NotImplementedException {
  161.        
  162.         Connection connection = null;
  163.         try{
  164.            
  165.             // check parameters
  166.             if(obj==null){
  167.                 throw this.newServiceExceptionParameterObjIsNull();
  168.             }
  169.            
  170.             // ISQLQueryObject
  171.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  172.             sqlQueryObject.setANDLogicOperator(true);
  173.             // Connection sql
  174.             connection = this.jdbcServiceManager.getConnection();
  175.        
  176.             return this.serviceSearch.convertToId(this.jdbcProperties,this.log,connection,sqlQueryObject,obj);
  177.        
  178.         }catch(ServiceException | NotImplementedException e){
  179.             this.logError(e); throw e;
  180.         }catch(Exception e){
  181.             this.logError(e); throw new ServiceException("ConvertToId not completed: "+e.getMessage(),e);
  182.         }finally{
  183.             if(connection!=null){
  184.                 this.jdbcServiceManager.closeConnection(connection);
  185.             }
  186.         }
  187.        
  188.     }
  189.        
  190.     @Override
  191.     public ConfigurazioneFiltro get(IdConfigurazioneFiltro id) throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  192.    
  193.         Connection connection = null;
  194.         try{
  195.            
  196.             // check parameters
  197.             if(id==null){
  198.                 throw this.newServiceExceptionParameterIdIsNull();
  199.             }
  200.            
  201.             // ISQLQueryObject
  202.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  203.             sqlQueryObject.setANDLogicOperator(true);
  204.             // Connection sql
  205.             connection = this.jdbcServiceManager.getConnection();
  206.        
  207.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,id,null);
  208.        
  209.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  210.             this.logError(e); throw e;
  211.         }catch(NotFoundException e){
  212.             this.logDebug(e); throw e;
  213.         }catch(Exception e){
  214.             this.logError(e); throw new ServiceException("Get not completed: "+e.getMessage(),e);
  215.         }finally{
  216.             if(connection!=null){
  217.                 this.jdbcServiceManager.closeConnection(connection);
  218.             }
  219.         }
  220.    
  221.     }

  222.     @Override
  223.     public ConfigurazioneFiltro get(IdConfigurazioneFiltro id, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  224.         Connection connection = null;
  225.         try{
  226.            
  227.             // check parameters
  228.             if(id==null){
  229.                 throw this.newServiceExceptionParameterIdIsNull();
  230.             }
  231.             if(idMappingResolutionBehaviour==null){
  232.                 throw this.newServiceExceptionParameterIdMappingResolutionBehaviourIsNull();
  233.             }
  234.            
  235.             // ISQLQueryObject
  236.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  237.             sqlQueryObject.setANDLogicOperator(true);
  238.             // Connection sql
  239.             connection = this.jdbcServiceManager.getConnection();
  240.        
  241.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,id,idMappingResolutionBehaviour);
  242.        
  243.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  244.             this.logError(e); throw e;
  245.         }catch(NotFoundException e){
  246.             this.logDebug(e); throw e;
  247.         }catch(Exception e){
  248.             this.logError(e); throw new ServiceException("Get (idMappingResolutionBehaviour) not completed: "+e.getMessage(),e);
  249.         }finally{
  250.             if(connection!=null){
  251.                 this.jdbcServiceManager.closeConnection(connection);
  252.             }
  253.         }
  254.    
  255.     }

  256.     @Override
  257.     public boolean exists(IdConfigurazioneFiltro id) throws MultipleResultException,ServiceException,NotImplementedException {

  258.         Connection connection = null;
  259.         try{
  260.            
  261.             // check parameters
  262.             if(id==null){
  263.                 throw this.newServiceExceptionParameterIdIsNull();
  264.             }

  265.             // ISQLQueryObject
  266.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  267.             sqlQueryObject.setANDLogicOperator(true);
  268.             // Connection sql
  269.             connection = this.jdbcServiceManager.getConnection();

  270.             return this.serviceSearch.exists(this.jdbcProperties,this.log,connection,sqlQueryObject,id);
  271.    
  272.         }catch(MultipleResultException | ServiceException | NotImplementedException e){
  273.             this.logError(e); throw e;
  274.         }catch(Exception e){
  275.             this.logError(e); throw new ServiceException("Exists not completed: "+e.getMessage(),e);
  276.         }finally{
  277.             if(connection!=null){
  278.                 this.jdbcServiceManager.closeConnection(connection);
  279.             }
  280.         }
  281.        
  282.     }
  283.    
  284.     @Override
  285.     public List<IdConfigurazioneFiltro> findAllIds(IPaginatedExpression expression) throws ServiceException, NotImplementedException {

  286.         Connection connection = null;
  287.         try{
  288.            
  289.             // check parameters
  290.             if(expression==null){
  291.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  292.             }
  293.             if( ! (expression instanceof JDBCPaginatedExpression) ){
  294.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongType(expression);
  295.             }
  296.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) expression;
  297.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  298.             // ISQLQueryObject
  299.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  300.             sqlQueryObject.setANDLogicOperator(true);
  301.             // Connection sql
  302.             connection = this.jdbcServiceManager.getConnection();
  303.            
  304.             return this.serviceSearch.findAllIds(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,null);
  305.    
  306.         }catch(ServiceException | NotImplementedException e){
  307.             this.logError(e); throw e;
  308.         }catch(Exception e){
  309.             this.logError(e); throw new ServiceException("FindAllIds not completed: "+e.getMessage(),e);
  310.         }finally{
  311.             if(connection!=null){
  312.                 this.jdbcServiceManager.closeConnection(connection);
  313.             }
  314.         }
  315.        
  316.     }
  317.    
  318.     @Override
  319.     public List<IdConfigurazioneFiltro> findAllIds(IPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotImplementedException {

  320.         Connection connection = null;
  321.         try{
  322.            
  323.             // check parameters
  324.             if(idMappingResolutionBehaviour==null){
  325.                 throw this.newServiceExceptionParameterIdMappingResolutionBehaviourIsNull();
  326.             }
  327.             if(expression==null){
  328.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  329.             }
  330.             if( ! (expression instanceof JDBCPaginatedExpression) ){
  331.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongType(expression);
  332.             }
  333.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) expression;
  334.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  335.             // ISQLQueryObject
  336.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  337.             sqlQueryObject.setANDLogicOperator(true);
  338.             // Connection sql
  339.             connection = this.jdbcServiceManager.getConnection();
  340.            
  341.             return this.serviceSearch.findAllIds(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,idMappingResolutionBehaviour);
  342.    
  343.         }catch(ServiceException | NotImplementedException e){
  344.             this.logError(e); throw e;
  345.         }catch(Exception e){
  346.             this.logError(e); throw new ServiceException("FindAllIds not completed: "+e.getMessage(),e);
  347.         }finally{
  348.             if(connection!=null){
  349.                 this.jdbcServiceManager.closeConnection(connection);
  350.             }
  351.         }
  352.        
  353.     }

  354.     @Override
  355.     public List<ConfigurazioneFiltro> findAll(IPaginatedExpression expression) throws ServiceException, NotImplementedException {

  356.         Connection connection = null;
  357.         try{
  358.            
  359.             // check parameters
  360.             if(expression==null){
  361.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  362.             }
  363.             if( ! (expression instanceof JDBCPaginatedExpression) ){
  364.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongType(expression);
  365.             }
  366.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) expression;
  367.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  368.             // ISQLQueryObject
  369.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  370.             sqlQueryObject.setANDLogicOperator(true);
  371.             // Connection sql
  372.             connection = this.jdbcServiceManager.getConnection();

  373.             return this.serviceSearch.findAll(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,null);        
  374.    
  375.         }catch(ServiceException | NotImplementedException e){
  376.             this.logError(e); throw e;
  377.         }catch(Exception e){
  378.             this.logError(e); throw new ServiceException("FindAll not completed: "+e.getMessage(),e);
  379.         }finally{
  380.             if(connection!=null){
  381.                 this.jdbcServiceManager.closeConnection(connection);
  382.             }
  383.         }
  384.        
  385.     }
  386.    
  387.     @Override
  388.     public List<ConfigurazioneFiltro> findAll(IPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotImplementedException {

  389.         Connection connection = null;
  390.         try{
  391.            
  392.             // check parameters
  393.             if(idMappingResolutionBehaviour==null){
  394.                 throw this.newServiceExceptionParameterIdMappingResolutionBehaviourIsNull();
  395.             }
  396.             if(expression==null){
  397.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  398.             }
  399.             if( ! (expression instanceof JDBCPaginatedExpression) ){
  400.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongType(expression);
  401.             }
  402.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) expression;
  403.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  404.             // ISQLQueryObject
  405.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  406.             sqlQueryObject.setANDLogicOperator(true);
  407.             // Connection sql
  408.             connection = this.jdbcServiceManager.getConnection();

  409.             return this.serviceSearch.findAll(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,idMappingResolutionBehaviour);        
  410.    
  411.         }catch(ServiceException | NotImplementedException e){
  412.             this.logError(e); throw e;
  413.         }catch(Exception e){
  414.             this.logError(e); throw new ServiceException("FindAll not completed: "+e.getMessage(),e);
  415.         }finally{
  416.             if(connection!=null){
  417.                 this.jdbcServiceManager.closeConnection(connection);
  418.             }
  419.         }
  420.        
  421.     }

  422.     @Override
  423.     public ConfigurazioneFiltro find(IExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException {

  424.         Connection connection = null;
  425.         try{
  426.            
  427.             // check parameters
  428.             if(expression==null){
  429.                 throw this.newServiceExceptionParameterExpressionIsNull();
  430.             }
  431.             if( ! (expression instanceof JDBCExpression) ){
  432.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  433.             }
  434.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  435.             this.logJDBCExpression(jdbcExpression);

  436.             // ISQLQueryObject
  437.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  438.             sqlQueryObject.setANDLogicOperator(true);
  439.             // Connection sql
  440.             connection = this.jdbcServiceManager.getConnection();

  441.             return this.serviceSearch.find(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression,null);        

  442.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  443.             this.logError(e); throw e;
  444.         }catch(NotFoundException e){
  445.             this.logDebug(e); throw e;
  446.         }catch(Exception e){
  447.             this.logError(e); throw new ServiceException("Find not completed: "+e.getMessage(),e);
  448.         }finally{
  449.             if(connection!=null){
  450.                 this.jdbcServiceManager.closeConnection(connection);
  451.             }
  452.         }
  453.        
  454.     }
  455.    
  456.     @Override
  457.     public ConfigurazioneFiltro find(IExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException {

  458.         Connection connection = null;
  459.         try{
  460.            
  461.             // check parameters
  462.             if(idMappingResolutionBehaviour==null){
  463.                 throw this.newServiceExceptionParameterIdMappingResolutionBehaviourIsNull();
  464.             }
  465.             if(expression==null){
  466.                 throw this.newServiceExceptionParameterExpressionIsNull();
  467.             }
  468.             if( ! (expression instanceof JDBCExpression) ){
  469.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  470.             }
  471.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  472.             this.logJDBCExpression(jdbcExpression);

  473.             // ISQLQueryObject
  474.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  475.             sqlQueryObject.setANDLogicOperator(true);
  476.             // Connection sql
  477.             connection = this.jdbcServiceManager.getConnection();

  478.             return this.serviceSearch.find(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression,idMappingResolutionBehaviour);        

  479.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  480.             this.logError(e); throw e;
  481.         }catch(NotFoundException e){
  482.             this.logDebug(e); throw e;
  483.         }catch(Exception e){
  484.             this.logError(e); throw new ServiceException("Find not completed: "+e.getMessage(),e);
  485.         }finally{
  486.             if(connection!=null){
  487.                 this.jdbcServiceManager.closeConnection(connection);
  488.             }
  489.         }
  490.        
  491.     }

  492.     @Override
  493.     public NonNegativeNumber count(IExpression expression) throws ServiceException, NotImplementedException {

  494.         Connection connection = null;
  495.         try{
  496.            
  497.             // check parameters
  498.             if(expression==null){
  499.                 throw this.newServiceExceptionParameterExpressionIsNull();
  500.             }
  501.             if( ! (expression instanceof JDBCExpression) ){
  502.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  503.             }
  504.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  505.             this.logJDBCExpression(jdbcExpression);
  506.            
  507.             // ISQLQueryObject
  508.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  509.             sqlQueryObject.setANDLogicOperator(true);
  510.             // Connection sql
  511.             connection = this.jdbcServiceManager.getConnection();

  512.             return this.serviceSearch.count(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression);
  513.    
  514.         }catch(ServiceException | NotImplementedException e){
  515.             this.logError(e); throw e;
  516.         }catch(Exception e){
  517.             this.logError(e); throw new ServiceException("Count not completed: "+e.getMessage(),e);
  518.         }finally{
  519.             if(connection!=null){
  520.                 this.jdbcServiceManager.closeConnection(connection);
  521.             }
  522.         }
  523.        
  524.     }

  525.     @Override
  526.     public InUse inUse(IdConfigurazioneFiltro id) throws ServiceException, NotFoundException,NotImplementedException {

  527.         Connection connection = null;
  528.         try{
  529.            
  530.             // check parameters
  531.             if(id==null){
  532.                 throw this.newServiceExceptionParameterIdIsNull();
  533.             }
  534.            
  535.             // ISQLQueryObject
  536.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  537.             sqlQueryObject.setANDLogicOperator(true);
  538.             // Connection sql
  539.             connection = this.jdbcServiceManager.getConnection();

  540.             return this.serviceSearch.inUse(this.jdbcProperties,this.log,connection,sqlQueryObject,id);
  541.    
  542.         }catch(ServiceException | NotImplementedException e){
  543.             this.logError(e); throw e;
  544.         }catch(NotFoundException e){
  545.             this.logDebug(e); throw e;
  546.         }catch(Exception e){
  547.             this.logError(e); throw new ServiceException("InUse not completed: "+e.getMessage(),e);
  548.         }finally{
  549.             if(connection!=null){
  550.                 this.jdbcServiceManager.closeConnection(connection);
  551.             }
  552.         }
  553.        
  554.     }
  555.    
  556.     @Override
  557.     public List<Object> select(IPaginatedExpression paginatedExpression, IField field) throws ServiceException,NotFoundException,NotImplementedException {
  558.    
  559.         Connection connection = null;
  560.         try{
  561.            
  562.             // check parameters
  563.             if(paginatedExpression==null){
  564.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  565.             }
  566.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  567.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  568.             }
  569.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  570.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  571.             // ISQLQueryObject
  572.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  573.             sqlQueryObject.setANDLogicOperator(true);
  574.             // Connection sql
  575.             connection = this.jdbcServiceManager.getConnection();

  576.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,field);        
  577.    
  578.         }catch(ServiceException | NotImplementedException e){
  579.             this.logError(e); throw e;
  580.         }catch(NotFoundException e){
  581.             this.logDebug(e); throw e;
  582.         }catch(Exception e){
  583.             this.logError(e); throw new ServiceException("Select 'field' not completed: "+e.getMessage(),e);
  584.         }finally{
  585.             if(connection!=null){
  586.                 this.jdbcServiceManager.closeConnection(connection);
  587.             }
  588.         }
  589.    
  590.     }
  591.    
  592.     @Override
  593.     public List<Object> select(IPaginatedExpression paginatedExpression, boolean distinct, IField field) throws ServiceException,NotFoundException,NotImplementedException {

  594.         Connection connection = null;
  595.         try{
  596.            
  597.             // check parameters
  598.             if(paginatedExpression==null){
  599.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  600.             }
  601.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  602.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  603.             }
  604.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  605.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  606.             // ISQLQueryObject
  607.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  608.             sqlQueryObject.setANDLogicOperator(true);
  609.             // Connection sql
  610.             connection = this.jdbcServiceManager.getConnection();

  611.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,distinct,field);            
  612.    
  613.         }catch(ServiceException | NotImplementedException e){
  614.             this.logError(e); throw e;
  615.         }catch(NotFoundException e){
  616.             this.logDebug(e); throw e;
  617.         }catch(Exception e){
  618.             this.logError(e); throw new ServiceException("Select 'distinct:"+distinct+"' field not completed: "+e.getMessage(),e);
  619.         }finally{
  620.             if(connection!=null){
  621.                 this.jdbcServiceManager.closeConnection(connection);
  622.             }
  623.         }
  624.        
  625.     }
  626.    
  627.     @Override
  628.     public List<Map<String,Object>> select(IPaginatedExpression paginatedExpression, IField ... field) throws ServiceException,NotFoundException,NotImplementedException {
  629.    
  630.         Connection connection = null;
  631.         try{
  632.            
  633.             // check parameters
  634.             if(paginatedExpression==null){
  635.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  636.             }
  637.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  638.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  639.             }
  640.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  641.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  642.             // ISQLQueryObject
  643.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  644.             sqlQueryObject.setANDLogicOperator(true);
  645.             // Connection sql
  646.             connection = this.jdbcServiceManager.getConnection();

  647.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,field);        
  648.    
  649.         }catch(ServiceException | NotImplementedException e){
  650.             this.logError(e); throw e;
  651.         }catch(NotFoundException e){
  652.             this.logDebug(e); throw e;
  653.         }catch(Exception e){
  654.             this.logError(e); throw new ServiceException("Select not completed: "+e.getMessage(),e);
  655.         }finally{
  656.             if(connection!=null){
  657.                 this.jdbcServiceManager.closeConnection(connection);
  658.             }
  659.         }
  660.    
  661.     }
  662.     @Override
  663.     public List<Map<String,Object>> select(IPaginatedExpression paginatedExpression, boolean distinct, IField ... field) throws ServiceException,NotFoundException,NotImplementedException {

  664.         Connection connection = null;
  665.         try{
  666.            
  667.             // check parameters
  668.             if(paginatedExpression==null){
  669.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  670.             }
  671.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  672.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  673.             }
  674.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  675.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  676.             // ISQLQueryObject
  677.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  678.             sqlQueryObject.setANDLogicOperator(true);
  679.             // Connection sql
  680.             connection = this.jdbcServiceManager.getConnection();

  681.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,distinct,field);            
  682.    
  683.         }catch(ServiceException | NotImplementedException e){
  684.             this.logError(e); throw e;
  685.         }catch(NotFoundException e){
  686.             this.logDebug(e); throw e;
  687.         }catch(Exception e){
  688.             this.logError(e); throw new ServiceException("Select distinct:"+distinct+" not completed: "+e.getMessage(),e);
  689.         }finally{
  690.             if(connection!=null){
  691.                 this.jdbcServiceManager.closeConnection(connection);
  692.             }
  693.         }
  694.        
  695.     }
  696.    
  697.     @Override
  698.     public Object aggregate(IExpression expression, FunctionField functionField) throws ServiceException,NotFoundException,NotImplementedException {

  699.         Connection connection = null;
  700.         try{
  701.            
  702.             // check parameters
  703.             if(expression==null){
  704.                 throw this.newServiceExceptionParameterExpressionIsNull();
  705.             }
  706.             if( ! (expression instanceof JDBCExpression) ){
  707.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  708.             }
  709.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  710.             this.logJDBCExpression(jdbcExpression);

  711.             // ISQLQueryObject
  712.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  713.             sqlQueryObject.setANDLogicOperator(true);
  714.             // Connection sql
  715.             connection = this.jdbcServiceManager.getConnection();

  716.             return this.serviceSearch.aggregate(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression,functionField);          
  717.    
  718.         }catch(ServiceException | NotImplementedException e){
  719.             this.logError(e); throw e;
  720.         }catch(NotFoundException e){
  721.             this.logDebug(e); throw e;
  722.         }catch(Exception e){
  723.             this.logError(e); throw new ServiceException("Aggregate not completed: "+e.getMessage(),e);
  724.         }finally{
  725.             if(connection!=null){
  726.                 this.jdbcServiceManager.closeConnection(connection);
  727.             }
  728.         }
  729.        
  730.     }
  731.    
  732.     @Override
  733.     public Map<String,Object> aggregate(IExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException {

  734.         Connection connection = null;
  735.         try{
  736.            
  737.             // check parameters
  738.             if(expression==null){
  739.                 throw this.newServiceExceptionParameterExpressionIsNull();
  740.             }
  741.             if( ! (expression instanceof JDBCExpression) ){
  742.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  743.             }
  744.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  745.             this.logJDBCExpression(jdbcExpression);

  746.             // ISQLQueryObject
  747.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  748.             sqlQueryObject.setANDLogicOperator(true);
  749.             // Connection sql
  750.             connection = this.jdbcServiceManager.getConnection();

  751.             return this.serviceSearch.aggregate(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression,functionField);          
  752.    
  753.         }catch(ServiceException | NotImplementedException e){
  754.             this.logError(e); throw e;
  755.         }catch(NotFoundException e){
  756.             this.logDebug(e); throw e;
  757.         }catch(Exception e){
  758.             this.logError(e); throw new ServiceException("Aggregate not completed: "+e.getMessage(),e);
  759.         }finally{
  760.             if(connection!=null){
  761.                 this.jdbcServiceManager.closeConnection(connection);
  762.             }
  763.         }
  764.        
  765.     }
  766.    
  767.     @Override
  768.     public List<Map<String,Object>> groupBy(IExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException {

  769.         Connection connection = null;
  770.         try{
  771.            
  772.             // check parameters
  773.             if(expression==null){
  774.                 throw this.newServiceExceptionParameterExpressionIsNull();
  775.             }
  776.             if( ! (expression instanceof JDBCExpression) ){
  777.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  778.             }
  779.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  780.             this.logJDBCExpression(jdbcExpression);

  781.             // ISQLQueryObject
  782.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  783.             sqlQueryObject.setANDLogicOperator(true);
  784.             // Connection sql
  785.             connection = this.jdbcServiceManager.getConnection();

  786.             return this.serviceSearch.groupBy(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression,functionField);        
  787.    
  788.         }catch(ServiceException | NotImplementedException e){
  789.             this.logError(e); throw e;
  790.         }catch(NotFoundException e){
  791.             this.logDebug(e); throw e;
  792.         }catch(Exception e){
  793.             this.logError(e); throw new ServiceException("GroupBy not completed: "+e.getMessage(),e);
  794.         }finally{
  795.             if(connection!=null){
  796.                 this.jdbcServiceManager.closeConnection(connection);
  797.             }
  798.         }
  799.        
  800.     }
  801.    
  802.     @Override
  803.     public List<Map<String,Object>> groupBy(IPaginatedExpression paginatedExpression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException {

  804.         Connection connection = null;
  805.         try{
  806.            
  807.             // check parameters
  808.             if(paginatedExpression==null){
  809.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  810.             }
  811.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  812.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  813.             }
  814.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  815.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  816.             // ISQLQueryObject
  817.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  818.             sqlQueryObject.setANDLogicOperator(true);
  819.             // Connection sql
  820.             connection = this.jdbcServiceManager.getConnection();

  821.             return this.serviceSearch.groupBy(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,functionField);            
  822.    
  823.         }catch(ServiceException | NotImplementedException e){
  824.             this.logError(e); throw e;
  825.         }catch(NotFoundException e){
  826.             this.logDebug(e); throw e;
  827.         }catch(Exception e){
  828.             this.logError(e); throw new ServiceException("GroupBy not completed: "+e.getMessage(),e);
  829.         }finally{
  830.             if(connection!=null){
  831.                 this.jdbcServiceManager.closeConnection(connection);
  832.             }
  833.         }
  834.        
  835.     }
  836.    
  837.     @Override
  838.     public List<Map<String,Object>> union(Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException {

  839.         Connection connection = null;
  840.         try{
  841.            
  842.             // check parameters
  843.             if(unionExpression==null){
  844.                 throw this.newServiceExceptionParameterUnionExpressionIsNull();
  845.             }
  846.            
  847.             // ISQLQueryObject
  848.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  849.             sqlQueryObject.setANDLogicOperator(true);
  850.             // Connection sql
  851.             connection = this.jdbcServiceManager.getConnection();

  852.             return this.serviceSearch.union(this.jdbcProperties,this.log,connection,sqlQueryObject,union,unionExpression);          
  853.    
  854.         }catch(ServiceException | NotImplementedException e){
  855.             this.logError(e); throw e;
  856.         }catch(NotFoundException e){
  857.             this.logDebug(e); throw e;
  858.         }catch(Exception e){
  859.             this.logError(e); throw new ServiceException("Union not completed: "+e.getMessage(),e);
  860.         }finally{
  861.             if(connection!=null){
  862.                 this.jdbcServiceManager.closeConnection(connection);
  863.             }
  864.         }
  865.        
  866.     }
  867.    
  868.     @Override
  869.     public NonNegativeNumber unionCount(Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException {

  870.         Connection connection = null;
  871.         try{
  872.            
  873.             // check parameters
  874.             if(unionExpression==null){
  875.                 throw this.newServiceExceptionParameterUnionExpressionIsNull();
  876.             }
  877.            
  878.             // ISQLQueryObject
  879.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  880.             sqlQueryObject.setANDLogicOperator(true);
  881.             // Connection sql
  882.             connection = this.jdbcServiceManager.getConnection();

  883.             return this.serviceSearch.unionCount(this.jdbcProperties,this.log,connection,sqlQueryObject,union,unionExpression);        
  884.    
  885.         }catch(ServiceException | NotImplementedException e){
  886.             this.logError(e); throw e;
  887.         }catch(NotFoundException e){
  888.             this.logDebug(e); throw e;
  889.         }catch(Exception e){
  890.             this.logError(e); throw new ServiceException("UnionCount not completed: "+e.getMessage(),e);
  891.         }finally{
  892.             if(connection!=null){
  893.                 this.jdbcServiceManager.closeConnection(connection);
  894.             }
  895.         }
  896.        
  897.     }

  898.     @Override
  899.     public IExpression newExpression() throws ServiceException,NotImplementedException {

  900.         return this.serviceSearch.newExpression(this.log);

  901.     }

  902.     @Override
  903.     public IPaginatedExpression newPaginatedExpression() throws ServiceException, NotImplementedException {

  904.         return this.serviceSearch.newPaginatedExpression(this.log);

  905.     }
  906.    
  907.     @Override
  908.     public IExpression toExpression(IPaginatedExpression paginatedExpression) throws ServiceException,NotImplementedException {

  909.         return this.serviceSearch.toExpression((JDBCPaginatedExpression)paginatedExpression,this.log);

  910.     }

  911.     @Override
  912.     public IPaginatedExpression toPaginatedExpression(IExpression expression) throws ServiceException, NotImplementedException {

  913.         return this.serviceSearch.toPaginatedExpression((JDBCExpression)expression,this.log);

  914.     }
  915.    

  916.     // -- DB
  917.    
  918.     @Override
  919.     public void mappingTableIds(IdConfigurazioneFiltro id, ConfigurazioneFiltro obj) throws ServiceException,NotFoundException,NotImplementedException{
  920.         Connection connection = null;
  921.         try{
  922.            
  923.             // check parameters
  924.             if(id==null){
  925.                 throw this.newServiceExceptionParameterIdIsNull();
  926.             }
  927.             if(obj==null){
  928.                 throw this.newServiceExceptionParameterObjIsNull();
  929.             }
  930.            
  931.             // ISQLQueryObject
  932.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  933.             sqlQueryObject.setANDLogicOperator(true);
  934.             // Connection sql
  935.             connection = this.jdbcServiceManager.getConnection();
  936.        
  937.             this.serviceSearch.mappingTableIds(this.jdbcProperties,this.log,connection,sqlQueryObject,id,obj);
  938.        
  939.         }catch(ServiceException | NotImplementedException e){
  940.             this.logError(e); throw e;
  941.         }catch(NotFoundException e){
  942.             this.logDebug(e); throw e;
  943.         }catch(Exception e){
  944.             this.logError(e); throw new ServiceException("mappingIds(IdObject) not completed: "+e.getMessage(),e);
  945.         }finally{
  946.             if(connection!=null){
  947.                 this.jdbcServiceManager.closeConnection(connection);
  948.             }
  949.         }
  950.     }
  951.    
  952.     @Override
  953.     public void mappingTableIds(long tableId, ConfigurazioneFiltro obj) throws ServiceException,NotFoundException,NotImplementedException{
  954.         Connection connection = null;
  955.         try{
  956.            
  957.             // check parameters
  958.             if(tableId<=0){
  959.                 throw this.newServiceExceptionParameterWithTypeTableIdLessEqualsZero();
  960.             }
  961.             if(obj==null){
  962.                 throw this.newServiceExceptionParameterObjIsNull();
  963.             }
  964.            
  965.             // ISQLQueryObject
  966.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  967.             sqlQueryObject.setANDLogicOperator(true);
  968.             // Connection sql
  969.             connection = this.jdbcServiceManager.getConnection();
  970.        
  971.             this.serviceSearch.mappingTableIds(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,obj);
  972.        
  973.         }catch(ServiceException | NotImplementedException e){
  974.             this.logError(e); throw e;
  975.         }catch(NotFoundException e){
  976.             this.logDebug(e); throw e;
  977.         }catch(Exception e){
  978.             this.logError(e); throw new ServiceException("mappingIds(tableId) not completed: "+e.getMessage(),e);
  979.         }finally{
  980.             if(connection!=null){
  981.                 this.jdbcServiceManager.closeConnection(connection);
  982.             }
  983.         }
  984.     }
  985.        
  986.     @Override
  987.     public ConfigurazioneFiltro get(long tableId) throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  988.    
  989.         Connection connection = null;
  990.         try{
  991.            
  992.             // check parameters
  993.             if(tableId<=0){
  994.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  995.             }
  996.            
  997.             // ISQLQueryObject
  998.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  999.             sqlQueryObject.setANDLogicOperator(true);
  1000.             // Connection sql
  1001.             connection = this.jdbcServiceManager.getConnection();
  1002.        
  1003.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,null);
  1004.        
  1005.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  1006.             this.logError(e); throw e;
  1007.         }catch(NotFoundException e){
  1008.             this.logDebug(e); throw e;
  1009.         }catch(Exception e){
  1010.             this.logError(e); throw new ServiceException("Get(tableId) not completed: "+e.getMessage(),e);
  1011.         }finally{
  1012.             if(connection!=null){
  1013.                 this.jdbcServiceManager.closeConnection(connection);
  1014.             }
  1015.         }
  1016.    
  1017.     }
  1018.    
  1019.     @Override
  1020.     public ConfigurazioneFiltro get(long tableId,org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  1021.    
  1022.         Connection connection = null;
  1023.         try{
  1024.            
  1025.             // check parameters
  1026.             if(tableId<=0){
  1027.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  1028.             }
  1029.             if(idMappingResolutionBehaviour==null){
  1030.                 throw this.newServiceExceptionParameterIdMappingResolutionBehaviourIsNull();
  1031.             }
  1032.            
  1033.             // ISQLQueryObject
  1034.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1035.             sqlQueryObject.setANDLogicOperator(true);
  1036.             // Connection sql
  1037.             connection = this.jdbcServiceManager.getConnection();
  1038.        
  1039.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,idMappingResolutionBehaviour);
  1040.        
  1041.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  1042.             this.logError(e); throw e;
  1043.         }catch(NotFoundException e){
  1044.             this.logDebug(e); throw e;
  1045.         }catch(Exception e){
  1046.             this.logError(e); throw new ServiceException("Get(tableId,idMappingResolutionBehaviour) not completed: "+e.getMessage(),e);
  1047.         }finally{
  1048.             if(connection!=null){
  1049.                 this.jdbcServiceManager.closeConnection(connection);
  1050.             }
  1051.         }
  1052.    
  1053.     }
  1054.    
  1055.     @Override
  1056.     public boolean exists(long tableId) throws MultipleResultException,ServiceException,NotImplementedException {

  1057.         Connection connection = null;
  1058.         try{
  1059.            
  1060.             // check parameters
  1061.             if(tableId<=0){
  1062.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  1063.             }

  1064.             // ISQLQueryObject
  1065.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1066.             sqlQueryObject.setANDLogicOperator(true);
  1067.             // Connection sql
  1068.             connection = this.jdbcServiceManager.getConnection();

  1069.             return this.serviceSearch.exists(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId);          
  1070.    
  1071.         }catch(MultipleResultException | ServiceException | NotImplementedException e){
  1072.             this.logError(e); throw e;
  1073.         }catch(Exception e){
  1074.             this.logError(e); throw new ServiceException("Exists(tableId) not completed: "+e.getMessage(),e);
  1075.         }finally{
  1076.             if(connection!=null){
  1077.                 this.jdbcServiceManager.closeConnection(connection);
  1078.             }
  1079.         }
  1080.        
  1081.     }
  1082.    
  1083.     @Override
  1084.     public List<Long> findAllTableIds(IPaginatedExpression expression) throws ServiceException, NotImplementedException {
  1085.        
  1086.         Connection connection = null;
  1087.         try{
  1088.            
  1089.             // check parameters
  1090.             if(expression==null){
  1091.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  1092.             }
  1093.             if( ! (expression instanceof JDBCPaginatedExpression) ){
  1094.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongType(expression);
  1095.             }
  1096.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) expression;
  1097.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  1098.             // ISQLQueryObject
  1099.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1100.             sqlQueryObject.setANDLogicOperator(true);
  1101.             // Connection sql
  1102.             connection = this.jdbcServiceManager.getConnection();
  1103.            
  1104.             return this.serviceSearch.findAllTableIds(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression);
  1105.    
  1106.         }catch(ServiceException | NotImplementedException e){
  1107.             this.logError(e); throw e;
  1108.         }catch(Exception e){
  1109.             this.logError(e); throw new ServiceException("findAllTableIds not completed: "+e.getMessage(),e);
  1110.         }finally{
  1111.             if(connection!=null){
  1112.                 this.jdbcServiceManager.closeConnection(connection);
  1113.             }
  1114.         }
  1115.        
  1116.     }
  1117.    
  1118.     @Override
  1119.     public long findTableId(IExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException {
  1120.    
  1121.         Connection connection = null;
  1122.         try{
  1123.            
  1124.             // check parameters
  1125.             if(expression==null){
  1126.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  1127.             }
  1128.             if( ! (expression instanceof JDBCExpression) ){
  1129.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  1130.             }
  1131.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  1132.             this.logJDBCExpression(jdbcExpression);

  1133.             // ISQLQueryObject
  1134.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1135.             sqlQueryObject.setANDLogicOperator(true);
  1136.             // Connection sql
  1137.             connection = this.jdbcServiceManager.getConnection();

  1138.             return this.serviceSearch.findTableId(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression);          

  1139.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  1140.             this.logError(e); throw e;
  1141.         }catch(NotFoundException e){
  1142.             this.logDebug(e); throw e;
  1143.         }catch(Exception e){
  1144.             this.logError(e); throw new ServiceException("findTableId not completed: "+e.getMessage(),e);
  1145.         }finally{
  1146.             if(connection!=null){
  1147.                 this.jdbcServiceManager.closeConnection(connection);
  1148.             }
  1149.         }
  1150.    
  1151.     }
  1152.    
  1153.     @Override
  1154.     public InUse inUse(long tableId) throws ServiceException, NotFoundException, NotImplementedException {
  1155.    
  1156.         Connection connection = null;
  1157.         try{
  1158.            
  1159.             // check parameters
  1160.             if(tableId<=0){
  1161.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  1162.             }
  1163.            
  1164.             // ISQLQueryObject
  1165.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1166.             sqlQueryObject.setANDLogicOperator(true);
  1167.             // Connection sql
  1168.             connection = this.jdbcServiceManager.getConnection();

  1169.             return this.serviceSearch.inUse(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId);        
  1170.    
  1171.         }catch(ServiceException | NotImplementedException e){
  1172.             this.logError(e); throw e;
  1173.         }catch(NotFoundException e){
  1174.             this.logDebug(e); throw e;
  1175.         }catch(Exception e){
  1176.             this.logError(e); throw new ServiceException("InUse(tableId) not completed: "+e.getMessage(),e);
  1177.         }finally{
  1178.             if(connection!=null){
  1179.                 this.jdbcServiceManager.closeConnection(connection);
  1180.             }
  1181.         }
  1182.    
  1183.     }
  1184.    
  1185.     @Override
  1186.     public IdConfigurazioneFiltro findId(long tableId, boolean throwNotFound)
  1187.             throws NotFoundException, ServiceException, NotImplementedException {
  1188.        
  1189.         Connection connection = null;
  1190.         try{
  1191.            
  1192.             // check parameters
  1193.             if(tableId<=0){
  1194.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  1195.             }
  1196.            
  1197.             // ISQLQueryObject
  1198.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1199.             sqlQueryObject.setANDLogicOperator(true);
  1200.             // Connection sql
  1201.             connection = this.jdbcServiceManager.getConnection();

  1202.             return this.serviceSearch.findId(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,throwNotFound);    
  1203.    
  1204.         }catch(ServiceException | NotImplementedException e){
  1205.             this.logError(e); throw e;
  1206.         }catch(NotFoundException e){
  1207.             this.logDebug(e); throw e;
  1208.         }catch(Exception e){
  1209.             this.logError(e); throw new ServiceException("findId(tableId,throwNotFound) not completed: "+e.getMessage(),e);
  1210.         }finally{
  1211.             if(connection!=null){
  1212.                 this.jdbcServiceManager.closeConnection(connection);
  1213.             }
  1214.         }
  1215.        
  1216.     }

  1217.     @Override
  1218.     public Long findTableId(IdConfigurazioneFiltro id, boolean throwNotFound)
  1219.             throws NotFoundException, ServiceException, NotImplementedException {
  1220.        
  1221.         Connection connection = null;
  1222.         try{
  1223.            
  1224.             // check parameters
  1225.             if(id==null){
  1226.                 throw new ServiceException("Parameter 'id' is null");
  1227.             }
  1228.            
  1229.             // ISQLQueryObject
  1230.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1231.             sqlQueryObject.setANDLogicOperator(true);
  1232.             // Connection sql
  1233.             connection = this.jdbcServiceManager.getConnection();

  1234.             return this.serviceSearch.findTableId(this.jdbcProperties,this.log,connection,sqlQueryObject,id,throwNotFound);    
  1235.    
  1236.         }catch(ServiceException | NotImplementedException e){
  1237.             this.logError(e); throw e;
  1238.         }catch(NotFoundException e){
  1239.             this.logDebug(e); throw e;
  1240.         }catch(Exception e){
  1241.             this.logError(e); throw new ServiceException("findId(tableId,throwNotFound) not completed: "+e.getMessage(),e);
  1242.         }finally{
  1243.             if(connection!=null){
  1244.                 this.jdbcServiceManager.closeConnection(connection);
  1245.             }
  1246.         }
  1247.     }
  1248.    
  1249.     @Override
  1250.     public void disableSelectForUpdate() throws ServiceException,NotImplementedException {
  1251.         this.jdbcSqlObjectFactory.setSelectForUpdate(false);
  1252.     }

  1253.     @Override
  1254.     public void enableSelectForUpdate() throws ServiceException,NotImplementedException {
  1255.         this.jdbcSqlObjectFactory.setSelectForUpdate(true);
  1256.     }
  1257.    
  1258.    
  1259.     @Override
  1260.     public List<List<Object>> nativeQuery(String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException{
  1261.    
  1262.         Connection connection = null;
  1263.         try{
  1264.            
  1265.             // check parameters
  1266.             if(returnClassTypes==null || returnClassTypes.isEmpty()){
  1267.                 throw new ServiceException("Parameter 'returnClassTypes' is less equals 0");
  1268.             }
  1269.            
  1270.             // ISQLQueryObject
  1271.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1272.             sqlQueryObject.setANDLogicOperator(true);
  1273.             // Connection sql
  1274.             connection = this.jdbcServiceManager.getConnection();

  1275.             return this.serviceSearch.nativeQuery(this.jdbcProperties,this.log,connection,sqlQueryObject,sql,returnClassTypes,param);      
  1276.    
  1277.         }catch(ServiceException | NotImplementedException e){
  1278.             this.logError(e); throw e;
  1279.         }catch(NotFoundException e){
  1280.             this.logDebug(e); throw e;
  1281.         }catch(Exception e){
  1282.             this.logError(e); throw new ServiceException("nativeQuery not completed: "+e.getMessage(),e);
  1283.         }finally{
  1284.             if(connection!=null){
  1285.                 this.jdbcServiceManager.closeConnection(connection);
  1286.             }
  1287.         }
  1288.    
  1289.     }
  1290.    
  1291. }