ConfigurazioneServizioAzioneFetch.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.ConfigurazioneServizioAzione;


  30. /**    
  31.  * ConfigurazioneServizioAzioneFetch
  32.  *
  33.  * @author Poli Andrea (poli@link.it)
  34.  * @author $Author$
  35.  * @version $Rev$, $Date$
  36.  */
  37. public class ConfigurazioneServizioAzioneFetch 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(ConfigurazioneServizioAzione.model())){
  45.                 ConfigurazioneServizioAzione object = new ConfigurazioneServizioAzione();
  46.                 setParameter(object, "setId", Long.class,
  47.                     jdbcParameterUtilities.readParameter(rs, "id", Long.class));
  48.                 setParameter(object, "setAzione", ConfigurazioneServizioAzione.model().AZIONE.getFieldType(),
  49.                     jdbcParameterUtilities.readParameter(rs, "azione", ConfigurazioneServizioAzione.model().AZIONE.getFieldType()));
  50.                 return object;
  51.             }
  52.            
  53.             else{
  54.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  55.             }  
  56.                    
  57.         }catch(Exception e){
  58.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  59.         }
  60.        
  61.     }
  62.    
  63.     @Override
  64.     public Object fetch(TipiDatabase tipoDatabase, IModel<?> model , Map<String,Object> map ) throws ServiceException {
  65.        
  66.         try{

  67.             if(model.equals(ConfigurazioneServizioAzione.model())){
  68.                 ConfigurazioneServizioAzione object = new ConfigurazioneServizioAzione();
  69.                 setParameter(object, "setId", Long.class,
  70.                     this.getObjectFromMap(map,"id"));
  71.                 setParameter(object, "setAzione", ConfigurazioneServizioAzione.model().AZIONE.getFieldType(),
  72.                     this.getObjectFromMap(map,"azione"));
  73.                 return object;
  74.             }
  75.            
  76.             else{
  77.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  78.             }  
  79.                    
  80.         }catch(Exception e){
  81.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  82.         }
  83.        
  84.     }
  85.    
  86.    
  87.     @Override
  88.     public IKeyGeneratorObject getKeyGeneratorObject( IModel<?> model )  throws ServiceException {
  89.        
  90.         try{

  91.             if(model.equals(ConfigurazioneServizioAzione.model())){
  92.                 return new org.openspcoop2.utils.jdbc.CustomKeyGeneratorObject("plugins_conf_azioni","id","seq_plugins_conf_azioni","plugins_conf_azioni_init_seq");
  93.             }
  94.            
  95.             else{
  96.                 throw new ServiceException("Model ["+model.toString()+"] not supported by getKeyGeneratorObject: "+this.getClass().getName());
  97.             }

  98.         }catch(Exception e){
  99.             throw new ServiceException("Model ["+model.toString()+"] occurs error in getKeyGeneratorObject: "+e.getMessage(),e);
  100.         }
  101.        
  102.     }

  103. }