# HG changeset patch # User Raimund Renkert # Date 1423061540 -3600 # Node ID 82b616dcbd5371624ce8918ae57b5ec07fcd61ff # Parent 9709bf4162fa4ec8086f8b9a1fa723c0a0ed0637 Removed files. Development starts "from scratch". diff -r 9709bf4162fa -r 82b616dcbd53 INSTALL --- a/INSTALL Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,303 +0,0 @@ -Installation -============ -Allgemeine Informationen finden Sie in der README Datei - -Die Installation der Serverkomponente erfordert folgende Vorraussetzungen: - -* PostgreSQL-9.2/PostGIS-2.0 Datenbank inklusive Testdaten -* JBoss-AS - -Zum Bauen der Anwendung aus den Quellen wird zusätzlich das Build-Tool 'maven' -benötigt. - -Installation JBoss-AS -------------------------- - -Im folgenden ist die Installation des JBoss-AS in dem Ordner /opt beschrieben. - -$ cd /opt -$ curl -O http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip -# Integrität prüfen. Leider bietet Redhat für diese "Community Edition" keinen -# Überprüfungsweg an. Vermutlich als Verkaufsanreiz für die professionelle -# Version. Beim Herunterladen am 2013-05-09 hatte die Datei folgende sha256 -# Prüfsumme: -# 0aece7899b54c0219732112307b2bede78ab9b39ee14140ce89ac8c1b716d0ee -# jboss-as-7.1.1.Final.zip -$ unzip jboss-as-7.1.1.Final.zip - -# Der Jboss Server soll nicht als root, sondern unter einem dedizierten Nutzer -# laufen. In diesem Fall als Nutzer "lada". Hierfür müssen einige -# Berechtigungen angepasst werden. -$ USER=lada -$ chgrp -R ${USER} jboss-as-7.1.1.Final -$ cd jboss-as-7.1.1.Final -$ chmod 775 standalone/ -$ chmod 775 standalone/deployments -$ chmod 775 standalone/tmp -$ chmod 775 standalone/configuration -$ chmod 660 standalone/configuration/mgmt-users.properties -$ chmod 660 standalone/configuration/application-users.properties - -Einrichten eines Admin Zugangs -`````````````````````````````` -Um den JBoss Server über die Weboberfläche administrieren zu können muss -zunächst ein neuer Nutzer erstellt werden: - -$ cd jboss-as-7.1.1.Final -$ sh bin/add-user.sh - -Einrichten von JBoss als Service -```````````````````````````````` -JBoss soll als Service start und beendbar sein. - -$ cd /etc/init.d -$ cp /opt/jboss-as-7.1.1.Final/bin/init.d/jboss-as-standalone.sh jboss - -# In diesem SCRIPT müssen dann folgene Variablen angepasst werden: -# 1. JBOSS_HOME=/opt/jboss-as-7.1.1.Final -# 2. JBOSS_USER=lada - -$ servive jboss start - - -Datenbank ---------- -Die LADA Anwendung basiert auf einer PostgreSQL/PostGIS Datenbank in den -Versionen PostgreSQL 9.2/PostGIS 2.0. -Beipieldaten sind in dem Datenbankdump lada-db.zip verfügbar und können -in eine PostgreSQL/PostGIS Datenbank importiert werden. -Hierzu sollte vorher ein Benutzer in der Datenbank angelegt werden. In der -folgenden Installationsanleitung wird davon ausgegangen, dass ein Benutzer -'lada' in der Datenbank existiert. -Der dadurch verfügbare Testdatensatz enthält zusätzlich Daten zu Gemeinden und -Verwaltungen in Deutschland, die vom BKG zur Verfügung gestellt werden. - -Einrichtung der Datenbankverbindung im JBoss AS ------------------------------------------------ -Die Datenbankverbindung wird im Application Server eingerichtet. Hierzu muss der -entsprechende Treiber zunächst als Modul eingefügt werden. Die folgenden -Schritte setzen vorraus, dass der JBoss AS in dem Ordner -/opt/jboss-as-7.1.1-Final installiert ist. - -1. Anlegen des Verzeichnisses und herunterladen der Treiber. - -$cd /opt/jboss-as-7.1.1.Final/modules/org -$mkdir -p postgresql/main/ -$cd postgresql/main -$curl -O "http://jdbc.postgresql.org/download/postgresql-9.2-1002.jdbc4.jar" -$curl -O "http://www.hibernatespatial.org/repository/org/postgis/postgis-jdbc/1.5.2/postgis-jdbc-1.5.2.jar" - -2. In dem Ordner /opt/jboss-as-7.1.1.Final/modules/org/postgresql/main/ eine -Datei module.xml mit folgendem Inhalt anlegen. - - - - - - - - - - - - - -3. Einfügen der Hibernate-Spatial Komponenten. - -$cd /opt/jboss-as-7.1.1.Final/modules/org/hibernate/main -$curl -O "http://www.hibernatespatial.org/repository/org/hibernate/hibernate-spatial/4.0/hibernate-spatial-4.0.jar" -$curl -O "http://repo1.maven.org/maven2/com/vividsolutions/jts/1.13/jts-1.13.jar" - -4. Eintragen der Hibernate-Spatial Komponenten in -/opt/jboss-as-7.1.1.Final/modules/org/hibernate/main/module.xml - - - ... - - - - - ... - - - -5. Einfügen des PostgreSQL Moduls als Treiber in die JBoss Konfiguration. - - In den Abschnitt folgenden Block einfügen: - - - org.postgresql.xa.PGXADataSource - - - -Nun kann man eine neue Datenbankverbindung mit dem neuen Treiber einrichten. -Dazu verbindet man sich mit dem soeben angelegten Management-Nutzer mit der -Administrations-Webinterface unter der Adresse: http://localhost:9990 - -1. Datesources auswählen. Hier werden alle derzeit eingerichteten Datenquellen - angzeigt. Wir wollen eine neue einrichten. Hierzu -2. Oben rechts von "Runtime" auf "Profile" wechseln. -3. "Add" wählen. -4. Name: Lada, JNDI: java:/jboss/Lada -5. Treiber Wählen: postgis -6. Weitere Verbindungsparameter angeben. - a) connection url: jdbc:postgresql_postGIS://localhost:5432/lada - b) Nutzer (lada) - c) Password - -7.Da während dieser Einrichtung die Standard PostgreSQL Treiberklasse gewählt - wird, muss diese noch in der Datei - /opt/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml - geändert werden: - Hierzu wird im Abschnitt für die neu angelegte Datenquelle - org.postgresql.Driver gegen - org.postgis.DriverWrapper ausgetauscht. - -Installation der LADA Anwendung -=============================== -Zur Installation der LADA Anwendung müssen folgende Schritte unternommen werden: - -Erstellen der Anwendung aus den Quellen (optional) --------------------------------------------------- - -Befehle zum Bauen der Anwendung aus den Quellen: - -$ cd /path/to/sources/ -$ mvn clean compile package - -Das WAR-Archiv der Anwendung wird in dem Ordner 'target/' abgelegt. - -Installation des Pakets ------------------------ - -$ cd /opt/jboss-as-7.1.1.Final/standalone/deployments -$ cp /path/where/the/war/file/is/lada.war . -touch lada.war.dodeploy - -$cd /opt/jboss-as-7.1.1.Final/standalone/deployments -$cp /path/where/the/war/file/is/lada.war . -$touch lada.war.dodeploy - -Zum Aktualisieren der Anwendung genügt es, wenn die lada.war Datei aktualisiert -wird. - -Die Anwendung ist dann unter dem Pfad "/lada" (abhängig vom Archivnamen) -erreichbar. - -Konfiguration der LADA Anwendung -================================ -Die Konfigurationsdateien sind Dateien im JSON-Format und können an einer -beliebigen Stelle im System abgelegt werden, solang diese Dateien für den -Nutzer, mit dem JBoss-Server gestartet wird, gelesen werden kann. - -Bei Änderungen an der Konfigurationsdatei muss der Server nicht neu gestartet -werden. Es reicht ein erneutes Laden der Anwendung durch den Client. -Vorbereitete und vollständige Konfigurationsdateien sind in dem Ordner -'config' zu finden. - -Importer --------- -Der Pfad an dem diese Konfigurationsdatei zu finden ist wird in einer JBoss -Konfigurationsdatei "standalone.xml" abgelegt. Diese Datei findet sich im JBoss -Ordner ($JBOSSHOME/standalone/configuration/standalone.xml). - -In dieser Datei wird der Pfad in Form einer Property abgelegt: - - -... - - - - - -... - - -Flexible Suche --------------- -Der Pfad an dem diese Konfigurationsdatei zu finden ist wird in einer JBoss -Konfigurationsdatei "standalone.xml" abgelegt. Diese Datei findet sich im JBoss -Ordner ($JBOSSHOME/standalone/configuration/standalone.xml). - -In dieser Datei wird der Pfad in Form einer Property abgelegt: - - -... - - - ... - - - -... - - -Einrichtung des Webservers (Apache) -=================================== -Die folgenden Module des Apache Webserver sind nötig, um die LADA Anwendung zu -betreiben: - * ldap_module: Authenitfizierung gegen den LDAP - * headers_module: Setzten der Header nach der Authenitifizierung - * proxy_module: Reverse Proxy des Apache zum Jboss-Server - -Damit der Client eine Verbindung zu dem Server aufbauen kann, um von dort Daten -laden zu können ist es notwendig den Server weiter zu konfigurieren. - -togglesebool httpd_can_network_connect -service httpd restart - -Dies erlaubt dem Apache grundsätzlich sich an einen anderen Dienst zu verbinden. - -Nun muss noch ein Reverse-Proxy eingerichtet werden. Dieser ist nur für -bestimmte Adressen aktiv - -Folgende Datei sollte unter "/etc/httpd/conf.d/lada.conf" angelegt werden: - - - ServerAdmin webmaster@localhost - #ServerName dummy-host.example.com - ErrorLog logs/lada-error_log - CustomLog logs/lada-access_log common - - # Set multiple Proxys - ProxyPass /lada/server http://localhost:8080/lada - ProxyPassReverse /lada/server http://localhost:8080/lada - - -Alles Anfragen an die Adresse "/lada/service" werden nun an den JBoss -weitergeleitet. - -Authentifizierung - -Die Authentifizierung geschieht gegen einen LDAP-Server. - - - AuthType basic - AuthName "test" - AuthBasicProvider ldap - AuthLDAPURL "ldap://ike.polyhedra.intevation.de:389/cn=users,dc=icosahedron,dc=polyhedra,dc=intevation,dc=de?uid,memberof??(&(objectClass=inetOrgPerson)(memberOf=*))" - Require valid-user - - - - RequestHeader unset Authorization - RequestHeader set X-LDAP-User "%{AUTHENTICATE_uid}e" - RequestHeader set X-LDAP-Groups "%{AUTHENTICATE_memberof}e" - - -Sofern gewünscht ist die Authentifizierung für Testzwecke zu deaktivieren muss -trotz allem die entsprechenden Header gesetzt werden, da der Server diese -derzeit erwartet. - -# Set Headers to simulate Authentification. - - RequestHeader set X-LDAP-User "mst_06010" - RequestHeader set X-LDAP-Groups "cn=Imis_world,cn=groups,dc=icosahedron,dc=polyhedra,dc=intevation,dc=de;cn=mst_06010,cn=groups,dc=icosahedron,dc=polyhedra,dc=intevation,dc=de;cn=mst_11010,cn=groups,dc=icosahedron,dc=polyhedra,dc=intevation,dc=de" - - -Dokumentation -============= -Eine HTML-Dokumenation des Quellcodes(Javadoc) ist in dem Ordner 'doc' hinterlegt und -kann über einen Webserver (z.B. Apache WebServer) bereitgestellt werden. diff -r 9709bf4162fa -r 82b616dcbd53 README --- a/README Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -Lada-Server -=========== -Dies ist die Prototypversion der Serverkomponente für die Anwendung LADA zur -Verarbeitung und Erfassung von Labordaten. - -Die Software bietet grundlegende Funktionalität zur Erfassung und Bearbeitung -von Messdaten. Weitere Informationen finden sich auf der Projektwebseite unter -der Adresse: - - https://wald.intevation.org/projects/lada/ - -Die Software entstand im Rahmen einer Software Entwicklung durch die -Intevation GmbH im Auftrag des Bundesamt für Strahlenschutz im Jahre 2013. - -Kontakt -------- -Bundesamt für Strahlenschutz -SW2 Notfallschutz, Zentralstelle des Bundes (ZdB) -Willy-Brandt-Strasse 5 -38226 Salzgitter -info@bfs.de - -Lizenz ------- -Die Software unter der GNU GPL v>=3 Lizenz verfügbar. Details siehe die Datei -COPYING. - -Quelltext ---------- -Die Quelldateien lassen sich wie folgt auschecken: -hg clone https://scm.wald.intevation.org/hg/lada/lada-server - -Installation ------------- -Siehe INSTALL Datei - -Dokumenation ------------- -Die Entwicklerdokumentation (Javadoc) kann mit dem folgenden Befehl im -Verzeichnis der Serveranwendung erzeugt werden: - -mvn javadoc:javadoc - -Der Ordner 'target' enthält dann die Dokumentation im HTML-Format in dem -Verzeichnis 'site/apidocs'. diff -r 9709bf4162fa -r 82b616dcbd53 jboss/config/standalone.xml --- a/jboss/config/standalone.xml Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,327 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 - h2 - - sa - sa - - - - jdbc:postgresql://localhost:6543/lada - org.postgresql.Driver - postgresql-9.2-1002.jdbc4.jar - - lada - ohY9iiD9 - - - false - false - - - false - - - - - org.h2.jdbcx.JdbcDataSource - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - ${jboss.bind.address:127.0.0.1} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/auth/Authentication.java --- a/src/main/java/de/intevation/lada/auth/Authentication.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.auth; - -import javax.ws.rs.core.HttpHeaders; - -/** - * Defines the interface authentication modules that provide information about - * the user. - * - * @author Raimund Renkert - */ -public interface Authentication -{ - public boolean isAuthorizedUser(HttpHeaders headers) - throws AuthenticationException; - - public AuthenticationResponse authorizedGroups(HttpHeaders headers) - throws AuthenticationException; - - public boolean hasAccess(HttpHeaders headers, String probeId) - throws AuthenticationException; - - public String getUserName(HttpHeaders headers) - throws AuthenticationException; -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/auth/AuthenticationException.java --- a/src/main/java/de/intevation/lada/auth/AuthenticationException.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.auth; - -/** - * Exception thrown in the authentication process. - * - * @author Raimund Renkert - */ -public class AuthenticationException -extends Exception -{ - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/auth/AuthenticationResponse.java --- a/src/main/java/de/intevation/lada/auth/AuthenticationResponse.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.auth; - -import java.util.List; - -/** - * Response of an authentication module. Contains the user name, - * 'Messstellen' and 'Netzbetreiber'. - * - * @author Raimund Renkert - */ -public class AuthenticationResponse -{ - private String user; - private List mst; - private List netzbetreiber; - - public AuthenticationResponse() { - } - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - public List getMst() { - return mst; - } - - public void setMst(List mst) { - this.mst = mst; - } - - public List getNetzbetreiber() { - return netzbetreiber; - } - - public void setNetzbetreiber(List netzbetreiber) { - this.netzbetreiber = netzbetreiber; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/auth/Authorization.java --- a/src/main/java/de/intevation/lada/auth/Authorization.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.auth; - -/** - * Defines the interface for data access. - * - * @author Raimund Renkert - */ -public interface Authorization -{ - public boolean isReadOnly(String id); -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/auth/DataAuthorization.java --- a/src/main/java/de/intevation/lada/auth/DataAuthorization.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.auth; - -import java.util.List; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; - -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.rest.Response; - -/** -* This implementation of the authorization interface handles access to data -* objects. -* -* @author Raimund Renkert -*/ -@ApplicationScoped -@Named("dataauthorization") -public class DataAuthorization -implements Authorization -{ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * Determine if the LProbe identified by probeId is writable for the user. - * - * @param probeId The probe id. - */ - public boolean isReadOnly(String probeId) { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), - LMessung.class); - builder.and("probeId", probeId); - Response response = repository.filter(builder.getQuery()); - @SuppressWarnings("unchecked") - List messungen = (List) response.getData(); - if (messungen.isEmpty()) { - return false; - } - for(LMessung messung : messungen) { - if (messung.isFertig()) { - return true; - } - } - return false; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/auth/LdapAuthentication.java --- a/src/main/java/de/intevation/lada/auth/LdapAuthentication.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,197 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.auth; - -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.naming.InvalidNameException; -import javax.naming.ldap.LdapName; -import javax.naming.ldap.Rdn; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.model.Auth; -import de.intevation.lada.model.LProbe; - -/** - * This implementation of the authentication interface reads LDAP users - * and groups from HTTP headers and validates the groups using a database. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("ldapauth") -public class LdapAuthentication -implements Authentication -{ - @Inject - private EntityManager em; - - /** - * Determine if the header contains information about a valid user. - * - * @param headers The HTTP header containing LDAP user information. - */ - @Override - public boolean isAuthorizedUser(HttpHeaders headers) - throws AuthenticationException { - AuthenticationResponse auth = authorizedGroups(headers); - if (auth.getMst().isEmpty() || - auth.getNetzbetreiber().isEmpty()) { - return false; - } - return true; - } - - /** - * Synchronize LDAP user and groups with database. - * - * @param headers The HTTP header containing LDAP user information. - */ - @Override - public AuthenticationResponse authorizedGroups(HttpHeaders headers) - throws AuthenticationException { - List groups = new ArrayList(); - try { - LdapName ldap = extractLdapName(headers); - List rdns = ldap.getRdns(); - for (Rdn rdn: rdns) { - String value = (String)rdn.getValue(); - if (rdn.getType().equals("cn")) { - groups.add(value); - } - } - } - catch(InvalidNameException ine) { - throw new AuthenticationException(); - } - AuthenticationResponse response = getDatabaseAtributes(groups); - String user = extractUser(headers); - if (user == null) { - throw new AuthenticationException(); - } - response.setUser(user); - return response; - } - - /** - * Determine if the user has the permission to access a probe. - * - * @param headers The HTTP header containing LDAP user information. - * @param probeId The LProbe id. - */ - public boolean hasAccess (HttpHeaders headers, String probeId) - throws AuthenticationException { - QueryBuilder builder = new QueryBuilder(em, LProbe.class); - builder.and("probeId", probeId); - List probe = em.createQuery(builder.getQuery()).getResultList(); - if (probe.isEmpty()) { - return false; - } - String nbId = probe.get(0).getNetzbetreiberId(); - String mstId = probe.get(0).getMstId(); - AuthenticationResponse auth = authorizedGroups(headers); - if (auth.getNetzbetreiber().contains(nbId) && - auth.getMst().contains(mstId)) { - return true; - } - return false; - } - - - /** - * Get the user from HTTP header. - * - * @param headers The HTTP header containing user information. - * @return The user name. - */ - private String extractUser(HttpHeaders headers) { - List user = headers.getRequestHeader("x-ldap-user"); - if (user == null || user.isEmpty()) { - return null; - } - return user.get(0); - } - - /** - * Extract LDAP information from HTTP header. - * - * @param headers The HTTP header containing ldap information. - * @return The Ldap object. - * @throws InvalidNameException - */ - private LdapName extractLdapName(HttpHeaders headers) throws InvalidNameException { - List attributes = headers.getRequestHeader("x-ldap-groups"); - if (attributes == null ||attributes.isEmpty()) { - return new LdapName(""); - } - LdapName ldap = new LdapName(""); - String all = attributes.get(0); - String[] groups = all.split(";"); - for (int i = 0; i < groups.length; i++) { - String[] items = groups[i].trim().split(","); - for (int j = 0; j < items.length; j++) { - ldap.add(items[j]); - } - } - return ldap; - } - - /** - * Get the 'Messstellen' and 'Netzbetreiber' from database using the - * LDAP groups. - * - * @param groups List of LDAP groups. - * @return AuthenticationResponse object. - */ - private AuthenticationResponse getDatabaseAtributes(List groups) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(Auth.class); - Root member = criteria.from(Auth.class); - List orFilter = new ArrayList(); - for (String group: groups) { - orFilter.add(builder.equal(member.get("ldapGroup"), group)); - } - Predicate orf = builder.or(orFilter.toArray(new Predicate[orFilter.size()])); - criteria.where(orf); - List result = em.createQuery(criteria).getResultList(); - List mst = new ArrayList(); - List nb = new ArrayList(); - for (Auth a: result) { - if (a.getSMessStelle() != null) { - mst.add(a.getSMessStelle().getMstId()); - } - if (a.getSNetzBetreiber() != null) { - nb.add(a.getSNetzBetreiber().getNetzbetreiberId()); - } - } - AuthenticationResponse response = new AuthenticationResponse(); - response.setMst(mst); - response.setNetzbetreiber(nb); - return response; - } - - /** - * Returns the username specified in the header. - * - * @param headers The HTTP header. - */ - public String getUserName(HttpHeaders headers) - throws AuthenticationException { - return extractUser(headers); - } -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/LKommentarMRepository.java --- a/src/main/java/de/intevation/lada/data/LKommentarMRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,193 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.TransactionRequiredException; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import de.intevation.lada.manage.Manager; -import de.intevation.lada.model.LKommentarM; -import de.intevation.lada.rest.Response; - -/** - * This Container is an interface to read, write and update LKommentarM objects. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("lkommentarmrepository") -public class LKommentarMRepository implements Repository -{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - /** - * The data manager providing database operations. - */ - @Inject - @Named("datamanager") - private Manager manager; - - public EntityManager getEntityManager() { - return this.em; - } - /** - * Filter object list by the given criteria. - * - * @param filter The query filter. - * @return Response object. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - - /** - * Get all objects of type clazzfrom database. - * - * @param clazz The object type. - * @return Response object. - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } - - /** - * Find a single object identified by its id. - * - * @param clazz The object type. - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } - - /** - * Create a new LKommentarM object. - * - * @param object The new object. - * @return Response object. - */ - public Response create(Object object) { - if (!(object instanceof LKommentarM)) { - return new Response(false, 602, object); - } - LKommentarM kommentar = (LKommentarM)object; - Response response = new Response(true, 200, kommentar); - try { - manager.create(kommentar); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Update a LKommentarM object. - * - * @param object The object to update. - * @return Response object. - */ - public Response update(Object object) { - if (!(object instanceof LKommentarM)) { - return new Response(false, 602, object); - } - LKommentarM kommentar = (LKommentarM)object; - Response response = new Response(true, 200, kommentar); - try { - manager.update(kommentar); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Delete a LKommentarM object. - * - * @param object The object to delete - * @return Response object. - */ - public Response delete(Object object) { - if (!(object instanceof LKommentarM)) { - return new Response(false, 602, null); - } - LKommentarM kommentar = (LKommentarM)object; - Response response = new Response(true, 200, null); - try { - manager.delete(kommentar); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - return response; - } - @Override - public Response filter(CriteriaQuery filter, int size, int start) { - return null; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/LKommentarPRepository.java --- a/src/main/java/de/intevation/lada/data/LKommentarPRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; -import java.util.logging.Logger; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.TransactionRequiredException; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import de.intevation.lada.manage.Manager; -import de.intevation.lada.model.LKommentarP; -import de.intevation.lada.rest.Response; - -/** - * This Container is an interface to read, write and update LKommentarP objects. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("lkommentarRepository") -public class LKommentarPRepository implements Repository -{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - /** - * The data manager providing database operations. - */ - @Inject - @Named("datamanager") - private Manager manager; - - /** - * The logger for this class. - */ - @Inject - private Logger logger; - - public EntityManager getEntityManager() { - return this.em; - } - - /** - * Filter object list by the given criteria. - * - * @param filter The query filter. - * @return Response object. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - - /** - * Get all objects of type clazzfrom database. - * - * @param clazz The object type. - * @return Response object. - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } - - /** - * Find a single object identified by its id. - * - * @param clazz The object type. - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } - - /** - * Create a new LKommentarP object. - * - * @param object The new object. - * @return Response object. - */ - public Response create(Object object) { - if (!(object instanceof LKommentarP)) { - return new Response(false, 602, object); - } - LKommentarP kommentar = (LKommentarP)object; - Response response = new Response(true, 200, kommentar); - try { - manager.create(kommentar); - return response; - } - catch(EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch(IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch(TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Update a LKommentarP object. - * - * @param object The object to update. - * @return Response object. - */ - public Response update(Object object) { - if (!(object instanceof LKommentarP)) { - return new Response(false, 602, object); - } - LKommentarP kommentar = (LKommentarP)object; - Response response = new Response(true, 200, kommentar); - try { - manager.update(kommentar); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Delete a LKommentarP object. - * - * @param object The object to delete. - * @return Response object. - */ - public Response delete(Object object) { - if (!(object instanceof LKommentarP)) { - return new Response(false, 602, null); - } - LKommentarP kommentar = (LKommentarP)object; - Response response = new Response(true, 200, null); - try { - manager.delete(kommentar); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - return response; - } - - @Override - public Response filter(CriteriaQuery filter, int size, int start) { - return null; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/LMessungRepository.java --- a/src/main/java/de/intevation/lada/data/LMessungRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,221 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; -import java.util.Map; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.TransactionRequiredException; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import de.intevation.lada.manage.Manager; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.rest.Response; -import de.intevation.lada.validation.ValidationException; -import de.intevation.lada.validation.Validator; - -/** - * This Container is an interface to read, write and update LMessung obejcts. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("lmessungrepository") -public class LMessungRepository implements Repository -{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - /** - * The data manager providing database operations. - */ - @Inject - @Named("datamanager") - private Manager manager; - - /** - * The validator used for LMessung objects. - */ - @Inject - @Named("lmessungvalidator") - private Validator validator; - - @Override - public EntityManager getEntityManager() { - return this.em; - } - /** - * Filter object list by the given criteria. - * - * @param filter The query filter. - * @return Response opbject. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - - /** - * Get all objects of type clazzfrom database. - * - * @param clazz The object type. - * @return Response object. - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } - - /** - * Find a single object identified by its id. - * - * @param clazz The object type. - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } - - /** - * Validate and persist a new LMessung object. - * - * @param object The new object - * @return Response object. - */ - public Response create(Object object) { - if (!(object instanceof LMessung)) { - return new Response(false, 602, object); - } - LMessung messung = (LMessung)object; - Response response = new Response(true, 200, messung); - try { - Map warnings = validator.validate(messung, false); - manager.create(messung); - response.setWarnings(warnings); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (ValidationException ve) { - response.setSuccess(false); - response.setMessage(604); - response.setErrors(ve.getErrors()); - response.setWarnings(ve.getWarnings()); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Update a LMessung object. - * - * @param object The object to update - * @return Response object. - */ - public Response update(Object object) { - if (!(object instanceof LMessung)) { - return new Response(false, 602, object); - } - LMessung messung = (LMessung)object; - Response response = new Response(true, 200, messung); - // Try to save the new LProbe. - try { - Map warnings = validator.validate(messung, true); - manager.update(messung); - response.setWarnings(warnings); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (ValidationException ve) { - response.setSuccess(false); - response.setMessage(604); - response.setErrors(ve.getErrors()); - response.setWarnings(ve.getWarnings()); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Delete a LMessung object. - * - * @param object The object to delete. - * @return Response object. - */ - public Response delete(Object object) { - if (!(object instanceof LMessung)) { - return new Response(false, 602, null); - } - LMessung messung = (LMessung)object; - Response response = new Response(true, 200, null); - try { - manager.delete(messung); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - return response; - } - @Override - public Response filter(CriteriaQuery filter, int size, int start) { - return null; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/LMesswertRepository.java --- a/src/main/java/de/intevation/lada/data/LMesswertRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,209 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; -import java.util.Map; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.TransactionRequiredException; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import de.intevation.lada.manage.Manager; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.rest.Response; -import de.intevation.lada.validation.ValidationException; -import de.intevation.lada.validation.Validator; - -/** - * This Container is an interface to read, write and update LMesswert obejcts. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("lmesswertrepository") -public class LMesswertRepository implements Repository -{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - /** - * The data manager providing database operations. - */ - @Inject - @Named("datamanager") - private Manager manager; - - /** - * The validator used for LMesswert. - */ - @Inject - @Named("lmesswertvalidator") - private Validator validator; - - public EntityManager getEntityManager() { - return this.em; - } - /** - * Filter object list by the given criteria. - * - * @param filter The query filter. - * @return Response object. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - - /** - * Get all objects of type clazzfrom database. - * - * @param clazz The object type. - * @return Response object. - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } - - /** - * Find a single object identified by its id. - * - * @param clazz The object type. - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } - - /** - * Create a new LMesswert object. - * - * @param object The new object. - * @return Response object. - */ - public Response create(Object object) { - if (!(object instanceof LMesswert)) { - return new Response(false, 602, object); - } - LMesswert messwert = (LMesswert)object; - Response response = new Response(true, 200, messwert); - try { - Map warnings = validator.validate(messwert, false); - manager.create(messwert); - response.setWarnings(warnings); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - catch (ValidationException e) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Update a LMesswert object. - * - * @param object The object to update. - * @return Response object. - */ - public Response update(Object object) { - if (!(object instanceof LMesswert)) { - return new Response(false, 602, object); - } - LMesswert messwert = (LMesswert)object; - Response response = new Response(true, 200, messwert); - try { - manager.update(messwert); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Delete a LMesswert object. - * - * @param object The object to delete. - * @return Response object. - */ - public Response delete(Object object) { - if (!(object instanceof LMesswert)) { - return new Response(false, 602, null); - } - LMesswert messwert = (LMesswert)object; - Response response = new Response(true, 200, null); - try { - manager.delete(messwert); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - return response; - } - @Override - public Response filter(CriteriaQuery filter, int size, int start) { - return null; - } -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/LOrtRepository.java --- a/src/main/java/de/intevation/lada/data/LOrtRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,223 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; -import java.util.Map; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.TransactionRequiredException; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import de.intevation.lada.manage.Manager; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.rest.Response; -import de.intevation.lada.validation.ValidationException; -import de.intevation.lada.validation.Validator; - -/** - * This Container is an interface to read, write and update LOrt objects. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("lortrepository") -public class LOrtRepository implements Repository -{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - /** - * The validator used for LOrt objects. - */ - @Inject - @Named("lortvalidator") - private Validator validator; - - /** - * The data manager providing database operations. - */ - @Inject - @Named("datamanager") - private Manager manager; - - @Override - public EntityManager getEntityManager() { - return this.em; - } - - /** - * Filter object list by the given criteria. - * - * @param filter The query filter. - * @return Response object. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - /** - * Get all objects of type clazzfrom database. - * - * @param clazz The object type. - * @return Response object. - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } - - /** - * Find a single object identified by its id. - * - * @param clazz The object type. - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } - - /** - * Validate and persist a new LOrt object. - * - * @param object The new object - * @return Response object. - */ - public Response create(Object object) { - if (!(object instanceof LOrt)) { - return new Response(false, 600, object); - } - LOrt ort = (LOrt)object; - Response response = new Response(true, 200, ort); - // Try to save the new LOrt. - try { - Map warnings = validator.validate(ort, false); - manager.create(ort); - response.setWarnings(warnings); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (ValidationException ve) { - response.setSuccess(false); - response.setMessage(604); - response.setErrors(ve.getErrors()); - response.setWarnings(ve.getWarnings()); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Validate and update a LOrt object. - * - * @param object The object to update. - * @return Response object. - */ - public Response update(Object object) { - if (!(object instanceof LOrt)) { - return new Response(false, 600, object); - } - LOrt ort = (LOrt)object; - Response response = new Response(true, 200, ort); - // Try to update a LOrt object. - try { - Map warnings = validator.validate(ort, true); - manager.update(ort); - response.setWarnings(warnings); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (ValidationException ve) { - response.setSuccess(false); - response.setMessage(604); - response.setErrors(ve.getErrors()); - response.setWarnings(ve.getWarnings()); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Delete a LOrt object. - * - * @param object The object to delete. - * @return Response object. - */ - public Response delete(Object object) { - if (!(object instanceof LOrt)) { - return new Response(false, 602, null); - } - LOrt ort = (LOrt)object; - Response response = new Response(true, 200, null); - try { - manager.delete(ort); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - return response; - } - - @Override - public Response filter(CriteriaQuery filter, int size, int start) { - return null; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/LProbeRepository.java --- a/src/main/java/de/intevation/lada/data/LProbeRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,247 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.Query; -import javax.persistence.TransactionRequiredException; -import javax.persistence.criteria.CriteriaQuery; -import javax.ws.rs.core.MultivaluedMap; - -import de.intevation.lada.auth.Authorization; -import de.intevation.lada.manage.Manager; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.LProbeInfo; -import de.intevation.lada.rest.Response; -import de.intevation.lada.validation.ValidationException; -import de.intevation.lada.validation.Validator; - -/** - * This Container is an interface to read, write and update LProbe objects. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("lproberepository") -public class LProbeRepository implements Repository{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - /** - * The data manager providing database operations. - */ - @Inject - @Named("datamanager") - private Manager manager; - - /** - * The validator used for LProbe objects. - */ - @Inject - @Named("lprobevalidator") - private Validator validator; - - @Inject - @Named("dataauthorization") - private Authorization authorization; - - public EntityManager getEntityManager() { - return this.em; - } - - /** - * Filter object list by the given criteria. - * - * @param filter The query filter - * @return Response object. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - public Response filterFree( - String sql, - List filters, - List results, - MultivaluedMap params, - List msts) { - Query query = em.createNativeQuery(sql); - for (String filter: filters) { - List param = params.get(filter); - List clean = new ArrayList(); - for(String p : param) { - clean.add(p.replace(",", "|")); - } - query.setParameter(filter, clean); - } - List result = query.getResultList(); - List> res = new ArrayList>(); - for (Object[] row: result) { - Map set = new HashMap(); - boolean ro = false; - for (int i = 0; i < row.length; i++) { - set.put(results.get(i), row[i]); - if (results.get(i).equals("probeId")) { - if (authorization.isReadOnly((String)row[i])) { - ro = true; - } - } - if (results.get(i).equals("mstId") && - !msts.contains((String)row[i])) { - ro = true; - } - } - set.put("readonly", ro); - res.add(set); - } - return new Response(true, 200, res); - } - - /** - * Get all objects. - * - * @param clazz The object type. (unused) - * @return Response object. - */ - public Response findAll(Class clazz) { - QueryBuilder builder = - new QueryBuilder(this.getEntityManager(), LProbeInfo.class); - builder.distinct(); - return filter(builder.getQuery()); - } - - /** - * Find object identified by its id. - * - * @param clazz The object type.(unused) - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - QueryBuilder builder = - new QueryBuilder(this.getEntityManager(), LProbeInfo.class); - builder.and("probeId", id); - builder.distinct(); - return filter(builder.getQuery()); - } - - /** - * Validate and persist a new LProbe object. - * - * @param object The new LProbe object - * @return Response. - */ - public Response create(Object object) { - if (!(object instanceof LProbe)) { - return new Response(false, 602, object); - } - LProbe probe = (LProbe)object; - Response response = new Response(true, 200, probe); - // Try to save the new LProbe. - try { - Map warnings = validator.validate(probe, false); - manager.persist(probe); - response.setWarnings(warnings); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (ValidationException ve) { - response.setSuccess(false); - response.setMessage(604); - response.setErrors(ve.getErrors()); - response.setWarnings(ve.getWarnings()); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Validate and update a LProbe object. - * - * @param object The object to update. - * @return Response object. - */ - public Response update(Object object) { - if (!(object instanceof LProbe)) { - return new Response(false, 602, object); - } - LProbe probe = (LProbe)object; - Response response = new Response(true, 200, probe); - try { - Map warnings = validator.validate(probe, true); - manager.update(probe); - response.setWarnings(warnings); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (ValidationException ve) { - response.setSuccess(false); - response.setMessage(604); - response.setErrors(ve.getErrors()); - response.setWarnings(ve.getWarnings()); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * This class does not support this operation. - * - * @param object - */ - public Response delete(Object object) { - return null; - } - - @Override - public Response filter(CriteriaQuery filter, int size, int start) { - return null; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/LStatusRepository.java --- a/src/main/java/de/intevation/lada/data/LStatusRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,196 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.TransactionRequiredException; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import de.intevation.lada.manage.Manager; -import de.intevation.lada.model.LStatus; -import de.intevation.lada.rest.Response; - -/** - * This Container is an interface to read, write and update LStatus - * objects from the connected database. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("lstatusrepository") -public class LStatusRepository implements Repository -{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - /** - * The data manager providing database operations. - */ - @Inject - @Named("datamanager") - private Manager manager; - - public EntityManager getEntityManager() { - return this.em; - } - - /** - * Filter object list by the given criteria. - * - * @param filter The query filter. - * @return Response object. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - - /** - * Get all objects of type clazzfrom database. - * - * @param clazz The object type. - * @return Response object. - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } - - /** - * Find a single object identified by its id. - * - * @param clazz The object type. - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } - - /** - * Create a new LStatus object. - * - * @param object The new object. - * @return Response object. - */ - public Response create(Object object) { - if (!(object instanceof LStatus)) { - return new Response(false, 602, object); - } - LStatus status = (LStatus)object; - Response response = new Response(true, 200, status); - try { - manager.create(status); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Update a Lstatus object. - * - * @param object The object to update. - * @return Response object. - */ - public Response update(Object object) { - if (!(object instanceof LStatus)) { - return new Response(false, 602, object); - } - LStatus status = (LStatus)object; - Response response = new Response(true, 200, status); - try { - manager.update(status); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Delete a LStatus object. - * - * @param object The object to delete. - * @return Response object. - */ - public Response delete(Object object) { - if (!(object instanceof LStatus)) { - return new Response(false, 602, null); - } - LStatus status = (LStatus)object; - Response response = new Response(true, 200, null); - try { - manager.delete(status); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - return response; - } - - @Override - public Response filter(CriteriaQuery filter, int size, int start) { - return null; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/LZusatzwertRepository.java --- a/src/main/java/de/intevation/lada/data/LZusatzwertRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,207 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.TransactionRequiredException; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import de.intevation.lada.manage.Manager; -import de.intevation.lada.model.LZusatzWert; -import de.intevation.lada.model.LZusatzWertId; -import de.intevation.lada.rest.Response; - -/** - * This Container is an interface to read, write and update LZusatzWert - * objects from the connected database. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("lzusatzwertrepository") -public class LZusatzwertRepository implements Repository -{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - /** - * The data manager providing database operations. - */ - @Inject - @Named("datamanager") - private Manager manager; - - public EntityManager getEntityManager() { - return this.em; - } - - /** - * Filter object list by the given criteria. - * - * @param filter The query filter. - * @return Response object. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - - /** - * Get all objects of type clazzfrom database. - * - * @param clazz The object type. - * @return Response object. - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } - - /** - * Find a single object identified by its id. - * - * @param clazz The object type. - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } - - /** - * Create a new LZusatzwert object. - * - * @param object The new object. - * @return Response object. - */ - public Response create(Object object) { - if (!(object instanceof LZusatzWert)) { - return new Response(false, 602, object); - } - LZusatzWert zusatzwert = (LZusatzWert)object; - LZusatzWertId id = - new LZusatzWertId( - zusatzwert.getProbeId(), - zusatzwert.getPzsId()); - zusatzwert.setId(id); - Response response = new Response(true, 200, zusatzwert); - // Try to save the new LProbe. - try { - manager.create(zusatzwert); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Update a LZusatzwert object. - * - * @param object The object to update. - * @return Response object. - */ - public Response update(Object object) { - if (!(object instanceof LZusatzWert)) { - return new Response(false, 602, object); - } - LZusatzWert zusatzwert = (LZusatzWert)object; - LZusatzWertId id = new LZusatzWertId( - zusatzwert.getProbeId(), - zusatzwert.getPzsId()); - zusatzwert.setId(id); - Response response = new Response(true, 200, zusatzwert); - try { - manager.update(zusatzwert); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Delete a LZusatzwert object. - * - * @param object The object to delete. - * @return Response object. - */ - public Response delete(Object object) { - if (!(object instanceof LZusatzWert)) { - return new Response(false, 602, null); - } - LZusatzWert zusatzwert = (LZusatzWert)object; - Response response = new Response(true, 200, null); - try { - manager.delete(zusatzwert); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - return response; - } - - @Override - public Response filter(CriteriaQuery filter, int size, int start) { - return null; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/OrtRepository.java --- a/src/main/java/de/intevation/lada/data/OrtRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,189 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.TransactionRequiredException; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import de.intevation.lada.manage.Manager; -import de.intevation.lada.model.Ort; -import de.intevation.lada.rest.Response; - -/** - * Repository that allows read, write and update operations on 'Ort' objects. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("ortrepository") -public class OrtRepository implements Repository -{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - /** - * THe data manager providing database operations. - */ - @Inject - @Named("datamanager") - private Manager manager; - - public EntityManager getEntityManager() { - return this.em; - } - - /** - * Filter object list by the given criteria. - * - * @param filter The query filter. - * @return Response object. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - - /** - * Get all objects of type clazzfrom database. - * - * @param clazz The object type. - * @return Response object - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } - - /** - * Find a single object identified by its id. - * - * @param clazz The object type. - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } - - /** - * Create a new 'Ort' object. - * - * @param object The new object. - * @return Response object. - */ - public Response create(Object object) { - if (!(object instanceof Ort)) { - return new Response(false, 602, object); - } - Ort ort = (Ort)object; - try { - manager.persist(ort); - int id = ort.getOrtId(); - ort.setBezeichnung("D_ " + String.format("%05d", id)); - manager.update(ort); - return new Response(true, 200, ort); - } - catch(EntityExistsException eee) { - return new Response(false, 601, ort); - } - catch(IllegalArgumentException iae) { - return new Response(false, 602, ort); - } - catch(TransactionRequiredException tre) { - return new Response(false, 603, ort); - } - } - - /** - * Update a 'Ort' object. - * - * @param object The object to update. - * @return Response object. - */ - public Response update(Object object) { - if (!(object instanceof Ort)) { - return new Response(false, 602, object); - } - Ort ort = (Ort)object; - Response response = new Response(true, 200, ort); - try { - manager.update(ort); - return response; - } - catch (EntityExistsException eee) { - response.setSuccess(false); - response.setMessage(601); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - catch (EJBTransactionRolledbackException te) { - response.setSuccess(false); - response.setMessage(604); - } - return response; - } - - /** - * Delete a 'Ort' object. - * - * @param object The object to delete. - * @return Response object. - */ - public Response delete(Object object) { - if (!(object instanceof Ort)) { - return new Response(false, 602, null); - } - Ort ort = (Ort)object; - Response response = new Response(true, 200, null); - try { - manager.delete(ort); - } - catch (IllegalArgumentException iae) { - response.setSuccess(false); - response.setMessage(602); - } - catch (TransactionRequiredException tre) { - response.setSuccess(false); - response.setMessage(603); - } - return response; - } - - @Override - public Response filter(CriteriaQuery filter, int size, int start) { - return null; - } -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/QueryBuilder.java --- a/src/main/java/de/intevation/lada/data/QueryBuilder.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,234 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; - -/** - * @author Raimund Renkert - */ -public class QueryBuilder -{ - private EntityManager manager; - private CriteriaBuilder builder; - private CriteriaQuery query; - private Root root; - private Class clazz; - private Predicate filter; - - /** - * Create a new QueryBuilder for the specified class. - * - * @param manager - * @param clazz - */ - public QueryBuilder(EntityManager manager, Class clazz) { - this.manager = manager; - this.clazz = clazz; - this.builder = this.manager.getCriteriaBuilder(); - this.query = this.builder.createQuery(this.clazz); - this.root = this.query.from(this.clazz); - } - - /** - * Get the criteria query build with this class. - * - * @return The query. - */ - public CriteriaQuery getQuery() { - this.query.where(this.filter); - return this.query; - } - - /** - * Logical AND operation. - * - * @param id The database column name. - * @param value The filter value - * @return The builder itself. - */ - public QueryBuilder and(String id, Object value) { - Predicate p = this.builder.equal(this.root.get(id), value); - if (this.filter != null) { - this.filter = this.builder.and(this.filter, p); - } - else { - this.filter = this.builder.and(p); - } - return this; - } - - /** - * Logical AND with like operation. - * - * @param id The database column name. - * @param value The filter value - * @return The builder itself. - */ - public QueryBuilder andLike(String id, String value) { - Path path = this.root.get(id); - Predicate p = this.builder.like(path, value); - if (this.filter != null) { - this.filter = this.builder.and(this.filter, p); - } - else { - this.filter = this.builder.and(p); - } - return this; - } - - /** - * Logical OR operation. - * - * @param id The database column name - * @param value The filter value. - * @return The builder itself. - */ - public QueryBuilder or(String id, Object value) { - Predicate p = this.builder.equal(this.root.get(id), value); - if (this.filter != null) { - this.filter = this.builder.or(this.filter, p); - } - else { - this.filter = this.builder.or(p); - } - return this; - } - - /** - * Logical OR with like operation. - * - * @param column The database column name. - * @param value The filter value - * @return The builder itself. - */ - public QueryBuilder orLike(String id, String value) { - Path path = this.root.get(id); - Predicate p = this.builder.like(path, value); - if (this.filter != null) { - this.filter = this.builder.or(this.filter, p); - } - else { - this.filter = this.builder.or(p); - } - return this; - } - - /** - * Logical AND operation. - * All elements in values will be concatenated with AND operator. - * - * @param id The database column name. - * @param values List of values. - * @return The builder itself. - */ - public QueryBuilder and(String id, List values) { - for(String v: values) { - this.and(id, v); - } - return this; - } - - /** - * Logical OR operation. - * All elements in values will be concatenated with OR operator. - * - * @param id The database column name. - * @param values List of values. - * @return The builder itself. - */ - public QueryBuilder or(String id, List values) { - for (String v: values) { - this.or(id, v); - } - return this; - } - - /** - * Logical AND operation. - * The actually defined query will be concatenated with the query defined - * in the builder b. - * - * @param b A builder. - * @return The builder itself. - */ - public QueryBuilder and(QueryBuilder b) { - if (b == null || b.filter == null) { - return this; - } - if (this.filter != null) { - this.filter = this.builder.and(this.filter, b.filter); - } - else { - this.filter = this.builder.and(b.filter); - } - return this; - } - - /** - * Logical OR operation. - * The actually defined query will be concatenated with the query defined - * in the builder b. - * - * @param b A builder. - * @return The builder itself. - */ - public QueryBuilder or(QueryBuilder b) { - if (b == null || b.filter == null) { - return this; - } - if (this.filter != null) { - this.filter = this.builder.or(this.filter, b.filter); - } - else { - this.filter = this.builder.or(b.filter); - } - return this; - } - - /** - * Use 'distinct' in the query. - */ - public void distinct() { - this.query.distinct(true); - } - - /** - * Order result by the specified column name - * - * @param id The column name. - * @param asc Ascending(true), Descending(false). - */ - public void orderBy(String id, boolean asc) { - if (asc) { - this.query.orderBy(this.builder.asc(this.root.get(id))); - } - else { - this.query.orderBy(this.builder.desc(this.root.get(id))); - } - } - - /** - * Get an empty instance of this builder to create subfilters. - * - * @return An empty instance of this builder. - */ - public QueryBuilder getEmptyBuilder(){ - QueryBuilder copy = new QueryBuilder(manager, clazz); - copy.builder = this.builder; - copy.root = this.root; - return copy; - } -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/ReadOnlyRepository.java --- a/src/main/java/de/intevation/lada/data/ReadOnlyRepository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import java.util.List; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; - -import de.intevation.lada.rest.Response; - -/** - * Repository that allows read only access to model objects. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("readonlyrepository") -public class ReadOnlyRepository implements Repository -{ - /** - * The entitymanager managing the data. - */ - @Inject - private EntityManager em; - - public EntityManager getEntityManager() { - return this.em; - } - - /** - * Filter object list by the given criteria. - * - * @param filter The filter query. - * @return Response object. - */ - public Response filter(CriteriaQuery filter) { - List result = em.createQuery(filter).getResultList(); - return new Response(true, 200, result); - } - - /** - * Filter object list by the given criteria. - * - * @param filter The filter query. - * @return Response object. - */ - public Response filter(CriteriaQuery filter, int size, int start) { - List result = em.createQuery(filter).getResultList(); - if (size > 0 && start > -1) { - List newList = result.subList(start, size + start); - return new Response(true, 200, newList, result.size()); - } - return new Response(true, 200, result); - } - - /** - * Get all objects of type clazzfrom database. - * - * @param clazz The object type. - * @return Response object. - */ - public Response findAll(Class clazz) { - CriteriaBuilder builder = em.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(clazz); - Root member = criteria.from(clazz); - criteria.select(member); - List result = em.createQuery(criteria).getResultList(); - return new Response(true, 200, result); - } - - /** - * Find a single object identified by its id. - * - * @param clazz The object type. - * @param id The object id. - * @return Response object. - */ - public Response findById(Class clazz, String id) { - T item = em.find(clazz, id); - if (item == null) { - return new Response(false, 600, null); - } - return new Response(true, 200, item); - } - - /** - * This class does not support this operation. - * - * @param object - */ - public Response create(Object object) { - return null; - } - - /** - * This class does not support this operation. - * - * @param object - */ - public Response update(Object object) { - return null; - } - - /** - * This class does not support this operation. - * - * @param object - */ - public Response delete(Object object) { - return null; - } -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/Repository.java --- a/src/main/java/de/intevation/lada/data/Repository.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data; - -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaQuery; - -import de.intevation.lada.rest.Response; - -/** - * This generic Container is an interface to request and select Data - * obejcts from the connected database. - * - * @author Raimund Renkert - */ -public interface Repository -{ - public Response create(Object object); - - public Response update(Object object); - - public Response delete(Object object); - - public Response filter(CriteriaQuery filter); - - public Response filter(CriteriaQuery filter, int size, int start); - - public Response findAll(Class clazz); - - public Response findById(Class clazz, String id); - - public EntityManager getEntityManager(); -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/exporter/Creator.java --- a/src/main/java/de/intevation/lada/data/exporter/Creator.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.exporter; - - -/** - * - * @author Raimund Renkert - */ -public interface Creator -{ - public String create(String probeId); -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/exporter/Exporter.java --- a/src/main/java/de/intevation/lada/data/exporter/Exporter.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.exporter; - -import java.io.InputStream; -import java.util.List; - -import de.intevation.lada.auth.AuthenticationResponse; - - -public interface Exporter -{ - public InputStream export(List proben, AuthenticationResponse auth); -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/exporter/LAFCreator.java --- a/src/main/java/de/intevation/lada/data/exporter/LAFCreator.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,374 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.exporter; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; - -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LKommentarM; -import de.intevation.lada.model.LKommentarP; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.LProbeInfo; -import de.intevation.lada.model.LZusatzWert; -import de.intevation.lada.model.Ort; -import de.intevation.lada.model.SKoordinatenArt; -import de.intevation.lada.model.SMessEinheit; -import de.intevation.lada.model.SMessgroesse; -import de.intevation.lada.model.SProbenZusatz; -import de.intevation.lada.model.SProbenart; -import de.intevation.lada.rest.Response; - -/** - * This creator produces a LAF conform String containing all information about - * a single {@link LProbe} object including subobjects like - * {@link LMessung}, {@link LMesswert}, {@link LKommentarP}... - * - * @author Raimund Renkert - */ -@Named("lafcreator") -public class LAFCreator -implements Creator -{ - - @Inject - @Named("lproberepository") - private Repository proben; - - @Inject - @Named("lmessungrepository") - private Repository messungRepo; - - @Inject - @Named("lortrepository") - private Repository ortRepo; - - @Inject - @Named("lmessungrepository") - private Repository messwertRepo; - - @Inject - @Named("lkommentarmrepository") - private Repository mkommentarRepo; - - @Inject - @Named("lkommentarRepository") - private Repository pkommentarRepo; - - @Inject - @Named("lzusatzwertrepository") - private Repository zusatzwertRepo; - - @Inject - @Named("readonlyrepository") - private Repository readonlyRepo; - - /** - * Create the LAF conform String. - * - * @param probeId The {@link LProbe} id. - */ - @Override - public String create(String probeId) { - String lafProbe = "%PROBE%\n"; - lafProbe += probeToLAF(probeId); - return lafProbe; - } - - /** - * Find the {@link LProbe} object and produce the LAF conform string. - * @param probeId The {@link LProbe} id. - * @return LAF conform string. - */ - private String probeToLAF(String probeId) { - Response found = this.proben.findById(LProbe.class, probeId); - if (found.getData() == null) { - return null; - } - ArrayList aProbe = (ArrayList)found.getData(); - LProbeInfo probe = aProbe.get(0); - String lafProbe = writeAttributes(probe); - return lafProbe; - } - - /** - * Write the attributes and subobjects. - * - * @param probe The {@link LProbeInfo} object. - * @return LAF conform string. - */ - private String writeAttributes(LProbeInfo probe) { - DateFormat format = new SimpleDateFormat("yyyyMMdd HHmm"); - QueryBuilder kommBuilder = - new QueryBuilder( - pkommentarRepo.getEntityManager(), LKommentarP.class); - kommBuilder.and("probeId", probe.getProbeId()); - Response kommentar = mkommentarRepo.filter(kommBuilder.getQuery()); - List kommentare = (List)kommentar.getData(); - - QueryBuilder artBuilder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SProbenart.class); - artBuilder.and("probenartId", probe.getProbenartId()); - Response art = readonlyRepo.filter(artBuilder.getQuery()); - List probenart = (List)art.getData(); - - QueryBuilder zusatzBuilder = - new QueryBuilder( - zusatzwertRepo.getEntityManager(), LZusatzWert.class); - zusatzBuilder.and("probeId", probe.getProbeId()); - Response zusatz = zusatzwertRepo.filter(zusatzBuilder.getQuery()); - List zusatzwerte = (List)zusatz.getData(); - - String laf = ""; - laf += probe.getDatenbasisId() == null ? - "": lafLine("DATENBASIS_S", probe.getDatenbasisId().toString()); - laf += probe.getNetzbetreiberId() == null ? - "" : lafLine("NETZKENNUNG", probe.getNetzbetreiberId()); - laf += probe.getMstId() == null ? - "" : lafLine("MESSSTELLE", probe.getMstId()); - laf += lafLine("PROBE_ID", probe.getProbeId()); - laf += lafLine("HAUPTPROBENNUMMER", probe.getHauptprobenNr()); - laf += probe.getBaId() == null ? - "" : lafLine("MESSPROGRAMM_S", "\"" + probe.getBaId() + "\""); - laf += probe.getProbenartId() == null ? - "" : lafLine("PROBENART", - "\"" + probenart.get(0).getProbenart() + "\""); - laf += probe.getSolldatumBeginn() == null ? - "" : lafLine("SOLL_DATUM_UHRZEIT_A", - format.format(probe.getSolldatumBeginn())); - laf += probe.getSolldatumEnde() == null ? - "" : lafLine("SOLL_DATUM_UHRZEIT_E", - format.format(probe.getSolldatumEnde())); - laf += probe.getProbeentnahmeBeginn() == null ? - "" : lafLine("PROBENAHME_DATUM_UHRZEIT_A", - format.format(probe.getProbeentnahmeBeginn())); - laf += probe.getProbeentnahmeEnde() == null ? - "" : lafLine("PROBENAHME_DATUM_UHRZEIT_E", - format.format(probe.getProbeentnahmeEnde())); - laf += probe.getUmwId() == null ? - "" : lafLine("UMWELTBEREICH_S", probe.getUmwId()); - laf += probe.getMedia() == null ? - "" : lafLine("MEDIUM", "\"" + probe.getMedia() + "\""); - laf += probe.getMediaDesk() == null ? - "" : lafLine("DESKRIPTOREN", "\"" + probe.getMediaDesk() + "\""); - laf += probe.getTest() == Boolean.TRUE ? - lafLine("TESTDATEN", "1") : lafLine("TESTDATEN", "0"); - for (LZusatzWert zw : zusatzwerte) { - laf += writeZusatzwert(zw); - } - for (LKommentarP kp : kommentare) { - laf += writeKommentar(kp); - } - laf += writeMessung(probe); - laf += writeOrt(probe); - return laf; - } - - /** - * Write {@link LZusatzWert} attributes. - * - * @param zw The {@link LZusatzWert}. - * @return Single LAF line. - */ - private String writeZusatzwert(LZusatzWert zw) { - QueryBuilder builder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SProbenZusatz.class); - builder.and("pzsId", zw.getPzsId()); - List zusaetze = - (List)readonlyRepo.filter(builder.getQuery()); - - String value = "\"" + zusaetze.get(0).getBeschreibung() + "\""; - value += " " + zw.getMesswertPzs(); - value += " " + zusaetze.get(0).getMehId(); - value += " " + zw.getMessfehler(); - return lafLine("PZB_S", value); - } - - /** - * Write {@link LOrt} attributes. - * - * @param probe The {@link LProbeInfo} object. - * @return LAF conform string - */ - private String writeOrt(LProbeInfo probe) { - QueryBuilder builder = - new QueryBuilder( - ortRepo.getEntityManager(), - LOrt.class); - builder.and("probeId", probe.getProbeId()); - Response objects = ortRepo.filter(builder.getQuery()); - List orte = (List)objects.getData(); - - String laf = ""; - for(LOrt o : orte) { - laf += "%ORT%\n"; - QueryBuilder oBuilder = - new QueryBuilder( - readonlyRepo.getEntityManager(), Ort.class); - oBuilder.and("ortId", o.getOrtId()); - Response resp = readonlyRepo.filter(oBuilder.getQuery()); - List ort = (List)resp.getData(); - laf += lafLine("ORT_CODE", - "\"" + ort.get(0).getBezeichnung() + "\""); - laf += lafLine("ORT_TYP", "\"" + o.getOrtsTyp() + "\""); - laf += o.getOrtszusatztext() == null ? "": - lafLine("ORT_ZUSATZTEXT", "\"" + o.getOrtszusatztext() + "\""); - laf += lafLine("ORT_LAND_S", String.valueOf(ort.get(0).getStaatId())); - QueryBuilder kaBuilder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SKoordinatenArt.class); - String koord = ""; - koord += "05 "; - koord += ort.get(0).getLatitude() + " "; - koord += ort.get(0).getLongitude(); - //TODO: use table koordinatenart and koord*extern! - laf += lafLine("ORT_KOORDINATEN_S", koord); - laf += lafLine("ORT_GEMEINDESCHLUESSEL", ort.get(0).getGemId()); - } - return laf; - } - - /** - * Write {@link LKommentarP} attributes. - * - * @param kp The {@link LKommentarP} object. - * @return Single LAF line. - */ - private String writeKommentar(LKommentarP kp) { - DateFormat format = new SimpleDateFormat("yyyyMMdd HHmm"); - String value = "\"" + kp.getErzeuger() + "\" " + - format.format(kp.getKDatum()) + " " + - "\"" + kp.getKText() + "\""; - return lafLine("PROBENKOMMENTAR", value); - } - - /** - * Write {@link LMessung} attributes. - * - * @param probe The {@link LProbeInfo} object. - * @return LAF conform string. - */ - private String writeMessung(LProbeInfo probe) { - DateFormat format = new SimpleDateFormat("yyyyMMdd HHmm"); - // Get all messungen - QueryBuilder builder = - new QueryBuilder( - messungRepo.getEntityManager(), - LMessung.class); - builder.and("probeId", probe.getProbeId()); - Response objects = messungRepo.filter(builder.getQuery()); - List mess = (List)objects.getData(); - - String laf = ""; - for(LMessung m : mess) { - laf += "%MESSUNG%\n"; - QueryBuilder wertBuilder = - new QueryBuilder( - messwertRepo.getEntityManager(), LMesswert.class); - wertBuilder.and("probeId", probe.getProbeId()).and("messungsId", m.getMessungsId()); - Response messw = messwertRepo.filter(wertBuilder.getQuery()); - List werte = (List)messw.getData(); - QueryBuilder kommBuilder = - new QueryBuilder( - mkommentarRepo.getEntityManager(), LKommentarM.class); - kommBuilder.and("probeId", probe.getProbeId()).and("messungsId", m.getMessungsId()); - Response kommentar = mkommentarRepo.filter(kommBuilder.getQuery()); - List kommentare = (List)kommentar.getData(); - laf += lafLine("MESSUNGS_ID", m.getMessungsId().toString()); - laf += lafLine("NEBENPROBENNUMMER", m.getNebenprobenNr()); - laf += m.getMesszeitpunkt() == null ? - "" : lafLine( - "MESS_DATUM_UHRZEIT", - format.format(m.getMesszeitpunkt())); - laf += m.getMessdauer() == null ? - "" : lafLine("MESSZEIT_SEKUNDEN", m.getMessdauer().toString()); - laf += m.getMmtId() == null ? - "" : lafLine("MESSMETHODE_S", m.getMmtId()); - for (LMesswert mw : werte) { - laf += writeMesswert(mw); - } - for (LKommentarM mk: kommentare) { - laf += writeKommentar(mk); - } - } - return laf; - } - - /** - * Write {@link LKommentarM} attributes. - * @param mk The {@link LKommentarM} object. - * @return Single LAF line. - */ - private String writeKommentar(LKommentarM mk) { - DateFormat format = new SimpleDateFormat("yyyyMMdd HHmm"); - String value = "\"" + mk.getErzeuger() + "\" " + - format.format(mk.getKDatum()) + " " + - "\"" + mk.getKText() + "\""; - return lafLine("KOMMENTAR", value); - } - - /** - * Write {@link LMesswert} attributes. - * @param mw The {@link LMesswert} object. - * @return Single LAF line. - */ - private String writeMesswert(LMesswert mw) { - QueryBuilder builder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SMessgroesse.class); - builder.and("messgroesseId", mw.getMessgroesseId()); - Response r = readonlyRepo.filter(builder.getQuery()); - List sm = (List)r.getData(); - QueryBuilder einheitBuilder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SMessEinheit.class); - einheitBuilder.and("mehId", mw.getMehId()); - Response re = readonlyRepo.filter(einheitBuilder.getQuery()); - List me = (List)re.getData(); - String value = "\"" + sm.get(0).getMessgroesse() + "\""; - if (mw.getGrenzwertueberschreitung() != null && - !mw.getGrenzwertueberschreitung()) { - value += " <"; - } - else { - value += " "; - } - value += mw.getMesswert(); - value += " \"" + me.get(0).getEinheit() + "\""; - value += mw.getMessfehler() == null ? " NULL" : " " + mw.getMessfehler(); - value += mw.getNwgZuMesswert() == null ? " NULL" : " " + mw.getNwgZuMesswert(); - value += mw.getGrenzwertueberschreitung() == null ? " N" : - mw.getGrenzwertueberschreitung() ? " Y" : " N"; - return lafLine("MESSWERT", value); - } - - /** - * Write a single LAF conform line from key and value. - * - * @param key The key. - * @param value The value. - * @return LAF conform line. - */ - private String lafLine(String key, String value) { - for (int i = key.length(); i < 30; i++) { - key += " "; - } - return key + value + "\n"; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/exporter/LAFExporter.java --- a/src/main/java/de/intevation/lada/data/exporter/LAFExporter.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.exporter; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; - -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.model.LProbe; - -/** -* The LAF exporter implements {@link Exporter} to produce a LAF file. -* -* @author Raimund Renkert -*/ -@Named("lafexporter") -public class LAFExporter -implements Exporter -{ - - @Inject - @Named("lafcreator") - private Creator creator; - - /** - * Export the {@link LProbe} objects. - * - * @param proben List of probe ids. - * @param auth The authentication information. - * @return InputStream with the LAF data. - */ - @Override - public InputStream export( - List proben, - AuthenticationResponse auth - ) { - String laf = ""; - for (String probeId: proben) { - laf += creator.create(probeId); - } - InputStream in = new ByteArrayInputStream(laf.getBytes()); - try { - in.close(); - } - catch (IOException e) { - //TODO Exception handling. - } - return in; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/AttributeMapper.java --- a/src/main/java/de/intevation/lada/data/importer/AttributeMapper.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,554 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.ejb.Stateless; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityManager; - -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LKommentarM; -import de.intevation.lada.model.LKommentarP; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMessungId; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.LProbeInfo; -import de.intevation.lada.model.LZusatzWert; -import de.intevation.lada.model.SDatenbasis; -import de.intevation.lada.model.SMessEinheit; -import de.intevation.lada.model.SMessgroesse; -import de.intevation.lada.model.SProbenZusatz; -import de.intevation.lada.model.SProbenart; -import de.intevation.lada.model.SUmwelt; -import de.intevation.lada.rest.Response; - -/** - * The AttributeMapper is used to set object attributes via string based - * key value pairs. The key represents a member of an entity object. - * - * @author Raimund Renkert - */ -@Stateless -public class AttributeMapper -{ - @Inject - private EntityManager em; - - @Inject - @Named("lproberepository") - private Repository probeRepo; - - @Inject - @Named("ortrepository") - private Repository ortRepo; - - @Inject - @Named("readonlyrepository") - private Repository sRepository; - - private List warnings; - private List errors; - - /** - * Default constructor to create a new AttributeMapper object. - */ - public AttributeMapper() { - this.warnings = new ArrayList(); - this.errors = new ArrayList(); - } - - /** - * Add an attribute to the given LProbe object. - * - * @param key The key mapping to a object member. - * @param value The value to set. - * @param probe The entity object. - * @return The updated entity object. - */ - public LProbe addAttribute(String key, Object value, LProbe probe) { - DateFormat format = new SimpleDateFormat("yyyyMMdd HHmm"); - if ("datenbasis_s".equals(key) && probe.getDatenbasisId() == null) { - Integer v = Integer.valueOf(value.toString()); - probe.setDatenbasisId(v); - } - else if ("datenbasis_s".equals(key) && probe.getDatenbasisId() != null){ - this.warnings.add(new ReportData(key, value.toString(), 672)); - } - - if ("datenbasis".equals(key) && probe.getDatenbasisId() == null) { - QueryBuilder builder = - new QueryBuilder( - this.sRepository.getEntityManager(), SDatenbasis.class); - builder.and("datenbasis", value.toString()); - Response response = sRepository.filter(builder.getQuery()); - List datenbasis = (List)response.getData(); - Integer v = Integer.valueOf(datenbasis.get(0).getDatenbasisId()); - probe.setDatenbasisId(v); - } - else if ("datenbasis".equals(key) && probe.getDatenbasisId() != null){ - this.warnings.add(new ReportData(key, value.toString(), 672)); - } - - if ("probe_id".equals(key)) { - Response response = - probeRepo.findById(LProbeInfo.class, value.toString()); - List info = (List)response.getData(); - if (info != null && info.size() > 0) { - errors.add(new ReportData("probe_id", value.toString(), 671)); - return null; - } - probe.setProbeId(value.toString()); - } - - if ("hauptprobennummer".equals(key)) { - probe.setHauptprobenNr(value.toString()); - } - - if ("mpr_id".equals(key)) { - Integer v = Integer.valueOf(value.toString()); - probe.setMprId(v); - } - - if ("netzkennung".equals(key)) { - probe.setNetzbetreiberId(value.toString()); - } - - if ("messstelle".equals(key)) { - probe.setMstId(value.toString()); - } - - if ("messprogramm_s".equals(key) && probe.getBaId() == null) { - probe.setBaId(value.toString()); - } - else if ("messprogramm_s".equals(key) && probe.getBaId() != null){ - this.warnings.add(new ReportData(key, value.toString(), 672)); - } - - if ("soll_datum_uhrzeit_a".equals(key)) { - try { - Date d = format.parse(value.toString()); - probe.setSolldatumBeginn(d); - } - catch (ParseException e) { - this.warnings.add(new ReportData(key, value.toString(), 674)); - } - } - if ("soll_datum_uhrzeit_e".equals(key)) { - try { - Date d = format.parse(value.toString()); - probe.setSolldatumEnde(d); - } - catch (ParseException e) { - this.warnings.add(new ReportData(key, value.toString(), 674)); - } - } - if ("probenahme_datum_uhrzeit_a".equals(key)) { - try { - Date d = format.parse(value.toString()); - probe.setProbeentnahmeBeginn(d); - } - catch (ParseException e) { - this.warnings.add(new ReportData(key, value.toString(), 674)); - } - } - if ("probenahme_datum_uhrzeit_e".equals(key)) { - try { - Date d = format.parse(value.toString()); - probe.setProbeentnahmeEnde(d); - } - catch (ParseException e) { - this.warnings.add(new ReportData(key, value.toString(), 674)); - } - } - - if ("umweltbereich_s".equals(key) && probe.getUmwId() == null) { - probe.setUmwId(value.toString()); - } - else if ("umweltbereich_s".equals(key) && probe.getUmwId() != null){ - this.warnings.add(new ReportData(key, value.toString(), 672)); - } - if ("umweltbereich_c".equals(key) && probe.getUmwId() == null) { - QueryBuilder builder = - new QueryBuilder( - sRepository.getEntityManager(), SUmwelt.class); - int length = value.toString().length() > 80 ? 80 : value.toString().length(); - builder.and("umweltBereich", value.toString().substring(0, length)); - Response response = sRepository.filter(builder.getQuery()); - List umw = (List)response.getData(); - probe.setUmwId(umw.get(0).getUmwId()); - } - else if ("umweltbereich_c".equals(key) && probe.getUmwId() != null){ - this.warnings.add(new ReportData(key, value.toString(), 672)); - } - - if ("deskriptoren".equals(key)) { - probe.setMediaDesk(value.toString()); - } - - if ("testdaten".equals(key)) { - if (!value.toString().equals("0")) { - probe.setTest(true); - } - else { - probe.setTest(false); - } - } - - if ("medium".equals(key)) { - probe.setMedia(value.toString()); - } - - if ("probenart".equals(key)) { - QueryBuilder builder = - new QueryBuilder( - sRepository.getEntityManager(), SProbenart.class); - builder.and("probenart", value.toString()); - Response response = sRepository.filter(builder.getQuery()); - List art = (List)response.getData(); - probe.setProbenartId(Integer.valueOf(art.get(0).getProbenartId())); - } - return probe; - } - - /** - * Add an attribute to the given LKommentarP object. - * - * @param key The key mapping to a object member. - * @param value The value to set. - * @param kommentar The entity object. - * @return The updated entity object. - */ - public LKommentarP addAttribute( - String key, - Object value, - LKommentarP kommentar - ) { - DateFormat format = new SimpleDateFormat("yyyyMMdd HHmm"); - String v = value.toString(); - String erzeuger = v.substring(1, 5); - String date = v.substring(8, 21); - Date d; - try { - d = format.parse(date); - kommentar.setKDatum(d); - } - catch (ParseException e) { - this.warnings.add(new ReportData(key, value.toString(), 674)); - } - String text = v.substring(23, v.length() -1); - kommentar.setErzeuger(erzeuger); - kommentar.setKText(text); - return kommentar; - } - - /** - * Add an attribute to the given LKommentarM object. - * - * @param key The key mapping to a object member. - * @param value The value to set. - * @param kommentar The entity object. - * @return The updated entity object. - */ - public LKommentarM addAttribute( - String key, - Object value, - LKommentarM kommentar - ) { - DateFormat format = new SimpleDateFormat("yyyyMMdd HHmm"); - String v = value.toString(); - String erzeuger = v.substring(1, 5); - String date = v.substring(8, 21); - Date d; - try { - d = format.parse(date); - kommentar.setKDatum(d); - } - catch (ParseException e) { - this.warnings.add(new ReportData(key, value.toString(), 674)); - } - String text = v.substring(23, v.length() -1); - kommentar.setErzeuger(erzeuger); - kommentar.setKText(text); - return kommentar; - } - - /** - * Add an attribute to the given LMessung object. - * - * @param key The key mapping to a object member. - * @param value The value to set. - * @param messung The entity object. - * @return The updated entity object. - */ - public LMessung addAttribute( - String key, - Object value, - LMessung messung - ) { - DateFormat format = new SimpleDateFormat("yyyyMMdd HHmm"); - if ("messungs_id".equals(key)) { - LMessungId id = messung.getId(); - Integer v = Integer.valueOf(value.toString()); - id.setMessungsId(v); - messung.setMessungsId(v); - messung.setId(id); - } - else if ("nebenprobennummer".equals(key)) { - messung.setNebenprobenNr(value.toString()); - } - else if ("mess_datum_uhrzeit".equals(key)) { - try { - Date d = format.parse(value.toString()); - messung.setMesszeitpunkt(d); - } - catch (ParseException e) { - this.warnings.add(new ReportData(key, value.toString(), 674)); - } - } - else if ("messzeit_sekunden".equals(key)) { - Integer i = Integer.valueOf(value.toString()); - messung.setMessdauer(i); - } - else if ("messmethode_s".equals(key)) { - messung.setMmtId(value.toString()); - } - else if ("bearbeitungsstatus".equals(key)) { - //ignored.!? - } - else if ("erfassung_abgeschlossen".equals(key)) { - if(!value.toString().equals("0")) { - messung.setFertig(true); - } - else { - messung.setFertig(false); - } - } - return messung; - } - - /** - * Add an attribute to the given LMesswert object. - * - * @param key The key mapping to a object member. - * @param value The value to set. - * @param messwert The entity object. - * @return The updated entity object. - */ - public LMesswert addAttribute( - String key, - Object value, - LMesswert messwert - ) { - Pattern p = Pattern.compile( - "(\".+\")( .+ )(\".+\")( .*)( .{1,12})( .{1,9})(.{0,9})(.{0,3})"); - //TODO Does not perfectly match... Use better matching for floats. - Matcher m = p.matcher(value.toString()); - if (m.matches()) { - String messgroesse = m.group(1).substring(1, m.group(1).length() - 1); - String wert = m.group(2); - String einheit = m.group(3).substring(1, m.group(3).length() - 1); - if (wert.startsWith(" <")) { - wert = wert.substring(2); - messwert.setGrenzwertueberschreitung(false); - } - else if (wert.startsWith(" >")) { - wert = wert.substring(2); - messwert.setGrenzwertueberschreitung(true); - } - float fWert = Float.valueOf(wert); - messwert.setMesswert(fWert); - Response responseEinheit = sRepository.findAll(SMessEinheit.class); - List einheiten = - (List)responseEinheit.getData(); - boolean foundEinheit = false; - for (SMessEinheit e: einheiten) { - if(e.getEinheit().equals(einheit)) { - foundEinheit = true; - messwert.setMehId((int) e.getMehId()); - } - } - if (!foundEinheit) { - this.errors.add(new ReportData("messeinheit", "null", 673)); - return null; - } - Response responseGroesse = sRepository.findAll(SMessgroesse.class); - List messgroessen = - (List)responseGroesse.getData(); - boolean foundGroesse = false; - for (SMessgroesse g: messgroessen) { - if(g.getMessgroesse().equals(messgroesse)) { - foundGroesse = true; - messwert.setMessgroesseId(g.getMessgroesseId()); - messwert.getId().setMessgroesseId(g.getMessgroesseId()); - } - } - if (!foundGroesse) { - this.errors.add(new ReportData("messgroesse", "null", 673)); - return null; - } - } - return messwert; - } - - /** - * Add an attribute to the OrtCreator. The creator is used to build the - * two objects Ort and LOrt. - * - * @param key The key mapping to a object member. - * @param value The value to set. - * @param ort The creator object. - * @return The updated creator object. - */ - public OrtCreator addAttribute( - String key, - Object value, - OrtCreator ort - ) { - if ("ort_code".equals(key)) { - ort.setOrtCode(value.toString()); - } - if ("ort_typ".equals(key)) { - ort.setOrtTyp(value.toString()); - } - if ("ort_zusatz".equals(key)) { - ort.setZusatztext(value.toString()); - } - if ("ort_land_lang".equals(key)) { - ort.setLandLang(value.toString()); - } - if ("ort_land_kurz".equals(key)) { - ort.setLandKurz(value.toString()); - } - if ("ort_land_s".equals(key)) { - ort.setLandS(value.toString()); - } - if ("ort_gemeindeschlüssel".equals(key)) { - ort.setGemSchluessel(value.toString()); - } - if ("ort_bezeichnung".equals(key)) { - ort.setBezeichnung(value.toString()); - } - if ("ort_beschreibung".equals(key)) { - ort.setBeschreibung(value.toString()); - } - if ("ort_nuts_code".equals(key)) { - ort.setNuts(value.toString()); - } - if ("ort_hoehe_land".equals(key)) { - ort.setHoehe(value.toString()); - } - if ("ort_koordinaten".equals(key)) { - ort.setKoordinaten(value.toString()); - } - if ("ort_koordinaten_s".equals(key)) { - ort.setKoordinatenS(value.toString()); - } - return ort; - } - - /** - * Add an attribute to the given LZusatzwert object. - * - * @param lKey The key mapping to a object member. - * @param value The value to set. - * @param wert The entity object. - * @return The updated entity object. - */ - public LZusatzWert addAttribute( - String lKey, - Object value, - LZusatzWert wert - ) { - String v = value.toString().substring(1); - int ndx = v.indexOf("\""); - String groesse = v.substring(0, ndx); - v = v.substring(ndx + 2); - ndx = v.indexOf(" "); - String w = v.substring(0, ndx); - v = v.substring(ndx + 2); - ndx = v.indexOf("\""); - String einheit = v.substring(0, ndx); - String fehler = v.substring(ndx + 2); - QueryBuilder builder = - new QueryBuilder( - sRepository.getEntityManager(), SProbenZusatz.class); - builder.and("zusatzwert", groesse); - Response response = sRepository.filter(builder.getQuery()); - List list = (List)response.getData(); - if (list == null || list.isEmpty()) { - this.errors.add(new ReportData(lKey, "zusatzwert", 673)); - return null; - } - wert.getId().setPzsId(list.get(0).getPzsId()); - wert.setPzsId(list.get(0).getPzsId()); - wert.setMesswertPzs(Float.valueOf(w)); - wert.setMessfehler(Float.valueOf(fehler)); - return wert; - } - - /** - * Add an attribute to the given LZusatzwert object. - * - * @param lKey The key mapping to a object member. - * @param value The value to set. - * @param wert The entity object. - * @return The updated entity object. - */ - public LZusatzWert addAttributeS( - String lKey, - Object value, - LZusatzWert wert - ) { - String v = value.toString().substring(1); - int ndx = v.indexOf("\""); - String groesse = v.substring(0, ndx); - v = v.substring(ndx + 2); - ndx = v.indexOf(" "); - String w = v.substring(0, ndx); - v = v.substring(ndx + 2); - ndx = v.indexOf(" "); - String einheit = v.substring(0, ndx); - String fehler = v.substring(ndx + 2); - wert.getId().setPzsId(groesse); - wert.setPzsId(groesse); - wert.setMesswertPzs(Float.valueOf(w)); - wert.setMessfehler(Float.valueOf(fehler)); - return wert; - } - - /** - * @return the warnings - */ - public List getWarnings() { - return warnings; - } - - /** - * @return the errors - */ - public List getErrors() { - return errors; - } - - public void reset() { - errors = new ArrayList(); - warnings = new ArrayList(); - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/EntryFormat.java --- a/src/main/java/de/intevation/lada/data/importer/EntryFormat.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.util.regex.Pattern; - -/** - * An EntryFormat describes the internal structure of LAF-based key-value pairs. - * The pattern is a regular expression used to match the value in the LAF - * importer. - * The entry formats are defined in a config file - * (see wiki-doc: https://bfs-intern.intevation.de/Server/Importer). - * @author Raimund Renkert - */ -public class EntryFormat -{ - private String key; - private Pattern pattern; - private Object defaultValue; - - /** - * Default constructor to create a new EntryFormat object. - */ - public EntryFormat() { - } - - /** - * @return the key. - */ - public String getKey() { - return key; - } - - /** - * @param key The key to set. - */ - public void setKey(String key) { - this.key = key; - } - - /** - * @return the pattern - */ - public Pattern getPattern() { - return pattern; - } - - /** - * @param pattern The pattern to set. - */ - public void setPattern(Pattern pattern) { - this.pattern = pattern; - } - - /** - * @return the default value. - */ - public Object getDefaultValue() { - return defaultValue; - } - - /** - * @param defaultValue the default value to set. - */ - public void setDefaultValue(Object defaultValue) { - this.defaultValue = defaultValue; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/Importer.java --- a/src/main/java/de/intevation/lada/data/importer/Importer.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.util.List; -import java.util.Map; - -import de.intevation.lada.auth.AuthenticationResponse; - -/** - * Defines the interface for data importer using authentication information. - * - * @author Raimund Renkert - */ -public interface Importer -{ - public boolean importData(String content, AuthenticationResponse auth); - public Map> getErrors(); - public Map> getWarnings(); - public void reset(); -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/LAFFormat.java --- a/src/main/java/de/intevation/lada/data/importer/LAFFormat.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.LinkedList; -import java.util.List; -import java.util.regex.Pattern; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -/** - * The LAFFormat reads the config file - * (https://bfs-intern.intevation.de/Server/Importer) and creates format - * objects for each entry. - * - * @author Raimund Renkert - */ -public class LAFFormat -{ - private JSONObject fileContent; - - /** - * Reads the config file. - * - * @param fileName Path to the config file. - * @return success - */ - public boolean readConfigFile(String fileName) { - try { - byte[] encoded = Files.readAllBytes(Paths.get(fileName)); - Charset encoding = Charset.defaultCharset(); - String content = - encoding.decode(ByteBuffer.wrap(encoded)).toString(); - fileContent = new JSONObject(content); - return true; - } - catch (IOException ioe) { - return false; - } - catch (JSONException je) { - return false; - } - } - - /** - * Returns a List of EntryFormat for the requested entity type. - * The Entity type can be one of: - * * "probe" - * * "messung" - * * "ort" - * - * @param dataType The entity type - * @return List of entry formats defined for the requested type. - */ - public List getFormat(String dataType) { - List formats = new LinkedList(); - try { - JSONArray block = fileContent.getJSONArray(dataType); - for (int i = 0; i < block.length(); i++) { - JSONObject jEntry = block.getJSONObject(i); - EntryFormat entry = new EntryFormat(); - entry.setKey(jEntry.getString("key")); - Pattern pattern = - Pattern.compile( - jEntry.getString("regex"), - Pattern.MULTILINE); - entry.setPattern(pattern); - entry.setDefaultValue(jEntry.get("default")); - formats.add(entry); - } - return formats; - } - catch (JSONException e) { - return null; - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/LAFImporter.java --- a/src/main/java/de/intevation/lada/data/importer/LAFImporter.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.ejb.Stateless; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityManager; - -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.data.Repository; -import de.intevation.lada.validation.Validator; - -/** - * This importer uses the LAFParser to read data and create error/warning reports. - * - * @author Raimund Renkert - */ -@Named("lafimporter") -@Stateless -public class LAFImporter -implements Importer -{ - - @Inject - private EntityManager em; - - @Inject - private LAFParser parser; - - @Inject - @Named("lprobevalidator") - private Validator probeValidator; - @Inject - @Named("lmessungvalidator") - private Validator messungValidator; - @Inject - @Named("lortvalidator") - private Validator ortValidator; - @Inject - @Named("lmesswertvalidator") - private Validator messwertValidator; - - @Inject - @Named("lproberepository") - private Repository probeRepository; - @Inject - @Named("lmessungrepository") - private Repository messungRepository; - @Inject - @Named("lortrepository") - private Repository ortRepository; - @Inject - @Named("lkommentarRepository") - private Repository pKommentarRepository; - @Inject - @Named("lkommentarmrepository") - private Repository mKommentarRepository; - @Inject - @Named("lmesswertrepository") - private Repository messwertRepository; - - private Map> warnings; - private Map> errors; - - /** - * Default constructor. - */ - public LAFImporter() { - warnings = new HashMap>(); - errors = new HashMap>(); - } - - /** - * @return the warnings - */ - public Map> getWarnings() { - return warnings; - } - - /** - * @return the errors - */ - public Map> getErrors() { - return errors; - } - - /** - * Import LAF formated data using authentication information. - * - * @param content The LAF file content. - * @param auth The authentication information. - * @return success. - */ - @Override - public boolean importData(String content, AuthenticationResponse auth) { - this.warnings.clear(); - this.errors.clear(); - this.parser.reset(); - try { - boolean success = parser.parse(auth, content); - if (!success) { - List report = new ArrayList(); - report.add(new ReportData("parser", "no success", 660)); - errors.put("parser", report); - warnings.put("parser", new ArrayList()); - return false; - } - } - catch (LAFParserException e) { - List report = new ArrayList(); - report.add(new ReportData("parser", e.getMessage(), 670)); - errors.put("parser", report); - warnings.put("parser", new ArrayList()); - return false; - } - this.warnings.putAll(this.parser.getWarnings()); - this.errors.putAll(this.parser.getErrors()); - return true; - } - - /** - * Reset the errors and warnings. Use this before calling importData() - * to have a clean error and warning report. - */ - public void reset() { - parser.reset(); - this.warnings = new HashMap>(); - this.errors = new HashMap>(); - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/LAFParser.java --- a/src/main/java/de/intevation/lada/data/importer/LAFParser.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,493 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Named; - -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.validation.ValidationException; -import de.intevation.lada.validation.Validator; - -/** - * This parser is used to read data in LAF based key-value pair structure. - * - * @author Raimund Renkert - */ -public class LAFParser { - - private static final String PROBE_NEXT = "\n%PROBE%"; - - private boolean dryRun; - - @Inject - @Named("lafproducer") - private Producer producer; - - @Inject - @Named("lafwriter") - private Writer writer; - - @Inject - @Named("lprobevalidator") - private Validator probeValidator; - @Inject - @Named("lmessungvalidator") - private Validator messungValidator; - @Inject - @Named("lmesswertvalidator") - private Validator messwertValidator; - @Inject - @Named("lortvalidator") - private Validator ortValidator; - - private Map> warnings; - private Map> errors; - - /** - * Default constructor. - */ - public LAFParser() { - this.warnings = new HashMap>(); - this.errors = new HashMap>(); - this.setDryRun(false); - } - - /** - * Read and parse the data and write the objects to the database. - * - * @param auth Authentication information - * @param laf The LAF formated data. - * @return success - * @throws LAFParserException - */ - public boolean parse(AuthenticationResponse auth, String laf) - throws LAFParserException - { - if (!laf.startsWith("%PROBE%\n")) { - throw new LAFParserException("No %PROBE% at the begining."); - } - boolean parsed = false; - while (laf.startsWith("%PROBE%\n")) { - parsed = true; - int nextPos = laf.indexOf(PROBE_NEXT); - String single = ""; - if (nextPos > 0) { - single = laf.substring(0, nextPos + 1); - laf = laf.substring(nextPos + 1); - try { - readAll(single); - this.warnings.putAll(producer.getWarnings()); - this.errors.putAll(producer.getErrors()); - writeAll(auth); - this.producer.reset(); - this.writer.reset(); - } - catch (LAFParserException lpe) { - Map> pErr = producer.getErrors(); - if (pErr.isEmpty()) { - List err = new ArrayList(); - err.add(new ReportData("parser", lpe.getMessage(), 673)); - this.errors.put("parser", err); - this.warnings.put("parser", new ArrayList()); - } - else { - this.errors.putAll(pErr); - this.warnings.putAll(producer.getWarnings()); - } - this.producer.reset(); - continue; - } - } - else { - try { - readAll(laf); - this.warnings.putAll(producer.getWarnings()); - this.errors.putAll(producer.getErrors()); - writeAll(auth); - this.producer.reset(); - this.writer.reset(); - laf = ""; - } - catch (LAFParserException lpe) { - Map> pErr = producer.getErrors(); - if (pErr.isEmpty()) { - List err = new ArrayList(); - err.add(new ReportData("parser", lpe.getMessage(), 673)); - this.errors.put("parser", err); - this.warnings.put("parser", new ArrayList()); - } - else { - this.errors.putAll(pErr); - this.warnings.putAll(producer.getWarnings()); - } - this.producer.reset(); - laf = ""; - continue; - } - } - } - return parsed; - } - - /** - * Write all created objects to the database. - * - * @param auth The authentication information. - */ - private void writeAll(AuthenticationResponse auth) { - String probeId = producer.getProbe().getProbeId() == null ? "probeId" : producer.getProbe().getProbeId(); - boolean p = writer.writeProbe(auth, producer.getProbe()); - if (!p) { - this.errors.put(probeId, writer.getErrors()); - return; - } - writer.writeProbenKommentare(auth, producer.getProbenKommentare()); - boolean m = writer.writeMessungen(auth, producer.getMessungen()); - if (!m) { - return; - } - writer.writeOrte(auth, producer.getOrte()); - writer.writeLOrte(auth, producer.getLOrte()); - writer.writeMessungKommentare(auth, producer.getMessungsKommentare()); - writer.writeMesswerte(auth, producer.getMesswerte()); - this.validateProbe(producer.getProbe()); - this.validateMessungen(producer.getMessungen()); - this.validateMesswerte(producer.getMesswerte()); - this.validateLOrte(producer.getLOrte()); - } - - private boolean validateProbe(LProbe probe) { - try { - Map warn = - probeValidator.validate(probe, false); - if (warn != null) { - List warns = new ArrayList(); - for (String key: warn.keySet()) { - warns.add(new ReportData(key, "validation", warn.get(key))); - } - this.appendWarnings(probe.getProbeId(), warns); - } - } - catch (ValidationException e) { - Map err = e.getErrors(); - List errs = new ArrayList(); - for(String key: err.keySet()) { - errs.add(new ReportData(key, "validation", err.get(key))); - } - this.appendErrors(probe.getProbeId(), errs); - Map warn = e.getWarnings(); - if (warn != null) { - List warns = new ArrayList(); - for (String key: warn.keySet()) { - warns.add(new ReportData(key, "validation", warn.get(key))); - } - this.appendWarnings(probe.getProbeId(), warns); - } - return false; - } - return true; - } - - private boolean validateMessungen(List messungen) { - for(LMessung messung: messungen) { - try { - Map warn = - messungValidator.validate(messung, false); - if (warn != null) { - List warns = new ArrayList(); - for (String key : warn.keySet()) { - warns.add( - new ReportData(key, "validation", warn.get(key))); - } - this.appendWarnings(messung.getProbeId(), warns); - } - } - catch (ValidationException e) { - Map err = e.getErrors(); - List errs = new ArrayList(); - for(String key: err.keySet()) { - errs.add( - new ReportData(key, "validation", err.get(key))); - } - this.appendErrors(messung.getProbeId(), errs); - Map warn = e.getWarnings(); - if (warn != null) { - List warns = new ArrayList(); - for (String key: warn.keySet()) { - warns.add( - new ReportData(key, "validation", warn.get(key))); - } - this.appendWarnings(messung.getProbeId(), warns); - } - return false; - } - } - - return true; - - } - - private boolean validateMesswerte(List werte) { - for(LMesswert messwert: werte) { - try { - Map warn = - messwertValidator.validate(messwert, false); - if (warn != null) { - List warns = new ArrayList(); - for (String key : warn.keySet()) { - warns.add( - new ReportData(key, "validation", warn.get(key))); - } - this.appendWarnings(messwert.getProbeId(), warns); - } - } - catch (ValidationException e) { - Map err = e.getErrors(); - List errs = new ArrayList(); - for(String key: err.keySet()) { - errs.add( - new ReportData(key, "validation", err.get(key))); - } - this.appendErrors(messwert.getProbeId(), errs); - Map warn = e.getWarnings(); - if (warn != null) { - List warns = new ArrayList(); - for (String key: warn.keySet()) { - warns.add( - new ReportData(key, "validation", warn.get(key))); - } - this.appendWarnings(messwert.getProbeId(), warns); - } - return false; - } - } - return true; - } - - private boolean validateLOrte(List orte) { - for(LOrt ort: orte) { - try { - Map warn = - ortValidator.validate(ort, false); - if (warn != null) { - List warns = new ArrayList(); - for (String key : warn.keySet()) { - warns.add( - new ReportData(key, "validation", warn.get(key))); - } - this.appendWarnings(ort.getProbeId(), warns); - } - } - catch (ValidationException e) { - Map err = e.getErrors(); - List errs = new ArrayList(); - for(String key: err.keySet()) { - errs.add( - new ReportData(key, "validation", err.get(key))); - } - this.appendErrors(ort.getProbeId(), errs); - Map warn = e.getWarnings(); - if (warn != null) { - List warns = new ArrayList(); - for (String key: warn.keySet()) { - warns.add( - new ReportData(key, "validation", warn.get(key))); - } - this.appendWarnings(ort.getProbeId(), warns); - } - return false; - } - } - return true; - - } - - /** - * Read all attributes from a single probe block and create entity objects. - * - * @param content Single probe block enclosed by %PROBE% - * @throws LAFParserException - */ - private void readAll(String content) - throws LAFParserException - { - boolean key = false; - boolean value = false; - boolean header = false; - boolean white = false; - boolean string = false; - boolean multiValue = false; - String keyString = ""; - String valueString = ""; - String headerString = ""; - for (int i = 0; i < content.length(); i++) { - char current = content.charAt(i); - - if ((current == '"' || (current == ' ' && !string)) && - value && - i < content.length() - 1 && - (content.charAt(i + 1) != '\n' && - content.charAt(i + 1) != '\r')) { - multiValue = true; - } - - if (current == '"' && !string) { - string = true; - } - else if (current == '"' && string) { - string = false; - } - - if (current == ' ' && !value) { - key = false; - white = true; - continue; - } - else if (current != ' ' && - current != '\n' && - current != '\r' && - white) { - value = true; - white = false; - } - else if (current == '%' && !header && !value) { - headerString = ""; - producer.finishOrt(); - key = false; - header = true; - } - else if ((current == '\n' || current == '\r') && header) { - header = false; - key = true; - if (!dryRun) { - if (headerString.contains("MESSUNG")) { - producer.newMessung(); - } - if (headerString.contains("ORT")) { - producer.newOrt(); - } - } - if (headerString.contains("%ENDE%")) { - if (!dryRun) { - this.producer.newMessung(); - this.producer.newOrt(); - } - return; - } - continue; - } - else if (current == '"' && !value) { - value = true; - } - else if ((current == '\n' || current == '\r') && value && !string) { - if (!multiValue && valueString.startsWith("\"")) { - valueString = - valueString.substring(1, valueString.length() - 1); - } - value = false; - multiValue = false; - key = true; - if (!this.dryRun) { - producer.addData(keyString, valueString); - } - keyString = ""; - valueString = ""; - continue; - } - if ((current == '\n' || current == '\r') && (key || white)) { - throw new LAFParserException("No value for key: " + keyString); - } - - if (key) { - keyString += current; - } - else if (value) { - valueString += current; - } - else if (header) { - headerString += current; - } - } - if (!dryRun) { - this.producer.newMessung(); - this.producer.newOrt(); - } - } - - /** - * @return if objects are or not. - */ - public boolean isDryRun() { - return dryRun; - } - - /** - * If set to true, no objects will be created and written to database. - * - * @param dryRun - */ - public void setDryRun(boolean dryRun) { - this.dryRun = dryRun; - } - - /** - * @return the warnings - */ - public Map> getWarnings() { - return warnings; - } - - /** - * @return the errors - */ - public Map> getErrors() { - return errors; - } - - /** - * Reset errors and warnings. - */ - public void reset() { - producer.reset(); - this.errors = new HashMap>(); - this.warnings = new HashMap>(); - } - - private void appendErrors(String probeId, List errs) { - List err = this.errors.get(probeId); - if (err == null) { - this.errors.put(probeId, errs); - } - else { - err.addAll(errs); - this.errors.put(probeId, err); - } - } - - private void appendWarnings(String probeId, List warns) { - List warn = this.warnings.get(probeId); - if (warn == null) { - this.warnings.put(probeId, warns); - } - else { - warn.addAll(warns); - this.warnings.put(probeId, warn); - } - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/LAFParserException.java --- a/src/main/java/de/intevation/lada/data/importer/LAFParserException.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -/** - * Exception thrown in the LAF import process. - * - * @author Raimund Renkert - */ -public class LAFParserException -extends Exception -{ - public LAFParserException(String message) { - super(message); - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/LAFProducer.java --- a/src/main/java/de/intevation/lada/data/importer/LAFProducer.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,413 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Named; - -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LKommentarM; -import de.intevation.lada.model.LKommentarMId; -import de.intevation.lada.model.LKommentarP; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMessungId; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.model.LMesswertId; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.LZusatzWert; -import de.intevation.lada.model.LZusatzWertId; -import de.intevation.lada.model.Ort; - -/** - * The LAFProducer creates entity objects form key-value pairs using the - * AttributeMapper. - * - * @author Raimund Renkert - */ -@Named("lafproducer") -public class LAFProducer -implements Producer -{ - - @Inject - @Named("readonlyrepository") - private Repository sRepository; - - private LProbe probe; - private LMessung messung; - @Inject - private OrtCreator ort; - - private List pKommentare; - private List mKommentare; - private List messungen; - private List lorte; - private List orte; - private List messwerte; - private List zusatzwerte; - - private List probenFormat; - private List messungFormat; - private List ortFormat; - - private Map> warnings; - private Map> errors; - - @Inject - private AttributeMapper mapper; - - /** - * Default contructor. Initializes the producer and reads the config file - * using the systemproperty "de.intevation.lada.importconfig". - */ - public LAFProducer() { - this.warnings = new HashMap>(); - this.errors = new HashMap>(); - this.probe = new LProbe(); - this.pKommentare = new ArrayList(); - this.mKommentare = new ArrayList(); - this.messungen = new ArrayList(); - this.lorte = new ArrayList(); - this.messwerte = new ArrayList(); - String fileName = System.getProperty("de.intevation.lada.importconfig"); - LAFFormat format = new LAFFormat(); - format.readConfigFile(fileName); - probenFormat = format.getFormat("probe"); - messungFormat = format.getFormat("messung"); - ortFormat = format.getFormat("ort"); - } - - /** - * Add data to the producer. - * This triggers the producer to create a new object or add data to - * existing objects. - * - * @param key The key. - * @param values The value - */ - @Override - public void addData(String key, Object values) - throws LAFParserException { - String lKey = key.toLowerCase(); - if(lKey.equals("probenkommentar")) { - LKommentarP kommentar = new LKommentarP(); - kommentar.setProbeId(this.probe.getProbeId()); - this.pKommentare.add( - mapper.addAttribute(lKey, values, kommentar)); - } - else if (lKey.equals("kommentar")) { - LKommentarMId id = new LKommentarMId(); - id.setMessungsId(this.messung.getMessungsId()); - id.setProbeId(this.probe.getProbeId()); - LKommentarM kommentar = new LKommentarM(); - kommentar.setId(id); - kommentar.setMessungsId(this.messung.getMessungsId()); - kommentar.setProbeId(this.probe.getProbeId()); - this.mKommentare.add( - mapper.addAttribute(lKey, values, kommentar)); - } - else if (lKey.equals("probenzusatzbeschreibung")) { - LZusatzWertId zusatzId = new LZusatzWertId(); - zusatzId.setProbeId(this.probe.getProbeId()); - LZusatzWert wert = new LZusatzWert(); - wert.setId(zusatzId); - LZusatzWert zusatzWert = mapper.addAttribute(lKey, values, wert); - if (zusatzWert != null) { - this.zusatzwerte.add(zusatzWert); - } - else { - String ekey = probe.getProbeId() == null ? "probeId" : probe.getProbeId(); - List err = this.errors.get(ekey); - if (err == null) { - this.errors.put(ekey, mapper.getErrors()); - } - else { - err.addAll(mapper.getErrors()); - } - } - } - else if (lKey.equals("pzb_s")) { - LZusatzWertId zusatzId = new LZusatzWertId(); - zusatzId.setProbeId(this.probe.getProbeId()); - LZusatzWert wert = new LZusatzWert(); - wert.setId(zusatzId); - LZusatzWert zusatzWert = mapper.addAttributeS(lKey, values, wert); - if (zusatzWert != null) { - this.zusatzwerte.add(zusatzWert); - } - else { - String ekey = probe.getProbeId() == null ? "probeId" : probe.getProbeId(); - List err = this.errors.get(ekey); - if (err == null) { - this.errors.put(ekey, mapper.getErrors()); - } - else { - err.addAll(mapper.getErrors()); - } - } - } - else if (lKey.equals("messwert")) { - LMesswertId id = new LMesswertId(); - id.setProbeId(this.probe.getProbeId()); - id.setMessungsId(this.messung.getId().getMessungsId()); - LMesswert m = new LMesswert(); - m.setId(id); - m.setMessungsId(this.messung.getMessungsId()); - m.setProbeId(this.probe.getProbeId()); - LMesswert wert = mapper.addAttribute(lKey, values, m); - if (wert != null) { - this.messwerte.add(wert); - } - else { - String ekey = probe.getProbeId() == null ? "probeId" : probe.getProbeId(); - List err = this.errors.get(ekey); - if (err == null) { - this.errors.put(ekey, mapper.getErrors()); - } - else { - err.addAll(mapper.getErrors()); - } - } - } - else if (isValidMessung(lKey, values.toString())) { - this.messung = mapper.addAttribute(lKey, values, this.messung); - } - else if (isValidProbe(lKey, values.toString())) { - this.probe = mapper.addAttribute(lKey, values, this.probe); - if (this.probe == null) { - this.errors.put(values.toString(), mapper.getErrors()); - throw new LAFParserException(values.toString() + " exists"); - } - } - else if (isValidOrt(lKey, values.toString())) { - this.ort.addAttribute(lKey, values); - } - } - - /** - * Check if the key is defined in the config file and validate the value - * using the pattern defined for this key. - * - * @param key The key. - * @param value The value. - * @return valid or not. - */ - private boolean isValidOrt(String key, String value) { - for (EntryFormat ef: ortFormat) { - if (ef.getKey().equals(key.toLowerCase())) { - if (ef.getPattern().matcher(value).matches()) { - return true; - } - } - } - return false; - } - - /** - * Check if the key is defined in the config file and validate the value - * using the pattern defined for this key. - * - * @param key The key. - * @param value The value. - * @return valid or not. - */ - private boolean isValidMessung(String key, String value) { - for (EntryFormat ef: messungFormat) { - if (ef.getKey().equals(key.toLowerCase())) { - if (ef.getPattern().matcher(value).matches()) { - return true; - } - } - } - return false; - } - - /** - * Check if the key is defined in the config file and validate the value - * using the pattern defined for this key. - * - * @param key The key. - * @param value The value. - * @return valid or not. - */ - private boolean isValidProbe(String key, String value) { - for (EntryFormat ef: probenFormat) { - if (ef.getKey().equals(key.toLowerCase())) { - if (ef.getPattern().matcher(value).matches()) { - return true; - } - } - } - return false; - } - - /** - * @return the {@link LProbe} entity. - */ - @Override - public LProbe getProbe() { - return this.probe; - } - - /** - * @return List of {@link LMessung} entities. - */ - @Override - public List getMessungen() { - return this.messungen; - } - - /** - * @return List of {@link Ort} entities. - */ - @Override - public List getOrte() { - return this.orte; - } - - /** - * @return List of {@link LOrt} entities. - */ - @Override - public List getLOrte() { - return this.lorte; - } - - /** - * @return List of {@link LKommentarP} entities. - */ - @Override - public List getProbenKommentare() { - return this.pKommentare; - } - - /** - * @return List of {@link LKommentarM} entities. - */ - @Override - public List getMessungsKommentare() { - return this.mKommentare; - } - - /** - * @return List of {@link LMesswert} entities. - */ - @Override - public List getMesswerte() { - return this.messwerte; - } - - /** - * @return List of {@link LZusatzWert} entities. - */ - @Override - public List getZusatzwerte() { - return this.zusatzwerte; - } - - /** - * Reset errors and warnings. - */ - @Override - public void reset() { - this.errors = new HashMap>(); - this.warnings = new HashMap>(); - this.probe = new LProbe(); - this.messungen = new ArrayList(); - this.messung = null; - this.lorte = new ArrayList(); - this.orte = new ArrayList(); - this.ort.reset(); - this.messwerte = new ArrayList(); - this.mKommentare = new ArrayList(); - this.pKommentare = new ArrayList(); - mapper.reset(); - } - - /** - * Add the current {@link LMessung} entity to the List and create a new one. - */ - public void newMessung() { - if (this.messung != null) { - this.messungen.add(this.messung); - } - LMessungId id = new LMessungId(); - id.setProbeId(this.probe.getProbeId()); - this.messung = new LMessung(); - this.messung.setProbeId(this.probe.getProbeId()); - this.messung.setId(id); - } - - /** - * Add the {@link Ort} and {@link LOrt} entities to the lists and create - * a new {@link OrtCreator}. - */ - public void newOrt() { - if (this.ort != null) { - Ort o = this.ort.toOrt(); - if (o != null) { - this.orte.add(o); - } - LOrt lo = this.ort.toLOrt(); - if (lo != null) { - this.lorte.add(lo); - } - } - this.ort.reset(); - this.ort.setProbeId(this.probe.getProbeId()); - } - - /** - * @return the warnings - */ - public Map> getWarnings() { - if (this.probe == null) { - return this.warnings; - } - String key = probe.getProbeId() == null ? "probeId" : probe.getProbeId(); - List warn = this.warnings.get(key); - if (warn == null) { - this.warnings.put(key, mapper.getWarnings()); - } - else { - warn.addAll(mapper.getWarnings()); - } - return this.warnings; - } - - /** - * @return the errors - */ - public Map> getErrors() { - if (this.probe == null) { - return this.errors; - } - String key = probe.getProbeId() == null ? "probeId" : probe.getProbeId(); - List err = this.errors.get(key); - if (err == null) { - this.errors.put(key, mapper.getErrors()); - } - else { - err.addAll(mapper.getErrors()); - } - return this.errors; - } - - @Override - public void finishOrt() { - if (orte.isEmpty()) { - return; - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/LAFWriter.java --- a/src/main/java/de/intevation/lada/data/importer/LAFWriter.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,381 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceException; -import javax.persistence.Query; - -import org.hibernate.HibernateException; -import org.postgresql.util.PSQLException; - -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LKommentarM; -import de.intevation.lada.model.LKommentarP; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.Ort; -import de.intevation.lada.validation.ValidationException; -import de.intevation.lada.validation.Validator; - -/** - * Writer to persist new entities in the database. - * - * @author Raimund Renkert - */ -@Named("lafwriter") -public class LAFWriter -implements Writer -{ - @Inject - private EntityManager em; - - @Inject - @Named("lproberepository") - private Repository probeRepository; - @Inject - @Named("lmessungrepository") - private Repository messungRepository; - @Inject - @Named("lortrepository") - private Repository lortRepository; - @Inject - @Named("ortrepository") - private Repository ortRepository; - @Inject - @Named("lkommentarRepository") - private Repository pKommentarRepository; - @Inject - @Named("lkommentarmrepository") - private Repository mKommentarRepository; - @Inject - @Named("lmesswertrepository") - private Repository messwertRepository; - - private List errors; - private List warnings; - - /** - * Default constructor. - */ - public LAFWriter() { - errors = new ArrayList(); - warnings = new ArrayList(); - } - - /** - * Write a new {@link LProbe} object to the database using - * authorization and validation. - * - * @param auth The authentication information. - * @param probe The new {@link LProbe} object. - * @return success - */ - @Override - public boolean writeProbe(AuthenticationResponse auth, LProbe probe) { - if (!authorized(probe, auth)) { - errors.add(new ReportData("auth", "not authorized", 699)); - return false; - } - if (probe.getProbeId() == null) { - errors.add(new ReportData("probeId", "missing", 673)); - return false; - } - try { - persist(probe); - } - catch (PersistenceException e) { - errors.add(new ReportData("probe", "writing", 670)); - return false; - } - return true; - } - - /** - * Write new {@link LMessung} objects to the database using - * authorization and validation. - * - * @param auth The authentication information. - * @param messungen The new {@link LMessung} objects. - * @return success - */ - @Override - public boolean writeMessungen( - AuthenticationResponse auth, - List messungen - ) { - for(LMessung messung: messungen) { - messungRepository.create(messung); - } - return true; - } - - /** - * Write new {@link Ort} objects to the database. - * - * @param auth The authentication information. - * @param orte List of {@link Ort} objects. - * @return success - */ - @Override - public boolean writeOrte(AuthenticationResponse auth, List orte) { - for (Ort ort :orte) { - ortRepository.create(ort); - } - return true; - } - - /** - * Write new {@link LOrt} objects to the database using validation. - * - * @param auth The authentication information. - * @param orte List of {@link LOrt} objects. - * @return success - */ - @Override - public boolean writeLOrte(AuthenticationResponse auth, List orte) { - for(LOrt ort: orte) { - lortRepository.create(ort); - } - return true; - } - - /** - * Write new {@link LKommentarP} objects to the database. - * - * @param auth The authentication information. - * @param kommentare List of {@link LKommentarP} objects. - * @return success - */ - @Override - public boolean writeProbenKommentare( - AuthenticationResponse auth, - List kommentare - ) { - for(LKommentarP kommentar: kommentare) { - pKommentarRepository.create(kommentar); - } - return true; - } - - /** - * Write new {@link LKommentarM} objects to the database. - * - * @param auth The authentication information. - * @param kommentare List of {@link LKommentarM} objects. - * @return success - */ - @Override - public boolean writeMessungKommentare( - AuthenticationResponse auth, - List kommentare - ) { - for(LKommentarM kommentar: kommentare) { - Query q = - em.createNativeQuery( - "select nextval('kommentar_m_id_seq')"); - BigInteger seqId = (BigInteger)q.getSingleResult(); - kommentar.getId().setKId(seqId.intValue()); - mKommentarRepository.create(kommentar); - } - return true; - } - - /** - * Write new {@link LMesswert} objects to the database using validation. - * - * @param auth The authentication information. - * @param werte List of {@link LMesswert} objects. - * @return success - */ - @Override - public boolean writeMesswerte( - AuthenticationResponse auth, - List werte - ) { - for(LMesswert messwert: werte) { - messwertRepository.create(messwert); - } - return true; - } - - /** - * Persist a {@link LProbe} object. - * - * @param probe The {@link LProbe} object. - */ - @TransactionAttribute(TransactionAttributeType.REQUIRED) - private void persist(LProbe probe) - throws PersistenceException { - String queryColumns = "insert into l_probe (probe_id, ba_id, test," + - " datenbasis_id, netzbetreiber_id, mst_id, probenart_id, umw_id"; - String queryParameter = " values (:probe_id, :ba_id, :test," + - " :datenbasis_id, :netzbetreiber_id, :mst_id, :probenart_id," + - " :umw_id"; - if (probe.getErzeugerId() != null) { - queryColumns += ", erzeuger_id"; - queryParameter += ", :erzeuger_id"; - } - if (probe.getHauptprobenNr() != null) { - queryColumns += ", hauptproben_nr"; - queryParameter += ", :hauptproben_nr"; - } - if (probe.getLetzteAenderung() != null) { - queryColumns += ", letzte_aenderung"; - queryParameter += ", :letzte_aenderung"; - } - if (probe.getMedia() != null) { - queryColumns += ", media"; - queryParameter += ", :media"; - } - if (probe.getMediaDesk() != null) { - queryColumns += ", media_desk"; - queryParameter += ", :media_desk"; - } - if (probe.getMittelungsdauer() != null) { - queryColumns += ", mittelungsdauer"; - queryParameter += ", :mittelungsdauer"; - } - if (probe.getMpKat() != null) { - queryColumns += ", mp_kat"; - queryParameter += ", mp_kat"; - } - if (probe.getMplId() != null) { - queryColumns += ", mpl_id"; - queryParameter += ", :mpl_id"; - } - if (probe.getMprId() != null) { - queryColumns += ", mpr_id"; - queryParameter += ", :mpr_id"; - } - if (probe.getProbeNehmerId() != null) { - queryColumns += ", probe_nehmer_id"; - queryParameter += ", :probe_nehmer_id"; - } - if (probe.getProbeentnahmeBeginn() != null) { - queryColumns += ", probeentnahme_beginn"; - queryParameter += ", :probeentnahme_beginn"; - } - if (probe.getProbeentnahmeEnde() != null) { - queryColumns += ", probeentnahme_ende"; - queryParameter += ", :probeentnahme_ende"; - } - if (probe.getSolldatumBeginn() != null) { - queryColumns += ", solldatum_beginn"; - queryParameter += ", :solldatum_beginn"; - } - if (probe.getSolldatumEnde() != null) { - queryColumns += ", solldatum_ende"; - queryParameter += ", :solldatum_ende"; - } - queryColumns += ") " + queryParameter + ")"; - - Query insert = em.createNativeQuery(queryColumns); - insert.setParameter("probe_id", probe.getProbeId()); - insert.setParameter("ba_id", probe.getBaId()); - insert.setParameter("datenbasis_id", probe.getDatenbasisId()); - insert.setParameter("mst_id", probe.getMstId()); - insert.setParameter("netzbetreiber_id", probe.getNetzbetreiberId()); - insert.setParameter("probenart_id", probe.getProbenartId()); - insert.setParameter("test", probe.isTest()); - insert.setParameter("umw_id", probe.getUmwId()); - if (probe.getErzeugerId() != null) { - insert.setParameter("erzeuger_id", probe.getErzeugerId()); - } - if (probe.getHauptprobenNr() != null) { - insert.setParameter("hauptproben_nr", probe.getHauptprobenNr()); - } - if (probe.getLetzteAenderung() != null) { - insert.setParameter("letzte_aenderung", probe.getLetzteAenderung()); - } - if (probe.getMedia() != null) { - insert.setParameter("media", probe.getMedia()); - } - if (probe.getMediaDesk() != null) { - insert.setParameter("media_desk", probe.getMediaDesk()); - } - if (probe.getMittelungsdauer() != null) { - insert.setParameter("mittelungsdauer", probe.getMittelungsdauer()); - } - if (probe.getMpKat() != null) { - insert.setParameter("mp_kat", probe.getMpKat()); - } - if (probe.getMplId() != null) { - insert.setParameter("mpl_id", probe.getMplId()); - } - if (probe.getMprId() != null) { - insert.setParameter("mpr_id", probe.getMprId()); - } - if (probe.getProbeNehmerId() != null) { - insert.setParameter("probe_nehmer_id", probe.getProbeNehmerId()); - } - if (probe.getProbeentnahmeBeginn() != null) { - insert.setParameter("probeentnahme_beginn", probe.getProbeentnahmeBeginn()); - } - if (probe.getProbeentnahmeEnde() != null) { - insert.setParameter("probeentnahme_ende", probe.getProbeentnahmeEnde()); - } - if (probe.getSolldatumBeginn() != null) { - insert.setParameter("solldatum_beginn", probe.getSolldatumBeginn()); - } - if (probe.getSolldatumEnde() != null) { - insert.setParameter("solldatum_ende", probe.getSolldatumEnde()); - } - insert.executeUpdate(); - } - - /** - * Check if the user given in the authentication information is authorized - * to access the {@link LProbe} object. - * - * @param probe The {@link LProbe} object. - * @param auth The authentication information. - * @return access - */ - private boolean authorized(LProbe probe, AuthenticationResponse auth) { - if (auth.getNetzbetreiber().contains(probe.getNetzbetreiberId()) && - auth.getMst().contains(probe.getMstId())) { - return true; - } - return false; - } - - /** - * @return the errors - */ - public List getErrors() { - return errors; - } - - /** - * @return the warnings - */ - public List getWarnings() { - return warnings; - } - - /** - * Reset the errors and warnings. - */ - public void reset() { - this.warnings = new ArrayList(); - this.errors = new ArrayList(); - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/OrtCreator.java --- a/src/main/java/de/intevation/lada/data/importer/OrtCreator.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,727 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.util.List; - -import javax.ejb.Stateless; -import javax.inject.Inject; -import javax.inject.Named; - -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.Ort; -import de.intevation.lada.model.SStaat; -import de.intevation.lada.model.SVerwaltungseinheit; -import de.intevation.lada.rest.Response; - -/** - * Class to produce Ort/LOrt objects from a given set of attributes. - * - * @author Raimund Renkert - */ -@Stateless -public class OrtCreator -{ - @Inject - @Named("ortrepository") - private Repository ortRepo; - - @Inject - @Named("readonlyrepository") - private Repository readonlyRepo; - - private String probeId; - private Integer ortId; - private String ortCode; - private String ortTyp; - private String zusatztext; - private String landLang; - private String landKurz; - private String landS; - private String gemSchluessel; - private String gemName; - private String koordArt; - private String koord; - private String koordS; - private String bezeichnung; - private String beschreibung; - private String nuts; - private String hoehe; - private String koordinaten; - private String koordinatenS; - - public OrtCreator() { - this.ortId = null; - } - - /** - * @return the probeId - */ - public String getProbeId() { - return probeId; - } - - /** - * @param probeId the probeId to set - */ - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - /** - * @return the ortCode - */ - public String getOrtCode() { - return ortCode; - } - - /** - * @param ortCode the ortCode to set - */ - public void setOrtCode(String ortCode) { - this.ortCode = ortCode; - } - - /** - * @return the ortTyp - */ - public String getOrtTyp() { - return ortTyp; - } - - /** - * @param ortTyp the ortTyp to set - */ - public void setOrtTyp(String ortTyp) { - this.ortTyp = ortTyp; - } - - /** - * @return the zusatztext - */ - public String getZusatztext() { - return zusatztext; - } - - /** - * @param zusatztext the zusatztext to set - */ - public void setZusatztext(String zusatztext) { - this.zusatztext = zusatztext; - } - - /** - * @return the landLang - */ - public String getLandLang() { - return landLang; - } - - /** - * @param landLang the landLang to set - */ - public void setLandLang(String landLang) { - this.landLang = landLang; - } - - /** - * @return the landKurz - */ - public String getLandKurz() { - return landKurz; - } - - /** - * @param landKurz the landKurz to set - */ - public void setLandKurz(String landKurz) { - this.landKurz = landKurz; - } - - /** - * @return the landS - */ - public String getLandS() { - return landS; - } - - /** - * @param landS the landS to set - */ - public void setLandS(String landS) { - this.landS = landS; - } - - /** - * @return the gemSchluessel - */ - public String getGemSchluessel() { - return gemSchluessel; - } - - /** - * @param gemSchluessel the gemSchluessel to set - */ - public void setGemSchluessel(String gemSchluessel) { - this.gemSchluessel = gemSchluessel; - } - - /** - * @return the koordArt - */ - public String getKoordArt() { - return koordArt; - } - - /** - * @param koordArt the koordArt to set - */ - public void setKoordArt(String koordArt) { - this.koordArt = koordArt; - } - - /** - * @return the koord - */ - public String getKoord() { - return koord; - } - - /** - * @param koord the koord to set - */ - public void setKoord(String koord) { - this.koord = koord; - } - - /** - * @return the koordS - */ - public String getKoordS() { - return koordS; - } - - /** - * @param koordS the koordS to set - */ - public void setKoordS(String koordS) { - this.koordS = koordS; - } - - /** - * @return the nuts - */ - public String getNuts() { - return nuts; - } - - /** - * @param nuts the nuts to set - */ - public void setNuts(String nuts) { - this.nuts = nuts; - } - - /** - * @return the hoehe - */ - public String getHoehe() { - return hoehe; - } - - /** - * @param hoehe the hoehe to set - */ - public void setHoehe(String hoehe) { - this.hoehe = hoehe; - } - - /** - * @return the bezeichung - */ - public String getBezeichnung() { - return bezeichnung; - } - - /** - * @param bezeichnung the bezeichnung to set - */ - public void setBezeichnung(String bezeichnung) { - this.bezeichnung = bezeichnung; - } - - /** - * @return the gemName - */ - public String getGemName() { - return gemName; - } - - /** - * @param gemName the gemName to set - */ - public void setGemName(String gemName) { - this.gemName = gemName; - } - - /** - * @return the beschreibung - */ - public String getBeschreibung() { - return beschreibung; - } - - /** - * @param beschreibung the beschreibung to set - */ - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - /** - * @return the koordinaten - */ - public String getKoordinaten() { - return koordinaten; - } - - /** - * @param koordinaten the koordinaten to set - */ - public void setKoordinaten(String koordinaten) { - this.koordinaten = koordinaten; - } - - /** - * @return the koordinatenS - */ - public String getKoordinatenS() { - return koordinatenS; - } - - /** - * @param koordinatenS the koordinatenS to set - */ - public void setKoordinatenS(String koordinatenS) { - this.koordinatenS = koordinatenS; - } - - /** - * Add an attribute to the OrtCreator. The creator is used to build the - * two objects Ort and LOrt. - * - * @param key The key mapping to a object member. - * @param value The value to set. - * @param ort The creator object. - * @return The updated creator object. - */ - public void addAttribute( - String key, - Object value - ) { - if ("ort_code".equals(key)) { - this.setOrtCode(value.toString()); - } - if ("ort_typ".equals(key)) { - this.setOrtTyp(value.toString()); - } - if ("ort_zusatz".equals(key)) { - this.setZusatztext(value.toString()); - } - if ("ort_land_lang".equals(key)) { - this.setLandLang(value.toString()); - } - if ("ort_land_kurz".equals(key)) { - this.setLandKurz(value.toString()); - } - if ("ort_land_s".equals(key)) { - this.setLandS(value.toString()); - } - if ("ort_gemeindeschluessel".equals(key)) { - this.setGemSchluessel(value.toString()); - } - if ("ort_bezeichnung".equals(key)) { - this.setBezeichnung(value.toString()); - } - if ("ort_beschreibung".equals(key)) { - this.setBeschreibung(value.toString()); - } - if ("ort_nuts_code".equals(key)) { - this.setNuts(value.toString()); - } - if ("ort_hoehe_land".equals(key)) { - this.setHoehe(value.toString()); - } - if ("ort_koordinaten".equals(key)) { - this.setKoordinaten(value.toString()); - } - if ("ort_koordinaten_s".equals(key)) { - this.setKoordinatenS(value.toString()); - } - } - - - /** - * Create the Ort object. - * - * @return The new Ort. - */ - public Ort toOrt() { - if (this.ortCode != null && this.ortCode.length() > 0) { - return null; - } - Ort ort = new Ort(); - ortRepo.create(ort); - this.ortId = ort.getOrtId(); - boolean koord = true; - if (this.koordinatenS != null && this.koordinatenS.length() > 0) { - ort = setKoordinatenS(ort); - koord = false; - if (this.koordinaten != null && this.koordinaten.length() > 0) { - //TODO: add warning. - } - } - else if (this.koordinaten != null && this.koordinaten.length() > 0) { - ort = setKoordinaten(ort); - koord = false; - } - if (this.gemSchluessel != null && - this.gemSchluessel.length() > 0){ - ort = setGemeindeS(ort, koord); - koord = false; - if(this.gemName != null && this.gemName.length() > 0) { - //TODO: add warning. - } - } - else if (this.gemName != null && this.gemName.length() > 0) { - ort = setGemeinde(ort, koord); - koord = false; - } - if(this.landS != null && this.landS.length() > 0) { - ort = setLandS(ort, koord); - koord = false; - if (this.landLang != null && this.landLang.length() > 0) { - //TODO: add warning. - } - if (this.landKurz != null && this.landKurz.length() > 0) { - //TODO: add warning. - } - } - else if (this.landKurz != null && this.landKurz.length() > 0) { - ort = setLandKurz(ort, koord); - koord = false; - if (this.landLang != null && this.landLang.length() > 0) { - //TODO: add warning. - } - } - else if (this.landLang != null && this.landLang.length() > 0) { - ort = setLandLang(ort, koord); - } - if (koord) { - //TODO: add warning. - return null; - } - if (this.nuts != null && this.nuts.length() > 0) { - ort.setNutsCode(nuts); - } - else if (ort.getGemId() != null && ort.getGemId().length() > 0) { - QueryBuilder builder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SVerwaltungseinheit.class); - builder.and("gemId", ort.getGemId()); - Response response = readonlyRepo.filter(builder.getQuery()); - List list = - (List)response.getData(); - ort.setNutsCode(list.get(0).getNuts()); - } - ort.setBeschreibung(beschreibung); - if (this.hoehe != null) { - ort.setHoeheLand(Float.valueOf(hoehe)); - } - ortRepo.update(ort); - return ort; - } - - /** - * Find the SStaat object identified by the land_lang string and set a - * reference to the ort object. - * - * @param ort The ort object. - * @param koord Set the coordinates or not. - * @return The Ort object. - */ - private Ort setLandLang(Ort ort, boolean koord) { - QueryBuilder builder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SStaat.class); - builder.and("staat", this.landLang); - Response response = readonlyRepo.filter(builder.getQuery()); - List list = (List)response.getData(); - if (list.isEmpty()) { - //TODO: add warning. - return ort; - } - ort.setStaatId(list.get(0).getStaatId()); - if (koord) { - ort.setKoordXExtern(list.get(0).getKoordXExtern()); - ort.setKoordYExtern(list.get(0).getKoordYExtern()); - } - return ort; - } - - /** - * Find the SStaat object identified by the land_kurz string and set a - * reference to the ort object. - * - * @param ort The ort object. - * @param koord Set the coordinates or not. - * @return The Ort object. - */ - private Ort setLandKurz(Ort ort, boolean koord) { - QueryBuilder builder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SStaat.class); - builder.and("staat_kurz", this.landKurz); - Response response = readonlyRepo.filter(builder.getQuery()); - List list = (List)response.getData(); - if (list.isEmpty()) { - //TODO add warning. - return ort; - } - ort.setStaatId(list.get(0).getStaatId()); - if (koord) { - ort.setKoordXExtern(list.get(0).getKoordXExtern()); - ort.setKoordYExtern(list.get(0).getKoordYExtern()); - } - return ort; - } - - /** - * Find the SStaat object identified by the land_s id and set a - * reference to the ort object. - * - * @param ort The ort object. - * @param koord Set the coordinates or not. - * @return The Ort object. - */ - private Ort setLandS(Ort ort, boolean koord) { - ort.setStaatId(Integer.valueOf(this.landS)); - if (koord) { - QueryBuilder builder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SStaat.class); - builder.and("staatId", this.landS); - Response response = readonlyRepo.filter(builder.getQuery()); - List list = (List)response.getData(); - if (list.isEmpty()) { - //TODO: add warning. - return ort; - } - ort.setKoordXExtern(list.get(0).getKoordXExtern()); - ort.setLongitude(Double.valueOf(list.get(0).getKoordXExtern())); - ort.setKoordYExtern(list.get(0).getKoordYExtern()); - ort.setLatitude(Double.valueOf(list.get(0).getKoordYExtern())); - } - return ort; - } - - /** - * Find the SVerwaltungseinheit object identified by the gem_name string - * and set a reference to the ort object. - * - * @param ort The ort object. - * @param koord Set the coordinates or not. - * @return The Ort object. - */ - private Ort setGemeinde(Ort ort, boolean koord) { - QueryBuilder builder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SVerwaltungseinheit.class); - builder.and("bezeichnung", this.gemName); - Response response = readonlyRepo.filter(builder.getQuery()); - List list = - (List)response.getData(); - if (list.isEmpty()) { - //TODO: add warning. - return ort; - } - ort.setGemId(list.get(0).getGemId()); - if (koord) { - ort.setKoordXExtern(list.get(0).getKoordXExtern()); - ort.setKoordYExtern(list.get(0).getKoordYExtern()); - } - return ort; - } - - /** - * Find the SVerwaltungseinheit object identified by the gem_schluessel id - * and set a reference to the ort object. - * - * @param ort The ort object. - * @param koord Set the coordinates or not. - * @return The Ort object. - */ - private Ort setGemeindeS(Ort ort, boolean koord) { - ort.setGemId(this.gemSchluessel); - if (koord) { - QueryBuilder builder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SVerwaltungseinheit.class); - builder.and("bezeichnung", this.gemName); - Response response = readonlyRepo.filter(builder.getQuery()); - List list = - (List)response.getData(); - if (list.isEmpty()) { - // TODO: add warning. - return ort; - } - ort.setKoordXExtern(list.get(0).getKoordXExtern()); - ort.setKoordYExtern(list.get(0).getKoordYExtern()); - } - return ort; - } - - /** - * Parse the coordinates and the the attributes to the new ort object. - * - * @param ort The ort object. - * @return The Ort object. - */ - private Ort setKoordinaten(Ort ort) { - String art = ""; - String x = ""; - String y = ""; - String tmp = ""; - if (this.koordinaten.startsWith("\"")) { - tmp = this.koordinaten.substring(1); - art = tmp.substring(0, tmp.indexOf("\"")); - tmp = tmp.substring(tmp.indexOf("\"") + 2); - } - else { - art = this.koordinaten.substring(0, this.koordinaten.indexOf(" ")); - tmp = this.koordinaten.substring( - 0, this.koordinaten.indexOf(" ") + 1); - } - if (tmp.startsWith("\"")) { - tmp = tmp.substring(1); - x = tmp.substring(0, tmp.indexOf("\"")); - tmp = tmp.substring(0, tmp.indexOf("\"") + 2); - } - else { - x = tmp.substring(0, tmp.indexOf(" ")); - tmp = tmp.substring(0, tmp.indexOf(" ") + 1); - } - if (tmp.startsWith("\"")) { - tmp = tmp.substring(1); - y = tmp.substring(0, tmp.indexOf("\"")); - } - else { - y = tmp; - } - ort.setKoordXExtern(x); - ort.setKoordYExtern(y); - return ort; - } - - /** - * Parse the coordinates and the the attributes to the new ort object. - * - * @param ort The ort object. - * @return The Ort object. - */ - private Ort setKoordinatenS(Ort ort) { - String art = ""; - String x = ""; - String y = ""; - String tmp = ""; - if (this.koordinatenS.startsWith("\"")) { - tmp = this.koordinatenS.substring(1); - art = tmp.substring(0, tmp.indexOf("\"")); - tmp = tmp.substring(tmp.indexOf("\"") + 2); - } - else { - art = this.koordinatenS.substring(0, this.koordinatenS.indexOf(" ")); - tmp = this.koordinatenS.substring( - this.koordinatenS.indexOf(" ") + 1); - } - if (tmp.startsWith("\"")) { - tmp = tmp.substring(1); - x = tmp.substring(0, tmp.indexOf("\"")); - tmp = tmp.substring(tmp.indexOf("\"") + 2); - } - else { - x = tmp.substring(0, tmp.indexOf(" ")); - tmp = tmp.substring(tmp.indexOf(" ") + 1); - } - if (tmp.startsWith("\"")) { - tmp = tmp.substring(1); - y = tmp.substring(0, tmp.indexOf("\"")); - } - else { - y = tmp; - } - ort.setKoordXExtern(x); - ort.setLongitude(Double.valueOf(x)); - ort.setKoordYExtern(y); - ort.setLatitude(Double.valueOf(y)); - return ort; - } - - /** - * Create the new LOrt object from the given attributes. - * - * @return The new LOrt object. - */ - public LOrt toLOrt() { - if (this.ortId == null && - (this.ortCode == null || this.ortCode.length() == 0) || - this.probeId == null) { - return null; - } - if(this.ortCode != null && this.ortCode.length() > 0) { - QueryBuilder builder = - new QueryBuilder(ortRepo.getEntityManager(), Ort.class); - builder.and("bezeichnung", this.ortCode); - Response response = ortRepo.filter(builder.getQuery()); - List orte = (List)response.getData(); - if (orte != null && !orte.isEmpty()) { - this.ortId = orte.get(0).getOrtId(); - } - } - LOrt ort = new LOrt(); - ort.setOrtId(this.ortId); - ort.setProbeId(this.probeId); - ort.setOrtsTyp(this.ortTyp); - ort.setOrtszusatztext(this.zusatztext); - return ort; - } - - public void reset() { - this.beschreibung = null; - this.bezeichnung = null; - this.gemName = null; - this.gemSchluessel = null; - this.hoehe = null; - this.koord = null; - this.koordArt = null; - this.koordinaten = null; - this.koordinatenS = null; - this.koordS = null; - this.landKurz = null; - this.landLang = null; - this.landS = null; - this.nuts = null; - this.ortCode = null; - this.ortId = null; - this.ortTyp = null; - this.probeId = null; - this.zusatztext = null; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/Producer.java --- a/src/main/java/de/intevation/lada/data/importer/Producer.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.util.List; -import java.util.Map; - -import de.intevation.lada.model.LKommentarM; -import de.intevation.lada.model.LKommentarP; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.LZusatzWert; -import de.intevation.lada.model.Ort; - -/** - * Defines the interface for producers that create lada entities from - * key-value pairs. - * - * @author Raimund Renkert - */ -public interface Producer -{ - public void addData(String key, Object values) - throws LAFParserException; - public void finishOrt(); - public LProbe getProbe(); - public List getMessungen(); - public List getLOrte(); - public List getOrte(); - public List getProbenKommentare(); - public List getMessungsKommentare(); - public List getMesswerte(); - public List getZusatzwerte(); - public void reset(); - public void newMessung(); - public void newOrt(); - public Map> getErrors(); - public Map> getWarnings(); -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/ReportData.java --- a/src/main/java/de/intevation/lada/data/importer/ReportData.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -/** - * Container for error or warning messages send to the client. - * - * Errors and warnings are specified by the key-value pair that caused the problem and a code. - * The code can be - * 670: Parser error - * 671: existing - * 672: duplicated entry - * 673: missing - * 674: date error - * or any validation code. - * - * @author Raimund Renkert - */ -public class ReportData -{ - private String key; - private String value; - private Integer code; - - /** - * Default constructor. - */ - public ReportData() { - } - - /** - * Constructor to create a {@link ReportData} object with data. - * @param key The key caused the error/warning. - * @param value The value caused the error/warning. - * @param code The code specifying the error/warning. - */ - public ReportData(String key, String value, Integer code) { - this.key = key; - this.value = value; - this.code = code; - } - - /** - * @return the key - */ - public String getKey() { - return key; - } - - /** - * @param key the key to set - */ - public void setKey(String key) { - this.key = key; - } - - /** - * @return the value - */ - public String getValue() { - return value; - } - - /** - * @param value the value to set - */ - public void setValue(String value) { - this.value = value; - } - - /** - * @return the code - */ - public Integer getCode() { - return code; - } - - /** - * @param code the code to set - */ - public void setCode(Integer code) { - this.code = code; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/data/importer/Writer.java --- a/src/main/java/de/intevation/lada/data/importer/Writer.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.data.importer; - -import java.util.List; - -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.model.LKommentarM; -import de.intevation.lada.model.LKommentarP; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.Ort; - -/** - * Defines the interface for database object writers. - * - * @author Raimund Renkert - */ -public interface Writer -{ - public boolean writeProbe(AuthenticationResponse auth, LProbe probe); - public boolean writeMessungen( - AuthenticationResponse auth, - List messungen); - public boolean writeLOrte(AuthenticationResponse auth, List orte); - public boolean writeOrte(AuthenticationResponse auth, List orte); - public boolean writeProbenKommentare( - AuthenticationResponse auth, - List kommentare); - public boolean writeMessungKommentare( - AuthenticationResponse auth, - List kommentare); - public boolean writeMesswerte( - AuthenticationResponse auth, - List werte); - public List getErrors(); - public List getWarnings(); - public void reset(); -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/manage/DataManager.java --- a/src/main/java/de/intevation/lada/manage/DataManager.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.manage; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.ejb.Stateless; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityManager; -import javax.persistence.TransactionRequiredException; - - -/** - * This data manager provides the interface to persist, remove and update - * database objects. - * - * @author Raimund Renkert - */ -@Stateless -@Named("datamanager") -public class DataManager -implements Manager -{ - @Inject - private EntityManager em; - - /** - * Create a new database object. - * - * @param object The new object. - */ - @Override - @TransactionAttribute(TransactionAttributeType.REQUIRED) - public void create(Object object) - throws EntityExistsException, - IllegalArgumentException, - EJBTransactionRolledbackException, - TransactionRequiredException { - em.merge(object); - } - - /** - * Persist a database object. - * - * @param object The new object. - */ - @Override - @TransactionAttribute(TransactionAttributeType.REQUIRED) - public void persist(Object object) - throws EntityExistsException, - IllegalArgumentException, - EJBTransactionRolledbackException, - TransactionRequiredException { - em.persist(object); - } - /** - * Update a database object. - * - * @param object The object to update. - */ - @Override - @TransactionAttribute(TransactionAttributeType.REQUIRED) - public void update(Object object) - throws EntityExistsException, - IllegalArgumentException, - EJBTransactionRolledbackException, - TransactionRequiredException { - em.merge(object); - } - - /** - * Delete a database object. - * - * @param object The object to delete. - */ - @Override - @TransactionAttribute(TransactionAttributeType.REQUIRED) - public void delete(Object object) - throws IllegalArgumentException, - TransactionRequiredException { - em.remove(em.contains(object) ? object : em.merge(object)); - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/manage/Manager.java --- a/src/main/java/de/intevation/lada/manage/Manager.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.manage; - -import javax.ejb.EJBTransactionRolledbackException; -import javax.ejb.Stateless; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.persistence.EntityExistsException; -import javax.persistence.TransactionRequiredException; - -/** - * @author Raimund Renkert - */ -@Stateless -public interface Manager -{ - @TransactionAttribute(TransactionAttributeType.REQUIRED) - public void create(Object object) - throws EntityExistsException, - IllegalArgumentException, - EJBTransactionRolledbackException, - TransactionRequiredException; - - @TransactionAttribute(TransactionAttributeType.REQUIRED) - public void update(Object object) - throws EntityExistsException, - IllegalArgumentException, - EJBTransactionRolledbackException, - TransactionRequiredException; - - @TransactionAttribute(TransactionAttributeType.REQUIRED) - public void delete(Object object) - throws IllegalArgumentException, - TransactionRequiredException; - - void persist(Object object) throws EntityExistsException, - IllegalArgumentException, EJBTransactionRolledbackException, - TransactionRequiredException; -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/Auth.java --- a/src/main/java/de/intevation/lada/model/Auth.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 24.06.2013 16:31:53 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - - -/** - * Auth generated by hbm2java - */ -@Entity -@Table(name = "auth", schema = "public") -public class Auth -implements java.io.Serializable -{ - - private int id; - private SMessStelle SMessStelle; - private SNetzBetreiber SNetzBetreiber; - private String ldapGroup; - - public Auth() { - } - - public Auth(int id, String ldapGroup) { - this.id = id; - this.ldapGroup = ldapGroup; - } - - public Auth( - int id, - SMessStelle SMessStelle, - SNetzBetreiber SNetzBetreiber, - String ldapGroup) { - this.id = id; - this.SMessStelle = SMessStelle; - this.SNetzBetreiber = SNetzBetreiber; - this.ldapGroup = ldapGroup; - } - - @Id - @Column(name = "id", unique = true, nullable = false) - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "mst_id") - public SMessStelle getSMessStelle() { - return this.SMessStelle; - } - - public void setSMessStelle(SMessStelle SMessStelle) { - this.SMessStelle = SMessStelle; - } - - @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "netzbetreiber_id") - public SNetzBetreiber getSNetzBetreiber() { - return this.SNetzBetreiber; - } - - public void setSNetzBetreiber(SNetzBetreiber SNetzBetreiber) { - this.SNetzBetreiber = SNetzBetreiber; - } - - @Column(name = "ldap_group", nullable = false, length = 40) - public String getLdapGroup() { - return this.ldapGroup; - } - - public void setLdapGroup(String ldapGroup) { - this.ldapGroup = ldapGroup; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/DeVg.java --- a/src/main/java/de/intevation/lada/model/DeVg.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,206 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -import java.io.Serializable; -import javax.persistence.*; - -import org.hibernate.annotations.Type; - -import com.vividsolutions.jts.geom.MultiPolygon; - -import java.math.BigDecimal; -import java.util.Date; - - -/** - * The persistent class for the de_vg database table. - * - */ -@Entity -@Table(name="de_vg") -public class DeVg implements Serializable { - private static final long serialVersionUID = 1L; - - private Integer gid; - private String ags; - private String bemerk; - private String debkgId; - private String des; - private String gen; - private MultiPolygon geom; - private double gf; - private double isn; - private BigDecimal length; - private String nambild; - private String rauRs; - private String rs; - private String rsAlt; - private BigDecimal shapeArea; - private double use; - private Date wirksamkei; - - public DeVg() { - } - - @Id - @Column(name = "gid") - public Integer getGid() { - return this.gid; - } - - public void setGid(Integer gid) { - this.gid = gid; - } - - @Column(name = "ags") - public String getAgs() { - return this.ags; - } - - public void setAgs(String ags) { - this.ags = ags; - } - - @Column(name = "bemerk") - public String getBemerk() { - return this.bemerk; - } - - public void setBemerk(String bemerk) { - this.bemerk = bemerk; - } - - @Column(name = "debkg_id") - public String getDebkgId() { - return this.debkgId; - } - - public void setDebkgId(String debkgId) { - this.debkgId = debkgId; - } - - @Column(name = "des") - public String getDes() { - return this.des; - } - - public void setDes(String des) { - this.des = des; - } - - @Column(name = "gen") - public String getGen() { - return this.gen; - } - - public void setGen(String gen) { - this.gen = gen; - } - - @Column(name = "geom") - @Type(type = "org.hibernate.spatial.GeometryType") - public MultiPolygon getGeom() { - return this.geom; - } - - public void setGeom(MultiPolygon geom) { - this.geom = geom; - } - - @Column(name = "gf") - public double getGf() { - return this.gf; - } - - public void setGf(double gf) { - this.gf = gf; - } - - @Column(name = "isn") - public double getIsn() { - return this.isn; - } - - public void setIsn(double isn) { - this.isn = isn; - } - - @Column(name = "length") - public BigDecimal getLength() { - return this.length; - } - - public void setLength(BigDecimal length) { - this.length = length; - } - - @Column(name = "nambild") - public String getNambild() { - return this.nambild; - } - - public void setNambild(String nambild) { - this.nambild = nambild; - } - - @Column(name = "rau_rs") - public String getRauRs() { - return this.rauRs; - } - - public void setRauRs(String rauRs) { - this.rauRs = rauRs; - } - - @Column(name = "rs") - public String getRs() { - return this.rs; - } - - public void setRs(String rs) { - this.rs = rs; - } - - @Column(name = "rs_alt") - public String getRsAlt() { - return this.rsAlt; - } - - public void setRsAlt(String rsAlt) { - this.rsAlt = rsAlt; - } - - @Column(name = "shape_area") - public BigDecimal getShapeArea() { - return this.shapeArea; - } - - public void setShapeArea(BigDecimal shapeArea) { - this.shapeArea = shapeArea; - } - - @Column(name = "use") - public double getUse() { - return this.use; - } - - public void setUse(double use) { - this.use = use; - } - - @Column(name = "wirksamkei") - public Date getWirksamkei() { - return this.wirksamkei; - } - - public void setWirksamkei(Date wirksamkei) { - this.wirksamkei = wirksamkei; - } - -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LKommentarM.java --- a/src/main/java/de/intevation/lada/model/LKommentarM.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,127 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import java.util.Date; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * LKommentarM generated by hbm2java - */ -@Entity -@Table(name = "l_kommentar_m", schema = "public") -public class LKommentarM implements java.io.Serializable { - - private LKommentarMId id; - private Integer kId; - private String probeId; - private Integer messungsId; - private String erzeuger; - private Date KDatum; - private String KText; - - public LKommentarM() { - } - - public LKommentarM(LKommentarMId id, String probeId, - Integer messungsId, String erzeuger, Date KDatum) { - this.id = id; - this.setProbeId(probeId); - this.messungsId = messungsId; - this.erzeuger = erzeuger; - this.KDatum = KDatum; - } - - public LKommentarM(LKommentarMId id, String probeId, - Integer messungsId, String erzeuger, Date KDatum, String KText) { - this.id = id; - this.probeId = probeId; - this.messungsId = messungsId; - this.erzeuger = erzeuger; - this.KDatum = KDatum; - this.KText = KText; - } - - @EmbeddedId - @AttributeOverrides({ - @AttributeOverride(name = "probeId", column = @Column(name = "probe_id", nullable = false, length = 20)), - @AttributeOverride(name = "messungsId", column = @Column(name = "messungs_id", nullable = false)), - @AttributeOverride(name = "KId", column = @Column(name = "k_id", nullable = false)) }) - public LKommentarMId getId() { - return this.id; - } - - public void setId(LKommentarMId id) { - this.id = id; - } - - @Column(name = "k_id", nullable = false, insertable = false, updatable = false) - public Integer getKId() { - return kId; - } - - public void setKId(Integer kId) { - this.kId = kId; - } - - @Column(name = "probe_id", nullable = false, insertable = false, updatable = false) - public String getProbeId() { - return probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "messungs_id", nullable = false, insertable = false, updatable = false) - public Integer getMessungsId() { - return this.messungsId; - } - - public void setMessungsId(Integer messungsId) { - this.messungsId = messungsId; - } - - @Column(name = "erzeuger", nullable = false, length = 5) - public String getErzeuger() { - return this.erzeuger; - } - - public void setErzeuger(String erzeuger) { - this.erzeuger = erzeuger; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "k_datum", nullable = false, length = 35) - public Date getKDatum() { - return this.KDatum; - } - - public void setKDatum(Date KDatum) { - this.KDatum = KDatum; - } - - @Column(name = "k_text", length = 1024) - public String getKText() { - return this.KText; - } - - public void setKText(String KText) { - this.KText = KText; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LKommentarMId.java --- a/src/main/java/de/intevation/lada/model/LKommentarMId.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -/** - * LKommentarMId generated by hbm2java - */ -@Embeddable -public class LKommentarMId implements java.io.Serializable { - - private String probeId; - private Integer messungsId; - private int KId; - - public LKommentarMId() { - } - - public LKommentarMId(String probeId, Integer messungsId, int KId) { - this.probeId = probeId; - this.messungsId = messungsId; - this.KId = KId; - } - - @Column(name = "probe_id", nullable = false, length = 20) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "messungs_id", nullable = false) - public Integer getMessungsId() { - return this.messungsId; - } - - public void setMessungsId(Integer messungsId) { - this.messungsId = messungsId; - } - - @Column(name = "k_id", nullable = false) - public int getKId() { - return this.KId; - } - - public void setKId(int KId) { - this.KId = KId; - } - - public boolean equals(Object other) { - if ((this == other)) - return true; - if ((other == null)) - return false; - if (!(other instanceof LKommentarMId)) - return false; - LKommentarMId castOther = (LKommentarMId) other; - - return ((this.getProbeId() == castOther.getProbeId()) || (this - .getProbeId() != null && castOther.getProbeId() != null && this - .getProbeId().equals(castOther.getProbeId()))) - && (this.getMessungsId() == castOther.getMessungsId()) - && (this.getKId() == castOther.getKId()); - } - - public int hashCode() { - int result = 17; - - result = 37 * result - + (getProbeId() == null ? 0 : this.getProbeId().hashCode()); - result = 37 * result + this.getMessungsId(); - result = 37 * result + this.getKId(); - return result; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LKommentarP.java --- a/src/main/java/de/intevation/lada/model/LKommentarP.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * LKommentarP generated by hbm2java - */ -@Entity -@Table(name = "l_kommentar_p", schema = "public") -@SequenceGenerator(name = "ID_STORE", sequenceName = "l_kommentar_p_id_seq") -public class LKommentarP implements java.io.Serializable { - - private String probeId; - private int kId; - private String erzeuger; - private Date KDatum; - private String KText; - - public LKommentarP() { - } - - public LKommentarP(int kId, String probeId, - String erzeuger, Date KDatum) { - this.kId =kId; - this.probeId = probeId; - this.erzeuger = erzeuger; - this.KDatum = KDatum; - } - - public LKommentarP(int kId, String probeId, - String erzeuger, Date KDatum, String KText) { - this.kId = kId; - this.probeId = probeId; - this.erzeuger = erzeuger; - this.KDatum = KDatum; - this.KText = KText; - } - - @Id - @Column(name = "k_id", nullable = false, insertable = false, updatable = false) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ID_STORE") - public int getkId() { - return kId; - } - - public void setkId(int kId) { - this.kId = kId; - } - - @Column(name = "probe_id", nullable = false, length = 20) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "erzeuger", nullable = false, length = 5) - public String getErzeuger() { - return this.erzeuger; - } - - public void setErzeuger(String erzeuger) { - this.erzeuger = erzeuger; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "k_datum", nullable = false, length = 35) - public Date getKDatum() { - return this.KDatum; - } - - public void setKDatum(Date KDatum) { - this.KDatum = KDatum; - } - - @Column(name = "k_text", length = 1024) - public String getKText() { - return this.KText; - } - - public void setKText(String KText) { - this.KText = KText; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LMessung.java --- a/src/main/java/de/intevation/lada/model/LMessung.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import java.util.Date; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * LMessung generated by hbm2java - */ -@Entity -@Table(name = "l_messung", schema = "public") -public class LMessung implements java.io.Serializable { - - private LMessungId id; - private Integer messungsId; - private String probeId; - private String mmtId; - private String nebenprobenNr; - private Integer messdauer; - private Date messzeitpunkt; - private boolean fertig; - private Date letzteAenderung; - private boolean geplant; - - public LMessung() { - } - - public LMessung(LMessungId id, String probeId, String mmtId, - boolean fertig, boolean geplant) { - this.id = id; - this.probeId = probeId; - this.mmtId = mmtId; - this.fertig = fertig; - this.geplant = geplant; - } - - public LMessung(LMessungId id, String probeId, String mmtId, - String nebenprobenNr, Integer messdauer, Date messzeitpunkt, - boolean fertig, Date letzteAenderung, boolean geplant) { - this.id = id; - this.probeId = probeId; - this.mmtId = mmtId; - this.nebenprobenNr = nebenprobenNr; - this.messdauer = messdauer; - this.messzeitpunkt = messzeitpunkt; - this.fertig = fertig; - this.letzteAenderung = letzteAenderung; - this.geplant = geplant; - } - - @EmbeddedId - @AttributeOverrides({ - @AttributeOverride(name = "probeId", column = @Column(name = "probe_id", nullable = false, length = 20)), - @AttributeOverride(name = "messungsId", column = @Column(name = "messungs_id", nullable = false)) }) - public LMessungId getId() { - return this.id; - } - - public void setId(LMessungId id) { - this.id = id; - } - - @Column(name = "messungs_id", nullable = false, insertable = false, updatable = false) - public Integer getMessungsId() { - return messungsId; - } - - public void setMessungsId(Integer messungsId) { - this.messungsId = messungsId; - } - - @Column(name = "probe_id", nullable = false, insertable = false, updatable = false) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "mmt_id", nullable = false) - public String getMmtId() { - return this.mmtId; - } - - public void setMmtId(String mmtId) { - this.mmtId = mmtId; - } - - @Column(name = "nebenproben_nr", length = 10) - public String getNebenprobenNr() { - return this.nebenprobenNr; - } - - public void setNebenprobenNr(String nebenprobenNr) { - this.nebenprobenNr = nebenprobenNr; - } - - @Column(name = "messdauer") - public Integer getMessdauer() { - return this.messdauer; - } - - public void setMessdauer(Integer messdauer) { - this.messdauer = messdauer; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "messzeitpunkt", length = 35) - public Date getMesszeitpunkt() { - return this.messzeitpunkt; - } - - public void setMesszeitpunkt(Date messzeitpunkt) { - this.messzeitpunkt = messzeitpunkt; - } - - @Column(name = "fertig", nullable = false) - public boolean isFertig() { - return this.fertig; - } - - public void setFertig(boolean fertig) { - this.fertig = fertig; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "letzte_aenderung", length = 29) - public Date getLetzteAenderung() { - return this.letzteAenderung; - } - - public void setLetzteAenderung(Date letzteAenderung) { - this.letzteAenderung = letzteAenderung; - } - - @Column(name = "geplant", nullable = false) - public boolean isGeplant() { - return this.geplant; - } - - public void setGeplant(boolean geplant) { - this.geplant = geplant; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LMessungId.java --- a/src/main/java/de/intevation/lada/model/LMessungId.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -/** - * LMessungId generated by hbm2java - */ -@Embeddable -public class LMessungId implements java.io.Serializable { - - private String probeId; - private Integer messungsId; - - public LMessungId() { - } - - public LMessungId(String probeId, Integer messungsId) { - this.probeId = probeId; - this.messungsId = messungsId; - } - - @Column(name = "probe_id", nullable = false, length = 20) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "messungs_id", nullable = false) - public Integer getMessungsId() { - return this.messungsId; - } - - public void setMessungsId(Integer messungsId) { - this.messungsId = messungsId; - } - - public boolean equals(Object other) { - if ((this == other)) - return true; - if ((other == null)) - return false; - if (!(other instanceof LMessungId)) - return false; - LMessungId castOther = (LMessungId) other; - - return ((this.getProbeId() == castOther.getProbeId()) || (this - .getProbeId() != null && castOther.getProbeId() != null && this - .getProbeId().equals(castOther.getProbeId()))) - && (this.getMessungsId() == castOther.getMessungsId()); - } - - public int hashCode() { - int result = 17; - - result = 37 * result - + (getProbeId() == null ? 0 : this.getProbeId().hashCode()); - result = 37 * result + this.getMessungsId(); - return result; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LMesswert.java --- a/src/main/java/de/intevation/lada/model/LMesswert.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import java.util.Date; - -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * LMesswert generated by hbm2java - */ -@Entity -@Table(name = "l_messwert", schema = "public") -public class LMesswert implements java.io.Serializable { - - private LMesswertId id; - private String probeId; - private Integer messungsId; - private Integer mehId; - private Integer messgroesseId; - private String messwertNwg; - private float messwert; - private Float messfehler; - private Float nwgZuMesswert; - private Boolean grenzwertueberschreitung; - private Date letzteAenderung; - - public LMesswert() { - } - - public LMesswert(LMesswertId id, String probeId, Integer messungsId, - Integer mehId, Integer messgroesseId, float messwert - ) { - this.id = id; - this.probeId = probeId; - this.messungsId = messungsId; - this.mehId = mehId; - this.messgroesseId = messgroesseId; - this.messwert = messwert; - } - - public LMesswert(LMesswertId id, String probeId, Integer messungsId, - Integer mehId, Integer messgroesseId, String messwertNwg, - float messwert, Float messfehler, Float nwgZuMesswert, - Boolean grenzwertueberschreitung, Date letzteAenderung - ) { - this.id = id; - this.probeId = probeId; - this.messungsId = messungsId; - this.mehId = mehId; - this.messgroesseId = messgroesseId; - this.messwertNwg = messwertNwg; - this.messwert = messwert; - this.messfehler = messfehler; - this.nwgZuMesswert = nwgZuMesswert; - this.grenzwertueberschreitung = grenzwertueberschreitung; - this.letzteAenderung = letzteAenderung; - } - - @EmbeddedId - @AttributeOverrides({ - @AttributeOverride(name = "probeId", column = @Column(name = "probe_id", nullable = false, length = 20)), - @AttributeOverride(name = "messungsId", column = @Column(name = "messungs_id", nullable = false)), - @AttributeOverride(name = "messgroesseId", column = @Column(name = "messgroesse_id", nullable = false)) }) - public LMesswertId getId() { - return this.id; - } - - public void setId(LMesswertId id) { - this.id = id; - } - - @Column(name = "probe_id", nullable = false, insertable = false, updatable = false) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "messungs_id", nullable = false, insertable = false, updatable= false) - public Integer getMessungsId() { - return this.messungsId; - } - - public void setMessungsId(Integer messungsId) { - this.messungsId = messungsId; - } - - @Column(name = "meh_id", nullable = false) - public Integer getMehId() { - return this.mehId; - } - - public void setMehId(Integer mehId) { - this.mehId = mehId; - } - - @Column(name = "messgroesse_id", nullable = false, insertable = false, updatable = false) - public Integer getMessgroesseId() { - return this.messgroesseId; - } - - public void setMessgroesseId(Integer messgroesseId) { - this.messgroesseId = messgroesseId; - } - - @Column(name = "messwert_nwg", length = 1) - public String getMesswertNwg() { - return this.messwertNwg; - } - - public void setMesswertNwg(String messwertNwg) { - this.messwertNwg = messwertNwg; - } - - @Column(name = "messwert", nullable = false, precision = 8, scale = 8) - public float getMesswert() { - return this.messwert; - } - - public void setMesswert(float messwert) { - this.messwert = messwert; - } - - @Column(name = "messfehler", precision = 8, scale = 8) - public Float getMessfehler() { - return this.messfehler; - } - - public void setMessfehler(Float messfehler) { - this.messfehler = messfehler; - } - - @Column(name = "nwg_zu_messwert", precision = 8, scale = 8) - public Float getNwgZuMesswert() { - return this.nwgZuMesswert; - } - - public void setNwgZuMesswert(Float nwgZuMesswert) { - this.nwgZuMesswert = nwgZuMesswert; - } - - @Column(name = "grenzwertueberschreitung") - public Boolean getGrenzwertueberschreitung() { - return this.grenzwertueberschreitung; - } - - public void setGrenzwertueberschreitung(Boolean grenzwertueberschreitung) { - this.grenzwertueberschreitung = grenzwertueberschreitung; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "letzte_aenderung", length = 29) - public Date getLetzteAenderung() { - return this.letzteAenderung; - } - - public void setLetzteAenderung(Date letzteAenderung) { - this.letzteAenderung = letzteAenderung; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LMesswertId.java --- a/src/main/java/de/intevation/lada/model/LMesswertId.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -/** - * LMesswertId generated by hbm2java - */ -@Embeddable -public class LMesswertId implements java.io.Serializable { - - private String probeId; - private Integer messungsId; - private int messgroesseId; - - public LMesswertId() { - } - - public LMesswertId(String probeId, Integer messungsId, int messgroesseId) { - this.probeId = probeId; - this.messungsId = messungsId; - this.messgroesseId = messgroesseId; - } - - @Column(name = "probe_id", nullable = false, length = 20) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "messungs_id", nullable = false) - public Integer getMessungsId() { - return this.messungsId; - } - - public void setMessungsId(Integer messungsId) { - this.messungsId = messungsId; - } - - @Column(name = "messgroesse_id", nullable = false) - public int getMessgroesseId() { - return this.messgroesseId; - } - - public void setMessgroesseId(int messgroesseId) { - this.messgroesseId = messgroesseId; - } - - public boolean equals(Object other) { - if ((this == other)) - return true; - if ((other == null)) - return false; - if (!(other instanceof LMesswertId)) - return false; - LMesswertId castOther = (LMesswertId) other; - - return ((this.getProbeId() == castOther.getProbeId()) || (this - .getProbeId() != null && castOther.getProbeId() != null && this - .getProbeId().equals(castOther.getProbeId()))) - && (this.getMessungsId() == castOther.getMessungsId()) - && (this.getMessgroesseId() == castOther.getMessgroesseId()); - } - - public int hashCode() { - int result = 17; - - result = 37 * result - + (getProbeId() == null ? 0 : this.getProbeId().hashCode()); - result = 37 * result + this.getMessungsId(); - result = 37 * result + this.getMessgroesseId(); - return result; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LOrt.java --- a/src/main/java/de/intevation/lada/model/LOrt.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; - -/** - * LOrt generated by hbm2java - */ -@Entity -@Table(name = "l_ort", schema = "public") -public class LOrt implements java.io.Serializable { - - private int POrtId; - private int ortId; - private String probeId; - private String ortsTyp; - private String ortszusatztext; - private Date letzteAenderung; - private boolean readonly; - - public LOrt() { - } - - public LOrt(int POrtId, int ortId, String probeId) { - this.POrtId = POrtId; - this.ortId = ortId; - this.probeId = probeId; - } - - public LOrt(int POrtId, int ortId, String probeId, String ortsTyp, - String ortszusatztext, Date letzteAenderung) { - this.POrtId = POrtId; - this.ortId = ortId; - this.probeId = probeId; - this.ortsTyp = ortsTyp; - this.ortszusatztext = ortszusatztext; - this.letzteAenderung = letzteAenderung; - } - - @Id - @Column(name = "p_ort_id", unique = true, nullable = false) - @SequenceGenerator(name = "LORT_ID_STORE", sequenceName = "l_ort_id_seq", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "LORT_ID_STORE") - public int getPOrtId() { - return this.POrtId; - } - - public void setPOrtId(int POrtId) { - this.POrtId = POrtId; - } - - @Column(name = "ort_id", nullable = false) - public int getOrtId() { - return this.ortId; - } - - public void setOrtId(int ortId) { - this.ortId = ortId; - } - - @Column(name = "probe_id", nullable = false) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "orts_typ", length = 1) - public String getOrtsTyp() { - return this.ortsTyp; - } - - public void setOrtsTyp(String ortsTyp) { - this.ortsTyp = ortsTyp; - } - - @Column(name = "ortszusatztext", length = 100) - public String getOrtszusatztext() { - return this.ortszusatztext; - } - - public void setOrtszusatztext(String ortszusatztext) { - this.ortszusatztext = ortszusatztext; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "letzte_aenderung", length = 29) - public Date getLetzteAenderung() { - return this.letzteAenderung; - } - - public void setLetzteAenderung(Date letzteAenderung) { - this.letzteAenderung = letzteAenderung; - } - - @Transient - public boolean isReadonly() { - return readonly; - } - - public void setReadonly(boolean readonly) { - this.readonly = readonly; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LProbe.java --- a/src/main/java/de/intevation/lada/model/LProbe.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,295 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * LProbe generated by hbm2java - */ -@Entity -@Table(name = "l_probe", schema = "public") -public class LProbe implements java.io.Serializable { - - private String probeId; - private String mstId; - private String umwId; - private boolean test; - private String hauptprobenNr; - private String baId; - private String mediaDesk; - private String media; - private Integer probenartId; - private Integer datenbasisId; - private Date probeentnahmeBeginn; - private Date probeentnahmeEnde; - private Long mittelungsdauer; - private Date letzteAenderung; - private Integer erzeugerId; - private Integer probeNehmerId; - private Character mpKat; - private String mplId; - private Integer mprId; - private Date solldatumBeginn; - private Date solldatumEnde; - private String netzbetreiberId; - - public LProbe() { - } - - public LProbe(String probeId, boolean test) { - this.probeId = probeId; - this.test = test; - } - - public LProbe(String probeId, String mstId, String umwId, boolean test, - String hauptprobenNr, String baId, String mediaDesk, String media, - Integer probenartId, Integer datenbasisId, - Date probeentnahmeBeginn, Date probeentnahmeEnde, - Long mittelungsdauer, Date letzteAenderung, Integer erzeugerId, - Integer probeNehmerId, Character mpKat, String mplId, - Integer mprId, Date solldatumBeginn, Date solldatumEnde, String netzbetreiberId) { - this.probeId = probeId; - this.mstId = mstId; - this.umwId = umwId; - this.test = test; - this.hauptprobenNr = hauptprobenNr; - this.baId = baId; - this.mediaDesk = mediaDesk; - this.media = media; - this.setProbenartId(probenartId); - this.setDatenbasisId(datenbasisId); - this.probeentnahmeBeginn = probeentnahmeBeginn; - this.probeentnahmeEnde = probeentnahmeEnde; - this.mittelungsdauer = mittelungsdauer; - this.letzteAenderung = letzteAenderung; - this.erzeugerId = erzeugerId; - this.probeNehmerId = probeNehmerId; - this.mpKat = mpKat; - this.mplId = mplId; - this.mprId = mprId; - this.solldatumBeginn = solldatumBeginn; - this.solldatumEnde = solldatumEnde; - this.netzbetreiberId = netzbetreiberId; - } - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - @Column(name = "probe_id", unique = true, nullable = false, length = 20) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "test", nullable = false) - public boolean isTest() { - return this.test; - } - - public void setTest(boolean test) { - this.test = test; - } - - @Column(name = "hauptproben_nr", length = 20) - public String getHauptprobenNr() { - return this.hauptprobenNr; - } - - public void setHauptprobenNr(String hauptprobenNr) { - this.hauptprobenNr = hauptprobenNr; - } - - @Column(name = "ba_id", length = 1) - public String getBaId() { - return this.baId; - } - - public void setBaId(String baId) { - this.baId = baId; - } - - @Column(name = "media_desk", length = 100) - public String getMediaDesk() { - return this.mediaDesk; - } - - public void setMediaDesk(String mediaDesk) { - this.mediaDesk = mediaDesk; - } - - @Column(name = "media", length = 100) - public String getMedia() { - return this.media; - } - - public void setMedia(String media) { - this.media = media; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "probeentnahme_beginn", length = 35) - public Date getProbeentnahmeBeginn() { - return this.probeentnahmeBeginn; - } - - public void setProbeentnahmeBeginn(Date probeentnahmeBeginn) { - this.probeentnahmeBeginn = probeentnahmeBeginn; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "probeentnahme_ende", length = 35) - public Date getProbeentnahmeEnde() { - return this.probeentnahmeEnde; - } - - public void setProbeentnahmeEnde(Date probeentnahmeEnde) { - this.probeentnahmeEnde = probeentnahmeEnde; - } - - @Column(name = "mittelungsdauer") - public Long getMittelungsdauer() { - return this.mittelungsdauer; - } - - public void setMittelungsdauer(Long mittelungsdauer) { - this.mittelungsdauer = mittelungsdauer; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "letzte_aenderung", length = 29) - public Date getLetzteAenderung() { - return this.letzteAenderung; - } - - public void setLetzteAenderung(Date letzteAenderung) { - this.letzteAenderung = letzteAenderung; - } - - @Column(name = "erzeuger_id") - public Integer getErzeugerId() { - return this.erzeugerId; - } - - public void setErzeugerId(Integer erzeugerId) { - this.erzeugerId = erzeugerId; - } - - @Column(name = "probe_nehmer_id") - public Integer getProbeNehmerId() { - return this.probeNehmerId; - } - - public void setProbeNehmerId(Integer probeNehmerId) { - this.probeNehmerId = probeNehmerId; - } - - @Column(name = "mp_kat", length = 1) - public Character getMpKat() { - return this.mpKat; - } - - public void setMpKat(Character mpKat) { - this.mpKat = mpKat; - } - - @Column(name = "mpl_id", length = 3) - public String getMplId() { - return this.mplId; - } - - public void setMplId(String mplId) { - this.mplId = mplId; - } - - @Column(name = "mpr_id") - public Integer getMprId() { - return this.mprId; - } - - public void setMprId(Integer mprId) { - this.mprId = mprId; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "solldatum_beginn", length = 29) - public Date getSolldatumBeginn() { - return this.solldatumBeginn; - } - - public void setSolldatumBeginn(Date solldatumBeginn) { - this.solldatumBeginn = solldatumBeginn; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "solldatum_ende", length = 29) - public Date getSolldatumEnde() { - return this.solldatumEnde; - } - - public void setSolldatumEnde(Date solldatumEnde) { - this.solldatumEnde = solldatumEnde; - } - - public void setMstId(String mstId) { - this.mstId = mstId; - } - @Column(name = "mst_id") - public String getMstId() { - return this.mstId; - } - - public void setUmwId(String umwId) { - this.umwId = umwId; - } - - @Column(name = "umw_id") - public String getUmwId() { - return this.umwId; - } - - @Column(name = "probenart_id") - public Integer getProbenartId() { - return probenartId; - } - - public void setProbenartId(Integer probenartId) { - this.probenartId = probenartId; - } - - @Column(name = "datenbasis_id") - public Integer getDatenbasisId() { - return datenbasisId; - } - - public void setDatenbasisId(Integer datenbasisId) { - this.datenbasisId = datenbasisId; - } - - @Column(name = "netzbetreiber_id") - public String getNetzbetreiberId() { - return netzbetreiberId; - } - - public void setNetzbetreiberId(String netzbetreiberId) { - this.netzbetreiberId = netzbetreiberId; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LProbeInfo.java --- a/src/main/java/de/intevation/lada/model/LProbeInfo.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,310 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -import java.io.Serializable; -import javax.persistence.*; -import java.sql.Timestamp; - - -/** - * The persistent class for the l_probe_info database table. - * - */ -@Entity -@Table(name="l_probe_info") -public class LProbeInfo implements Serializable { - private static final long serialVersionUID = 1L; - - @EmbeddedId - private LProbeInfoId lprobeInfoId; - - @Column(name="ba_id") - private String baId; - - @Column(name="datenbasis_id") - private Integer datenbasisId; - - @Column(name="erzeuger_id") - private Integer erzeugerId; - - @Column(name="hauptproben_nr") - private String hauptprobenNr; - - @Column(name="letzte_aenderung") - private Timestamp letzteAenderung; - - @Column(name="media") - private String media; - - @Column(name="media_desk") - private String mediaDesk; - - @Column(name="mittelungsdauer") - private Long mittelungsdauer; - - @Column(name="mp_kat") - private Character mpKat; - - @Column(name="mpl_id") - private String mplId; - - @Column(name="mpr_id") - private Integer mprId; - - @Column(name="mst_id") - private String mstId; - - @Column(name="netzbetreiber_id") - private String netzbetreiberId; - - @Column(name="probe_id", insertable = false, updatable = false) - private String probeId; - - @Column(name="probe_nehmer_id") - private Integer probeNehmerId; - - @Column(name="probeentnahme_beginn") - private Timestamp probeentnahmeBeginn; - - @Column(name="probeentnahme_ende") - private Timestamp probeentnahmeEnde; - - @Column(name="probenart_id") - private Integer probenartId; - - @Column(name="solldatum_beginn") - private Timestamp solldatumBeginn; - - @Column(name="solldatum_ende") - private Timestamp solldatumEnde; - - @Column(name="test") - private Boolean test; - - @Column(name="umw_id") - private String umwId; - - @Column(name="readonly") - private Boolean readonly; - - public LProbeInfo() { - } - - public String getBaId() { - return this.baId; - } - - public void setBaId(String baId) { - this.baId = baId; - } - - public Integer getDatenbasisId() { - return this.datenbasisId; - } - - public void setDatenbasisId(Integer datenbasisId) { - this.datenbasisId = datenbasisId; - } - - public Integer getErzeugerId() { - return this.erzeugerId; - } - - public void setErzeugerId(Integer erzeugerId) { - this.erzeugerId = erzeugerId; - } - - public String getHauptprobenNr() { - return this.hauptprobenNr; - } - - public void setHauptprobenNr(String hauptprobenNr) { - this.hauptprobenNr = hauptprobenNr; - } - - public Timestamp getLetzteAenderung() { - return this.letzteAenderung; - } - - public void setLetzteAenderung(Timestamp letzteAenderung) { - this.letzteAenderung = letzteAenderung; - } - - public String getMedia() { - return this.media; - } - - public void setMedia(String media) { - this.media = media; - } - - public String getMediaDesk() { - return this.mediaDesk; - } - - public void setMediaDesk(String mediaDesk) { - this.mediaDesk = mediaDesk; - } - - public Long getMittelungsdauer() { - return this.mittelungsdauer; - } - - public void setMittelungsdauer(Long mittelungsdauer) { - this.mittelungsdauer = mittelungsdauer; - } - - public Character getMpKat() { - return this.mpKat; - } - - public void setMpKat(Character mpKat) { - this.mpKat = mpKat; - } - - public String getMplId() { - return this.mplId; - } - - public void setMplId(String mplId) { - this.mplId = mplId; - } - - public Integer getMprId() { - return this.mprId; - } - - public void setMprId(Integer mprId) { - this.mprId = mprId; - } - - public String getMstId() { - return this.mstId; - } - - public void setMstId(String mstId) { - this.mstId = mstId; - } - - public String getNetzbetreiberId() { - return this.netzbetreiberId; - } - - public void setNetzbetreiberId(String netzbetreiberId) { - this.netzbetreiberId = netzbetreiberId; - } - - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - public Integer getProbeNehmerId() { - return this.probeNehmerId; - } - - public void setProbeNehmerId(Integer probeNehmerId) { - this.probeNehmerId = probeNehmerId; - } - - public Timestamp getProbeentnahmeBeginn() { - return this.probeentnahmeBeginn; - } - - public void setProbeentnahmeBeginn(Timestamp probeentnahmeBeginn) { - this.probeentnahmeBeginn = probeentnahmeBeginn; - } - - public Timestamp getProbeentnahmeEnde() { - return this.probeentnahmeEnde; - } - - public void setProbeentnahmeEnde(Timestamp probeentnahmeEnde) { - this.probeentnahmeEnde = probeentnahmeEnde; - } - - public Integer getProbenartId() { - return this.probenartId; - } - - public void setProbenartId(Integer probenartId) { - this.probenartId = probenartId; - } - - public Timestamp getSolldatumBeginn() { - return this.solldatumBeginn; - } - - public void setSolldatumBeginn(Timestamp solldatumBeginn) { - this.solldatumBeginn = solldatumBeginn; - } - - public Timestamp getSolldatumEnde() { - return this.solldatumEnde; - } - - public void setSolldatumEnde(Timestamp solldatumEnde) { - this.solldatumEnde = solldatumEnde; - } - - public Boolean getTest() { - return this.test; - } - - public void setTest(Boolean test) { - this.test = test; - } - - public String getUmwId() { - return this.umwId; - } - - public void setUmwId(String umwId) { - this.umwId = umwId; - } - - public Boolean getReadonly() { - return readonly; - } - - public void setReadonly(Boolean readonly) { - this.readonly = readonly; - } - - public LProbe toLProbe() { - LProbe probe = new LProbe(); - probe.setProbeId(probeId); - probe.setMstId(mstId); - probe.setUmwId(umwId); - probe.setTest(test); - probe.setHauptprobenNr(hauptprobenNr); - probe.setBaId(baId); - probe.setMediaDesk(mediaDesk); - probe.setMedia(media); - probe.setProbenartId(probenartId); - probe.setDatenbasisId(datenbasisId); - probe.setProbeentnahmeBeginn(probeentnahmeBeginn); - probe.setProbeentnahmeEnde(probeentnahmeEnde); - probe.setMittelungsdauer(mittelungsdauer); - probe.setLetzteAenderung(letzteAenderung); - probe.setErzeugerId(erzeugerId); - probe.setProbeNehmerId(probeNehmerId); - probe.setMpKat(mpKat); - probe.setMplId(mplId); - probe.setMprId(mprId); - probe.setSolldatumBeginn(solldatumBeginn); - probe.setSolldatumEnde(solldatumEnde); - probe.setNetzbetreiberId(netzbetreiberId); - - return probe; - } -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LProbeInfoId.java --- a/src/main/java/de/intevation/lada/model/LProbeInfoId.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - - -@Embeddable -public class LProbeInfoId -implements Serializable -{ - @Column(name = "probe_id", nullable = false) - private String probeId; - - public LProbeInfoId() { - } - - public LProbeInfoId(String probeId) { - this.probeId = probeId; - } - - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Override - public boolean equals(Object other) { - if ((this == other)) - return true; - if ((other == null)) - return false; - if (!(other instanceof LProbeInfoId)) - return false; - LProbeInfoId castOther = (LProbeInfoId) other; - - return ((this.getProbeId() == castOther.getProbeId()) || (this - .getProbeId() != null && castOther.getProbeId() != null && this - .getProbeId().equals(castOther.getProbeId()))); - } - - @Override - public int hashCode() { - int result = 17; - - result = 37 * result - + (getProbeId() == null ? 0 : this.getProbeId().hashCode()); - result = 37 * result; - return result; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LStatus.java --- a/src/main/java/de/intevation/lada/model/LStatus.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import java.util.Date; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * LStatus generated by hbm2java - */ -@Entity -@Table(name = "l_status", schema = "public") -@SequenceGenerator(name = "STATUS_ID_STORE", sequenceName = "status_id_seq") -public class LStatus implements java.io.Serializable { - - private LStatusId id; - private Integer sId; - private String probeId; - private String erzeuger; - private Integer messungsId; - private Short status; - private Date SDatum; - private String SKommentar; - - public LStatus() { - } - - public LStatus(LStatusId id, String probeId, String erzeuger, - Integer messungsId, Date SDatum) { - this.id = id; - this.setProbeId(probeId); - this.erzeuger = erzeuger; - this.messungsId = messungsId; - this.SDatum = SDatum; - } - - public LStatus(LStatusId id, String probeId, String erzeuger, - Integer messungsId, Short status, Date SDatum, String SKommentar - ) { - this.id = id; - this.setProbeId(probeId); - this.erzeuger = erzeuger; - this.messungsId = messungsId; - this.status = status; - this.SDatum = SDatum; - this.SKommentar = SKommentar; - } - - @EmbeddedId - @AttributeOverrides({ - @AttributeOverride(name = "probeId", column = @Column(name = "probe_id", nullable = false, length = 20)), - @AttributeOverride(name = "messungsId", column = @Column(name = "messungs_id", nullable = false)), - @AttributeOverride(name = "SId", column = @Column(name = "s_id", nullable = false)) }) - public LStatusId getId() { - return this.id; - } - - public void setId(LStatusId id) { - this.id = id; - } - - @Column(name = "s_id", nullable = false, insertable = false, updatable = false) - public Integer getSId() { - return sId; - } - - public void setSId(Integer sId) { - this.sId = sId; - } - - @Column(name = "probe_id", nullable = false, insertable = false, updatable = false) - public String getProbeId() { - return probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "erzeuger", nullable = false) - public String getErzeuger() { - return this.erzeuger; - } - - public void setErzeuger(String erzeuger) { - this.erzeuger = erzeuger; - } - - @Column(name = "messungs_id", nullable = false, insertable = false, updatable = false) - public Integer getMessungsId() { - return this.messungsId; - } - - public void setMessungsId(Integer messungsId) { - this.messungsId = messungsId; - } - - @Column(name = "status") - public Short getStatus() { - return this.status; - } - - public void setStatus(Short status) { - this.status = status; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "s_datum", nullable = false, length = 35) - public Date getSDatum() { - return this.SDatum; - } - - public void setSDatum(Date SDatum) { - this.SDatum = SDatum; - } - - @Column(name = "s_kommentar", length = 1024) - public String getSKommentar() { - return this.SKommentar; - } - - public void setSKommentar(String SKommentar) { - this.SKommentar = SKommentar; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LStatusId.java --- a/src/main/java/de/intevation/lada/model/LStatusId.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; - -/** - * LStatusId generated by hbm2java - */ -@Embeddable -public class LStatusId implements java.io.Serializable { - - private String probeId; - private Integer messungsId; - private short SId; - - public LStatusId() { - } - - public LStatusId(String probeId, Integer messungsId, short SId) { - this.probeId = probeId; - this.messungsId = messungsId; - this.SId = SId; - } - - @Column(name = "probe_id", nullable = false, length = 20) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "messungs_id", nullable = false) - public Integer getMessungsId() { - return this.messungsId; - } - - public void setMessungsId(Integer messungsId) { - this.messungsId = messungsId; - } - - @Column(name = "s_id", nullable = false) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "STATUS_ID_STORE") - public short getSId() { - return this.SId; - } - - public void setSId(short SId) { - this.SId = SId; - } - - public boolean equals(Object other) { - if ((this == other)) - return true; - if ((other == null)) - return false; - if (!(other instanceof LStatusId)) - return false; - LStatusId castOther = (LStatusId) other; - - return ((this.getProbeId() == castOther.getProbeId()) || (this - .getProbeId() != null && castOther.getProbeId() != null && this - .getProbeId().equals(castOther.getProbeId()))) - && (this.getMessungsId() == castOther.getMessungsId()) - && (this.getSId() == castOther.getSId()); - } - - public int hashCode() { - int result = 17; - - result = 37 * result - + (getProbeId() == null ? 0 : this.getProbeId().hashCode()); - result = 37 * result + this.getMessungsId(); - result = 37 * result + this.getSId(); - return result; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LZusatzWert.java --- a/src/main/java/de/intevation/lada/model/LZusatzWert.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import java.util.Date; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * LZusatzWert generated by hbm2java - */ -@Entity -@Table(name = "l_zusatz_wert", schema = "public") -public class LZusatzWert implements java.io.Serializable { - - private LZusatzWertId id; - private String probeId; - private String pzsId; - private Float nwgZuMesswert; - private Float messwertPzs; - private Float messfehler; - private Date letzteAenderung; - - public LZusatzWert() { - } - - public LZusatzWert(LZusatzWertId id, String probeId, - String pzsId) { - this.id = id; - this.probeId = probeId; - this.pzsId = pzsId; - } - - public LZusatzWert(LZusatzWertId id, String probeId, - SProbenZusatz SProbenZusatz, Float nwgZuMesswert, Float messwertPzs, - Float messfehler, Date letzteAenderung) { - this.id = id; - this.probeId = probeId; - this.pzsId = pzsId; - this.nwgZuMesswert = nwgZuMesswert; - this.messwertPzs = messwertPzs; - this.messfehler = messfehler; - this.letzteAenderung = letzteAenderung; - } - - @EmbeddedId - @AttributeOverrides({ - @AttributeOverride(name = "probeId", column = @Column(name = "probe_id", nullable = false, length = 20)), - @AttributeOverride(name = "pzsId", column = @Column(name = "pzs_id", nullable = false, length = 3)) }) - public LZusatzWertId getId() { - return this.id; - } - - public void setId(LZusatzWertId id) { - this.id = id; - } - - @Column(name = "probe_id", nullable = false, insertable = false, updatable = false) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "pzs_id", nullable = false, insertable = false, updatable = false) - public String getPzsId() { - return this.pzsId; - } - - public void setPzsId(String pzsId) { - this.pzsId = pzsId; - } - - @Column(name = "nwg_zu_messwert", precision = 8, scale = 8) - public Float getNwgZuMesswert() { - return this.nwgZuMesswert; - } - - public void setNwgZuMesswert(Float nwgZuMesswert) { - this.nwgZuMesswert = nwgZuMesswert; - } - - @Column(name = "messwert_pzs", precision = 8, scale = 8) - public Float getMesswertPzs() { - return this.messwertPzs; - } - - public void setMesswertPzs(Float messwertPzs) { - this.messwertPzs = messwertPzs; - } - - @Column(name = "messfehler", precision = 8, scale = 8) - public Float getMessfehler() { - return this.messfehler; - } - - public void setMessfehler(Float messfehler) { - this.messfehler = messfehler; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "letzte_aenderung", length = 29) - public Date getLetzteAenderung() { - return this.letzteAenderung; - } - - public void setLetzteAenderung(Date letzteAenderung) { - this.letzteAenderung = letzteAenderung; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/LZusatzWertId.java --- a/src/main/java/de/intevation/lada/model/LZusatzWertId.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -/** - * LZusatzWertId generated by hbm2java - */ -@Embeddable -public class LZusatzWertId implements java.io.Serializable { - - private String probeId; - private String pzsId; - - public LZusatzWertId() { - } - - public LZusatzWertId(String probeId, String pzsId) { - this.probeId = probeId; - this.pzsId = pzsId; - } - - @Column(name = "probe_id", nullable = false, length = 20) - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - @Column(name = "pzs_id", nullable = false, length = 3) - public String getPzsId() { - return this.pzsId; - } - - public void setPzsId(String pzsId) { - this.pzsId = pzsId; - } - - public boolean equals(Object other) { - if ((this == other)) - return true; - if ((other == null)) - return false; - if (!(other instanceof LZusatzWertId)) - return false; - LZusatzWertId castOther = (LZusatzWertId) other; - - return ((this.getProbeId() == castOther.getProbeId()) || (this - .getProbeId() != null && castOther.getProbeId() != null && this - .getProbeId().equals(castOther.getProbeId()))) - && ((this.getPzsId() == castOther.getPzsId()) || (this - .getPzsId() != null && castOther.getPzsId() != null && this - .getPzsId().equals(castOther.getPzsId()))); - } - - public int hashCode() { - int result = 17; - - result = 37 * result - + (getProbeId() == null ? 0 : this.getProbeId().hashCode()); - result = 37 * result - + (getPzsId() == null ? 0 : this.getPzsId().hashCode()); - return result; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/Ort.java --- a/src/main/java/de/intevation/lada/model/Ort.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,203 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * Ort generated by hbm2java - */ -@Entity -@Table(name = "ort", schema = "public") -public class Ort implements java.io.Serializable { - - private int ortId; - private String OTyp; - private String bezeichnung; - private String beschreibung; - private Character unscharf; - private String nutsCode; - private String koordXExtern; - private String koordYExtern; - private Float hoeheLand; - private Date letzteAenderung; - private Double latitude; - private Double longitude; - private int staatId; - private String gemId; - - public Ort() { - } - - public Ort(int ortId) { - this.ortId = ortId; - } - - public Ort(int ortId, String OTyp, String bezeichnung, - String beschreibung, Character unscharf, String nutsCode, - String koordXExtern, String koordYExtern, Float hoeheLand, - Date letzteAenderung, Double latitude, Double longitude, - int staatId, String gemId) { - this.ortId = ortId; - this.OTyp = OTyp; - this.bezeichnung = bezeichnung; - this.beschreibung = beschreibung; - this.unscharf = unscharf; - this.nutsCode = nutsCode; - this.koordXExtern = koordXExtern; - this.koordYExtern = koordYExtern; - this.hoeheLand = hoeheLand; - this.letzteAenderung = letzteAenderung; - this.latitude = latitude; - this.longitude = longitude; - this.staatId = staatId; - this.gemId = gemId; - } - - @Id - @Column(name = "ort_id", unique = true, nullable = false) - @SequenceGenerator(name = "ORT_ID_STORE", sequenceName = "ort_ort_id_seq", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ORT_ID_STORE") - public int getOrtId() { - return this.ortId; - } - - public void setOrtId(int ortId) { - this.ortId = ortId; - } - - @Column(name = "o_typ", length = 1) - public String getOTyp() { - return this.OTyp; - } - - public void setOTyp(String OTyp) { - this.OTyp = OTyp; - } - - @Column(name = "bezeichnung", length = 10) - public String getBezeichnung() { - return this.bezeichnung; - } - - public void setBezeichnung(String bezeichnung) { - this.bezeichnung = bezeichnung; - } - - @Column(name = "beschreibung", length = 100) - public String getBeschreibung() { - return this.beschreibung; - } - - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - @Column(name = "unscharf", length = 1) - public Character getUnscharf() { - return this.unscharf; - } - - public void setUnscharf(Character unscharf) { - this.unscharf = unscharf; - } - - @Column(name = "nuts_code", length = 10) - public String getNutsCode() { - return this.nutsCode; - } - - public void setNutsCode(String nutsCode) { - this.nutsCode = nutsCode; - } - - @Column(name = "koord_x_extern", length = 22) - public String getKoordXExtern() { - return this.koordXExtern; - } - - public void setKoordXExtern(String koordXExtern) { - this.koordXExtern = koordXExtern; - } - - @Column(name = "koord_y_extern", length = 22) - public String getKoordYExtern() { - return this.koordYExtern; - } - - public void setKoordYExtern(String koordYExtern) { - this.koordYExtern = koordYExtern; - } - - @Column(name = "hoehe_land", precision = 8, scale = 8) - public Float getHoeheLand() { - return this.hoeheLand; - } - - public void setHoeheLand(Float hoeheLand) { - this.hoeheLand = hoeheLand; - } - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "letzte_aenderung", length = 29) - public Date getLetzteAenderung() { - return this.letzteAenderung; - } - - public void setLetzteAenderung(Date letzteAenderung) { - this.letzteAenderung = letzteAenderung; - } - - @Column(name = "latitude", precision = 17, scale = 17) - public Double getLatitude() { - return this.latitude; - } - - public void setLatitude(Double latitude) { - this.latitude = latitude; - } - - @Column(name = "longitude", precision = 17, scale = 17) - public Double getLongitude() { - return this.longitude; - } - - public void setLongitude(Double longitude) { - this.longitude = longitude; - } - - @Column(name = "gem_id") - public String getGemId() { - return this.gemId; - } - - public void setGemId(String gemId) { - this.gemId= gemId; - } - - @Column(name = "staat_id") - public int getStaatId() { - return this.staatId; - } - - public void setStaatId(int staatId) { - this.staatId= staatId; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SDatenbasis.java --- a/src/main/java/de/intevation/lada/model/SDatenbasis.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * SDatenbasis generated by hbm2java - */ -@Entity -@Table(name = "s_datenbasis", schema = "public") -public class SDatenbasis implements java.io.Serializable { - - private short datenbasisId; - private String beschreibung; - private String datenbasis; - - public SDatenbasis() { - } - - public SDatenbasis(short datenbasisId) { - this.datenbasisId = datenbasisId; - } - - public SDatenbasis(short datenbasisId, String beschreibung, - String datenbasis) { - this.datenbasisId = datenbasisId; - this.beschreibung = beschreibung; - this.datenbasis = datenbasis; - } - - @Id - @Column(name = "datenbasis_id", unique = true, nullable = false) - public short getDatenbasisId() { - return this.datenbasisId; - } - - public void setDatenbasisId(short datenbasisId) { - this.datenbasisId = datenbasisId; - } - - @Column(name = "beschreibung", length = 30) - public String getBeschreibung() { - return this.beschreibung; - } - - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - @Column(name = "datenbasis", length = 6) - public String getDatenbasis() { - return this.datenbasis; - } - - public void setDatenbasis(String datenbasis) { - this.datenbasis = datenbasis; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SKoordinatenArt.java --- a/src/main/java/de/intevation/lada/model/SKoordinatenArt.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * SKoordinatenArt generated by hbm2java - */ -@Entity -@Table(name = "s_koordinaten_art", schema = "public") -public class SKoordinatenArt implements java.io.Serializable { - - private short kdaId; - private String koordinatenart; - private String idfGeoKey; - - public SKoordinatenArt() { - } - - public SKoordinatenArt(short kdaId) { - this.kdaId = kdaId; - } - - public SKoordinatenArt(short kdaId, String koordinatenart, - String idfGeoKey) { - this.kdaId = kdaId; - this.koordinatenart = koordinatenart; - this.idfGeoKey = idfGeoKey; - } - - @Id - @Column(name = "kda_id", unique = true, nullable = false) - public short getKdaId() { - return this.kdaId; - } - - public void setKdaId(short kdaId) { - this.kdaId = kdaId; - } - - @Column(name = "koordinatenart", length = 50) - public String getKoordinatenart() { - return this.koordinatenart; - } - - public void setKoordinatenart(String koordinatenart) { - this.koordinatenart = koordinatenart; - } - - @Column(name = "idf_geo_key", length = 1) - public String getIdfGeoKey() { - return this.idfGeoKey; - } - - public void setIdfGeoKey(String idfGeoKey) { - this.idfGeoKey = idfGeoKey; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SMessEinheit.java --- a/src/main/java/de/intevation/lada/model/SMessEinheit.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * SMessEinheit generated by hbm2java - */ -@Entity -@Table(name = "s_mess_einheit", schema = "public") -public class SMessEinheit implements java.io.Serializable { - - private short mehId; - private String beschreibung; - private String einheit; - private String eudfMesseinheitId; - private Long umrechnungsFaktorEudf; - - public SMessEinheit() { - } - - public SMessEinheit(short mehId) { - this.mehId = mehId; - } - - public SMessEinheit(short mehId, String beschreibung, String einheit, - String eudfMesseinheitId, Long umrechnungsFaktorEudf) { - this.mehId = mehId; - this.beschreibung = beschreibung; - this.einheit = einheit; - this.eudfMesseinheitId = eudfMesseinheitId; - this.umrechnungsFaktorEudf = umrechnungsFaktorEudf; - } - - @Id - @Column(name = "meh_id", unique = true, nullable = false) - public short getMehId() { - return this.mehId; - } - - public void setMehId(short mehId) { - this.mehId = mehId; - } - - @Column(name = "beschreibung", length = 50) - public String getBeschreibung() { - return this.beschreibung; - } - - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - @Column(name = "einheit", length = 12) - public String getEinheit() { - return this.einheit; - } - - public void setEinheit(String einheit) { - this.einheit = einheit; - } - - @Column(name = "eudf_messeinheit_id", length = 8) - public String getEudfMesseinheitId() { - return this.eudfMesseinheitId; - } - - public void setEudfMesseinheitId(String eudfMesseinheitId) { - this.eudfMesseinheitId = eudfMesseinheitId; - } - - @Column(name = "umrechnungs_faktor_eudf") - public Long getUmrechnungsFaktorEudf() { - return this.umrechnungsFaktorEudf; - } - - public void setUmrechnungsFaktorEudf(Long umrechnungsFaktorEudf) { - this.umrechnungsFaktorEudf = umrechnungsFaktorEudf; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SMessMethode.java --- a/src/main/java/de/intevation/lada/model/SMessMethode.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 24.06.2013 16:31:53 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - - -/** - * SMessMethode generated by hbm2java - */ -@Entity -@Table(name = "s_mess_methode" - , schema = "public") -public class SMessMethode -implements java.io.Serializable -{ - - private String mmtId; - private String beschreibung; - private String messmethode; - - public SMessMethode() { - } - - public SMessMethode(String mmtId) { - this.mmtId = mmtId; - } - - public SMessMethode( - String mmtId, - String beschreibung, - String messmethode) { - this.mmtId = mmtId; - this.beschreibung = beschreibung; - this.messmethode = messmethode; - } - - @Id - @Column(name = "mmt_id", unique = true, nullable = false, length = 2) - public String getMmtId() { - return this.mmtId; - } - - public void setMmtId(String mmtId) { - this.mmtId = mmtId; - } - - @Column(name = "beschreibung", length = 300) - public String getBeschreibung() { - return this.beschreibung; - } - - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - @Column(name = "messmethode", length = 50) - public String getMessmethode() { - return this.messmethode; - } - - public void setMessmethode(String messmethode) { - this.messmethode = messmethode; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SMessStelle.java --- a/src/main/java/de/intevation/lada/model/SMessStelle.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * SMessStelle generated by hbm2java - */ -@Entity -@Table(name = "s_mess_stelle", schema = "public") -public class SMessStelle implements java.io.Serializable { - - private String mstId; - private String netzbetreiberId; - private String beschreibung; - private String messStelle; - private String mstTyp; - private String amtskennung; - - public SMessStelle() { - } - - public SMessStelle(String mstId) { - this.mstId = mstId; - } - - public SMessStelle(String mstId, String netzbetreiberId, - String beschreibung, String messStelle, String mstTyp, - String amtskennung) { - this.mstId = mstId; - this.netzbetreiberId = netzbetreiberId; - this.beschreibung = beschreibung; - this.messStelle = messStelle; - this.mstTyp = mstTyp; - this.amtskennung = amtskennung; - } - - @Id - @Column(name = "mst_id", unique = true, nullable = false, length = 5) - public String getMstId() { - return this.mstId; - } - - public void setMstId(String mstId) { - this.mstId = mstId; - } - - @Column(name = "netzbetreiber_id", length = 2) - public String getNetzbetreiberId() { - return this.netzbetreiberId; - } - - public void setNetzbetreiberId(String netzbetreiberId) { - this.netzbetreiberId = netzbetreiberId; - } - - @Column(name = "beschreibung", length = 300) - public String getBeschreibung() { - return this.beschreibung; - } - - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - @Column(name = "mess_stelle", length = 60) - public String getMessStelle() { - return this.messStelle; - } - - public void setMessStelle(String messStelle) { - this.messStelle = messStelle; - } - - @Column(name = "mst_typ", length = 1) - public String getMstTyp() { - return this.mstTyp; - } - - public void setMstTyp(String mstTyp) { - this.mstTyp = mstTyp; - } - - @Column(name = "amtskennung", length = 6) - public String getAmtskennung() { - return this.amtskennung; - } - - public void setAmtskennung(String amtskennung) { - this.amtskennung = amtskennung; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SMessgroesse.java --- a/src/main/java/de/intevation/lada/model/SMessgroesse.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,127 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * SMessgroesse generated by hbm2java - */ -@Entity -@Table(name = "s_messgroesse", schema = "public") -public class SMessgroesse implements java.io.Serializable { - - private int messgroesseId; - private String beschreibung; - private String messgroesse; - private String defaultFarbe; - private String idfNuklidKey; - private Character istLeitnuklid; - private Long eudfNuklidId; - private String kennungBvl; - - public SMessgroesse() { - } - - public SMessgroesse(int messgroesseId, String messgro0esse) { - this.messgroesseId = messgroesseId; - this.messgroesse = messgro0esse; - } - - public SMessgroesse(int messgroesseId, String beschreibung, - String messgro0esse, String defaultFarbe, String idfNuklidKey, - Character istLeitnuklid, Long eudfNuklidId, String kennungBvl) { - this.messgroesseId = messgroesseId; - this.beschreibung = beschreibung; - this.messgroesse = messgro0esse; - this.defaultFarbe = defaultFarbe; - this.idfNuklidKey = idfNuklidKey; - this.istLeitnuklid = istLeitnuklid; - this.eudfNuklidId = eudfNuklidId; - this.kennungBvl = kennungBvl; - } - - @Id - @Column(name = "messgroesse_id", unique = true, nullable = false) - public int getMessgroesseId() { - return this.messgroesseId; - } - - public void setMessgroesseId(int messgroesseId) { - this.messgroesseId = messgroesseId; - } - - @Column(name = "beschreibung", length = 300) - public String getBeschreibung() { - return this.beschreibung; - } - - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - @Column(name = "messgroesse", nullable = false, length = 50) - public String getMessgroesse() { - return this.messgroesse; - } - - public void setMessgroesse(String messgro0esse) { - this.messgroesse = messgro0esse; - } - - @Column(name = "default_farbe", length = 9) - public String getDefaultFarbe() { - return this.defaultFarbe; - } - - public void setDefaultFarbe(String defaultFarbe) { - this.defaultFarbe = defaultFarbe; - } - - @Column(name = "idf_nuklid_key", length = 6) - public String getIdfNuklidKey() { - return this.idfNuklidKey; - } - - public void setIdfNuklidKey(String idfNuklidKey) { - this.idfNuklidKey = idfNuklidKey; - } - - @Column(name = "ist_leitnuklid", length = 1) - public Character getIstLeitnuklid() { - return this.istLeitnuklid; - } - - public void setIstLeitnuklid(Character istLeitnuklid) { - this.istLeitnuklid = istLeitnuklid; - } - - @Column(name = "eudf_nuklid_id") - public Long getEudfNuklidId() { - return this.eudfNuklidId; - } - - public void setEudfNuklidId(Long eudfNuklidId) { - this.eudfNuklidId = eudfNuklidId; - } - - @Column(name = "kennung_bvl", length = 7) - public String getKennungBvl() { - return this.kennungBvl; - } - - public void setKennungBvl(String kennungBvl) { - this.kennungBvl = kennungBvl; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SNetzBetreiber.java --- a/src/main/java/de/intevation/lada/model/SNetzBetreiber.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -import java.io.Serializable; -import javax.persistence.*; - - -/** - * The persistent class for the s_netz_betreiber database table. - * - */ -@Entity -@Table(name="s_netz_betreiber") -public class SNetzBetreiber implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @Column(name="netzbetreiber_id") - private String netzbetreiberId; - - private String aktiv; - - @Column(name="idf_netzbetreiber") - private String idfNetzbetreiber; - - @Column(name="is_bmn") - private String isBmn; - - private String mailverteiler; - - private String netzbetreiber; - - @Column(name="zust_mst_id") - private String zustMstId; - - public SNetzBetreiber() { - } - - public String getNetzbetreiberId() { - return this.netzbetreiberId; - } - - public void setNetzbetreiberId(String netzbetreiberId) { - this.netzbetreiberId = netzbetreiberId; - } - - public String getAktiv() { - return this.aktiv; - } - - public void setAktiv(String aktiv) { - this.aktiv = aktiv; - } - - public String getIdfNetzbetreiber() { - return this.idfNetzbetreiber; - } - - public void setIdfNetzbetreiber(String idfNetzbetreiber) { - this.idfNetzbetreiber = idfNetzbetreiber; - } - - public String getIsBmn() { - return this.isBmn; - } - - public void setIsBmn(String isBmn) { - this.isBmn = isBmn; - } - - public String getMailverteiler() { - return this.mailverteiler; - } - - public void setMailverteiler(String mailverteiler) { - this.mailverteiler = mailverteiler; - } - - public String getNetzbetreiber() { - return this.netzbetreiber; - } - - public void setNetzbetreiber(String netzbetreiber) { - this.netzbetreiber = netzbetreiber; - } - - public String getZustMstId() { - return this.zustMstId; - } - - public void setZustMstId(String zustMstId) { - this.zustMstId = zustMstId; - } - -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SPflichtMessgroesse.java --- a/src/main/java/de/intevation/lada/model/SPflichtMessgroesse.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -import java.io.Serializable; -import javax.persistence.*; - - -/** - * The persistent class for the s_pflicht_messgroesse database table. - * - */ -@Entity -@Table(name="s_pflicht_messgroesse") -public class SPflichtMessgroesse implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - private Integer id; - - @Column(name="datenbasis_id") - private Integer datenbasisId; - - @Column(name="messgroesse_id") - private Integer messgroesseId; - - @Column(name="mmt_id") - private String mmtId; - - @Column(name="umw_id") - private String umwId; - - public SPflichtMessgroesse() { - } - - public Integer getId() { - return this.id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getDatenbasisId() { - return this.datenbasisId; - } - - public void setDatenbasisId(Integer datenbasisId) { - this.datenbasisId = datenbasisId; - } - - public Integer getMessgroesseId() { - return this.messgroesseId; - } - - public void setMessgroesseId(Integer messgroesseId) { - this.messgroesseId = messgroesseId; - } - - public String getMmtId() { - return this.mmtId; - } - - public void setMmtId(String mmtId) { - this.mmtId = mmtId; - } - - public String getUmwId() { - return this.umwId; - } - - public void setUmwId(String umwId) { - this.umwId = umwId; - } - -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SProbenZusatz.java --- a/src/main/java/de/intevation/lada/model/SProbenZusatz.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; - -/** - * SProbenZusatz generated by hbm2java - */ -@Entity -@Table(name = "s_proben_zusatz", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = "eudf_keyword")) -public class SProbenZusatz implements java.io.Serializable { - - private String pzsId; - private Short mehId; - private String beschreibung; - private String zusatzwert; - private String eudfKeyword; - - public SProbenZusatz() { - } - - public SProbenZusatz(String pzsId, String beschreibung, String zusatzwert) { - this.pzsId = pzsId; - this.beschreibung = beschreibung; - this.zusatzwert = zusatzwert; - } - - public SProbenZusatz(String pzsId, Short mehId, String beschreibung, - String zusatzwert, String eudfKeyword) { - this.pzsId = pzsId; - this.mehId = mehId; - this.beschreibung = beschreibung; - this.zusatzwert = zusatzwert; - this.eudfKeyword = eudfKeyword; - } - - @Id - @Column(name = "pzs_id", unique = true, nullable = false, length = 3) - public String getPzsId() { - return this.pzsId; - } - - public void setPzsId(String pzsId) { - this.pzsId = pzsId; - } - - @Column(name = "meh_id") - public Short getMehId() { - return this.mehId; - } - - public void setMehId(Short mehId) { - this.mehId = mehId; - } - - @Column(name = "beschreibung", nullable = false, length = 50) - public String getBeschreibung() { - return this.beschreibung; - } - - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - @Column(name = "zusatzwert", nullable = false, length = 7) - public String getZusatzwert() { - return this.zusatzwert; - } - - public void setZusatzwert(String zusatzwert) { - this.zusatzwert = zusatzwert; - } - - @Column(name = "eudf_keyword", unique = true, length = 40) - public String getEudfKeyword() { - return this.eudfKeyword; - } - - public void setEudfKeyword(String eudfKeyword) { - this.eudfKeyword = eudfKeyword; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SProbenart.java --- a/src/main/java/de/intevation/lada/model/SProbenart.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * SProbenart generated by hbm2java - */ -@Entity -@Table(name = "s_probenart", schema = "public") -public class SProbenart implements java.io.Serializable { - - private short probenartId; - private String beschreibung; - private String probenart; - private String probenartEudfId; - - public SProbenart() { - } - - public SProbenart(short probenartId, String probenart, - String probenartEudfId) { - this.probenartId = probenartId; - this.probenart = probenart; - this.probenartEudfId = probenartEudfId; - } - - public SProbenart(short probenartId, String beschreibung, String probenart, - String probenartEudfId) { - this.probenartId = probenartId; - this.beschreibung = beschreibung; - this.probenart = probenart; - this.probenartEudfId = probenartEudfId; - } - - @Id - @Column(name = "probenart_id", unique = true, nullable = false) - public short getProbenartId() { - return this.probenartId; - } - - public void setProbenartId(short probenartId) { - this.probenartId = probenartId; - } - - @Column(name = "beschreibung", length = 30) - public String getBeschreibung() { - return this.beschreibung; - } - - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - @Column(name = "probenart", nullable = false, length = 5) - public String getProbenart() { - return this.probenart; - } - - public void setProbenart(String probenart) { - this.probenart = probenart; - } - - @Column(name = "probenart_eudf_id", nullable = false, length = 1) - public String getProbenartEudfId() { - return this.probenartEudfId; - } - - public void setProbenartEudfId(String probenartEudfId) { - this.probenartEudfId = probenartEudfId; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SStaat.java --- a/src/main/java/de/intevation/lada/model/SStaat.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - -/** - * SStaat generated by hbm2java - */ -@Entity -@Table(name = "s_staat", schema = "public") -public class SStaat implements java.io.Serializable { - - private short staatId; - private SKoordinatenArt SKoordinatenArt; - private String staat; - private short hklId; - private String staatIso; - private String staatKurz; - private Character eu; - private String koordXExtern; - private String koordYExtern; - - public SStaat() { - } - - public SStaat(short staatId, String staat, short hklId, String staatIso) { - this.staatId = staatId; - this.staat = staat; - this.hklId = hklId; - this.staatIso = staatIso; - } - - public SStaat(short staatId, SKoordinatenArt SKoordinatenArt, String staat, - short hklId, String staatIso, String staatKurz, Character eu, - String koordXExtern, String koordYExtern) { - this.staatId = staatId; - this.SKoordinatenArt = SKoordinatenArt; - this.staat = staat; - this.hklId = hklId; - this.staatIso = staatIso; - this.staatKurz = staatKurz; - this.eu = eu; - this.koordXExtern = koordXExtern; - this.koordYExtern = koordYExtern; - } - - @Id - @Column(name = "staat_id", unique = true, nullable = false) - public short getStaatId() { - return this.staatId; - } - - public void setStaatId(short staatId) { - this.staatId = staatId; - } - - @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "kda_id") - public SKoordinatenArt getSKoordinatenArt() { - return this.SKoordinatenArt; - } - - public void setSKoordinatenArt(SKoordinatenArt SKoordinatenArt) { - this.SKoordinatenArt = SKoordinatenArt; - } - - @Column(name = "staat", nullable = false, length = 50) - public String getStaat() { - return this.staat; - } - - public void setStaat(String staat) { - this.staat = staat; - } - - @Column(name = "hkl_id", nullable = false) - public short getHklId() { - return this.hklId; - } - - public void setHklId(short hklId) { - this.hklId = hklId; - } - - @Column(name = "staat_iso", nullable = false, length = 2) - public String getStaatIso() { - return this.staatIso; - } - - public void setStaatIso(String staatIso) { - this.staatIso = staatIso; - } - - @Column(name = "staat_kurz", length = 5) - public String getStaatKurz() { - return this.staatKurz; - } - - public void setStaatKurz(String staatKurz) { - this.staatKurz = staatKurz; - } - - @Column(name = "eu", length = 1) - public Character getEu() { - return this.eu; - } - - public void setEu(Character eu) { - this.eu = eu; - } - - @Column(name = "koord_x_extern", length = 22) - public String getKoordXExtern() { - return this.koordXExtern; - } - - public void setKoordXExtern(String koordXExtern) { - this.koordXExtern = koordXExtern; - } - - @Column(name = "koord_y_extern", length = 22) - public String getKoordYExtern() { - return this.koordYExtern; - } - - public void setKoordYExtern(String koordYExtern) { - this.koordYExtern = koordYExtern; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SUmwelt.java --- a/src/main/java/de/intevation/lada/model/SUmwelt.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; - -/** - * SUmwelt generated by hbm2java - */ -@Entity -@Table(name = "s_umwelt", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = "umwelt_bereich")) -public class SUmwelt implements java.io.Serializable { - - private String umwId; - private SMessEinheit SMessEinheit; - private String beschreibung; - private String umweltBereich; - - public SUmwelt() { - } - - public SUmwelt(String umwId, String umweltBereich) { - this.umwId = umwId; - this.umweltBereich = umweltBereich; - } - - public SUmwelt(String umwId, SMessEinheit SMessEinheit, - String beschreibung, String umweltBereich) { - this.umwId = umwId; - this.SMessEinheit = SMessEinheit; - this.beschreibung = beschreibung; - this.umweltBereich = umweltBereich; - } - - @Id - @Column(name = "umw_id", unique = true, nullable = false, length = 3) - public String getUmwId() { - return this.umwId; - } - - public void setUmwId(String umwId) { - this.umwId = umwId; - } - - @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "meh_id") - public SMessEinheit getSMessEinheit() { - return this.SMessEinheit; - } - - public void setSMessEinheit(SMessEinheit SMessEinheit) { - this.SMessEinheit = SMessEinheit; - } - - @Column(name = "beschreibung", length = 300) - public String getBeschreibung() { - return this.beschreibung; - } - - public void setBeschreibung(String beschreibung) { - this.beschreibung = beschreibung; - } - - @Column(name = "umwelt_bereich", unique = true, nullable = false, length = 80) - public String getUmweltBereich() { - return this.umweltBereich; - } - - public void setUmweltBereich(String umweltBereich) { - this.umweltBereich = umweltBereich; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/SVerwaltungseinheit.java --- a/src/main/java/de/intevation/lada/model/SVerwaltungseinheit.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,225 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model; - -// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * SVerwaltungseinheit generated by hbm2java - */ -@Entity -@Table(name = "s_verwaltungseinheit", schema = "public") -public class SVerwaltungseinheit implements java.io.Serializable { - - private String gemId; - private String bundesland; - private Short kdaId; - private String kreis; - private String nuts; - private String regbezirk; - private String bezeichnung; - private char isBundesland; - private char isGemeinde; - private char isLandkreis; - private char isRegbezirk; - private String koordXExtern; - private String koordYExtern; - private String plz; - private Double longitude; - private Double latitude; - - public SVerwaltungseinheit() { - } - - public SVerwaltungseinheit(String gemId, String bundesland, - String bezeichnung, char isBundesland, char isGemeinde, - char isLandkreis, char isRegbezirk) { - this.gemId = gemId; - this.bundesland = bundesland; - this.bezeichnung = bezeichnung; - this.isBundesland = isBundesland; - this.isGemeinde = isGemeinde; - this.isLandkreis = isLandkreis; - this.isRegbezirk = isRegbezirk; - } - - public SVerwaltungseinheit(String gemId, String bundesland, Short kdaId, - String kreis, String nuts, String regbezirk, String bezeichnung, - char isBundesland, char isGemeinde, char isLandkreis, - char isRegbezirk, String koordXExtern, - String koordYExtern, String plz, - Double longitude, Double latitude) { - this.gemId = gemId; - this.bundesland = bundesland; - this.kdaId = kdaId; - this.kreis = kreis; - this.nuts = nuts; - this.regbezirk = regbezirk; - this.bezeichnung = bezeichnung; - this.isBundesland = isBundesland; - this.isGemeinde = isGemeinde; - this.isLandkreis = isLandkreis; - this.isRegbezirk = isRegbezirk; - this.koordXExtern = koordXExtern; - this.koordYExtern = koordYExtern; - this.plz = plz; - this.longitude = longitude; - this.latitude = latitude; - } - - @Id - @Column(name = "gem_id", unique = true, nullable = false, length = 8) - public String getGemId() { - return this.gemId; - } - - public void setGemId(String gemId) { - this.gemId = gemId; - } - - @Column(name = "bundesland", nullable = false, length = 8) - public String getBundesland() { - return this.bundesland; - } - - public void setBundesland(String bundesland) { - this.bundesland = bundesland; - } - - @Column(name = "kda_id") - public Short getKdaId() { - return this.kdaId; - } - - public void setKdaId(Short kdaId) { - this.kdaId = kdaId; - } - - @Column(name = "kreis", length = 8) - public String getKreis() { - return this.kreis; - } - - public void setKreis(String kreis) { - this.kreis = kreis; - } - - @Column(name = "nuts", length = 10) - public String getNuts() { - return this.nuts; - } - - public void setNuts(String nuts) { - this.nuts = nuts; - } - - @Column(name = "regbezirk", length = 8) - public String getRegbezirk() { - return this.regbezirk; - } - - public void setRegbezirk(String regbezirk) { - this.regbezirk = regbezirk; - } - - @Column(name = "bezeichnung", nullable = false, length = 80) - public String getBezeichnung() { - return this.bezeichnung; - } - - public void setBezeichnung(String bezeichnung) { - this.bezeichnung = bezeichnung; - } - - @Column(name = "is_bundesland", nullable = false, length = 1) - public char getIsBundesland() { - return this.isBundesland; - } - - public void setIsBundesland(char isBundesland) { - this.isBundesland = isBundesland; - } - - @Column(name = "is_gemeinde", nullable = false, length = 1) - public char getIsGemeinde() { - return this.isGemeinde; - } - - public void setIsGemeinde(char isGemeinde) { - this.isGemeinde = isGemeinde; - } - - @Column(name = "is_landkreis", nullable = false, length = 1) - public char getIsLandkreis() { - return this.isLandkreis; - } - - public void setIsLandkreis(char isLandkreis) { - this.isLandkreis = isLandkreis; - } - - @Column(name = "is_regbezirk", nullable = false, length = 1) - public char getIsRegbezirk() { - return this.isRegbezirk; - } - - public void setIsRegbezirk(char isRegbezirk) { - this.isRegbezirk = isRegbezirk; - } - - @Column(name = "koord_x_extern", length = 22) - public String getKoordXExtern() { - return this.koordXExtern; - } - - public void setKoordXExtern(String koordXExtern) { - this.koordXExtern = koordXExtern; - } - - @Column(name = "koord_y_extern", length = 22) - public String getKoordYExtern() { - return this.koordYExtern; - } - - public void setKoordYExtern(String koordYExtern) { - this.koordYExtern = koordYExtern; - } - - @Column(name = "plz", length = 6) - public String getPlz() { - return this.plz; - } - - public void setPlz(String plz) { - this.plz = plz; - } - - @Column(name = "longitude", precision = 17, scale = 17) - public Double getLongitude() { - return this.longitude; - } - - public void setLongitude(Double longitude) { - this.longitude = longitude; - } - - @Column(name = "latitude", precision = 17, scale = 17) - public Double getLatitude() { - return this.latitude; - } - - public void setLatitude(Double latitude) { - this.latitude = latitude; - } - -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/query/QueryConfig.java --- a/src/main/java/de/intevation/lada/model/query/QueryConfig.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model.query; - -import java.util.List; - -import de.intevation.lada.model.LProbeInfo; - -/** - * Container for SQL query configuration. - * - * The server can filter {@link LProbeInfo} objects by configurable SQL queries - * as described in the project wiki (https://bfs-intern.intevation.de/Server/Suche). - * This container is used to store the config at runtime. - * - * @author Raimund Renkert - */ -public class QueryConfig -{ - int id; - String name; - String description; - String sql; - List filters; - List results; - - public QueryConfig() - { - } - - /** - * @return the id - */ - public int getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(int id) { - this.id = id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * @return the sql - */ - public String getSql() { - return sql; - } - - /** - * @param sql the sql to set - */ - public void setSql(String sql) { - this.sql = sql; - } - - /** - * @return the filter - */ - public List getFilters() { - return filters; - } - - /** - * @param filters the filter to set - */ - public void setFilters(List filters) { - this.filters = filters; - } - - /** - * @return the results - */ - public List getResults() { - return results; - } - - /** - * @param results the results to set - */ - public void setResults(List results) { - this.results = results; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/query/QueryFilter.java --- a/src/main/java/de/intevation/lada/model/query/QueryFilter.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model.query; - -/** - * Container for data filter. - * Stores filter defined in the SQL query configuration. - * - * @author Raimund Renkert - */ -public class QueryFilter -{ - private String dataIndex; - private String type; - private String label; - private boolean multiSelect; - - /** - * Default constructor. - */ - public QueryFilter() { - } - - /** - * Constructor to create a filled filter. - * - * @param dataIndex The dataIndex. - * @param type The filter type. - * @param label The label. - */ - public QueryFilter(String dataIndex, String type, String label) { - this.dataIndex = dataIndex; - this.type = type; - this.label = label; - } - - /** - * @return The dataIndex - */ - public String getDataIndex() { - return dataIndex; - } - - /** - * @param dataIndex THe dataIndex to set. - */ - public void setDataIndex(String dataIndex) { - this.dataIndex = dataIndex; - } - - /** - * @return The filter type. - */ - public String getType() { - return type; - } - - /** - * @param type The filter type to set. - */ - public void setType(String type) { - this.type = type; - } - - /** - * @return The label. - */ - public String getLabel() { - return label; - } - - /** - * @param label The label to set. - */ - public void setLabel(String label) { - this.label = label; - } - - /** - * @return the multiSelect - */ - public boolean isMultiSelect() { - return multiSelect; - } - - /** - * @param multiSelect the multiSelect to set - */ - public void setMultiSelect(boolean multiSelect) { - this.multiSelect = multiSelect; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/model/query/ResultConfig.java --- a/src/main/java/de/intevation/lada/model/query/ResultConfig.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.model.query; - -/** - * Container for result configurations. - * Provides config for the client like column header, column with and data index. - * - * @author Raimund Renkert - */ -public class ResultConfig -{ - String dataIndex; - String header; - Integer flex; - Integer width; - - /** - * Default constructor. - */ - public ResultConfig() { - } - - /** - * @param dataIndex The dataIndex - * @param header The column header - * @param flex Flexible with - * @param width Width in px. - */ - public ResultConfig(String dataIndex, String header, Integer flex, Integer width) { - this.dataIndex= dataIndex; - this.header= header; - this.flex = flex; - this.width = width; - } - - /** - * @param dataIndex The dataIndex - * @param header The column header - * @param flex Flexible with - */ - public ResultConfig(String dataIndex, String header, Integer flex) { - this.dataIndex= dataIndex; - this.header= header; - this.flex = flex; - this.width = null; - } - - /** - * @param dataIndex The dataIndex - * @param header The column header - */ - public ResultConfig(String dataIndex, String header) { - this.dataIndex= dataIndex; - this.header= header; - this.flex = 0; - this.width = null; - } - - /** - * @return the dataIndex - */ - public String getDataIndex() { - return dataIndex; - } - - /** - * @param dataIndex the dataIndex to set - */ - public void setDataIndex(String dataIndex) { - this.dataIndex = dataIndex; - } - - /** - * @return the header - */ - public String getHeader() { - return header; - } - - /** - * @param header the header to set - */ - public void setHeader(String header) { - this.header = header; - } - - /** - * @return the width - */ - public Integer getWidth() { - return width; - } - - /** - * @param width the width to set - */ - public void setWidth(Integer width) { - this.width = width; - } - - /** - * @return the flex - */ - public Integer getFlex() { - return flex; - } - - /** - * @param flex the flex to set - */ - public void setFlex(Integer flex) { - this.flex = flex; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/AuthInfoService.java --- a/src/main/java/de/intevation/lada/rest/AuthInfoService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.auth.Authorization; -import de.intevation.lada.model.LProbe; - -/** - * This class produces a RESTful service to get information about - * access of probe objects. - * - * @author Raimund Renkert - */ -@Path("/authinfo") -@RequestScoped -public class AuthInfoService -{ - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - @Inject - @Named("dataauthorization") - private Authorization authorization; - - /** - * Request information about access to probe objects - * - * @param id The {@link LProbe} id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id}") - @Produces("text/json") - public Response get( - @PathParam("id") String id, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, null); - } - boolean isOwner = false; - boolean isReadonly = true; - if (authentication.hasAccess(headers, id)) { - isOwner = true; - } - if (!authorization.isReadOnly(id)) { - isReadonly = false; - } - Response response = new Response( - true, - 200, - "{isOwner: " + isOwner + ", readonly:" + isReadonly + "}"); - return response; - } - catch(AuthenticationException ae) { - return new Response(false, 699, null); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/InfoService.java --- a/src/main/java/de/intevation/lada/rest/InfoService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SNetzBetreiber; - -class Info { - String user; - String groups; - String version; - public Info(String user, String groups, String version) { - this.user = user; - this.groups = groups; - this.version = version; - } - public String getUser() { - return user; - } - public void setUser(String user) { - this.user = user; - } - public String getGroups() { - return groups; - } - public void setGroups(String groups) { - this.groups = groups; - } - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } -} - -/** - * This class produces a RESTful service to read information about the user and - * server - * - * @author Torsten Irländer - */ -@Path("/info") -@RequestScoped -public class InfoService -{ - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - @Inject - @Named("readonlyrepository") - private Repository readonlyRepo; - - /** - * Request User and Server information. - * - * @param info The URL query parameters. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, null); - } - String user = authentication.getUserName(headers); - AuthenticationResponse ar = authentication.authorizedGroups(headers); - List groups = ar.getNetzbetreiber(); - QueryBuilder builder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SNetzBetreiber.class); - for (String g : groups) { - builder.or("netzbetreiberId", g); - } - Response nResponse = readonlyRepo.filter(builder.getQuery()); - List netzbetr = (List)nResponse.getData(); - String gString = ""; - boolean first = true; - for(SNetzBetreiber nb : netzbetr) { - if (first) { - gString += nb.getNetzbetreiber(); - first = false; - } - else { - gString += ", " + nb.getNetzbetreiber(); - } - } - //TODO: This is the best way to get the version. - // Should read the version from MANIFEST.MF but does not work (returns null). - //String version = getClass().getPackage().getImplementationVersion(); - String version = System.getProperty("de.intevation.lada.server.version"); - - Response response = new Response(true, 200, new Info(user, gString, version)); - return response; - } - catch(AuthenticationException ae) { - return new Response(false, 699, null); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/JaxRsActivator.java --- a/src/main/java/de/intevation/lada/rest/JaxRsActivator.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; - -/** - * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 - * "no XML" approach to activating JAX-RS. - * - *

- * Resources are served relative to the servlet path specified in the {@link ApplicationPath} - * annotation. - *

- */ -@ApplicationPath("/rest") -public class JaxRsActivator extends Application { - /* class body intentionally left blank */ -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LAFExportService.java --- a/src/main/java/de/intevation/lada/rest/LAFExportService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.ResponseBuilder; -import javax.ws.rs.core.Response.Status; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.auth.Authorization; -import de.intevation.lada.data.exporter.Exporter; - -/** -* This class produces a RESTful service to export a LAF file. -* -* @author Raimund Renkert -*/ -@Path("/export") -@RequestScoped -public class LAFExportService -{ - @Inject - @Named("ldapauth") - private Authentication authentication; - - @Inject - @Named("dataauthorization") - private Authorization authorization; - - @Inject - @Named("lafexporter") - private Exporter exporter; - - /** - * Export LProbe objects. - * - * The service takes form url encoded POST data containing probe ids and - * exports the LProbe objects filtered by these ids. - * - * @param proben Form data (url encoded) string with probe ids. - * @param header The HTTP header containing authorization information. - * @return The LAF file to export. - */ - @POST - @Path("/laf") - @Consumes("application/x-www-form-urlencoded") - @Produces("text/plain") - public Response download( - String proben, - @Context HttpHeaders header - ) { - try { - String[] raw = proben.split("&"); - List probeIds = new ArrayList(); - for (int i = 0; i < raw.length; i++) { - String[] probe = raw[i].split("="); - probeIds.add(probe[1]); - } - String fileName = "export.laf"; - AuthenticationResponse auth = authentication.authorizedGroups(header); - if (!authentication.isAuthorizedUser(header)) { - ResponseBuilder response = Response.status(Status.FORBIDDEN); - return response.build(); - } - for (int i = 0; i < probeIds.size(); i++) { - String probeId = probeIds.get(i); - if (!authentication.hasAccess(header, probeId) && - !authorization.isReadOnly(probeId)) { - probeIds.remove(probeId); - } - } - InputStream exported = exporter.export(probeIds, auth); - ResponseBuilder response = Response.ok((Object)exported); - response.header( - "Content-Disposition", - "attachment; filename=\"" + fileName + "\""); - return response.build(); - - } - catch(AuthenticationException ae) { - ResponseBuilder response = Response.status(Status.FORBIDDEN); - return response.build(); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LAFImportService.java --- a/src/main/java/de/intevation/lada/rest/LAFImportService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; - -import org.apache.commons.io.IOUtils; -import org.jboss.resteasy.plugins.providers.multipart.InputPart; -import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.data.importer.Importer; - -/** -* This class produces a RESTful service to import a LAF file. -* -* @author Raimund Renkert -*/ -@Path("/import") -@RequestScoped -public class LAFImportService -{ - @Inject - @Named("ldapauth") - private Authentication authentication; - - @Inject - @Named("lafimporter") - private Importer importer; - - /** - * Import LProbe object. - * See - * http://howtodoinjava.com/2013/05/21/jax-rs-resteasy-file-upload-httpclient-example/ - * for more details on the implementation. - * - * @param input MulitpartFormDataInput containing the file to upload. - * @param header The HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Path("/laf") - @Produces("application/json") - @Consumes("multipart/form-data") - public Response upload(MultipartFormDataInput input, @Context HttpHeaders header) { - try { - AuthenticationResponse auth = authentication.authorizedGroups(header); - if (!authentication.isAuthorizedUser(header)) { - return new Response(false, 698, null); - } - - String name = ""; - String content = ""; - try { - List parts = input.getParts(); - for (InputPart part: parts) { - InputStream inStream = part.getBody(InputStream.class, null); - MultivaluedMap headers = part.getHeaders(); - String[] cDisp = headers.getFirst("content-disposition").split(";"); - for (String fName : cDisp) { - if (fName.trim().startsWith("filename")) { - String[] fileName = fName.split("="); - name = fileName[1].trim().replace("\"", ""); - } - } - content = IOUtils.toString(inStream); - } - } - catch (IOException e) { - importer.reset(); - return new Response(false, 603, null); - } - - boolean success = importer.importData(content, auth); - Map respData = new HashMap(); - respData.put("errors", importer.getErrors()); - respData.put("warnings", importer.getWarnings()); - respData.put("filename", name); - int code = 200; - if (!success) { - code = 670; - } - Response response = new Response(success, code, respData); - importer.reset(); - return response; - } - catch(AuthenticationException ae) { - importer.reset(); - return new Response(false, 699, null); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LKommentarMService.java --- a/src/main/java/de/intevation/lada/rest/LKommentarMService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,205 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.Query; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LKommentarM; -import de.intevation.lada.model.LKommentarMId; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LProbe; - -/** - * This class produces a RESTful service to read, write and update - * LKommentarM objects. - * - * @author Raimund Renkert - */ -@Path("/messkommentare") -@RequestScoped -public class LKommentarMService -{ - /** - * The Repository for SMessStelle. - */ - @Inject - @Named("lkommentarmrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request LKommentarM via a filter. - * - * Query parameters are used for the filter in form of key-value pairs. - * - * @param info The URL query parameters. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - MultivaluedMap params = info.getQueryParameters(); - if (params.isEmpty() || - !params.containsKey("probeId") || - !params.containsKey("messungsId") - ) { - return new Response(false, 609, new ArrayList()); - } - String probeId = params.getFirst("probeId"); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), LKommentarM.class); - builder.and("probeId", probeId) - .and("messungsId", params.getFirst("messungsId")); - return repository.filter(builder.getQuery()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Update LKommentarM objects. - * - * @param kommentar The LKommentarM object to update. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @PUT - @Path("/{kId}/{messungsId}/{probeId}") - @Produces("text/json") - @Consumes("application/json") - public Response update( - LKommentarM kommentar, - @Context HttpHeaders headers - ) { - try { - String probeId = kommentar.getProbeId(); - if (authentication.hasAccess(headers, probeId)) { - return repository.update(kommentar); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Create a new LKommentarM object. - * - * @param kommentar The new LKommentarM object. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Produces("text/json") - @Consumes("application/json") - public Response create( - LKommentarM kommentar, - @Context HttpHeaders headers - ) { - try { - String probeId = kommentar.getProbeId(); - if (authentication.hasAccess(headers, probeId)) { - LKommentarMId id = new LKommentarMId(); - Query q = - repository.getEntityManager().createNativeQuery( - "select nextval('kommentar_m_id_seq')"); - BigInteger seqId = (BigInteger)q.getSingleResult(); - id.setKId(seqId.intValue()); - id.setMessungsId(kommentar.getMessungsId()); - id.setProbeId(probeId); - kommentar.setId(id); - return repository.create(kommentar); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Delete a LKommentarM object. - * - * @param kId The object id. - * @param messungsId The {@link LMessung} id. - * @param probeId The {@link LProbe} id - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @DELETE - @Path("/{kId}/{messungsId}/{probeId}") - public Response delete( - @PathParam("kId") String kId, - @PathParam("messungsId") String messungsId, - @PathParam("probeId") String probeId, - @Context HttpHeaders headers - ) { - try { - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), - LKommentarM.class); - builder.and("KId", kId) - .and("messungsId", messungsId) - .and("probeId", probeId); - Response response = repository.filter(builder.getQuery()); - List list = (List)response.getData(); - if (!list.isEmpty()) { - repository.delete(list.get(0)); - return new Response(true, 200, null); - } - return new Response(false, 600, null); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LKommentarService.java --- a/src/main/java/de/intevation/lada/rest/LKommentarService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,191 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LKommentarP; - -/** - * This class produces a RESTful service to read, write and update - * LKommentarP objects. - * - * @author Raimund Renkert - */ -@Path("/kommentare") -@RequestScoped -public class LKommentarService -{ - /** - * The Repository. - */ - @Inject - @Named("lkommentarRepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * The logger for this class - */ - @Inject - private Logger logger; - - /** - * Delete a LKommentarP object identified by 'probeId' and 'kId'. - * - * @param kId The object id. - * @param probeId The LProbe object id. - * @param headers The HTTP headers containing authorization information. - * @return Response object. - */ - @DELETE - @Path("/{kId}/{probeId}") - @Produces("text/json") - public Response delete( - @PathParam("kId") String kId, - @PathParam("probeId") String probeId, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), LKommentarP.class); - builder.and("probeId", probeId).and("kId", kId); - Response response = repository.filter(builder.getQuery()); - List list = (List)response.getData(); - if (!list.isEmpty()) { - repository.delete(list.get(0)); - return new Response(true, 200, null); - } - return new Response(false, 600, null); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request a list of LKommentarP objects filtered by LProbe id. - * - * @param info The URL parameters - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - MultivaluedMap params = info.getQueryParameters(); - if (params.isEmpty() || !params.containsKey("probeId")) { - return new Response(false, 609, new ArrayList()); - } - String probeId = params.getFirst("probeId"); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), LKommentarP.class); - builder.and("probeId", probeId); - return repository.filter(builder.getQuery()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Update a LKommentarP object. - * - * @param kommentar The LKommentarP object to update. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @PUT - @Path("/{kId}/{probeId}") - @Produces("text/json") - @Consumes("application/json") - public Response update( - LKommentarP kommentar, - @Context HttpHeaders headers - ) { - try { - String probeId = kommentar.getProbeId(); - if (authentication.hasAccess(headers, probeId)) { - return repository.update(kommentar); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Create a new LKommentarP object. - * - * @param kommentar The new LKommentarP object. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Consumes("application/json") - @Produces("text/json") - public Response create( - LKommentarP kommentar, - @Context HttpHeaders headers - ) { - try { - String probeId = kommentar.getProbeId(); - if (authentication.hasAccess(headers, probeId)) { - return repository.create(kommentar); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LMessungService.java --- a/src/main/java/de/intevation/lada/rest/LMessungService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,222 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.persistence.Query; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.DELETE; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMessungId; - -/** -* This class produces a RESTful service to read, write and update -* LMessung objects. -* -* @author Raimund Renkert -*/ -@Path("/messung") -@RequestScoped -public class LMessungService -{ - /** - * The Repository for LMessung. - */ - @Inject - @Named("lmessungrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request LMessung via a filter. - * - * Query parameters are used for the filter in form of key-value pairs. - * This filter can take the three parameters - * probe=$PROBEID (String) - * - * @param info The URL query parameters. - * @return JSON Object via Rest service. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - MultivaluedMap params = info.getQueryParameters(); - if (params.isEmpty() || !(params.containsKey("probeId"))) { - return new Response(false, 609, new ArrayList()); - } - String probeId = params.getFirst("probeId"); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), - LMessung.class); - builder.and("probeId", probeId); - return repository.filter(builder.getQuery()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Update a LMessung object. - * - * @param messung The LMessung object to update. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @PUT - @Path("/{messungId}/{probeId}") - @Produces("text/json") - @Consumes("application/json") - public Response update( - LMessung messung, - @Context HttpHeaders headers - ) { - try { - String probeId = messung.getProbeId(); - int messungsId = messung.getId().getMessungsId(); - if (authentication.hasAccess(headers, probeId) && - !isReadOnly(probeId, messungsId, messung)) { - return repository.update(messung); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Create a new LMessung object. - * - * @param messung The new LMessung object. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Produces("text/json") - @Consumes("application/json") - public Response create( - LMessung messung, - @Context HttpHeaders headers - ) { - try { - String probeId = messung.getProbeId(); - if (authentication.hasAccess(headers, probeId)) { - Query q = repository.getEntityManager().createNativeQuery( - "select nextval('messung_id_seq')"); - BigInteger seqId = (BigInteger)q.getSingleResult(); - LMessungId id = new LMessungId(); - id.setProbeId(probeId); - id.setMessungsId(seqId.intValue()); - messung.setId(id); - return repository.create(messung); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - private boolean isReadOnly(String probeId, Integer messungsId, LMessung messung) { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), - LMessung.class); - builder.and("probeId", probeId) - .and("messungsId", String.valueOf(messungsId)); - Response response = repository.filter(builder.getQuery()); - List messungen = (List) response.getData(); - if (messungen.isEmpty()) { - return true; - } - if (messungen.size() > 1) { - return true; - } - - if (messungen.get(0).isFertig() && !messung.isFertig()) { - return false; - } - return messungen.get(0).isFertig(); - } - - /** - * Delete a LMessung object identified by 'probeId' and 'messungsId'. - * - * @param messungsId The object id. - * @param probeId The LProbe object id. - * @param headers The HTTP headers containing authorization information. - * @return Response object. - */ - @DELETE - @Path("/{messungsId}/{probeId}") - @Produces("text/json") - public Response delete( - @PathParam("messungsId") String messungsId, - @PathParam("probeId") String probeId, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), LMessung.class); - builder.and("probeId", probeId).and("messungsId", messungsId); - Response response = repository.filter(builder.getQuery()); - List list = (List)response.getData(); - if (!list.isEmpty()) { - repository.delete(list.get(0)); - return new Response(true, 200, null); - } - return new Response(false, 600, null); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LMesswertService.java --- a/src/main/java/de/intevation/lada/rest/LMesswertService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,225 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.model.LMesswertId; -import de.intevation.lada.model.LProbe; - -/** - * This class produces a RESTful service to read, write and update - * the contents of LMesswert objects. - * - * @author Raimund Renkert - */ -@Path("/messwert") -@RequestScoped -public class LMesswertService -{ - /** - * The Repository for LMesswert. - */ - @Inject - @Named("lmesswertrepository") - private Repository repository; - - @Inject - @Named("lmessungrepository") - private Repository messungRepository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request LMessert via a filter. - * - * Query parameters are used for the filter in form of key-value pairs. - * - * @param info The URL query parameters. - * @param headers The HTTP header containing authorization information. - * @return JSON Object via Rest service. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - MultivaluedMap params = info.getQueryParameters(); - if (params.isEmpty() || - !params.containsKey("probeId") || - !params.containsKey("messungsId")) { - return new Response(false, 609, new ArrayList()); - } - String probeId = params.getFirst("probeId"); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), LMesswert.class); - builder.and("probeId", probeId) - .and("messungsId", params.getFirst("messungsId")); - return repository.filter(builder.getQuery()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Update a LMesswert object. - * - * @param messwert The LMesswert object to update. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @PUT - @Path("/{messgroesseId}/{messungsId}/{probeId}") - @Produces("text/json") - @Consumes("application/json") - public Response update( - LMesswert messwert, - @Context HttpHeaders headers - ) { - try { - String probeId = messwert.getProbeId(); - Integer messungsId = messwert.getMessungsId(); - if (authentication.hasAccess(headers, probeId) && - !isReadOnly(probeId, messungsId)) { - return repository.update(messwert); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Create a new LMesswert object. - * - * @param messwert The new LMesswert object. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Produces("text/json") - @Consumes("application/json") - public Response create( - LMesswert messwert, - @Context HttpHeaders headers - ) { - try { - String probeId = messwert.getProbeId(); - Integer messungsId = messwert.getMessungsId(); - if (authentication.hasAccess(headers, probeId) && - !isReadOnly(probeId, messungsId)) { - LMesswertId id = new LMesswertId(); - id.setMessgroesseId(messwert.getMessgroesseId()); - id.setMessungsId(messungsId); - id.setProbeId(probeId); - messwert.setId(id); - return repository.create(messwert); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Delete a LMesswert object. - * - * @param messgroesseId The messgroesse id. - * @param messungsId The {@link LMessung} id. - * @param probeId The {@link LProbe} id - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @DELETE - @Produces("text/json") - @Path("/{messgroesseId}/{messungsId}/{probeId}") - public Response delete( - @PathParam("messgroesseId") String messgroesseId, - @PathParam("messungsId") String messungsId, - @PathParam("probeId") String probeId, - @Context HttpHeaders headers - ) { - try { - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), - LMesswert.class); - builder.and("messgroesseId", messgroesseId) - .and("messungsId", messungsId) - .and("probeId", probeId); - Response response = repository.filter(builder.getQuery()); - List list = (List)response.getData(); - if (!list.isEmpty()) { - repository.delete(list.get(0)); - return new Response(true, 200, null); - } - return new Response(false, 600, null); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - private boolean isReadOnly(String probeId, Integer messungsId) { - QueryBuilder builder = - new QueryBuilder( - messungRepository.getEntityManager(), - LMessung.class); - builder.and("probeId", probeId) - .and("messungsId", String.valueOf(messungsId)); - Response response = messungRepository.filter(builder.getQuery()); - List messungen = (List) response.getData(); - if (messungen.isEmpty()) { - return true; - } - if (messungen.size() > 1) { - return true; - } - return messungen.get(0).isFertig(); - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LOrtService.java --- a/src/main/java/de/intevation/lada/rest/LOrtService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.auth.Authorization; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.LProbe; - -/** - * This class produces a RESTful service to read, write and update - * LOrt objects. - * - * @author Raimund Renkert - */ -@Path("/ort") -@RequestScoped -public class LOrtService -{ - - /** - * The repository for LOrt. - */ - @Inject - @Named("lortrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - @Inject - @Named("dataauthorization") - private Authorization authorization; - - /** - * Request LOrt via a filter. - * - * Query parameters are used for the filter in form of key-value pairs. - * - * @param info The URL query parameters. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - MultivaluedMap params = info.getQueryParameters(); - if (params.isEmpty() || - !params.containsKey("probeId")) { - return new Response(false, 609, new ArrayList()); - } - String probeId = params.getFirst("probeId"); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), LOrt.class); - builder.and("probeId", probeId); - Response response = repository.filter(builder.getQuery()); - List list = (List) response.getData(); - boolean readonly = authorization.isReadOnly(probeId); - for (LOrt ort: list) { - ort.setReadonly(readonly); - } - response.setData(list); - return response; - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Update LOrt objects. - * - * @param ort The LOrt object to update. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @PUT - @Path("/{portId}/{probeId}") - @Produces("text/json") - @Consumes("application/json") - public Response update( - LOrt ort, - @Context HttpHeaders headers - ) { - try { - String probeId = ort.getProbeId(); - if (authentication.hasAccess(headers, probeId) && - !authorization.isReadOnly(probeId)) { - return repository.update(ort); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Create a new LOrt object. - * - * @param ort The new LOrt object. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Produces("text/json") - @Consumes("application/json") - public Response create( - LOrt ort, - @Context HttpHeaders headers - ) { - try { - String probeId = ort.getProbeId(); - if (authentication.hasAccess(headers, probeId) && - !authorization.isReadOnly(probeId)) { - return repository.create(ort); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Delete a LOrt object. - * - * @param ortId The {@link LOrt} id. - * @param probeId The {@link LProbe} id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @DELETE - @Produces("text/json") - @Path("/{ortId}/{probeId}") - public Response delete( - @PathParam("ortId") String ortId, - @PathParam("probeId") String probeId, - @Context HttpHeaders headers - ) { - try { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), - LOrt.class); - builder.and("POrtId", ortId).and("probeId", probeId); - Response response = repository.filter(builder.getQuery()); - List list = (List)response.getData(); - if (!list.isEmpty()) { - LOrt ort = list.get(0); - if (authentication.hasAccess(headers, ort.getProbeId())) { - repository.delete(list.get(0)); - return new Response(true, 200, null); - } - return new Response(false, 698, null); - } - return new Response(false, 600, null); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LProbeService.java --- a/src/main/java/de/intevation/lada/rest/LProbeService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,274 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.auth.Authorization; -import de.intevation.lada.data.LProbeRepository; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.LProbeInfo; -import de.intevation.lada.utils.QueryTools; -import de.intevation.lada.validation.ValidationException; -import de.intevation.lada.validation.Validator; - -/** -* This class produces a RESTful service to read, write and update -* LProbe objects. -* -* @author Raimund Renkert -*/ -@Path("/proben") -@RequestScoped -public class LProbeService { - - /** - * The Repository for LProbe. - */ - @Inject - @Named("lproberepository") - private Repository repository; - - @Inject - @Named("lmessungrepository") - private Repository messungRepository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - @Inject - @Named("dataauthorization") - private Authorization authorization; - - @Inject - @Named("lprobevalidator") - private Validator validator; - - /** - * The logger for this class. - */ - @Inject - private Logger log; - - /** - * Request a LProbe via its id. - * - * @param id The LProbe id - * @param header THe HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders header - ) { - try { - AuthenticationResponse auth = - authentication.authorizedGroups(header); - Response response = - repository.findById(LProbeInfo.class, id); - @SuppressWarnings("unchecked") - List probe = (List)response.getData(); - if (probe.isEmpty()) { - return new Response(false, 601, new ArrayList()); - } - LProbeInfo p = probe.get(0); - try { - Map warn = - validator.validate(p.toLProbe(), false); - response.setWarnings(warn); - } - catch (ValidationException e) { - response.setErrors(e.getErrors()); - response.setWarnings(e.getWarnings()); - } - - String nbId = probe.get(0).getNetzbetreiberId(); - String mstId = probe.get(0).getMstId(); - if (auth.getNetzbetreiber().contains(nbId) || - probe.get(0).getReadonly()) { - if (auth.getMst().contains(mstId)) { - return response; - } - p.setReadonly(true); - return response; - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request LProbe via a filter. - * - * Query parameters are used for the filter in form of key-value pairs. - * This filter can take the three parameters - * mstId=$MSTID (String) - * umwId=$UWBID (String) - * begin=$PROBEENTNAHMEBEGIN (Timestamp) - * - * @param info The URL query parameters. - * @param header The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders header - ) { - try { - AuthenticationResponse auth = - authentication.authorizedGroups(header); - MultivaluedMap params = info.getQueryParameters(); - if (params.isEmpty() || !params.containsKey("qid")) { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), - LProbeInfo.class); - builder.or("readonly", true); - List netzbetreiberIds = auth.getNetzbetreiber(); - for (String netzbetreiberId: netzbetreiberIds) { - builder.or("netzbetreiberId", netzbetreiberId); - } - return repository.filter(builder.getQuery()); - } - String qid = params.getFirst("qid"); - JSONObject query = QueryTools.getQueryById(qid); - List filters = new ArrayList(); - List results = new ArrayList(); - String sql = ""; - try { - sql = query.getString("sql"); - JSONArray jFilters = query.getJSONArray("filters"); - for (int i = 0; i < jFilters.length(); i++) { - JSONObject jFilter = jFilters.getJSONObject(i); - filters.add(jFilter.getString("dataIndex")); - } - JSONArray jResults = query.getJSONArray("result"); - for (int i = 0; i < jResults.length(); i++) { - JSONObject jResult = jResults.getJSONObject(i); - results.add(jResult.getString("dataIndex")); - } - } - catch (JSONException e) { - return new Response(false, 603, new ArrayList()); - } - - if (sql == null || sql.length() == 0) { - return new Response(false, 603, new ArrayList()); - } - LProbeRepository lpr = (LProbeRepository)repository; - String subselect = "(select * from l_probe_info where "; - List netzbetreiberIds = auth.getNetzbetreiber(); - boolean first = true; - for (String netzbetreiberId: netzbetreiberIds) { - if (first) { - subselect += "netzbetreiber_id = '" + netzbetreiberId + "' "; - first = false; - } - else { - subselect += "or netzbetreiber_id = '" + netzbetreiberId + "' "; - } - } - subselect += "or readonly = true) as lp"; - sql = sql.replace("l_probe", subselect); - List msts = auth.getMst(); - return lpr.filterFree(sql, filters, results, params, msts); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Update a LProbe object. - * - * @param probe A LProbeInfo object wrapping the LProbe object. - * @param header The HTTP header containing authorization information. - * @return Response object. - */ - @PUT - @Path("/{id}") - @Produces("text/json") - @Consumes("application/json") - public Response update(LProbeInfo probe, @Context HttpHeaders header) { - try { - if(authentication.hasAccess(header, probe.getProbeId())) { - LProbe p = probe.toLProbe(); - p.setProbeId(probe.getProbeId()); - return repository.update(p); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Create a new LProbe object. - * - * @param probe A LProbeInfo object wrapping the LProbe object. - * @param header The HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Produces("text/json") - @Consumes("application/json") - public Response create(LProbeInfo probe, @Context HttpHeaders header) { - try { - AuthenticationResponse auth = - authentication.authorizedGroups(header); - if (auth.getNetzbetreiber().contains(probe.getNetzbetreiberId()) && - auth.getMst().contains(probe.getMstId())) { - LProbe p = probe.toLProbe(); - return repository.create(p); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LStatusService.java --- a/src/main/java/de/intevation/lada/rest/LStatusService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,197 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.LStatus; -import de.intevation.lada.model.LStatusId; - -/** - * This class produces a RESTful service to read, write and update - * LStatus objects. - * - * @author Raimund Renkert - */ -@Path("/status") -@RequestScoped -public class LStatusService -{ - /** - * The Repository for LStatus. - */ - @Inject - @Named("lstatusrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request LStatus via a filter. - * - * Query parameters are used for the filter in form of key-value pairs. - * - * @param info The URL query parameters. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - MultivaluedMap params = info.getQueryParameters(); - if (params.isEmpty() || - !params.containsKey("probeId") || - !params.containsKey("messungsId")) { - return new Response(false, 609, new ArrayList()); - } - String probeId = params.getFirst("probeId"); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), LStatus.class); - builder.and("probeId", probeId) - .and("messungsId", params.getFirst("messungsId")); - return repository.filter(builder.getQuery()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Update a LStatus object. - * - * @param status The LStatus object to update. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @PUT - @Produces("text/json") - @Consumes("application/json") - public Response update( - LStatus status, - @Context HttpHeaders headers - ) { - try { - String probeId = status.getProbeId(); - if (authentication.hasAccess(headers, probeId)) { - return repository.update(status); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Create a new LStatus object. - * - * @param status The new LStatus object. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Produces("text/json") - @Consumes("application/json") - public Response create( - LStatus status, - @Context HttpHeaders headers - ) { - try { - String probeId = status.getProbeId(); - if (authentication.hasAccess(headers, probeId)) { - LStatusId id = new LStatusId(); - id.setMessungsId(status.getMessungsId()); - id.setProbeId(probeId); - status.setId(id); - return repository.create(status); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Delete a LStatus object. - * - * @param statusId The object id. - * @param messungsId The {@link LMessung} id. - * @param probeId The {@link LProbe} id - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @DELETE - @Produces("text/json") - @Path("/{statusId}/{messungsId}/{probeId}") - public Response delete( - @PathParam("statusId") String statusId, - @PathParam("messungsId") String messungsId, - @PathParam("probeId") String probeId, - @Context HttpHeaders headers - ) { - try { - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), - LStatus.class); - builder.and("SId", statusId) - .and("messungsId", messungsId) - .and("probeId", probeId); - Response response = repository.filter(builder.getQuery()); - List list = (List)response.getData(); - if (!list.isEmpty()) { - repository.delete(list.get(0)); - return new Response(true, 200, null); - } - return new Response(false, 600, null); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/LZusatzwertService.java --- a/src/main/java/de/intevation/lada/rest/LZusatzwertService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,183 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LZusatzWert; - -/** - * This class produces a RESTful service to read, write and update - * LZusatzwert objects. - * - * @author Raimund Renkert - */ -@Path("/zusatzwert") -@RequestScoped -public class LZusatzwertService -{ - /** - * The Repository for LZusatzwert. - */ - @Inject - @Named("lzusatzwertrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request LZusatzwert via a filter. - * - * Query parameters are used for the filter in form of key-value pairs. - * - * @param info The URL query parameters. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - MultivaluedMap params = info.getQueryParameters(); - if (params.isEmpty() || !params.containsKey("probeId")) { - return new Response(false, 609, new ArrayList()); - } - String probeId = params.getFirst("probeId"); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), LZusatzWert.class); - builder.and("probeId", probeId); - return repository.filter(builder.getQuery()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Update a LZusatzwert object. - * - * @param zusatzwert The LZusatzwert object to update. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @PUT - @Produces("text/json") - @Path("/{pzsId}/{probeId}") - @Consumes("application/json") - public Response update( - LZusatzWert zusatzwert, - @Context HttpHeaders headers - ) { - try { - String probeId = zusatzwert.getProbeId(); - if (authentication.hasAccess(headers, probeId)) { - return repository.update(zusatzwert); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Create a new LZusatzwert object. - * - * @param zusatzwert The new LZusatzwert object. - * @param headers THe HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Produces("text/json") - @Consumes("application/json") - public Response create( - LZusatzWert zusatzwert, - @Context HttpHeaders headers - ) { - try { - String probeId = zusatzwert.getProbeId(); - if (authentication.hasAccess(headers, probeId)) { - return repository.create(zusatzwert); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Delete a LZusatzwert object. - * - * @param pzsId The object id. - * @param probeId The LProbe id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @DELETE - @Path("/{pzsId}/{probeId}") - public Response delete( - @PathParam("pzsId") String pzsId, - @PathParam("probeId") String probeId, - @Context HttpHeaders headers - ) { - try { - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), - LZusatzWert.class); - builder.and("pzsId", pzsId).and("probeId", probeId); - Response response = repository.filter(builder.getQuery()); - List list = (List)response.getData(); - if (!list.isEmpty()) { - repository.delete(list.get(0)); - return new Response(true, 200, null); - } - return new Response(false, 600, null); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/OrtService.java --- a/src/main/java/de/intevation/lada/rest/OrtService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.Ort; - -/** -* This class produces a RESTful service to read, write and update -* Ort objects. -* -* @author Raimund Renkert -*/ -@Path("/ortinfo") -@RequestScoped -public class OrtService -{ - /** - * The Repository for Ort. - */ - @Inject - @Named("ortrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request a Ort object via its id. - * - * @param id The Ort id - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers - ) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findById(Ort.class, id); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request all Ort objects - * - * @param headers The HTTP header containing authorization information. - * @return JSON Object via Rest service. - */ - @GET - @Produces("text/json") - public Response filter(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(Ort.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Update a Ort object. - * - * @param ort The Ort object to update. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @PUT - @Produces("text/json") - @Path("/{ortId}") - @Consumes("application/json") - public Response update(Ort ort, @Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.update(ort); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Create a new Ort object. - * - * @param ort The new Ort object. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @POST - @Produces("text/json") - @Consumes("application/json") - public Response create(Ort ort, @Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.create(ort); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Delete a Ort object. - * - * @param ortId The object od. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @DELETE - @Produces("text/json") - @Path("/{ortId}/{probeId}") - public Response delete( - @PathParam("ortId") String ortId, - @Context HttpHeaders headers - ) { - try { - if (authentication.isAuthorizedUser(headers)) { - Response response = repository.findById(Ort.class, ortId); - Ort ort = (Ort)response.getData(); - if (ort != null) { - repository.delete(ort); - return new Response(true, 200, null); - } - return new Response(false, 600, null); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/QueryService.java --- a/src/main/java/de/intevation/lada/rest/QueryService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.query.QueryConfig; -import de.intevation.lada.utils.QueryTools; - -/** - * This class produces a RESTful service to read, write and update - * LOrt objects. - * - * @author Torsten Irländer - */ -@Path("/query") -@RequestScoped -public class QueryService -{ - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request SQL-Queries - * - * Query parameters are used for the filter in form of key-value pairs. - * - * @param info The URL query parameters. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response get( - @Context UriInfo info, - @Context HttpHeaders headers - ) { - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, new ArrayList()); - } - Response response = new Response(true, 200, this.loadQueryConfig()); - return response; - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - private List loadQueryConfig() { - /* Typicall available fields - {header: 'Datenbasis', dataIndex: 'datenbasisId', width: 70}, - {header: 'MPL', dataIndex: 'mplId', width: 50}, - {header: 'UWB', dataIndex: 'umwId', width: 50}, - {header: 'MMT', dataIndex: 'messmethode'}, - {header: 'HPNR', dataIndex: 'hauptprobenNr'}, - {header: 'NPNR', dataIndex: 'nebenprobenNr'}, - {header: 'E.Gemeinde', dataIndex: 'bezeichnung', flex: 1}, - {header: 'Ursprungsgemeinde', dataIndex: 'kreis', flex: 1}, - {header: 'ProbeID', dataIndex: 'probeId'}, - {header: 'MST', dataIndex: 'mstId', width: 50} - */ - return QueryTools.getConfig(); - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/Response.java --- a/src/main/java/de/intevation/lada/rest/Response.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Logger; - -import javax.inject.Inject; - -/** -* Response object storing information about success, warnings, errors and -* the data object. This class is used as return value in REST services. -* -* @author Torsten Irländer -*/ -@SuppressWarnings("serial") -public class Response implements java.io.Serializable { - - - /** - * The logger for this class. - */ - @Inject - private Logger log; - - private Boolean success; - private String message; - private Object data; - private Map errors; - private Map warnings; - private Boolean readonly; - private int totalCount; - - /** - * Constructor to create a basic Response object. - * - * @param success Information if the operation was successful. - * @param code The return code. - * @param data The data object wrapped by the response. - */ - public Response(boolean success, int code, Object data) { - this.success = success; - this.message = Integer.toString(code); - this.data = data; - this.errors = new HashMap(); - this.warnings = new HashMap(); - this.readonly = Boolean.FALSE; - this.totalCount = 0; - } - - /** - * Constructor to create a basic Response object. - * - * @param success Information if the operation was successful. - * @param code The return code. - * @param data The data object wrapped by the response. - */ - public Response(boolean success, int code, Object data, int totalCount) { - this.success = success; - this.message = Integer.toString(code); - this.data = data; - this.errors = new HashMap(); - this.warnings = new HashMap(); - this.readonly = Boolean.FALSE; - this.totalCount = totalCount; - } - - public Boolean getSuccess() { - return success; - } - - public void setSuccess(Boolean success) { - this.success = success; - } - - public String getMessage() { - return message; - } - - public void setMessage(int message) { - this.message = Integer.toString(message); - } - - public Object getData() { - return data; - } - - public void setData(Object data) { - this.data = data; - } - - public Map getErrors() { - return errors; - } - - public void setErrors(Map errors) { - this.errors = this.convertCodes(errors); - } - - public Map getWarnings() { - return warnings; - } - - public void setWarnings(Map warnings) { - this.warnings = this.convertCodes(warnings); - } - - public Boolean getReadonly() { - return readonly; - } - - public void setReadonly(Boolean readonly) { - this.readonly = readonly; - } - - /** - * @return the totalCount - */ - public int getTotalCount() { - return totalCount; - } - - /** - * @param totalCount the totalCount to set - */ - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - private HashMap convertCodes(Map codes) { - HashMap converted = new HashMap(); - if (codes == null || codes.isEmpty()) { - return converted; - } - for (Map.Entry entry: codes.entrySet()) { - converted.put(entry.getKey(), Integer.toString(entry.getValue())); - } - return converted; - } - - /* Currently unused but might be helpfull later */ - private String codes2string(Map codes) { - String response = "{"; - if (codes == null || codes.isEmpty()) { - response += "}"; - return response; - } - boolean first = true; - for (Map.Entry entry: codes.entrySet()) { - if (!first) { - response +=","; - } - response += entry.getKey() + ":" + "\"" + entry.getValue() + "\""; - first = false; - } - response += "}"; - return response; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SDatenbasisService.java --- a/src/main/java/de/intevation/lada/rest/SDatenbasisService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.logging.Logger; - -import javax.faces.bean.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SDatenbasis; - -/** - * This class produces a RESTful service to read SDatenbasis objects. - * - * @author Raimund Renkert - */ -@Path("/datenbasis") -@RequestScoped -public class SDatenbasisService -{ - /** - * The Repository for SDatenbasis. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * The logger for this class - */ - @Inject - private Logger logger; - - /** - * Request all SDatenbasis objects. - * - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(SDatenbasis.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request a single SDatenbasis via its id. - * - * @param id The object id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers - ) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findById(SDatenbasis.class, id); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SMessMethodeService.java --- a/src/main/java/de/intevation/lada/rest/SMessMethodeService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SMessMethode; - -/** - * This class produces a RESTful service to read SMessMethode objects. - * - * @author Raimund Renkert - */ -@Path("/messmethode") -@RequestScoped -public class SMessMethodeService -{ - /** - * The Repository for SMessMethode. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request all SMessMethode objects. - * - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(SMessMethode.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request a SMessMethode object via its id. - * - * @param id The object id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id:[0-9][0-9]*}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findById(SMessMethode.class, id); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SMesseinheitService.java --- a/src/main/java/de/intevation/lada/rest/SMesseinheitService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.logging.Logger; - -import javax.faces.bean.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SMessEinheit; - -/** - * This class produces a RESTful service to read SMesseinheit objects. - * - * @author Raimund Renkert - */ -@Path("/messeinheit") -@RequestScoped -public class SMesseinheitService -{ - /** - * The Repository for SDatenbasis. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * The logger for this class - */ - @Inject - private Logger logger; - - /** - * Request all SMesseinheit objects. - * - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(SMessEinheit.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SMessgroesseService.java --- a/src/main/java/de/intevation/lada/rest/SMessgroesseService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SMessgroesse; - -/** - * This class produces a RESTful service to read SMessgroesse objects. - * - * @author Raimund Renkert - */ -@Path("/messgroesse") -@RequestScoped -public class SMessgroesseService -{ - /** - * The Repository for SMessgroesse. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request all SMessgroesse objects. - * - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(SMessgroesse.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request a SMessgroesse object via its id. - * - * @param id The object id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id:[0-9][0-9]*}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findById(SMessgroesse.class, id); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SMessstelleService.java --- a/src/main/java/de/intevation/lada/rest/SMessstelleService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.logging.Logger; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SMessStelle; - -/** - * This class produces a RESTful service to read SMessstelle objects - * - * @author Raimund Renkert - */ -@Path("/mst") -@RequestScoped -public class SMessstelleService -{ - /** - * The Repository for SMessStelle. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * The logger for this class - */ - @Inject - private Logger logger; - - /** - * Request all SMessstelle objects. - * - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - AuthenticationResponse auth = - authentication.authorizedGroups(headers); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), SMessStelle.class); - builder.or("mstId", auth.getMst()); - return repository.filter(builder.getQuery()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request a single SMessstelle via its id. - * - * @param id The object id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers) { - try { - AuthenticationResponse auth = - authentication.authorizedGroups(headers); - if (auth.getMst().contains(id)) { - return repository.findById(SMessStelle.class, id); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SNetzBetreiberService.java --- a/src/main/java/de/intevation/lada/rest/SNetzBetreiberService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.logging.Logger; - -import javax.faces.bean.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SNetzBetreiber; - -/** - * This class produces a RESTful service to read SNetzbetreiber objects. - * - * @author Torsten Irländer - */ -@Path("/netzbetreiber") -@RequestScoped -public class SNetzBetreiberService -{ - /** - * The Repository for SNetzBetreiber. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * The logger for this class - */ - @Inject - private Logger logger; - - /** - * Request all SNetzBetreiber objects. - * - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - AuthenticationResponse auth = - authentication.authorizedGroups(headers); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), SNetzBetreiber.class); - builder.or("netzbetreiberId", auth.getNetzbetreiber()); - return repository.filter(builder.getQuery()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request a single SNetzBetreiber via its id. - * - * @param id The object id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers) { - try { - AuthenticationResponse auth = - authentication.authorizedGroups(headers); - if (auth.getNetzbetreiber().contains(id)) { - return repository.findById(SNetzBetreiber.class, id); - } - return new Response(false, 698, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SProbenartService.java --- a/src/main/java/de/intevation/lada/rest/SProbenartService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.logging.Logger; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SProbenart; - -/** - * This class produces a RESTful service to read SProbenart objects. - * - * @author Raimund Renkert - */ -@Path("/probenart") -@RequestScoped -public class SProbenartService -{ - /** - * The Repository for SProbenart. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * The logger for this class - */ - @Inject - private Logger logger; - - /** - * Request all SProbenart objects. - * - * @return Response object. - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(SProbenart.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request a single SProbenart via its id. - * - * @param id The object id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers - ) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findById(SProbenart.class, id); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SProbenzusatzService.java --- a/src/main/java/de/intevation/lada/rest/SProbenzusatzService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.logging.Logger; - -import javax.faces.bean.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SProbenZusatz; - -/** - * This class produces a RESTful service to read SProbenzusatz objects. - * - * @author Raimund Renkert - */ -@Path("/probenzusatz") -@RequestScoped -public class SProbenzusatzService -{ - /** - * The Repository for SDatenbasis. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * The logger for this class - */ - @Inject - private Logger logger; - - /** - * Request all SProbenzusatz objects. - * - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(SProbenZusatz.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SStaatService.java --- a/src/main/java/de/intevation/lada/rest/SStaatService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SStaat; - -/** - * This class produces a RESTful service to read SStaat objects. - * - * @author Raimund Renkert - */ -@Path("/staat") -@RequestScoped -public class SStaatService -{ - /** - * The Repository for SStaat. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request all SStaat objects. - * - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(SStaat.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request a SStaat object via its id. - * - * @param id The object id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id:[0-9][0-9]*}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findById(SStaat.class, id); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SUmweltService.java --- a/src/main/java/de/intevation/lada/rest/SUmweltService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; -import java.util.logging.Logger; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SUmwelt; - -/** - * This class produces a RESTful service to read SUmwelt objects. - * - * @author Raimund Renkert - */ -@Path("/uwb") -@RequestScoped -public class SUmweltService { - - /** - * The Repository for SUmwelt. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * The logger for this class. - */ - @Inject - private Logger log; - - /** - * Request all SUmwelt objects. - * - * @param headers The HTTP header containing authorization information. - * @return JSON Object via Rest service - */ - @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(SUmwelt.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request a SUmwelt object via its id. - * - * @param id The object id. - * @param headers The HTTP header containing authorization information. - * @return JSON Object via REST service. - */ - @GET - @Path("/{id:[0-9][0-9]*}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers - ) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findById(SUmwelt.class, id); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/rest/SVerwaltungseinheitService.java --- a/src/main/java/de/intevation/lada/rest/SVerwaltungseinheitService.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.rest; - -import java.util.ArrayList; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; - -import de.intevation.lada.auth.Authentication; -import de.intevation.lada.auth.AuthenticationException; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.SVerwaltungseinheit; - -/** - * This class produces a RESTful service to read SVerwaltungseinheit objects. - * - * @author Raimund Renkert - */ -@Path("/verwaltungseinheit") -@RequestScoped -public class SVerwaltungseinheitService -{ - /** - * The Repository for SUmwelt. - */ - @Inject - @Named("readonlyrepository") - private Repository repository; - - /** - * The authorization module. - */ - @Inject - @Named("ldapauth") - private Authentication authentication; - - /** - * Request all SVerwaltungseinheit objects. - * - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ -/* @GET - @Produces("text/json") - public Response findAll(@Context HttpHeaders headers) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findAll(SVerwaltungseinheit.class); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } -*/ - /** - * Request a SVerwaltungseinheit object via its id. - * - * @param id The object id. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Path("/{id:[0-9][0-9]*}") - @Produces("text/json") - public Response findById( - @PathParam("id") String id, - @Context HttpHeaders headers - ) { - try { - if (authentication.isAuthorizedUser(headers)) { - return repository.findById(SVerwaltungseinheit.class, id); - } - return new Response(false, 699, new ArrayList()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, new ArrayList()); - } - } - - /** - * Request SVerwaltungseinheit objects filtered by the given criteria. - * - * @param filter The filter string. - * @param headers The HTTP header containing authorization information. - * @return Response object. - */ - @GET - @Produces("text/json") - public Response filter( - @Context UriInfo info, - @Context HttpHeaders headers - ){ - try { - if (!authentication.isAuthorizedUser(headers)) { - return new Response(false, 699, null); - } - MultivaluedMap params = info.getQueryParameters(); - if (params.isEmpty() || !params.containsKey("query")) { - return repository.findAll(SVerwaltungseinheit.class); - } - String filter = params.getFirst("query"); - QueryBuilder builder = - new QueryBuilder( - repository.getEntityManager(), SVerwaltungseinheit.class); - builder.andLike("bezeichnung", filter + "%"); - return repository.filter(builder.getQuery()); - } - catch(AuthenticationException ae) { - return new Response(false, 699, null); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/utils/QueryTools.java --- a/src/main/java/de/intevation/lada/utils/QueryTools.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.utils; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import de.intevation.lada.model.query.QueryConfig; -import de.intevation.lada.model.query.QueryFilter; -import de.intevation.lada.model.query.ResultConfig; - -/** - * Utility class to handle the SQL query configuration. - * - * @author Raimund Renkert - */ -public class QueryTools -{ - /** - * Read the config file using the system property - * "de.intevation.lada.sqlconfig". - * - * @return The file content. - */ - public static String readConfigFile() { - String file = System.getProperty("de.intevation.lada.sqlconfig"); - try { - byte[] encoded = Files.readAllBytes(Paths.get(file)); - Charset encoding = Charset.defaultCharset(); - return encoding.decode(ByteBuffer.wrap(encoded)).toString(); - } - catch (IOException ioe) { - return null; - } - } - - /** - * Get the configuration objects. - * First reads the config file and creates {@link QueryConfig} objects - * from JSON. - * - * @return List of {@link QueryConfig} objects. - */ - public static List getConfig() { - String content = readConfigFile(); - if (content == null) { - return null; - } - List configs = new ArrayList(); - JSONArray queries; - try { - queries = new JSONArray(content); - for (int i = 0; i < queries.length(); i++) { - JSONObject query = queries.getJSONObject(i); - QueryConfig qConf = new QueryConfig(); - qConf.setId(query.getInt("id")); - qConf.setName(query.getString("name")); - qConf.setDescription(query.getString("description")); - qConf.setSql(query.getString("sql")); - JSONArray filters = query.getJSONArray("filters"); - List qFilters = new ArrayList(); - for (int j = 0; j < filters.length(); j++) { - JSONObject filter = filters.getJSONObject(j); - QueryFilter qFilter = new QueryFilter(); - qFilter.setDataIndex(filter.getString("dataIndex")); - qFilter.setType(filter.getString("type")); - qFilter.setLabel(filter.getString("label")); - qFilter.setMultiSelect(filter.optBoolean("multiselect", false)); - qFilters.add(qFilter); - } - qConf.setFilters(qFilters); - JSONArray results = query.getJSONArray("result"); - List sResults = new ArrayList(); - for (int k = 0; k < results.length(); k++) { - JSONObject result = results.getJSONObject(k); - ResultConfig config = new ResultConfig(); - config.setDataIndex(result.getString("dataIndex")); - config.setHeader(result.getString("header")); - config.setWidth(result.optInt("width", 100)); - config.setFlex(result.optInt("flex", 0)); - sResults.add(config); - } - qConf.setResults(sResults); - configs.add(qConf); - } - } - catch (JSONException e) { - return null; - } - return configs; - } - - /** - * Get a query by id. - * First reads the config file and returns the {@link QueryConfig} - * identified by the given id. - * - * @param id {@link QueryConfig} id. - * @return The query config as JSON object or null if no object was found. - */ - public static JSONObject getQueryById(String id) { - try { - String content = readConfigFile(); - if (content != null) { - JSONArray queries = new JSONArray(content); - for (int i = 0; i < queries.length(); i++) { - JSONObject query = queries.getJSONObject(i); - if (query.getString("id").equals(id)) { - return query; - } - } - } - return null; - } - catch (JSONException e) { - return null; - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/utils/Resources.java --- a/src/main/java/de/intevation/lada/utils/Resources.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -/* - * JBoss, Home of Professional Open Source - * Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.intevation.lada.utils; - -import java.util.logging.Logger; - -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.InjectionPoint; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -/** - * This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans - */ -public class Resources { - - @Produces - @PersistenceContext(unitName = "primary") - private EntityManager em; - - @Produces - public Logger produceLog(InjectionPoint injectionPoint) { - return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/validation/LMessungValidator.java --- a/src/main/java/de/intevation/lada/validation/LMessungValidator.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,233 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.validation; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; - -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.LMessung; -import de.intevation.lada.model.LMesswert; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.LProbeInfo; -import de.intevation.lada.model.SPflichtMessgroesse; -import de.intevation.lada.rest.Response; - -/** - * Validator for LMessung objects. - * - * @author Raimund Renkert - */ -@Named("lmessungvalidator") -@ApplicationScoped -public class LMessungValidator -implements Validator -{ - @Inject - @Named("lproberepository") - private Repository probeRepository; - - @Inject - @Named("lmessungrepository") - private Repository messungRepository; - - @Inject - @Named("lmesswertrepository") - private Repository messwertRepository; - - @Inject - @Named("readonlyrepository") - private Repository readonlyRepository; - - /** - * Validate a LMessung object. - * - * @param object The object to validate. - * @param update The database operation. - * TRUE indicates that the object should be updated, FALSE - * if the object is a new Object. - * @return Map containing warnings. - * @throws ValidationException - */ - @Override - public Map validate(Object object, boolean update) - throws ValidationException { - Map warnings = new HashMap(); - if (!(object instanceof LMessung)) { - Map errors = new HashMap(); - errors.put("lmessung", 610); - throw new ValidationException(errors); - } - LMessung messung = (LMessung)object; - - validateHasNebenprobenNr(messung, warnings); - validateDatum(messung, warnings); - validateHasMesswert(messung, warnings); - validateMessgroesse(messung, warnings); - validatePflichtmessgroessen(messung, warnings); - if (!update) { - validateUniqueNebenprobenNr(messung, warnings); - } - return warnings; - } - - private void validateHasMesswert( - LMessung messung, - Map warnings) { - QueryBuilder wertBuilder = - new QueryBuilder( - messwertRepository.getEntityManager(), LMesswert.class); - wertBuilder.and("messungsId", messung.getMessungsId()) - .and("probeId", messung.getProbeId()); - Response wertResponse = messwertRepository.filter(wertBuilder.getQuery()); - List messwerte = (List)wertResponse.getData(); - if (messwerte == null || messwerte.isEmpty()) { - warnings.put("messwert", 631); - } - } - - private void validatePflichtmessgroessen( - LMessung messung, - Map warnings) { - QueryBuilder builder = - new QueryBuilder( - readonlyRepository.getEntityManager(), - SPflichtMessgroesse.class); - builder.and("mmtId", messung.getMmtId()); - Response response = readonlyRepository.filter(builder.getQuery()); - List pflicht = - (List)response.getData(); - - QueryBuilder wertBuilder = - new QueryBuilder( - messwertRepository.getEntityManager(), LMesswert.class); - wertBuilder.and("messungsId", messung.getMessungsId()) - .and("probeId", messung.getProbeId()); - Response wertResponse = - messwertRepository.filter(wertBuilder.getQuery()); - List messwerte = (List)wertResponse.getData(); - for (SPflichtMessgroesse p : pflicht) { - boolean hit = false; - for (LMesswert wert : messwerte) { - if (p.getMessgroesseId().equals(wert.getMessgroesseId())) { - hit = true; - } - } - if (!hit) { - warnings.put("pflichtmessgroesse", 631); - } - } - } - - private void validateMessgroesse( - LMessung messung, - Map warnings - ) { - String mmt = messung.getMmtId(); - QueryBuilder builder = - new QueryBuilder( - messwertRepository.getEntityManager(), LMesswert.class); - builder.and("messungsId", messung.getMessungsId()) - .and("probeId", messung.getProbeId()); - Response response = messwertRepository.filter(builder.getQuery()); - List messwerte = (List)response.getData(); - String query = "select messgroesse_id from \"S_mmt_messgroesse\" where mmt_id = '" + mmt + "'"; - List results = readonlyRepository.getEntityManager().createNativeQuery(query).getResultList(); - for(LMesswert messwert: messwerte) { - boolean hit = false; - for (Integer row: results) { - if (messwert.getMessgroesseId().equals(row.toString())) { - hit = true; - } - } - if (!hit) { - warnings.put("messgroesse", 632); - } - } - } - - /** - * Check if the object has a 'Nebenproben Nr.'. - * - * @param messung The LMessung object. - * @param warnings The map containing warnings. - * @throws ValidationException - */ - private void validateHasNebenprobenNr( - LMessung messung, - Map warnings) - throws ValidationException { - if (messung.getNebenprobenNr() == null || - messung.getNebenprobenNr().equals("")) { - warnings.put("nebenprobenNr", 631); - } - } - - /** - * Check if the 'Nebenproben Nr' is unique. - * - * @param messung The LMessung object. - * @param warnings The map containing warnings. - * @throws ValidationException - */ - private void validateUniqueNebenprobenNr( - LMessung messung, - Map warnings) - throws ValidationException { - QueryBuilder builder = - new QueryBuilder( - messungRepository.getEntityManager(), - LMessung.class); - builder.and("probeId", messung.getProbeId()); - Response response = messungRepository.filter(builder.getQuery()); - List list = (List) response.getData(); - if (list.isEmpty()) { - return; - } - for (LMessung m: list) { - if (m.getNebenprobenNr().equals(messung.getNebenprobenNr())) { - Map errors = new HashMap(); - errors.put("nebenprobenNr", 611); - throw new ValidationException(errors); - } - } - } - - /** - * Check if the 'Messdatum' is after the 'Probennahmedatum'. - * - * @param messung The LMessung object. - * @param warnings The map containing warinings. - * @throws ValidationException - */ - private void validateDatum( - LMessung messung, - Map warnings) - throws ValidationException{ - String probeId = messung.getProbeId(); - Response response = probeRepository.findById(LProbe.class, probeId); - @SuppressWarnings("unchecked") - List list = (List) response.getData(); - if (list.isEmpty()) { - Map errors = new HashMap(); - errors.put("lprobe", 604); - throw new ValidationException(errors); - } - LProbeInfo probe = list.get(0); - if (probe.getProbeentnahmeEnde() == null || - probe.getProbeentnahmeEnde().after(messung.getMesszeitpunkt())) { - warnings.put("messzeitpunkt", 661); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/validation/LMesswertValidator.java --- a/src/main/java/de/intevation/lada/validation/LMesswertValidator.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.validation; - -import java.util.HashMap; -import java.util.Map; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Named; - -import de.intevation.lada.model.LMesswert; - -@Named("lmesswertvalidator") -@ApplicationScoped -public class LMesswertValidator -implements Validator -{ - /** - * Validate a LMesswert object. - * - * @param object The LMesswert object. - * @param update The database operation. - * TRUE indicates that the object should be updated, FALSE - * if the object is a new Object. - * @return Map containing warnings. - */ - @Override - public Map validate(Object object, boolean update) - throws ValidationException { - Map warnings = new HashMap(); - if (!(object instanceof LMesswert)) { - Map errors = new HashMap(); - errors.put("lmesswert", 610); - throw new ValidationException(errors); - } - LMesswert messwert = (LMesswert)object; - - validateMessunsicherheit(messwert, warnings); - return null; - } - - /** - * Check if the LMesswert has a 'Messunsicherheit' or if the the value - * is lower than the 'Nachweisgrenze'. - * - * @param messwert The LMesswert object. - * @param warnings The map containing warnings. - * @throws ValidationException - */ - private void validateMessunsicherheit( - LMesswert messwert, - Map warnings) - throws ValidationException { - Float unsicherheit = messwert.getMessfehler(); - Float nachweisgrenze = messwert.getNwgZuMesswert(); - Float wert = messwert.getMesswert(); - if (unsicherheit != null && unsicherheit > 0f) { - return; - } - else if (nachweisgrenze != null && wert < nachweisgrenze) { - return; - } - else { - warnings.put("messwert", 631); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/validation/LOrtValidator.java --- a/src/main/java/de/intevation/lada/validation/LOrtValidator.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.validation; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; - -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.GeometryFactory; -import com.vividsolutions.jts.geom.Point; -import com.vividsolutions.jts.geom.PrecisionModel; - -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.data.Repository; -import de.intevation.lada.model.DeVg; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.Ort; -import de.intevation.lada.model.SVerwaltungseinheit; -import de.intevation.lada.rest.Response; - -/** - * Validator for LOrt objects. - * - * @author Raimund Renkert - */ -@ApplicationScoped -@Named("lortvalidator") -public class LOrtValidator -implements Validator -{ - @Inject - @Named("readonlyrepository") - private Repository readonlyRepo; - - @Inject - @Named("ortrepository") - private Repository ortRepo; - - /** - * Validate a LOrt object. - * - * @param object The LOrt object. - * @param update The database operation. - * TRUE indicates that the object should be updated, FALSE - * if the object is a new Object. - * @return Map containing warnings. - */ - @Override - public Map validate(Object object, boolean update) - throws ValidationException { - Map warnings = new HashMap(); - if (!(object instanceof LOrt)) { - Map errors = new HashMap(); - errors.put("lort", 610); - throw new ValidationException(errors); - } - LOrt ort = (LOrt)object; - validateVerwaltungseinheit(ort, warnings); - //TODO: more validation, see LSB: VI - Konsistenzregeln - return warnings; - } - - /** - * Check if the given lat/lon coordinates are within the area of the - * verwaltungseinheit. - * - * @param ort - * @param warnings - */ - private void validateVerwaltungseinheit(LOrt ort, Map warnings) { - if (!"E".equals(ort.getOrtsTyp())) { - return; - } - QueryBuilder ortBuilder = - new QueryBuilder(ortRepo.getEntityManager(), Ort.class); - ortBuilder.and("ortId", ort.getOrtId()); - Response response = ortRepo.filter(ortBuilder.getQuery()); - List orte = (List)response.getData(); - QueryBuilder veBuilder = - new QueryBuilder( - readonlyRepo.getEntityManager(), SVerwaltungseinheit.class); - veBuilder.and("gemId", orte.get(0).getGemId()); - Response ver = readonlyRepo.filter(veBuilder.getQuery()); - if (((List)ver.getData()).isEmpty()) { - warnings.put("verwaltungseinheit", 653); - return; - } - SVerwaltungseinheit ve = ((List)ver.getData()).get(0); - QueryBuilder vg = - new QueryBuilder(readonlyRepo.getEntityManager(), DeVg.class); - vg.and("ags", ve.getGemId()); - Response rvg = readonlyRepo.filter(vg.getQuery()); - List vgs = (List)rvg.getData(); - if (vgs == null || vgs.isEmpty()) { - warnings.put("verwaltungseinheit", 653); - return; - } - double y = orte.get(0).getLatitude(); - double x = orte.get(0).getLongitude(); - Coordinate c = new Coordinate(x, y); - GeometryFactory gf = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 4326); - Point p = gf.createPoint(c); - boolean hit = false; - for (DeVg singlevg : vgs) { - if(singlevg.getGeom().contains(p)) { - hit = true; - } - } - if (!hit) { - warnings.put("verwaltungseinheit", 651); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/validation/LProbeValidator.java --- a/src/main/java/de/intevation/lada/validation/LProbeValidator.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.validation; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.inject.Named; - -import de.intevation.lada.data.LOrtRepository; -import de.intevation.lada.data.LProbeRepository; -import de.intevation.lada.data.QueryBuilder; -import de.intevation.lada.model.LOrt; -import de.intevation.lada.model.LProbe; -import de.intevation.lada.model.LProbeInfo; -import de.intevation.lada.rest.Response; - -/** - * Validator for LProbe objects. - * - * @author Raimund Renkert - */ -@Named("lprobevalidator") -@ApplicationScoped -public class LProbeValidator -implements Validator -{ - /** - * The repositories used in this validator. - */ - @Inject - private LProbeRepository probeRepository; - @Inject - private LOrtRepository ortRepository; - - /** - * Validate a LProbe object. - * - * @param probe The LProbe object. - * @param update The database operation. - * TRUE indicates that the object should be updated, FALSE - * if the object is a new Object. - * @return Map containing warnings. - */ - @Override - public Map validate(Object probe, boolean update) - throws ValidationException { - Mapwarnings = new HashMap(); - if (!(probe instanceof LProbe)) { - Map errors = new HashMap(); - errors.put("lprobe", 610); - throw new ValidationException(errors); - } - LProbe p = (LProbe)probe; - - validateEntnahmeOrt(p, warnings); - validateProbenahmeBegin(p, warnings); - validateUWB(p, warnings); - validateHauptProbenNummer(p, warnings); - return warnings; - } - - /** - * Check if the 'Hauptproben Nr' is unique. - * - * @param p The LProbe object. - * @param warnings The map containing warnings. - * @throws ValidationException - */ - private void validateHauptProbenNummer(LProbe p, Map warnings) - throws ValidationException { - Response pInfo = - probeRepository.findById(LProbeInfo.class, p.getProbeId()); - List pList = (List)pInfo.getData(); - if (!(pList == null) && !pList.isEmpty()) { - LProbeInfo probe = pList.get(0); - if (probe.getHauptprobenNr().equals(p.getHauptprobenNr())) { - return; - } - } - String hpn = p.getHauptprobenNr(); - QueryBuilder builder = - new QueryBuilder( - probeRepository.getEntityManager(), LProbe.class); - builder.and("mstId", p.getMstId()).and("hauptprobenNr", hpn); - - Response response = probeRepository.filter(builder.getQuery()); - if (!((List)response.getData()).isEmpty()) { - Map errors = new HashMap(); - errors.put("hauptprobenNr", 611); - throw new ValidationException(errors, warnings); - } - } - - /** - * Check if the LProbe object has 'Entnahmeort'. - * - * @param probe - * @param warnings - */ - private void validateEntnahmeOrt(LProbe probe, Map warnings) { - String pid = probe.getProbeId(); - - QueryBuilder builder = - new QueryBuilder( - ortRepository.getEntityManager(), LOrt.class); - builder.and("probeId", pid); - - Response response = ortRepository.filter(builder.getQuery()); - if (((List)response.getData()).isEmpty()) { - warnings.put("entnahmeOrt", 631); - } - } - - /** - * Check if 'Probenahmeende' is after 'Probenahmebeginn'. - * - * @param probe The LProbe object. - * @param warnings The map containing warnings. - */ - private void validateProbenahmeBegin(LProbe probe, Map warnings) { - Date begin = probe.getProbeentnahmeBeginn(); - if (begin == null) { - warnings.put("probeentnahmeBegin", 631); - } - else if (begin.after(new Date())){ - warnings.put("probeentnahmeBegin", 661); - } - } - - /** - * Check if the LProbe object has a 'Umweltbereich'. - * - * @param probe The LProbe object. - * @param warnings The map containing warnings. - */ - private void validateUWB(LProbe probe, Map warnings) { - String uwb = probe.getUmwId(); - if (uwb == null || uwb.equals("")) { - warnings.put("uwb", 631); - } - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/validation/ValidationException.java --- a/src/main/java/de/intevation/lada/validation/ValidationException.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.validation; - -import java.util.HashMap; -import java.util.Map; - -/** - * Exception used for validation errors. - * - * @author Raimund Renkert - */ -public class ValidationException -extends Exception -{ - /** - * Errors saved in this exception. - */ - private Map errors; - - /** - * Warnings saved in this exception. - */ - private Map warnings; - - /** - * Do not allow an empty ValidationException object. - */ - private ValidationException() { - } - - /** - * Create a new instance with errors. - * - * @param errors - */ - public ValidationException(Map errors) { - this(); - this.errors = errors; - this.warnings = new HashMap(); - } - - /** - * Create a new instance with errors and warnings. - * - * @param errors - */ - public ValidationException( - Map errors, - Map warnings - ) { - this(); - this.errors = errors; - this.warnings = warnings; - } - - /** - * Getter for the errors. - * - * @return the errors - */ - public Map getErrors() { - return errors; - } - - /** - * Getter for the warnings. - * - * @return the warnings - */ - public Map getWarnings() { - return warnings; - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/java/de/intevation/lada/validation/Validator.java --- a/src/main/java/de/intevation/lada/validation/Validator.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.validation; - -import java.util.Map; - -/** - * Validator interface. Implement this interface for lada object validations. - * - * @author Raimund Renkert - */ -public interface Validator -{ - /** - * Validate a database object. - * - * @param object The object to validate. - * @param update The database operation. - * TRUE indicates that the object should be updated, FALSE - * if the object is a new Object. - * @return Map containing warnings. - * @throws ValidationException - */ - public Map validate(Object object, boolean update) - throws ValidationException; -} diff -r 9709bf4162fa -r 82b616dcbd53 src/main/resources/META-INF/persistence.xml --- a/src/main/resources/META-INF/persistence.xml Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ - - - - java:/jboss/Lada - de.intevation.lada.model.LProbe - de.intevation.lada.model.SNetzBetreiber - - - - - - - - diff -r 9709bf4162fa -r 82b616dcbd53 src/main/webapp/WEB-INF/faces-config.xml --- a/src/main/webapp/WEB-INF/faces-config.xml Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ - - - - - - - - - diff -r 9709bf4162fa -r 82b616dcbd53 src/main/webapp/WEB-INF/lada-ds.xml.old --- a/src/main/webapp/WEB-INF/lada-ds.xml.old Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ - - - - - - jdbc:h2:mem:lada;DB_CLOSE_DELAY=-1 - h2 - - sa - sa - - - - \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/main/webapp/index.html --- a/src/main/webapp/index.html Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ - - - - -Lada - - -

Lada Debug Page

-

This is the debugging page for the lada webservice. Below you find some links to trigger actions on the REST Api.

-

Test

- -

Proben

- - - diff -r 9709bf4162fa -r 82b616dcbd53 src/test/java/de/intevation/lada/ImporterTest.java --- a/src/test/java/de/intevation/lada/ImporterTest.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Ignore; - -import de.intevation.lada.auth.AuthenticationResponse; -import de.intevation.lada.importer.TestLAFImporter; - - -@Ignore -public class ImporterTest -{ - /* - @Ignore - public static void main(String[] args) { - System.setProperty( - "de.intevation.lada.test.singleprobe", - "/home/rrenkert/single.laf"); - System.setProperty( - "de.intevation.lada.test.incompleteprobe", - "/home/rrenkert/incomplete.laf"); - System.setProperty( - "de.intevation.lada.import", - "/opt/lada/config/import.json"); - System.out.println("ImporterTest started."); - TestLAFImporter test = new TestLAFImporter(); - test.loadLafFiles(); - - System.out.print("Testing config file not found: "); - test.testConfigFileNotFound(); - System.out.print("success.\n"); - - System.out.print("Testing config file: "); - test.testConfigFileLoading(); - System.out.print("success.\n"); - - System.out.print("Testing Parser:\n 1. Wrong header: "); - test.testProbeHeaderFail(); - System.out.print("success.\n 2. Complete probe: "); - test.testCompleteParser(); - System.out.print("success.\n"); - - //Prepare simulated authorization. - List netzbetreiber = new ArrayList(); - netzbetreiber.add("0611"); - List mst = new ArrayList(); - mst.add("06110"); - mst.add("06112"); - AuthenticationResponse auth = new AuthenticationResponse(); - auth.setUser("testeins"); - auth.setNetzbetreiber(netzbetreiber); - auth.setMst(mst); - auth.setNetzbetreiber(netzbetreiber); - - - System.out.println("end."); - return; - }*/ -} diff -r 9709bf4162fa -r 82b616dcbd53 src/test/java/de/intevation/lada/TestRestEasyClient.java --- a/src/test/java/de/intevation/lada/TestRestEasyClient.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada; - -import junit.framework.Assert; -import org.junit.Test; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; - -public class TestRestEasyClient { - - public static String baseURL = "https://bfs-lada.intevation.de/lada-1.0/server/rest/"; - - public ClientResponse getResponse(String url, boolean header){ - ClientRequest request = new ClientRequest(url); - if(header) - request.header("Authorization", "Basic dGVzdGVpbnM6TjVKOENmSm5iOA=="); - ClientResponse response = null; - try { - response = request.get(String.class); - } - catch(Exception e) { - e.printStackTrace(); - } - return response; - } - - public void checkResponse(ClientResponse response){ - Assert.assertEquals(true, response.getEntity().contains("\"message\":\"200\"")); - } - - public void testHttpOK(String url) { - ClientResponse response = getResponse(url, true); - Assert.assertNotNull("Response shouldnot be null", response); - Assert.assertEquals(200, response.getStatus()); - checkResponse(response); - } - - public void testHttpForbidden(String url) { - ClientResponse response = getResponse(url, false); - Assert.assertNotNull("Response shouldnot be null", response); - Assert.assertEquals(401, response.getStatus()); - } - - @Test - public void testLOrtService(){ - testHttpOK(baseURL + "ort?probeId=000007587685X"); - testHttpForbidden(baseURL + "ort"); - ClientResponse response = getResponse(baseURL + "ort/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); - } - @Test - public void testLMessKommentarService() { - testHttpOK(baseURL + "messkommentare?probeId=000007587685X&messungsId=1"); - testHttpForbidden(baseURL + "messkommentare"); - ClientResponse response = getResponse(baseURL + "messkommentare/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); - } - @Test - public void testLKommentarService() { - testHttpOK(baseURL + "kommentare?probeId=000007587685X"); - testHttpForbidden(baseURL + "kommentare"); - ClientResponse response = getResponse(baseURL + "kommentare/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); - } - @Test - public void testMessungService() { - testHttpOK(baseURL + "messung?probeId=000007587685X"); - testHttpForbidden(baseURL + "messung"); - ClientResponse response = getResponse(baseURL + "messung/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); - } - @Test - public void testLMesswertService() { - testHttpOK(baseURL + "messwert?probeId=000007587685X&messungsId=1"); - testHttpForbidden(baseURL + "messwert"); - ClientResponse response = getResponse(baseURL + "messungwert/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); - } - @Test - public void testLProbenService() { - testHttpOK(baseURL + "proben?mst_id=06010&umw_id=N24&qid=2"); - testHttpForbidden(baseURL + "proben?mst_id=06010&umw_id=N24&qid=2"); - ClientResponse response = getResponse(baseURL + "proben/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(200, response.getStatus()); - checkResponse(response); - } - @Test - public void testLStatusService() { - testHttpOK(baseURL + "status?probeId=000007587685X&messungsId=1"); - testHttpForbidden(baseURL + "status"); - ClientResponse response = getResponse(baseURL + "status/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); - } - @Test - public void testLZusatzwertService() { - testHttpOK(baseURL + "zusatzwert?probeId=000007587685X"); - testHttpForbidden(baseURL + "zusatzwert"); - ClientResponse response = getResponse(baseURL + "zusatzwert/000007587685X", true); - Assert.assertNotNull(response); - Assert.assertEquals(404, response.getStatus()); - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/test/java/de/intevation/lada/importer/TestLAFImporter.java --- a/src/test/java/de/intevation/lada/importer/TestLAFImporter.java Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU GPL (v>=3) - * and comes with ABSOLUTELY NO WARRANTY! Check out - * the documentation coming with IMIS-Labordaten-Application for details. - */ -package de.intevation.lada.importer; - - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.List; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import de.intevation.lada.data.importer.EntryFormat; -import de.intevation.lada.data.importer.LAFFormat; -import de.intevation.lada.data.importer.LAFParser; -import de.intevation.lada.data.importer.LAFParserException; - - -public class TestLAFImporter -{ - - private static final String PROBE_HEADER_FAIL = - "%OBE%\n"; - private String singleProbe; - private String incompleteProbe; - - @Before - public void loadLafFiles() { - String single = System.getProperty("de.intevation.lada.test.singleprobe"); - String incomplete = - System.getProperty("de.intevation.lada.test.incompleteprobe"); - try { - byte[] encodedSingle = Files.readAllBytes(Paths.get(single)); - byte[] encodedIncomplete = - Files.readAllBytes(Paths.get(incomplete)); - Charset encoding = Charset.defaultCharset(); - singleProbe = - encoding.decode(ByteBuffer.wrap(encodedSingle)).toString(); - incompleteProbe = - encoding.decode(ByteBuffer.wrap(encodedIncomplete)).toString(); - } - catch (IOException ioe) { - singleProbe = ""; - incompleteProbe = ""; - } - } - - @Test - public void testConfigFileNotFound() { - LAFFormat format = new LAFFormat(); - boolean success = format.readConfigFile("/file/not/found"); - assertEquals(false, success); - } - - @Test - public void testConfigFileLoading() { - String fileName = System.getProperty("de.intevation.lada.import"); - LAFFormat format = new LAFFormat(); - boolean success = format.readConfigFile(fileName); - assertEquals(true, success); - List probeFormat = format.getFormat("probe"); - assertNotNull("No probe format available", probeFormat); - assertEquals( - "Not enough configuration elements for probe.", - 33, - probeFormat.size()); - List messungFormat = format.getFormat("messung"); - assertNotNull("No messung format available", messungFormat); - assertEquals( - "Not enough configuration elements for messung.", - 10, - messungFormat.size()); - List ortFormat = format.getFormat("ort"); - assertNotNull("No ort format available", ortFormat); - assertEquals( - "Not enough configuration elements for ort.", - 21, - ortFormat.size()); - } - - @Test - @Ignore - public void testProbeHeaderFail() { - LAFParser parser = new LAFParser(); - parser.setDryRun(true); - /* - try { - boolean success = parser.parse(PROBE_HEADER_FAIL); - assertEquals(false, success); - } - catch (LAFParserException e) { - assertEquals( - "Exception cause not expected: " + e.getMessage(), - "No %PROBE% at the begining.", e.getMessage()); - } - */ - } - - @Test - @Ignore - public void testIncompleteProbe() { - LAFParser parser = new LAFParser(); - parser.setDryRun(true); - /* - try { - parser.parse(incompleteProbe); - } - catch (LAFParserException e) { - e.printStackTrace(); - } - */ - } - - @Test - @Ignore - public void testCompleteParser() { - LAFParser parser = new LAFParser(); - parser.setDryRun(true); - /* - try { - parser.parse(singleProbe); - } - catch (LAFParserException e) { - e.printStackTrace(); - } - */ - } -} diff -r 9709bf4162fa -r 82b616dcbd53 src/test/resources/META-INF/test-persistence.xml --- a/src/test/resources/META-INF/test-persistence.xml Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ - - - - - - java:jboss/datasources/ladaTestDS - - - - - - - \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/test/resources/arquillian.xml --- a/src/test/resources/arquillian.xml Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - /path/to/jboss/as - - - - \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 src/test/resources/test-ds.xml --- a/src/test/resources/test-ds.xml Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ - - - - - - jdbc:h2:mem:lada-test;DB_CLOSE_DELAY=-1 - h2 - - sa - sa - - - - \ No newline at end of file diff -r 9709bf4162fa -r 82b616dcbd53 test/example.laf --- a/test/example.laf Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -%PROBE% -UEBERTRAGUNGSFORMAT "7" -VERSION "0084" -DATENBASIS_S 02 -NETZKENNUNG "11" -ERZEUGER "bv" -MESSSTELLE "11010" -MESSLABOR "30021" -PROBE_ID "000007695981X" -HAUPTPROBENNUMMER "Beispiel_01" -MESSPROGRAMM_S "1" -MESSPROGRAMM_LAND "007" -PROBENAHMEINSTITUTION "001" -PROBENART "S" -ZEITBASIS_S 2 -URSPRUNGS_DATUM_UHRZEIT 20120906 0800 -PROBENAHME_DATUM_UHRZEIT_A 20120906 1000 -PROBENAHME_DATUM_UHRZEIT_E 20120906 1100 -UMWELTBEREICH_S "N12" -DESKRIPTOREN "0101010207 " -TESTDATEN 1 -SZENARIO "dummy" -P_HERKUNFTSLAND_S 00000000 -P_GEMEINDESCHLUESSEL 13071084 -P_ORTS_ZUSATZKENNZAHL 133 -P_KOORDINATEN_S 01 "3752892" "5967336" -P_ORTS_ZUSATZCODE "0200" -P_ORTS_ZUSATZTEXT "Testzusatztext 01" -P_NUTS_CODE "DE808" -%URSPRUNGSORT% -U_HERKUNFTSLAND_S 00000000 -U_GEMEINDESCHLUESSEL 13071005 -U_KOORDINATEN_S 05 "33363084" "5926966" -U_NUTS_CODE "DE80C" -PROBENKOMMENTAR "30021" 20120906 1354 "Testkommentar 01" -PROBENZUSATZBESCHREIBUNG "WAREN-L" 10.000E+00 "l" 0.00 -%MESSUNG% -MESSUNGS_ID 01 -NEBENPROBENNUMMER "0001" -MESSMETHODE_S "A1" -BEARBEITUNGSSTATUS "1110" -MESS_DATUM_UHRZEIT 20120906 1200 -MESSZEIT_SEKUNDEN 00003600 -PEP_FLAG 0 -ERFASSUNG_ABGESCHLOSSEN 1 -MESSWERT "Am 241" <1.000E-02 "Bq/l" 0.00 -MESSWERT "Pu 238" <2.000E-02 "Bq/l" 0.00 -MESSWERT "Pu 239" 1.230E-01 "Bq/l" 10.00 -KOMMENTAR "30021" 20120906 1355 "Testkommentar 01" -KOMMENTAR "30021" 20120906 1356 "Testkommentar 02" -%MESSUNG% -MESSUNGS_ID 02 -NEBENPROBENNUMMER "0002" -MESSMETHODE_S "G1" -BEARBEITUNGSSTATUS "1110" -MESS_DATUM_UHRZEIT 20120906 1300 -MESSZEIT_SEKUNDEN 00007200 -PEP_FLAG 0 -ERFASSUNG_ABGESCHLOSSEN 1 -MESSWERT "Ce 144" <1.000E-02 "Bq/l" 0.00 -MESSWERT "Co 60" 1.000E-01 "Bq/l" 20.00 -MESSWERT "Cs 134" <1.000E-01 "Bq/l" 0.00 -MESSWERT "Cs 137" 10.000E+00 "Bq/l" 10.00 -MESSWERT "I 131" <1.000E-02 "Bq/l" 0.00 -MESSWERT "K 40" 10.000E+01 "Bq/l" 10.00 -MESSWERT "Ru 103" <2.000E-02 "Bq/l" 0.00 -KOMMENTAR "30021" 20120906 1358 "Testkommentar 01" -%PROBE% -UEBERTRAGUNGSFORMAT "7" -VERSION "0084" -DATENBASIS_S 02 -NETZKENNUNG "19" -ERZEUGER "bv" -MESSSTELLE "30021" -MESSLABOR "30021" -PROBE_ID "000007695982X" -HAUPTPROBENNUMMER "Beispiel_02" -MESSPROGRAMM_S "1" -MESSPROGRAMM_LAND "007" -PROBENAHMEINSTITUTION "001" -PROBENART "S" -ZEITBASIS_S 2 -URSPRUNGS_DATUM_UHRZEIT 20120905 0800 -PROBENAHME_DATUM_UHRZEIT_A 20120905 1000 -PROBENAHME_DATUM_UHRZEIT_E 20120906 1100 -UMWELTBEREICH_S "F11" -DESKRIPTOREN "020105 " -TESTDATEN 1 -SZENARIO "dummy" -P_HERKUNFTSLAND_S 00000000 -P_GEMEINDESCHLUESSEL 13003000 -P_ORTS_ZUSATZKENNZAHL 004 -P_KOORDINATEN_S 02 "0120524" "541041" -P_ORTS_ZUSATZCODE "0200" -P_ORTS_ZUSATZTEXT "Testzusatztext 01" -P_NUTS_CODE "DE803" -%URSPRUNGSORT% -PROBENKOMMENTAR "30021" 20120906 1407 "Testkommentar 01" -PROBENKOMMENTAR "30021" 20120906 1407 "Testkommetar 02" -PROBENZUSATZBESCHREIBUNG "PRMENGF" 1.000E+00 "kg(FM)" 0.00 -PROBENZUSATZBESCHREIBUNG "PRMENGT" 9.000E-01 "kg(TM)" 0.00 -%MESSUNG% -MESSUNGS_ID 01 -NEBENPROBENNUMMER "0001" -MESSMETHODE_S "B1" -BEARBEITUNGSSTATUS "1000" -MESS_DATUM_UHRZEIT 20120906 1400 -MESSZEIT_SEKUNDEN 00001800 -PEP_FLAG 0 -ERFASSUNG_ABGESCHLOSSEN 1 -MESSWERT "H 3" 1.230E+02 "Bq/kg(FM)" 12.00 -KOMMENTAR "30021" 20120906 1410 "Testkommentar 01" -KOMMENTAR "30021" 20120906 1410 "Testkommetar 02" -%ENDE% - diff -r 9709bf4162fa -r 82b616dcbd53 test/incomplete.laf --- a/test/incomplete.laf Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -%PROBE% -UEBERTRAGUNGSFORMAT "7" -VERSION "0084" -DATENBASIS_S 02 -NETZKENNUNG "19" -ERZEUGER "bv" -MESSSTELLE "30021" -MESSLABOR "30021" -HAUPTPROBENNUMMER "Beispiel_01" -MESSPROGRAMM_S "1" -MESSPROGRAMM_LAND "007" -PROBENAHMEINSTITUTION "001" -PROBENART "S" -ZEITBASIS_S 2 -URSPRUNGS_DATUM_UHRZEIT 20120906 0800 -PROBENAHME_DATUM_UHRZEIT_A 20120906 1000 -PROBENAHME_DATUM_UHRZEIT_E 20120906 1100 -UMWELTBEREICH_S "N12" -DESKRIPTOREN "0101010207 " -TESTDATEN 1 -SZENARIO "dummy" -P_HERKUNFTSLAND_S 00000000 -P_GEMEINDESCHLUESSEL 13071084 -P_ORTS_ZUSATZKENNZAHL 133 -P_KOORDINATEN_S 01 "3752892" "5967336" -P_ORTS_ZUSATZCODE "0200" -P_ORTS_ZUSATZTEXT "Testzusatztext 01" -P_NUTS_CODE "DE808" -%URSPRUNGSORT% -U_HERKUNFTSLAND_S 00000000 -U_GEMEINDESCHLUESSEL 13071005 -U_KOORDINATEN_S 05 "33363084" "5926966" -U_NUTS_CODE "DE80C" -PROBENKOMMENTAR "30021" 20120906 1354 "Testkommentar 01" -PROBENZUSATZBESCHREIBUNG "WAREN-L" 10.000E+00 "l" 0.00 -%MESSUNG% -MESSUNGS_ID 01 -NEBENPROBENNUMMER "0001" -MESSMETHODE_S "A1" -BEARBEITUNGSSTATUS "1110" -MESS_DATUM_UHRZEIT 20120906 1200 -MESSZEIT_SEKUNDEN 00003600 -PEP_FLAG 0 -ERFASSUNG_ABGESCHLOSSEN 1 -MESSWERT "Am 241" <1.000E-02 "Bq/l" 0.00 -MESSWERT "Pu 238" <2.000E-02 "Bq/l" 0.00 -MESSWERT "Pu 239" 1.230E-01 "Bq/l" 10.00 -KOMMENTAR "30021" 20120906 1355 "Testkommentar 01" -KOMMENTAR "30021" 20120906 1356 "Testkommentar 02" -%MESSUNG% -MESSUNGS_ID 02 -NEBENPROBENNUMMER "0002" -MESSMETHODE_S "G1" -BEARBEITUNGSSTATUS "1110" -MESS_DATUM_UHRZEIT 20120906 1300 -MESSZEIT_SEKUNDEN 00007200 -PEP_FLAG 0 -ERFASSUNG_ABGESCHLOSSEN 1 -MESSWERT "Ce 144" <1.000E-02 "Bq/l" 0.00 -MESSWERT "Co 60" 1.000E-01 "Bq/l" 20.00 -MESSWERT "Cs 134" <1.000E-01 "Bq/l" 0.00 -MESSWERT "Cs 137" 10.000E+00 "Bq/l" 10.00 -MESSWERT "I 131" <1.000E-02 "Bq/l" 0.00 -MESSWERT "K 40" 10.000E+01 "Bq/l" 10.00 -MESSWERT "Ru 103" <2.000E-02 "Bq/l" 0.00 -KOMMENTAR "30021" 20120906 1358 "Testkommentar 01" -%ENDE% diff -r 9709bf4162fa -r 82b616dcbd53 test/single.laf --- a/test/single.laf Wed Feb 04 15:48:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -%PROBE% -UEBERTRAGUNGSFORMAT "7" -VERSION "0084" -DATENBASIS_S 02 -NETZKENNUNG "19" -ERZEUGER "bv" -MESSSTELLE "30021" -MESSLABOR "30021" -PROBE_ID "000007695981X" -HAUPTPROBENNUMMER "Beispiel_01" -MESSPROGRAMM_S "1" -MESSPROGRAMM_LAND "007" -PROBENAHMEINSTITUTION "001" -PROBENART "S" -ZEITBASIS_S 2 -URSPRUNGS_DATUM_UHRZEIT 20120906 0800 -PROBENAHME_DATUM_UHRZEIT_A 20120906 1000 -PROBENAHME_DATUM_UHRZEIT_E 20120906 1100 -UMWELTBEREICH_S "N12" -DESKRIPTOREN "0101010207 " -TESTDATEN 1 -SZENARIO "dummy" -P_HERKUNFTSLAND_S 00000000 -P_GEMEINDESCHLUESSEL 13071084 -P_ORTS_ZUSATZKENNZAHL 133 -P_KOORDINATEN_S 01 "3752892" "5967336" -P_ORTS_ZUSATZCODE "0200" -P_ORTS_ZUSATZTEXT "Testzusatztext 01" -P_NUTS_CODE "DE808" -%URSPRUNGSORT% -U_HERKUNFTSLAND_S 00000000 -U_GEMEINDESCHLUESSEL 13071005 -U_KOORDINATEN_S 05 "33363084" "5926966" -U_NUTS_CODE "DE80C" -PROBENKOMMENTAR "30021" 20120906 1354 "Testkommentar 01 -bla blub" -PROBENZUSATZBESCHREIBUNG "WAREN-L" 10.000E+00 "l" 0.00 -%MESSUNG% -MESSUNGS_ID 01 -NEBENPROBENNUMMER "0001" -MESSMETHODE_S "A1" -BEARBEITUNGSSTATUS "1110" -MESS_DATUM_UHRZEIT 20120906 1200 -MESSZEIT_SEKUNDEN 00003600 -PEP_FLAG 0 -ERFASSUNG_ABGESCHLOSSEN 1 -MESSWERT "Am 241" <1.000E-02 "Bq/l" 0.00 -MESSWERT "Pu 238" <2.000E-02 "Bq/l" 0.00 -MESSWERT "Pu 239" 1.230E-01 "Bq/l" 10.00 -KOMMENTAR "30021" 20120906 1355 "Testkommentar 01" -KOMMENTAR "30021" 20120906 1356 "Testkommentar 02" -%MESSUNG% -MESSUNGS_ID 02 -NEBENPROBENNUMMER "0002" -MESSMETHODE_S "G1" -BEARBEITUNGSSTATUS "1110" -MESS_DATUM_UHRZEIT 20120906 1300 -MESSZEIT_SEKUNDEN 00007200 -PEP_FLAG 0 -ERFASSUNG_ABGESCHLOSSEN 1 -MESSWERT "Ce 144" <1.000E-02 "Bq/l" 0.00 -MESSWERT "Co 60" 1.000E-01 "Bq/l" 20.00 -MESSWERT "Cs 134" <1.000E-01 "Bq/l" 0.00 -MESSWERT "Cs 137" 10.000E+00 "Bq/l" 10.00 -MESSWERT "I 131" <1.000E-02 "Bq/l" 0.00 -MESSWERT "K 40" 10.000E+01 "Bq/l" 10.00 -MESSWERT "Ru 103" <2.000E-02 "Bq/l" 0.00 -KOMMENTAR "30021" 20120906 1358 "Testkommentar 01" -%PROBE% -UEBERTRAGUNGSFORMAT "7" -VERSION "0084" -DATENBASIS_S 02 -NETZKENNUNG "19" -ERZEUGER "bv" -MESSSTELLE "30021" -MESSLABOR "30021" -PROBE_ID "000007695981Y" -HAUPTPROBENNUMMER "Beispiel_01" -MESSPROGRAMM_S "1" -MESSPROGRAMM_LAND "007" -PROBENAHMEINSTITUTION "001" -PROBENART "S" -ZEITBASIS_S 2 -URSPRUNGS_DATUM_UHRZEIT 20120906 0800 -PROBENAHME_DATUM_UHRZEIT_A 20120906 1000 -PROBENAHME_DATUM_UHRZEIT_E 20120906 1100 -UMWELTBEREICH_S "N12" -DESKRIPTOREN "0101010207 " -TESTDATEN 1 -SZENARIO "dummy" -P_HERKUNFTSLAND_S 00000000 -P_GEMEINDESCHLUESSEL 13071084 -P_ORTS_ZUSATZKENNZAHL 133 -P_KOORDINATEN_S 01 "3752892" "5967336" -P_ORTS_ZUSATZCODE "0200" -P_ORTS_ZUSATZTEXT "Testzusatztext 01" -P_NUTS_CODE "DE808" -%URSPRUNGSORT% -U_HERKUNFTSLAND_S 00000000 -U_GEMEINDESCHLUESSEL 13071005 -U_KOORDINATEN_S 05 "33363084" "5926966" -U_NUTS_CODE "DE80C" -PROBENKOMMENTAR "30021" 20120906 1354 "Testkommentar 01 -bla blub" -PROBENZUSATZBESCHREIBUNG "WAREN-L" 10.000E+00 "l" 0.00 -%MESSUNG% -MESSUNGS_ID 01 -NEBENPROBENNUMMER "0001" -MESSMETHODE_S "A1" -BEARBEITUNGSSTATUS "1110" -MESS_DATUM_UHRZEIT 20120906 1200 -MESSZEIT_SEKUNDEN 00003600 -PEP_FLAG 0 -ERFASSUNG_ABGESCHLOSSEN 1 -MESSWERT "Am 241" <1.000E-02 "Bq/l" 0.00 -MESSWERT "Pu 238" <2.000E-02 "Bq/l" 0.00 -MESSWERT "Pu 239" 1.230E-01 "Bq/l" 10.00 -KOMMENTAR "30021" 20120906 1355 "Testkommentar 01" -KOMMENTAR "30021" 20120906 1356 "Testkommentar 02" -%ENDE%