JDBCDumpMessaggioServiceSearch.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.transazioni.dao.jdbc;

  21. import java.lang.reflect.Method;
  22. import java.sql.Connection;
  23. import java.util.List;
  24. import java.util.Map;

  25. import org.openspcoop2.core.transazioni.DumpMessaggio;
  26. import org.openspcoop2.core.transazioni.IdDumpMessaggio;
  27. import org.openspcoop2.core.transazioni.dao.IDBDumpMessaggioServiceSearch;
  28. import org.openspcoop2.core.transazioni.utils.ProjectInfo;
  29. import org.openspcoop2.generic_project.beans.FunctionField;
  30. import org.openspcoop2.generic_project.beans.IField;
  31. import org.openspcoop2.generic_project.beans.InUse;
  32. import org.openspcoop2.generic_project.beans.NonNegativeNumber;
  33. import org.openspcoop2.generic_project.beans.Union;
  34. import org.openspcoop2.generic_project.beans.UnionExpression;
  35. import org.openspcoop2.generic_project.dao.IDBServiceUtilities;
  36. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceSearchWithId;
  37. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  38. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;
  39. import org.openspcoop2.generic_project.dao.jdbc.JDBCProperties;
  40. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  41. import org.openspcoop2.generic_project.dao.jdbc.utils.IJDBCFetch;
  42. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBC_SQLObjectFactory;
  43. import org.openspcoop2.generic_project.exception.ExpressionException;
  44. import org.openspcoop2.generic_project.exception.MultipleResultException;
  45. import org.openspcoop2.generic_project.exception.NotFoundException;
  46. import org.openspcoop2.generic_project.exception.NotImplementedException;
  47. import org.openspcoop2.generic_project.exception.ServiceException;
  48. import org.openspcoop2.generic_project.exception.ValidationException;
  49. import org.openspcoop2.generic_project.expression.IExpression;
  50. import org.openspcoop2.generic_project.expression.IPaginatedExpression;
  51. import org.openspcoop2.generic_project.expression.impl.sql.ISQLFieldConverter;
  52. import org.openspcoop2.utils.sql.ISQLQueryObject;
  53. import org.slf4j.Logger;

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  493.     @Override
  494.     public JDBCDumpMessaggioStream getContentInputStream(IExpression expression)
  495.             throws ServiceException {
  496.        
  497.         Connection connection = null;
  498.         try{
  499.            
  500.             // check parameters
  501.             if(expression==null){
  502.                 throw newServiceExceptionParameterPaginatedExpressionIsNull();
  503.             }
  504.             if( ! (expression instanceof JDBCExpression) ){
  505.                 throw newServiceExceptionParameterExpressionWrongType(expression);
  506.             }
  507.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  508.             logJDBCExpression(jdbcExpression);

  509.             // ISQLQueryObject
  510.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  511.             sqlQueryObject.setANDLogicOperator(true);
  512.             // Connection sql
  513.             connection = this.jdbcServiceManager.getConnection();

  514.             Method method = this.serviceSearch.getClass().getMethod("getContentInputStream",
  515.                     JDBCServiceManagerProperties.class, Logger.class,
  516.                     Connection.class, JDBCServiceManager.class,
  517.                     ISQLQueryObject.class, JDBCExpression.class);
  518.             return (JDBCDumpMessaggioStream) method.invoke(this.serviceSearch,
  519.                     this.jdbcProperties,this.log,
  520.                     connection, this.jdbcServiceManager,
  521.                     sqlQueryObject,jdbcExpression);        

  522.         }catch(ServiceException e){
  523.             this.logError(e); throw e;
  524.         }catch(Exception e){
  525.             this.logError(e); throw new ServiceException("Find not completed: "+e.getMessage(),e);
  526.         }finally{
  527.             /**
  528.              * OP-1635
  529.             if(connection!=null){
  530.                 this.jdbcServiceManager.closeConnection(connection);
  531.             }
  532.             */
  533.         }
  534.        
  535.     }

  536.     @Override
  537.     public NonNegativeNumber count(IExpression expression) throws ServiceException, NotImplementedException {

  538.         Connection connection = null;
  539.         try{
  540.            
  541.             // check parameters
  542.             if(expression==null){
  543.                 throw this.newServiceExceptionParameterExpressionIsNull();
  544.             }
  545.             if( ! (expression instanceof JDBCExpression) ){
  546.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  547.             }
  548.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  549.             this.logJDBCExpression(jdbcExpression);
  550.            
  551.             // ISQLQueryObject
  552.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  553.             sqlQueryObject.setANDLogicOperator(true);
  554.             // Connection sql
  555.             connection = this.jdbcServiceManager.getConnection();

  556.             return this.serviceSearch.count(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression);
  557.    
  558.         }catch(ServiceException | NotImplementedException e){
  559.             this.logError(e); throw e;
  560.         }catch(Exception e){
  561.             this.logError(e); throw new ServiceException("Count not completed: "+e.getMessage(),e);
  562.         }finally{
  563.             if(connection!=null){
  564.                 this.jdbcServiceManager.closeConnection(connection);
  565.             }
  566.         }
  567.        
  568.     }

  569.     @Override
  570.     public InUse inUse(IdDumpMessaggio id) throws ServiceException, NotFoundException,NotImplementedException {

  571.         Connection connection = null;
  572.         try{
  573.            
  574.             // check parameters
  575.             if(id==null){
  576.                 throw this.newServiceExceptionParameterIdIsNull();
  577.             }
  578.            
  579.             // ISQLQueryObject
  580.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  581.             sqlQueryObject.setANDLogicOperator(true);
  582.             // Connection sql
  583.             connection = this.jdbcServiceManager.getConnection();

  584.             return this.serviceSearch.inUse(this.jdbcProperties,this.log,connection,sqlQueryObject,id);
  585.    
  586.         }catch(ServiceException | NotImplementedException e){
  587.             this.logError(e); throw e;
  588.         }catch(NotFoundException e){
  589.             this.logDebug(e); throw e;
  590.         }catch(Exception e){
  591.             this.logError(e); throw new ServiceException("InUse not completed: "+e.getMessage(),e);
  592.         }finally{
  593.             if(connection!=null){
  594.                 this.jdbcServiceManager.closeConnection(connection);
  595.             }
  596.         }
  597.        
  598.     }
  599.    
  600.     @Override
  601.     public List<Object> select(IPaginatedExpression paginatedExpression, IField field) throws ServiceException,NotFoundException,NotImplementedException {
  602.    
  603.         Connection connection = null;
  604.         try{
  605.            
  606.             // check parameters
  607.             if(paginatedExpression==null){
  608.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  609.             }
  610.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  611.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  612.             }
  613.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  614.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  615.             // ISQLQueryObject
  616.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  617.             sqlQueryObject.setANDLogicOperator(true);
  618.             // Connection sql
  619.             connection = this.jdbcServiceManager.getConnection();

  620.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,field);        
  621.    
  622.         }catch(ServiceException | NotImplementedException e){
  623.             this.logError(e); throw e;
  624.         }catch(NotFoundException e){
  625.             this.logDebug(e); throw e;
  626.         }catch(Exception e){
  627.             this.logError(e); throw new ServiceException("Select 'field' not completed: "+e.getMessage(),e);
  628.         }finally{
  629.             if(connection!=null){
  630.                 this.jdbcServiceManager.closeConnection(connection);
  631.             }
  632.         }
  633.    
  634.     }
  635.    
  636.     @Override
  637.     public List<Object> select(IPaginatedExpression paginatedExpression, boolean distinct, IField field) throws ServiceException,NotFoundException,NotImplementedException {

  638.         Connection connection = null;
  639.         try{
  640.            
  641.             // check parameters
  642.             if(paginatedExpression==null){
  643.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  644.             }
  645.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  646.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  647.             }
  648.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  649.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  650.             // ISQLQueryObject
  651.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  652.             sqlQueryObject.setANDLogicOperator(true);
  653.             // Connection sql
  654.             connection = this.jdbcServiceManager.getConnection();

  655.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,distinct,field);            
  656.    
  657.         }catch(ServiceException | NotImplementedException e){
  658.             this.logError(e); throw e;
  659.         }catch(NotFoundException e){
  660.             this.logDebug(e); throw e;
  661.         }catch(Exception e){
  662.             this.logError(e); throw new ServiceException("Select 'distinct:"+distinct+"' field not completed: "+e.getMessage(),e);
  663.         }finally{
  664.             if(connection!=null){
  665.                 this.jdbcServiceManager.closeConnection(connection);
  666.             }
  667.         }
  668.        
  669.     }
  670.    
  671.     @Override
  672.     public List<Map<String,Object>> select(IPaginatedExpression paginatedExpression, IField ... field) throws ServiceException,NotFoundException,NotImplementedException {
  673.    
  674.         Connection connection = null;
  675.         try{
  676.            
  677.             // check parameters
  678.             if(paginatedExpression==null){
  679.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  680.             }
  681.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  682.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  683.             }
  684.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  685.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  686.             // ISQLQueryObject
  687.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  688.             sqlQueryObject.setANDLogicOperator(true);
  689.             // Connection sql
  690.             connection = this.jdbcServiceManager.getConnection();

  691.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,field);        
  692.    
  693.         }catch(ServiceException | NotImplementedException e){
  694.             this.logError(e); throw e;
  695.         }catch(NotFoundException e){
  696.             this.logDebug(e); throw e;
  697.         }catch(Exception e){
  698.             this.logError(e); throw new ServiceException("Select not completed: "+e.getMessage(),e);
  699.         }finally{
  700.             if(connection!=null){
  701.                 this.jdbcServiceManager.closeConnection(connection);
  702.             }
  703.         }
  704.    
  705.     }
  706.     @Override
  707.     public List<Map<String,Object>> select(IPaginatedExpression paginatedExpression, boolean distinct, IField ... field) throws ServiceException,NotFoundException,NotImplementedException {

  708.         Connection connection = null;
  709.         try{
  710.            
  711.             // check parameters
  712.             if(paginatedExpression==null){
  713.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  714.             }
  715.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  716.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  717.             }
  718.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  719.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  720.             // ISQLQueryObject
  721.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  722.             sqlQueryObject.setANDLogicOperator(true);
  723.             // Connection sql
  724.             connection = this.jdbcServiceManager.getConnection();

  725.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,distinct,field);            
  726.    
  727.         }catch(ServiceException | NotImplementedException e){
  728.             this.logError(e); throw e;
  729.         }catch(NotFoundException e){
  730.             this.logDebug(e); throw e;
  731.         }catch(Exception e){
  732.             this.logError(e); throw new ServiceException("Select distinct:"+distinct+" not completed: "+e.getMessage(),e);
  733.         }finally{
  734.             if(connection!=null){
  735.                 this.jdbcServiceManager.closeConnection(connection);
  736.             }
  737.         }
  738.        
  739.     }
  740.    
  741.     @Override
  742.     public Object aggregate(IExpression expression, FunctionField functionField) throws ServiceException,NotFoundException,NotImplementedException {

  743.         Connection connection = null;
  744.         try{
  745.            
  746.             // check parameters
  747.             if(expression==null){
  748.                 throw this.newServiceExceptionParameterExpressionIsNull();
  749.             }
  750.             if( ! (expression instanceof JDBCExpression) ){
  751.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  752.             }
  753.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  754.             this.logJDBCExpression(jdbcExpression);

  755.             // ISQLQueryObject
  756.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  757.             sqlQueryObject.setANDLogicOperator(true);
  758.             // Connection sql
  759.             connection = this.jdbcServiceManager.getConnection();

  760.             return this.serviceSearch.aggregate(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression,functionField);          
  761.    
  762.         }catch(ServiceException | NotImplementedException e){
  763.             this.logError(e); throw e;
  764.         }catch(NotFoundException e){
  765.             this.logDebug(e); throw e;
  766.         }catch(Exception e){
  767.             this.logError(e); throw new ServiceException("Aggregate not completed: "+e.getMessage(),e);
  768.         }finally{
  769.             if(connection!=null){
  770.                 this.jdbcServiceManager.closeConnection(connection);
  771.             }
  772.         }
  773.        
  774.     }
  775.    
  776.     @Override
  777.     public Map<String,Object> aggregate(IExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException {

  778.         Connection connection = null;
  779.         try{
  780.            
  781.             // check parameters
  782.             if(expression==null){
  783.                 throw this.newServiceExceptionParameterExpressionIsNull();
  784.             }
  785.             if( ! (expression instanceof JDBCExpression) ){
  786.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  787.             }
  788.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  789.             this.logJDBCExpression(jdbcExpression);

  790.             // ISQLQueryObject
  791.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  792.             sqlQueryObject.setANDLogicOperator(true);
  793.             // Connection sql
  794.             connection = this.jdbcServiceManager.getConnection();

  795.             return this.serviceSearch.aggregate(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression,functionField);          
  796.    
  797.         }catch(ServiceException | NotImplementedException e){
  798.             this.logError(e); throw e;
  799.         }catch(NotFoundException e){
  800.             this.logDebug(e); throw e;
  801.         }catch(Exception e){
  802.             this.logError(e); throw new ServiceException("Aggregate not completed: "+e.getMessage(),e);
  803.         }finally{
  804.             if(connection!=null){
  805.                 this.jdbcServiceManager.closeConnection(connection);
  806.             }
  807.         }
  808.        
  809.     }
  810.    
  811.     @Override
  812.     public List<Map<String,Object>> groupBy(IExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException {

  813.         Connection connection = null;
  814.         try{
  815.            
  816.             // check parameters
  817.             if(expression==null){
  818.                 throw this.newServiceExceptionParameterExpressionIsNull();
  819.             }
  820.             if( ! (expression instanceof JDBCExpression) ){
  821.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  822.             }
  823.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  824.             this.logJDBCExpression(jdbcExpression);

  825.             // ISQLQueryObject
  826.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  827.             sqlQueryObject.setANDLogicOperator(true);
  828.             // Connection sql
  829.             connection = this.jdbcServiceManager.getConnection();

  830.             return this.serviceSearch.groupBy(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcExpression,functionField);        
  831.    
  832.         }catch(ServiceException | NotImplementedException e){
  833.             this.logError(e); throw e;
  834.         }catch(NotFoundException e){
  835.             this.logDebug(e); throw e;
  836.         }catch(Exception e){
  837.             this.logError(e); throw new ServiceException("GroupBy not completed: "+e.getMessage(),e);
  838.         }finally{
  839.             if(connection!=null){
  840.                 this.jdbcServiceManager.closeConnection(connection);
  841.             }
  842.         }
  843.        
  844.     }
  845.    
  846.     @Override
  847.     public List<Map<String,Object>> groupBy(IPaginatedExpression paginatedExpression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException {

  848.         Connection connection = null;
  849.         try{
  850.            
  851.             // check parameters
  852.             if(paginatedExpression==null){
  853.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  854.             }
  855.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  856.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  857.             }
  858.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  859.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  860.             // ISQLQueryObject
  861.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  862.             sqlQueryObject.setANDLogicOperator(true);
  863.             // Connection sql
  864.             connection = this.jdbcServiceManager.getConnection();

  865.             return this.serviceSearch.groupBy(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,functionField);            
  866.    
  867.         }catch(ServiceException | NotImplementedException e){
  868.             this.logError(e); throw e;
  869.         }catch(NotFoundException e){
  870.             this.logDebug(e); throw e;
  871.         }catch(Exception e){
  872.             this.logError(e); throw new ServiceException("GroupBy not completed: "+e.getMessage(),e);
  873.         }finally{
  874.             if(connection!=null){
  875.                 this.jdbcServiceManager.closeConnection(connection);
  876.             }
  877.         }
  878.        
  879.     }
  880.    
  881.     @Override
  882.     public List<Map<String,Object>> union(Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException {

  883.         Connection connection = null;
  884.         try{
  885.            
  886.             // check parameters
  887.             if(unionExpression==null){
  888.                 throw this.newServiceExceptionParameterUnionExpressionIsNull();
  889.             }
  890.            
  891.             // ISQLQueryObject
  892.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  893.             sqlQueryObject.setANDLogicOperator(true);
  894.             // Connection sql
  895.             connection = this.jdbcServiceManager.getConnection();

  896.             return this.serviceSearch.union(this.jdbcProperties,this.log,connection,sqlQueryObject,union,unionExpression);          
  897.    
  898.         }catch(ServiceException | NotImplementedException e){
  899.             this.logError(e); throw e;
  900.         }catch(NotFoundException e){
  901.             this.logDebug(e); throw e;
  902.         }catch(Exception e){
  903.             this.logError(e); throw new ServiceException("Union not completed: "+e.getMessage(),e);
  904.         }finally{
  905.             if(connection!=null){
  906.                 this.jdbcServiceManager.closeConnection(connection);
  907.             }
  908.         }
  909.        
  910.     }
  911.    
  912.     @Override
  913.     public NonNegativeNumber unionCount(Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException {

  914.         Connection connection = null;
  915.         try{
  916.            
  917.             // check parameters
  918.             if(unionExpression==null){
  919.                 throw this.newServiceExceptionParameterUnionExpressionIsNull();
  920.             }
  921.            
  922.             // ISQLQueryObject
  923.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  924.             sqlQueryObject.setANDLogicOperator(true);
  925.             // Connection sql
  926.             connection = this.jdbcServiceManager.getConnection();

  927.             return this.serviceSearch.unionCount(this.jdbcProperties,this.log,connection,sqlQueryObject,union,unionExpression);        
  928.    
  929.         }catch(ServiceException | NotImplementedException e){
  930.             this.logError(e); throw e;
  931.         }catch(NotFoundException e){
  932.             this.logDebug(e); throw e;
  933.         }catch(Exception e){
  934.             this.logError(e); throw new ServiceException("UnionCount not completed: "+e.getMessage(),e);
  935.         }finally{
  936.             if(connection!=null){
  937.                 this.jdbcServiceManager.closeConnection(connection);
  938.             }
  939.         }
  940.        
  941.     }

  942.     @Override
  943.     public IExpression newExpression() throws ServiceException,NotImplementedException {

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

  945.     }

  946.     @Override
  947.     public IPaginatedExpression newPaginatedExpression() throws ServiceException, NotImplementedException {

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

  949.     }
  950.    
  951.     @Override
  952.     public IExpression toExpression(IPaginatedExpression paginatedExpression) throws ServiceException,NotImplementedException {

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

  954.     }

  955.     @Override
  956.     public IPaginatedExpression toPaginatedExpression(IExpression expression) throws ServiceException, NotImplementedException {

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

  958.     }
  959.    

  960.     // -- DB
  961.    
  962.     @Override
  963.     public void mappingTableIds(IdDumpMessaggio id, DumpMessaggio obj) throws ServiceException,NotFoundException,NotImplementedException{
  964.         Connection connection = null;
  965.         try{
  966.            
  967.             // check parameters
  968.             if(id==null){
  969.                 throw this.newServiceExceptionParameterIdIsNull();
  970.             }
  971.             if(obj==null){
  972.                 throw this.newServiceExceptionParameterObjIsNull();
  973.             }
  974.            
  975.             // ISQLQueryObject
  976.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  977.             sqlQueryObject.setANDLogicOperator(true);
  978.             // Connection sql
  979.             connection = this.jdbcServiceManager.getConnection();
  980.        
  981.             this.serviceSearch.mappingTableIds(this.jdbcProperties,this.log,connection,sqlQueryObject,id,obj);
  982.        
  983.         }catch(ServiceException | NotImplementedException e){
  984.             this.logError(e); throw e;
  985.         }catch(NotFoundException e){
  986.             this.logDebug(e); throw e;
  987.         }catch(Exception e){
  988.             this.logError(e); throw new ServiceException("mappingIds(IdObject) not completed: "+e.getMessage(),e);
  989.         }finally{
  990.             if(connection!=null){
  991.                 this.jdbcServiceManager.closeConnection(connection);
  992.             }
  993.         }
  994.     }
  995.    
  996.     @Override
  997.     public void mappingTableIds(long tableId, DumpMessaggio obj) throws ServiceException,NotFoundException,NotImplementedException{
  998.         Connection connection = null;
  999.         try{
  1000.            
  1001.             // check parameters
  1002.             if(tableId<=0){
  1003.                 throw this.newServiceExceptionParameterWithTypeTableIdLessEqualsZero();
  1004.             }
  1005.             if(obj==null){
  1006.                 throw this.newServiceExceptionParameterObjIsNull();
  1007.             }
  1008.            
  1009.             // ISQLQueryObject
  1010.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1011.             sqlQueryObject.setANDLogicOperator(true);
  1012.             // Connection sql
  1013.             connection = this.jdbcServiceManager.getConnection();
  1014.        
  1015.             this.serviceSearch.mappingTableIds(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,obj);
  1016.        
  1017.         }catch(ServiceException | NotImplementedException e){
  1018.             this.logError(e); throw e;
  1019.         }catch(NotFoundException e){
  1020.             this.logDebug(e); throw e;
  1021.         }catch(Exception e){
  1022.             this.logError(e); throw new ServiceException("mappingIds(tableId) not completed: "+e.getMessage(),e);
  1023.         }finally{
  1024.             if(connection!=null){
  1025.                 this.jdbcServiceManager.closeConnection(connection);
  1026.             }
  1027.         }
  1028.     }
  1029.        
  1030.     @Override
  1031.     public DumpMessaggio get(long tableId) throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  1032.    
  1033.         Connection connection = null;
  1034.         try{
  1035.            
  1036.             // check parameters
  1037.             if(tableId<=0){
  1038.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  1039.             }
  1040.            
  1041.             // ISQLQueryObject
  1042.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1043.             sqlQueryObject.setANDLogicOperator(true);
  1044.             // Connection sql
  1045.             connection = this.jdbcServiceManager.getConnection();
  1046.        
  1047.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,null);
  1048.        
  1049.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  1050.             this.logError(e); throw e;
  1051.         }catch(NotFoundException e){
  1052.             this.logDebug(e); throw e;
  1053.         }catch(Exception e){
  1054.             this.logError(e); throw new ServiceException("Get(tableId) not completed: "+e.getMessage(),e);
  1055.         }finally{
  1056.             if(connection!=null){
  1057.                 this.jdbcServiceManager.closeConnection(connection);
  1058.             }
  1059.         }
  1060.    
  1061.     }
  1062.    
  1063.     @Override
  1064.     public DumpMessaggio get(long tableId,org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  1065.    
  1066.         Connection connection = null;
  1067.         try{
  1068.            
  1069.             // check parameters
  1070.             if(tableId<=0){
  1071.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  1072.             }
  1073.             if(idMappingResolutionBehaviour==null){
  1074.                 throw this.newServiceExceptionParameterIdMappingResolutionBehaviourIsNull();
  1075.             }
  1076.            
  1077.             // ISQLQueryObject
  1078.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1079.             sqlQueryObject.setANDLogicOperator(true);
  1080.             // Connection sql
  1081.             connection = this.jdbcServiceManager.getConnection();
  1082.        
  1083.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,idMappingResolutionBehaviour);
  1084.        
  1085.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  1086.             this.logError(e); throw e;
  1087.         }catch(NotFoundException e){
  1088.             this.logDebug(e); throw e;
  1089.         }catch(Exception e){
  1090.             this.logError(e); throw new ServiceException("Get(tableId,idMappingResolutionBehaviour) not completed: "+e.getMessage(),e);
  1091.         }finally{
  1092.             if(connection!=null){
  1093.                 this.jdbcServiceManager.closeConnection(connection);
  1094.             }
  1095.         }
  1096.    
  1097.     }
  1098.    
  1099.     @Override
  1100.     public boolean exists(long tableId) throws MultipleResultException,ServiceException,NotImplementedException {

  1101.         Connection connection = null;
  1102.         try{
  1103.            
  1104.             // check parameters
  1105.             if(tableId<=0){
  1106.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  1107.             }

  1108.             // ISQLQueryObject
  1109.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1110.             sqlQueryObject.setANDLogicOperator(true);
  1111.             // Connection sql
  1112.             connection = this.jdbcServiceManager.getConnection();

  1113.             return this.serviceSearch.exists(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId);          
  1114.    
  1115.         }catch(MultipleResultException | ServiceException | NotImplementedException e){
  1116.             this.logError(e); throw e;
  1117.         }catch(Exception e){
  1118.             this.logError(e); throw new ServiceException("Exists(tableId) not completed: "+e.getMessage(),e);
  1119.         }finally{
  1120.             if(connection!=null){
  1121.                 this.jdbcServiceManager.closeConnection(connection);
  1122.             }
  1123.         }
  1124.        
  1125.     }
  1126.    
  1127.     @Override
  1128.     public List<Long> findAllTableIds(IPaginatedExpression expression) throws ServiceException, NotImplementedException {
  1129.        
  1130.         Connection connection = null;
  1131.         try{
  1132.            
  1133.             // check parameters
  1134.             if(expression==null){
  1135.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  1136.             }
  1137.             if( ! (expression instanceof JDBCPaginatedExpression) ){
  1138.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongType(expression);
  1139.             }
  1140.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) expression;
  1141.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  1142.             // ISQLQueryObject
  1143.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1144.             sqlQueryObject.setANDLogicOperator(true);
  1145.             // Connection sql
  1146.             connection = this.jdbcServiceManager.getConnection();
  1147.            
  1148.             return this.serviceSearch.findAllTableIds(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression);
  1149.    
  1150.         }catch(ServiceException | NotImplementedException e){
  1151.             this.logError(e); throw e;
  1152.         }catch(Exception e){
  1153.             this.logError(e); throw new ServiceException("findAllTableIds not completed: "+e.getMessage(),e);
  1154.         }finally{
  1155.             if(connection!=null){
  1156.                 this.jdbcServiceManager.closeConnection(connection);
  1157.             }
  1158.         }
  1159.        
  1160.     }
  1161.    
  1162.     @Override
  1163.     public long findTableId(IExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException {
  1164.    
  1165.         Connection connection = null;
  1166.         try{
  1167.            
  1168.             // check parameters
  1169.             if(expression==null){
  1170.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  1171.             }
  1172.             if( ! (expression instanceof JDBCExpression) ){
  1173.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  1174.             }
  1175.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  1176.             this.logJDBCExpression(jdbcExpression);

  1177.             // ISQLQueryObject
  1178.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1179.             sqlQueryObject.setANDLogicOperator(true);
  1180.             // Connection sql
  1181.             connection = this.jdbcServiceManager.getConnection();

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

  1183.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  1184.             this.logError(e); throw e;
  1185.         }catch(NotFoundException e){
  1186.             this.logDebug(e); throw e;
  1187.         }catch(Exception e){
  1188.             this.logError(e); throw new ServiceException("findTableId not completed: "+e.getMessage(),e);
  1189.         }finally{
  1190.             if(connection!=null){
  1191.                 this.jdbcServiceManager.closeConnection(connection);
  1192.             }
  1193.         }
  1194.    
  1195.     }
  1196.    
  1197.     @Override
  1198.     public InUse inUse(long tableId) throws ServiceException, NotFoundException, NotImplementedException {
  1199.    
  1200.         Connection connection = null;
  1201.         try{
  1202.            
  1203.             // check parameters
  1204.             if(tableId<=0){
  1205.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  1206.             }
  1207.            
  1208.             // ISQLQueryObject
  1209.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1210.             sqlQueryObject.setANDLogicOperator(true);
  1211.             // Connection sql
  1212.             connection = this.jdbcServiceManager.getConnection();

  1213.             return this.serviceSearch.inUse(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId);        
  1214.    
  1215.         }catch(ServiceException | NotImplementedException e){
  1216.             this.logError(e); throw e;
  1217.         }catch(NotFoundException e){
  1218.             this.logDebug(e); throw e;
  1219.         }catch(Exception e){
  1220.             this.logError(e); throw new ServiceException("InUse(tableId) not completed: "+e.getMessage(),e);
  1221.         }finally{
  1222.             if(connection!=null){
  1223.                 this.jdbcServiceManager.closeConnection(connection);
  1224.             }
  1225.         }
  1226.    
  1227.     }
  1228.    
  1229.     @Override
  1230.     public IdDumpMessaggio findId(long tableId, boolean throwNotFound)
  1231.             throws NotFoundException, ServiceException, NotImplementedException {
  1232.        
  1233.         Connection connection = null;
  1234.         try{
  1235.            
  1236.             // check parameters
  1237.             if(tableId<=0){
  1238.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  1239.             }
  1240.            
  1241.             // ISQLQueryObject
  1242.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1243.             sqlQueryObject.setANDLogicOperator(true);
  1244.             // Connection sql
  1245.             connection = this.jdbcServiceManager.getConnection();

  1246.             return this.serviceSearch.findId(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,throwNotFound);    
  1247.    
  1248.         }catch(ServiceException | NotImplementedException e){
  1249.             this.logError(e); throw e;
  1250.         }catch(NotFoundException e){
  1251.             this.logDebug(e); throw e;
  1252.         }catch(Exception e){
  1253.             this.logError(e); throw new ServiceException("findId(tableId,throwNotFound) not completed: "+e.getMessage(),e);
  1254.         }finally{
  1255.             if(connection!=null){
  1256.                 this.jdbcServiceManager.closeConnection(connection);
  1257.             }
  1258.         }
  1259.        
  1260.     }

  1261.     @Override
  1262.     public Long findTableId(IdDumpMessaggio id, boolean throwNotFound)
  1263.             throws NotFoundException, ServiceException, NotImplementedException {
  1264.        
  1265.         Connection connection = null;
  1266.         try{
  1267.            
  1268.             // check parameters
  1269.             if(id==null){
  1270.                 throw new ServiceException("Parameter 'id' is null");
  1271.             }
  1272.            
  1273.             // ISQLQueryObject
  1274.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1275.             sqlQueryObject.setANDLogicOperator(true);
  1276.             // Connection sql
  1277.             connection = this.jdbcServiceManager.getConnection();

  1278.             return this.serviceSearch.findTableId(this.jdbcProperties,this.log,connection,sqlQueryObject,id,throwNotFound);    
  1279.    
  1280.         }catch(ServiceException | NotImplementedException e){
  1281.             this.logError(e); throw e;
  1282.         }catch(NotFoundException e){
  1283.             this.logDebug(e); throw e;
  1284.         }catch(Exception e){
  1285.             this.logError(e); throw new ServiceException("findId(tableId,throwNotFound) not completed: "+e.getMessage(),e);
  1286.         }finally{
  1287.             if(connection!=null){
  1288.                 this.jdbcServiceManager.closeConnection(connection);
  1289.             }
  1290.         }
  1291.     }
  1292.    
  1293.     @Override
  1294.     public void disableSelectForUpdate() throws ServiceException,NotImplementedException {
  1295.         this.jdbcSqlObjectFactory.setSelectForUpdate(false);
  1296.     }

  1297.     @Override
  1298.     public void enableSelectForUpdate() throws ServiceException,NotImplementedException {
  1299.         this.jdbcSqlObjectFactory.setSelectForUpdate(true);
  1300.     }
  1301.    
  1302.    
  1303.     @Override
  1304.     public List<List<Object>> nativeQuery(String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException{
  1305.    
  1306.         Connection connection = null;
  1307.         try{
  1308.            
  1309.             // check parameters
  1310.             if(returnClassTypes==null || returnClassTypes.isEmpty()){
  1311.                 throw new ServiceException("Parameter 'returnClassTypes' is less equals 0");
  1312.             }
  1313.            
  1314.             // ISQLQueryObject
  1315.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  1316.             sqlQueryObject.setANDLogicOperator(true);
  1317.             // Connection sql
  1318.             connection = this.jdbcServiceManager.getConnection();

  1319.             return this.serviceSearch.nativeQuery(this.jdbcProperties,this.log,connection,sqlQueryObject,sql,returnClassTypes,param);      
  1320.    
  1321.         }catch(ServiceException | NotImplementedException e){
  1322.             this.logError(e); throw e;
  1323.         }catch(NotFoundException e){
  1324.             this.logDebug(e); throw e;
  1325.         }catch(Exception e){
  1326.             this.logError(e); throw new ServiceException("nativeQuery not completed: "+e.getMessage(),e);
  1327.         }finally{
  1328.             if(connection!=null){
  1329.                 this.jdbcServiceManager.closeConnection(connection);
  1330.             }
  1331.         }
  1332.    
  1333.     }
  1334.    
  1335. }