function addConceptWithLabels($bNode, $jsonElement, $dataGraph) { $dataGraph->add_resource_triple($bNode, CONCEPTWIKI_PREFIX . '#uuid', $jsonElement->{'uuid'}); foreach ($jsonElement->{'labels'} as $label) { addLabelWithLanguage($bNode, $label, $dataGraph); } $dataGraph->add_literal_triple($bNode, CONCEPTWIKI_PREFIX . '#deleted', (bool) $jsonElement->{'deleted'} ? 'true' : 'false', null, XSD . 'boolean'); }
$searchType = getSearchType($this->Request->getPathWithoutExtension()); $resultBNode = '_:searchResult'; $this->DataGraph->add_literal_triple($resultBNode, RDF_TYPE, $searchType); $unreservedParameters = $this->Request->getUnreservedParams(); foreach ($unreservedParameters as $name => $value) { $predSuffix = $paramNameToPredicate[$name]; $this->DataGraph->add_literal_triple($resultBNode, OPS_API . '#' . $predSuffix, $value); } //link the resultBNode with the UUIDs and their tags $tagCounter = 0; $urlCounter = 0; foreach ($decodedResponse as $elem) { $uuidNode = CONCEPTWIKI_PREFIX . $elem->{"uuid"}; $this->DataGraph->add_resource_triple($resultBNode, OPS_API . '#result', $uuidNode); foreach ($elem->{"labels"} as $label) { addLabelWithLanguage($uuidNode, $label, $this->DataGraph); } $this->DataGraph->add_literal_triple($uuidNode, OPS_API . '#match', $elem->{'match'}); foreach ($elem->{"tags"} as $tag) { $tagBNode = '_:tagNode' . $tagCounter; $this->DataGraph->add_resource_triple($uuidNode, OPS_API . '#semanticTag', $tagBNode); addConceptWithLabels($tagBNode, $tag, $this->DataGraph); $tagCounter++; } foreach ($elem->{"urls"} as $url) { $urlBNode = '_:urlNode' . $urlCounter; $this->DataGraph->add_resource_triple($uuidNode, SKOS . 'exactMatch', $urlBNode); $this->DataGraph->add_resource_triple($urlBNode, CONCEPTWIKI_PREFIX . '#url', $url->{'value'}); $this->DataGraph->add_resource_triple($urlBNode, CONCEPTWIKI_PREFIX . '#matchType', $url->{'type'}); $urlCounter++; }
$this->DataGraph->add_resource_triple($urlBNode, CONCEPTWIKI_PREFIX . '#matchType', $url->{'type'}); $lastPos = strrpos($url->{'value'}, '#'); if ($lastPos === FALSE) { $lastPos = strrpos($url->{'value'}, '/'); } if ($lastPos === FALSE) { continue; } $codeFromURL = substr($url->{'value'}, $lastPos + 1); foreach ($decodedResponse->{"notations"} as $notation) { if ($notation->{'code'} === $codeFromURL) { foreach ($notation->{'sources'} as $source) { $sourceURL = CONCEPTWIKI_PREFIX . $source->{'uuid'}; $this->DataGraph->add_resource_triple($urlBNode, VOID . 'inDataset', $sourceURL); foreach ($source->{'labels'} as $label) { addLabelWithLanguage($sourceURL, $label, $this->DataGraph); } $this->DataGraph->add_literal_triple($sourceURL, CONCEPTWIKI_PREFIX . '#deleted', (bool) $source->{'deleted'} ? 'true' : 'false', null, XSD . 'boolean'); } break; } } $urlCounter++; } //add notes : skos:definition foreach ($decodedResponse->{"notes"} as $note) { if ($note->{"type"} === 'DEFINITION') { $this->DataGraph->add_literal_triple($conceptWikiURL, SKOS . 'definition', $note->{'text'}); //add language } }