# 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:

<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:

Element Description
metrics Configuration of all metrics
metric Configuration of a metric
name Name of the Metric type
base Basic unit of the Metric type
unit Definition of the relationship between data with different units
name Unit for the unit
formula Conversion 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.

Element CEType Description
pid CEId KEY of the module table
order_key CEInteger For CEMetricList only. Position of the CEMetric in the list.
unit CEVarchar(50) Unit in which the value is stored.
value CEDouble Value to be saved.
normalized CEDouble Value 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