ConfigurazioneFiltroFetch.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.fetch;

  21. import org.openspcoop2.generic_project.beans.IModel;
  22. import org.openspcoop2.generic_project.dao.jdbc.utils.AbstractJDBCFetch;
  23. import org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCParameterUtilities;
  24. import org.openspcoop2.generic_project.exception.ServiceException;

  25. import java.sql.ResultSet;
  26. import java.util.Map;

  27. import org.openspcoop2.utils.TipiDatabase;
  28. import org.openspcoop2.utils.jdbc.IKeyGeneratorObject;

  29. import org.openspcoop2.core.plugins.ConfigurazioneFiltro;


  30. /**    
  31.  * ConfigurazioneFiltroFetch
  32.  *
  33.  * @author Poli Andrea (poli@link.it)
  34.  * @author $Author$
  35.  * @version $Rev$, $Date$
  36.  */
  37. public class ConfigurazioneFiltroFetch extends AbstractJDBCFetch {

  38.     @Override
  39.     public Object fetch(TipiDatabase tipoDatabase, IModel<?> model , ResultSet rs) throws ServiceException {
  40.        
  41.         try{
  42.             GenericJDBCParameterUtilities jdbcParameterUtilities =  
  43.                     new GenericJDBCParameterUtilities(tipoDatabase);

  44.             if(model.equals(ConfigurazioneFiltro.model())){
  45.                 ConfigurazioneFiltro object = new ConfigurazioneFiltro();
  46.                 setParameter(object, "setId", Long.class,
  47.                     jdbcParameterUtilities.readParameter(rs, "id", Long.class));
  48.                 setParameter(object, "setNome", ConfigurazioneFiltro.model().NOME.getFieldType(),
  49.                     jdbcParameterUtilities.readParameter(rs, "nome", ConfigurazioneFiltro.model().NOME.getFieldType()));
  50.                 setParameter(object, "setDescrizione", ConfigurazioneFiltro.model().DESCRIZIONE.getFieldType(),
  51.                     jdbcParameterUtilities.readParameter(rs, "descrizione", ConfigurazioneFiltro.model().DESCRIZIONE.getFieldType()));
  52.                 setParameter(object, "setTipoMittente", ConfigurazioneFiltro.model().TIPO_MITTENTE.getFieldType(),
  53.                     jdbcParameterUtilities.readParameter(rs, "tipo_mittente", ConfigurazioneFiltro.model().TIPO_MITTENTE.getFieldType()));
  54.                 setParameter(object, "setNomeMittente", ConfigurazioneFiltro.model().NOME_MITTENTE.getFieldType(),
  55.                     jdbcParameterUtilities.readParameter(rs, "nome_mittente", ConfigurazioneFiltro.model().NOME_MITTENTE.getFieldType()));
  56.                 setParameter(object, "setIdportaMittente", ConfigurazioneFiltro.model().IDPORTA_MITTENTE.getFieldType(),
  57.                     jdbcParameterUtilities.readParameter(rs, "idporta_mittente", ConfigurazioneFiltro.model().IDPORTA_MITTENTE.getFieldType()));
  58.                 setParameter(object, "setTipoDestinatario", ConfigurazioneFiltro.model().TIPO_DESTINATARIO.getFieldType(),
  59.                     jdbcParameterUtilities.readParameter(rs, "tipo_destinatario", ConfigurazioneFiltro.model().TIPO_DESTINATARIO.getFieldType()));
  60.                 setParameter(object, "setNomeDestinatario", ConfigurazioneFiltro.model().NOME_DESTINATARIO.getFieldType(),
  61.                     jdbcParameterUtilities.readParameter(rs, "nome_destinatario", ConfigurazioneFiltro.model().NOME_DESTINATARIO.getFieldType()));
  62.                 setParameter(object, "setIdportaDestinatario", ConfigurazioneFiltro.model().IDPORTA_DESTINATARIO.getFieldType(),
  63.                     jdbcParameterUtilities.readParameter(rs, "idporta_destinatario", ConfigurazioneFiltro.model().IDPORTA_DESTINATARIO.getFieldType()));
  64.                 setParameter(object, "setTipoServizio", ConfigurazioneFiltro.model().TIPO_SERVIZIO.getFieldType(),
  65.                     jdbcParameterUtilities.readParameter(rs, "tipo_servizio", ConfigurazioneFiltro.model().TIPO_SERVIZIO.getFieldType()));
  66.                 setParameter(object, "setNomeServizio", ConfigurazioneFiltro.model().NOME_SERVIZIO.getFieldType(),
  67.                     jdbcParameterUtilities.readParameter(rs, "nome_servizio", ConfigurazioneFiltro.model().NOME_SERVIZIO.getFieldType()));
  68.                 setParameter(object, "setVersioneServizio", ConfigurazioneFiltro.model().VERSIONE_SERVIZIO.getFieldType(),
  69.                     jdbcParameterUtilities.readParameter(rs, "versione_servizio", ConfigurazioneFiltro.model().VERSIONE_SERVIZIO.getFieldType()));
  70.                 setParameter(object, "setAzione", ConfigurazioneFiltro.model().AZIONE.getFieldType(),
  71.                     jdbcParameterUtilities.readParameter(rs, "azione", ConfigurazioneFiltro.model().AZIONE.getFieldType()));
  72.                 return object;
  73.             }
  74.            
  75.             else{
  76.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  77.             }  
  78.                    
  79.         }catch(Exception e){
  80.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  81.         }
  82.        
  83.     }
  84.    
  85.     @Override
  86.     public Object fetch(TipiDatabase tipoDatabase, IModel<?> model , Map<String,Object> map ) throws ServiceException {
  87.        
  88.         try{

  89.             if(model.equals(ConfigurazioneFiltro.model())){
  90.                 ConfigurazioneFiltro object = new ConfigurazioneFiltro();
  91.                 setParameter(object, "setId", Long.class,
  92.                     this.getObjectFromMap(map,"id"));
  93.                 setParameter(object, "setNome", ConfigurazioneFiltro.model().NOME.getFieldType(),
  94.                     this.getObjectFromMap(map,"nome"));
  95.                 setParameter(object, "setDescrizione", ConfigurazioneFiltro.model().DESCRIZIONE.getFieldType(),
  96.                     this.getObjectFromMap(map,"descrizione"));
  97.                 setParameter(object, "setTipoMittente", ConfigurazioneFiltro.model().TIPO_MITTENTE.getFieldType(),
  98.                     this.getObjectFromMap(map,"tipo-mittente"));
  99.                 setParameter(object, "setNomeMittente", ConfigurazioneFiltro.model().NOME_MITTENTE.getFieldType(),
  100.                     this.getObjectFromMap(map,"nome-mittente"));
  101.                 setParameter(object, "setIdportaMittente", ConfigurazioneFiltro.model().IDPORTA_MITTENTE.getFieldType(),
  102.                     this.getObjectFromMap(map,"idporta-mittente"));
  103.                 setParameter(object, "setTipoDestinatario", ConfigurazioneFiltro.model().TIPO_DESTINATARIO.getFieldType(),
  104.                     this.getObjectFromMap(map,"tipo-destinatario"));
  105.                 setParameter(object, "setNomeDestinatario", ConfigurazioneFiltro.model().NOME_DESTINATARIO.getFieldType(),
  106.                     this.getObjectFromMap(map,"nome-destinatario"));
  107.                 setParameter(object, "setIdportaDestinatario", ConfigurazioneFiltro.model().IDPORTA_DESTINATARIO.getFieldType(),
  108.                     this.getObjectFromMap(map,"idporta-destinatario"));
  109.                 setParameter(object, "setTipoServizio", ConfigurazioneFiltro.model().TIPO_SERVIZIO.getFieldType(),
  110.                     this.getObjectFromMap(map,"tipo-servizio"));
  111.                 setParameter(object, "setNomeServizio", ConfigurazioneFiltro.model().NOME_SERVIZIO.getFieldType(),
  112.                     this.getObjectFromMap(map,"nome-servizio"));
  113.                 setParameter(object, "setVersioneServizio", ConfigurazioneFiltro.model().VERSIONE_SERVIZIO.getFieldType(),
  114.                     this.getObjectFromMap(map,"versione-servizio"));
  115.                 setParameter(object, "setAzione", ConfigurazioneFiltro.model().AZIONE.getFieldType(),
  116.                     this.getObjectFromMap(map,"azione"));
  117.                 return object;
  118.             }
  119.            
  120.             else{
  121.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  122.             }  
  123.                    
  124.         }catch(Exception e){
  125.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  126.         }
  127.        
  128.     }
  129.    
  130.    
  131.     @Override
  132.     public IKeyGeneratorObject getKeyGeneratorObject( IModel<?> model )  throws ServiceException {
  133.        
  134.         try{

  135.             if(model.equals(ConfigurazioneFiltro.model())){
  136.                 return new org.openspcoop2.utils.jdbc.CustomKeyGeneratorObject("plugins_conf_filtri","id","seq_plugins_conf_filtri","plugins_conf_filtri_init_seq");
  137.             }
  138.            
  139.             else{
  140.                 throw new ServiceException("Model ["+model.toString()+"] not supported by getKeyGeneratorObject: "+this.getClass().getName());
  141.             }

  142.         }catch(Exception e){
  143.             throw new ServiceException("Model ["+model.toString()+"] occurs error in getKeyGeneratorObject: "+e.getMessage(),e);
  144.         }
  145.        
  146.     }

  147. }