Example #1
0
 /**
  * Update a Band entity
  */
 public function updateAction()
 {
     if ($this->request->hasArgument('uUID')) {
         $uuid = $this->request->getArgument('uUID');
     }
     if (empty($uuid)) {
         $this->throwStatus(400, 'Required uUID not provided', null);
     }
     $bandObj = $this->bandRepository->findByIdentifier($uuid);
     if (is_object($bandObj)) {
         $bandObj->setNummer($this->request->getArgument('nummer'));
         $bandObj->setTitel($this->request->getArgument('titel'));
         $bandObj->setKurztitel($this->request->getArgument('kurztitel'));
         $bandObj->setSortierung($this->request->getArgument('sortierung'));
         if ($this->request->hasArgument('bistum')) {
             $bistumUUID = $this->request->getArgument('bistum');
             $bistumObj = $this->bistumRepository->findByIdentifier($bistumUUID);
             if (is_object($bistumObj)) {
                 $bandObj->setBistum($bistumObj);
             }
         }
         $this->bandRepository->update($bandObj);
         // Fetch Band Urls
         $bandHasUrls = $bandObj->getBandHasUrls();
         $bandHasGND = 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 = $this->request->getArgument('nummer') . ' [' . $gndid . ']';
             }
             if (isset($gnd) && !empty($gnd)) {
                 if (!empty($bandHasUrls)) {
                     foreach ($bandHasUrls as $i => $bandHasUrl) {
                         $urlObj = $bandHasUrl->getUrl();
                         $urlTypObj = $urlObj->getUrltyp();
                         $urlTyp = $urlTypObj->getName();
                         if ($urlTyp == "GND") {
                             $urlObj->setUrl($gnd);
                             if (!empty($gnd_label)) {
                                 $urlObj->setBemerkung($gnd_label);
                             }
                             $this->urlRepository->update($urlObj);
                             $bandHasGND = true;
                         }
                     }
                 }
                 if (!$bandHasGND) {
                     $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);
                     $bandhasurl = new BandHasUrl();
                     $bandhasurl->setBand($bandObj);
                     $bandhasurl->setUrl($urlObj);
                     $this->bandHasUrlRepository->add($bandhasurl);
                 }
             }
         }
         //Update Wikipedia if set
         $bandHasWiki = 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 ($bandHasUrls as $i => $bandHasUrl) {
                     $urlObj = $bandHasUrl->getUrl();
                     $urlTypObj = $urlObj->getUrltyp();
                     $urlTyp = $urlTypObj->getName();
                     if ($urlTyp == "Wikipedia") {
                         $urlObj->setUrl($wikipedia);
                         if (!empty($wikipedia_label)) {
                             $urlObj->setBemerkung($wikipedia_label);
                         }
                         $this->urlRepository->update($urlObj);
                         $bandHasWiki = true;
                     }
                 }
                 if (!$bandHasWiki) {
                     $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);
                     $bandhasurl = new BandHasUrl();
                     $bandhasurl->setBand($bandObj);
                     $bandhasurl->setUrl($urlObj);
                     $this->bandHasUrlRepository->add($bandhasurl);
                 }
             }
         }
         // 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($urlArr) && !empty($urlArr) && (isset($urlTypArr) && !empty($urlTypArr))) {
                     foreach ($bandHasUrls as $i => $bandHasUrl) {
                         $urlObj = $bandHasUrl->getUrl();
                         $urlTypObj = $urlObj->getUrltyp();
                         $urlTyp = $urlTypObj->getName();
                         if ($urlTyp != "Wikipedia" && $urlTyp != "GND") {
                             $this->bandHasUrlRepository->remove($bandHasUrl);
                             $this->urlRepository->remove($urlObj);
                         }
                     }
                     foreach ($urlArr as $k => $url) {
                         if (!empty($url)) {
                             $urlObj = new Url();
                             $urlObj->setUrl($url);
                             $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);
                             $bandhasurl = new BandHasUrl();
                             $bandhasurl->setBand($bandObj);
                             $bandhasurl->setUrl($urlObj);
                             $this->bandHasUrlRepository->add($bandhasurl);
                         }
                     }
                 }
             }
         }
         $this->persistenceManager->persistAll();
         $this->throwStatus(200, null, null);
     } else {
         $this->throwStatus(400, 'Entity Band not available', null);
     }
 }
 /**
  * Import Orden table into the FLOW domain_model tabel subugoe_germaniasacra_domain_model_orden
  * @return int
  */
 public function importOrdenAction()
 {
     if ($this->logger) {
         $start = microtime(true);
     }
     /** @var \Doctrine\DBAL\Connection $sqlConnection */
     $sqlConnection = $this->entityManager->getConnection();
     $sql = 'SELECT * FROM Orden';
     $ordens = $sqlConnection->fetchAll($sql);
     $ordenstypArr = [];
     if (isset($ordens) and is_array($ordens)) {
         $nOrden = 0;
         foreach ($ordens as $ordenvalue) {
             $uid = $ordenvalue['ID_Ordo'];
             $orden = $ordenvalue['Ordensbezeichnung'];
             $ordo = $ordenvalue['Ordo'];
             $symbol = $ordenvalue['Symbol'];
             $graphik = null;
             if (isset($ordenvalue['Grafikdatei']) && !empty($ordenvalue['Grafikdatei'])) {
                 $graphik = $ordenvalue['Grafikdatei'];
             }
             $ordenstyp = $ordenvalue['Geschlecht'];
             $gnd = $ordenvalue['GND_Orden'];
             $wikipedia = $ordenvalue['Wikipedia_Orden'];
             if (empty($ordenstyp)) {
                 $ordenstyp = 'unbekannt';
             }
             if (!in_array($ordenstyp, $ordenstypArr)) {
                 $ordenstypObject = new Ordenstyp();
                 $ordenstypObject->setOrdenstyp($ordenstyp);
                 $this->ordenstypRepository->add($ordenstypObject);
                 $this->persistenceManager->persistAll();
                 $ordenstypUUID = $ordenstypObject->getUUID();
             }
             array_push($ordenstypArr, $ordenstyp);
             if (isset($ordenstypUUID) && !empty($ordenstypUUID)) {
                 $ordenstypObject = $this->ordenstypRepository->findByIdentifier($ordenstypUUID);
             } else {
                 $ordenstypObject = $this->ordenstypRepository->findOneByOrdenstyp($ordenstyp);
             }
             $ordenObject = new Orden();
             $ordenObject->setUid($uid);
             $ordenObject->setOrden($orden);
             $ordenObject->setOrdo($ordo);
             $ordenObject->setSymbol($symbol);
             $ordenObject->setGraphik($graphik);
             $ordenObject->setOrdenstyp($ordenstypObject);
             $this->ordenRepository->add($ordenObject);
             $this->persistenceManager->persistAll();
             unset($ordenstypUUID);
             $ordenUUID = $ordenObject->getUUID();
             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 = $orden . " [" . $gndid . "]";
                                 $urlObject = new Url();
                                 $urlObject->setUrl($gnd);
                                 $urlObject->setBemerkung($gndbemerkung);
                                 $gndurltypObject = $this->urltypRepository->findOneByName('GND');
                                 $urlObject->setUrltyp($gndurltypObject);
                                 $this->urlRepository->add($urlObject);
                                 $this->persistenceManager->persistAll();
                                 $gndurlUUID = $urlObject->getUUID();
                                 $oldgnd = $gnd;
                                 $ordenhasurlObject = new Ordenhasurl();
                                 $ordenObject = $this->ordenRepository->findByIdentifier($ordenUUID);
                                 $ordenhasurlObject->setOrden($ordenObject);
                                 $gndurlObject = $this->urlRepository->findByIdentifier($gndurlUUID);
                                 $ordenhasurlObject->setUrl($gndurlObject);
                                 $this->ordenHasUrlRepository->add($ordenhasurlObject);
                                 $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->findOneByName('Wikipedia');
                                 $urlObject->setUrltyp($wikiurltypObject);
                                 $this->urlRepository->add($urlObject);
                                 $this->persistenceManager->persistAll();
                                 $wikiurlUUID = $urlObject->getUUID();
                                 $oldwikipedia = $wikipedia;
                                 $ordenhasurlObject = new Ordenhasurl();
                                 $ordenObject = $this->ordenRepository->findByIdentifier($ordenUUID);
                                 $ordenhasurlObject->setOrden($ordenObject);
                                 $wikiurlObject = $this->urlRepository->findByIdentifier($wikiurlUUID);
                                 $ordenhasurlObject->setUrl($wikiurlObject);
                                 $this->ordenHasUrlRepository->add($ordenhasurlObject);
                                 $this->persistenceManager->persistAll();
                             }
                         }
                     }
                 }
             }
             $nOrden++;
         }
         if ($this->logger) {
             $end = microtime(true);
             $time = number_format($end - $start, 2);
             $this->logger->log('Orden import completed in ' . round($time / 60, 2) . ' minutes.');
         }
         return $nOrden;
     }
 }
 /** 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);
 }