# HG changeset patch # User gernotbelger # Date 1524732372 -7200 # Node ID 274ddafb719b8063a8f30530826bd09825c196d1 # Parent 679b1442c8865d05c1ebfe134ea5e0a61ff0a6bf S-Info-Proof-Init Testing diff -r 679b1442c886 -r 274ddafb719b .hgignore --- a/.hgignore Wed Apr 25 11:58:49 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -syntax: regexp -artifacts/target # maven output -artifacts/\.classpath # eclipse -artifacts/\.project # eclipse -artifacts/\.settings # eclipse -artifacts/test-output # eclipse junit/testng plugin output -backend/target # maven output -backend/\.classpath # eclipse -backend/\.project # eclipse -backend/\.settings # eclipse -backend/test-output # eclipse junit/testng plugin output -gwt-client/target # maven output -gwt-client/\.classpath # eclipse -gwt-client/\.project # eclipse -gwt-client/\.settings # eclipse -gwt-client/test-output # eclipse junit/testng plugin output -gwt-client/src/main/webapp/OpenLayers-2.11 -gwt-client/SmartGWT/.* -etl/target # maven output -etl/\.classpath # eclipse -etl/\.project # eclipse -etl/\.settings # eclipse -etl/test-output # eclipse junit/testng plugin output -\.swp -\.swo -\.pyc -TAGS diff -r 679b1442c886 -r 274ddafb719b artifacts/doc/conf/backend-db.xml --- a/artifacts/doc/conf/backend-db.xml Wed Apr 25 11:58:49 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ - - - - d4e - d4e - org.hibernate.dialect.PostgreSQLDialect - org.postgresql.Driver - jdbc:postgresql://localhost:5432/d4e - select 1 from rivers - 30000 - diff -r 679b1442c886 -r 274ddafb719b artifacts/doc/conf/conf.xml --- a/artifacts/doc/conf/conf.xml Wed Apr 25 11:58:49 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,378 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -]> - - YOUR_SECRET - - org.dive4elements.river.artifacts.context.RiverContextFactory - - org.dive4elements.artifactdatabase.DefaultArtifactCollectionFactory - - - - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - - - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - org.dive4elements.artifactdatabase.DefaultArtifactFactory - - - org.dive4elements.artifactdatabase.DefaultArtifactFactory - - org.dive4elements.artifactdatabase.DefaultArtifactFactory - - org.dive4elements.artifactdatabase.DefaultArtifactFactory - - - - org.dive4elements.artifactdatabase.DefaultUserFactory - - - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - org.dive4elements.artifactdatabase.DefaultServiceFactory - - - - - - org.dive4elements.river.artifacts.datacage.Datacage - org.dive4elements.river.wsplgen.SchedulerSetup - org.dive4elements.river.artifacts.map.RiverMapfileGeneratorStarter - - - - org.dive4elements.river.artifacts.datacage.DatacageBackendListener - - - org.dive4elements.river.artifacts.context.SessionCallContextListener - - - - - - - - - - - - - - - - &sqrelation-artifact; - &sqrelation-datacage-artifact; - &porosity-artifact; - &gaugedischargecurve-artifact; - &sedimentload-artifact; - &sedimentload-ls-artifact; - - &sinfo_artifact; - &uinfo_artifact; - - - &modules; - - - - - - - &generators; - - - - - - - &floodmap; - &rivermap; - - &rest-server; - - - - 60000 - - - - ${artifacts.config.dir}/cache.xml - - - - &artifact-db; - &datacage-db; - &backend-db; - &seddb-db; - - - - ${artifacts.config.dir}/themes.xml - - - - - &zoom-scales; - - /opt/d4e-river/dgm/ - - 1.9 - - - - http://example.com - diff -r 679b1442c886 -r 274ddafb719b artifacts/doc/conf/seddb-db.xml --- a/artifacts/doc/conf/seddb-db.xml Wed Apr 25 11:58:49 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ - - - - seddb - seddb - org.hibernate.dialect.PostgreSQLDialect - org.postgresql.Driver - jdbc:postgresql://localhost:5432/seddb - select 1 from gewaesser - 30000 - - diff -r 679b1442c886 -r 274ddafb719b backend/contrib/run_geo.sh --- a/backend/contrib/run_geo.sh Wed Apr 25 11:58:49 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -#!/bin/bash - -# Set this to your target database for Oracle -HOST=localhost -BACKEND_NAME="XE" -USER=flys28 -PASS=flys28 -# Alternatively you can provide a direct connection string: -# OGR_CONNECTION="PG:dbname=flys host=localhost port=5432 user=flys password=flys" - -# Optional -VERBOSE=1 -SKIP_AXIS=0 -SKIP_KMS=0 -SKIP_CROSSSECTIONS=0 -SKIP_FIXPOINTS=0 -SKIP_BUILDINGS=0 -SKIP_FLOODPLAINS=0 -SKIP_HYDR_BOUNDARIES=0 -SKIP_HWS_LINES=0 -SKIP_HWS_POINTS=0 -SKIP_UESG=0 -SKIP_DGM=0 -SKIP_JETTIES=0 -SKIP_FLOODMARKS=0 - -# Default encoding. Change here if necessary -export LC_ALL=de_DE@euro - -# There should be no need to change anything below this line -GEW_FILE="$1" -RIVER_NAME=$(grep "Gew.sser" "$1" | sed 's/Gew.sser: //') - -RIVER_PATH=$(grep "WSTDatei:" "$GEW_FILE" | awk '{print $2}') -RIVER_PATH=$(dirname "$RIVER_PATH")/../.. -RIVER_PATH=$(readlink -f "$RIVER_PATH") - -DIR=`dirname $0` -DIR=`readlink -f "$DIR"` - -exec python $DIR/shpimporter/shpimporter.py \ - --directory $RIVER_PATH \ - --river_name "$RIVER_NAME" \ - --ogr_connection "$OGR_CONNECTION" \ - --host $HOST/$BACKEND_NAME \ - --user $USER \ - --password $PASS \ - --verbose $VERBOSE \ - --skip_axis $SKIP_AXIS \ - --skip_kms $SKIP_KMS \ - --skip_crosssections $SKIP_CROSSSECTIONS \ - --skip_fixpoints $SKIP_FIXPOINTS \ - --skip_buildings $SKIP_BUILDINGS \ - --skip_floodplains $SKIP_FLOODPLAINS \ - --skip_hydr_boundaries $SKIP_HYDR_BOUNDARIES \ - --skip_uesgs $SKIP_UESG \ - --skip_hws_lines $SKIP_HWS_LINES \ - --skip_hws_points $SKIP_HWS_POINTS \ - --skip_dgm $SKIP_DGM \ - --skip_jetties $SKIP_JETTIES \ - --skip_floodmarks $SKIP_FLOODMARKS \ - 2>&1 diff -r 679b1442c886 -r 274ddafb719b backend/doc/schema/Dockerfile --- a/backend/doc/schema/Dockerfile Wed Apr 25 11:58:49 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -# Docker file for postgresql 9.4 on debain -# -# build with e.g. `docker build --force-rm=true -t d4e/river_db .', -# then run with e.g. -# `docker run --name d4eriver_db -dp 2345:5432 d4e/river_db:latest' -# - -FROM debian:jessie -MAINTAINER tom@intevation.de - -# -# Use utf-8 -# -RUN echo \ - "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | \ - debconf-set-selections && \ - echo "locales locales/default_environment_locale select en_US.UTF-8" | \ - debconf-set-selections - -RUN apt-get update -y && apt-get install -y locales - -ENV LC_ALL en_US.UTF-8 - -# -# Install packages -# -RUN apt-get update && \ - apt-get install -y postgresql-9.4-postgis-2.1 postgis curl - -# -# Use user postgres to run the next commands -# -USER postgres - -RUN /etc/init.d/postgresql start && \ - psql --command "CREATE USER admin WITH SUPERUSER PASSWORD 'secret';" - -# -# Adjust PostgreSQL configuration so that remote connections to the -# database are possible. -# -RUN echo "host all all 0.0.0.0/0 md5" >> \ - /etc/postgresql/9.4/main/pg_hba.conf - -ENV PGCONF /etc/postgresql/9.4/main/postgresql.conf -RUN echo "listen_addresses='*'" >> $PGCONF - -# -# Expose the PostgreSQL port -# -EXPOSE 5432 - -# -# Create database -# -# Don't mind scary messages like -# 'FATAL: the database system is starting up'. -# It's because of the -w -# -ADD . /opt/d4eriver_db - -# Go to postgres home for write permissions -WORKDIR /var/lib/postgresql -ENV DATA_ARCH demodaten_3.1.10-bis-3.2.x.tar.gz -RUN curl -k "https://wald.intevation.org/frs/download.php/2282/$DATA_ARCH" | \ - tar xz - -ENV PGDATA /var/lib/postgresql/9.4/main -RUN /usr/lib/postgresql/9.4/bin/pg_ctl start -wo "--config_file=$PGCONF" && \ - /opt/d4eriver_db/postgresql-setup.sh && \ - psql -f demodaten/d4e_demodata.dump.sql d4e && \ - createuser -S -D -R seddb && \ - createdb seddb && \ - psql -f demodaten/seddb_demodata.dump.sql seddb && \ - /usr/lib/postgresql/9.4/bin/pg_ctl stop - -# -# Set the default command to run when starting the container -# -CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-D", \ - "/var/lib/postgresql/9.4/main", "-c", \ - "config_file=/etc/postgresql/9.4/main/postgresql.conf"] diff -r 679b1442c886 -r 274ddafb719b backend/src/main/java/org/dive4elements/river/backend/SedDBCredentials.java --- a/backend/src/main/java/org/dive4elements/river/backend/SedDBCredentials.java Wed Apr 25 11:58:49 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.backend; - -import org.dive4elements.artifacts.common.utils.Config; - - -public class SedDBCredentials -extends Credentials -{ - public static final String XPATH_USER = - "/artifact-database/seddb-database/user/text()"; - - public static final String XPATH_PASSWORD = - "/artifact-database/seddb-database/password/text()"; - - public static final String XPATH_DIALECT = - "/artifact-database/seddb-database/dialect/text()"; - - public static final String XPATH_DRIVER = - "/artifact-database/seddb-database/driver/text()"; - - public static final String XPATH_URL = - "/artifact-database/seddb-database/url/text()"; - - public static final String XPATH_CONNECTION_INIT_SQLS = - "/artifact-database/seddb-database/connection-init-sqls/text()"; - - public static final String XPATH_VALIDATION_QUERY = - "/artifact-database/seddb-database/validation-query/text()"; - - public static final String XPATH_MAX_WAIT = - "/artifact-database/seddb-database/max-wait/text()"; - - public static final String DEFAULT_USER = - System.getProperty("flys.seddb.user", "seddb"); - - public static final String DEFAULT_PASSWORD = - System.getProperty("flys.seddb.password", "seddb"); - - public static final String DEFAULT_DIALECT = - System.getProperty( - "flys.seddb.dialect", - "org.hibernate.dialect.PostgreSQLDialect"); - - public static final String DEFAULT_DRIVER = - System.getProperty( - "flys.seddb.driver", - "org.postgresql.Driver"); - - public static final String DEFAULT_URL = - System.getProperty( - "flys.seddb.url", - "jdbc:postgresql://localhost:5432/seddb"); - - public static final String DEFAULT_CONNECTION_INIT_SQLS = - System.getProperty( - "flys.seddb.connection.init.sqls"); - - public static final String DEFAULT_VALIDATION_QUERY = - System.getProperty( - "flys.seddb.connection.validation.query"); - - public static final String DEFAULT_MAX_WAIT = - System.getProperty("flys.seddb.connection.max.wait"); - - public static final Class [] CLASSES = {}; - - private static Credentials instance; - - public SedDBCredentials() { - } - - public SedDBCredentials( - String user, - String password, - String dialect, - String driver, - String url, - String connectionInitSqls, - String validationQuery, - String maxWait - ) { - super( - user, password, dialect, driver, url, - connectionInitSqls, validationQuery, maxWait, CLASSES); - } - - 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); - String connectionInitSqls = - Config.getStringXPath( - XPATH_CONNECTION_INIT_SQLS, - DEFAULT_CONNECTION_INIT_SQLS); - String validationQuery = - Config.getStringXPath( - XPATH_VALIDATION_QUERY, - DEFAULT_VALIDATION_QUERY); - String maxWait = - Config.getStringXPath(XPATH_MAX_WAIT, DEFAULT_MAX_WAIT); - - instance = new SedDBCredentials( - user, password, dialect, driver, url, - connectionInitSqls, validationQuery, maxWait); - } - return instance; - } - - public static Credentials getDefault() { - return new SedDBCredentials( - DEFAULT_USER, - DEFAULT_PASSWORD, - DEFAULT_DIALECT, - DEFAULT_DRIVER, - DEFAULT_URL, - DEFAULT_CONNECTION_INIT_SQLS, - DEFAULT_VALIDATION_QUERY, - DEFAULT_MAX_WAIT - ); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 679b1442c886 -r 274ddafb719b etl/doc/conf.xml --- a/etl/doc/conf.xml Wed Apr 25 11:58:49 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ - - - - - - - - - - - - - /the/path/to/the/dips/file - /the/path/to/the/xslt/to/repair/dips - - - - - org.postgresql.Driver - flys - flys - jdbc:postgresql://localhost:5432/flys - - - - - - org.sqlite.JDBC - - - jdbc:sqlite:/path/to/aft.db - - - - diff -r 679b1442c886 -r 274ddafb719b gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RecommandationUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RecommandationUtils.java Thu Apr 26 10:46:12 2018 +0200 @@ -0,0 +1,58 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ +package org.dive4elements.river.client.client.ui; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.dive4elements.river.client.client.ui.AbstractPairRecommendationPanel.IRecommendationInfo; +import org.dive4elements.river.client.shared.model.Recommendation; +import org.dive4elements.river.client.shared.model.Recommendation.Facet; +import org.dive4elements.river.client.shared.model.Recommendation.Filter; + +/** + * @author Domenico Nardi Tironi + * + */ +public class RecommandationUtils { + /** + * Creates part of the String that encodes minuend or subtrahend. + * + * @param recommendation + * Recommendation to wrap in string. + * @param info + * Provides the factory to encode. + */ + public static final String createDataString(final String artifactUuid, final Recommendation recommendation, final IRecommendationInfo info) { + final String factory = info.getDataStringFactory(recommendation); + + final Filter filter = recommendation.getFilter(); + Facet f = null; + + if (filter != null) { + final Map> outs = filter.getOuts(); + final Set>> entries = outs.entrySet(); + + for (final Map.Entry> entry : entries) { + final List fs = entry.getValue(); + + f = fs.get(0); + if (f != null) { + break; + } + } + + return "[" + artifactUuid + ";" + f.getName() + ";" + f.getIndex() + ";" + recommendation.getDisplayName() + "]"; + } + + return "[" + artifactUuid + ";" + factory + ";0;" + recommendation.getDisplayName() + "]"; + } +} diff -r 679b1442c886 -r 274ddafb719b gwt-client/src/main/java/org/dive4elements/river/client/test/SinfoProof.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/test/SinfoProof.java Wed Apr 25 11:58:49 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/test/SinfoProof.java Thu Apr 26 10:46:12 2018 +0200 @@ -9,27 +9,30 @@ package org.dive4elements.river.client.test; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; -import java.net.MalformedURLException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; import org.dive4elements.artifacts.common.ArtifactNamespaceContext; import org.dive4elements.artifacts.common.utils.ClientProtocolUtils; import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; import org.dive4elements.artifacts.httpclient.http.HttpClient; import org.dive4elements.artifacts.httpclient.http.HttpClientImpl; import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler; -import org.dive4elements.artifacts.httpclient.utils.Configuration; import org.dive4elements.artifacts.httpclient.utils.XMLUtils; +import org.dive4elements.river.client.client.ui.NilDatacageTwinPanelInfo; +import org.dive4elements.river.client.client.ui.RecommandationUtils; import org.dive4elements.river.client.server.AdvanceServiceImpl; import org.dive4elements.river.client.server.ArtifactHelper; import org.dive4elements.river.client.server.CollectionHelper; import org.dive4elements.river.client.server.CreateCollectionServiceImpl; import org.dive4elements.river.client.server.FLYSArtifactCreator; import org.dive4elements.river.client.server.FeedServiceImpl; +import org.dive4elements.river.client.server.LoadArtifactServiceImpl; import org.dive4elements.river.client.server.auth.DefaultUser; import org.dive4elements.river.client.server.auth.User; import org.dive4elements.river.client.server.auth.UserClient; @@ -51,78 +54,12 @@ * @author Ingo Weinzierl */ public class SinfoProof { - /** - * The logging is done via Log4j. To configure the logging - * a file 'log4j.properties' is search in the configuration directory. - */ - public static final String LOG4J_PROPERTIES = "log4j.properties"; - /** - * The path of the configuration directory. - */ - public static final String CONFIG_PATH = System.getProperty("config.dir", "conf"); - - public static final String CONFIG = System.getProperty("config.file", "use_case1.conf"); - - public static final String XPATH_DYNAMIC = "/art:result/art:ui/art:dynamic"; private static final String serverUrl = "http://localhost:8181"; private static final String locale = "de"; - /** - * The logger used in this class. - */ - private static Logger logger; - - static { - configureLogging(); - - logger = Logger.getLogger(SinfoProof.class); - } - - /** - * Trys to load the Log4j configuration from ${config.dir}/log4j.properties. - */ - public static final void configureLogging() { - final File configDir = new File(CONFIG_PATH); - final File propFile = new File(configDir, LOG4J_PROPERTIES); - - if (propFile.isFile() && propFile.canRead()) { - try { - PropertyConfigurator.configure(propFile.toURI().toURL()); - } - catch (final MalformedURLException mue) { - mue.printStackTrace(System.err); - } - } - } - - public static final Configuration readConfiguration() { - final File configDir = new File(CONFIG_PATH); - final File configFile = new File(configDir, CONFIG); - - logger.debug("Configuration file: " + configFile.getAbsolutePath()); - - if (configFile.isFile() && configFile.canRead()) { - try { - final Configuration conf = new Configuration(configFile); - conf.initialize(); - - return conf; - } - catch (final IOException ioe) { - logger.error("Error while reading configuration."); - } - } - - return null; - } - - public SinfoProof() { - // empty constructor - super(); - } public static void main(final String[] args) throws ServerException, IOException { - logger.info("Starting console client."); + // logger.info("Starting console client."); final User user = new DefaultUser("belger", "belger", null, false, new ArrayList(), new ArrayList()); final UserClient userClient = new UserClient(serverUrl); @@ -144,33 +81,58 @@ final Data dataCalcMode = new StringOptionsData("calculation_mode", "calculation_mode", new DataItem[] { minMaxFlowdepth }); final Artifact rangeArtifact = feedAndGo(calcModeArtifact, new Data[] { dataCalcMode }, 0); - /* Select Distance */ + /* Select Range */ // entweder eine bestimmte Range - final Data dataFrom = new StringOptionsData("ld_from", "ld_from", new DataItem[] { new DefaultDataItem("0", "0", "0") }); + final Data dataFrom = new StringOptionsData("ld_from", "ld_from", new DataItem[] { new DefaultDataItem("10", "10", "10") }); final Data dataTo = new StringOptionsData("ld_to", "ld_to", new DataItem[] { new DefaultDataItem("100", "100", "100") }); final Data[] rangeFromToDetermined = new Data[] { dataFrom, dataTo }; // oder die maxRange final DataList list = rangeArtifact.getArtifactDescription().getCurrentData(); final Data[] rangeMax = new Data[] { list.get(0), list.get(1) }; - final Artifact dataChoiceArtifact = feedAndGo(rangeArtifact, rangeMax, 0); + + final Artifact dataChoiceArtifact = feedAndGo(rangeArtifact, rangeFromToDetermined, 0); /* Select Fixpunkte */ - final List recs = collection.getRecommendations(); - if (recs != null) { + final Recommendation rec1 = new Recommendation("staticwqkms", "additionals-wstv-0-103", "sinfo_flowdepth_waterlevels"); + final Recommendation rec2 = new Recommendation("bedheight", "bedheight-single-36-2015-FP-2015_0-502", "sinfo_flowdepthminmax_heights"); + final Artifact[] artifacts = loadMany(collection, new Recommendation[] { rec1, rec2 }, null); + + // rec1.getDisplayName() TODO: makeDisplayName + final String rec1String = RecommandationUtils.createDataString(artifacts[0].getUuid(), rec1, new NilDatacageTwinPanelInfo("xxxx")); + final String rec2String = RecommandationUtils.createDataString(artifacts[1].getUuid(), rec2, new NilDatacageTwinPanelInfo("xxxx")); + // TODO: check display name + final String combinedIdNeu = rec1String + "#" + rec2String; + + final Data pair = new StringOptionsData("diffids", "diffids", new DataItem[] { new DefaultDataItem(combinedIdNeu, combinedIdNeu, combinedIdNeu) }); + final Artifact exportArtifact = feedAndGo(dataChoiceArtifact, new Data[] { pair }, 0); + + // Describe collection + describeCollection(collection); // wichtig, damit die Facets erzeugt werden + + // /* Export calculation */ + final OutputMode[] modes = exportArtifact.getArtifactDescription().getOutputModes(); + if (modes != null) { + final OutputMode mode = modes[1]; // output.sinfo_flowdepthminmax_export + doGet(mode.getName(), collection.identifier()); } - final String combinedId = "[c23bcc26-2282-47b7-b262-5a328a372926;staticwqkms;0;ELBE_W-MNQ1890-2006_Fixierungsdaten_150-280.csv]#[d2e2e1da-81cd-40e6-8857-dddc22252c29;bedheight;0;FP-2015_0-502]"; // SCHWACHSTELLE... - final Data pair = new StringOptionsData("Ausgewählte Differenzen", "diffids", new DataItem[] { new DefaultDataItem(null, null, combinedId) }); - final Artifact export = feedAndGo(dataChoiceArtifact, new Data[] { pair }, 0); - final Recommendation r; + } - /* Export calculation */ - final OutputMode[] modes = export.getArtifactDescription().getOutputModes(); - if (modes != null) { + private static Collection describeCollection(final Collection collection) throws ConnectionException { - } + final String uuid = collection.identifier(); + + final Document describe = ClientProtocolUtils.newDescribeCollectionDocument(uuid); + + final HttpClient client = new HttpClientImpl(serverUrl, locale); + + final Document response = (Document) client.doCollectionAction(describe, uuid, new DocumentResponseHandler()); + + final Collection c = CollectionHelper.parseCollection(response); + + return c; } private static Artifact feedAndGo(final Artifact inputArtifact, final Data[] data, final int reachableStateIndex) @@ -263,6 +225,75 @@ throw new ServerException(AdvanceServiceImpl.ERROR_ADVANCE_ARTIFACT); } - // FIXME + public static Artifact[] loadMany(final Collection parent, final Recommendation[] recoms, final String factory) throws ServerException { + + final ArrayList artifacts = new ArrayList(); + final HashMap cloneMap = new HashMap(); + + for (final Recommendation recom : recoms) { + + final Artifact prevClone = cloneMap.get(recom); + if (prevClone != null) { + + artifacts.add(prevClone); + } else { + // Not already cloned. + final String realFactory = factory != null ? factory : recom.getFactory(); + + final Artifact clone = ArtifactHelper.createArtifact(serverUrl, locale, realFactory, recom); + + if (clone != null) { + final Collection c = CollectionHelper.addArtifact(parent, clone, serverUrl, locale); + + if (c != null) { + artifacts.add(clone); + // Remember we cloned a recommendation like this. + cloneMap.put(recom, clone); + } else { + throw new ServerException(LoadArtifactServiceImpl.ERROR_LOAD_ARTIFACT); + } + } + } + } + return artifacts.toArray(new Artifact[artifacts.size()]); + } + + /// ExportServiceImpl + + public static void doGet(final String mode, final String collectionId) { + + try { + + final String name = mode; + final String type = "csv"; + + final String fn = name + "." + type; // TODO: make filename unique + final String enc = "windows-1252";// req.getParameter("encoding"); + + final OutputStream out = new FileOutputStream(new File("D:" + File.separator + fn)); + final Document attr = null; + final Document request = ClientProtocolUtils.newOutCollectionDocument(collectionId, mode, type, attr); + final HttpClient client = new HttpClientImpl(serverUrl, locale); + + if (enc != null) { + final InputStreamReader in = new InputStreamReader(client.collectionOut(request, collectionId, mode), "UTF-8"); + try { + final OutputStreamWriter encOut = new OutputStreamWriter(out, enc); + final char buf[] = new char[4096]; + int c; + while ((c = in.read(buf, 0, buf.length)) >= 0) { + encOut.write(buf, 0, c); + } + encOut.flush(); + encOut.close(); + } finally { + in.close(); + } + } + } + catch (final IOException ioe) { + ioe.printStackTrace(); + } + } + } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: