protected function updatedTransformMetadataFailed(BatchJob $dbBatchJob, kTransformMetadataJobData $data, BatchJob $twinJob = null) { if (!$data->getMetadataProfileId()) { return $dbBatchJob; } $metadataProfile = MetadataProfilePeer::retrieveById($data->getMetadataProfileId()); if (!$metadataProfile) { return $dbBatchJob; } $metadataProfile->setStatus(MetadataProfile::STATUS_DEPRECATED); $metadataProfile->save(); return $dbBatchJob; }
protected function updatedTransformMetadataFailed(BatchJob $dbBatchJob, kTransformMetadataJobData $data) { if (!$data->getMetadataProfileId()) { return $dbBatchJob; } $metadataProfile = MetadataProfilePeer::retrieveByPK($data->getMetadataProfileId()); if (!$metadataProfile) { return $dbBatchJob; } if ($data->getSrcXslPath()) { $metadataProfile->setStatus(MetadataProfile::STATUS_DEPRECATED); $metadataProfile->save(); } return $dbBatchJob; }
/** * @param int $metadataProfileId * @param int $srcVersion * @param int $destVersion * @param string $xsl * * @return BatchJob */ private static function addTransformMetadataJob($partnerId, $metadataProfileId, $srcVersion, $destVersion, $xsl = null) { // check if any metadata objects require the transform $c = new Criteria(); $c->add(MetadataPeer::METADATA_PROFILE_ID, $metadataProfileId); $c->add(MetadataPeer::METADATA_PROFILE_VERSION, $destVersion, Criteria::LESS_THAN); $c->add(MetadataPeer::STATUS, Metadata::STATUS_VALID); $metadataCount = MetadataPeer::doCount($c); if (!$metadataCount) { return null; } $job = new BatchJob(); $job->setJobType(BatchJobType::METADATA_TRANSFORM); $job->setPartnerId($partnerId); $job->setObjectId($metadataProfileId); $job->setObjectType(kPluginableEnumsManager::apiToCore('BatchJobObjectType', MetadataBatchJobObjectType::METADATA_PROFILE)); $data = new kTransformMetadataJobData(); if ($xsl) { $job->save(); $key = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_CONFIG); kFileSyncUtils::file_put_contents($key, $xsl); $xslPath = kFileSyncUtils::getLocalFilePathForKey($key); $data->setSrcXslPath($xslPath); } $data->setMetadataProfileId($metadataProfileId); $data->setSrcVersion($srcVersion); $data->setDestVersion($destVersion); return kJobsManager::addJob($job, $data, BatchJobType::METADATA_TRANSFORM); }