Skip to content

Metrics ​

Data often consists of more than just one value. Only with the corresponding unit can the data be interpreted meaningfully. For this purpose, the data types CEMetric and CEMetricList are implemented in the CoreEngine.

These data types make it possible, for example, to store with the unit gram and search for kilograms. This is made possible by storing the value and unit in the database. In addition, the backend also stores the value of the base unit so that it is available for functions such as "search".

Configuration of Metric types ​

Metrics are stored in the file ce_global/defaults/metrics.xml.

Sample file:

xml
<metrics>
  <metric name="length" base="meter"><!-- generiert L-ME-METRICNAME -->
    <unit>
      <name>meter</name>
      <formula>value*1</formula>
    </unit>
    <unit>
      <name>millimeter</name>
      <formula>value*1000</formula>
    </unit>
    <unit>
      <name>centimeter</name>
      <formula>value*100</formula>
    </unit>
    <unit>
      <name>decimeter</name>
      <formula>value*10</formula>
    </unit>
    <unit>
      <name>kilometer</name><!-- generiert L-ME-METRICNAME-UNITNAME -->
      <!-- generiert L-ME-METRICNAME-UNITNAME-SHORT -->
      <formula>value*0.001</formula> <!-- Umrechnungsfaktor in die Basis -->
    </unit>
  </metric>
  <metric name="weight" base="kilo">
    <unit>
      <name>kilo</name>
      <formula>value*1</formula>
    </unit>
    <unit>
      <name>tonne</name>
      <formula>value*0.001</formula>
    </unit>
  </metric>
</metrics>

Description of the XML:

ElementDescription
metricsConfiguration of all metrics
metricConfiguration of a metric
nameName of the Metric type
baseBasic unit of the Metric type
unitDefinition of the relationship between data with different units
nameUnit for the unit
formulaConversion function to base unit. Initially "+-*/" and brackets must be supported.

Tables with available field types

Storage in the database ​

Fields of these types are stored in the database in a sub-table outsourced.

ElementCETypeDescription
pidCEIdKEY of the module table
order_keyCEIntegerFor CEMetricList only. Position of the CEMetric in the list.
unitCEVarchar(50)Unit in which the value is stored.
valueCEDoubleValue to be saved.
normalizedCEDoubleValue from field value normalized to the base unit.

Fields in the database

Activate metric for a field ​

Configuration see '4apfield-details

Search via the fields with metrics ​

The search filter was extended by a unit property. During the search, the value from the search filter is normalized to base unit and the search is executed.

Note!: If unit is not set, the default unit is taken from field configuration.

Request missing documentation