StatistichePdndTracingFetch.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.statistiche.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.constants.CostantiDB;
  30. import org.openspcoop2.core.statistiche.StatistichePdndTracing;


  31. /**    
  32.  * StatistichePdndTracingFetch
  33.  *
  34.  * @author Poli Andrea (poli@link.it)
  35.  * @author Tommaso Burlon (tommaso.burlon@link.it)
  36.  * @author $Author$
  37.  * @version $Rev$, $Date$
  38.  */
  39. public class StatistichePdndTracingFetch extends AbstractJDBCFetch {

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

  46.             if(model.equals(StatistichePdndTracing.model())){
  47.                 StatistichePdndTracing object = new StatistichePdndTracing();
  48.                 setParameter(object, "setId", Long.class,
  49.                     jdbcParameterUtilities.readParameter(rs, "id", Long.class));
  50.                 setParameter(object, "setDataTracciamento", StatistichePdndTracing.model().DATA_TRACCIAMENTO.getFieldType(),
  51.                     jdbcParameterUtilities.readParameter(rs, "data_tracciamento", StatistichePdndTracing.model().DATA_TRACCIAMENTO.getFieldType()));
  52.                 setParameter(object, "setDataRegistrazione", StatistichePdndTracing.model().DATA_REGISTRAZIONE.getFieldType(),
  53.                     jdbcParameterUtilities.readParameter(rs, "data_registrazione", StatistichePdndTracing.model().DATA_REGISTRAZIONE.getFieldType()));
  54.                 setParameter(object, "setDataPubblicazione", StatistichePdndTracing.model().DATA_PUBBLICAZIONE.getFieldType(),
  55.                     jdbcParameterUtilities.readParameter(rs, "data_pubblicazione", StatistichePdndTracing.model().DATA_PUBBLICAZIONE.getFieldType()));
  56.                 setParameter(object, "setPddCodice", StatistichePdndTracing.model().PDD_CODICE.getFieldType(),
  57.                     jdbcParameterUtilities.readParameter(rs, "pdd_codice", StatistichePdndTracing.model().PDD_CODICE.getFieldType()));
  58.                 setParameter(object, "setCsv", StatistichePdndTracing.model().CSV.getFieldType(),
  59.                     jdbcParameterUtilities.readParameter(rs, "csv", StatistichePdndTracing.model().CSV.getFieldType()));
  60.                 setParameter(object, "setMethodRawEnumValue", String.class,
  61.                     jdbcParameterUtilities.readParameter(rs, "method", StatistichePdndTracing.model().METHOD.getFieldType())+"");
  62.                 setParameter(object, "setStatoPdndRawEnumValue", String.class,
  63.                     jdbcParameterUtilities.readParameter(rs, "stato_pdnd", StatistichePdndTracing.model().STATO_PDND.getFieldType())+"");
  64.                 setParameter(object, "setTentativiPubblicazione", StatistichePdndTracing.model().TENTATIVI_PUBBLICAZIONE.getFieldType(),
  65.                     jdbcParameterUtilities.readParameter(rs, "tentativi_pubblicazione", StatistichePdndTracing.model().TENTATIVI_PUBBLICAZIONE.getFieldType()));
  66.                 setParameter(object, "setForcePublish", StatistichePdndTracing.model().FORCE_PUBLISH.getFieldType(),
  67.                     jdbcParameterUtilities.readParameter(rs, "force_publish", StatistichePdndTracing.model().FORCE_PUBLISH.getFieldType()));
  68.                 setParameter(object, "setStatoRawEnumValue", String.class,
  69.                     jdbcParameterUtilities.readParameter(rs, "stato", StatistichePdndTracing.model().STATO.getFieldType())+"");
  70.                 setParameter(object, "setTracingId", StatistichePdndTracing.model().TRACING_ID.getFieldType(),
  71.                     jdbcParameterUtilities.readParameter(rs, "tracing_id", StatistichePdndTracing.model().TRACING_ID.getFieldType()));
  72.                 setParameter(object, "setErrorDetails", StatistichePdndTracing.model().ERROR_DETAILS.getFieldType(),
  73.                     jdbcParameterUtilities.readParameter(rs, "error_details", StatistichePdndTracing.model().ERROR_DETAILS.getFieldType()));
  74.                 setParameter(object, "setHistory", StatistichePdndTracing.model().HISTORY.getFieldType(),
  75.                     jdbcParameterUtilities.readParameter(rs, "history", StatistichePdndTracing.model().HISTORY.getFieldType()));
  76.                 return object;
  77.             }
  78.            
  79.             else{
  80.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  81.             }  
  82.                    
  83.         }catch(Exception e){
  84.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  85.         }
  86.        
  87.     }
  88.    
  89.     @Override
  90.     public Object fetch(TipiDatabase tipoDatabase, IModel<?> model , Map<String,Object> map ) throws ServiceException {
  91.        
  92.         try{

  93.             if(model.equals(StatistichePdndTracing.model())){
  94.                 StatistichePdndTracing object = new StatistichePdndTracing();
  95.                 setParameter(object, "setId", Long.class,
  96.                     this.getObjectFromMap(map,"id"));
  97.                 setParameter(object, "setDataTracciamento", StatistichePdndTracing.model().DATA_TRACCIAMENTO.getFieldType(),
  98.                     this.getObjectFromMap(map,"data-tracciamento"));
  99.                 setParameter(object, "setDataRegistrazione", StatistichePdndTracing.model().DATA_REGISTRAZIONE.getFieldType(),
  100.                     this.getObjectFromMap(map,"data-registrazione"));
  101.                 setParameter(object, "setDataPubblicazione", StatistichePdndTracing.model().DATA_PUBBLICAZIONE.getFieldType(),
  102.                     this.getObjectFromMap(map,"data-pubblicazione"));
  103.                 setParameter(object, "setPddCodice", StatistichePdndTracing.model().PDD_CODICE.getFieldType(),
  104.                     this.getObjectFromMap(map,"pdd-codice"));
  105.                 setParameter(object, "setCsv", StatistichePdndTracing.model().CSV.getFieldType(),
  106.                     this.getObjectFromMap(map,"csv"));
  107.                 setParameter(object, "setMethodRawEnumValue", String.class,
  108.                     this.getObjectFromMap(map,"method"));
  109.                 setParameter(object, "setStatoPdndRawEnumValue", String.class,
  110.                     this.getObjectFromMap(map,"stato-pdnd"));
  111.                 setParameter(object, "setTentativiPubblicazione", StatistichePdndTracing.model().TENTATIVI_PUBBLICAZIONE.getFieldType(),
  112.                     this.getObjectFromMap(map,"tentativi-pubblicazione"));
  113.                 setParameter(object, "setForcePublish", StatistichePdndTracing.model().FORCE_PUBLISH.getFieldType(),
  114.                     this.getObjectFromMap(map,"force-publish"));
  115.                 setParameter(object, "setStatoRawEnumValue", String.class,
  116.                     this.getObjectFromMap(map,"stato"));
  117.                 setParameter(object, "setTracingId", StatistichePdndTracing.model().TRACING_ID.getFieldType(),
  118.                     this.getObjectFromMap(map,"tracing-id"));
  119.                 setParameter(object, "setErrorDetails", StatistichePdndTracing.model().ERROR_DETAILS.getFieldType(),
  120.                     this.getObjectFromMap(map,"error-details"));
  121.                 setParameter(object, "setHistory", StatistichePdndTracing.model().HISTORY.getFieldType(),
  122.                     this.getObjectFromMap(map,"history"));
  123.                 return object;
  124.             }
  125.            
  126.             else{
  127.                 throw new ServiceException("Model ["+model.toString()+"] not supported by fetch: "+this.getClass().getName());
  128.             }  
  129.                    
  130.         }catch(Exception e){
  131.             throw new ServiceException("Model ["+model.toString()+"] occurs error in fetch: "+e.getMessage(),e);
  132.         }
  133.        
  134.     }
  135.    
  136.    
  137.     @Override
  138.     public IKeyGeneratorObject getKeyGeneratorObject( IModel<?> model )  throws ServiceException {
  139.        
  140.         try{

  141.             if(model.equals(StatistichePdndTracing.model())){
  142.                 return new org.openspcoop2.utils.jdbc.CustomKeyGeneratorObject(CostantiDB.STATISTICHE_PDND_TRACING,"id","seq_"+CostantiDB.STATISTICHE_PDND_TRACING,CostantiDB.STATISTICHE_PDND_TRACING+"_init_seq");
  143.             }
  144.            
  145.             else{
  146.                 throw new ServiceException("Model ["+model.toString()+"] not supported by getKeyGeneratorObject: "+this.getClass().getName());
  147.             }

  148.         }catch(Exception e){
  149.             throw new ServiceException("Model ["+model.toString()+"] occurs error in getKeyGeneratorObject: "+e.getMessage(),e);
  150.         }
  151.        
  152.     }

  153. }