Mercurial > dive4elements > river
changeset 1018:d42fa223be48
Datacage: added first user specific config for cross sections.
flys-artifacts/trunk@2464 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 04 Aug 2011 15:05:02 +0000 |
parents | 8637756275e5 |
children | aff2a0a29aa3 |
files | flys-artifacts/ChangeLog flys-artifacts/doc/conf/meta-data-user.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java |
diffstat | 3 files changed, 67 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Thu Aug 04 10:58:00 2011 +0000 +++ b/flys-artifacts/ChangeLog Thu Aug 04 15:05:02 2011 +0000 @@ -1,3 +1,16 @@ +2011-08-04 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java: + If given an artifact place its identifier into parameters passed to template. + Fixed swapped user/system connections if using the user template. + + * doc/conf/meta-data-user.xml: Recommend w/q facet from old calculations + if an artifact was given that represents a longitudinal section + "Laengsschnitt". + + TODO I: The template uses PostgreSQL specific UUID casts. + TODO II: We need to find a way only to recommend the master artifacts. + 2011-08-04 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java: @@ -37,7 +50,7 @@ "/art:meta/art:artifact-id/@value" The UUID of the artifact. Optional. Used to fill the template enviroment. - "art:meta/art:user-id/@value" The UUID of the user. Optional. + "/art:meta/art:user-id/@value" The UUID of the user. Optional. If given the user specific template is filled. "/art:meta/art:outs/@value" The list of outs used to recommend for the various outputs.
--- a/flys-artifacts/doc/conf/meta-data-user.xml Thu Aug 04 10:58:00 2011 +0000 +++ b/flys-artifacts/doc/conf/meta-data-user.xml Thu Aug 04 15:05:02 2011 +0000 @@ -1,12 +1,53 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <dc:template xmlns:dc="http://www.intevation.org/2011/Datacage"> <datacage> - <dc:comment> - User specific part - ------------------ - </dc:comment> - <dc:if test="dc:contains($parameters, 'user-id')"> - <dc:text>Current user id: ${user-id}</dc:text> - </dc:if> + <dc:comment> + User specific part + ------------------ + </dc:comment> + <dc:if test="dc:contains($parameters, 'user-id')"> + <dc:context connection="user"> + <dc:statement>SELECT id as user_id FROM users WHERE gid = ${user-id}::uuid</dc:statement> + <dc:elements> + <dc:context> + <dc:statement>SELECT id AS collection_id FROM collections WHERE user_id = ${user_id}</dc:statement> + <dc:elements> + <dc:context> + <dc:statement>SELECT a.id AS a_id, a.state AS a_state, a.gid as a_gid FROM + collection_items ci JOIN artifacts a ON ci.artifact_id = a.id + WHERE collection_id = ${collection_id} AND a.state = ${current-state-id} AND a.gid <> ${artifact-id}::uuid + AND EXISTS (SELECT id FROM artifact_data WHERE artifact_id = a.id AND k = 'river' AND v = ${river}) + </dc:statement> + <dc:comment> --- TODO: We only need the 'master' artifacts! --- </dc:comment> + <dc:elements> + <dc:choose> + <dc:when test="$current-state-id = 'state.winfo.waterlevel'"> + <dc:context> + <dc:statement>SELECT id AS out_id FROM outs WHERE artifact_id = ${a_id} AND name = 'longitudinal_section'</dc:statement> + <dc:elements> + <dc:context> + <dc:statement>SELECT name AS facet_name, num as facet_num, description AS facet_description + FROM facets WHERE out_id = ${out_id} ORDER BY num ASC, name DESC + </dc:statement> + <dc:elements> + <dc:element name="${facet_name}"> + <dc:attribute name="description" value="${facet_description}"/> + <dc:attribute name="num" value="${facet_num}"/> + <dc:attribute name="factory" value="TODO"/> + <dc:attribute name="artifact-id" value="${a_gid}"/> + </dc:element> + </dc:elements> + </dc:context> + </dc:elements> + </dc:context> + </dc:when> + </dc:choose> + </dc:elements> + </dc:context> + </dc:elements> + </dc:context> + </dc:elements> + </dc:context> + </dc:if> </datacage> </dc:template>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java Thu Aug 04 10:58:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java Thu Aug 04 15:05:02 2011 +0000 @@ -72,6 +72,7 @@ Map<String, Object> parameters ) { parameters.put("current-state-id", artifact.getCurrentStateId()); + parameters.put("artifact-id", artifact.identifier()); for (StateData sd: artifact.getAllData()) { Object value = sd.getValue(); @@ -139,9 +140,6 @@ new ArrayList<Builder.NamedConnection>(2); if (userId != null) { // system and user templates - connections.add(new Builder.NamedConnection( - Builder.CONNECTION_USER, systemConnection)); - // get connection to datacage db DataSource dataSource = DBConfig .getInstance() @@ -151,7 +149,10 @@ Connection userConnection = dataSource.getConnection(); try { connections.add(new Builder.NamedConnection( - Builder.CONNECTION_SYSTEM, userConnection, false)); + Builder.CONNECTION_USER, userConnection)); + + connections.add(new Builder.NamedConnection( + Builder.CONNECTION_SYSTEM, systemConnection, false)); userBuilder.build(connections, result, parameters); }