sascha@947: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
sascha@947: <dc:template xmlns:dc="http://www.intevation.org/2011/Datacage">
sascha@947: <datacage>
sascha@947:   <dc:context>
sascha@947:     <dc:statement>
sascha@947:       SELECT id AS river_id, name as river_name FROM rivers
sascha@947:       WHERE name ILIKE ${river}
sascha@947:     </dc:statement>
sascha@947:     <dc:elements>
sascha@947:       <river>
sascha@947:         <dc:attribute name="name" value="${river_name}"/>
sascha@947:         <dc:attribute name="db-id" value="${river_id}"/>
ingo@964:         <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve')">
ingo@964:             <discharge-table-nn>
ingo@964:               <discharge-table-gauge>
ingo@964:                 <dc:context>
ingo@964:                   <dc:statement>
ingo@964:                     SELECT id   AS gauge_id,
ingo@964:                            name AS gauge_name
ingo@964:                     FROM gauges WHERE river_id = ${river_id}
ingo@964:                   </dc:statement>
ingo@964:                   <dc:elements>
ingo@964:                     <gauge>
ingo@964:                       <dc:attribute name="name" value="${gauge_name}"/>
ingo@964:                       <dc:attribute name="db-id" value="${gauge_id}"/>
ingo@964:                       <dc:context>
ingo@964:                         <dc:statement>
ingo@964:                           SELECT description   AS gauge_desc, 
ingo@964:                                  d.id          AS discharge_id,
ingo@964:                                  ti.start_time AS g_start, 
ingo@964:                                  ti.stop_time  AS g_stop
ingo@964:                           FROM discharge_tables d JOIN time_intervals ti 
ingo@964:                           ON d.time_interval_id = ti.id
ingo@964:                           WHERE d.gauge_id = ${gauge_id} AND d.kind = 1
ingo@964:                         </dc:statement>
ingo@964:                         <dc:elements>
ingo@964:                           <historical>
ingo@964:                             <dc:attribute name="name" value="${gauge_desc}"/>
ingo@964:                             <dc:attribute name="from" value="${g_start}"/>
ingo@964:                             <dc:attribute name="to" value="${g_stop}"/>
ingo@964:                             <dc:attribute name="db-id" value="${discharge_id}"/></historical>
ingo@964:                         </dc:elements>
ingo@964:                       </dc:context>
ingo@964:                     </gauge>
ingo@964:                   </dc:elements>
ingo@964:                 </dc:context>
ingo@964:               </discharge-table-gauge>
ingo@964:               <fixations>
ingo@964:                 <dc:attribute name="id" value="fixations-${river_id}"/>
ingo@964:                 <dc:context>
ingo@964:                   <dc:statement>
ingo@964:                     SELECT id          AS fix_id,
ingo@964:                            description AS fix_description
ingo@964:                     FROM wsts WHERE kind = 2 AND river_id = ${river_id}
ingo@964:                   </dc:statement>
ingo@964:                   <dc:elements>
ingo@964:                     <fixation>
ingo@964:                       <dc:attribute name="name" value="${fix_description}"/>
ingo@964:                       <dc:attribute name="db-id" value="${fix_id}"/>
ingo@964:                       <columns>
ingo@964:                         <dc:context>
ingo@964:                           <dc:statement>
ingo@964:                             SELECT id   AS fix_column_id,
ingo@964:                                    name AS fix_column_name
ingo@964:                             FROM wst_columns WHERE wst_id = ${fix_id}
ingo@964:                             ORDER by position
ingo@964:                           </dc:statement>
ingo@964:                           <dc:elements>
ingo@964:                             <column>
ingo@964:                               <dc:attribute name="name" value="${fix_column_name}"/>
ingo@964:                               <dc:attribute name="db-id" value="${fix_column_id}"/></column>
ingo@964:                           </dc:elements>
ingo@964:                         </dc:context>
ingo@964:                       </columns>
ingo@964:                     </fixation>
ingo@964:                   </dc:elements>
ingo@964:                 </dc:context>
ingo@964:               </fixations>
ingo@964:               <flood-protections>
ingo@964:                 <dc:attribute name="id" value="flood-protections-${river_id}"/>
ingo@964:                 <dc:context>
ingo@964:                   <dc:statement>
ingo@964:                     SELECT id          AS prot_id,
ingo@964:                            description AS prot_description
ingo@964:                     FROM wsts WHERE kind = 5 AND river_id = ${river_id}
ingo@964:                   </dc:statement>
ingo@964:                   <dc:elements>
ingo@964:                     <flood-protection>
ingo@964:                       <dc:attribute name="name" value="${prot_description}"/>
ingo@964:                       <dc:attribute name="db-id" value="${prot_id}"/>
ingo@964:                       <columns>
ingo@964:                         <dc:context>
ingo@964:                           <dc:statement>
ingo@964:                             SELECT id   AS prot_column_id,
ingo@964:                                    name AS prot_column_name
ingo@964:                             FROM wst_columns WHERE wst_id = ${prot_id}
ingo@964:                             ORDER by position
ingo@964:                           </dc:statement>
ingo@964:                           <dc:elements>
ingo@964:                             <column>
ingo@964:                               <dc:attribute name="name" value="${prot_column_name}"/>
ingo@964:                               <dc:attribute name="db-id" value="${prot_column_id}"/></column>
ingo@964:                           </dc:elements>
ingo@964:                         </dc:context>
ingo@964:                       </columns>
ingo@964:                     </flood-protection>
ingo@964:                   </dc:elements>
ingo@964:                 </dc:context>
ingo@964:               </flood-protections>
ingo@964:               <flood-water-marks>
ingo@964:                 <dc:attribute name="id" value="flood-water-marks-${river_id}"/>
ingo@964:                 <dc:context>
ingo@964:                   <dc:statement>
ingo@964:                     SELECT id          AS fw_id,
ingo@964:                            description AS fw_description
ingo@964:                     FROM wsts WHERE kind = 4 AND river_id = ${river_id}
ingo@964:                   </dc:statement>
ingo@964:                   <dc:elements>
ingo@964:                     <flood-water-mark>
ingo@964:                       <dc:attribute name="name" value="${fw_description}"/>
ingo@964:                       <dc:attribute name="db-id" value="${fw_id}"/>
ingo@964:                       <columns>
ingo@964:                         <dc:context>
ingo@964:                           <dc:statement>
ingo@964:                             SELECT id   AS fw_column_id,
ingo@964:                                    name AS fw_column_name
ingo@964:                             FROM wst_columns WHERE wst_id = ${fw_id}
ingo@964:                             ORDER by position
ingo@964:                           </dc:statement>
ingo@964:                           <dc:elements>
ingo@964:                             <column>
ingo@964:                               <dc:attribute name="name" value="${fw_column_name}"/>
ingo@964:                               <dc:attribute name="db-id" value="${fw_column_id}"/></column>
ingo@964:                           </dc:elements>
ingo@964:                         </dc:context>
ingo@964:                       </columns>
ingo@964:                     </flood-water-mark>
ingo@964:                   </dc:elements>
ingo@964:                 </dc:context>
ingo@964:               </flood-water-marks>
ingo@964:               <water-levels>
ingo@964:                 <dc:attribute name="id" value="water-levels-${river_id}"/>
ingo@964:                 <dc:context>
ingo@964:                   <dc:statement>
ingo@964:                     SELECT id          AS wl_id,
ingo@964:                            description AS wl_description
ingo@964:                     FROM wsts WHERE kind = 0 AND river_id = ${river_id}
ingo@964:                   </dc:statement>
ingo@964:                   <dc:elements>
ingo@964:                     <water-level>
ingo@964:                       <dc:attribute name="name" value="${wl_description}"/>
ingo@964:                       <dc:attribute name="db-id" value="${wl_id}"/>
ingo@964:                       <columns>
ingo@964:                         <dc:context>
ingo@964:                           <dc:statement>
ingo@964:                             SELECT id   AS wl_column_id,
ingo@964:                                    name AS wl_column_name
ingo@964:                             FROM wst_columns WHERE wst_id = ${wl_id}
ingo@964:                             ORDER by position
ingo@964:                           </dc:statement>
ingo@964:                           <dc:elements>
ingo@964:                             <column>
ingo@964:                               <dc:attribute name="name" value="${wl_column_name}"/>
ingo@964:                               <dc:attribute name="db-id" value="${wl_column_id}"/></column>
ingo@964:                           </dc:elements>
ingo@964:                         </dc:context>
ingo@964:                       </columns>
ingo@964:                     </water-level>
ingo@964:                   </dc:elements>
ingo@964:                 </dc:context>
ingo@964:               </water-levels>
ingo@964:               <extra-longitudinal-sections>
ingo@964:                 <dc:attribute name="id" value="extra-longitudinal-sections-${river_id}"/>
ingo@964:                 <dc:context>
ingo@964:                   <dc:statement>
ingo@964:                     SELECT id          AS els_id,
ingo@964:                            description AS els_description
ingo@964:                     FROM wsts WHERE kind = 1 AND river_id = ${river_id}
ingo@964:                   </dc:statement>
ingo@964:                   <dc:elements>
ingo@964:                     <extra-longitudinal-section>
ingo@964:                       <dc:attribute name="name" value="${els_description}"/>
ingo@964:                       <dc:attribute name="db-id" value="${els_id}"/>
ingo@964:                       <columns>
ingo@964:                         <dc:context>
ingo@964:                           <dc:statement>
ingo@964:                             SELECT id   AS els_column_id,
ingo@964:                                    name AS els_column_name
ingo@964:                             FROM wst_columns WHERE wst_id = ${els_id}
ingo@964:                             ORDER by position
ingo@964:                           </dc:statement>
ingo@964:                           <dc:elements>
ingo@964:                             <column>
ingo@964:                                 <dc:attribute name="name" value="${els_column_name}"/>
ingo@964:                                 <dc:attribute name="db-id" value="${els_column_id}"/></column>
ingo@964:                           </dc:elements>
ingo@964:                         </dc:context>
ingo@964:                       </columns>
ingo@964:                     </extra-longitudinal-section>
ingo@964:                   </dc:elements>
ingo@964:                 </dc:context>
ingo@964:               </extra-longitudinal-sections>
ingo@964:             </discharge-table-nn>
ingo@964:         </dc:if>
ingo@964:         <dc:if test="dc:contains($artifact-outs, 'longitudinal_section')">
ingo@964:             <longitudinal-section>
ingo@964:               <fixations><dc:attribute name="ref" value="fixations-${river_id}"/></fixations>
ingo@964:               <flood-protections><dc:attribute name="ref" value="flood-protections-${river_id}"/></flood-protections>
ingo@964:               <flood-water-marks><dc:attribute name="ref" value="flood-water-marks-${river_id}"/></flood-water-marks>
ingo@964:               <water-levels><dc:attribute name="ref" value="water-levels-${river_id}"/></water-levels>
ingo@964:               <extra-longitudinal-sections><dc:attribute name="ref" value="extra-longitudinal-sections-${river_id}"/></extra-longitudinal-sections>
ingo@964:             </longitudinal-section>
ingo@964:         </dc:if>
ingo@964:         <dc:if test="dc:contains($artifact-outs, 'floodmap')">
ingo@964:             <floodmap>
ingo@964:             <dc:choose>
sascha@976:                 <dc:when test="dc:contains($parameters, 'recommended')">
ingo@964:                   <dc:call-macro name="flood-map-recommended"/>
ingo@964:                 </dc:when>
ingo@964:                 <dc:otherwise>
ingo@964:                   <dc:call-macro name="flood-map-complete"/>
ingo@964:                 </dc:otherwise>
ingo@964:             </dc:choose>
ingo@964:             </floodmap>
ingo@964:             <dc:macro name="flood-map-recommended">
ingo@964:                 <kilometrage>
ingo@964:                     <riveraxis>
ingo@964:                         <dc:attribute name="factory" value="riveraxis"/>
ingo@967:                         <dc:attribute name="db-ids" value="${river_id}"/>
ingo@964:                     </riveraxis>
ingo@964:                 </kilometrage>
ingo@964:                 <rastermap>
ingo@964:                     <background>
ingo@964:                         <dc:attribute name="factory" value="wmsbackground"/>
ingo@968:                         <dc:attribute name="db-ids" value="${river_id}"/>
ingo@964:                     </background>
ingo@964:                 </rastermap>
ingo@964:             </dc:macro>
ingo@964:             <dc:macro name="flood-map-complete">
ingo@964:                 <kilometrage>
ingo@964:                     <riveraxis>
ingo@964:                         <dc:attribute name="factory" value="riveraxis"/>
ingo@967:                         <dc:attribute name="db-ids" value="${river_id}"/>
ingo@964:                     </riveraxis>
ingo@964:                 </kilometrage>
ingo@964:                 <rastermap>
ingo@964:                     <background>
ingo@964:                         <dc:attribute name="factory" value="wmsbackground"/>
ingo@968:                         <dc:attribute name="db-ids" value="${river_id}"/>
ingo@964:                     </background>
ingo@964:                 </rastermap>
ingo@964:             </dc:macro>
ingo@964:         </dc:if>
sascha@947:       </river>
sascha@947:     </dc:elements>
sascha@947:   </dc:context>
sascha@947: </datacage>
sascha@947: </dc:template>
sascha@947: