DAOConsolePropertiesFactory.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.core;

  21. import java.util.Properties;

  22. import org.openspcoop2.core.commons.dao.DAOFactoryProperties;
  23. import org.openspcoop2.generic_project.beans.IProjectInfo;
  24. import org.openspcoop2.web.ctrlstat.config.DatasourceProperties;
  25. import org.slf4j.Logger;

  26. /**
  27.  * DAOConsolePropertiesFactory
  28.  *
  29.  * @author Andrea Poli (apoli@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  *
  33.  */
  34. public class DAOConsolePropertiesFactory extends DAOFactoryProperties {

  35.     public DAOConsolePropertiesFactory(Logger log) throws Exception {
  36.         super(log);
  37.     }

  38.     private boolean isDiag(IProjectInfo tipoDAO) {
  39.         return (org.openspcoop2.core.tracciamento.utils.ProjectInfo.getInstance().getProjectName().equals(tipoDAO.getProjectName())
  40.                 ||
  41.             org.openspcoop2.core.statistiche.utils.ProjectInfo.getInstance().getProjectName().equals(tipoDAO.getProjectName())
  42.                 ||
  43.             org.openspcoop2.core.transazioni.utils.ProjectInfo.getInstance().getProjectName().equals(tipoDAO.getProjectName())
  44.                 ||
  45.             org.openspcoop2.core.diagnostica.utils.ProjectInfo.getInstance().getProjectName().equals(tipoDAO.getProjectName()));
  46.     }
  47.    
  48.     @Override
  49.     public String getTipoDatabase(IProjectInfo tipoDAO) throws Exception {
  50.         if(isDiag(tipoDAO)) {
  51.             return super.getTipoDatabase(tipoDAO);
  52.         }
  53.         else {
  54.             return DatasourceProperties.getInstance().getTipoDatabase();
  55.         }
  56.     }
  57.    
  58.     @Override
  59.     public String getTipoAccessoDatabase(IProjectInfo tipoDAO) throws Exception {
  60.         if(isDiag(tipoDAO)) {
  61.             return super.getTipoAccessoDatabase(tipoDAO);
  62.         }
  63.         else {
  64.             return DAOFactoryProperties.PROP_TIPO_VALUE_DATASOURCE;
  65.         }
  66.     }
  67.    
  68.     @Override
  69.     public String getDatasourceJNDIName(IProjectInfo tipoDAO) throws Exception {
  70.         if(isDiag(tipoDAO)) {
  71.             return super.getDatasourceJNDIName(tipoDAO);
  72.         }
  73.         else {
  74.             return DatasourceProperties.getInstance().getDataSource();
  75.         }
  76.     }
  77.    
  78.     @Override
  79.     public Properties getDatasourceJNDIContext(IProjectInfo tipoDAO) throws Exception {
  80.         if(isDiag(tipoDAO)) {
  81.             return super.getDatasourceJNDIContext(tipoDAO);
  82.         }
  83.         else {
  84.             return DatasourceProperties.getInstance().getDataSourceContext();
  85.         }
  86.     }
  87. }