All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.ird.observe.services.ObserveDataSourceConfigurationMainFactory Maven / Gradle / Ivy

The newest version!
package fr.ird.observe.services;

/*
 * #%L
 * ObServe Toolkit :: Common Service
 * %%
 * Copyright (C) 2017 - 2020 IRD, Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import fr.ird.observe.services.configuration.rest.ObserveDataSourceConfigurationRest;
import fr.ird.observe.services.configuration.topia.ObserveDataSourceConfigurationTopiaH2;
import fr.ird.observe.services.configuration.topia.ObserveDataSourceConfigurationTopiaPG;
import io.ultreia.java4all.application.context.spi.GenerateApplicationComponent;
import org.nuiton.version.Version;

import java.io.File;
import java.net.URL;

/**
 * Created on 30/08/15.
 *
 * @author Tony Chemit - [email protected]
 */
@GenerateApplicationComponent(name = "ObServe Data source configuration factory")
public class ObserveDataSourceConfigurationMainFactory {

    public ObserveDataSourceConfigurationTopiaPG createObserveDataSourceConfigurationTopiaPG(String label,
                                                                                             String jdbcUrl,
                                                                                             String username,
                                                                                             char[] password,
                                                                                             boolean useSsl,
                                                                                             boolean showMigrationProgression,
                                                                                             boolean showMigrationSql,
                                                                                             Version dbVersion) {

        ObserveDataSourceConfigurationTopiaPG result = new ObserveDataSourceConfigurationTopiaPG();
        result.setLabel(label);
        result.setJdbcUrl(jdbcUrl);
        result.setUsername(username);
        result.setPassword(password);
        result.setUseSsl(useSsl);
        result.setShowMigrationProgression(showMigrationProgression);
        result.setShowMigrationSql(showMigrationSql);
        result.setModelVersion(dbVersion);

        return result;

    }

    public ObserveDataSourceConfigurationTopiaH2 createObserveDataSourceConfigurationTopiaH2(String label,
                                                                                             File directory,
                                                                                             String databaseName,
                                                                                             String username,
                                                                                             char[] password,
                                                                                             boolean showMigrationProgression,
                                                                                             boolean showMigrationSql,
                                                                                             Version dbVersion) {

        ObserveDataSourceConfigurationTopiaH2 result = new ObserveDataSourceConfigurationTopiaH2();
        result.setLabel(label);
        result.setDbName(databaseName);
        result.setUsername(username);
        result.setPassword(password);
        result.setDirectory(directory);
        result.setShowMigrationProgression(showMigrationProgression);
        result.setShowMigrationSql(showMigrationSql);
        result.setModelVersion(dbVersion);

        return result;

    }

    public ObserveDataSourceConfigurationRest createObserveDataSourceConfigurationRest(String label,
                                                                                       URL serverUrl,
                                                                                       String login,
                                                                                       char[] password,
                                                                                       String databaseName,
                                                                                       Version dbVersion) {

        ObserveDataSourceConfigurationRest result = new ObserveDataSourceConfigurationRest();
        result.setLabel(label);
        result.setServerUrl(serverUrl);
        result.setLogin(login);
        result.setPassword(password);
        result.setOptionalDatabaseName(databaseName);
        result.setModelVersion(dbVersion);

        return result;

    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy