JDBCConfigurazioneServizioAzioneBaseLib.java

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

  21. import org.openspcoop2.core.plugins.ConfigurazioneFiltro;
  22. import org.openspcoop2.core.plugins.ConfigurazioneServizioAzione;
  23. import org.openspcoop2.core.plugins.IdConfigurazioneFiltro;
  24. import org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione;

  25. import java.sql.Connection;

  26. import org.slf4j.Logger;
  27. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  28. import org.openspcoop2.generic_project.exception.ExpressionException;
  29. import org.openspcoop2.generic_project.exception.ExpressionNotImplementedException;
  30. import org.openspcoop2.generic_project.exception.MultipleResultException;
  31. import org.openspcoop2.generic_project.exception.NotFoundException;
  32. import org.openspcoop2.generic_project.exception.NotImplementedException;
  33. import org.openspcoop2.generic_project.exception.ServiceException;
  34. import org.openspcoop2.generic_project.expression.IExpression;

  35. /**    
  36.  * JDBCConfigurazioneServizioAzioneBaseLib
  37.  *
  38.  * @author Poli Andrea (poli@link.it)
  39.  * @author $Author$
  40.  * @version $Rev$, $Date$
  41.  */
  42. public class JDBCConfigurazioneServizioAzioneBaseLib {

  43.    
  44.     public static Long getIdConfigurazioneServizioAzione(Connection connection, JDBCServiceManagerProperties jdbcProperties, Logger log,
  45.             String azione,String accordo, String tipoSoggettoReferente, String nomeSoggettoReferente,
  46.             Integer versioneServizio, String servizio, boolean throwNotFound) throws ServiceException, NotImplementedException, ExpressionNotImplementedException, ExpressionException, NotFoundException, MultipleResultException{
  47.        
  48.         JDBCServiceManager jdbcServiceManager = new JDBCServiceManager(connection, jdbcProperties, log);
  49.        
  50.         IExpression expressionSearchConfigurazioneServizioAzione = jdbcServiceManager.getConfigurazioneServizioAzioneServiceSearch().newExpression();
  51.         expressionSearchConfigurazioneServizioAzione.
  52.             and().
  53.             equals(ConfigurazioneServizioAzione.model().AZIONE,azione).
  54.             equals(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.ACCORDO, accordo).
  55.             equals(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.TIPO_SOGGETTO_REFERENTE, tipoSoggettoReferente).
  56.             equals(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.NOME_SOGGETTO_REFERENTE, nomeSoggettoReferente).
  57.             equals(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.VERSIONE, versioneServizio).
  58.             equals(ConfigurazioneServizioAzione.model().ID_CONFIGURAZIONE_SERVIZIO.SERVIZIO, servizio);
  59.        
  60.         Long id_configurazioneServizioAzione = null;
  61.         try{
  62.             ConfigurazioneServizioAzione configurazioneServizioAzione = jdbcServiceManager.getConfigurazioneServizioAzioneServiceSearch().find(expressionSearchConfigurazioneServizioAzione);
  63.             id_configurazioneServizioAzione = configurazioneServizioAzione.getId();
  64.         }catch(NotFoundException notFound){
  65.             if(throwNotFound){
  66.                 throw new NotFoundException(notFound);
  67.             }
  68.         }
  69.        
  70.         return id_configurazioneServizioAzione;
  71.     }
  72.    
  73.     public static IdConfigurazioneServizioAzione getIdConfigurazioneServizioAzione(Connection connection, JDBCServiceManagerProperties jdbcProperties, Logger log, Long idConfigurazioneServizioAzioneLong) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException{
  74.        
  75.         JDBCServiceManager jdbcServiceManager = new JDBCServiceManager(connection, jdbcProperties, log);
  76.        
  77.         ConfigurazioneServizioAzione configuraServizioAzione =
  78.                 ((org.openspcoop2.core.plugins.dao.IDBConfigurazioneServizioAzioneServiceSearch)jdbcServiceManager.getConfigurazioneServizioAzioneServiceSearch()).get(idConfigurazioneServizioAzioneLong);
  79.         org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione idConfigurazioneServizioAzione = new IdConfigurazioneServizioAzione();
  80.         idConfigurazioneServizioAzione.setAzione(configuraServizioAzione.getAzione());
  81.         idConfigurazioneServizioAzione.setIdConfigurazioneServizio(configuraServizioAzione.getIdConfigurazioneServizio());
  82.         return idConfigurazioneServizioAzione;
  83.     }
  84.    
  85.    
  86.    
  87.    
  88.     public static Long getIdConfigurazioneFiltro(Connection connection, JDBCServiceManagerProperties jdbcProperties, Logger log,
  89.             String nome, boolean throwNotFound) throws ServiceException, NotImplementedException, ExpressionNotImplementedException, ExpressionException, NotFoundException, MultipleResultException{
  90.        
  91.         JDBCServiceManager jdbcServiceManager = new JDBCServiceManager(connection, jdbcProperties, log);
  92.        
  93.         IExpression expressionSearchConfigurazioneFiltro = jdbcServiceManager.getConfigurazioneFiltroServiceSearch().newExpression();
  94.         expressionSearchConfigurazioneFiltro.
  95.             and().
  96.             equals(ConfigurazioneFiltro.model().NOME,nome);
  97.        
  98.         Long id_configurazioneFiltro = null;
  99.         try{
  100.             ConfigurazioneFiltro configurazioneFiltro = jdbcServiceManager.getConfigurazioneFiltroServiceSearch().find(expressionSearchConfigurazioneFiltro);
  101.             id_configurazioneFiltro = configurazioneFiltro.getId();
  102.         }catch(NotFoundException notFound){
  103.             if(throwNotFound){
  104.                 throw new NotFoundException(notFound);
  105.             }
  106.         }
  107.        
  108.         return id_configurazioneFiltro;
  109.     }
  110.    
  111.     public static IdConfigurazioneFiltro getIdConfigurazioneFiltro(Connection connection, JDBCServiceManagerProperties jdbcProperties, Logger log, Long idConfigurazioneFiltro) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException{
  112.        
  113.         JDBCServiceManager jdbcServiceManager = new JDBCServiceManager(connection, jdbcProperties, log);
  114.        
  115.         ConfigurazioneFiltro configuraFiltro =
  116.                 ((org.openspcoop2.core.plugins.dao.IDBConfigurazioneFiltroServiceSearch)jdbcServiceManager.getConfigurazioneFiltroServiceSearch()).get(idConfigurazioneFiltro);
  117.         org.openspcoop2.core.plugins.IdConfigurazioneFiltro idConfigurazioneFiltroAsObject = new IdConfigurazioneFiltro();
  118.         idConfigurazioneFiltroAsObject.setNome(configuraFiltro.getNome());
  119.         return idConfigurazioneFiltroAsObject;
  120.     }
  121.    
  122.     public static ConfigurazioneFiltro getConfigurazioneFiltro(Connection connection, JDBCServiceManagerProperties jdbcProperties, Logger log, Long idConfigurazioneFiltro) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException{
  123.        
  124.         JDBCServiceManager jdbcServiceManager = new JDBCServiceManager(connection, jdbcProperties, log);
  125.        
  126.         ConfigurazioneFiltro configuraFiltro =
  127.                 ((org.openspcoop2.core.plugins.dao.IDBConfigurazioneFiltroServiceSearch)jdbcServiceManager.getConfigurazioneFiltroServiceSearch()).get(idConfigurazioneFiltro);
  128.         return configuraFiltro;
  129.     }
  130.    
  131. }