public function executeList() { $idType = $this->getRequestParameter('IdType', null); $id = $this->getRequestParameter('id', null); if (!$idType) { //a current schema is required to be in the request URL myActionTools::requireSchemaFilter(); } else { $this->getRequest()->getParameterHolder()->set($idType, $id); } $schema = myActionTools::findCurrentSchema(); if ($schema) { $this->schema = $schema; $schemaId = $schema->getId(); } else { $import = FileImportHistoryPeer::retrieveByPK($id); if ($import) { $this->schema = $import->getSchema(); $schemaId = $this->schema->getId(); } } if (in_array($idType, array('schema_property_id', 'schema_property_element_id'))) { $property = myActionTools::findCurrentSchemaProperty(); if ($property) { $this->property = $property; $this->setFlash('hasProperty', true); $schemaId = $this->property->getSchemaId(); } } //get the versions array $c = new Criteria(); $c->add(SchemaHasVersionPeer::SCHEMA_ID, $schemaId); $versions = SchemaHasVersionPeer::doSelect($c); $this->setFlash('versions', $versions); parent::executeList(); }
public function executeList() { $idType = $this->getRequestParameter('IdType', null); $id = $this->getRequestParameter('id', null); if (!$idType) { //a current vocabulary is required to be in the request URL myActionTools::requireVocabularyFilter(); } else { $this->getRequest()->getParameterHolder()->set($idType, $id); } if ($idType !== 'import_id') { $vocabulary = myActionTools::findCurrentVocabulary(); $this->vocabulary = $vocabulary; if (in_array($idType, array('concept_id', 'property_id'))) { $this->concept = myActionTools::findCurrentConcept(); $this->setFlash('hasConcept', true); } } else { $import = FileImportHistoryPeer::retrieveByPK($id); if ($import) { $vocabulary = $import->getVocabulary(); $this->vocabulary = $vocabulary; } } //get the versions array $c = new Criteria(); $c->add(VocabularyHasVersionPeer::VOCABULARY_ID, $vocabulary->getId()); $versions = VocabularyHasVersionPeer::doSelect($c); $this->setFlash('versions', $versions); parent::executeList(); }
$objectId = $file_import_history->getVocabularyId(); $showVocabularyBc = true; $showVocabularyImportBc = true; //$tab = 'vocabulary'; } } $title = ''; break; case 'importlist': $showBc = true; $tab = false; /** @var \FileImportHistory $file_import_history */ if (!isset($file_import_history)) { $id = 'show' == $action ? $sf_params->get('id') : $paramId; if ($id) { $file_import_history = FileImportHistoryPeer::retrieveByPK($id); } } if ($file_import_history) { if ($file_import_history->getSchemaId() and !isset($schema)) { $schema = $file_import_history->getSchema(); $objectId = $file_import_history->getSchemaId(); $showSchemaBc = true; $showSchemaImportBc = true; //$tab = 'schema'; } if ($file_import_history->getVocabularyId() and !isset($vocabulary)) { $vocabulary = $file_import_history->getVocabulary(); $objectId = $file_import_history->getVocabularyId(); $showVocabularyBc = true; $showVocabularyImportBc = true;
/** * Get the associated FileImportHistory object * * @param Connection Optional Connection object. * @return FileImportHistory The associated FileImportHistory object. * @throws PropelException */ public function getFileImportHistory($con = null) { if ($this->aFileImportHistory === null && $this->import_id !== null) { // include the related Peer class include_once 'lib/model/om/BaseFileImportHistoryPeer.php'; $this->aFileImportHistory = FileImportHistoryPeer::retrieveByPK($this->import_id, $con); /* The following can be used instead of the line above to guarantee the related object contains a reference to this object, but this level of coupling may be undesirable in many circumstances. As it can lead to a db query with many results that may never be used. $obj = FileImportHistoryPeer::retrieveByPK($this->import_id, $con); $obj->addFileImportHistorys($this); */ } return $this->aFileImportHistory; }
public function perform($args) { list($schemaId, $filePath, $importId, $environment, $type) = $args; // Set up environment for this job define('SF_ROOT_DIR', realpath(dirname(__file__) . '/../../../..')); define('SF_APP', 'frontend'); define('SF_ENVIRONMENT', $environment); define('SF_DEBUG', false); //initialize composer require_once(SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'); // initialize symfony require_once(SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'); // initialize database manager $databaseManager = new \sfDatabaseManager(); $databaseManager->initialize(); $import = new ImportVocab($type, $filePath, $schemaId); try { $fileImportHistory = \FileImportHistoryPeer::retrieveByPK($importId); } catch (\PropelException $e) { //exit the job with an error throw $e; } try { if ('schema' == $type) { $schema = \SchemaPeer::retrieveByPK($schemaId); } else { $schema = \VocabularyPeer::retrieveByPK($schemaId); } } catch (\PropelException $e) { //exit the job with an error throw $e; } // Perform some job $import->importId = $importId; //todo update the prefixes table with prefixes //todo update the schema table with prefixes $schemaPrefixes = $schema->getPrefixes(); $countSchemaPrefixes = count($schemaPrefixes); /** @var string[] $importPrefixes */ $importPrefixes = $import->prolog['prefix']; foreach ($importPrefixes as $prefix => $url) { if (trim($prefix)) { if ( ! array_key_exists($prefix, $schemaPrefixes)) { $schemaPrefixes[$prefix] = $url; } } } if (count($schemaPrefixes) != $countSchemaPrefixes) { $schema->setPrefixes($schemaPrefixes); $schema->save(); } try { $prolog = $import->processProlog(); $import->processData(); $fileImportHistory->setResults($import->results); $fileImportHistory->setMap($import->mapping); $fileImportHistory->setTotalProcessedCount( $import->DataWorkflowResults->getTotalProcessedCount()); $fileImportHistory->setErrorCount($import->DataWorkflowResults->getErrorCount()); $fileImportHistory->setSuccessCount($import->DataWorkflowResults->getSuccessCount()); $fileImportHistory->setResults('Your file has been imported. It took us: ' . $import->DataWorkflowResults->getElapsed()->format("%h hours; %i minutes; %s seconds")); $fileImportHistory->save(); } catch (\Exception $e) { $fileImportHistory->setResults("There was an error processing the import. Message: " . $e->getMessage()); $fileImportHistory->save(); throw $e; } $agentId = ($fileImportHistory->getSchema()) ? $fileImportHistory->getSchema()->getAgentId() : $fileImportHistory->getVocabulary()->getAgentId(); $newFilePath = \sfConfig::get( 'sf_repos_dir' ) . DIRECTORY_SEPARATOR . 'agents' . DIRECTORY_SEPARATOR . $agentId . DIRECTORY_SEPARATOR . $fileImportHistory->getSourceFileName(); $request = new \myWebRequest(); $result = $request->moveToRepo($filePath, $newFilePath); $schema = \SchemaPeer::retrieveByPK($schemaId); if ($schema) { $schema->setUpdatedAt(time()); $schema->setUpdatedUserId($import->userId); $schema->save(); } unset ($import); unset ($request); unset($databaseManager); }