view flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java @ 4573:b87073a05f9d

flys-client: Patch to render combobox options as clickable links. The way of passing data arguments to the links and further to the Artifact feeding service is somewhat hacked and should be refactored (later...).
author Christian Lins <christian.lins@intevation.de>
date Tue, 27 Nov 2012 12:50:10 +0100
parents f63b39799d2d
children 91630b503ca8
line wrap: on
line source
package de.intevation.flys.backend;

import de.intevation.artifacts.common.utils.Config;

import de.intevation.flys.model.Annotation;
import de.intevation.flys.model.AnnotationType;
import de.intevation.flys.model.Attribute;
import de.intevation.flys.model.BedHeightEpoch;
import de.intevation.flys.model.BedHeightEpochValue;
import de.intevation.flys.model.BedHeightSingle;
import de.intevation.flys.model.BedHeightSingleValue;
import de.intevation.flys.model.BedHeightType;
import de.intevation.flys.model.Building;
import de.intevation.flys.model.Catchment;
import de.intevation.flys.model.CrossSection;
import de.intevation.flys.model.CrossSectionLine;
import de.intevation.flys.model.CrossSectionPoint;
import de.intevation.flys.model.CrossSectionTrack;
import de.intevation.flys.model.DGM;
import de.intevation.flys.model.Depth;
import de.intevation.flys.model.DischargeTable;
import de.intevation.flys.model.DischargeTableValue;
import de.intevation.flys.model.DischargeZone;
import de.intevation.flys.model.Edge;
import de.intevation.flys.model.ElevationModel;
import de.intevation.flys.model.Fixpoint;
import de.intevation.flys.model.Floodmaps;
import de.intevation.flys.model.Floodplain;
import de.intevation.flys.model.FlowVelocityMeasurement;
import de.intevation.flys.model.FlowVelocityMeasurementValue;
import de.intevation.flys.model.FlowVelocityModel;
import de.intevation.flys.model.FlowVelocityModelValue;
import de.intevation.flys.model.Gauge;
import de.intevation.flys.model.GaugeLocation;
import de.intevation.flys.model.GrainFraction;
import de.intevation.flys.model.HYK;
import de.intevation.flys.model.HYKEntry;
import de.intevation.flys.model.HYKFlowZone;
import de.intevation.flys.model.HYKFlowZoneType;
import de.intevation.flys.model.HYKFormation;
import de.intevation.flys.model.Hws;
import de.intevation.flys.model.HydrBoundary;
import de.intevation.flys.model.HydrBoundaryPoly;
import de.intevation.flys.model.Line;
import de.intevation.flys.model.LocationSystem;
import de.intevation.flys.model.MainValue;
import de.intevation.flys.model.MainValueType;
import de.intevation.flys.model.MeasurementStation;
import de.intevation.flys.model.MorphologicalWidth;
import de.intevation.flys.model.MorphologicalWidthValue;
import de.intevation.flys.model.NamedMainValue;
import de.intevation.flys.model.Position;
import de.intevation.flys.model.Range;
import de.intevation.flys.model.River;
import de.intevation.flys.model.RiverAxis;
import de.intevation.flys.model.RiverAxisKm;
import de.intevation.flys.model.SQRelation;
import de.intevation.flys.model.SQRelationValue;
import de.intevation.flys.model.SedimentDensity;
import de.intevation.flys.model.SedimentDensityValue;
import de.intevation.flys.model.SedimentYield;
import de.intevation.flys.model.SedimentYieldValue;
import de.intevation.flys.model.TimeInterval;
import de.intevation.flys.model.Unit;
import de.intevation.flys.model.Waterlevel;
import de.intevation.flys.model.WaterlevelDifference;
import de.intevation.flys.model.WaterlevelDifferenceColumn;
import de.intevation.flys.model.WaterlevelDifferenceValue;
import de.intevation.flys.model.WaterlevelQRange;
import de.intevation.flys.model.WaterlevelValue;
import de.intevation.flys.model.Wst;
import de.intevation.flys.model.WstColumn;
import de.intevation.flys.model.WstColumnQRange;
import de.intevation.flys.model.WstColumnValue;
import de.intevation.flys.model.WstQRange;

