sascha@3333: package de.intevation.flys.backend; sascha@3333: sascha@3333: import de.intevation.artifacts.common.utils.Config; sascha@3333: sascha@3333: import de.intevation.flys.model.Annotation; sascha@3333: import de.intevation.flys.model.AnnotationType; sascha@3333: import de.intevation.flys.model.Attribute; aheinecke@5146: import de.intevation.flys.model.AxisKind; sascha@3333: import de.intevation.flys.model.BedHeightEpoch; sascha@3333: import de.intevation.flys.model.BedHeightEpochValue; sascha@3333: import de.intevation.flys.model.BedHeightSingle; sascha@3333: import de.intevation.flys.model.BedHeightSingleValue; sascha@3333: import de.intevation.flys.model.BedHeightType; sascha@3333: import de.intevation.flys.model.Building; aheinecke@5063: import de.intevation.flys.model.BoundaryKind; sascha@3333: import de.intevation.flys.model.CrossSection; sascha@3333: import de.intevation.flys.model.CrossSectionLine; sascha@3333: import de.intevation.flys.model.CrossSectionPoint; sascha@3333: import de.intevation.flys.model.CrossSectionTrack; sascha@3333: import de.intevation.flys.model.DGM; sascha@3333: import de.intevation.flys.model.Depth; sascha@3333: import de.intevation.flys.model.DischargeTable; sascha@3333: import de.intevation.flys.model.DischargeTableValue; sascha@3333: import de.intevation.flys.model.DischargeZone; sascha@3333: import de.intevation.flys.model.Edge; sascha@3333: import de.intevation.flys.model.ElevationModel; aheinecke@5063: import de.intevation.flys.model.FedState; sascha@3333: import de.intevation.flys.model.Fixpoint; sascha@3333: import de.intevation.flys.model.Floodmaps; sascha@3333: import de.intevation.flys.model.Floodplain; sascha@3333: import de.intevation.flys.model.FlowVelocityMeasurement; sascha@3333: import de.intevation.flys.model.FlowVelocityMeasurementValue; sascha@3333: import de.intevation.flys.model.FlowVelocityModel; sascha@3333: import de.intevation.flys.model.FlowVelocityModelValue; sascha@3333: import de.intevation.flys.model.Gauge; sascha@3333: import de.intevation.flys.model.GaugeLocation; sascha@3333: import de.intevation.flys.model.GrainFraction; aheinecke@5063: import de.intevation.flys.model.HWSKind; aheinecke@5063: import de.intevation.flys.model.HWSLine; sascha@3333: import de.intevation.flys.model.HYK; sascha@3333: import de.intevation.flys.model.HYKEntry; sascha@3333: import de.intevation.flys.model.HYKFlowZone; sascha@3333: import de.intevation.flys.model.HYKFlowZoneType; sascha@3333: import de.intevation.flys.model.HYKFormation; sascha@3333: import de.intevation.flys.model.HydrBoundary; sascha@3333: import de.intevation.flys.model.HydrBoundaryPoly; sascha@3333: import de.intevation.flys.model.LocationSystem; sascha@3333: import de.intevation.flys.model.MainValue; sascha@3333: import de.intevation.flys.model.MainValueType; ingo@4193: import de.intevation.flys.model.MeasurementStation; sascha@3333: import de.intevation.flys.model.MorphologicalWidth; sascha@3333: import de.intevation.flys.model.MorphologicalWidthValue; sascha@3333: import de.intevation.flys.model.NamedMainValue; sascha@3333: import de.intevation.flys.model.Position; sascha@3333: import de.intevation.flys.model.Range; sascha@3333: import de.intevation.flys.model.River; sascha@3333: import de.intevation.flys.model.RiverAxis; sascha@3333: import de.intevation.flys.model.RiverAxisKm; sascha@3333: import de.intevation.flys.model.SQRelation; sascha@3333: import de.intevation.flys.model.SQRelationValue; aheinecke@5063: import de.intevation.flys.model.SectieKind; aheinecke@5063: import de.intevation.flys.model.SobekKind; sascha@3333: import de.intevation.flys.model.SedimentDensity; sascha@3333: import de.intevation.flys.model.SedimentDensityValue; sascha@3333: import de.intevation.flys.model.SedimentYield; sascha@3333: import de.intevation.flys.model.SedimentYieldValue; sascha@3333: import de.intevation.flys.model.TimeInterval; sascha@3333: import de.intevation.flys.model.Unit; sascha@3333: import de.intevation.flys.model.Waterlevel; sascha@3333: import de.intevation.flys.model.WaterlevelDifference; sascha@3333: import de.intevation.flys.model.WaterlevelDifferenceColumn; sascha@3333: import de.intevation.flys.model.WaterlevelDifferenceValue; sascha@3333: import de.intevation.flys.model.WaterlevelQRange; sascha@3333: import de.intevation.flys.model.WaterlevelValue; sascha@3333: import de.intevation.flys.model.Wst; sascha@3333: import de.intevation.flys.model.WstColumn; sascha@3333: import de.intevation.flys.model.WstColumnQRange; sascha@3333: import de.intevation.flys.model.WstColumnValue; sascha@3333: import de.intevation.flys.model.WstQRange; sascha@3333: sascha@3333: public class FLYSCredentials sascha@3333: extends Credentials sascha@3333: { sascha@3333: public static final String XPATH_USER = sascha@3333: "/artifact-database/backend-database/user/text()"; sascha@3333: sascha@3333: public static final String XPATH_PASSWORD = sascha@3333: "/artifact-database/backend-database/password/text()"; sascha@3333: sascha@3333: public static final String XPATH_DIALECT = sascha@3333: "/artifact-database/backend-database/dialect/text()"; sascha@3333: sascha@3333: public static final String XPATH_DRIVER = sascha@3333: "/artifact-database/backend-database/driver/text()"; sascha@3333: sascha@3333: public static final String XPATH_URL = sascha@3333: "/artifact-database/backend-database/url/text()"; sascha@3333: teichmann@5193: public static final String XPATH_CONNECTION_INIT_SQLS = teichmann@5193: "/artifact-database/backend-database/connection-init-sqls/text()"; teichmann@5193: sascha@3333: public static final String DEFAULT_USER = sascha@3333: System.getProperty("flys.backend.user", "flys"); sascha@3333: sascha@3333: public static final String DEFAULT_PASSWORD = sascha@3333: System.getProperty("flys.backend.password", "flys"); sascha@3333: sascha@3333: public static final String DEFAULT_DIALECT = sascha@3333: System.getProperty( sascha@3333: "flys.backend.dialect", sascha@3333: "org.hibernate.dialect.PostgreSQLDialect"); sascha@3333: sascha@3333: public static final String DEFAULT_DRIVER = sascha@3333: System.getProperty( sascha@3333: "flys.backend.driver", sascha@3333: "org.postgresql.Driver"); sascha@3333: sascha@3333: public static final String DEFAULT_URL = sascha@3333: System.getProperty( sascha@3333: "flys.backend.url", sascha@3333: "jdbc:postgresql://localhost:5432/flys"); sascha@3333: teichmann@5193: public static final String DEFAULT_CONNECTION_INIT_SQLS = teichmann@5193: System.getProperty( teichmann@5193: "flys.backend.connection.init.sqls"); teichmann@5193: sascha@3333: public static final Class [] CLASSES = { sascha@3333: Annotation.class, sascha@3333: AnnotationType.class, sascha@3333: Attribute.class, aheinecke@5146: AxisKind.class, sascha@3333: BedHeightEpoch.class, sascha@3333: BedHeightEpochValue.class, sascha@3333: BedHeightSingle.class, sascha@3333: BedHeightSingleValue.class, sascha@3333: BedHeightType.class, sascha@3333: Building.class, aheinecke@5063: BoundaryKind.class, sascha@3333: CrossSection.class, sascha@3333: CrossSectionLine.class, sascha@3333: CrossSectionPoint.class, sascha@3333: CrossSectionTrack.class, sascha@3333: Depth.class, sascha@3333: DGM.class, sascha@3333: DischargeTable.class, sascha@3333: DischargeTableValue.class, sascha@3333: DischargeZone.class, sascha@3333: Edge.class, sascha@3333: ElevationModel.class, aheinecke@5063: FedState.class, sascha@3333: Fixpoint.class, sascha@3333: Floodplain.class, sascha@3333: Floodmaps.class, sascha@3333: FlowVelocityMeasurement.class, sascha@3333: FlowVelocityMeasurementValue.class, sascha@3333: FlowVelocityModel.class, sascha@3333: FlowVelocityModelValue.class, sascha@3333: Gauge.class, sascha@3333: GaugeLocation.class, sascha@3333: GrainFraction.class, aheinecke@5063: HWSKind.class, aheinecke@5063: HWSLine.class, sascha@3333: HydrBoundary.class, sascha@3333: HydrBoundaryPoly.class, sascha@3333: HYK.class, sascha@3333: HYKEntry.class, sascha@3333: HYKFormation.class, sascha@3333: HYKFlowZoneType.class, sascha@3333: HYKFlowZone.class, sascha@3333: LocationSystem.class, sascha@3333: MainValueType.class, ingo@4193: MeasurementStation.class, sascha@3333: MorphologicalWidth.class, sascha@3333: MorphologicalWidthValue.class, sascha@3333: NamedMainValue.class, sascha@3333: MainValue.class, sascha@3333: Position.class, sascha@3333: Range.class, sascha@3333: River.class, sascha@3333: RiverAxis.class, sascha@3333: RiverAxisKm.class, aheinecke@5063: SectieKind.class, aheinecke@5063: SobekKind.class, sascha@3333: SedimentDensity.class, sascha@3333: SedimentDensityValue.class, sascha@3333: SedimentYield.class, sascha@3333: SedimentYieldValue.class, sascha@3333: SQRelation.class, sascha@3333: SQRelationValue.class, sascha@3333: TimeInterval.class, sascha@3333: Unit.class, sascha@3333: Waterlevel.class, sascha@3333: WaterlevelDifference.class, sascha@3333: WaterlevelDifferenceColumn.class, sascha@3333: WaterlevelDifferenceValue.class, sascha@3333: WaterlevelQRange.class, sascha@3333: WaterlevelValue.class, sascha@3333: WstColumn.class, sascha@3333: WstColumnQRange.class, sascha@3333: WstColumnValue.class, sascha@3333: Wst.class, sascha@3333: WstQRange.class sascha@3333: }; sascha@3333: sascha@3333: public FLYSCredentials() { sascha@3333: } sascha@3333: sascha@3333: public FLYSCredentials( sascha@3333: String user, sascha@3333: String password, sascha@3333: String dialect, sascha@3333: String driver, teichmann@5193: String url, teichmann@5193: String connectionInitSqls sascha@3333: ) { teichmann@5193: super( teichmann@5193: user, password, dialect, driver, url, connectionInitSqls, CLASSES); sascha@3333: } sascha@3333: sascha@3333: private static Credentials instance; sascha@3333: sascha@3333: public static synchronized Credentials getInstance() { sascha@3333: if (instance == null) { sascha@3333: String user = sascha@3333: Config.getStringXPath(XPATH_USER, DEFAULT_USER); sascha@3333: String password = sascha@3333: Config.getStringXPath(XPATH_PASSWORD, DEFAULT_PASSWORD); sascha@3333: String dialect = sascha@3333: Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT); sascha@3333: String driver = sascha@3333: Config.getStringXPath(XPATH_DRIVER, DEFAULT_DRIVER); sascha@3333: String url = sascha@3333: Config.getStringXPath(XPATH_URL, DEFAULT_URL); teichmann@5193: String connectionInitSqls = teichmann@5193: Config.getStringXPath( teichmann@5193: XPATH_CONNECTION_INIT_SQLS, teichmann@5193: DEFAULT_CONNECTION_INIT_SQLS); sascha@3333: sascha@3333: instance = new FLYSCredentials( aheinecke@5194: user, password, dialect, driver, url, connectionInitSqls); sascha@3333: } sascha@3333: return instance; sascha@3333: } sascha@3333: sascha@3333: public static Credentials getDefault() { sascha@3333: return new FLYSCredentials( sascha@3333: DEFAULT_USER, sascha@3333: DEFAULT_PASSWORD, sascha@3333: DEFAULT_DIALECT, sascha@3333: DEFAULT_DRIVER, teichmann@5193: DEFAULT_URL, teichmann@5193: DEFAULT_CONNECTION_INIT_SQLS); sascha@3333: } sascha@3333: } sascha@3333: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :