view flys-artifacts/doc/conf/meta-data.xml @ 1868:9793a67d7998

Have old_data in dc for discharge_longitudinal_sections. flys-artifacts/trunk@3217 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 10 Nov 2011 11:37:51 +0000
parents ba6659083fa0
children 8f7bc6acd48d
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<dc:template xmlns:dc="http://www.intevation.org/2011/Datacage">
<datacage>
  <dc:macro name="load-system">
    <dc:context connection="system">
      <dc:statement>
        SELECT id AS river_id, name as river_name FROM rivers
        WHERE lower(name) LIKE lower(${river})
      </dc:statement>
      <dc:elements>
        <dc:comment>
          Base-data macros (mostly data imported from wst-files)
        </dc:comment>
        <dc:macro name="basedata_0">
            <dc:comment comment=" BASEDATA ---------------------------"/>
            <basedata>
              <dc:context>
                <dc:statement>
                  SELECT id          AS prot_id,
                         description AS prot_description
                  FROM wsts WHERE kind = 0 AND river_id = ${river_id}
                </dc:statement>
                <dc:elements>
                  <basedata>
                    <dc:attribute name="name" value="${prot_description}"/>
                    <dc:context>
                      <dc:statement>
                        SELECT id       AS prot_column_id,
                               name     AS prot_column_name,
                               position AS prot_rel_pos
                        FROM wst_columns WHERE wst_id = ${prot_id}
                        ORDER by position
                      </dc:statement>
                      <dc:elements>
                        <column>
                          <dc:attribute name="name" value="${prot_column_name}"/>
                          <dc:attribute name="ids" value="base_data-wstv-${prot_rel_pos}-${prot_id}"/>
                          <dc:attribute name="factory" value="staticwkms"/>
                        </column>
                      </dc:elements>
                    </dc:context>
                  </basedata>
                </dc:elements>
              </dc:context>
            </basedata>
        </dc:macro>
        <dc:macro name="basedata_1_additionals">
            <dc:comment comment=".ZUS -------------------------------"/>
            <addtionals>
              <dc:context>
                <dc:statement>
                  SELECT id          AS prot_id,
                         description AS prot_description
                  FROM wsts WHERE kind = 1 AND river_id = ${river_id}
                </dc:statement>
                <dc:elements>
                  <additional>
                    <dc:attribute name="name" value="${prot_description}"/>
                    <dc:context>
                      <dc:statement>
                        SELECT id       AS prot_column_id,
                               name     AS prot_column_name,
                               position AS prot_rel_pos
                        FROM wst_columns WHERE wst_id = ${prot_id}
                        ORDER by position
                      </dc:statement>
                      <dc:elements>
                        <column>
                          <dc:attribute name="name" value="${prot_column_name}"/>
                          <dc:attribute name="ids" value="additionals-wstv-${prot_rel_pos}-${prot_id}"/>
                          <dc:attribute name="factory" value="staticwkms"/>
                        </column>
                      </dc:elements>
                    </dc:context>
                  </additional>
                </dc:elements>
              </dc:context>
            </addtionals>
        </dc:macro>
        <dc:macro name="mainvalues">
          <mainvalue>
            <dc:attribute name="factory" value="mainvalue"/>
            <dc:attribute name="ids"     value="${river_id}"/>
          </mainvalue>
        </dc:macro>


        <dc:macro name="annotations">
          <annotation>
            <dc:attribute name="factory" value="annotations"/>
            <dc:attribute name="ids"     value="${river_id}"/>
          </annotation>
        </dc:macro>

        <river>
          <dc:attribute name="name" value="${river_name}"/>
          <dc:if test="dc:contains($artifact-outs, 'w_differences')">
            <annotation>
              <dc:attribute name="factory" value="annotations"/>
              <dc:attribute name="ids"     value="${river_id}"/>
            </annotation>
          </dc:if>

          <dc:choose>
            <dc:when test="dc:contains($parameters, 'recommended')">
               <dc:comment>
                  Recommendations.
               </dc:comment>
               <dc:if test="dc:contains($artifact-outs, 'w_differences') or (dc:contains($artifact-outs, 'discharge_longitudinal_section'))">
                  <dc:call-macro name="annotations"/>
               </dc:if>
            </dc:when>
            <dc:otherwise>
            </dc:otherwise>
          </dc:choose>
          <dc:if test="dc:contains($artifact-outs, 'longitudinal_section') or (dc:contains($artifact-outs, 'w_differences'))">
            <dc:choose>
              <dc:when test="dc:contains($parameters, 'recommended')">
              </dc:when>
              <dc:otherwise>
                <dc:call-macro name="basedata_0"/>
                <dc:call-macro name="basedata_1_additionals"/>
                <dc:comment comment=" FIXATIONS ---------------------------"/>
                <fixations>
                  <dc:context>
                    <dc:statement>
                      SELECT id          AS prot_id,
                             description AS prot_description
                      FROM wsts WHERE kind = 2 AND river_id = ${river_id}
                    </dc:statement>
                    <dc:elements>
                      <fixation>
                        <dc:attribute name="name" value="${prot_description}"/>
                        <dc:context>
                          <dc:statement>
                            SELECT id       AS prot_column_id,
                                   name     AS prot_column_name,
                                   position AS prot_rel_pos
                            FROM wst_columns WHERE wst_id = ${prot_id}
                            ORDER by position
                          </dc:statement>
                          <dc:elements>
                            <column>
                              <dc:attribute name="name" value="${prot_column_name}"/>
                              <dc:attribute name="ids" value="fixations-wstv-${prot_rel_pos}-${prot_id}"/>
                              <dc:attribute name="factory" value="staticwkms"/>
                            </column>
                          </dc:elements>
                        </dc:context>
                      </fixation>
                    </dc:elements>
                  </dc:context>
                </fixations>
                <dc:comment comment=" HOEHENMARKEN ---------------------------"/>
                <heightmarks>
                  <dc:context>
                    <dc:statement>
                      SELECT id          AS prot_id,
                             description AS prot_description
                      FROM wsts WHERE kind = 4 AND river_id = ${river_id}
                    </dc:statement>
                    <dc:elements>
                      <heightmark>
                        <dc:attribute name="name" value="${prot_description}"/>
                        <dc:context>
                          <dc:statement>
                            SELECT id       AS prot_column_id,
                                   name     AS prot_column_name,
                                   position AS prot_rel_pos
                            FROM wst_columns WHERE wst_id = ${prot_id}
                            ORDER by position
                          </dc:statement>
                          <dc:elements>
                            <column>
                              <dc:attribute name="name" value="${prot_column_name}"/>
                              <dc:attribute name="ids" value="heightmarks_points-wstv-${prot_rel_pos}-${prot_id}"/>
                              <dc:attribute name="factory" value="staticwkms"/>
                            </column>
                          </dc:elements>
                        </dc:context>
                      </heightmark>
                    </dc:elements>
                  </dc:context>
                </heightmarks>
               </dc:otherwise>
            </dc:choose>
          </dc:if>

          <dc:if test="dc:contains($artifact-outs, 'waterlevels')">
            <flood-protections>
              <dc:attribute name="id" value="flood-protections-${river_id}"/>
              <dc:context>
                <dc:statement>
                  SELECT id          AS prot_id,
                         description AS prot_description
                  FROM wsts WHERE kind = 5 AND river_id = ${river_id}
                </dc:statement>
                <dc:elements>
                  <flood-protection>
                    <dc:attribute name="name" value="${prot_description}"/>
                    <dc:attribute name="db-id" value="${prot_id}"/>
                    <dc:attribute name="factory" value="staticwkms"/>
                    <columns>
                      <dc:context>
                        <dc:statement>
                          SELECT id       AS prot_column_id,
                                 name     AS prot_column_name,
                                 position AS prot_rel_pos
                          FROM wst_columns WHERE wst_id = ${prot_id}
                          ORDER by position
                        </dc:statement>
                        <dc:elements>
                          <column>
                            <dc:attribute name="name" value="${prot_column_name}"/>
                            <dc:attribute name="ids" value="flood_protection-wstv-${prot_rel_pos}-${prot_id}"/>
                            <dc:attribute name="factory" value="staticwkms"/>
                          </column>
                        </dc:elements>
                      </dc:context>
                    </columns>
                  </flood-protection>
                </dc:elements>
              </dc:context>
            </flood-protections>
            <extra-longitudinal-sections>
              <dc:attribute name="id" value="extra-longitudinal-sections-${river_id}"/>
              <dc:context>
                <dc:statement>
                  SELECT id          AS els_id,
                         description AS els_description
                  FROM wsts WHERE kind = 1 AND river_id = ${river_id}
                </dc:statement>
                <dc:elements>
                  <extra-longitudinal-section>
                    <dc:attribute name="name" value="${els_description}"/>
                    <dc:attribute name="db-id" value="${els_id}"/>
                    <columns>
                      <dc:context>
                        <dc:statement>
                          SELECT id       AS els_column_id,
                                 name     AS els_column_name,
                                 position AS els_rel_pos
                          FROM wst_columns WHERE wst_id = ${els_id}
                          ORDER by position
                        </dc:statement>
                        <dc:elements>
                          <column>
                             <dc:attribute name="name" value="${els_column_name}"/>
                             <dc:attribute name="ids" value="flood_protection-wstv-${els_rel_pos}-${els_id}"/>
                            <dc:attribute name="factory" value="staticwkms"/>
                          </column>
                        </dc:elements>
                      </dc:context>
                    </columns>
                  </extra-longitudinal-section>
                </dc:elements>
              </dc:context>
            </extra-longitudinal-sections>
          </dc:if>
          <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve') and not (dc:contains($parameters, 'recommended'))">
              <discharge-table-nn>
                <discharge-table-gauge>
                  <dc:context>
                    <dc:statement>
                      SELECT id   AS gauge_id,
                             name AS gauge_name
                      FROM gauges WHERE river_id = ${river_id}
                    </dc:statement>
                    <dc:elements>
                      <gauge>
                        <dc:attribute name="name" value="${gauge_name}"/>
                        <dc:attribute name="db-id" value="${gauge_id}"/>
                        <dc:context>
                          <dc:statement>
                            SELECT description   AS gauge_desc, 
                                   d.id          AS discharge_id,
                                   ti.start_time AS g_start, 
                                   ti.stop_time  AS g_stop
                            FROM discharge_tables d JOIN time_intervals ti 
                            ON d.time_interval_id = ti.id
                            WHERE d.gauge_id = ${gauge_id} AND d.kind = 1
                          </dc:statement>
                          <dc:elements>
                            <historical>
                              <dc:attribute name="name" value="${gauge_desc}"/>
                              <dc:attribute name="from" value="${g_start}"/>
                              <dc:attribute name="to" value="${g_stop}"/>
                              <dc:attribute name="db-id" value="${discharge_id}"/></historical>
                          </dc:elements>
                        </dc:context>
                      </gauge>
                    </dc:elements>
                  </dc:context>
                </discharge-table-gauge>
                <fixations>
                  <dc:attribute name="id" value="fixations-${river_id}"/>
                  <dc:context>
                    <dc:statement>
                      SELECT id          AS fix_id,
                             description AS fix_description
                      FROM wsts WHERE kind = 2 AND river_id = ${river_id}
                    </dc:statement>
                    <dc:elements>
                      <fixation>
                        <dc:attribute name="name" value="${fix_description}"/>
                        <dc:attribute name="db-id" value="${fix_id}"/>
                        <columns>
                          <dc:context>
                            <dc:statement>
                              SELECT id   AS fix_column_id,
                                     name AS fix_column_name
                              FROM wst_columns WHERE wst_id = ${fix_id}
                              ORDER by position
                            </dc:statement>
                            <dc:elements>
                              <column>
                                <dc:attribute name="name" value="${fix_column_name}"/>
                                <dc:attribute name="db-id" value="${fix_column_id}"/>
                              </column>
                            </dc:elements>
                          </dc:context>
                        </columns>
                      </fixation>
                    </dc:elements>
                  </dc:context>
                </fixations>
                <flood-protections>
                  <dc:attribute name="id" value="flood-protections-${river_id}"/>
                  <dc:context>
                    <dc:statement>
                      SELECT id          AS prot_id,
                             description AS prot_description
                      FROM wsts WHERE kind = 5 AND river_id = ${river_id}
                    </dc:statement>
                    <dc:elements>
                      <flood-protection>
                        <dc:attribute name="name" value="${prot_description}"/>
                        <dc:attribute name="db-id" value="${prot_id}"/>
                        <columns>
                          <dc:context>
                            <dc:statement>
                              SELECT id   AS prot_column_id,
                                     name AS prot_column_name
                              FROM wst_columns WHERE wst_id = ${prot_id}
                              ORDER by position
                            </dc:statement>
                            <dc:elements>
                              <column>
                                <dc:attribute name="name" value="${prot_column_name}"/>
                                <dc:attribute name="db-id" value="${prot_column_id}"/>
                                <dc:attribute name="factory" value="staticwkms"/>
                              </column>
                            </dc:elements>
                          </dc:context>
                        </columns>
                      </flood-protection>
                    </dc:elements>
                  </dc:context>
                </flood-protections>
                <flood-water-marks>
                  <dc:attribute name="id" value="flood-water-marks-${river_id}"/>
                  <dc:context>
                    <dc:statement>
                      SELECT id          AS fw_id,
                             description AS fw_description
                      FROM wsts WHERE kind = 4 AND river_id = ${river_id}
                    </dc:statement>
                    <dc:elements>
                      <flood-water-mark>
                        <dc:attribute name="name" value="${fw_description}"/>
                        <dc:attribute name="db-id" value="${fw_id}"/>
                        <columns>
                          <dc:context>
                            <dc:statement>
                              SELECT id   AS fw_column_id,
                                     name AS fw_column_name
                              FROM wst_columns WHERE wst_id = ${fw_id}
                              ORDER by position
                            </dc:statement>
                            <dc:elements>
                              <column>
                                <dc:attribute name="name" value="${fw_column_name}"/>
                                <dc:attribute name="db-id" value="${fw_column_id}"/></column>
                            </dc:elements>
                          </dc:context>
                        </columns>
                      </flood-water-mark>
                    </dc:elements>
                  </dc:context>
                </flood-water-marks>
                <water-levels>
                  <dc:attribute name="id" value="water-levels-${river_id}"/>
                  <dc:context>
                    <dc:statement>
                      SELECT id          AS wl_id,
                             description AS wl_description
                      FROM wsts WHERE kind = 0 AND river_id = ${river_id}
                    </dc:statement>
                    <dc:elements>
                      <water-level>
                        <dc:attribute name="name" value="${wl_description}"/>
                        <dc:attribute name="db-id" value="${wl_id}"/>
                        <columns>
                          <dc:context>
                            <dc:statement>
                              SELECT id   AS wl_column_id,
                                     name AS wl_column_name
                              FROM wst_columns WHERE wst_id = ${wl_id}
                              ORDER by position
                            </dc:statement>
                            <dc:elements>
                              <column>
                                <dc:attribute name="name" value="${wl_column_name}"/>
                                <dc:attribute name="db-id" value="${wl_column_id}"/>
                              </column>
                            </dc:elements>
                          </dc:context>
                        </columns>
                      </water-level>
                    </dc:elements>
                  </dc:context>
                </water-levels>
                <extra-longitudinal-sections>
                  <dc:attribute name="id" value="extra-longitudinal-sections-${river_id}"/>
                  <dc:context>
                    <dc:statement>
                      SELECT id          AS els_id,
                             description AS els_description
                      FROM wsts WHERE kind = 1 AND river_id = ${river_id}
                    </dc:statement>
                    <dc:elements>
                      <extra-longitudinal-section>
                        <dc:attribute name="name"  value="${els_description}"/>
                        <dc:attribute name="db-id" value="${els_id}"/>
                        <columns>
                          <dc:context>
                            <dc:statement>
                              SELECT id   AS els_column_id,
                                     name AS els_column_name
                              FROM wst_columns WHERE wst_id = ${els_id}
                              ORDER by position
                            </dc:statement>
                            <dc:elements>
                              <column>
                                <dc:attribute name="name"  value="${els_column_name}"/>
                                <dc:attribute name="db-id" value="${els_column_id}"/>
                              </column>
                            </dc:elements>
                          </dc:context>
                        </columns>
                      </extra-longitudinal-section>
                    </dc:elements>
                  </dc:context>
                </extra-longitudinal-sections>
              </discharge-table-nn>
          </dc:if>
          <dc:if test="dc:contains($artifact-outs, 'computed_discharge_curve')">
              <computed-discharge-curve>
                <dc:call-macro name="mainvalues"/>
              </computed-discharge-curve>
          </dc:if>
          <dc:if test="dc:contains($artifact-outs, 'duration_curve')">
            <dc:call-macro name="mainvalues"/>
          </dc:if>
          <dc:if test="dc:contains($artifact-outs, 'longitudinal_section')">
              <longitudinal-section>
                <dc:call-macro name="annotations"/>
              </longitudinal-section>
          </dc:if>
          <dc:if test="dc:contains($artifact-outs, 'floodmap')">
              <floodmap>
              <dc:choose>
                  <dc:when test="dc:contains($parameters, 'recommended')">
                    <dc:call-macro name="flood-map-recommended"/>
                  </dc:when>
                  <dc:when test="dc:contains($parameters, 'dem')">
                    <dc:call-macro name="flood-map-dem"/>
                  </dc:when>
                  <dc:otherwise>
                    <dc:call-macro name="flood-map-complete"/>
                  </dc:otherwise>
              </dc:choose>
              </floodmap>
              <dc:macro name="flood-map-recommended">
                <dc:comment>
                   FIXME: Following two macros look identical to me.
                </dc:comment>
                  <kilometrage>
                      <riveraxis>
                          <dc:attribute name="factory" value="riveraxis"/>
                          <dc:attribute name="ids" value="${river_id}"/>
                      </riveraxis>
                  </kilometrage>
                  <rastermap>
                      <background>
                          <dc:attribute name="factory" value="wmsbackground"/>
                          <dc:attribute name="ids" value="${river_id}"/>
                      </background>
                  </rastermap>
              </dc:macro>
              <dc:macro name="flood-map-dem">
                <dems>
                  <dc:context>
                    <dc:statement>
                      SELECT id    AS dem_id,
                             lower AS dem_lower,
                             upper AS dem_upper
                      FROM dem WHERE river_id = ${river_id}
                    </dc:statement>
                    <dc:elements>
                        <dem>
                          <dc:attribute name="factory" value="demfactory"/>
                          <dc:attribute name="ids" value="${dem_id}"/>
                          <dc:attribute name="description" value="${dem_lower}-${dem_upper}"/>
                        </dem>
                    </dc:elements>
                  </dc:context>
                </dems>
              </dc:macro>
              <dc:macro name="flood-map-km">
                <dc:context>
                  <dc:statement>
                    SELECT count(*) as km_exists
                    FROM river_axes_km WHERE river_id = ${river_id}
                  </dc:statement>
                   <dc:elements>
                    <dc:if test="$km_exists>0">
                      <km>
                        <dc:attribute name="factory" value="wmskmfactory"/>
                        <dc:attribute name="ids" value="${river_id}"/>
                      </km>
                    </dc:if>
                  </dc:elements>
                </dc:context>
              </dc:macro>
              <dc:macro name="flood-map-qps">
                <dc:context>
                  <dc:statement>
                    SELECT count(*) as km_exists
                    FROM cross_section_tracks WHERE river_id = ${river_id}
                  </dc:statement>
                   <dc:elements>
                    <dc:if test="$km_exists>0">
                      <qps>
                        <dc:attribute name="factory" value="wmsqpsfactory"/>
                        <dc:attribute name="ids" value="${river_id}"/>
                      </qps>
                    </dc:if>
                  </dc:elements>
                </dc:context>
              </dc:macro>
              <dc:macro name="flood-map-hws">
                <dc:context>
                  <dc:statement>
                    SELECT count(*) as km_exists
                    FROM hws WHERE river_id = ${river_id}
                  </dc:statement>
                   <dc:elements>
                    <dc:if test="$km_exists>0">
                      <hws>
                        <dc:attribute name="factory" value="wmshwsfactory"/>
                        <dc:attribute name="ids" value="${river_id}"/>
                      </hws>
                    </dc:if>
                  </dc:elements>
                </dc:context>
              </dc:macro>
              <dc:macro name="flood-map-catchments">
                <dc:context>
                  <dc:statement>
                    SELECT count(*) as km_exists
                    FROM catchment WHERE river_id = ${river_id}
                  </dc:statement>
                   <dc:elements>
                    <dc:if test="$km_exists>0">
                      <catchments>
                        <dc:attribute name="factory" value="wmscatchmentfactory"/>
                        <dc:attribute name="ids" value="${river_id}"/>
                      </catchments>
                    </dc:if>
                  </dc:elements>
                </dc:context>
              </dc:macro>
              <dc:macro name="flood-map-floodplain">
                <dc:context>
                  <dc:statement>
                    SELECT count(*) as km_exists
                    FROM floodplain WHERE river_id = ${river_id}
                  </dc:statement>
                   <dc:elements>
                    <dc:if test="$km_exists>0">
                      <floodplain>
                        <dc:attribute name="factory" value="wmsfloodplainfactory"/>
                        <dc:attribute name="ids" value="${river_id}"/>
                      </floodplain>
                    </dc:if>
                  </dc:elements>
                </dc:context>
              </dc:macro>
              <dc:macro name="flood-map-complete">
                  <kilometrage>
                      <riveraxis>
                          <dc:attribute name="factory" value="riveraxis"/>
                          <dc:attribute name="ids" value="${river_id}"/>
                      </riveraxis>
                    <dc:call-macro name="flood-map-km"/>
                    <dc:call-macro name="flood-map-qps"/>
                    <dc:call-macro name="flood-map-hws"/>
                    <dc:call-macro name="flood-map-catchments"/>
                    <dc:call-macro name="flood-map-floodplain"/>
                  </kilometrage>
                  <rastermap>
                      <background>
                          <dc:attribute name="factory" value="wmsbackground"/>
                          <dc:attribute name="ids" value="${river_id}"/>
                      </background>
                  </rastermap>
              </dc:macro>
          </dc:if>
        </river>
      </dc:elements>
    </dc:context>
  </dc:macro>

  <dc:choose>
    <dc:comment>
      User specific part
      ------------------
    </dc:comment>
    <dc:when test="dc:contains($parameters, 'user-id')">
      <dc:comment>
        Show diffferences if longitudinal sections are there.
        -----------------------------------------------------
      </dc:comment>
      <dc:choose>
      <dc:when test="dc:contains($artifact-outs, 'longitudinal_section')">
        <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
          FROM outs as o, facets as f, artifacts as a
          WHERE f.name = 'w_differences' and f.out_id = o.id and o.artifact_id = a.id;
        </dc:statement>
            <dc:elements>
             <differences>
              <dc:element name="${facet_name}">
                <dc:attribute name="description" value="${facet_description}"/>
                <dc:attribute name="factory"     value="winfo"/>
                <dc:attribute name="artifact-id" value="${aid}"/>
                <dc:attribute name="ids"         value="${aid}"/>
                <dc:attribute name="out"         value="w_differences"/>
              </dc:element>
             </differences>
            </dc:elements>
        </dc:context>
      </dc:when>
      </dc:choose>
      <old_calculations>
        <dc:context connection="user">
          <dc:statement>SELECT u.id AS user_id, c.id AS collection_id, c.name as collection_name
                        FROM collections c JOIN users u ON c.user_id = u.id
                        WHERE u.gid = CAST(${user-id} AS uuid)
                        ORDER BY c.creation DESC
          </dc:statement>
          <dc:elements>
            <dc:comment><!--
            <hello_collection><dc:attribute name="description" value="Collection: id=${collection_id} name='${collection_name}'"/></hello_collection>
            --></dc:comment>
            <dc:context>
              <dc:statement>SELECT m.id AS a_id, m.state AS a_state, m.gid AS a_gid, m.creation AS a_creation
                            FROM   master_artifacts m
                            WHERE  m.collection_id = ${collection_id} AND m.gid &lt;&gt; CAST(${artifact-id} AS uuid)
                            AND EXISTS (
                                SELECT id FROM artifact_data ad WHERE ad.artifact_id = m.id AND k = 'river' AND v = ${river})
              </dc:statement>
              <dc:elements>
              <dc:comment><!--
                <hello_artifact><dc:attribute name="description" value="Artifact UUID: ${a_gid}"/></hello_artifact>
              --></dc:comment>
                <dc:choose>


                  <dc:comment>
                    Import longitudinal sections only if the ${artifact-out} is defined as 'longitudinal_section'
                    ---------------------------------------------------------------------------------------------
                  </dc:comment>
                  <dc:when test="dc:contains($artifact-outs, 'longitudinal_section') or (dc:contains($artifact-outs, 'discharge_longitudinal_section'))">
                    <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>
                          <longitudinal_section_columns>
                              <dc:attribute name="description" value="${river} ${a_creation}"/>
                              <dc:elements>
                                <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:elements>
                          </longitudinal_section_columns>
                        </dc:context>
                      </dc:elements>
                    </dc:context>
                  </dc:when>
                  <dc:comment>
                    Import of longitudinal sections finished
                  </dc:comment>


                  <dc:comment>
                    Import Waterlevels only if the ${artifact-out} is defined as 'waterlevels'
                    --------------------------------------------------------------------------
                  </dc:comment>
                  <dc:when test="dc:contains($artifact-outs, 'waterlevels')">
                    <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} and name = 'longitudinal_section.w'
                            ORDER BY num ASC, name DESC
                          </dc:statement>
                          <waterlevels>
                            <dc:attribute name="description" value="${river} ${a_creation} ${collection_name}"/>
                            <dc:elements>
                              <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:elements>
                          </waterlevels>
                        </dc:context>
                      </dc:elements>
                    </dc:context>
                  </dc:when>
                  <dc:comment>
                    Import of waterlevels finished
                  </dc:comment>

                </dc:choose>
              </dc:elements>
            </dc:context>
          </dc:elements>
        </dc:context>
      </old_calculations>


      <dc:comment>
        Include System specific part when 'load-system' is in parameters.
        -----------------------------------------------------------------
      </dc:comment>
      <dc:choose>
        <dc:when test="dc:contains($parameters,'load-system')">
          <dc:call-macro name="load-system"/>
        </dc:when>
      </dc:choose>
    </dc:when>


    <dc:comment>
      Include System specific part only if no user ID is given.
      ---------------------------------------------------------
    </dc:comment>
    <dc:otherwise>
        <dc:call-macro name="load-system"/>
    </dc:otherwise>
  </dc:choose>
</datacage>
</dc:template>

http://dive4elements.wald.intevation.org