Esempio n. 1
0
 /**
  * Creates a record
  *
  * @param  \collection     $collection  The destination collection
  * @param  string          $pathfile    The file to archive
  * @param  string|null     $captionFile The Phrasea XML caption file or null if no caption file
  * @param  integer         $grp_rid     Add the record to a story
  * @param  integer         $force       Force lazaret or record ; use \Alchemy\Phrasea\Border\Manager::FORCE_* constants
  * @return \record_adapter
  */
 public function createRecord(Application $app, \collection $collection, $pathfile, $captionFile, $grp_rid, $force, $stat0, $stat1)
 {
     $status = \databox_status::operation_or($stat0, $stat1);
     $media = $app->getMediaFromUri($pathfile);
     $databox = $collection->get_databox();
     $metadatasStructure = $databox->get_meta_structure();
     $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas());
     $metaFields = [];
     if ($captionFile !== null && true === $app['filesystem']->exists($captionFile)) {
         $metaFields = $this->readXMLForDatabox($app, $metadatasStructure, $captionFile);
         $captionStatus = $this->parseStatusBit(@simplexml_load_file($captionFile));
         if ($captionStatus) {
             $status = \databox_status::operation_mask($status, $captionStatus);
         }
     }
     $file = new File($app, $media, $collection);
     $file->addAttribute(new BorderAttribute\Status($app, $status));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfFilepath(), new MonoValue($media->getFile()->getRealPath()))));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfDirname(), new MonoValue(dirname($media->getFile()->getRealPath())))));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfAtime(), new MonoValue($media->getFile()->getATime()))));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfMtime(), new MonoValue($media->getFile()->getMTime()))));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfCtime(), new MonoValue($media->getFile()->getCTime()))));
     foreach ($metadatas as $meta) {
         $file->addAttribute(new BorderAttribute\Metadata($meta));
     }
     foreach ($metaFields as $metaField) {
         $file->addAttribute($metaField);
     }
     if ($grp_rid) {
         $file->addAttribute(new BorderAttribute\Story(new \record_adapter($app, $databox->get_sbas_id(), $grp_rid)));
     }
     $record = null;
     $postProcess = function ($element, $visa, $code) use(&$record) {
         $record = $element;
     };
     $app['border-manager']->process($this->getLazaretSession($app), $file, $postProcess, $force);
     return $record;
 }
Esempio n. 2
0
 public function testOperation_mask()
 {
     $this->assertEquals('001101', databox_status::operation_mask(self::$DI['app'], '010101', '0011xx'));
     $this->assertEquals('001100', databox_status::operation_mask(self::$DI['app'], '0', '0011xx'));
     $this->assertEquals('001101', databox_status::operation_mask(self::$DI['app'], '1', '0011xx'));
 }