AccordoServizioParteComuneSinteticoCore.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.web.ctrlstat.servlet.apc;

  21. import java.sql.Connection;
  22. import java.util.List;

  23. import org.openspcoop2.core.commons.ISearch;
  24. import org.openspcoop2.core.id.IDAccordo;
  25. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  26. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  27. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  28. import org.openspcoop2.core.registry.driver.DriverRegistroServiziNotFound;
  29. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  30. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationDB;
  31. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationException;
  32. import org.openspcoop2.web.ctrlstat.registro.GestoreRegistroServiziRemoto;

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

  41.     protected AccordoServizioParteComuneSinteticoCore(ControlStationCore core) throws DriverControlStationException {
  42.         super(core);
  43.     }
  44.    
  45.     public AccordoServizioParteComuneSintetico getAccordoServizioSintetico(IDAccordo idAccordo) throws DriverRegistroServiziNotFound, DriverRegistroServiziException {
  46.         Connection con = null;
  47.         String nomeMetodo = "getAccordoServizioSintetico";
  48.         DriverControlStationDB driver = null;

  49.         try {
  50.             if(this.isRegistroServiziLocale()){
  51.                 // prendo una connessione
  52.                 con = ControlStationCore.dbM.getConnection();
  53.                 // istanzio il driver
  54.                 driver = new DriverControlStationDB(con, null, this.tipoDB);

  55.                 return driver.getDriverRegistroServiziDB().getAccordoServizioParteComuneSintetico(idAccordo);
  56.             }
  57.             else{
  58.                 AccordoServizioParteComune aspc = GestoreRegistroServiziRemoto.getDriverRegistroServizi(ControlStationCore.log).getAccordoServizioParteComune(idAccordo);
  59.                 return new AccordoServizioParteComuneSintetico(aspc);
  60.             }

  61.         } catch (DriverRegistroServiziNotFound de) {
  62.             ControlStationCore.logDebug(getPrefixError(nomeMetodo,  de),de);
  63.             throw de;
  64.         } catch (Exception e) {
  65.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  66.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  67.         } finally {
  68.             ControlStationCore.dbM.releaseConnection(con);
  69.         }

  70.     }
  71.    
  72.     public List<AccordoServizioParteComuneSintetico> accordiServizioParteComuneList(String superuser, ISearch ricerca) throws DriverRegistroServiziException {
  73.         Connection con = null;
  74.         String nomeMetodo = "accordiServizioParteComuneList";
  75.         DriverControlStationDB driver = null;

  76.         try {
  77.             // prendo una connessione
  78.             con = ControlStationCore.dbM.getConnection();
  79.             // istanzio il driver
  80.             driver = new DriverControlStationDB(con, null, this.tipoDB);

  81.             return driver.getDriverRegistroServiziDB().accordiServizioParteComuneList(superuser, ricerca);
  82.         } catch (DriverRegistroServiziException e) {
  83.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  84.             throw e;
  85.         } catch (Exception e) {
  86.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  87.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e), e);
  88.         } finally {
  89.             ControlStationCore.dbM.releaseConnection(con);
  90.         }
  91.     }
  92.     public List<AccordoServizioParteComuneSintetico> accordiServizioCompostiList(String superuser, ISearch ricerca) throws DriverRegistroServiziException {
  93.         Connection con = null;
  94.         String nomeMetodo = "accordiServizioCompostiList";
  95.         DriverControlStationDB driver = null;

  96.         try {
  97.             // prendo una connessione
  98.             con = ControlStationCore.dbM.getConnection();
  99.             // istanzio il driver
  100.             driver = new DriverControlStationDB(con, null, this.tipoDB);

  101.             return driver.getDriverRegistroServiziDB().accordiServizioCompostiList(superuser, ricerca);
  102.         } catch (DriverRegistroServiziException e) {
  103.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  104.             throw e;
  105.         } catch (Exception e) {
  106.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  107.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e), e);
  108.         } finally {
  109.             ControlStationCore.dbM.releaseConnection(con);
  110.         }
  111.     }
  112.    
  113.     public AccordoServizioParteComuneSintetico getAccordoServizioSintetico(long id) throws DriverRegistroServiziNotFound, DriverRegistroServiziException {
  114.         Connection con = null;
  115.         String nomeMetodo = "getAccordoServizioSintetico";
  116.         DriverControlStationDB driver = null;

  117.         try {
  118.             // prendo una connessione
  119.             con = ControlStationCore.dbM.getConnection();
  120.             // istanzio il driver
  121.             driver = new DriverControlStationDB(con, null, this.tipoDB);

  122.             return driver.getDriverRegistroServiziDB().getAccordoServizioParteComuneSintetico(id);

  123.         } catch (DriverRegistroServiziNotFound de) {
  124.             ControlStationCore.logDebug(getPrefixError(nomeMetodo,  de),de);
  125.             throw de;
  126.         } catch (Exception e) {
  127.             ControlStationCore.logError(getPrefixError(nomeMetodo,  e), e);
  128.             throw new DriverRegistroServiziException(getPrefixError(nomeMetodo,  e),e);
  129.         } finally {
  130.             ControlStationCore.dbM.releaseConnection(con);
  131.         }

  132.     }
  133. }