mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
Revert "start subdef creation after first write meta"
This reverts commit cfa854f307
.
This commit is contained in:
@@ -14,6 +14,8 @@ namespace Alchemy\Phrasea\Border;
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Border\Checker\CheckerInterface;
|
||||
use Alchemy\Phrasea\Border\Attribute\AttributeInterface;
|
||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Alchemy\Phrasea\Metadata\Tag\TfArchivedate;
|
||||
use Alchemy\Phrasea\Metadata\Tag\TfQuarantine;
|
||||
@@ -110,9 +112,6 @@ class Manager
|
||||
|
||||
if (($visa->isValid() || $forceBehavior === self::FORCE_RECORD) && $forceBehavior !== self::FORCE_LAZARET) {
|
||||
|
||||
// Write UUID
|
||||
$file->getUUID(false, true);
|
||||
|
||||
$this->addMediaAttributes($file);
|
||||
|
||||
$element = $this->createRecord($file, $nosubdef);
|
||||
@@ -120,14 +119,14 @@ class Manager
|
||||
$code = self::RECORD_CREATED;
|
||||
} else {
|
||||
|
||||
// Write UUID
|
||||
$file->getUUID(false, true);
|
||||
|
||||
$element = $this->createLazaret($file, $visa, $session, $forceBehavior === self::FORCE_LAZARET);
|
||||
|
||||
$code = self::LAZARET_CREATED;
|
||||
}
|
||||
|
||||
// Write UUID
|
||||
$file->getUUID(false, true);
|
||||
|
||||
if (is_callable($callable)) {
|
||||
$callable($element, $visa, $code);
|
||||
}
|
||||
@@ -333,11 +332,11 @@ class Manager
|
||||
}
|
||||
}
|
||||
|
||||
if ($nosubdef) {
|
||||
$element->setNoSubdef();
|
||||
}
|
||||
$this->app['phraseanet.metadata-setter']->replaceMetadata($newMetadata, $element);
|
||||
|
||||
$this->app['phraseanet.metadata-setter']->replaceMetadata($newMetadata, $element, true, $nosubdef);// true for $isNewRecord
|
||||
if(!$nosubdef) {
|
||||
$this->app['dispatcher']->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($element, true));
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
@@ -11,31 +11,6 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Event\Record;
|
||||
|
||||
use Alchemy\Phrasea\Model\RecordInterface;
|
||||
|
||||
class MetadataChangedEvent extends RecordEvent
|
||||
{
|
||||
private $isNewRecord;
|
||||
private $nosubdef;
|
||||
|
||||
public function __construct(RecordInterface $record, $isNewRecord = false, $nosubdef = false)
|
||||
{
|
||||
parent::__construct($record);
|
||||
|
||||
$this->isNewRecord = $isNewRecord;
|
||||
$this->nosubdef = $nosubdef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNewRecord()
|
||||
{
|
||||
return $this->isNewRecord;
|
||||
}
|
||||
|
||||
public function isNosubdef()
|
||||
{
|
||||
return $this->nosubdef;
|
||||
}
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ class PhraseanetMetadataSetter
|
||||
* @param \record_adapter $record
|
||||
* @throws \Exception_InvalidArgument
|
||||
*/
|
||||
public function replaceMetadata($metadataCollection, \record_adapter $record, $isNewRecord = false, $nosubdef = false)
|
||||
public function replaceMetadata($metadataCollection, \record_adapter $record)
|
||||
{
|
||||
$metaStructure = $this->repository->find($record->getDataboxId())->get_meta_structure()->get_elements();
|
||||
|
||||
@@ -82,7 +82,7 @@ class PhraseanetMetadataSetter
|
||||
}
|
||||
|
||||
if (! empty($metadataInRecordFormat)) {
|
||||
$record->set_metadatas($metadataInRecordFormat, true, $isNewRecord, $nosubdef);
|
||||
$record->set_metadatas($metadataInRecordFormat, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,8 +12,6 @@
|
||||
namespace Alchemy\Phrasea\TaskManager\Job;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Core\Event\Record\RecordEvents;
|
||||
use Alchemy\Phrasea\Core\Event\Record\SubdefinitionCreateEvent;
|
||||
use Alchemy\Phrasea\Core\PhraseaTokens;
|
||||
use Alchemy\Phrasea\Metadata\TagFactory;
|
||||
use Alchemy\Phrasea\TaskManager\Editor\WriteMetadataEditor;
|
||||
@@ -71,7 +69,7 @@ class WriteMetadataJob extends AbstractJob
|
||||
foreach ($jobData->getApplication()->getDataboxes() as $databox) {
|
||||
$connection = $databox->get_connection();
|
||||
|
||||
$statement = $connection->prepare('SELECT record_id, coll_id, work, jeton FROM record WHERE (jeton & :token > 0)');
|
||||
$statement = $connection->prepare('SELECT record_id, coll_id, jeton FROM record WHERE (jeton & :token > 0)');
|
||||
$statement->execute(['token' => PhraseaTokens::WRITE_META]);
|
||||
$rs = $statement->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$statement->closeCursor();
|
||||
@@ -205,13 +203,6 @@ class WriteMetadataJob extends AbstractJob
|
||||
'record_id' => $record_id,
|
||||
'token' => PhraseaTokens::WRITE_META,
|
||||
]);
|
||||
|
||||
// write meta for the document is finished
|
||||
// if it's a new record, order to create subdef
|
||||
if (count($record->get_subdefs()) == 3 && count($subdefs) == 1 && isset($subdefs['document']) && $row['work'] != 1) {
|
||||
$this->getDispatcher($jobData->getApplication())->dispatch(RecordEvents::SUBDEFINITION_CREATE, new SubdefinitionCreateEvent($record, true));
|
||||
}
|
||||
|
||||
$statement->closeCursor();
|
||||
}
|
||||
}
|
||||
@@ -226,11 +217,6 @@ class WriteMetadataJob extends AbstractJob
|
||||
return $app['exiftool.writer'];
|
||||
}
|
||||
|
||||
private function getDispatcher(Application $app)
|
||||
{
|
||||
return $app['dispatcher'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \databox $databox
|
||||
* @param string $subdefType
|
||||
|
@@ -1083,7 +1083,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
*
|
||||
* @return record_adapter
|
||||
*/
|
||||
public function set_metadatas(array $metadatas, $force_readonly = false, $isNewRecord = false, $nosubdef = false)
|
||||
public function set_metadatas(array $metadatas, $force_readonly = false)
|
||||
{
|
||||
$databox_descriptionStructure = $this->getDatabox()->get_meta_structure();
|
||||
|
||||
@@ -1108,7 +1108,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
unset($xml);
|
||||
|
||||
$this->write_metas();
|
||||
$this->dispatch(RecordEvents::METADATA_CHANGED, new MetadataChangedEvent($this, $isNewRecord, $nosubdef));
|
||||
$this->dispatch(RecordEvents::METADATA_CHANGED, new MetadataChangedEvent($this));
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -1175,16 +1175,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setNoSubdef()
|
||||
{
|
||||
$this->getDataboxConnection()->executeUpdate(
|
||||
'UPDATE record SET work = 1 WHERE record_id= :record_id',
|
||||
['record_id' => $this->getRecordId()]
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function dispatch($eventName, RecordEvent $event)
|
||||
{
|
||||
$this->app['dispatcher']->dispatch($eventName, $event);
|
||||
|
Reference in New Issue
Block a user