summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/includes/dataitems/DIConcept.php
blob: ea6cb70c46a178727a4b040d4d75accb265e4ff6 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php

namespace SMW;

use SMWDataItem;

/**
 * This class implements Concept data items.
 *
 * @note These special data items for storing concept declaration data in SMW
 * should vanish at some point since Container values could encode this data
 * just as well.
 *
 * @since 1.6
 *
 * @ingroup SMWDataItems
 *
 * @author Markus Krötzsch
 * @author mwjames
 */
class DIConcept extends \SMWDataItem {

	/**
	 * Query string for this concept. Possibly long.
	 * @var string
	 */
	protected $m_concept;
	/**
	 * Documentation for this concept. Possibly long.
	 * @var string
	 */
	protected $m_docu;
	/**
	 * Flags of query features.
	 * @var integer
	 */
	protected $m_features;
	/**
	 * Size of the query.
	 * @var integer
	 */
	protected $m_size;
	/**
	 * Depth of the query.
	 * @var integer
	 */
	protected $m_depth;

	/**
	 * Status
	 * @var integer
	 */
	protected $cacheStatus;

	/**
	 * Date
	 * @var integer
	 */
	protected $cacheDate;

	/**
	 * Count
	 * @var integer
	 */
	protected $cacheCount;

	/**
	 * @param string $concept the concept query string
	 * @param string $docu user documentation
	 * @param integer $queryefeatures flags about query features
	 * @param integer $size concept query size
	 * @param integer $depth concept query depth
	 */
	public function __construct( $concept, $docu, $queryfeatures, $size, $depth ) {
		$this->m_concept  = $concept;
		$this->m_docu     = $docu;
		$this->m_features = $queryfeatures;
		$this->m_size     = $size;
		$this->m_depth    = $depth;
	}

	public function getDIType() {
		return SMWDataItem::TYPE_CONCEPT;
	}

	public function getConceptQuery() {
		return $this->m_concept;
	}

	public function getDocumentation() {
		return $this->m_docu;
	}

	public function getQueryFeatures() {
		return $this->m_features;
	}

	public function getSize() {
		return $this->m_size;
	}

	public function getDepth() {
		return $this->m_depth;
	}

	public function getSortKey() {
		return $this->m_docu;
	}

	public function getSerialization() {
		return serialize( $this );
	}

	/**
	 * Sets cache status
	 *
	 * @since 1.9
	 *
	 * @param string
	 */
	public function setCacheStatus( $status ) {
		$this->cacheStatus = $status;
	}

	/**
	 * Sets cache date
	 *
	 * @since 1.9
	 *
	 * @param string
	 */
	public function setCacheDate( $date ) {
		$this->cacheDate = $date;
	}

	/**
	 * Sets cache count
	 *
	 * @since 1.9
	 *
	 * @param int
	 */
	public function setCacheCount( $count ) {
		$this->cacheCount = $count;
	}

	/**
	 * Returns cache status
	 *
	 * @since 1.9
	 *
	 * @return string
	 */
	public function getCacheStatus() {
		return $this->cacheStatus;
	}

	/**
	 * Returns cache date
	 *
	 * @since 1.9
	 *
	 * @return string
	 */
	public function getCacheDate() {
		return $this->cacheDate;
	}

	/**
	 * Returns cache count
	 *
	 * @since 1.9
	 *
	 * @return int
	 */
	public function getCacheCount() {
		return $this->cacheCount;
	}

	/**
	 * Create a data item from the provided serialization string and type
	 * ID.
	 * @return DIConcept
	 */
	public static function doUnserialize( $serialization ) {
		$result = unserialize( $serialization );
		if ( $result === false ) {
			throw new DataItemException( "Unserialization failed." );
		}
		return $result;
	}

	public function equals( SMWDataItem $di ) {
		if ( $di->getDIType() !== SMWDataItem::TYPE_CONCEPT ) {
			return false;
		}
		return $di->getSerialization() === $this->getSerialization();
	}

}