summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/Exporter/ResourceBuilders/UniquenessConstraintPropertyValueResourceBuilder.php
blob: 40d4f55a32f4b7ee09432506f8d8846704dace01 (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
<?php

namespace SMW\Exporter\ResourceBuilders;

use SMW\DIProperty;
use SMWDataItem as DataItem;
use SMWExpData as ExpData;

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

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

	/**
	 * @since 2.5
	 *
	 * {@inheritDoc}
	 */
	public function addResourceValue( ExpData $expData, DIProperty $property, DataItem $dataItem ) {

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

		// https://www.w3.org/TR/2004/REC-owl-ref-20040210/#FunctionalProperty-def
		//
		// "A functional property is a property that can have only one (unique)
		// value y for each instance x ..."

		$expData->addPropertyObjectValue(
			$this->exporter->getSpecialNsResource( 'rdf', 'type' ),
			$this->exporter->getSpecialNsResource( 'owl', 'FunctionalProperty' )
		);
	}

}