function it_finds_an_array_of_all_columns_based_on_a_schema_id_in_display_order() { $schema = \SchemaPeer::retrieveByPK(1); $schema->setLanguages(['en','fr']); $schema->save(); /** @var \ImportVocab\ExportVocab $this */ $this->setAsTemplate(true); $columns = $this->getSchema()->getAllProfileProperties(); $columns->shouldHaveCount( 26 ); $columns[1]['profile']->shouldHaveType( 'ProfileProperty' ); $columns[9]['count']->shouldEqual( 1 ); $columns[3]['languages']['en']->shouldEqual( 1 ); $columns[3]['languages']['fr']->shouldEqual( 1 ); $id = \ProfilePropertyPeer::retrieveByPK( 9 )->getId(); $columns[12]['id']->shouldEqual( $id ); }
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(); } } } } } }
/** * @param int $profileId The id of the application profile. defaults to '1' * * @return ProfileProperty[] */ public static function getPropertyArray($profileId = 1) { //init the array /** @var ProfileProperty[] $propArray */ $propArray = []; //get the profile properties $c = new Criteria(); $c->add(ProfilePropertyPeer::PROFILE_ID, $profileId); /** @var ProfileProperty[] $ProfileProps */ $ProfileProps = ProfilePropertyPeer::doSelect($c); foreach ($ProfileProps as $prop) { $propArray[$prop->getId()] = $prop; } //todo: figure out a better way to set the rdf:type property. probably in the data /** This is the id of rdf:type, which isn't used directly */ $propArray[4]->setName("@type"); $propArray[4]->setLabel("@type"); return $propArray; }
/** * @param $foo * @return array */ protected static function buildColumnArray( $foo ) { $bar = array(); if ( count( $foo ) ) { foreach ( $foo as $value ) { foreach ( $value as $key => $langArray ) { /** @var \ProfileProperty $profile */ $profile = \ProfilePropertyPeer::retrieveByPK( $key ); $order = $profile->getExportOrder(); $bar[$order]['profile'] = $profile; $bar[$order]['id'] = $key; foreach ( $langArray as $lang => $count ) { if ( $profile->getHasLanguage() ) { if ( ! isset( $bar[$order]['languages'][$lang] ) ) { $bar[$order]['languages'][$lang] = 1; } else if ( $bar[$order]['languages'][$lang] < $count ) { $bar[$order]['languages'][$lang] = $count; } } else { if ( ! isset( $bar[$order]['count'] ) ) { $bar[$order]['count'] = 1; } else if ( $bar[$order]['count'] < $count ) { $bar[$order]['count'] = $count; } } } } } } ksort($bar, SORT_NUMERIC); return $bar; }
/** * updates/creates/deletes the reciprocal property * * @param string $action * @param int $userId * @param int $schemaId * @param Connection $con * * @throws \PropelException */ public function updateReciprocal($action, $userId, $schemaId, $con = null) { $inverseProfilePropertyId = $this->getProfileProperty()->getInverseProfilePropertyId(); if (empty($inverseProfilePropertyId) and $this->getProfileProperty()->getIsReciprocal()) { $inverseProfilePropertyId = $this->getProfileProperty()->getId(); } if (!$inverseProfilePropertyId) { //there's no reciprocal or inverse to process return; } $relatedPropertyId = $this->getRelatedSchemaPropertyId(); if (!$relatedPropertyId) { $relatedProperty = SchemaPropertyPeer::retrieveByUri($this->getObject()); if (!$relatedProperty) { //there's no related property in the registry return; } else { $relatedPropertyId = $relatedProperty->getId(); $this->setRelatedSchemaPropertyId($relatedPropertyId); $this->save(); } } $schemaPropertyID = $this->getSchemaPropertyId(); $property = $this->getSchemaPropertyRelatedBySchemaPropertyId(); //does the user have editorial rights to the reciprocal... $permission = false; //get the maintainers of the reciprocal property $maintainers = $property->getSchema()->getMaintainerIds(); foreach ($maintainers as $maintainerId) { if ($userId == $maintainerId) { $permission = true; break; } } if (false === $permission) { return; } $c = new Criteria(); $c->add(SchemaPropertyElementPeer::SCHEMA_PROPERTY_ID, $relatedPropertyId); $c->add(SchemaPropertyElementPeer::PROFILE_PROPERTY_ID, $inverseProfilePropertyId); $c->add(SchemaPropertyElementPeer::OBJECT, $property->getUri()); $recipElement = SchemaPropertyElementPeer::doSelectOne($c, $con); $recipSchemaProperty = SchemaPropertyPeer::retrieveByPK($relatedPropertyId, $con); $recipProfileProperty = ProfilePropertyPeer::retrieveByPK($inverseProfilePropertyId, $con); $statusId = $this->getStatusId(); $language = ''; if ($recipProfileProperty) { $recipField = $recipProfileProperty->getName(); if ($recipProfileProperty->getHasLanguage()) { $language = $this->getLanguage(); } } //if action == deleted then if ('deleted' == $action && $recipElement) { //delete the reciprocal $recipElement->delete($con); return; } //undelete the element if it's deleted and we get this far if (isset($recipElement)) { $recipElement->setDeletedAt(null); } //if action == added, and reciprocal doesn't exist if ('added' == $action && !$recipElement) { //add the reciprocal $recipElement = SchemaPropertyElementPeer::createElement($recipSchemaProperty, $userId, $inverseProfilePropertyId, $statusId, $language, false, true); } //if action == updated if ('updated' == $action) { //check to see if there's a reciprocal if (!$recipElement) { //create a new one $recipElement = SchemaPropertyElementPeer::createElement($recipSchemaProperty, $userId, $inverseProfilePropertyId, $statusId, $language, false, true); } } if ($recipElement) { if (isset($this->importId)) { $recipElement->importId = $this->importId; } $recipElement->setUpdatedUserId($userId); $recipElement->setRelatedSchemaPropertyId($schemaPropertyID); $recipElement->setObject($this->getSchemaPropertyRelatedBySchemaPropertyId()->getUri()); $recipElement->save($con); } return; }
/** * Selects a collection of SchemaPropertyElementHistory objects pre-filled with all related objects except FileImportHistory. * * @return array Array of SchemaPropertyElementHistory objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptFileImportHistory(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); } SchemaPropertyElementHistoryPeer::addSelectColumns($c); $startcol2 = SchemaPropertyElementHistoryPeer::NUM_COLUMNS - SchemaPropertyElementHistoryPeer::NUM_LAZY_LOAD_COLUMNS + 1; UserPeer::addSelectColumns($c); $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; SchemaPropertyElementPeer::addSelectColumns($c); $startcol4 = $startcol3 + SchemaPropertyElementPeer::NUM_COLUMNS; SchemaPropertyPeer::addSelectColumns($c); $startcol5 = $startcol4 + SchemaPropertyPeer::NUM_COLUMNS; SchemaPeer::addSelectColumns($c); $startcol6 = $startcol5 + SchemaPeer::NUM_COLUMNS; ProfilePropertyPeer::addSelectColumns($c); $startcol7 = $startcol6 + ProfilePropertyPeer::NUM_COLUMNS; SchemaPropertyPeer::addSelectColumns($c); $startcol8 = $startcol7 + SchemaPropertyPeer::NUM_COLUMNS; StatusPeer::addSelectColumns($c); $startcol9 = $startcol8 + StatusPeer::NUM_COLUMNS; $c->addJoin(SchemaPropertyElementHistoryPeer::CREATED_USER_ID, UserPeer::ID); $c->addJoin(SchemaPropertyElementHistoryPeer::SCHEMA_PROPERTY_ELEMENT_ID, SchemaPropertyElementPeer::ID); $c->addJoin(SchemaPropertyElementHistoryPeer::SCHEMA_PROPERTY_ID, SchemaPropertyPeer::ID); $c->addJoin(SchemaPropertyElementHistoryPeer::SCHEMA_ID, SchemaPeer::ID); $c->addJoin(SchemaPropertyElementHistoryPeer::PROFILE_PROPERTY_ID, ProfilePropertyPeer::ID); $c->addJoin(SchemaPropertyElementHistoryPeer::RELATED_SCHEMA_PROPERTY_ID, SchemaPropertyPeer::ID); $c->addJoin(SchemaPropertyElementHistoryPeer::STATUS_ID, StatusPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = SchemaPropertyElementHistoryPeer::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->addSchemaPropertyElementHistory($obj1); break; } } if ($newObject) { $obj2->initSchemaPropertyElementHistorys(); $obj2->addSchemaPropertyElementHistory($obj1); } $omClass = SchemaPropertyElementPeer::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->getSchemaPropertyElement(); //CHECKME if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { $newObject = false; $temp_obj3->addSchemaPropertyElementHistory($obj1); break; } } if ($newObject) { $obj3->initSchemaPropertyElementHistorys(); $obj3->addSchemaPropertyElementHistory($obj1); } $omClass = SchemaPropertyPeer::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->getSchemaPropertyRelatedBySchemaPropertyId(); //CHECKME if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) { $newObject = false; $temp_obj4->addSchemaPropertyElementHistoryRelatedBySchemaPropertyId($obj1); break; } } if ($newObject) { $obj4->initSchemaPropertyElementHistorysRelatedBySchemaPropertyId(); $obj4->addSchemaPropertyElementHistoryRelatedBySchemaPropertyId($obj1); } $omClass = SchemaPeer::getOMClass(); $cls = Propel::import($omClass); $obj5 = new $cls(); $obj5->hydrate($rs, $startcol5); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj5 = $temp_obj1->getSchema(); //CHECKME if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) { $newObject = false; $temp_obj5->addSchemaPropertyElementHistory($obj1); break; } } if ($newObject) { $obj5->initSchemaPropertyElementHistorys(); $obj5->addSchemaPropertyElementHistory($obj1); } $omClass = ProfilePropertyPeer::getOMClass(); $cls = Propel::import($omClass); $obj6 = new $cls(); $obj6->hydrate($rs, $startcol6); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj6 = $temp_obj1->getProfileProperty(); //CHECKME if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) { $newObject = false; $temp_obj6->addSchemaPropertyElementHistory($obj1); break; } } if ($newObject) { $obj6->initSchemaPropertyElementHistorys(); $obj6->addSchemaPropertyElementHistory($obj1); } $omClass = SchemaPropertyPeer::getOMClass(); $cls = Propel::import($omClass); $obj7 = new $cls(); $obj7->hydrate($rs, $startcol7); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj7 = $temp_obj1->getSchemaPropertyRelatedByRelatedSchemaPropertyId(); //CHECKME if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) { $newObject = false; $temp_obj7->addSchemaPropertyElementHistoryRelatedByRelatedSchemaPropertyId($obj1); break; } } if ($newObject) { $obj7->initSchemaPropertyElementHistorysRelatedByRelatedSchemaPropertyId(); $obj7->addSchemaPropertyElementHistoryRelatedByRelatedSchemaPropertyId($obj1); } $omClass = StatusPeer::getOMClass(); $cls = Propel::import($omClass); $obj8 = new $cls(); $obj8->hydrate($rs, $startcol8); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj8 = $temp_obj1->getStatus(); //CHECKME if ($temp_obj8->getPrimaryKey() === $obj8->getPrimaryKey()) { $newObject = false; $temp_obj8->addSchemaPropertyElementHistory($obj1); break; } } if ($newObject) { $obj8->initSchemaPropertyElementHistorys(); $obj8->addSchemaPropertyElementHistory($obj1); } $results[] = $obj1; } return $results; }
/** * Get the associated ProfileProperty object * * @param Connection Optional Connection object. * @return ProfileProperty The associated ProfileProperty object. * @throws PropelException */ public function getProfileProperty($con = null) { if ($this->aProfileProperty === null && $this->profile_property_id !== null) { // include the related Peer class include_once 'lib/model/om/BaseProfilePropertyPeer.php'; $this->aProfileProperty = ProfilePropertyPeer::retrieveByPK($this->profile_property_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 = ProfilePropertyPeer::retrieveByPK($this->profile_property_id, $con); $obj->addProfilePropertys($this); */ } return $this->aProfileProperty; }
/** * 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(ProfilePropertyPeer::ID, $pks, Criteria::IN); $objs = ProfilePropertyPeer::doSelect($criteria, $con); } return $objs; }
/** * Retrieve a single object by pkey. * * @param $skosId int * @param Connection $con the connection to use * @return ProfileProperty * @throws PropelException */ public static function retrieveBySkosID($skosId, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(ProfilePropertyPeer::DATABASE_NAME); $criteria->add(ProfilePropertyPeer::SKOS_ID, $skosId); $v = ProfilePropertyPeer::doSelect($criteria, $con); return !empty($v) > 0 ? $v[0] : null; }
/** * Selects a collection of ConceptProperty objects pre-filled with all related objects except Status. * * @return array Array of ConceptProperty objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptStatus(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); } ConceptPropertyPeer::addSelectColumns($c); $startcol2 = ConceptPropertyPeer::NUM_COLUMNS - ConceptPropertyPeer::NUM_LAZY_LOAD_COLUMNS + 1; UserPeer::addSelectColumns($c); $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS; UserPeer::addSelectColumns($c); $startcol4 = $startcol3 + UserPeer::NUM_COLUMNS; ConceptPeer::addSelectColumns($c); $startcol5 = $startcol4 + ConceptPeer::NUM_COLUMNS; ProfilePropertyPeer::addSelectColumns($c); $startcol6 = $startcol5 + ProfilePropertyPeer::NUM_COLUMNS; VocabularyPeer::addSelectColumns($c); $startcol7 = $startcol6 + VocabularyPeer::NUM_COLUMNS; ConceptPeer::addSelectColumns($c); $startcol8 = $startcol7 + ConceptPeer::NUM_COLUMNS; ProfilePropertyPeer::addSelectColumns($c); $startcol9 = $startcol8 + ProfilePropertyPeer::NUM_COLUMNS; $c->addJoin(ConceptPropertyPeer::CREATED_USER_ID, UserPeer::ID); $c->addJoin(ConceptPropertyPeer::UPDATED_USER_ID, UserPeer::ID); $c->addJoin(ConceptPropertyPeer::CONCEPT_ID, ConceptPeer::ID); $c->addJoin(ConceptPropertyPeer::SKOS_PROPERTY_ID, ProfilePropertyPeer::SKOS_ID); $c->addJoin(ConceptPropertyPeer::SCHEME_ID, VocabularyPeer::ID); $c->addJoin(ConceptPropertyPeer::RELATED_CONCEPT_ID, ConceptPeer::ID); $c->addJoin(ConceptPropertyPeer::PROFILE_PROPERTY_ID, ProfilePropertyPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = ConceptPropertyPeer::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->getUserRelatedByCreatedUserId(); //CHECKME if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addConceptPropertyRelatedByCreatedUserId($obj1); break; } } if ($newObject) { $obj2->initConceptPropertysRelatedByCreatedUserId(); $obj2->addConceptPropertyRelatedByCreatedUserId($obj1); } $omClass = UserPeer::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->getUserRelatedByUpdatedUserId(); //CHECKME if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { $newObject = false; $temp_obj3->addConceptPropertyRelatedByUpdatedUserId($obj1); break; } } if ($newObject) { $obj3->initConceptPropertysRelatedByUpdatedUserId(); $obj3->addConceptPropertyRelatedByUpdatedUserId($obj1); } $omClass = ConceptPeer::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->getConceptRelatedByConceptId(); //CHECKME if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) { $newObject = false; $temp_obj4->addConceptPropertyRelatedByConceptId($obj1); break; } } if ($newObject) { $obj4->initConceptPropertysRelatedByConceptId(); $obj4->addConceptPropertyRelatedByConceptId($obj1); } $omClass = ProfilePropertyPeer::getOMClass(); $cls = Propel::import($omClass); $obj5 = new $cls(); $obj5->hydrate($rs, $startcol5); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj5 = $temp_obj1->getProfilePropertyRelatedBySkosPropertyId(); //CHECKME if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) { $newObject = false; $temp_obj5->addConceptPropertyRelatedBySkosPropertyId($obj1); break; } } if ($newObject) { $obj5->initConceptPropertysRelatedBySkosPropertyId(); $obj5->addConceptPropertyRelatedBySkosPropertyId($obj1); } $omClass = VocabularyPeer::getOMClass(); $cls = Propel::import($omClass); $obj6 = new $cls(); $obj6->hydrate($rs, $startcol6); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj6 = $temp_obj1->getVocabulary(); //CHECKME if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) { $newObject = false; $temp_obj6->addConceptProperty($obj1); break; } } if ($newObject) { $obj6->initConceptPropertys(); $obj6->addConceptProperty($obj1); } $omClass = ConceptPeer::getOMClass(); $cls = Propel::import($omClass); $obj7 = new $cls(); $obj7->hydrate($rs, $startcol7); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj7 = $temp_obj1->getConceptRelatedByRelatedConceptId(); //CHECKME if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) { $newObject = false; $temp_obj7->addConceptPropertyRelatedByRelatedConceptId($obj1); break; } } if ($newObject) { $obj7->initConceptPropertysRelatedByRelatedConceptId(); $obj7->addConceptPropertyRelatedByRelatedConceptId($obj1); } $omClass = ProfilePropertyPeer::getOMClass(); $cls = Propel::import($omClass); $obj8 = new $cls(); $obj8->hydrate($rs, $startcol8); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj8 = $temp_obj1->getProfilePropertyRelatedByProfilePropertyId(); //CHECKME if ($temp_obj8->getPrimaryKey() === $obj8->getPrimaryKey()) { $newObject = false; $temp_obj8->addConceptPropertyRelatedByProfilePropertyId($obj1); break; } } if ($newObject) { $obj8->initConceptPropertysRelatedByProfilePropertyId(); $obj8->addConceptPropertyRelatedByProfilePropertyId($obj1); } $results[] = $obj1; } return $results; }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this ProfileProperty is new, it will return * an empty collection; or if this ProfileProperty has previously * been saved, it will retrieve related ProfilePropertysRelatedByInverseProfilePropertyId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in ProfileProperty. */ public function getProfilePropertysRelatedByInverseProfilePropertyIdJoinStatus($criteria = null, $con = null) { // include the Peer class include_once 'lib/model/om/BaseProfilePropertyPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collProfilePropertysRelatedByInverseProfilePropertyId === null) { if ($this->isNew()) { $this->collProfilePropertysRelatedByInverseProfilePropertyId = array(); } else { $criteria->add(ProfilePropertyPeer::INVERSE_PROFILE_PROPERTY_ID, $this->getId()); $this->collProfilePropertysRelatedByInverseProfilePropertyId = ProfilePropertyPeer::doSelectJoinStatus($criteria, $con); } } else { // 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(ProfilePropertyPeer::INVERSE_PROFILE_PROPERTY_ID, $this->getId()); if (!isset($this->lastProfilePropertyRelatedByInverseProfilePropertyIdCriteria) || !$this->lastProfilePropertyRelatedByInverseProfilePropertyIdCriteria->equals($criteria)) { $this->collProfilePropertysRelatedByInverseProfilePropertyId = ProfilePropertyPeer::doSelectJoinStatus($criteria, $con); } } $this->lastProfilePropertyRelatedByInverseProfilePropertyIdCriteria = $criteria; return $this->collProfilePropertysRelatedByInverseProfilePropertyId; }
/** * Get the associated ProfileProperty object * * @param Connection $con Optional Connection object. * @return ProfileProperty The associated ProfileProperty object. * @throws PropelException */ public function getSkosProperty($con = null) { if ($this->aProfileProperty === null && $this->skos_property_id !== null) { // include the related Peer class include_once 'lib/model/om/BaseProfilePropertyPeer.php'; $c = new \Criteria(); $c->add(\ProfilePropertyPeer::SKOS_ID, $this->skos_property_id); $this->aProfileProperty = ProfilePropertyPeer::doSelect($c, $con); } return $this->aProfileProperty; }
public function executeEdit() { $this->setFlash('vocabID', $this->getVocabularyId()); if ($this->getRequest()->getMethod() == sfRequest::POST) { //before the save... $concept_property = $this->getRequestParameter('concept_property'); /** * @todo the list of skos property types that require a related concept should be in a master configuration array * this applies to the template too **/ //check to see if the skosproperty requires a related concept if (!in_array($concept_property['skos_property_id'], array('3', '16', '21', '32', '33', '34', '35', '36', '37'))) { $concept_property['related_concept_id'] = null; $concept_property['scheme_id'] = null; } $conceptPropertyId = $this->getRequestParameter('id'); $userId = $this->getUser()->getSubscriberId(); //does the user have editorial rights to the reciprocal... $permission = false; if (isset($concept_property['related_concept_id']) and $concept_property['related_concept_id']) { //we want to lookup the URI of the related term $related_concept = ConceptPeer::retrieveByPK($concept_property['related_concept_id']); if ($related_concept) { if ($this->getUser()->hasCredential(array(0 => 'administrator'))) { $permission = true; } else { //get the maintainers of the reciprocal property $maintainers = $related_concept->getVocabulary()->getVocabularyHasUsers(); /** @var VocabularyHasUser $maintainer */ foreach ($maintainers as $maintainer) { if ($userId === $maintainer->getUserId() and $maintainer->getIsMaintainerFor()) { $permission = true; break; } } } } } if ($permission) { if (isset($conceptPropertyId) && $conceptPropertyId) { $this->deleteReciprocalProperty($conceptPropertyId, $concept_property['related_concept_id']); } if (isset($concept_property['related_concept_id']) and $concept_property['related_concept_id']) { //we want to lookup the URI of the related term $related_concept = ConceptPeer::retrieveByPK($concept_property['related_concept_id']); if ($related_concept) { //and overwrite whatever is in the current object TODO: move this into an javascript action in the user interface $concept_property['object'] = $related_concept->getUri(); $this->getRequest()->getParameterHolder()->set('concept_property', $concept_property); } //lookup the inverse id $InverseProfileId = ProfilePropertyPeer::retrieveBySkosID($concept_property['skos_property_id'])->getInverseProfilePropertyId(); $InverseSkosId = ProfilePropertyPeer::retrieveByPK($InverseProfileId)->getSkosId(); //then we create a new reciprocal property in the related term $newProp = new ConceptProperty(); $newProp->setConceptId($concept_property['related_concept_id']); $newProp->setSkosPropertyId($InverseSkosId); $newProp->setSchemeId($this->concept->getVocabularyId()); $newProp->setRelatedConceptId($this->concept->GetId()); $newProp->setObject($this->concept->getUri()); $newProp->setStatusId($concept_property['status_id']); $newProp->setIsGenerated(true); $newProp->setCreatedUserId($this->getUser()->getSubscriberId()); $newProp->setUpdatedUserId($this->getUser()->getSubscriberId()); //TODO: make this the user's default language (actually the language is not relevant when defining relationships) //$newProp->setLanguage($this->concept->getLanguage()); $newProp->setLanguage(''); $concept_property['language'] = ''; $newProp->save(); } } //save the array back to the request parameter $this->requestParameterHolder->set('concept_property', $concept_property); } parent::executeEdit(); }