/**
  * Update a list of Band entities
  */
 public function updateListAction()
 {
     if ($this->request->hasArgument('data')) {
         $bandlist = $this->request->getArgument('data');
     }
     if (empty($bandlist)) {
         $this->throwStatus(400, 'Required data arguemnts not provided', null);
     }
     foreach ($bandlist as $uuid => $band) {
         if (isset($uuid) && !empty($uuid)) {
             $bandObj = $this->bandRepository->findByIdentifier($uuid);
             $bandObj->setNummer($band['nummer']);
             $bandObj->setTitel($band['titel']);
             $bandObj->setKurztitel($band['kurztitel']);
             $bandObj->setSortierung($band['sortierung']);
             $bistumUUID = $band['bistum'];
             $bistum = $this->bistumRepository->findByIdentifier($bistumUUID);
             $bandObj->setBistum($bistum);
             $this->bandRepository->update($bandObj);
         } else {
             $this->throwStatus(400, 'Required uUID not provided', null);
         }
     }
     $this->persistenceManager->persistAll();
     $this->throwStatus(200, null, null);
 }
 /**
  * Update a list of Bistum entities
  */
 public function updateListAction()
 {
     if ($this->request->hasArgument('data')) {
         $bistumlist = $this->request->getArgument('data');
     }
     if (empty($bistumlist)) {
         $this->throwStatus(400, 'Required data arguemnts not provided', null);
     }
     foreach ($bistumlist as $uuid => $bistum) {
         if (isset($uuid) && !empty($uuid)) {
             $bistumObj = $this->bistumRepository->findByIdentifier($uuid);
             $bistumObj->setBistum($bistum['bistum']);
             $bistumObj->setKirchenprovinz($bistum['kirchenprovinz']);
             $bistumObj->setBemerkung($bistum['bemerkung']);
             if (isset($bistum['ist_erzbistum']) && !empty($bistum['ist_erzbistum'])) {
                 $ist_erzbistum = $bistum['ist_erzbistum'];
             } else {
                 $ist_erzbistum = 0;
             }
             $bistumObj->setIst_erzbistum($ist_erzbistum);
             $bistumObj->setShapefile($bistum['shapefile']);
             $ortUUID = $bistum['ort'];
             $ort = $this->ortRepository->findByIdentifier($ortUUID);
             $bistumObj->setOrt($ort);
             $this->bistumRepository->update($bistumObj);
         } else {
             $this->throwStatus(400, 'Required uUID not provided', null);
         }
     }
     $this->persistenceManager->persistAll();
     $this->throwStatus(200, null, null);
 }
 /**
  * Update a list of Ort entities
  */
 public function updateListAction()
 {
     if ($this->request->hasArgument('data')) {
         $ortlist = $this->request->getArgument('data');
     }
     if (empty($ortlist)) {
         $this->throwStatus(400, 'Required data arguemnts not provided', null);
     }
     foreach ($ortlist as $uuid => $ort) {
         if (isset($uuid) && !empty($uuid)) {
             $ortObj = $this->ortRepository->findByIdentifier($uuid);
             $ortObj->setOrt($ort['ort']);
             $ortObj->setGemeinde($ort['gemeinde']);
             $ortObj->setKreis($ort['kreis']);
             $ortObj->setBreite($ort['breite']);
             $ortObj->setLaenge($ort['laenge']);
             if (isset($ort['wuestung']) && !empty($ort['wuestung'])) {
                 $wuestung = $ort['wuestung'];
             } else {
                 $wuestung = 0;
             }
             $ortObj->setWuestung($wuestung);
             $bistumUUID = $ort['bistum'];
             $bistum = $this->bistumRepository->findByIdentifier($bistumUUID);
             $ortObj->setBistum($bistum);
             $this->ortRepository->update($ortObj);
         } else {
             $this->throwStatus(400, 'Required uUID not provided', null);
         }
     }
     $this->persistenceManager->persistAll();
     $this->throwStatus(200, null, null);
 }
 /**
  * Import Bistum table into the FLOW domain_model tabel subugoe_germaniasacra_domain_model_bistum
  * @return int
  */
 public function importBistumAction()
 {
     if ($this->logger) {
         $start = microtime(true);
     }
     /** @var \Doctrine\DBAL\Connection $sqlConnection */
     $sqlConnection = $this->entityManager->getConnection();
     $tbl = 'subugoe_germaniasacra_domain_model_urltyp';
     $sql = 'SELECT * FROM ' . $tbl . ' WHERE name = "GND"';
     $gndurltyp = $sqlConnection->fetchAll($sql);
     if (count($gndurltyp) > 0) {
         $gndurltypUUID = $gndurltyp[0]['persistence_object_identifier'];
     }
     if (!isset($gndurltypUUID)) {
         $gndurlTypeName = "GND";
         $urltypObject = new Urltyp();
         $urltypObject->setName($gndurlTypeName);
         $this->urltypRepository->add($urltypObject);
         $this->persistenceManager->persistAll();
         $gndurltypUUID = $urltypObject->getUUID();
     }
     $sql = 'SELECT * FROM ' . $tbl . ' WHERE name = "Wikipedia"';
     $wikiurltyp = $sqlConnection->fetchAll($sql);
     if (count($wikiurltyp) > 0) {
         $wikiurltypUUID = $wikiurltyp[0]['persistence_object_identifier'];
     }
     if (!isset($wikiurltypUUID)) {
         $wikiurlTypeName = "Wikipedia";
         $urltypObject = new Urltyp();
         $urltypObject->setName($wikiurlTypeName);
         $this->urltypRepository->add($urltypObject);
         $this->persistenceManager->persistAll();
         $wikiurltypUUID = $urltypObject->getUUID();
     }
     $sql = 'SELECT * FROM Bistum';
     $Bistums = $sqlConnection->fetchAll($sql);
     if (isset($Bistums) and is_array($Bistums)) {
         $nBistum = 0;
         foreach ($Bistums as $Bistum) {
             $uid = $Bistum['ID'];
             $bistum = $Bistum['Bistum'];
             $kirchenprovinz = $Bistum['Kirchenprovinz'];
             $bemerkung = $Bistum['Bemerkung'];
             $erzbistum = $Bistum['ErzbistumAuswahlfeld'];
             $shapefile = $Bistum['Shapefile'];
             $ort = $Bistum['Bistumssitz'];
             $gnd = $Bistum['GND_Dioezese'];
             $wikipedia = $Bistum['Wikipedia_Dioezese'];
             $bistumObject = new Bistum();
             $bistumObject->setUid($uid);
             $bistumObject->setBistum($bistum);
             $bistumObject->setKirchenprovinz($kirchenprovinz);
             $bistumObject->setBemerkung($bemerkung);
             if ($erzbistum == "Erzbistum") {
                 $is_erzbistum = 1;
             } else {
                 $is_erzbistum = 0;
             }
             $bistumObject->setIst_erzbistum($is_erzbistum);
             $bistumObject->setShapefile($shapefile);
             $ortObject = $this->ortRepository->findOneByUid($ort);
             if (is_object($ortObject)) {
                 $bistumObject->setOrt($ortObject);
             }
             $this->bistumRepository->add($bistumObject);
             $this->persistenceManager->persistAll();
             $bistumUUID = $bistumObject->getUUID();
             $sql = 'SELECT * FROM Ort WHERE ID_Bistum=' . $uid . '';
             $ortuids = $sqlConnection->fetchAll($sql);
             if (!empty($ortuids)) {
                 foreach ($ortuids as $ortuid) {
                     $ort = $this->ortRepository->findOneByUid($ortuid['ID']);
                     $ortBistum = $this->bistumRepository->findByIdentifier($bistumUUID);
                     $ort->setBistum($ortBistum);
                     $this->ortRepository->update($ort);
                     $this->persistenceManager->persistAll();
                 }
             }
             if (isset($gnd) && !empty($gnd)) {
                 $gnd = str_replace("\t", " ", $gnd);
                 $gnd = str_replace("http:// ", " ", $gnd);
                 $gnd = str_replace(" http", ";http", $gnd);
                 $gnd = str_replace(";", "#", $gnd);
                 $gnds = explode("#", $gnd);
                 if (isset($gnds) && is_array($gnds)) {
                     $oldgnd = "";
                     foreach ($gnds as $gnd) {
                         if (isset($gnd) && !empty($gnd)) {
                             if ($gnd != $oldgnd) {
                                 $gnd = str_replace(" ", "", $gnd);
                                 $gnd = str_replace("# ", "", $gnd);
                                 $gndid = str_replace("http://d-nb.info/gnd/", "", $gnd);
                                 $gndbemerkung = $bistum . " [" . $gndid . "]";
                                 $urlObject = new Url();
                                 $urlObject->setUrl($gnd);
                                 $urlObject->setBemerkung($gndbemerkung);
                                 $gndurltypObject = $this->urltypRepository->findByIdentifier($gndurltypUUID);
                                 $urlObject->setUrltyp($gndurltypObject);
                                 $this->urlRepository->add($urlObject);
                                 $this->persistenceManager->persistAll();
                                 $gndurlUUID = $urlObject->getUUID();
                                 $oldgnd = $gnd;
                                 $bistumhasurlObject = new Bistumhasurl();
                                 $bistumObject = $this->bistumRepository->findByIdentifier($bistumUUID);
                                 $bistumhasurlObject->setBistum($bistumObject);
                                 $gndurlObject = $this->urlRepository->findByIdentifier($gndurlUUID);
                                 $bistumhasurlObject->setUrl($gndurlObject);
                                 $this->bistumHasUrlRepository->add($bistumhasurlObject);
                                 $this->persistenceManager->persistAll();
                             }
                         }
                     }
                 }
             }
             if (isset($wikipedia) && !empty($wikipedia)) {
                 $wikipedia = str_replace("http:// ", " ", $wikipedia);
                 $wikipedia = str_replace(";", "#", $wikipedia);
                 $wikipedias = explode("#", $wikipedia);
                 if (isset($wikipedias) && is_array($wikipedias)) {
                     $oldwikipedia = "";
                     foreach ($wikipedias as $wikipedia) {
                         if (isset($wikipedia) && !empty($wikipedia)) {
                             if ($wikipedia != $oldwikipedia) {
                                 $wikipediabemerkung = str_replace("http://de.wikipedia.org/wiki/", "", $wikipedia);
                                 $wikipediabemerkung = str_replace("_", " ", $wikipediabemerkung);
                                 $wikipediabemerkung = rawurldecode($wikipediabemerkung);
                                 $urlObject = new Url();
                                 $urlObject->setUrl($wikipedia);
                                 $urlObject->setBemerkung($wikipediabemerkung);
                                 $wikiurltypObject = $this->urltypRepository->findByIdentifier($wikiurltypUUID);
                                 $urlObject->setUrltyp($wikiurltypObject);
                                 $this->urlRepository->add($urlObject);
                                 $this->persistenceManager->persistAll();
                                 $wikiurlUUID = $urlObject->getUUID();
                                 $oldwikipedia = $wikipedia;
                                 $bistumhasurlObject = new Bistumhasurl();
                                 $bistumObject = $this->bistumRepository->findByIdentifier($bistumUUID);
                                 $bistumhasurlObject->setBistum($bistumObject);
                                 $wikiurlObject = $this->urlRepository->findByIdentifier($wikiurlUUID);
                                 $bistumhasurlObject->setUrl($wikiurlObject);
                                 $this->bistumHasUrlRepository->add($bistumhasurlObject);
                                 $this->persistenceManager->persistAll();
                             }
                         }
                     }
                 }
             }
             $nBistum++;
         }
     }
     if ($this->logger) {
         $end = microtime(true);
         $time = number_format($end - $start, 2);
         $this->logger->log('Bistum import completed in ' . round($time / 60, 2) . ' minutes.');
     }
     return $nBistum;
 }
 /** Update a Kloster entity
  **/
 public function updateAction()
 {
     // Update Kloster
     if ($this->request->hasArgument('uUID')) {
         $uuid = $this->request->getArgument('uUID');
     }
     if (empty($uuid)) {
         $this->throwStatus(400, 'Required uUID not provided', null);
     }
     $kloster = $this->klosterRepository->findByIdentifier($uuid);
     if (!is_object($kloster)) {
         $this->throwStatus(400, 'Entity Kloster not available', null);
     }
     $bearbeitungsstatus_uuid = $this->request->getArgument('bearbeitungsstatus');
     $bearbeitungsstatus = $this->bearbeitungsstatusRepository->findByIdentifier($bearbeitungsstatus_uuid);
     $role = array_keys($this->securityContext->getAccount()->getRoles())[0];
     if (trim($role) == 'Flow.Login:Hiwi') {
         if (is_object($bearbeitungsstatus)) {
             $bearbeitungsstatusName = $bearbeitungsstatus->getName();
         }
         if (isset($bearbeitungsstatusName) && !empty($bearbeitungsstatusName)) {
             if (trim($bearbeitungsstatusName) == 'Online') {
                 $this->throwStatus(400, 'You are not allowed to set a Kloster entry online', null);
             }
         }
     }
     $kloster->setKloster($this->request->getArgument('kloster_name'));
     $kloster->setPatrozinium($this->request->getArgument('patrozinium'));
     $kloster->setBemerkung($this->request->getArgument('bemerkung'));
     $kloster->setBand_seite($this->request->getArgument('band_seite'));
     $kloster->setText_gs_band($this->request->getArgument('text_gs_band'));
     $kloster->setBearbeitungsstand($this->request->getArgument('bearbeitungsstand'));
     $kloster->setBearbeitungsstatus($bearbeitungsstatus);
     $bearbeiter = $this->bearbeiterObj;
     $kloster->setBearbeiter($bearbeiter);
     if ($this->request->hasArgument('band')) {
         $band_uuid = $this->request->getArgument('band');
         $band = $this->bandRepository->findByIdentifier($band_uuid);
         $kloster->setBand($band);
     }
     $this->klosterRepository->update($kloster);
     // Update Klosterstandort
     if ($this->request->hasArgument('ort')) {
         $ortArr = $this->request->getArgument('ort');
     }
     if ($this->request->hasArgument('bistum')) {
         $bistumArr = $this->request->getArgument('bistum');
     }
     $gruenderArr = $this->request->getArgument('gruender');
     $breiteArr = $this->request->getArgument('breite');
     $laengeArr = $this->request->getArgument('laenge');
     $bemerkung_standortArr = $this->request->getArgument('bemerkung_standort');
     $bemerkungArr = $this->request->getArgument('standort_interne_bemerkung');
     $von_vonArr = $this->request->getArgument('von_von');
     $von_bisArr = $this->request->getArgument('von_bis');
     $von_verbalArr = $this->request->getArgument('von_verbal');
     $bis_vonArr = $this->request->getArgument('bis_von');
     $bis_bisArr = $this->request->getArgument('bis_bis');
     $bis_verbalArr = $this->request->getArgument('bis_verbal');
     if ($this->request->hasArgument('wuestung')) {
         $wuestungArr = $this->request->getArgument('wuestung');
     }
     $klosterstandortNumber = count($ortArr);
     $klosterstandortArr = [];
     for ($i = 0; $i < $klosterstandortNumber; $i++) {
         $klosterstandortArr[$i]['kloster'] = $uuid;
         if (!empty($ortArr[$i])) {
             $klosterstandortArr[$i]['ort'] = $ortArr[$i];
         }
         if (!empty($bistumArr[$i])) {
             $klosterstandortArr[$i]['bistum'] = $bistumArr[$i];
         }
         $klosterstandortArr[$i]['gruender'] = $gruenderArr[$i];
         $klosterstandortArr[$i]['breite'] = $breiteArr[$i];
         $klosterstandortArr[$i]['laenge'] = $laengeArr[$i];
         $klosterstandortArr[$i]['bemerkung_standort'] = $bemerkung_standortArr[$i];
         $klosterstandortArr[$i]['bemerkung'] = $bemerkungArr[$i];
         $klosterstandortArr[$i]['von_von'] = $von_vonArr[$i];
         $klosterstandortArr[$i]['von_bis'] = $von_bisArr[$i];
         $klosterstandortArr[$i]['von_verbal'] = $von_verbalArr[$i];
         $klosterstandortArr[$i]['bis_von'] = $bis_vonArr[$i];
         $klosterstandortArr[$i]['bis_bis'] = $bis_bisArr[$i];
         $klosterstandortArr[$i]['bis_verbal'] = $bis_verbalArr[$i];
         if (isset($wuestungArr[$i]) && !empty($wuestungArr[$i])) {
             $klosterstandortArr[$i]['wuestung'] = 1;
         } else {
             $klosterstandortArr[$i]['wuestung'] = 0;
         }
     }
     if (isset($klosterstandortArr) && !empty($klosterstandortArr) && is_array($klosterstandortArr)) {
         $klosterstandorts = $kloster->getKlosterstandorts();
         foreach ($klosterstandorts as $i => $klosterstandort) {
             $this->klosterstandortRepository->remove($klosterstandort);
         }
         $lastKlosterstandortId = $this->getLastKlosterstandortIdAction();
         foreach ($klosterstandortArr as $ko) {
             $klosterstandort = new Klosterstandort();
             $kloster_uuid = $ko['kloster'];
             $kloster = $this->klosterRepository->findByIdentifier($kloster_uuid);
             $klosterstandort->setUid(++$lastKlosterstandortId);
             $klosterstandort->setKloster($kloster);
             if (!empty($ko['ort'])) {
                 $ort_uuid = $ko['ort'];
                 $ort = $this->ortRepository->findByIdentifier($ort_uuid);
                 $klosterstandort->setOrt($ort);
             }
             $klosterstandort->setGruender($ko['gruender']);
             $klosterstandort->setBreite($ko['breite']);
             $klosterstandort->setLaenge($ko['laenge']);
             $klosterstandort->setVon_von($ko['von_von']);
             $klosterstandort->setVon_bis($ko['von_bis']);
             $klosterstandort->setVon_verbal($ko['von_verbal']);
             $klosterstandort->setBis_von($ko['bis_von']);
             $klosterstandort->setBis_bis($ko['bis_bis']);
             $klosterstandort->setBis_verbal($ko['bis_verbal']);
             $klosterstandort->setBemerkung_standort($ko['bemerkung_standort']);
             $klosterstandort->setBemerkung($ko['bemerkung']);
             $this->klosterstandortRepository->add($klosterstandort);
             if (isset($ort) && is_object($ort)) {
                 $ort->setWuestung($ko['wuestung']);
             }
             if (!empty($ko['bistum'])) {
                 $bistumObject = $this->bistumRepository->findByIdentifier($ko['bistum']);
                 if (is_object($bistumObject) && isset($ort) && is_object($ort)) {
                     $ort->setBistum($bistumObject);
                 }
             }
             if (isset($ort) && is_object($ort)) {
                 $this->ortRepository->update($ort);
             }
         }
     }
     // Update Orden
     $ordenArr = $this->request->getArgument('orden');
     $klosterstatusArr = $this->request->getArgument('klosterstatus');
     $bemerkung_ordenArr = $this->request->getArgument('bemerkung_orden');
     $orden_von_vonArr = $this->request->getArgument('orden_von_von');
     $orden_von_bisArr = $this->request->getArgument('orden_von_bis');
     $orden_von_verbalArr = $this->request->getArgument('orden_von_verbal');
     $orden_bis_vonArr = $this->request->getArgument('orden_bis_von');
     $orden_bis_bisArr = $this->request->getArgument('orden_bis_bis');
     $orden_bis_verbalArr = $this->request->getArgument('orden_bis_verbal');
     $klosterordenNumber = count($ordenArr);
     $klosterordenArr = [];
     for ($i = 0; $i < $klosterordenNumber; $i++) {
         $klosterordenArr[$i]['kloster'] = $uuid;
         $klosterordenArr[$i]['orden'] = $ordenArr[$i];
         $klosterordenArr[$i]['klosterstatus'] = $klosterstatusArr[$i];
         $klosterordenArr[$i]['bemerkung_orden'] = $bemerkung_ordenArr[$i];
         $klosterordenArr[$i]['orden_von_von'] = $orden_von_vonArr[$i];
         $klosterordenArr[$i]['orden_von_bis'] = $orden_von_bisArr[$i];
         $klosterordenArr[$i]['orden_von_verbal'] = $orden_von_verbalArr[$i];
         $klosterordenArr[$i]['orden_bis_von'] = $orden_bis_vonArr[$i];
         $klosterordenArr[$i]['orden_bis_bis'] = $orden_bis_bisArr[$i];
         $klosterordenArr[$i]['orden_bis_verbal'] = $orden_bis_verbalArr[$i];
     }
     if (isset($klosterordenArr) && !empty($klosterordenArr) && is_array($klosterordenArr)) {
         $klosterordens = $kloster->getKlosterordens();
         foreach ($klosterordens as $i => $klosterorden) {
             $this->klosterordenRepository->remove($klosterorden);
         }
         $lastKlosterordentId = $this->getLastKlosterordenIdAction();
         foreach ($klosterordenArr as $ko) {
             $klosterorden = new Klosterorden();
             $kloster_uuid = $ko['kloster'];
             $kloster = $this->klosterRepository->findByIdentifier($kloster_uuid);
             $klosterorden->setUid(++$lastKlosterordentId);
             $klosterorden->setKloster($kloster);
             $klosterorden->setVon_von($ko['orden_von_von']);
             $klosterorden->setVon_bis($ko['orden_von_bis']);
             $klosterorden->setVon_verbal($ko['orden_von_verbal']);
             $klosterorden->setBis_von($ko['orden_bis_von']);
             $klosterorden->setBis_bis($ko['orden_bis_bis']);
             $klosterorden->setBis_verbal($ko['orden_bis_verbal']);
             $orden_uuid = $ko['orden'];
             $orden = $this->ordenRepository->findByIdentifier($orden_uuid);
             $klosterorden->setOrden($orden);
             $klosterstatus_uuid = $ko['klosterstatus'];
             $klosterstatus = $this->klosterstatusRepository->findByIdentifier($klosterstatus_uuid);
             $klosterorden->setKlosterstatus($klosterstatus);
             $klosterorden->setBemerkung($ko['bemerkung_orden']);
             $this->klosterordenRepository->add($klosterorden);
         }
     }
     // Update literatur
     $literaturs = $kloster->getKlosterHasLiteraturs();
     if (!empty($literaturs)) {
         foreach ($literaturs as $literatur) {
             $this->klosterHasLiteraturRepository->remove($literatur);
         }
     }
     if ($this->request->hasArgument('literatur')) {
         $literaturArr = $this->request->getArgument('literatur');
         if ($this->request->hasArgument('fundstelle')) {
             $fundstelleArr = $this->request->getArgument('fundstelle');
         }
         if (isset($literaturArr) && !empty($literaturArr) && is_array($literaturArr)) {
             foreach ($literaturArr as $k => $lit) {
                 if (isset($lit) && !empty($lit)) {
                     $lit = trim($lit);
                     $fundstelle = trim($fundstelleArr[$k]);
                     if (!empty($fundstelle)) {
                         $literatur = $this->literaturRepository->findByProperties(['citekey' => $lit, 'beschreibung' => $fundstelle]);
                         if (count($literatur) > 0) {
                             $litUUID = $literatur->getFirst()->getUUID();
                             if (!empty($litUUID)) {
                                 $literatur = $this->literaturRepository->findByIdentifier($litUUID);
                             }
                         } else {
                             $literatur = new Literatur();
                             $literatur->setCitekey($lit);
                             $literatur->setBeschreibung($fundstelle);
                             $this->literaturRepository->add($literatur);
                             $litUUID = $literatur->getUUID();
                         }
                         if (is_object($kloster) && is_object($literatur)) {
                             $klosterHasLiteratur = new KlosterHasLiteratur();
                             $klosterHasLiteratur->setKloster($kloster);
                             $klosterHasLiteratur->setLiteratur($literatur);
                             $this->klosterHasLiteraturRepository->add($klosterHasLiteratur);
                         }
                     }
                 }
             }
         }
     }
     // Fetch Kloster Urls
     $klosterHasUrls = $kloster->getKlosterHasUrls();
     $klosterHasGND = false;
     // Update GND if set
     if ($this->request->hasArgument('gnd')) {
         $gnd = $this->request->getArgument('gnd');
         if ($this->request->hasArgument('gnd_label')) {
             $gnd_label = $this->request->getArgument('gnd_label');
         }
         if (empty($gnd_label)) {
             $gndid = str_replace('http://d-nb.info/gnd/', '', trim($gnd));
             $gnd_label = $kloster . ' [' . $gndid . ']';
         }
         if (isset($gnd) && !empty($gnd)) {
             foreach ($klosterHasUrls as $i => $klosterHasUrl) {
                 $urlObj = $klosterHasUrl->getUrl();
                 $urlTypObj = $urlObj->getUrltyp();
                 if (is_object($urlTypObj)) {
                     $urlTyp = $urlTypObj->getName();
                     if ($urlTyp == "GND") {
                         $urlObj->setUrl($gnd);
                         if (!empty($gnd_label)) {
                             $urlObj->setBemerkung($gnd_label);
                         }
                         $this->urlRepository->update($urlObj);
                         $klosterHasGND = true;
                     }
                 }
             }
             if (!$klosterHasGND) {
                 $url = new Url();
                 $url->setUrl($gnd);
                 if (!empty($gnd_label)) {
                     $url->setBemerkung($gnd_label);
                 }
                 $urlTypObj = $this->urltypRepository->findOneByName('GND');
                 $url->setUrltyp($urlTypObj);
                 $this->urlRepository->add($url);
                 $urlUUID = $url->getUUID();
                 $urlObj = $this->urlRepository->findByIdentifier($urlUUID);
                 $klosterhasurl = new KlosterHasUrl();
                 $klosterhasurl->setKloster($kloster);
                 $klosterhasurl->setUrl($urlObj);
                 $this->klosterHasUrlRepository->add($klosterhasurl);
             }
         }
     }
     //Update Wikipedia if set
     $klosterHasWiki = false;
     if ($this->request->hasArgument('wikipedia')) {
         $wikipedia = $this->request->getArgument('wikipedia');
         if ($this->request->hasArgument('wikipedia_label')) {
             $wikipedia_label = $this->request->getArgument('wikipedia_label');
         }
         if (empty($wikipedia_label)) {
             $wikipedia_label = str_replace('http://de.wikipedia.org/wiki/', '', trim($wikipedia));
             $wikipedia_label = str_replace('_', ' ', $wikipedia_label);
             $wikipedia_label = rawurldecode($wikipedia_label);
         }
         if (isset($wikipedia) && !empty($wikipedia)) {
             foreach ($klosterHasUrls as $i => $klosterHasUrl) {
                 $urlObj = $klosterHasUrl->getUrl();
                 $url = $urlObj->getUrl();
                 $urlTypObj = $urlObj->getUrltyp();
                 if (is_object($urlTypObj)) {
                     $urlTyp = $urlTypObj->getName();
                     if ($urlTyp == "Wikipedia") {
                         $urlObj->setUrl($wikipedia);
                         if (!empty($wikipedia_label)) {
                             $urlObj->setBemerkung($wikipedia_label);
                         }
                         $this->urlRepository->update($urlObj);
                         $klosterHasWiki = true;
                     }
                 }
             }
             if (!$klosterHasWiki) {
                 $url = new Url();
                 $url->setUrl($wikipedia);
                 if (!empty($wikipedia_label)) {
                     $url->setBemerkung($wikipedia_label);
                 }
                 $urlTypObj = $this->urltypRepository->findOneByName('Wikipedia');
                 $url->setUrltyp($urlTypObj);
                 $this->urlRepository->add($url);
                 $urlUUID = $url->getUUID();
                 $urlObj = $this->urlRepository->findByIdentifier($urlUUID);
                 $klosterhasurl = new KlosterHasUrl();
                 $klosterhasurl->setKloster($kloster);
                 $klosterhasurl->setUrl($urlObj);
                 $this->klosterHasUrlRepository->add($klosterhasurl);
             }
         }
     }
     // Add Url if set
     if ($this->request->hasArgument('url')) {
         $urlArr = $this->request->getArgument('url');
         if (isset($urlArr) && !empty($urlArr)) {
             if ($this->request->hasArgument('url_typ')) {
                 $urlTypArr = $this->request->getArgument('url_typ');
             }
             if ($this->request->hasArgument('links_label')) {
                 $linksLabelArr = $this->request->getArgument('links_label');
             }
             if (isset($klosterHasUrls) && $klosterHasUrls !== []) {
                 foreach ($klosterHasUrls as $i => $klosterHasUrl) {
                     $urlObj = $klosterHasUrl->getUrl();
                     $urlTypObj = $urlObj->getUrltyp();
                     if (is_object($urlTypObj)) {
                         $urlTyp = $urlTypObj->getName();
                     }
                     if (isset($urlTyp) && ($urlTyp != "Wikipedia" && $urlTyp != "GND")) {
                         $this->klosterHasUrlRepository->remove($klosterHasUrl);
                         $this->urlRepository->remove($urlObj);
                     }
                 }
             }
             foreach ($urlArr as $k => $url) {
                 if (!empty($url)) {
                     $urlObj = new Url();
                     $urlObj->setUrl($url);
                     if (isset($urlTypArr[$k]) && !empty($urlTypArr[$k])) {
                         $urlTypObj = $this->urltypRepository->findByIdentifier($urlTypArr[$k]);
                         $urlTyp = $urlTypObj->getName();
                         $urlObj->setUrltyp($urlTypObj);
                     }
                     if (isset($linksLabelArr[$k]) && !empty($linksLabelArr[$k])) {
                         $urlObj->setBemerkung($linksLabelArr[$k]);
                     } else {
                         $urlObj->setBemerkung($urlTyp);
                     }
                     $this->urlRepository->add($urlObj);
                     $klosterhasurlObj = new KlosterHasUrl();
                     $klosterhasurlObj->setKloster($kloster);
                     $klosterhasurlObj->setUrl($urlObj);
                     $this->klosterHasUrlRepository->add($klosterhasurlObj);
                 }
             }
         }
     }
     $this->throwStatus(200, null, null);
 }