Extensions

section under revision/update

Extensions are configured for a controller instance via metadataExtensions property list. For details have a look at Configuration section section.

License Extension

This simple extension which reads a license file and makes the content available to clients via /<endpoint>/extras?fields=license URL. This may be a full license text or a plain link.

Configuration Location

Place a text file calling config-license.txt under WEB-INF/classes and enable license by placing it under the ParameterController:

<bean class="org.n52.web.ctrl.ParameterController" id="parameterController" abstract="true">
    <property name="metadataExtensions">
        <list>
            <bean class="org.n52.io.response.extension.LicenseExtension" />
        </list>
    </property>
</bean>

Prerendering

A data provider can configure datasets being pre-/rerendered regularly for given time intervals (lastMonth, lastWeek, or lastDay). A client experience may be instant access rather than to wait for that kind of fixed time intervals. Also, prerendered charts are easy to integrate via html tags without making requests to render charts dynamically.

On prerendering mode only single series charts are rendered (no chart overlay).

Job Configuration

A prerendering job can run at a given rate (as Cron Expression, e.g. every Sunday at 04:00 in the morning). Such job can be configured and added to the Job scheduler available by default, for example via Spring:

<bean id="jobScheduler" class="org.n52.io.task.JobScheduler" init-method="init" destroy-method="shutdown">
  <property name="scheduler">
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
      <property name="jobFactory">
        <bean class="org.n52.io.task.AutowiringSpringBeanJobFactory" />
      </property>
    </bean>
  </property>
  <property name="enabled" value="true" />
  <property name="startupDelayInSeconds" value="5" />
  <property name="scheduledJobs">
    <list>
      <ref bean="preRenderingJob" />
    </list>
  </property>
</bean>

<bean id="preRenderingJob" class="org.n52.io.PreRenderingJob">
    <!-- start with '/' for config files lying under WEB-INF/classes folder -->
    <property name="configFile" value="/config-task-prerendering.json" />

    <property name="jobName" value="Prerendering Job" />
    <property name="jobDescription" value="Job prerendering charts." />
    <property name="triggerName" value="preRenderingV1_dailyAt_03:00am" />
    <!-- http://quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/tutorial-lesson-06 -->
    <property name="cronExpression" value="0 0 03 * * ?" />
    <property name="triggerAtStartup" value="true" />
    <property name="enabled" value="true" />

</bean>

Configuration Location

Prerendering (styles, intervals, legend, etc.) can be configured for datasets having a particular phenomenon or each individually (overriding a possibly matching phenomenona config). A general configuration section applies to all further config unless overridden (within a config entry).

For example:

{
  "generalConfig" : {
    "width": "800",
    "height": "500",
    "locale" : "de",
    "grid" : true,
    "generalize" : false
  },
  "phenomenonStyles": [
    {
     "id" : "3",
      "title" : "Station: %1$s, Phenomenon: %2$s [{ %8$s}] (w/ legend)",
      "chartQualifier" : "with_legend",
      "interval": [
        "lastWeek",
        "lastMonth"
      ],
      "config" : {
        "legend" : true
      },
      "style": {
        "chartType": "line",
        "properties": {
          "color": "#00ffff",
          "lineType": "solid",
          "width": 2
        }
      }
    }
  ],
  "datasetStyles": [
    {
      "id" : "16",
      "interval": [
        "lastWeek",
        "lastMonth"
      ],
      "style": {
        "chartType": "bar",
        "properties": {
          "interval": "byDay",
          "width": 0.8,
          "color": "#0000ff"
        }
      }
    }
  ]
}

timeseriesStyles and seriesStyles mean the same as datasetStyles and is kept for backwards compatibility reasons.

Placeholders

To add fine grained title configuration on a phenomenona group a String.format template can be used.

Choose one of the following

  • %1$s: Platform label
  • %2$s: Phenomenon label
  • %3$s: Procedure label
  • %4$s: Category label
  • %5$s: Offering label
  • %6$s: Feature label
  • %7$s: Service label
  • %8$s: Unit of Measure

Use the template for the title config within config file config-task-prerendering, e.g. Platform: %1$s, Phenomenon: %2$s [{ %8$s}].

