TransazioneExportFetch.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.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.core.transazioni.TransazioneExport;


  30. /**    
  31.  * TransazioneExportFetch
  32.  *
  33.  * @author Poli Andrea (poli@link.it)
  34.  * @author $Author$
  35.  * @version $Rev$, $Date$
  36.  */
  37. public class TransazioneExportFetch 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(TransazioneExport.model())){
  45.                 TransazioneExport object = new TransazioneExport();
  46.                 setParameter(object, "setId", Long.class,
  47.                     jdbcParameterUtilities.readParameter(rs, "id", Long.class));
  48.                 setParameter(object, "setIntervalloInizio", TransazioneExport.model().INTERVALLO_INIZIO.getFieldType(),
  49.                     jdbcParameterUtilities.readParameter(rs, "intervallo_inizio", TransazioneExport.model().INTERVALLO_INIZIO.getFieldType()));
  50.                 setParameter(object, "setIntervalloFine", TransazioneExport.model().INTERVALLO_FINE.getFieldType(),
  51.                     jdbcParameterUtilities.readParameter(rs, "intervallo_fine", TransazioneExport.model().INTERVALLO_FINE.getFieldType()));
  52.                 setParameter(object, "setNome", TransazioneExport.model().NOME.getFieldType(),
  53.                     jdbcParameterUtilities.readParameter(rs, "nome", TransazioneExport.model().NOME.getFieldType()));
  54.                 setParameter(object, "setExportStateRawEnumValue", String.class,
  55.                     jdbcParameterUtilities.readParameter(rs, "export_state", TransazioneExport.model().EXPORT_STATE.getFieldType())+"");
  56.                 setParameter(object, "setExportError", TransazioneExport.model().EXPORT_ERROR.getFieldType(),
  57.                     jdbcParameterUtilities.readParameter(rs, "export_error", TransazioneExport.model().EXPORT_ERROR.getFieldType()));
  58.                 setParameter(object, "setExportTimeStart", TransazioneExport.model().EXPORT_TIME_START.getFieldType(),
  59.                     jdbcParameterUtilities.readParameter(rs, "export_time_start", TransazioneExport.model().EXPORT_TIME_START.getFieldType()));
  60.                 setParameter(object, "setExportTimeEnd", TransazioneExport.model().EXPORT_TIME_END.getFieldType(),
  61.                     jdbcParameterUtilities.readParameter(rs, "export_time_end", TransazioneExport.model().EXPORT_TIME_END.getFieldType()));
  62.                 setParameter(object, "setDeleteStateRawEnumValue", String.class,
  63.                     jdbcParameterUtilities.readParameter(rs, "delete_state", TransazioneExport.model().DELETE_STATE.getFieldType())+"");
  64.                 setParameter(object, "setDeleteError", TransazioneExport.model().DELETE_ERROR.getFieldType(),
  65.                     jdbcParameterUtilities.readParameter(rs, "delete_error", TransazioneExport.model().DELETE_ERROR.getFieldType()));
  66.                 setParameter(object, "setDeleteTimeStart", TransazioneExport.model().DELETE_TIME_START.getFieldType(),
  67.                     jdbcParameterUtilities.readParameter(rs, "delete_time_start", TransazioneExport.model().DELETE_TIME_START.getFieldType()));
  68.                 setParameter(object, "setDeleteTimeEnd", TransazioneExport.model().DELETE_TIME_END.getFieldType(),
  69.                     jdbcParameterUtilities.readParameter(rs, "delete_time_end", TransazioneExport.model().DELETE_TIME_END.getFieldType()));
  70.                 return object;
  71.             }
  72.            
  73.             else{
  74.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  75.             }  
  76.                    
  77.         }catch(Exception e){
  78.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  79.         }
  80.        
  81.     }
  82.    
  83.     @Override
  84.     public Object fetch(TipiDatabase tipoDatabase, IModel<?> model , Map<String,Object> map ) throws ServiceException {
  85.        
  86.         try{

  87.             if(model.equals(TransazioneExport.model())){
  88.                 TransazioneExport object = new TransazioneExport();
  89.                 setParameter(object, "setId", Long.class,
  90.                     this.getObjectFromMap(map,"id"));
  91.                 setParameter(object, "setIntervalloInizio", TransazioneExport.model().INTERVALLO_INIZIO.getFieldType(),
  92.                     this.getObjectFromMap(map,"intervallo-inizio"));
  93.                 setParameter(object, "setIntervalloFine", TransazioneExport.model().INTERVALLO_FINE.getFieldType(),
  94.                     this.getObjectFromMap(map,"intervallo-fine"));
  95.                 setParameter(object, "setNome", TransazioneExport.model().NOME.getFieldType(),
  96.                     this.getObjectFromMap(map,"nome"));
  97.                 setParameter(object, "setExportStateRawEnumValue", String.class,
  98.                     this.getObjectFromMap(map,"export-state"));
  99.                 setParameter(object, "setExportError", TransazioneExport.model().EXPORT_ERROR.getFieldType(),
  100.                     this.getObjectFromMap(map,"export-error"));
  101.                 setParameter(object, "setExportTimeStart", TransazioneExport.model().EXPORT_TIME_START.getFieldType(),
  102.                     this.getObjectFromMap(map,"export-time-start"));
  103.                 setParameter(object, "setExportTimeEnd", TransazioneExport.model().EXPORT_TIME_END.getFieldType(),
  104.                     this.getObjectFromMap(map,"export-time-end"));
  105.                 setParameter(object, "setDeleteStateRawEnumValue", String.class,
  106.                     this.getObjectFromMap(map,"delete-state"));
  107.                 setParameter(object, "setDeleteError", TransazioneExport.model().DELETE_ERROR.getFieldType(),
  108.                     this.getObjectFromMap(map,"delete-error"));
  109.                 setParameter(object, "setDeleteTimeStart", TransazioneExport.model().DELETE_TIME_START.getFieldType(),
  110.                     this.getObjectFromMap(map,"delete-time-start"));
  111.                 setParameter(object, "setDeleteTimeEnd", TransazioneExport.model().DELETE_TIME_END.getFieldType(),
  112.                     this.getObjectFromMap(map,"delete-time-end"));
  113.                 return object;
  114.             }
  115.            
  116.             else{
  117.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  118.             }  
  119.                    
  120.         }catch(Exception e){
  121.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  122.         }
  123.        
  124.     }
  125.    
  126.    
  127.     @Override
  128.     public IKeyGeneratorObject getKeyGeneratorObject( IModel<?> model )  throws ServiceException {
  129.        
  130.         try{

  131.             if(model.equals(TransazioneExport.model())){
  132.                 return new org.openspcoop2.utils.jdbc.CustomKeyGeneratorObject("transazioni_export","id","seq_transazioni_export","transazioni_export_init_seq");
  133.             }
  134.            
  135.             else{
  136.                 throw new ServiceException("Model ["+model.toString()+"] not supported by getKeyGeneratorObject: "+this.getClass().getName());
  137.             }

  138.         }catch(Exception e){
  139.             throw new ServiceException("Model ["+model.toString()+"] occurs error in getKeyGeneratorObject: "+e.getMessage(),e);
  140.         }
  141.        
  142.     }

  143. }