/** * Import Klosterorden table into the FLOW domain_model tabel subugoe_germaniasacra_domain_klosterorden_band * @return int */ public function importKlosterordenAction() { if ($this->logger) { $start = microtime(true); } /** @var \Doctrine\DBAL\Connection $sqlConnection */ $sqlConnection = $this->entityManager->getConnection(); $sql = 'SELECT * FROM Klosterorden ORDER BY ID_KlosterOrden ASC'; $klosterordens = $sqlConnection->fetchAll($sql); $klosterstatusArr = []; if (isset($klosterordens) and is_array($klosterordens)) { $nKlosterorden = 0; foreach ($klosterordens as $klosterorden) { $uid = $klosterorden['ID_KlosterOrden']; $kloster = $klosterorden['Klosternummer']; $orden = $klosterorden['Orden']; if (isset($kloster) && !empty($kloster) && (isset($orden) && !empty($orden))) { $klosterObject = $this->klosterRepository->findOneByUid($kloster); $ordenObject = $this->ordenRepository->findOneByUid($orden); if (is_object($klosterObject) && $klosterObject !== null && (is_object($ordenObject) && $ordenObject !== null)) { if (!isset($klosterorden['Klosterstatus']) || empty($klosterorden['Klosterstatus'])) { $klosterorden['Klosterstatus'] = "keine Angabe"; } $klosterstatus = $klosterorden['Klosterstatus']; if (!in_array($klosterstatus, $klosterstatusArr)) { array_push($klosterstatusArr, $klosterstatus); $klosterstatusObject = new Klosterstatus(); $klosterstatusObject->setStatus($klosterstatus); $this->klosterstatusRepository->add($klosterstatusObject); $this->persistenceManager->persistAll(); $klosterstatusUUID = $klosterstatusObject->getUUID(); $klosterstatusObject = $this->klosterstatusRepository->findByIdentifier($klosterstatusUUID); } else { $klosterstatusObject = $this->klosterstatusRepository->findOneByStatus($klosterstatus); } $von_von = $klosterorden['von_von']; $von_bis = $klosterorden['von_bis']; $von_verbal = $klosterorden['verbal_von']; $bis_von = $klosterorden['bis_von']; $bis_bis = $klosterorden['bis_bis']; $bis_verbal = $klosterorden['verbal_bis']; $bemerkung = $klosterorden['interne_Anmerkungen']; $klosterordenObject = new Klosterorden(); $klosterordenObject->setUid($uid); $klosterordenObject->setKloster($klosterObject); $klosterordenObject->setOrden($ordenObject); $klosterordenObject->setKlosterstatus($klosterstatusObject); $klosterordenObject->setVon_von($von_von); $klosterordenObject->setVon_bis($von_bis); $klosterordenObject->setVon_verbal($von_verbal); $klosterordenObject->setBis_von($bis_von); $klosterordenObject->setBis_bis($bis_bis); $klosterordenObject->setBis_verbal($bis_verbal); $klosterordenObject->setBemerkung($bemerkung); $this->klosterordenRepository->add($klosterordenObject); $this->persistenceManager->persistAll(); } $nKlosterorden++; } else { if ($klosterObject === null) { $this->importExportLogger->log('Entweder ist das Feld Klosternummer in Klosterordentabelle leer oder das Klosterobject in der Klostertabelle für das Kloster mit der Id = ' . $kloster . ' wurde nicht gefunden.', LOG_ERR); } if ($ordenObject === null) { $this->importExportLogger->log('Entweder ist das Feld Orden in Klosterordentabelle leer oder das Ordenobject in der Ordentabelle für den Orden mit der Id = ' . $orden . ' wurde nicht gefunden.', LOG_ERR); } } } if ($this->logger) { $end = microtime(true); $time = number_format($end - $start, 2); $this->logger->log('Klosterorden import completed in ' . round($time / 60, 2) . ' minutes.'); } return $nKlosterorden; } }
/** 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); }