public class FLYSCredentials
extends      Credentials
{
    public static final String XPATH_USER =
        "/artifact-database/backend-database/user/text()";

    public static final String XPATH_PASSWORD =
        "/artifact-database/backend-database/password/text()";

    public static final String XPATH_DIALECT =
        "/artifact-database/backend-database/dialect/text()";

    public static final String XPATH_DRIVER =
        "/artifact-database/backend-database/driver/text()";

    public static final String XPATH_URL =
        "/artifact-database/backend-database/url/text()";

    public static final String DEFAULT_USER =
        System.getProperty("flys.backend.user", "flys");

    public static final String DEFAULT_PASSWORD =
        System.getProperty("flys.backend.password", "flys");

    public static final String DEFAULT_DIALECT =
        System.getProperty(
            "flys.backend.dialect",
            "org.hibernate.dialect.PostgreSQLDialect");

    public static final String DEFAULT_DRIVER =
        System.getProperty(
            "flys.backend.driver",
            "org.postgresql.Driver");

    public static final String DEFAULT_URL =
        System.getProperty(
            "flys.backend.url",
            "jdbc:postgresql://localhost:5432/flys");

    public static final Class [] CLASSES = {
        Annotation.class,
        AnnotationType.class,
        Attribute.class,
        BedHeightEpoch.class,
        BedHeightEpochValue.class,
        BedHeightSingle.class,
        BedHeightSingleValue.class,
        BedHeightType.class,
        Building.class,
        Catchment.class,
        CrossSection.class,
        CrossSectionLine.class,
        CrossSectionPoint.class,
        CrossSectionTrack.class,
        Depth.class,
        DGM.class,
        DischargeTable.class,
        DischargeTableValue.class,
        DischargeZone.class,
        Edge.class,
        ElevationModel.class,
        Fixpoint.class,
        Floodplain.class,
        Floodmaps.class,
        FlowVelocityMeasurement.class,
        FlowVelocityMeasurementValue.class,
        FlowVelocityModel.class,
        FlowVelocityModelValue.class,
        Gauge.class,
        GaugeLocation.class,
        GrainFraction.class,
        Hws.class,
        HydrBoundary.class,
        HydrBoundaryPoly.class,
        HYK.class,
        HYKEntry.class,
        HYKFormation.class,
        HYKFlowZoneType.class,
        HYKFlowZone.class,
        Line.class,
        LocationSystem.class,
        MainValueType.class,
        MeasurementStation.class,
        MorphologicalWidth.class,
        MorphologicalWidthValue.class,
        NamedMainValue.class,
        MainValue.class,
        Position.class,
        Range.class,
        River.class,
        RiverAxis.class,
        RiverAxisKm.class,
        SedimentDensity.class,
        SedimentDensityValue.class,
        SedimentYield.class,
        SedimentYieldValue.class,
        SQRelation.class,
        SQRelationValue.class,
        TimeInterval.class,
        Unit.class,
        Waterlevel.class,
        WaterlevelDifference.class,
        WaterlevelDifferenceColumn.class,
        WaterlevelDifferenceValue.class,
        WaterlevelQRange.class,
        WaterlevelValue.class,
        WstColumn.class,
        WstColumnQRange.class,
        WstColumnValue.class,
        Wst.class,
        WstQRange.class
    };

    public FLYSCredentials() {
    }

    public FLYSCredentials(
        String user,
        String password,
        String dialect,
        String driver,
        String url
    ) {
        super(user, password, dialect, driver, url, CLASSES);
    }

    private static Credentials instance;

    public static synchronized Credentials getInstance() {
        if (instance == null) {
            String user =
                Config.getStringXPath(XPATH_USER, DEFAULT_USER);
            String password =
                Config.getStringXPath(XPATH_PASSWORD, DEFAULT_PASSWORD);
            String dialect =
                Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT);
            String driver =
                Config.getStringXPath(XPATH_DRIVER, DEFAULT_DRIVER);
            String url =
                Config.getStringXPath(XPATH_URL, DEFAULT_URL);

            instance = new FLYSCredentials(
                user, password, dialect, driver, url);
        }
        return instance;
    }

    public static Credentials getDefault() {
        return new FLYSCredentials(
            DEFAULT_USER,
            DEFAULT_PASSWORD,
            DEFAULT_DIALECT,
            DEFAULT_DRIVER,
            DEFAULT_URL);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org