Commit 12f249d1 authored by dj3c1t's avatar dj3c1t

import.previous.version: make waveforms

parent fc12311f
......@@ -90,7 +90,6 @@ class ImportPreviousVersion {
$this->importSources();
$this->importSourcesCompositions();
$this->importSourcesOrders();
$this->importDocuments();
$this->importDerivations();
}
......@@ -292,6 +291,7 @@ class ImportPreviousVersion {
$this->log("import sources");
$em = $this->container->get('doctrine')->getManager();
$sm = $this->container->get('sourceml.source_manager');
$sw = $this->container->get('sourceml.source_waveform');
$authorRepo = $em->getRepository('Dj3c1tSourceMLBundle:Author');
$licenceRepo = $em->getRepository('Dj3c1tSourceMLBundle:Licence');
$authorRoleRepo = $em->getRepository('Dj3c1tSourceMLBundle:AuthorRole');
......@@ -411,6 +411,28 @@ class ImportPreviousVersion {
$this->log("WARNING skiping source logo for : ".$mw_source["titre"]);
}
}
if(($mw_documents = $this->mw_data->source_documents($mw_source["id"])) === false) {
$this->log("can't load source documents for source: ".$mw_source["id"]);
$this->log("WARNING skiping source documents for source: ".$mw_source["titre"]);
}
else {
foreach($mw_documents as $mw_document) {
$sourceDocument = new SourceDocument();
$sourceDocument->setSource($source);
$sourceDocument->setName($mw_document["nom"]);
$sourceDocument->setUrl($mw_document["url"]);
$em->persist($sourceDocument);
$source->addDocument($sourceDocument);
try {
$sw->updateWaveform($source);
}
catch(\Exception $e) {
}
}
if($mw_documents) {
$em->flush();
}
}
}
}
......@@ -520,41 +542,6 @@ class ImportPreviousVersion {
}
// ----------------------------------------------------------------------
// documents
//
public function importDocuments() {
$this->log("import documents");
$em = $this->container->get('doctrine')->getManager();
$sm = $this->container->get('sourceml.source_manager');
$sourceRepo = $em->getRepository("Dj3c1tSourceMLBundle:Source");
if(($sources = $this->mw_data->sources(array())) === false) {
$this->error("can't load sources from mw_data");
}
foreach($sources["list"] as $mw_source) {
if(!($source = $sourceRepo->find($mw_source["id"]))) {
$this->log("can't load source: ".$mw_source["id"]);
$this->log("WARNING skiping source documents for source: ".$mw_source["titre"]);
continue;
}
if(($mw_documents = $this->mw_data->source_documents($mw_source["id"])) === false) {
$this->log("can't load source documents for source: ".$mw_source["id"]);
$this->log("WARNING skiping source documents for source: ".$mw_source["titre"]);
continue;
}
foreach($mw_documents as $mw_document) {
$sourceDocument = new SourceDocument();
$sourceDocument->setSource($source);
$sourceDocument->setName($mw_document["nom"]);
$sourceDocument->setUrl($mw_document["url"]);
$em->persist($sourceDocument);
$source->addDocument($sourceDocument);
}
}
$em->flush();
}
// ----------------------------------------------------------------------
// utils
//
......
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