ConfigurazioneTransazioneFetch.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.monitor.engine.config.transazioni.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.monitor.engine.config.transazioni.ConfigurazioneTransazioneRisorsaContenuto;
  30. import org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazionePlugin;
  31. import org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneStato;
  32. import org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazione;


  33. /**    
  34.  * ConfigurazioneTransazioneFetch
  35.  *
  36.  * @author Poli Andrea (poli@link.it)
  37.  * @author $Author$
  38.  * @version $Rev$, $Date$
  39.  */
  40. public class ConfigurazioneTransazioneFetch extends AbstractJDBCFetch {

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

  47.             if(model.equals(ConfigurazioneTransazione.model())){
  48.                 ConfigurazioneTransazione object = new ConfigurazioneTransazione();
  49.                 setParameter(object, "setId", Long.class,
  50.                     jdbcParameterUtilities.readParameter(rs, "id", Long.class));
  51.                 setParameter(object, "setEnabled", ConfigurazioneTransazione.model().ENABLED.getFieldType(),
  52.                     jdbcParameterUtilities.readParameter(rs, "enabled", ConfigurazioneTransazione.model().ENABLED.getFieldType()));
  53.                 return object;
  54.             }
  55.             if(model.equals(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN)){
  56.                 ConfigurazioneTransazionePlugin object = new ConfigurazioneTransazionePlugin();
  57.                 setParameter(object, "setId", Long.class,
  58.                     jdbcParameterUtilities.readParameter(rs, "id", Long.class));
  59.                 setParameter(object, "setIdConfigurazioneTransazionePlugin", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.ID_CONFIGURAZIONE_TRANSAZIONE_PLUGIN.getFieldType(),
  60.                     jdbcParameterUtilities.readParameter(rs, "id_conf_trans_plugin", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.ID_CONFIGURAZIONE_TRANSAZIONE_PLUGIN.getFieldType()));
  61.                 setParameter(object, "setEnabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.ENABLED.getFieldType(),
  62.                     jdbcParameterUtilities.readParameter(rs, "enabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.ENABLED.getFieldType()));
  63.                 return object;
  64.             }
  65.             if(model.equals(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO)){
  66.                 ConfigurazioneTransazioneStato object = new ConfigurazioneTransazioneStato();
  67.                 setParameter(object, "setId", Long.class,
  68.                     jdbcParameterUtilities.readParameter(rs, "id", Long.class));
  69.                 setParameter(object, "setEnabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.ENABLED.getFieldType(),
  70.                     jdbcParameterUtilities.readParameter(rs, "enabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.ENABLED.getFieldType()));
  71.                 setParameter(object, "setNome", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.NOME.getFieldType(),
  72.                     jdbcParameterUtilities.readParameter(rs, "nome", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.NOME.getFieldType()));
  73.                 setParameter(object, "setTipoControlloRawEnumValue", String.class,
  74.                     jdbcParameterUtilities.readParameter(rs, "tipo_controllo", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.TIPO_CONTROLLO.getFieldType())+"");
  75.                 setParameter(object, "setTipoMessaggioRawEnumValue", String.class,
  76.                     jdbcParameterUtilities.readParameter(rs, "tipo_messaggio", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.TIPO_MESSAGGIO.getFieldType())+"");
  77.                 setParameter(object, "setValore", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.VALORE.getFieldType(),
  78.                     jdbcParameterUtilities.readParameter(rs, "valore", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.VALORE.getFieldType()));
  79.                 setParameter(object, "setXpath", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.XPATH.getFieldType(),
  80.                     jdbcParameterUtilities.readParameter(rs, "xpath", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.XPATH.getFieldType()));
  81.                 return object;
  82.             }
  83.             if(model.equals(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO)){
  84.                 ConfigurazioneTransazioneRisorsaContenuto object = new ConfigurazioneTransazioneRisorsaContenuto();
  85.                 setParameter(object, "setId", Long.class,
  86.                     jdbcParameterUtilities.readParameter(rs, "id", Long.class));
  87.                 setParameter(object, "setAbilitaAnonimizzazione", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ABILITA_ANONIMIZZAZIONE.getFieldType(),
  88.                     jdbcParameterUtilities.readParameter(rs, "abilita_anonimizzazione", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ABILITA_ANONIMIZZAZIONE.getFieldType()));
  89.                 setParameter(object, "setAbilitaCompressione", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ABILITA_COMPRESSIONE.getFieldType(),
  90.                     jdbcParameterUtilities.readParameter(rs, "abilita_compressione", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ABILITA_COMPRESSIONE.getFieldType()));
  91.                 setParameter(object, "setTipoCompressioneRawEnumValue", String.class,
  92.                     jdbcParameterUtilities.readParameter(rs, "tipo_compressione", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.TIPO_COMPRESSIONE.getFieldType())+"");
  93.                 setParameter(object, "setCarattereMaschera", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.CARATTERE_MASCHERA.getFieldType(),
  94.                     jdbcParameterUtilities.readParameter(rs, "carattere_maschera", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.CARATTERE_MASCHERA.getFieldType()));
  95.                 setParameter(object, "setNumeroCaratteriMaschera", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.NUMERO_CARATTERI_MASCHERA.getFieldType(),
  96.                     jdbcParameterUtilities.readParameter(rs, "num_char_maschera", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.NUMERO_CARATTERI_MASCHERA.getFieldType()));
  97.                 setParameter(object, "setPosizionamentoMascheraRawEnumValue", String.class,
  98.                     jdbcParameterUtilities.readParameter(rs, "posizionamento_maschera", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.POSIZIONAMENTO_MASCHERA.getFieldType())+"");
  99.                 setParameter(object, "setTipoMascheramentoRawEnumValue", String.class,
  100.                     jdbcParameterUtilities.readParameter(rs, "tipo_mascheramento", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.TIPO_MASCHERAMENTO.getFieldType())+"");
  101.                 setParameter(object, "setEnabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ENABLED.getFieldType(),
  102.                     jdbcParameterUtilities.readParameter(rs, "enabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ENABLED.getFieldType()));
  103.                 setParameter(object, "setNome", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.NOME.getFieldType(),
  104.                     jdbcParameterUtilities.readParameter(rs, "nome", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.NOME.getFieldType()));
  105.                 setParameter(object, "setTipoMessaggioRawEnumValue", String.class,
  106.                     jdbcParameterUtilities.readParameter(rs, "tipo_messaggio", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.TIPO_MESSAGGIO.getFieldType())+"");
  107.                 setParameter(object, "setXpath", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.XPATH.getFieldType(),
  108.                     jdbcParameterUtilities.readParameter(rs, "xpath", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.XPATH.getFieldType()));
  109.                 setParameter(object, "setStatEnabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.STAT_ENABLED.getFieldType(),
  110.                     jdbcParameterUtilities.readParameter(rs, "stat_enabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.STAT_ENABLED.getFieldType()));
  111.                 return object;
  112.             }
  113.            
  114.             else{
  115.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  116.             }  
  117.                    
  118.         }catch(Exception e){
  119.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  120.         }
  121.        
  122.     }
  123.    
  124.     @Override
  125.     public Object fetch(TipiDatabase tipoDatabase, IModel<?> model , Map<String,Object> map ) throws ServiceException {
  126.        
  127.         try{

  128.             if(model.equals(ConfigurazioneTransazione.model())){
  129.                 ConfigurazioneTransazione object = new ConfigurazioneTransazione();
  130.                 setParameter(object, "setId", Long.class,
  131.                     this.getObjectFromMap(map,"id"));
  132.                 setParameter(object, "setEnabled", ConfigurazioneTransazione.model().ENABLED.getFieldType(),
  133.                     this.getObjectFromMap(map,"enabled"));
  134.                 return object;
  135.             }
  136.             if(model.equals(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN)){
  137.                 ConfigurazioneTransazionePlugin object = new ConfigurazioneTransazionePlugin();
  138.                 setParameter(object, "setId", Long.class,
  139.                     this.getObjectFromMap(map,"configurazione-transazione-plugin.id"));
  140.                 setParameter(object, "setIdConfigurazioneTransazionePlugin", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.ID_CONFIGURAZIONE_TRANSAZIONE_PLUGIN.getFieldType(),
  141.                     this.getObjectFromMap(map,"configurazione-transazione-plugin.id-configurazione-transazione-plugin"));
  142.                 setParameter(object, "setEnabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.ENABLED.getFieldType(),
  143.                     this.getObjectFromMap(map,"configurazione-transazione-plugin.enabled"));
  144.                 return object;
  145.             }
  146.             if(model.equals(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO)){
  147.                 ConfigurazioneTransazioneStato object = new ConfigurazioneTransazioneStato();
  148.                 setParameter(object, "setId", Long.class,
  149.                     this.getObjectFromMap(map,"configurazione-transazione-stato.id"));
  150.                 setParameter(object, "setEnabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.ENABLED.getFieldType(),
  151.                     this.getObjectFromMap(map,"configurazione-transazione-stato.enabled"));
  152.                 setParameter(object, "setNome", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.NOME.getFieldType(),
  153.                     this.getObjectFromMap(map,"configurazione-transazione-stato.nome"));
  154.                 setParameter(object, "setTipoControlloRawEnumValue", String.class,
  155.                     this.getObjectFromMap(map,"configurazione-transazione-stato.tipo-controllo"));
  156.                 setParameter(object, "setTipoMessaggioRawEnumValue", String.class,
  157.                     this.getObjectFromMap(map,"configurazione-transazione-stato.tipo-messaggio"));
  158.                 setParameter(object, "setValore", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.VALORE.getFieldType(),
  159.                     this.getObjectFromMap(map,"configurazione-transazione-stato.valore"));
  160.                 setParameter(object, "setXpath", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.XPATH.getFieldType(),
  161.                     this.getObjectFromMap(map,"configurazione-transazione-stato.xpath"));
  162.                 return object;
  163.             }
  164.             if(model.equals(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO)){
  165.                 ConfigurazioneTransazioneRisorsaContenuto object = new ConfigurazioneTransazioneRisorsaContenuto();
  166.                 setParameter(object, "setId", Long.class,
  167.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.id"));
  168.                 setParameter(object, "setAbilitaAnonimizzazione", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ABILITA_ANONIMIZZAZIONE.getFieldType(),
  169.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.abilita-anonimizzazione"));
  170.                 setParameter(object, "setAbilitaCompressione", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ABILITA_COMPRESSIONE.getFieldType(),
  171.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.abilita-compressione"));
  172.                 setParameter(object, "setTipoCompressioneRawEnumValue", String.class,
  173.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.tipo-compressione"));
  174.                 setParameter(object, "setCarattereMaschera", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.CARATTERE_MASCHERA.getFieldType(),
  175.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.carattere-maschera"));
  176.                 setParameter(object, "setNumeroCaratteriMaschera", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.NUMERO_CARATTERI_MASCHERA.getFieldType(),
  177.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.numero-caratteri-maschera"));
  178.                 setParameter(object, "setPosizionamentoMascheraRawEnumValue", String.class,
  179.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.posizionamento-maschera"));
  180.                 setParameter(object, "setTipoMascheramentoRawEnumValue", String.class,
  181.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.tipo-mascheramento"));
  182.                 setParameter(object, "setEnabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ENABLED.getFieldType(),
  183.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.enabled"));
  184.                 setParameter(object, "setNome", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.NOME.getFieldType(),
  185.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.nome"));
  186.                 setParameter(object, "setTipoMessaggioRawEnumValue", String.class,
  187.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.tipo-messaggio"));
  188.                 setParameter(object, "setXpath", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.XPATH.getFieldType(),
  189.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.xpath"));
  190.                 setParameter(object, "setStatEnabled", ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.STAT_ENABLED.getFieldType(),
  191.                     this.getObjectFromMap(map,"configurazione-transazione-risorsa-contenuto.stat-enabled"));
  192.                 return object;
  193.             }
  194.            
  195.             else{
  196.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  197.             }  
  198.                    
  199.         }catch(Exception e){
  200.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  201.         }
  202.        
  203.     }
  204.    
  205.    
  206.     @Override
  207.     public IKeyGeneratorObject getKeyGeneratorObject( IModel<?> model )  throws ServiceException {
  208.        
  209.         try{

  210.             if(model.equals(ConfigurazioneTransazione.model())){
  211.                 return new org.openspcoop2.utils.jdbc.CustomKeyGeneratorObject("config_transazioni","id","seq_config_transazioni","config_transazioni_init_seq");
  212.             }
  213.             if(model.equals(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN)){
  214.                 return new org.openspcoop2.utils.jdbc.CustomKeyGeneratorObject("config_tran_plugins","id","seq_config_tran_plugins","config_tran_plugins_init_seq");
  215.             }
  216.             if(model.equals(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO)){
  217.                 return new org.openspcoop2.utils.jdbc.CustomKeyGeneratorObject("configurazione_stati","id","seq_configurazione_stati","configurazione_stati_init_seq");
  218.             }
  219.             if(model.equals(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO)){
  220.                 return new org.openspcoop2.utils.jdbc.CustomKeyGeneratorObject("conf_risorse_contenuti","id","seq_conf_risorse_contenuti","conf_risorse_contenuti_init_seq");
  221.             }
  222.            
  223.             else{
  224.                 throw new ServiceException("Model ["+model.toString()+"] not supported by getKeyGeneratorObject: "+this.getClass().getName());
  225.             }

  226.         }catch(Exception e){
  227.             throw new ServiceException("Model ["+model.toString()+"] occurs error in getKeyGeneratorObject: "+e.getMessage(),e);
  228.         }
  229.        
  230.     }

  231. }