summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/Exporter/ResourceBuilders/ExternalIdentifierPropertyValueResourceBuilder.php
blob: a27f766f50aea837fef08fb525a9c3b21dbc4e45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

namespace SMW\Exporter\ResourceBuilders;

use SMW\DataValueFactory;
use SMW\DIProperty;
use SMWDataItem as DataItem;
use SMWDIUri as DIUri;
use SMWExpData as ExpData;

/**
 * @private
 *
 * @license GNU GPL v2+
 * @since 2.5
 *
 * @author mwjames
 */
class ExternalIdentifierPropertyValueResourceBuilder extends PropertyValueResourceBuilder {

	/**
	 * @since 2.5
	 *
	 * {@inheritDoc}
	 */
	public function isResourceBuilderFor( DIProperty $property ) {
		return $property->findPropertyTypeID() === '_eid';
	}

	/**
	 * Instead of representing an external identifier as "owl:sameAs", the weaker
	 * declarative axiom "skos:exactMatch" has been chosen to avoid potential
	 * issues with undesirable entailments.
	 *
	 * "skos:exactMatch" has been defined as "... indicating a high degree of
	 * confidence that the concepts can be used interchangeably across a wide
	 * range of information retrieval applications ..."
	 *
	 * @since 2.5
	 *
	 * {@inheritDoc}
	 */
	public function addResourceValue( ExpData $expData, DIProperty $property, DataItem $dataItem ) {

		parent::addResourceValue( $expData, $property, $dataItem );

		$dataValue = DataValueFactory::getInstance()->newDataValueByItem(
			$dataItem,
			$property
		);

		$uri = $dataValue->getUri();

		if ( $uri instanceof DIUri ) {
			$expData->addPropertyObjectValue(
				$this->exporter->getSpecialNsResource( 'skos', 'exactMatch' ),
				$this->exporter->getDataItemExpElement( $uri )
			);
		}
	}

}