GestoreRepositoryFactory.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.protocol.engine.driver.repository;

  21. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  22. import org.openspcoop2.protocol.sdk.ProtocolException;
  23. import org.openspcoop2.utils.TipiDatabase;

  24. /**
  25.  * Factory degli oggetti SQLQueryObject
  26.  *
  27.  *
  28.  * @author Poli Andrea (apoli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */

  32. public class GestoreRepositoryFactory {

  33.     public static IGestoreRepository createRepositoryBuste(TipiDatabase tipoDatabase) throws ProtocolException {
  34.         return createRepositoryBuste(tipoDatabase.toString());
  35.     }
  36.     public static IGestoreRepository createRepositoryBuste(String tipoDatabase) throws ProtocolException {
  37.         IGestoreRepository repositoryBuste = null;
  38.        
  39.         if (TipiDatabase.POSTGRESQL.equals(tipoDatabase)) {
  40.             repositoryBuste = new GestoreRepositoryBytewise();
  41.         }else if (TipiDatabase.MYSQL.equals(tipoDatabase)) {
  42.             repositoryBuste = new GestoreRepositoryBytewise();
  43.         }else if (TipiDatabase.ORACLE.equals(tipoDatabase)) {
  44.             repositoryBuste = new GestoreRepositoryOracle();
  45.         }else if (TipiDatabase.HSQL.equals(tipoDatabase)) {
  46.             repositoryBuste = new GestoreRepositoryBitOrAndFunction();
  47.         }else if (TipiDatabase.SQLSERVER.equals(tipoDatabase)) {
  48.             repositoryBuste = new GestoreRepositoryBytewise();
  49.         }else if (TipiDatabase.DB2.equals(tipoDatabase)) {
  50.             repositoryBuste = new GestoreRepositoryBitOrAndFunction();
  51.         }else{
  52.             throw new ProtocolException("Tipo database non gestito ["+tipoDatabase+"]");
  53.         }
  54.    
  55.         return repositoryBuste;
  56.     }
  57.    
  58.     public static String getTipoRepositoryBuste(TipiDatabase tipoDatabase) throws ProtocolException {
  59.         return getTipoRepositoryBuste(tipoDatabase.toString());
  60.     }
  61.     public static String getTipoRepositoryBuste(String tipoDatabase) throws ProtocolException {
  62.         String repositoryBuste = null;
  63.        
  64.         if (TipiDatabase.POSTGRESQL.equals(tipoDatabase)) {
  65.             repositoryBuste = CostantiConfigurazione.REPOSITORY_BUSTE_BYTEWISE;
  66.         }else if (TipiDatabase.MYSQL.equals(tipoDatabase)) {
  67.             repositoryBuste = CostantiConfigurazione.REPOSITORY_BUSTE_BYTEWISE;
  68.         }else if (TipiDatabase.ORACLE.equals(tipoDatabase)) {
  69.             repositoryBuste = CostantiConfigurazione.REPOSITORY_BUSTE_BYTEWISE_ORACLE;
  70.         }else if (TipiDatabase.HSQL.equals(tipoDatabase)) {
  71.             repositoryBuste = CostantiConfigurazione.REPOSITORY_BUSTE_BIT_OR_AND_FUNCTION;
  72.         }else if (TipiDatabase.SQLSERVER.equals(tipoDatabase)) {
  73.             repositoryBuste = CostantiConfigurazione.REPOSITORY_BUSTE_BYTEWISE;
  74.         }else if (TipiDatabase.DB2.equals(tipoDatabase)) {
  75.             repositoryBuste = CostantiConfigurazione.REPOSITORY_BUSTE_BIT_OR_AND_FUNCTION;
  76.         }else{
  77.             throw new ProtocolException("Tipo database non gestito ["+tipoDatabase+"]");
  78.         }

  79.         return repositoryBuste;
  80.     }

  81. }