/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = BatchPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setRunTime($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setRunDescription($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setObjectType($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setObjectId($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setEventTime($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setEventType($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setEventDescription($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setRegistryUri($arr[$keys[8]]); } }
/** * Selects a collection of FileImportHistory objects pre-filled with all related objects except Schema. * * @return array Array of FileImportHistory objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptSchema(Criteria $c, $con = null) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } FileImportHistoryPeer::addSelectColumns($c); $startcol2 = FileImportHistoryPeer::NUM_COLUMNS - FileImportHistoryPeer::NUM_LAZY_LOAD_COLUMNS + 1; UserPeer::addSelectColumns($c); $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; VocabularyPeer::addSelectColumns($c); $startcol4 = $startcol3 + VocabularyPeer::NUM_COLUMNS; BatchPeer::addSelectColumns($c); $startcol5 = $startcol4 + BatchPeer::NUM_COLUMNS; $c->addJoin(FileImportHistoryPeer::USER_ID, UserPeer::ID); $c->addJoin(FileImportHistoryPeer::VOCABULARY_ID, VocabularyPeer::ID); $c->addJoin(FileImportHistoryPeer::BATCH_ID, BatchPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = FileImportHistoryPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = UserPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getUser(); //CHECKME if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addFileImportHistory($obj1); break; } } if ($newObject) { $obj2->initFileImportHistorys(); $obj2->addFileImportHistory($obj1); } $omClass = VocabularyPeer::getOMClass(); $cls = Propel::import($omClass); $obj3 = new $cls(); $obj3->hydrate($rs, $startcol3); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj3 = $temp_obj1->getVocabulary(); //CHECKME if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { $newObject = false; $temp_obj3->addFileImportHistory($obj1); break; } } if ($newObject) { $obj3->initFileImportHistorys(); $obj3->addFileImportHistory($obj1); } $omClass = BatchPeer::getOMClass(); $cls = Propel::import($omClass); $obj4 = new $cls(); $obj4->hydrate($rs, $startcol4); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj4 = $temp_obj1->getBatch(); //CHECKME if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) { $newObject = false; $temp_obj4->addFileImportHistory($obj1); break; } } if ($newObject) { $obj4->initFileImportHistorys(); $obj4->addFileImportHistory($obj1); } $results[] = $obj1; } return $results; }
$_SERVER['HTTP_HOST'] = $argv[1]; } if (isset($argv[2])) { $_SERVER['SERVER_NAME'] = $argv[2]; } require_once dirname(__FILE__) . '/../config/arc_config.php'; /* instantiation */ //creates a special registry-extended store, using a custom ARC2::getStore $store = new Reg_ARC2_Store($arc_config, new stdClass()); if (!$store->isSetup()) { $store->setUp(); } //get the batch log $batchTime = time(); $batchDescription = "Updating 3store - " . $_SERVER['HTTP_HOST'] . ": " . $_SERVER['SERVER_NAME']; $batchLog = new BatchPeer(); //get the vocabularies $foo = new VocabularyPeer(); $selectCriteria = new Criteria(VocabularyPeer::DATABASE_NAME); $rs = $foo->doSelect($selectCriteria); $batchObjectType = "vocabulary"; $result = $batchLog->createBatchRecord($batchTime, $batchDescription, $batchObjectType, "Starting Vocabulary run", "init"); //foreach vocabulary /** @var Vocabulary $vocabulary **/ foreach ($rs as $vocabulary) { $query = 'LOAD <http://' . $_SERVER['HTTP_HOST'] . '/vocabulary/show/id/' . $vocabulary->getId() . '.rdf> INTO <' . $vocabulary->getUri() . '>'; $result = $batchLog->createBatchRecord($batchTime, $batchDescription, $batchObjectType, $query, "query", $vocabulary->getId(), $vocabulary->getUri()); $store->clearErrors(); $rs = $store->query($query); if ($errs = $store->getErrors()) { foreach ($errs as $key => $value) {
public function saveResults($batchId = '') { $batchLog = new \BatchPeer(); if ($batchId) { $criteria = new \Criteria(); $criteria->add(\BatchPeer::ID, $batchId); /** @var $batch \Batch */ $batch = $batchLog::doSelectOne($criteria); } if (empty( $batch )) { $batch = $batchLog->createBatchRecord(time(), "manual import from file", "schema", "manual import (testing)", "import", $this->vocabId, $this->vocabulary->getUri()); } //there's a bunch more stuff we should save here $import = new \FileImportHistory(); $import->setFileName($this->file); $import->setFileType($this->type); //todo $this->mapping isn't correct //$import->setMap($this->mapping); $import->setResults($this->results); $import->setUserId($this->userId); $import->setSchemaId($this->vocabId); $import->setBatch($batch); //$import->setBatch($batch); $import->save(); return $batch->getId(); }
/** * Get the associated Batch object * * @param Connection Optional Connection object. * @return Batch The associated Batch object. * @throws PropelException */ public function getBatch($con = null) { if ($this->aBatch === null && $this->batch_id !== null) { // include the related Peer class include_once 'lib/model/om/BaseBatchPeer.php'; $this->aBatch = BatchPeer::retrieveByPK($this->batch_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 = BatchPeer::retrieveByPK($this->batch_id, $con); $obj->addBatchs($this); */ } return $this->aBatch; }
/** * 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(BatchPeer::ID, $pks, Criteria::IN); $objs = BatchPeer::doSelect($criteria, $con); } return $objs; }