/** * transform * * @param KVDthes_Term $thes * @return EasyRdf_Resource */ public function transform(KVDthes_Term $thes) { if ($thes->isNull()) { throw new InvalidArgumentException('Een nullobject kan niet geserialiseerd worden!'); } if ($thes->getType()->getId() != 'HR') { throw new InvalidArgumentException('Om een thesaurus te kunnen serialiseren hebben we de HR term nodig.'); } $term = $thes; $thes = $term->getThesaurus(); $type = 'skos:ConceptScheme'; try { $uri = $this->genThesaurusUri($thes); $res = $this->graph->resource($uri, $type); } catch (InvalidArgumentException $e) { $res = $this->graph->newBNode($type); } $res->add('skos:prefLabel', $thes->getNaam()); $res->add('dc:title', $thes->getNaam()); $res->add('dc:language', $thes->getLanguage()); if ($term->hasNTRelations()) { $term->sortRelations(KVDthes_TermSorter::SORT_ID); $rels = $term->getNarrowerTerms(); foreach ($rels as $rel) { $tt = $this->graph->resource($this->genTermUri($rel)); $res->add('skos:hasTopConcept', $tt); } } return $res; }
/** * 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(); }
public function testIsNull() { $this->assertFalse($this->object->isNull()); $niets = KVDthes_TestTerm::newNull(); $this->assertTrue($niets->isNull()); }