Esempio n. 1
0
 /**
  * Gets the vocab element represented by this state instance.
  *
  * @return \Gedcomx\Vocab\VocabElement
  */
 public function getVocabElement()
 {
     $vocabElement = new VocabElement();
     $idQuad = $this->rdfCollection->getPropertyQuad(VocabConstants::DC_NAMESPACE . "identifier");
     $vocabElement->setId(RdfNode::getValue($idQuad->getObject()));
     $vocabElement->setUri(RdfNode::getValue($this->rdfCollection->first()->getSubject()));
     $subclass = $this->rdfCollection->getPropertyQuad(VocabConstants::RDFS_NAMESPACE . "subClassOf");
     if ($subclass != null) {
         $vocabElement->setSubclass(RdfNode::getValue($subclass->getObject()));
     }
     $type = $this->rdfCollection->getPropertyQuad(VocabConstants::DC_NAMESPACE . "type");
     if ($type != null) {
         $vocabElement->setType(RdfNode::getValue($type->getObject()));
     }
     $labels = $this->rdfCollection->quadsMatchingProperty(VocabConstants::RDFS_NAMESPACE . "label");
     if ($labels->count()) {
         foreach ($labels as $label) {
             $node = $label->getObject();
             $vocabElement->addLabel(RdfNode::getValue($node), RdfNode::getLanguage($node));
         }
     }
     $comments = $this->rdfCollection->quadsMatchingProperty(VocabConstants::RDFS_NAMESPACE . "comment");
     if ($comments->count()) {
         foreach ($comments as $comment) {
             $node = $comment->getObject();
             $vocabElement->addDescription(RdfNode::getValue($node), RdfNode::getLanguage($node));
         }
     }
     return $vocabElement;
 }
Esempio n. 2
0
 public function compareTo(VocabElement $o)
 {
     // A position value overrides and trumps sortName
     // Otherwise, compare alphabetically against sortName
     // Then arbitrarily compare on Term Type, Concept, and Id
     $pos = 0;
     $oPosition = $o->getPosition();
     if ($this->position != null) {
         $pos = $oPosition == null ? $this->position : $this->position - $oPosition;
     } else {
         if ($oPosition != null) {
             $pos = $oPosition;
         }
     }
     if ($pos == 0) {
         // Either positions are the same or null
         $pos = $this->sortName == $o->getSortName() ? 1 : 0;
     }
     if ($pos == 0) {
         $pos = $this->type == $o->getType() ? 1 : 0;
     }
     if ($pos == 0) {
         $pos = $this->subclass == $o->getSubclass() ? 1 : 0;
     }
     if ($pos == 0) {
         $pos = $this->uri == $o->getUri() ? 1 : 0;
     }
     return $pos;
 }