JDBCConfigurazioneGeneraleServiceSearch.java

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

  21. import org.openspcoop2.generic_project.dao.IDBServiceUtilities;
  22. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceSearchSingleObject;
  23. import org.openspcoop2.generic_project.beans.InUse;
  24. import org.openspcoop2.generic_project.beans.IField;
  25. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  26. import org.openspcoop2.generic_project.exception.ExpressionException;
  27. import org.openspcoop2.generic_project.exception.MultipleResultException;
  28. import org.openspcoop2.generic_project.exception.NotFoundException;
  29. import org.openspcoop2.generic_project.exception.NotImplementedException;
  30. import org.openspcoop2.generic_project.exception.ServiceException;
  31. import org.openspcoop2.generic_project.exception.ValidationException;
  32. import org.openspcoop2.generic_project.expression.IExpression;
  33. import org.openspcoop2.generic_project.expression.IPaginatedExpression;
  34. import org.openspcoop2.generic_project.expression.impl.sql.ISQLFieldConverter;
  35. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  36. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;
  37. import org.openspcoop2.generic_project.dao.jdbc.JDBCProperties;
  38. import org.openspcoop2.generic_project.dao.jdbc.utils.IJDBCFetch;
  39. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBC_SQLObjectFactory;

  40. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  41. import org.openspcoop2.core.controllo_traffico.dao.IDBConfigurazioneGeneraleServiceSearch;
  42. import org.openspcoop2.core.controllo_traffico.utils.ProjectInfo;

  43. import java.sql.Connection;
  44. import java.util.List;
  45. import java.util.Map;

  46. import org.slf4j.Logger;
  47. import org.openspcoop2.utils.sql.ISQLQueryObject;

  48. /**    
  49.  * Service can be used to search for the backend objects of type {@link org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale}
  50.  *
  51.  * @author Poli Andrea (poli@link.it)
  52.  * @author $Author$
  53.  * @version $Rev$, $Date$
  54. */
  55. public class JDBCConfigurazioneGeneraleServiceSearch implements IDBConfigurazioneGeneraleServiceSearch, IDBServiceUtilities<ConfigurazioneGenerale> {


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

  103.     protected ServiceException newServiceExceptionParameterExpressionWrongType(IExpression expression){
  104.         return new ServiceException(PARAMETER_TYPE_PREFIX+expression.getClass().getName()+") 'expression' has wrong type, expect "+JDBCExpression.class.getName());
  105.     }
  106.     protected ServiceException newServiceExceptionParameterExpressionIsNull(){
  107.         return new ServiceException(PARAMETER_TYPE_PREFIX+IExpression.class.getName()+") 'expression' is null");
  108.     }
  109.    
  110.     private ServiceException newServiceExceptionParameterPaginatedExpressionIsNull(){
  111.         return new ServiceException(PARAMETER_TYPE_PREFIX+IPaginatedExpression.class.getName()+") 'expression' is null");
  112.     }
  113.     private ServiceException newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated(){
  114.         return new ServiceException(PARAMETER_TYPE_PREFIX+IPaginatedExpression.class.getName()+") 'paginatedExpression' is null");
  115.     }
  116.     private ServiceException newServiceExceptionParameterPaginatedExpressionWrongType(IPaginatedExpression expression){
  117.         return new ServiceException(PARAMETER_TYPE_PREFIX+expression.getClass().getName()+") 'expression' has wrong type, expect "+JDBCPaginatedExpression.class.getName());
  118.     }
  119.     private ServiceException newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(IPaginatedExpression paginatedExpression){
  120.         return new ServiceException(PARAMETER_TYPE_PREFIX+paginatedExpression.getClass().getName()+") 'paginatedExpression' has wrong type, expect "+JDBCPaginatedExpression.class.getName());
  121.     }
  122.    
  123.    
  124.     private ServiceException newServiceExceptionParameterTableIdLessEqualsZero(){
  125.         return new ServiceException("Parameter 'tableId' is less equals 0");
  126.     }
  127.    
  128.     @Override
  129.     public void validate(ConfigurazioneGenerale configurazioneGenerale) throws ServiceException,
  130.             ValidationException, NotImplementedException {
  131.         org.openspcoop2.generic_project.utils.XSDValidator.validate(configurazioneGenerale, this.log,
  132.                 org.openspcoop2.core.controllo_traffico.utils.XSDValidator.getXSDValidator(this.log));
  133.     }
  134.    
  135.     @Override
  136.     public IJDBCFetch getFetch() {
  137.         return this.serviceSearch.getFetch();
  138.     }

  139.     @Override
  140.     public ISQLFieldConverter getFieldConverter() {
  141.         return this.serviceSearch.getFieldConverter();
  142.     }
  143.    
  144.        
  145.     @Override
  146.     public ConfigurazioneGenerale get() throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  147.    
  148.         Connection connection = null;
  149.         try{
  150.            
  151.            
  152.             // ISQLQueryObject
  153.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  154.             sqlQueryObject.setANDLogicOperator(true);
  155.             // Connection sql
  156.             connection = this.jdbcServiceManager.getConnection();
  157.        
  158.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,null);
  159.        
  160.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  161.             this.logError(e); throw e;
  162.         }catch(NotFoundException e){
  163.             this.logDebug(e); throw e;
  164.         }catch(Exception e){
  165.             this.logError(e); throw new ServiceException("Get not completed: "+e.getMessage(),e);
  166.         }finally{
  167.             if(connection!=null){
  168.                 this.jdbcServiceManager.closeConnection(connection);
  169.             }
  170.         }
  171.    
  172.     }

  173.     @Override
  174.     public ConfigurazioneGenerale get(org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  175.         Connection connection = null;
  176.         try{
  177.            
  178.             if(idMappingResolutionBehaviour==null){
  179.                 throw this.newServiceExceptionParameterIdMappingResolutionBehaviourIsNull();
  180.             }
  181.            
  182.             // ISQLQueryObject
  183.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  184.             sqlQueryObject.setANDLogicOperator(true);
  185.             // Connection sql
  186.             connection = this.jdbcServiceManager.getConnection();
  187.        
  188.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,idMappingResolutionBehaviour);
  189.        
  190.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  191.             this.logError(e); throw e;
  192.         }catch(NotFoundException e){
  193.             this.logDebug(e); throw e;
  194.         }catch(Exception e){
  195.             this.logError(e); throw new ServiceException("Get (idMappingResolutionBehaviour) not completed: "+e.getMessage(),e);
  196.         }finally{
  197.             if(connection!=null){
  198.                 this.jdbcServiceManager.closeConnection(connection);
  199.             }
  200.         }
  201.    
  202.     }

  203.     @Override
  204.     public boolean exists() throws MultipleResultException,ServiceException,NotImplementedException {

  205.         Connection connection = null;
  206.         try{
  207.            

  208.             // ISQLQueryObject
  209.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  210.             sqlQueryObject.setANDLogicOperator(true);
  211.             // Connection sql
  212.             connection = this.jdbcServiceManager.getConnection();

  213.             return this.serviceSearch.exists(this.jdbcProperties,this.log,connection,sqlQueryObject);
  214.    
  215.         }catch(MultipleResultException | ServiceException | NotImplementedException e){
  216.             this.logError(e); throw e;
  217.         }catch(Exception e){
  218.             this.logError(e); throw new ServiceException("Exists not completed: "+e.getMessage(),e);
  219.         }finally{
  220.             if(connection!=null){
  221.                 this.jdbcServiceManager.closeConnection(connection);
  222.             }
  223.         }
  224.        
  225.     }
  226.    




  227.     @Override
  228.     public InUse inUse() throws ServiceException, NotFoundException,NotImplementedException {

  229.         Connection connection = null;
  230.         try{
  231.            
  232.            
  233.             // ISQLQueryObject
  234.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  235.             sqlQueryObject.setANDLogicOperator(true);
  236.             // Connection sql
  237.             connection = this.jdbcServiceManager.getConnection();

  238.             return this.serviceSearch.inUse(this.jdbcProperties,this.log,connection,sqlQueryObject);    
  239.    
  240.         }catch(ServiceException | NotImplementedException e){
  241.             this.logError(e); throw e;
  242.         }catch(NotFoundException e){
  243.             this.logDebug(e); throw e;
  244.         }catch(Exception e){
  245.             this.logError(e); throw new ServiceException("InUse not completed: "+e.getMessage(),e);
  246.         }finally{
  247.             if(connection!=null){
  248.                 this.jdbcServiceManager.closeConnection(connection);
  249.             }
  250.         }
  251.        
  252.     }
  253.    
  254.     @Override
  255.     public List<Object> select(IPaginatedExpression paginatedExpression, IField field) throws ServiceException,NotFoundException,NotImplementedException {
  256.    
  257.         Connection connection = null;
  258.         try{
  259.            
  260.             // check parameters
  261.             if(paginatedExpression==null){
  262.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  263.             }
  264.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  265.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  266.             }
  267.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  268.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  269.             // ISQLQueryObject
  270.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  271.             sqlQueryObject.setANDLogicOperator(true);
  272.             // Connection sql
  273.             connection = this.jdbcServiceManager.getConnection();

  274.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,field);        
  275.    
  276.         }catch(ServiceException | NotImplementedException e){
  277.             this.logError(e); throw e;
  278.         }catch(NotFoundException e){
  279.             this.logDebug(e); throw e;
  280.         }catch(Exception e){
  281.             this.logError(e); throw new ServiceException("Select 'field' not completed: "+e.getMessage(),e);
  282.         }finally{
  283.             if(connection!=null){
  284.                 this.jdbcServiceManager.closeConnection(connection);
  285.             }
  286.         }
  287.    
  288.     }
  289.    
  290.     @Override
  291.     public List<Object> select(IPaginatedExpression paginatedExpression, boolean distinct, IField field) throws ServiceException,NotFoundException,NotImplementedException {

  292.         Connection connection = null;
  293.         try{
  294.            
  295.             // check parameters
  296.             if(paginatedExpression==null){
  297.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  298.             }
  299.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  300.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  301.             }
  302.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  303.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  304.             // ISQLQueryObject
  305.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  306.             sqlQueryObject.setANDLogicOperator(true);
  307.             // Connection sql
  308.             connection = this.jdbcServiceManager.getConnection();

  309.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,distinct,field);            
  310.    
  311.         }catch(ServiceException | NotImplementedException e){
  312.             this.logError(e); throw e;
  313.         }catch(NotFoundException e){
  314.             this.logDebug(e); throw e;
  315.         }catch(Exception e){
  316.             this.logError(e); throw new ServiceException("Select 'distinct:"+distinct+"' field not completed: "+e.getMessage(),e);
  317.         }finally{
  318.             if(connection!=null){
  319.                 this.jdbcServiceManager.closeConnection(connection);
  320.             }
  321.         }
  322.        
  323.     }
  324.    
  325.     @Override
  326.     public List<Map<String,Object>> select(IPaginatedExpression paginatedExpression, IField ... field) throws ServiceException,NotFoundException,NotImplementedException {
  327.    
  328.         Connection connection = null;
  329.         try{
  330.            
  331.             // check parameters
  332.             if(paginatedExpression==null){
  333.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  334.             }
  335.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  336.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  337.             }
  338.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  339.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  340.             // ISQLQueryObject
  341.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  342.             sqlQueryObject.setANDLogicOperator(true);
  343.             // Connection sql
  344.             connection = this.jdbcServiceManager.getConnection();

  345.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,field);        
  346.    
  347.         }catch(ServiceException | NotImplementedException e){
  348.             this.logError(e); throw e;
  349.         }catch(NotFoundException e){
  350.             this.logDebug(e); throw e;
  351.         }catch(Exception e){
  352.             this.logError(e); throw new ServiceException("Select not completed: "+e.getMessage(),e);
  353.         }finally{
  354.             if(connection!=null){
  355.                 this.jdbcServiceManager.closeConnection(connection);
  356.             }
  357.         }
  358.    
  359.     }
  360.     @Override
  361.     public List<Map<String,Object>> select(IPaginatedExpression paginatedExpression, boolean distinct, IField ... field) throws ServiceException,NotFoundException,NotImplementedException {

  362.         Connection connection = null;
  363.         try{
  364.            
  365.             // check parameters
  366.             if(paginatedExpression==null){
  367.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNullErrorParameterPaginated();
  368.             }
  369.             if( ! (paginatedExpression instanceof JDBCPaginatedExpression) ){
  370.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongTypeErrorParameterPaginated(paginatedExpression);
  371.             }
  372.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) paginatedExpression;
  373.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  374.             // ISQLQueryObject
  375.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  376.             sqlQueryObject.setANDLogicOperator(true);
  377.             // Connection sql
  378.             connection = this.jdbcServiceManager.getConnection();

  379.             return this.serviceSearch.select(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression,distinct,field);            
  380.    
  381.         }catch(ServiceException | NotImplementedException e){
  382.             this.logError(e); throw e;
  383.         }catch(NotFoundException e){
  384.             this.logDebug(e); throw e;
  385.         }catch(Exception e){
  386.             this.logError(e); throw new ServiceException("Select distinct:"+distinct+" not completed: "+e.getMessage(),e);
  387.         }finally{
  388.             if(connection!=null){
  389.                 this.jdbcServiceManager.closeConnection(connection);
  390.             }
  391.         }
  392.        
  393.     }
  394.    
  395.    
  396.    
  397.    
  398.    
  399.    

  400.     @Override
  401.     public IExpression newExpression() throws ServiceException,NotImplementedException {

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

  403.     }

  404.     @Override
  405.     public IPaginatedExpression newPaginatedExpression() throws ServiceException, NotImplementedException {

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

  407.     }
  408.    
  409.     @Override
  410.     public IExpression toExpression(IPaginatedExpression paginatedExpression) throws ServiceException,NotImplementedException {

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

  412.     }

  413.     @Override
  414.     public IPaginatedExpression toPaginatedExpression(IExpression expression) throws ServiceException, NotImplementedException {

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

  416.     }
  417.    

  418.     // -- DB
  419.    
  420.     @Override
  421.     public void mappingTableIds(ConfigurazioneGenerale obj) throws ServiceException,NotFoundException,NotImplementedException{
  422.         Connection connection = null;
  423.         try{
  424.            
  425.             // check parameters
  426.             if(obj==null){
  427.                 throw this.newServiceExceptionParameterObjIsNull();
  428.             }
  429.            
  430.             // ISQLQueryObject
  431.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  432.             sqlQueryObject.setANDLogicOperator(true);
  433.             // Connection sql
  434.             connection = this.jdbcServiceManager.getConnection();
  435.        
  436.             this.serviceSearch.mappingTableIds(this.jdbcProperties,this.log,connection,sqlQueryObject,obj);
  437.        
  438.         }catch(ServiceException | NotImplementedException e){
  439.             this.logError(e); throw e;
  440.         }catch(NotFoundException e){
  441.             this.logDebug(e); throw e;
  442.         }catch(Exception e){
  443.             this.logError(e); throw new ServiceException("mappingIds not completed: "+e.getMessage(),e);
  444.         }finally{
  445.             if(connection!=null){
  446.                 this.jdbcServiceManager.closeConnection(connection);
  447.             }
  448.         }
  449.     }
  450.        
  451.     @Override
  452.     public ConfigurazioneGenerale get(long tableId) throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  453.    
  454.         Connection connection = null;
  455.         try{
  456.            
  457.             // check parameters
  458.             if(tableId<=0){
  459.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  460.             }
  461.            
  462.             // ISQLQueryObject
  463.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  464.             sqlQueryObject.setANDLogicOperator(true);
  465.             // Connection sql
  466.             connection = this.jdbcServiceManager.getConnection();
  467.        
  468.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,null);
  469.        
  470.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  471.             this.logError(e); throw e;
  472.         }catch(NotFoundException e){
  473.             this.logDebug(e); throw e;
  474.         }catch(Exception e){
  475.             this.logError(e); throw new ServiceException("Get(tableId) not completed: "+e.getMessage(),e);
  476.         }finally{
  477.             if(connection!=null){
  478.                 this.jdbcServiceManager.closeConnection(connection);
  479.             }
  480.         }
  481.    
  482.     }
  483.    
  484.     @Override
  485.     public ConfigurazioneGenerale get(long tableId,org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws ServiceException, NotFoundException,MultipleResultException, NotImplementedException {
  486.    
  487.         Connection connection = null;
  488.         try{
  489.            
  490.             // check parameters
  491.             if(tableId<=0){
  492.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  493.             }
  494.             if(idMappingResolutionBehaviour==null){
  495.                 throw this.newServiceExceptionParameterIdMappingResolutionBehaviourIsNull();
  496.             }
  497.            
  498.             // ISQLQueryObject
  499.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  500.             sqlQueryObject.setANDLogicOperator(true);
  501.             // Connection sql
  502.             connection = this.jdbcServiceManager.getConnection();
  503.        
  504.             return this.serviceSearch.get(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId,idMappingResolutionBehaviour);
  505.        
  506.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  507.             this.logError(e); throw e;
  508.         }catch(NotFoundException e){
  509.             this.logDebug(e); throw e;
  510.         }catch(Exception e){
  511.             this.logError(e); throw new ServiceException("Get(tableId,idMappingResolutionBehaviour) not completed: "+e.getMessage(),e);
  512.         }finally{
  513.             if(connection!=null){
  514.                 this.jdbcServiceManager.closeConnection(connection);
  515.             }
  516.         }
  517.    
  518.     }
  519.    
  520.     @Override
  521.     public boolean exists(long tableId) throws MultipleResultException,ServiceException,NotImplementedException {

  522.         Connection connection = null;
  523.         try{
  524.            
  525.             // check parameters
  526.             if(tableId<=0){
  527.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  528.             }

  529.             // ISQLQueryObject
  530.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  531.             sqlQueryObject.setANDLogicOperator(true);
  532.             // Connection sql
  533.             connection = this.jdbcServiceManager.getConnection();

  534.             return this.serviceSearch.exists(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId);          
  535.    
  536.         }catch(MultipleResultException | ServiceException | NotImplementedException e){
  537.             this.logError(e); throw e;
  538.         }catch(Exception e){
  539.             this.logError(e); throw new ServiceException("Exists(tableId) not completed: "+e.getMessage(),e);
  540.         }finally{
  541.             if(connection!=null){
  542.                 this.jdbcServiceManager.closeConnection(connection);
  543.             }
  544.         }
  545.        
  546.     }
  547.    
  548.     @Override
  549.     public List<Long> findAllTableIds(IPaginatedExpression expression) throws ServiceException, NotImplementedException {
  550.        
  551.         Connection connection = null;
  552.         try{
  553.            
  554.             // check parameters
  555.             if(expression==null){
  556.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  557.             }
  558.             if( ! (expression instanceof JDBCPaginatedExpression) ){
  559.                 throw this.newServiceExceptionParameterPaginatedExpressionWrongType(expression);
  560.             }
  561.             JDBCPaginatedExpression jdbcPaginatedExpression = (JDBCPaginatedExpression) expression;
  562.             logJDBCPaginatedExpression(jdbcPaginatedExpression);

  563.             // ISQLQueryObject
  564.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  565.             sqlQueryObject.setANDLogicOperator(true);
  566.             // Connection sql
  567.             connection = this.jdbcServiceManager.getConnection();
  568.            
  569.             return this.serviceSearch.findAllTableIds(this.jdbcProperties,this.log,connection,sqlQueryObject,jdbcPaginatedExpression);
  570.    
  571.         }catch(ServiceException | NotImplementedException e){
  572.             this.logError(e); throw e;
  573.         }catch(Exception e){
  574.             this.logError(e); throw new ServiceException("findAllTableIds not completed: "+e.getMessage(),e);
  575.         }finally{
  576.             if(connection!=null){
  577.                 this.jdbcServiceManager.closeConnection(connection);
  578.             }
  579.         }
  580.        
  581.     }
  582.    
  583.     @Override
  584.     public long findTableId(IExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException {
  585.    
  586.         Connection connection = null;
  587.         try{
  588.            
  589.             // check parameters
  590.             if(expression==null){
  591.                 throw this.newServiceExceptionParameterPaginatedExpressionIsNull();
  592.             }
  593.             if( ! (expression instanceof JDBCExpression) ){
  594.                 throw this.newServiceExceptionParameterExpressionWrongType(expression);
  595.             }
  596.             JDBCExpression jdbcExpression = (JDBCExpression) expression;
  597.             this.logJDBCExpression(jdbcExpression);

  598.             // ISQLQueryObject
  599.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  600.             sqlQueryObject.setANDLogicOperator(true);
  601.             // Connection sql
  602.             connection = this.jdbcServiceManager.getConnection();

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

  604.         }catch(ServiceException | MultipleResultException | NotImplementedException e){
  605.             this.logError(e); throw e;
  606.         }catch(NotFoundException e){
  607.             this.logDebug(e); throw e;
  608.         }catch(Exception e){
  609.             this.logError(e); throw new ServiceException("findTableId not completed: "+e.getMessage(),e);
  610.         }finally{
  611.             if(connection!=null){
  612.                 this.jdbcServiceManager.closeConnection(connection);
  613.             }
  614.         }
  615.    
  616.     }
  617.    
  618.     @Override
  619.     public InUse inUse(long tableId) throws ServiceException, NotFoundException, NotImplementedException {
  620.    
  621.         Connection connection = null;
  622.         try{
  623.            
  624.             // check parameters
  625.             if(tableId<=0){
  626.                 throw this.newServiceExceptionParameterTableIdLessEqualsZero();
  627.             }
  628.            
  629.             // ISQLQueryObject
  630.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  631.             sqlQueryObject.setANDLogicOperator(true);
  632.             // Connection sql
  633.             connection = this.jdbcServiceManager.getConnection();

  634.             return this.serviceSearch.inUse(this.jdbcProperties,this.log,connection,sqlQueryObject,tableId);        
  635.    
  636.         }catch(ServiceException | NotImplementedException e){
  637.             this.logError(e); throw e;
  638.         }catch(NotFoundException e){
  639.             this.logDebug(e); throw e;
  640.         }catch(Exception e){
  641.             this.logError(e); throw new ServiceException("InUse(tableId) not completed: "+e.getMessage(),e);
  642.         }finally{
  643.             if(connection!=null){
  644.                 this.jdbcServiceManager.closeConnection(connection);
  645.             }
  646.         }
  647.    
  648.     }
  649.    
  650.    
  651.     @Override
  652.     public void disableSelectForUpdate() throws ServiceException,NotImplementedException {
  653.         this.jdbcSqlObjectFactory.setSelectForUpdate(false);
  654.     }

  655.     @Override
  656.     public void enableSelectForUpdate() throws ServiceException,NotImplementedException {
  657.         this.jdbcSqlObjectFactory.setSelectForUpdate(true);
  658.     }
  659.    
  660.    
  661.     @Override
  662.     public List<List<Object>> nativeQuery(String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException{
  663.    
  664.         Connection connection = null;
  665.         try{
  666.            
  667.             // check parameters
  668.             if(returnClassTypes==null || returnClassTypes.isEmpty()){
  669.                 throw new ServiceException("Parameter 'returnClassTypes' is less equals 0");
  670.             }
  671.            
  672.             // ISQLQueryObject
  673.             ISQLQueryObject sqlQueryObject = this.jdbcSqlObjectFactory.createSQLQueryObject(this.jdbcProperties.getDatabase());
  674.             sqlQueryObject.setANDLogicOperator(true);
  675.             // Connection sql
  676.             connection = this.jdbcServiceManager.getConnection();

  677.             return this.serviceSearch.nativeQuery(this.jdbcProperties,this.log,connection,sqlQueryObject,sql,returnClassTypes,param);      
  678.    
  679.         }catch(ServiceException | NotImplementedException e){
  680.             this.logError(e); throw e;
  681.         }catch(NotFoundException e){
  682.             this.logDebug(e); throw e;
  683.         }catch(Exception e){
  684.             this.logError(e); throw new ServiceException("nativeQuery not completed: "+e.getMessage(),e);
  685.         }finally{
  686.             if(connection!=null){
  687.                 this.jdbcServiceManager.closeConnection(connection);
  688.             }
  689.         }
  690.    
  691.     }
  692.    
  693. }