Accessing prerendered charts

datasets/<id>/images/<img_id>

Rendering Hints

The Series API provides I/O mechanisms to render charts so that clients may directly request data via accept=image/png HTTP header. However, styles are chosen either randomly or by passing the style=... parameter. As the data provider should know best what style fit best to a particular dataset, it can be configured as rendering hints.

The rendering hints are available to a client as extra data for a given dataset.

Configuration Location

Status intervals can be configured for datasets having a particular phenomenon or each individually (overriding a possibly matching phenomenona config). Each entry provides a title, upper and lower limit and some color hint a client may use to render properly.

For example:

{
  "phenomenonStyles": {
    "3": {
      "style": {
        "chartType": "bar",
        "properties": {
          "interval": "byHour",
          "width": 0.8,
          "color": "#0000ff"
        }
      }
    }
  },
  "datasetStyles": {
    "2": {
      "style": {
        "chartType": "line",
        "properties": {
          "lineType": "solid",
          "width": 1,
          "color": "#1E90FF"
        },
        "referenceValueStyleProperties": {
          "278" : {
            "chartType": "line",
            "properties": {
              "lineType": "solid",
              "width": 1,
              "color": "#1E90FF"
            }
          }
        }
      }
    }
  }
}

timeseriesStyles and seriesStyles mean the same as datasetStyles and is kept for backwards compatibility reasons.

Status Intervals

The data provider knows best how to interpret available data and can add domain specific information which may help to interpret data values of a particular dataset.Clients are then able to render data values (e.g. when rendering lastValues on a map) by comparing against those intervals. This gives a user hints what data values actually mean and helps to avoid misunderstandings.

The status intervals are available to a client as extra data for a given dataset.

Configuration Location

Status intervals can be configured for datasets having a particular phenomenon or each individually (overriding a possibly matching phenomenona config). Each entry provides a title, upper and lower limit and some color hint a client may use to render properly.

For example:

{
  "phenomenonIntervals": {
    "1": {
      "statusIntervals": {
        "90-100 Percent": {
          "upper" : 100.0,
          "lower" : 90.0,
          "color" : "#0000FF"
        },
        "80-90 Percent": {
          "upper" : 90.0,
          "lower" : 80.0,
          "color" : "#1C00E2"
        },
        "70-80 Percent": {
          "upper" : 80.0,
          "lower" : 70.0,
          "color" : "#3800C6"
        },
        "60-70 Percent": {
          "upper" : 70.0,
          "lower" : 60.0,
          "color" : "#5500AA"
        },
        "50-60 Percent": {
          "upper" : 60.0,
          "lower" : 50.0,
          "color" : "#71008D"
        },
        "40-50 Percent": {
          "upper" : 50.0,
          "lower" : 40.0,
          "color" : "#8D0071"
        },
        "30-40 Percent": {
          "upper" : 40.0,
          "lower" : 30.0,
          "color" : "#AA0055"
        },
        "20-30 Percent": {
          "upper" : 30.0,
          "lower" : 20.0,
          "color" : "#C60038"
        },
        "10-20 Percent": {
          "upper" : 20.0,
          "lower" : 10.0,
          "color" : "#E2001C"
        },
        "0-10 Percent": {
          "upper" : 10.0,
          "lower" : 0.0,
          "color" : "#FF0000"
        }
      }
    }
  },
  "datasetIntervals": {
    "10": {
      "statusIntervals": {
        ">20": {
          "lower" : 20.0,
          "color" : "#FF0000"
        },
        "15-20": {
          "upper" : 20.0,
          "lower" : 15.0,
          "color" : "#BF003F"
        },
        "10-15": {
          "upper" : 15.0,
          "lower" : 10.0,
          "color" : "#7F007F"
        },
        "5-10": {
          "upper" : 10.0,
          "lower" : 5.0,
          "color" : "#3F00BF"
        },
        "0-5": {
          "upper" : 5.0,
          "lower" : 0.0,
          "color" : "#0000FF"
        }
      }
    }
  }
}

timeseriesStyles and seriesStyles mean the same as datasetStyles and is kept for backwards compatibility reasons.