public function executePropertylist() { $c = new Criteria(); $c->add(ConceptPropertyPeer::CONCEPT_ID, $this->conceptId); $c->addDescendingOrderByColumn(ConceptPropertyPeer::SKOS_PROPERTY_ID); $this->properties = ConceptPropertyPeer::doSelect($c); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Concept has previously * been saved, it will retrieve related ConceptPropertysRelatedByRelatedConceptId from storage. * If this Concept 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 getConceptPropertysRelatedByRelatedConceptId($criteria = null, $con = null) { // include the Peer class include_once 'lib/model/om/BaseConceptPropertyPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collConceptPropertysRelatedByRelatedConceptId === null) { if ($this->isNew()) { $this->collConceptPropertysRelatedByRelatedConceptId = array(); } else { $criteria->add(ConceptPropertyPeer::RELATED_CONCEPT_ID, $this->getId()); ConceptPropertyPeer::addSelectColumns($criteria); $this->collConceptPropertysRelatedByRelatedConceptId = ConceptPropertyPeer::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(ConceptPropertyPeer::RELATED_CONCEPT_ID, $this->getId()); ConceptPropertyPeer::addSelectColumns($criteria); if (!isset($this->lastConceptPropertyRelatedByRelatedConceptIdCriteria) || !$this->lastConceptPropertyRelatedByRelatedConceptIdCriteria->equals($criteria)) { $this->collConceptPropertysRelatedByRelatedConceptId = ConceptPropertyPeer::doSelect($criteria, $con); } } } $this->lastConceptPropertyRelatedByRelatedConceptIdCriteria = $criteria; return $this->collConceptPropertysRelatedByRelatedConceptId; }
public function execute(&$value, &$error) { $property = $this->getContext()->getRequest()->getParameter('concept_property'); $propertyId = $this->getContext()->getRequest()->getParameter('id'); $conceptId = $this->getContext()->getRequest()->getParameter('concept_id'); $vocabId = $this->getContext()->getUser()->getAttribute('vocabulary')->getId(); //if it's not a prefLabel then we just check for uniqueness in the context of the Concept if ((int) $property['skos_property_id'] !== 19) { $c = new Criteria(); $c->add(ConceptPropertyPeer::CONCEPT_ID, $conceptId); $c->add(ConceptPropertyPeer::LANGUAGE, $property['language']); $c->add(ConceptPropertyPeer::STATUS_ID, $property['status_id']); $c->add(ConceptPropertyPeer::OBJECT, $value); $object = ConceptPropertyPeer::doSelectOne($c); if ($object) { //check to see if the retrieved object has the same id if ($propertyId && $object->getId() == $propertyId) { return true; } else { if ($property['skos_property_id'] != $object->getSkosPropertyId()) { $error = "This Concept already has this label applied to the " . $object->getSkosPropertyName() . " property."; } else { $error = "This Concept already has this exact property."; } return false; } } else { if (!in_array($property['skos_property_id'], array('3', '16', '21', 32, 33, 34, 35, 36, 37))) { $property['related_concept_id'] = null; $property['scheme_id'] = null; //save the array back to the request parameter // $this->requestParameterHolder->set('concept_property', $concept_property); } } } else { //check for no duplicate prefLable in the entire vocabulary $c = new Criteria(); $c->add(ConceptPeer::VOCABULARY_ID, $vocabId); $c->add(ConceptPropertyPeer::LANGUAGE, $property['language']); $c->add(ConceptPropertyPeer::STATUS_ID, $property['status_id']); $c->add(ConceptPropertyPeer::SKOS_PROPERTY_ID, 19); $c->add(ConceptPropertyPeer::OBJECT, $value); $c->addJoin(ConceptPropertyPeer::CONCEPT_ID, ConceptPeer::ID); $object = ConceptPropertyPeer::doSelectOne($c); if ($object) { //check to see if the retrieved object has the same id if ($propertyId && $object->getId() == $propertyId) { return true; } else { $error = "This Vocabulary already has a Concept with a prefLabel with this status and language."; return false; } } $c = new Criteria(); $c->add(ConceptPropertyPeer::CONCEPT_ID, $conceptId); $c->add(ConceptPropertyPeer::LANGUAGE, $property['language']); $c->add(ConceptPropertyPeer::STATUS_ID, $property['status_id']); $c->add(ConceptPropertyPeer::SKOS_PROPERTY_ID, 19); $objects = ConceptPropertyPeer::doSelect($c); if ($objects && ($propertyId && count($objects) > 1 or !$propertyId && count($objects))) { $error = "This Concept already has a prefLabel with this status and language."; return false; } } return true; }
/** * 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(ConceptPropertyPeer::ID, $pks, Criteria::IN); $objs = ConceptPropertyPeer::doSelect($criteria, $con); } return $objs; }
/** * updatedb batch script * * This script is used to update the database data as needed * * @package registry * @subpackage batch * @version $Id$ */ define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..')); define('SF_APP', 'frontend'); define('SF_ENVIRONMENT', 'test'); define('SF_DEBUG', true); 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(); // batch process here //get the concept properties $foo = new ConceptPropertyPeer(); $selectCriteria = new Criteria(VocabularyPeer::DATABASE_NAME); $rs = $foo->doSelect($selectCriteria); foreach ($rs as $conceptProperty) { /** @var ConceptProperty **/ $historys = $conceptProperty->getConceptPropertyHistorys(); if (count($historys) == 0) { debugbreak; } } echo "Done!";