Ejemplo n.º 1
0
 /**
  * Delete an Orden entity
  */
 public function deleteAction()
 {
     if ($this->request->hasArgument('uUID')) {
         $uuid = $this->request->getArgument('uUID');
     }
     if (empty($uuid)) {
         $this->throwStatus(400, 'Required uUID not provided', null);
     }
     $klosterordens = count($this->klosterordenRepository->findByOrden($uuid));
     $ordenhasurls = count($this->ordenHasUrlRepository->findByOrden($uuid));
     if ($klosterordens == 0 && $ordenhasurls == 0) {
         $ordenObj = $this->ordenRepository->findByIdentifier($uuid);
         if (!is_object($ordenObj)) {
             $this->throwStatus(400, 'Entity Orden not available', null);
         }
         $this->ordenRepository->remove($ordenObj);
         // Fetch Orden Urls
         $ordenHasUrls = $ordenObj->getOrdenHasUrls();
         if (is_array($ordenHasUrls)) {
             foreach ($ordenHasUrls as $ordenHasUrl) {
                 $this->ordenHasUrlRepository->remove($ordenHasUrl);
             }
         }
         $this->throwStatus(200, null, null);
     } else {
         $this->throwStatus(400, 'Due to dependencies Orden entity could not be deleted', null);
     }
 }
Ejemplo n.º 2
0
 /**
  * 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;
     }
 }