Commit 3aecc197 authored by dj3c1t's avatar dj3c1t

import source dates

parent fe64054c
......@@ -301,7 +301,7 @@ class ImportPreviousVersion {
}
$upload_manager = $this->container->get('dj3c1t_jq_file_upload.upload_manager');
foreach($sources["list"] as $mw_source) {
$this->log("creating new source: ".$mw_source["titre"]);
$this->log("import source: ".$mw_source["titre"]);
$adminAthorInfos = $this->mw_data->get_admin_groupe(
$this->mw_data->source_groupes($mw_source["id"])
);
......@@ -329,6 +329,15 @@ class ImportPreviousVersion {
}
$source->setLicence($licence);
}
if(isset($mw_source["date_creation"]) && $mw_source["date_creation"]) {
try {
$creationDate = new \DateTime($mw_source["date_creation"]);
$source->setCreationDate($creationDate);
}
catch(\Exception $e) {
$this->log("WARNING creation date invalid for: ".$mw_source["titre"]);
}
}
if(isset($mw_source["reference"]["xml"]["url"]) && $mw_source["reference"]["xml"]["url"]) {
$source->setReferenceUrl($mw_source["reference"]["xml"]["url"]);
}
......@@ -350,8 +359,17 @@ class ImportPreviousVersion {
$source->setSourceType($sourceType);
$em->persist($source);
$em->flush();
if(isset($mw_source["date_inscription"]) && $mw_source["date_inscription"]) {
try {
$publicationDate = new \DateTime($mw_source["date_inscription"]);
$source->setPublicationDate($publicationDate);
$em->flush();
}
catch(\Exception $e) {
$this->log("WARNING publication date invalid for: ".$mw_source["titre"]);
}
}
foreach($mw_source["groupes"] as $mw_groupe) {
$this->log("add source author: ".$mw_groupe["nom"]);
if(!($author = $authorRepo->find($mw_groupe["id"]))) {
$this->log("can't find author ".$mw_groupe["id"]);
$this->log("WARNING skiping this author for source : ".$mw_source["titre"]);
......@@ -393,7 +411,6 @@ class ImportPreviousVersion {
$this->log("WARNING skiping source logo for : ".$mw_source["titre"]);
}
}
}
}
......@@ -434,7 +451,6 @@ class ImportPreviousVersion {
}
}
if($hasCompositionsToPersist) {
$this->log("persisting source compositions to database");
$em->flush();
}
}
......@@ -470,7 +486,6 @@ class ImportPreviousVersion {
}
}
}
$this->log("persisting source orders to database");
$em->flush();
}
......@@ -501,7 +516,6 @@ class ImportPreviousVersion {
$em->persist($derivationSource);
$source->addDerivation($derivationSource);
}
$this->log("persisting derivations to database");
$em->flush();
}
......@@ -537,7 +551,6 @@ class ImportPreviousVersion {
$source->addDocument($sourceDocument);
}
}
$this->log("persisting documents to database");
$em->flush();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment