public function testSort() { $rel2 = new KVDthes_Relation(KVDthes_Relation::REL_RT, $this->gebied); $rel3 = new KVDthes_Relation(KVDthes_Relation::REL_RT, $this->locatie); $this->object->addRelation($this->relation); $this->object->addRelation($rel2); $this->object->addRelation($rel3); $this->object->sort(KVDthes_TermSorter::SORT_TERM); $coll = new KVDdom_DomainObjectCollection(array($rel2, $rel3, $this->relation)); $this->assertEquals($coll, $this->object->getImmutableCollection()); $this->object->sort(KVDthes_TermSorter::SORT_SORTKEY); $this->assertEquals($coll, $this->object->getImmutableCollection()); $this->object->sort(KVDthes_TermSorter::SORT_QUALTERM); $this->assertEquals($coll, $this->object->getImmutableCollection()); $this->object->sort(KVDthes_TermSorter::SORT_ID); $coll = new KVDdom_DomainObjectCollection(array($this->relation, $rel2, $rel3)); $this->assertEquals($coll, $this->object->getImmutableCollection()); }
/** * getIterator * * @param KVDthes_Relations $relations * @return KVDthes_RelationsIterator */ public function getIterator(KVDthes_Relations $relations) { return $relations->getNTIterator(); }
/** * setBroaderTerm * * @since 10 apr 2009 * @param KVDthes_Term $term * @return void */ public function setBroaderTerm(KVDthes_Term $term) { if (!$this->isPreferredTerm() && !$term->isNull()) { throw new LogicException('You are trying to set a Broader Term for a term which is not a preferred term.'); } $this->checkRelations(); $it = $this->relations->getBTIterator(); $it->rewind(); if ($it->valid()) { $current = $it->current(); $this->removeRelation($current); } // Indien de term een NullObject is wissen we de bestaande BT relation maar vervangen we die niet door iets nieuws. if (!$term->isNull()) { $this->addRelation(new KVDthes_Relation(KVDthes_Relation::REL_BT, $term)); } $this->markDirty(); }