public function endEditLookup()
 {
     $this->current = Modules::getModule($this->request->current);
     $this->entity = $this->current->getEntity($this->request->entity);
     $this->lookup = ModelField::createField(ModelField::TYPE_LOOKUP, $this->request->name, $this->request->description, 0, '');
     $relation = $this->entity->relations[$this->request->relation];
     // TODO: Was machen, wenn leer
     $this->lookup->setRelation($relation);
     $this->lookup->setField($this->request->field);
     $this->entity->lookupFields[$this->request->name] = $this->lookup;
     $this->current->save();
     $this->request->clear();
     $this->request->id = $this->current->qualifiedName;
     $this->request->hash = 'entity_' . $this->entity->name;
     $this->request->initPanel = 2;
 }
 /**
  * Parst das XML Objekt und erstellt die einzelnen Objekte.
  * Die Objekte werden im weiteren Verlauf immer geclont, so dass die
  * Einstellungen übernommen werden
  * @param SimpleXMLElement $entity
  * @throws Exception
  */
 private function buildEntity(SimpleXMLElement $entity)
 {
     $this->name = (string) $entity['name'];
     $this->extends = (string) $entity['extends'];
     $this->match = (string) $entity['match'];
     if ($this->match === '') {
         $this->match = $this->name;
     }
     $this->primaryKey = (string) $entity->primary['name'];
     // Felder
     foreach ($entity->field as $field) {
         $this->fields[(string) $field['name']] = ModelField::createByXml($field);
     }
     // Relationen
     foreach ($entity->relation as $relation) {
         $this->relations[(string) $relation['name']] = Relation::createByXml($relation);
     }
     // Lookups
     foreach ($entity->lookup as $lookup) {
         // Werden auch als "normale" Felder angelegt
         $temp = ModelField::createField(ModelField::TYPE_LOOKUP, (string) $lookup['name'], (string) $lookup['description'], (string) $lookup['maxlength']);
         if (isset($lookup['relation'])) {
             if ($this->relations[(string) $lookup['relation']] == null) {
                 throw new \RuntimeException('Relation [' . (string) $lookup['relation'] . '] für Feld [' . (string) $lookup['name'] . '] in Entity [' . $this->name . '] konnte nicht gefunden werden');
             }
             $temp->setRelation($this->relations[(string) $lookup['relation']]);
         }
         if (isset($lookup['field'])) {
             $temp->setField((string) $lookup['field']);
         }
         $this->fields[(string) $lookup['name']] = $temp;
         $this->lookupFields[(string) $lookup['name']] = $temp;
     }
 }