/** * Create a new Ordenstyp entity */ public function createAction() { $ordenstypObj = new Ordenstyp(); if (is_object($ordenstypObj)) { if (!$this->request->hasArgument('ordenstyp')) { $this->throwStatus(400, 'Ordenstyp not provided', null); } $ordenstypObj->setOrdenstyp($this->request->getArgument('ordenstyp')); $this->ordenstypRepository->add($ordenstypObj); $this->persistenceManager->persistAll(); $this->throwStatus(201, null, 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; } }