Difference between revisions of "Restore Orphaned Records"

From IVS Wiki
Jump to: navigation, search
(Created page with "To restore records the following step should be performed: 1) Modify file src/FS/CamBundle/Entity/Record.php set @ORM\GeneratedValue(strategy="NONE") for ID field change setId...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
To restore records the following step should be performed:
+
Click the link below for instructions.
1) Modify file src/FS/CamBundle/Entity/Record.php
+
 
set @ORM\GeneratedValue(strategy="NONE") for ID field
+
https://ivs.box.com/s/z9al317378w5io7qlpy3y1j9e4ou044c
change setId() method:
 
public function setId($id)
 
{
 
$this->id = $id;
 
}
 
2) Modify file src/FS/UserBundle/Controller/UpdateController.php
 
add to use directives:
 
use FS\CamBundle\Entity\Record;
 
use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
 
add following method:
 
/**
 
* @Route(path="/restore", name="restore_records")
 
*/
 
public function restoreAction()
 
{
 
$em = $this->getDoctrine()->getManager();
 
$recordsRep = $em->getRepository('FSCamBundle:Record');
 
$videoFolder = '/usr/local/WowzaStreamingEngine/content/ivrv3_recordings/video/';
 
$dirHandle = opendir($videoFolder);
 
while ($file = readdir($dirHandle)) {
 
$filename = $videoFolder . $file;
 
if (is_dir($filename) && $file != '.' && $file != '..' && $file != 'mosaic') {
 
if ($recordsRep->find($file) !== null) {
 
} else {
 
$date = date("Y-m-d H:i:s", filemtime($filename));
 
echo $file . ' ' . $date . ' not found ';
 
$record = new Record();
 
$record->setId($file);
 
$record->setName('Restored Record');
 
$record->setNameTitle('Recording name');
 
$record->setIsCompleted();
 
$record->setStartedAt(new \DateTime($date));
 
$record->setCreatedBy($em->getRepository('FSUserBundle:User')->find(1));
 
$record->setRecordType('record');
 
$record->setRecordPreviewReady(true);
 
$em->persist($record);
 
$this->get('fs_cam.wowza_manager')->makeThumbnailLocalWowza($record);
 
}
 
}
 
}
 
$em->flush();
 
}
 
Be sure to choose correct video folder
 
/usr/local/WowzaStreamingEngine/content/ivrv3_recordings/video/ , change it according to
 
wowza’s recordings folder.
 
3) Then wait while script executes (/update/restore). It may take long time depending on how
 
many records are being restored.
 
4) Restore all code parts back to what they were before
 
Delete use directives, delete restore method, change Id strategy to AUTO. setId method may
 
not be changed back
 

Latest revision as of 08:14, 3 February 2017

Click the link below for instructions.

https://ivs.box.com/s/z9al317378w5io7qlpy3y1j9e4ou044c