/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Batch has previously * been saved, it will retrieve related FileImportHistorys from storage. * If this Batch is new, it will return * an empty collection or the current collection, the criteria * is ignored on a new object. * * @param Connection $con * @param Criteria $criteria * @throws PropelException */ public function getFileImportHistorys($criteria = null, $con = null) { // include the Peer class include_once 'lib/model/om/BaseFileImportHistoryPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collFileImportHistorys === null) { if ($this->isNew()) { $this->collFileImportHistorys = array(); } else { $criteria->add(FileImportHistoryPeer::BATCH_ID, $this->getId()); FileImportHistoryPeer::addSelectColumns($criteria); $this->collFileImportHistorys = FileImportHistoryPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(FileImportHistoryPeer::BATCH_ID, $this->getId()); FileImportHistoryPeer::addSelectColumns($criteria); if (!isset($this->lastFileImportHistoryCriteria) || !$this->lastFileImportHistoryCriteria->equals($criteria)) { $this->collFileImportHistorys = FileImportHistoryPeer::doSelect($criteria, $con); } } } $this->lastFileImportHistoryCriteria = $criteria; return $this->collFileImportHistorys; }
function run_import_repair($task, $args) { //xdebug_break(); if (count($args) < 1) { throw new Exception('You must provide a batch ID.'); } $batchId = $args[0]; //get the import history for the batchid $criteria = new Criteria(); $criteria->add(\FileImportHistoryPeer::BATCH_ID, $batchId); $batch = \FileImportHistoryPeer::doSelect($criteria); if (empty($batch)) { throw new Exception('Not a valid batch ID.'); } $criteria = new \Criteria(); $criteria->add(\ProfilePropertyPeer::NAME, "isSameAs"); /** @var $profileProperty \ProfileProperty */ $profileProperty = \ProfilePropertyPeer::doSelectOne($criteria); $sameasId = $profileProperty->getId(); //for each one in the list /** @var $history FileImportHistory */ foreach ($batch as $history) { //get result array $results = $history->getResults(); $rows = $results['success']['rows']; $userId = $history->getUserId(); //for each row foreach ($rows as $row) { //get the references /** @var $property \SchemaProperty */ $property = \SchemaPropertyPeer::retrieveByPK($row['id']); /** @var $ref \SchemaProperty */ $ref = \SchemaPropertyPeer::retrieveByUri($property->getParentUri()); if ($property and $ref) { $property->setIsSubpropertyOf($ref->getId()); $property->saveSchemaProperty($userId); } //update the parent property if (isset($row['statements'])) { //for each statement foreach ($row['statements'] as $statement) { //get the references if ($sameasId != $statement['propertyId']) { /** @var $ref \SchemaProperty */ $ref = \SchemaPropertyPeer::retrieveByUri($statement['object']); } else { //ref = the parent $ref = $property; } /** @var $propertyElement \SchemaPropertyElement */ $propertyElement = \SchemaPropertyElementPeer::retrieveByPK($statement['id']); if ($propertyElement and $ref) { $propertyElement->setSchemaPropertyRelatedByRelatedSchemaPropertyId($ref); $propertyElement->save(); } } } } } }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param Connection $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(FileImportHistoryPeer::ID, $pks, Criteria::IN); $objs = FileImportHistoryPeer::doSelect($criteria, $con); } return $objs; }