fixed definitions and added translations
This commit is contained in:
parent
d63f919322
commit
ed9f71e519
7 changed files with 184 additions and 150 deletions
4
README
4
README
|
@ -4,11 +4,11 @@ volkszaehler.org/
|
|||
|_ frontend/ Web Frontend
|
||||
|_ backend/ PHP Backend
|
||||
|_ controller/ Controller Code für verschiedene Plattformen/Programmiersprachen
|
||||
| \_ php/ Einfach Referenzimplementation des Controller-Codes in PHP
|
||||
| |_ php/ Einfach Referenzimplementation des Controller-Codes in PHP
|
||||
| \_ ethersex Portierung auf ethersex
|
||||
|
|
||||
\_ share/ Gemeinsam genutze Codebestandteile
|
||||
|_ docs/ Dokumentation
|
||||
|_ definitions/ Gemeinsame Definitionen über Entities und deren Eigenschaften für Controller, Backend & Frontend
|
||||
|_ sql/ SQL-Schema Dumps für verschieden Datenbanksysteme
|
||||
| \_ demo/ Demo Daten zum Import in die Datenbank
|
||||
|
|
||||
|
|
|
@ -30,14 +30,15 @@ use Volkszaehler\Util;
|
|||
* @package default
|
||||
*/
|
||||
abstract class Definition {
|
||||
/** @var string discriminator for database column */
|
||||
/**
|
||||
* @var string discriminator for database column
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/** @var string title for UI */
|
||||
//protected $title;
|
||||
|
||||
/** @var string description for UI */
|
||||
//protected $description;
|
||||
/**
|
||||
* @var string title for UI
|
||||
*/
|
||||
protected $translation;
|
||||
|
||||
/**
|
||||
* Hide default constructor
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Definition of entities
|
||||
|
||||
* Format is specified in EntityDefinition class
|
||||
* Format is specified in EntityDefinition model
|
||||
*
|
||||
* @author Steffen Vogel <info@steffenvogel.de>
|
||||
* @copyright Copyright (c) 2010, The volkszaehler.org project
|
||||
|
@ -27,98 +27,111 @@
|
|||
|
||||
[
|
||||
{
|
||||
"name" : "group",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "tolerance"],
|
||||
"interpreter" : "AggregatorInterpreter",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Gruppe"
|
||||
"name" : "group",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\AggregatorInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Aggregator",
|
||||
"translation" : { "de" : "Gruppe" }
|
||||
},
|
||||
{
|
||||
"name" : "user",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "tolerance"],
|
||||
"interpreter" : "AggregatorInterpreter",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Nutzer"
|
||||
"name" : "user",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\AggregatorInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Aggregator",
|
||||
"translation" : { "de" : "Nutzer" }
|
||||
},
|
||||
{
|
||||
"name" : "power",
|
||||
"required" : ["title", "resolution"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"interpreter" : "MeterInterpreter",
|
||||
"unit" : "kW/h",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Strom"
|
||||
"name" : "power",
|
||||
"required" : ["title", "resolution"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"unit" : "kW/h",
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\MeterInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Channel",
|
||||
"translation" : { "de" : "Strom" }
|
||||
},
|
||||
{
|
||||
"name" : "gas",
|
||||
"required" : ["title", "resolution"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"interpreter" : "MeterInterpreter",
|
||||
"unit" : "m³/h",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Gas"
|
||||
"name" : "gas",
|
||||
"required" : ["title", "resolution"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"unit" : "m³/h",
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\MeterInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Channel",
|
||||
"translation" : { "de" : "Gas" }
|
||||
},
|
||||
{
|
||||
"name" : "water",
|
||||
"required" : ["title", "resolution"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"interpreter" : "MeterInterpreter",
|
||||
"unit" : "m³/h",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Wasser"
|
||||
"name" : "water",
|
||||
"required" : ["title", "resolution"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"unit" : "m³/h",
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\MeterInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Channel",
|
||||
"translation" : { "de" : "Wasser" }
|
||||
},
|
||||
{
|
||||
"name" : "temperature",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"interpreter" : "SensorInterpreter",
|
||||
"unit" : "°C",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Temperatur"
|
||||
"name" : "temperature",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"unit" : "°C",
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\SensorInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Channel",
|
||||
"translation" : { "de" : "Temperatur" }
|
||||
},
|
||||
{
|
||||
"name" : "pressure",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"interpreter" : "SensorInterpreter",
|
||||
"unit" : "hPa",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Luftdruck"
|
||||
"name" : "pressure",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"unit" : "hPa",
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\SensorInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Channel",
|
||||
"translation" : { "de" : "Luftdruck" }
|
||||
},
|
||||
{
|
||||
"name" : "humidity",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"interpreter" : "SensorInterpreter",
|
||||
"unit" : "%",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Luftfeuchtigkeit"
|
||||
"name" : "humidity",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"unit" : "%",
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\SensorInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Channel",
|
||||
"translation" : { "de" : "Luftfeuchtigkeit" }
|
||||
},
|
||||
{
|
||||
"name" : "windspeed",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"interpreter" : "SensorInterpreter",
|
||||
"unit" : "km/h",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Windgeschwindigkeit"
|
||||
"name" : "windspeed",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"unit" : "km/h",
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\SensorInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Channel",
|
||||
"translation" : { "de" : "Windgeschwindigkeit" }
|
||||
},
|
||||
{
|
||||
"name" : "radition",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"interpreter" : "SensorInterpreter",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Strahlung"
|
||||
"name" : "radition",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"unit" : "", // TODO add unit
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\SensorInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Channel",
|
||||
"translation" : { "de" : "Strahlung" }
|
||||
},
|
||||
{
|
||||
"name" : "luminosity",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"interpreter" : "SensorInterpreter",
|
||||
"icon" : "", // TODO look for an icon
|
||||
"de_name" : "Lichtstärke"
|
||||
"name" : "luminosity",
|
||||
"required" : ["title"],
|
||||
"optional" : ["description", "details:", "owner:", "address:", "tolerance"],
|
||||
"icon" : "", // TODO look for an icon
|
||||
"unit" : "", // TODO add unit
|
||||
"interpreter" : "Volkszaehler\\Interpreter\\SensorInterpreter",
|
||||
"model" : "Volkszaehler\\Model\\Channel",
|
||||
"translation" : { "de" : "Lichtstärke" }
|
||||
}
|
||||
]
|
||||
|
|
|
@ -58,6 +58,13 @@ class EntityDefinition extends Definition {
|
|||
*/
|
||||
protected $interpreter;
|
||||
|
||||
/**
|
||||
* Classname of model (see backend/lib/Model/)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Optional for Aggregator class entities
|
||||
*
|
||||
|
@ -71,7 +78,10 @@ class EntityDefinition extends Definition {
|
|||
*/
|
||||
protected $icon;
|
||||
|
||||
static protected $definitions = NULL;
|
||||
/**
|
||||
* @var array holds definitions
|
||||
*/
|
||||
protected static $definitions = NULL;
|
||||
|
||||
/*
|
||||
* Setter & Getter
|
||||
|
|
|
@ -27,72 +27,72 @@
|
|||
|
||||
[
|
||||
{
|
||||
"name" : "title",
|
||||
"type" : "string",
|
||||
"pattern" : "/[a-z0-9 ]/",
|
||||
"min": 3,
|
||||
"max" : 255,
|
||||
"de_name" : "Titel"
|
||||
"name" : "title",
|
||||
"type" : "string",
|
||||
"pattern" : "/[a-z0-9 ]/",
|
||||
"min" : 3,
|
||||
"max" : 255,
|
||||
"translation" : { "de" : "Titel" }
|
||||
},
|
||||
{
|
||||
"name" : "description",
|
||||
"type" : "text",
|
||||
"pattern" : "/[a-z0-9 ]/", // TODO add whitespaces as \t \n \r
|
||||
"max" : 255, // TODO allowed column size in database?
|
||||
"de_name" : "Beschreibung"
|
||||
"name" : "description",
|
||||
"type" : "text",
|
||||
"pattern" : "/[a-z0-9 ]/", // TODO add whitespaces as \t \n \r
|
||||
"max" : 255, // TODO allowed column size in database?
|
||||
"translation" : { "de" : "Beschreibung" }
|
||||
},
|
||||
{
|
||||
"name" : "cost",
|
||||
"type" : "float",
|
||||
"min" : 0,
|
||||
"de_name" : "Kosten"
|
||||
"name" : "cost",
|
||||
"type" : "float",
|
||||
"min" : 0,
|
||||
"translation" : { "de" : "Kosten" }
|
||||
},
|
||||
{
|
||||
"name" : "resolution",
|
||||
"type" : "integer",
|
||||
"min" : 1,
|
||||
"de_name" : "Auflösung"
|
||||
"name" : "resolution",
|
||||
"type" : "integer",
|
||||
"min" : 1,
|
||||
"translation" : { "de" : "Auflösung" }
|
||||
},
|
||||
{
|
||||
"name" : "tolerance",
|
||||
"type" : "float",
|
||||
"min" : 0,
|
||||
"max" : 1,
|
||||
"de_name" : "Toleranz"
|
||||
"name" : "tolerance",
|
||||
"type" : "float",
|
||||
"min" : 0,
|
||||
"max" : 1,
|
||||
"translation" : { "de" : "Toleranz" }
|
||||
},
|
||||
{
|
||||
"name" : "address:lat",
|
||||
"type" : "float",
|
||||
"min" : -90,
|
||||
"max" : 90,
|
||||
"de_name" : "Latitude"
|
||||
"name" : "address:lat",
|
||||
"type" : "float",
|
||||
"min" : -90,
|
||||
"max" : 90,
|
||||
"translation" : { "de" : "Latitude" }
|
||||
},
|
||||
{
|
||||
"name" : "address:lon",
|
||||
"type" : "float",
|
||||
"min" : -90,
|
||||
"max" : 90,
|
||||
"de_name" : "Longitude"
|
||||
"name" : "address:lon",
|
||||
"type" : "float",
|
||||
"min" : -90,
|
||||
"max" : 90,
|
||||
"translation" : { "de" : "Longitude" }
|
||||
},
|
||||
{
|
||||
"name" : "address:city",
|
||||
"type" : "string",
|
||||
"pattern" : "", // TODO add pattern
|
||||
"de_name" : "Stadt"
|
||||
"name" : "address:city",
|
||||
"type" : "string",
|
||||
"pattern" : "", // TODO add pattern
|
||||
"translation" : { "de" : "Stadt" }
|
||||
},
|
||||
{
|
||||
"name" : "address:houseno",
|
||||
"type" : "string",
|
||||
"de_name" : "Hausnummer"
|
||||
"name" : "address:houseno",
|
||||
"type" : "string",
|
||||
"translation" : { "de" : "Hausnummer" }
|
||||
},
|
||||
{
|
||||
"name" : "address:postal",
|
||||
"type" : "string",
|
||||
"de_name" : "Postleitzahl"
|
||||
"name" : "address:postal",
|
||||
"type" : "string",
|
||||
"translation" : { "de" : "Postleitzahl" }
|
||||
},
|
||||
{
|
||||
"name" : "address:state",
|
||||
"type" : "multiple",
|
||||
"name" : "address:state",
|
||||
"type" : "multiple",
|
||||
"options" : [
|
||||
"Albania",
|
||||
"Algeria",
|
||||
|
@ -284,34 +284,34 @@
|
|||
"Yemen",
|
||||
"Zambia"
|
||||
],
|
||||
"de_name" : "Land"
|
||||
"translation" : { "de" : "Land" }
|
||||
},
|
||||
{
|
||||
"name" : "address:country",
|
||||
"type" : "string",
|
||||
"de_name" : "Staat"
|
||||
"name" : "address:country",
|
||||
"type" : "string",
|
||||
"translation" : { "de" : "Staat" }
|
||||
},
|
||||
{
|
||||
"name" : "photo:url",
|
||||
"type" : "string",
|
||||
"pattern" : "", // TODO add pattern
|
||||
"de_name" : "Foto (URL)"
|
||||
"name" : "photo:url",
|
||||
"type" : "string",
|
||||
"pattern" : "", // TODO add pattern
|
||||
"translation" : { "de" : "Foto (URL)" }
|
||||
},
|
||||
{
|
||||
"name" : "cuuid",
|
||||
"type" : "string",
|
||||
"max" : 37,
|
||||
"de_name" : "Cotroller UUID"
|
||||
"name" : "cuuid",
|
||||
"type" : "string",
|
||||
"max" : 37,
|
||||
"translation" : { "de" : "Cotroller UUID" }
|
||||
},
|
||||
{
|
||||
"name" : "port",
|
||||
"type" : "string",
|
||||
"max" : 6,
|
||||
"de_name" : "Controller Pin"
|
||||
"name" : "port",
|
||||
"type" : "string",
|
||||
"max" : 6,
|
||||
"translation" : { "de" : "Controller Pin" }
|
||||
},
|
||||
{
|
||||
"name" : "active",
|
||||
"type" : "boolean",
|
||||
"de_name" : "Aktiv?"
|
||||
"name" : "active",
|
||||
"type" : "boolean",
|
||||
"translation" : { "de" : "Aktiv?" }
|
||||
}
|
||||
]
|
||||
|
|
|
@ -73,6 +73,9 @@ class PropertyDefinition extends Definition {
|
|||
*/
|
||||
protected $options = array();
|
||||
|
||||
/**
|
||||
* @var array holds definitions
|
||||
*/
|
||||
protected static $definitions = NULL;
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,8 +81,15 @@ class Property {
|
|||
* @PostLoad
|
||||
*/
|
||||
public function cast() {
|
||||
if ($this->getDefinition()->getType() != 'multiple') {
|
||||
settype($this->value, $this->getDefinition()->getType());
|
||||
$type = $this->getDefinition()->getType();
|
||||
if ($type == 'multiple') {
|
||||
// TODO
|
||||
}
|
||||
elseif ($type == 'text') {
|
||||
settype($this->value, 'string');
|
||||
}
|
||||
else {
|
||||
settype($this->value, $type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue