Mercurial > dive4elements > river
changeset 6095:0f3ca851d204
First part of the filtering datacage for user data.
This joins the outs to the master artifact information
and adds km filtering.
Next step: Joining the facets and filtering by them.
This will also fix the broken select-facet macro
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 24 May 2013 18:53:05 +0200 |
parents | 16027599b2a9 |
children | 6e99ce505860 |
files | artifacts/doc/conf/meta-data.xml |
diffstat | 1 files changed, 196 insertions(+), 292 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml Fri May 24 17:10:19 2013 +0200 +++ b/artifacts/doc/conf/meta-data.xml Fri May 24 18:53:05 2013 +0200 @@ -273,115 +273,117 @@ <dc:macro name="generate-user-content"> <dc:call-macro name="user-range"> - <dc:call-macro name="km-filtered-userdata"> - <dc:choose> - <dc:when test="dc:contains($parameters, 'recommended')"> - <dc:comment> - Recommendations (client shall load immediately). - </dc:comment> - <dc:iterate var="out" container="artifact-outs"> - <dc:choose> - <dc:when test="$out = 'longitudinal_section'"> - <dc:call-macro name="officiallines_user"/> - </dc:when> - </dc:choose> - </dc:iterate> - </dc:when> - <dc:otherwise> - <dc:comment> - Non Recommendations - </dc:comment> - <dc:iterate var="out" container="artifact-outs"> - <dc:choose> - <dc:when test="$out = 'longitudinal_section'"> - <dc:call-macro name="longitudinal"/> - <dc:call-macro name="differences"/> - </dc:when> - <dc:when test="$out = 'discharge_longitudinal_section'"> - <dc:call-macro name="longitudinal"/> - <dc:call-macro name="differences"/> - </dc:when> - <dc:when test="$out = 'w_differences'"> - <dc:call-macro name="longitudinal"/> - <dc:call-macro name="differences"/> - </dc:when> - <dc:when test="$out = 'fix_deltawt_curve'"> - <dc:call-macro name="delta-wt"/> - </dc:when> - <dc:when test="$out = 'reference_curve'"> - <dc:call-macro name="reference-curves"/> - </dc:when> - <dc:when test="$out = 'computed_discharge_curve'"> - <dc:call-macro name="computed-discharge-curve"/> - </dc:when> - <dc:when test="$out = 'cross_section'"> - <dc:call-macro name="waterlevels"/> - </dc:when> - <dc:when test="$out = 'fix_longitudinal_section_curve'"> - <dc:call-macro name="longitudinal-section"/> - </dc:when> - <dc:when test="$out = 'fix_derivate_curve'"> - <dc:call-macro name="fix-derivate-curve"/> - </dc:when> - <dc:when test="$out = 'fix_wq_curve'"> - <dc:call-macro name="fix-wq-curve"/> - </dc:when> - <dc:when test="$out = 'duration_curve'"> - <dc:call-macro name="duration-curve"/> - </dc:when> - <dc:when test="$out = 'waterlevels'"> - <dc:call-macro name="waterlevels-fix"/> - </dc:when> - <dc:when test="$out = 'fix_wq_curve'"> - <dc:call-macro name="waterlevels-fix"/> - </dc:when> - <dc:when test="$out = 'floodmap'"> - <dc:call-macro name="flood-map"/> - </dc:when> - <dc:when test="$out = 'map'"> - <dc:call-macro name="flood-map"/> - </dc:when> - <dc:when test="$out = 'bedheight_middle'"> - <dc:call-macro name="waterlevels-discharge"/> - <dc:call-macro name="waterlevels-fix"/> - </dc:when> - <dc:when test="$out = 'floodmap-hws'"> - <dc:call-macro name="floodmap-hws-user"/> - </dc:when> - <dc:when test="$out = 'flow_velocity'"> - <dc:call-macro name="bedquality-bed"/> - <dc:call-macro name="bedquality-load"/> - </dc:when> - <dc:when test="$out = 'bed_longitudinal_section'"> - <dc:call-macro name="bedquality-bed"/> - <dc:call-macro name="bedquality-load"/> - <dc:call-macro name="bedquality-density"/> - <dc:call-macro name="bedquality-porosity"/> - </dc:when> - <dc:when test="$out = 'sedimentload_ls'"> - <dc:call-macro name="differences"/> - <dc:call-macro name="bedheight-differences"/> - <dc:call-macro name="flow-velocity"/> - <dc:call-macro name="sediment-load"/> - </dc:when> - <dc:when test="$out = 'bed_difference_year'"> - <dc:call-macro name="waterlevels-discharge"/> - <dc:call-macro name="bedheight-differences"/> - <dc:call-macro name="differences"/> - <dc:call-macro name="waterlevels-fix"/> - <dc:call-macro name="delta-wt-ls"/> - </dc:when> - <dc:when test="$out = 'bed_difference_epoch'"> - <dc:call-macro name="waterlevels-discharge"/> - <dc:call-macro name="bedheight-differences"/> - <dc:call-macro name="differences"/> - <dc:call-macro name="waterlevels-fix"/> - <dc:call-macro name="delta-wt-ls"/> - </dc:when> - </dc:choose> - </dc:iterate> - </dc:otherwise> - </dc:choose> + <dc:call-macro name="all-user-artifacts"> + <dc:call-macro name="km-filtered-user-artifacts"> + <dc:choose> + <dc:when test="dc:contains($parameters, 'recommended')"> + <dc:comment> + Recommendations (user) + </dc:comment> + <dc:iterate var="out" container="artifact-outs"> + <dc:choose> + <dc:when test="$out = 'longitudinal_section'"> + <dc:call-macro name="officiallines_user"/> + </dc:when> + </dc:choose> + </dc:iterate> + </dc:when> + <dc:otherwise> + <dc:comment> + Non Recommendations (user) + </dc:comment> + <dc:iterate var="out" container="artifact-outs"> + <dc:choose> + <dc:when test="$out = 'longitudinal_section'"> + <dc:call-macro name="longitudinal"/> + <dc:call-macro name="differences"/> + </dc:when> + <dc:when test="$out = 'discharge_longitudinal_section'"> + <dc:call-macro name="longitudinal"/> + <dc:call-macro name="differences"/> + </dc:when> + <dc:when test="$out = 'w_differences'"> + <dc:call-macro name="longitudinal"/> + <dc:call-macro name="differences"/> + </dc:when> + <dc:when test="$out = 'fix_deltawt_curve'"> + <dc:call-macro name="delta-wt"/> + </dc:when> + <dc:when test="$out = 'reference_curve'"> + <dc:call-macro name="reference-curves"/> + </dc:when> + <dc:when test="$out = 'computed_discharge_curve'"> + <dc:call-macro name="computed-discharge-curve"/> + </dc:when> + <dc:when test="$out = 'cross_section'"> + <dc:call-macro name="waterlevels"/> + </dc:when> + <dc:when test="$out = 'fix_longitudinal_section_curve'"> + <dc:call-macro name="longitudinal-section"/> + </dc:when> + <dc:when test="$out = 'fix_derivate_curve'"> + <dc:call-macro name="fix-derivate-curve"/> + </dc:when> + <dc:when test="$out = 'fix_wq_curve'"> + <dc:call-macro name="fix-wq-curve"/> + </dc:when> + <dc:when test="$out = 'duration_curve'"> + <dc:call-macro name="duration-curve"/> + </dc:when> + <dc:when test="$out = 'waterlevels'"> + <dc:call-macro name="waterlevels-fix"/> + </dc:when> + <dc:when test="$out = 'fix_wq_curve'"> + <dc:call-macro name="waterlevels-fix"/> + </dc:when> + <dc:when test="$out = 'floodmap'"> + <dc:call-macro name="flood-map"/> + </dc:when> + <dc:when test="$out = 'map'"> + <dc:call-macro name="flood-map"/> + </dc:when> + <dc:when test="$out = 'bedheight_middle'"> + <dc:call-macro name="waterlevels-discharge"/> + <dc:call-macro name="waterlevels-fix"/> + </dc:when> + <dc:when test="$out = 'floodmap-hws'"> + <dc:call-macro name="floodmap-hws-user"/> + </dc:when> + <dc:when test="$out = 'flow_velocity'"> + <dc:call-macro name="bedquality-bed"/> + <dc:call-macro name="bedquality-load"/> + </dc:when> + <dc:when test="$out = 'bed_longitudinal_section'"> + <dc:call-macro name="bedquality-bed"/> + <dc:call-macro name="bedquality-load"/> + <dc:call-macro name="bedquality-density"/> + <dc:call-macro name="bedquality-porosity"/> + </dc:when> + <dc:when test="$out = 'sedimentload_ls'"> + <dc:call-macro name="differences"/> + <dc:call-macro name="bedheight-differences"/> + <dc:call-macro name="flow-velocity"/> + <dc:call-macro name="sediment-load"/> + </dc:when> + <dc:when test="$out = 'bed_difference_year'"> + <dc:call-macro name="waterlevels-discharge"/> + <dc:call-macro name="bedheight-differences"/> + <dc:call-macro name="differences"/> + <dc:call-macro name="waterlevels-fix"/> + <dc:call-macro name="delta-wt-ls"/> + </dc:when> + <dc:when test="$out = 'bed_difference_epoch'"> + <dc:call-macro name="waterlevels-discharge"/> + <dc:call-macro name="bedheight-differences"/> + <dc:call-macro name="differences"/> + <dc:call-macro name="waterlevels-fix"/> + <dc:call-macro name="delta-wt-ls"/> + </dc:when> + </dc:choose> + </dc:iterate> + </dc:otherwise> + </dc:choose> + </dc:call-macro> </dc:call-macro> </dc:call-macro> </dc:macro> @@ -389,6 +391,7 @@ <!-- Macros to load user data --> <dc:macro name="select-facets"> + <!-- FIXME : this is broken now! --> <dc:context> <dc:statement> SELECT a.gid AS aid, @@ -476,12 +479,7 @@ </dc:macro> <dc:macro name="waterlevels"> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} AND name = 'cross_section' - </dc:statement> + <dc:filter expr="$out_name = 'cross_section'"> <dc:if test="dc:has-result()"> <waterlevels> <dc:for-each> @@ -507,17 +505,11 @@ </dc:for-each> </waterlevels> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="longitudinal"> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} - AND name = 'longitudinal_section' - </dc:statement> + <dc:filter expr="$out_name = 'longitudinal_section'"> <dc:if test="dc:has-result()"> <waterlevels> <dc:for-each> @@ -545,17 +537,11 @@ </dc:for-each> </waterlevels> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="longitudinal-section"> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} - AND name = 'fix_longitudinal_section_curve' - </dc:statement> + <dc:filter expr="$out_name = 'fix_longitudinal_section_curve'"> <dc:if test="dc:has-result()"> <waterlevels> <dc:for-each> @@ -587,17 +573,11 @@ </dc:for-each> </waterlevels> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="delta-wt"> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} - AND name = 'fix_deltawt_curve' - </dc:statement> + <dc:filter expr="$out_name = 'fix_deltawt_curve'"> <dc:if test="dc:has-result()"> <waterlevels> <dc:for-each> @@ -630,16 +610,11 @@ </dc:for-each> </waterlevels> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="delta-wt-ls"> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} AND name = 'fix_deltawt_curve' - </dc:statement> + <dc:filter expr="$out_name = 'fix_deltawt_curve'"> <dc:if test="dc:has-result()"> <waterlevels> <dc:for-each> @@ -667,16 +642,11 @@ </dc:for-each> </waterlevels> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="fix-derivate-curve"> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} AND name = 'fix_derivate_curve' - </dc:statement> + <dc:filter expr="$out_name = 'fix_derivate_curve'"> <dc:if test="dc:has-result()"> <waterlevels> <dc:for-each> @@ -702,16 +672,11 @@ </dc:for-each> </waterlevels> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="fix-wq-curve"> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} AND name = 'fix_wq_curve' - </dc:statement> + <dc:filter expr="$out_name = 'fix_wq_curve'"> <dc:if test="dc:has-result()"> <waterlevels> <dc:for-each> @@ -741,7 +706,7 @@ </dc:for-each> </waterlevels> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="duration-curve"> @@ -777,53 +742,41 @@ <dc:comment>TODO doesnt work nicely for fix/wq-diags.</dc:comment> <dc:macro name="waterlevels-fix"> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} AND name = 'longitudinal_section' - </dc:statement> - <dc:if test="dc:has-result()"> - <waterlevels> - <dc:for-each> - <dc:context> - <dc:statement> - SELECT name AS facet_name, num AS facet_num, description AS facet_description - FROM facets - WHERE out_id = ${out_id} and name = 'longitudinal_section.w' - ORDER BY num ASC, name DESC - </dc:statement> - <waterlevels description="{$river} {$a_creation} {$collection_name}"> - <dc:for-each> - <dc:element name="${facet_name}"> - <dc:attribute name="description" value="${facet_description}"/> - <dc:attribute name="ids" value="${facet_num}"/> - <dc:attribute name="factory" value="winfo"/> - <dc:attribute name="artifact-id" value="${a_gid}"/> - <dc:attribute name="out" value="longitudinal_section"/> - </dc:element> - </dc:for-each> - </waterlevels> - </dc:context> - </dc:for-each> - </waterlevels> - </dc:if> - </dc:context> + <dc:filter expr="$out_name = 'longitudinal_section'"> + <waterlevels> + <dc:for-each> + <dc:context> + <dc:statement> + SELECT name AS facet_name, num AS facet_num, description AS facet_description + FROM facets + WHERE out_id = ${out_id} and name = 'longitudinal_section.w' + ORDER BY num ASC, name DESC + </dc:statement> + <waterlevels description="{$river} {$a_creation} {$collection_name}"> + <dc:for-each> + <dc:element name="${facet_name}"> + <dc:attribute name="description" value="${facet_description}"/> + <dc:attribute name="ids" value="${facet_num}"/> + <dc:attribute name="factory" value="winfo"/> + <dc:attribute name="artifact-id" value="${a_gid}"/> + <dc:attribute name="out" value="longitudinal_section"/> + </dc:element> + </dc:for-each> + </waterlevels> + </dc:context> + </dc:for-each> + </waterlevels> + </dc:filter> </dc:macro> <dc:macro name="floodmap-hws-user"> - <dc:context> - <dc:statement> - SELECT id AS out_id - FROM outs - WHERE artifact_id = ${a_id} AND name = 'floodmap' - </dc:statement> + <dc:filter expr="$out_name = 'floodmap'"> <dc:for-each> <dc:context> <dc:statement> SELECT name AS facet_name, - num AS facet_num, - description AS facet_description + num AS facet_num, + description AS facet_description FROM facets WHERE out_id = ${out_id} AND name = 'floodmap.usershape' ORDER BY num ASC, name DESC @@ -841,18 +794,11 @@ </own-hws> </dc:context> </dc:for-each> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="bedquality-bed"> - <dc:context> - <dc:statement> - SELECT id AS oid - FROM outs AS o - WHERE - o.artifact_id = ${a_id} AND - o.name='bed_longitudinal_section' - </dc:statement> + <dc:filter expr="$out_name = 'bed_longitudinal_section'"> <dc:if test="dc:has-result()"> <bed_quality_bed> <dc:for-each> @@ -860,17 +806,17 @@ <dc:context> <dc:statement> SELECT a.gid AS aid, - f.id AS fid, - f.name AS facet_name, - f.num AS facet_num, - f.description AS facet_description + f.id AS fid, + f.name AS facet_name, + f.num AS facet_num, + f.description AS facet_description FROM outs AS o, facets AS f, artifacts AS a WHERE - (f.name = 'bed_longitudinal_section.bed_diameter_toplayer' - OR f.name = 'bed_longitudinal_section.bed_diameter_sublayer') AND - f.out_id = o.id AND - o.artifact_id = ${a_id} AND - a.id = ${a_id} + (f.name = 'bed_longitudinal_section.bed_diameter_toplayer' + OR f.name = 'bed_longitudinal_section.bed_diameter_sublayer') AND + f.out_id = o.id AND + o.artifact_id = ${a_id} AND + a.id = ${a_id} </dc:statement> <dc:for-each> <dc:element name="${facet_name}"> @@ -886,18 +832,11 @@ </dc:for-each> </bed_quality_bed> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="bedquality-load"> - <dc:context> - <dc:statement> - SELECT id AS oid - FROM outs AS o - WHERE - o.artifact_id = ${a_id} AND - o.name='bed_longitudinal_section' - </dc:statement> + <dc:filter expr="$out_name = 'bed_longitudinal_section'"> <dc:if test="dc:has-result()"> <bed_quality_load> <dc:for-each> @@ -930,18 +869,11 @@ </dc:for-each> </bed_quality_load> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="bedquality-density"> - <dc:context> - <dc:statement> - SELECT id AS oid - FROM outs AS o - WHERE - o.artifact_id = ${a_id} AND - o.name='bed_longitudinal_section' - </dc:statement> + <dc:filter expr="$out_name = 'bed_longitudinal_section'"> <dc:if test="dc:has-result()"> <bed_quality_density> <dc:for-each> @@ -975,18 +907,11 @@ </dc:for-each> </bed_quality_density> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="bedquality-porosity"> - <dc:context> - <dc:statement> - SELECT id AS oid - FROM outs AS o - WHERE - o.artifact_id = ${a_id} AND - o.name='bed_longitudinal_section' - </dc:statement> + <dc:filter expr="$out_name = 'bed_longitudinal_section'"> <dc:if test="dc:has-result()"> <bed_quality_porosity> <dc:for-each> @@ -1020,17 +945,11 @@ </dc:for-each> </bed_quality_porosity> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="flow-velocity"> - <dc:context> - <dc:statement> - SELECT id AS oid - FROM outs AS o - WHERE - o.artifact_id = ${a_id} and o.name='flow_velocity' - </dc:statement> + <dc:filter expr="$out_name = 'flow_velocity'"> <dc:if test="dc:has-result()"> <flow-velocity> <dc:for-each> @@ -1066,17 +985,11 @@ </dc:for-each> </flow-velocity> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="sediment-load"> - <dc:context> - <dc:statement> - SELECT id AS oid - FROM outs AS o - WHERE - o.artifact_id = ${a_id} and o.name='sedimentload_ls' - </dc:statement> + <dc:filter expr="$out_name = 'sedimentload_ls'"> <dc:if test="dc:has-result()"> <sediment-load> <dc:for-each> @@ -1108,20 +1021,11 @@ </dc:for-each> </sediment-load> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="bedheight-differences"> - <dc:context> - <dc:statement> - SELECT id AS oid, - name AS o_name - FROM outs AS o - WHERE - o.artifact_id = ${a_id} AND - (o.name = 'bed_difference_year' OR - o.name = 'bed_differnece_epoch') - </dc:statement> + <dc:filter expr="$out_name = 'bed_difference_year' or $out_name = 'bed_difference_epoch'"> <dc:if test="dc:has-result()"> <bedheight-differences> <dc:for-each> @@ -1161,18 +1065,11 @@ </dc:for-each> </bedheight-differences> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <dc:macro name="waterlevels-discharge"> - <dc:context> - <dc:statement> - SELECT id AS oid - FROM outs AS o - WHERE - o.artifact_id = ${a_id} AND - o.name = 'discharge_longitudinal_section' - </dc:statement> + <dc:filter expr="$out_name = 'discharge_longitudinal_section'"> <dc:if test="dc:has-result()"> <waterlevels-discharge> <dc:for-each> @@ -1204,7 +1101,7 @@ </dc:for-each> </waterlevels-discharge> </dc:if> - </dc:context> + </dc:filter> </dc:macro> <!-- Macros to load system data --> @@ -2653,7 +2550,7 @@ </dc:context> </dc:macro> - <dc:macro name="km-filtered-userdata"> + <dc:macro name="all-user-artifacts"> <dc:context connection="user"> <dc:comment>Select collections and masterartifacts.</dc:comment> <dc:statement> @@ -2665,10 +2562,13 @@ COALESCE(ma.ld_mode, '') AS ld_m, COALESCE(ma.ld_locations, '') AS ld_l, COALESCE(ma.ld_from, '') AS ld_f, - COALESCE(ma.ld_to, '') AS ld_t + COALESCE(ma.ld_to, '') AS ld_t, + o.name AS out_name, + o.id AS out_id FROM users u JOIN collections c ON c.user_id = u.id JOIN master_artifacts_range ma ON ma.collection_id = c.id + JOIN outs o ON o.artifact_id = ma.id WHERE u.gid = CAST(${user-id} AS UUID) AND ma.gid <> CAST(${artifact-id} AS uuid) AND EXISTS ( @@ -2678,16 +2578,20 @@ AND k = 'river' AND v = ${river}) </dc:statement> - <dc:for-each> - <dc:variable name="from" type="number" expr="dc:fromValue($ld_m, $ld_l, $ld_f)"/> - <dc:variable name="to" type="number" expr="dc:toValue($ld_m, $ld_l, $ld_t)"/> - <dc:if test="not (($tokm < $from) or $fromkm > $tokm)"> - <dc:macro-body/> - </dc:if> - </dc:for-each> + <dc:virtual-column name="deffrom" type="number" expr="dc:fromValue($ld_m, $ld_l, $ld_f)"> + <dc:virtual-column name="defto" type="number" expr="dc:toValue($ld_m, $ld_l, $ld_t)"> + <dc:macro-body/> + </dc:virtual-column> + </dc:virtual-column> </dc:context> </dc:macro> + <dc:macro name="km-filtered-user-artifacts"> + <dc:filter expr="not($deffrom > $tokm or $defto < $fromkm)"> + <dc:macro-body/> + </dc:filter> + </dc:macro> + <dc:macro name="user-range"> <dc:choose> <dc:when test="dc:contains($parameters, 'user-id')">