|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PPP\Wikidata; |
|
4
|
|
|
|
|
5
|
|
|
use DataValues\DataValue; |
|
6
|
|
|
use PPP\DataModel\ResourceNode; |
|
7
|
|
|
use Wikibase\DataModel\Entity\EntityId; |
|
8
|
|
|
use Wikibase\DataModel\Entity\PropertyId; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Annotates intermediate representation with Wikibase |
|
12
|
|
|
* |
|
13
|
|
|
* @licence AGPLv3+ |
|
14
|
|
|
* @author Thomas Pellissier Tanon |
|
15
|
|
|
*/ |
|
16
|
|
|
class WikibaseResourceNode extends ResourceNode { |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var DataValue |
|
20
|
|
|
*/ |
|
21
|
|
|
private $dataValue; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var EntityId|null the subject from which the value is retrieved |
|
25
|
|
|
*/ |
|
26
|
|
|
private $fromSubject; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var PropertyId|null the predicate from which the value is retrieved |
|
30
|
|
|
*/ |
|
31
|
|
|
private $fromPredicate; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param string $value |
|
35
|
|
|
* @param DataValue $dataValue |
|
36
|
|
|
* @param EntityId $fromSubject |
|
37
|
|
|
* @param PropertyId $fromPredicate |
|
38
|
|
|
*/ |
|
39
|
7 |
|
public function __construct($value, DataValue $dataValue, EntityId $fromSubject = null, PropertyId $fromPredicate = null) { |
|
40
|
7 |
|
$this->dataValue = $dataValue; |
|
41
|
7 |
|
$this->fromSubject = $fromSubject; |
|
42
|
7 |
|
$this->fromPredicate = $fromPredicate; |
|
43
|
|
|
|
|
44
|
7 |
|
parent::__construct($value); |
|
45
|
7 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return DataValue |
|
49
|
|
|
*/ |
|
50
|
1 |
|
public function getDataValue() { |
|
51
|
1 |
|
return $this->dataValue; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return EntityId|null |
|
56
|
|
|
*/ |
|
57
|
2 |
|
public function getFromSubject() { |
|
58
|
2 |
|
return $this->fromSubject; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return PropertyId|null |
|
63
|
|
|
*/ |
|
64
|
2 |
|
public function getFromPredicate() { |
|
65
|
2 |
|
return $this->fromPredicate; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @see AbstractNode::equals |
|
70
|
|
|
*/ |
|
71
|
3 |
|
public function equals($target) { |
|
72
|
3 |
|
return $target instanceof self && |
|
73
|
3 |
|
$this->dataValue->equals($target->dataValue); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @see WikibaseResourceNode::equals |
|
78
|
|
|
*/ |
|
79
|
1 |
|
public function getValueType() { |
|
80
|
1 |
|
return 'wikidata-datavalue'; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|