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
|
<?php
namespace SMW\SQLStore\EntityStore\DIHandlers;
use SMW\DIConcept;
use SMW\SQLStore\EntityStore\DataItemHandler;
use SMW\SQLStore\EntityStore\Exception\DataItemHandlerException;
use SMW\SQLStore\TableBuilder\FieldType;
use SMWDataItem as DataItem;
/**
* This class implements Store access to Concept data items.
*
* @note The table layout and behavior of this class is not coherent with the
* way that other DIs work. This is because of the unfortunate use of the
* concept table to store extra cache data, but also due to the design of
* concept DIs. This will be cleaned up at some point.
*
* @license GNU GPL v2+
* @since 1.8
*
* @author Nischay Nahata
*/
class DIConceptHandler extends DataItemHandler {
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function getTableFields() {
return [
'concept_txt' => FieldType::TYPE_BLOB,
'concept_docu' => FieldType::TYPE_BLOB,
'concept_features' => FieldType::FIELD_NAMESPACE,
'concept_size' => FieldType::FIELD_NAMESPACE,
'concept_depth' => FieldType::FIELD_NAMESPACE,
'cache_date' => FieldType::TYPE_INT_UNSIGNED,
'cache_count' => FieldType::TYPE_INT_UNSIGNED
];
}
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function getFetchFields() {
return [
'concept_txt' => FieldType::TYPE_BLOB,
'concept_docu' => FieldType::TYPE_BLOB,
'concept_features' => FieldType::FIELD_NAMESPACE,
'concept_size' => FieldType::FIELD_NAMESPACE,
'concept_depth' => FieldType::FIELD_NAMESPACE,
];
}
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function getWhereConds( DataItem $dataItem ) {
return [
'concept_txt' => $dataItem->getConceptQuery(),
'concept_docu' => $dataItem->getDocumentation(),
'concept_features' => $dataItem->getQueryFeatures(),
'concept_size' => $dataItem->getSize(),
'concept_depth' => $dataItem->getDepth()
];
}
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function getInsertValues( DataItem $dataItem ) {
return [
'concept_txt' => $dataItem->getConceptQuery(),
'concept_docu' => $dataItem->getDocumentation(),
'concept_features' => $dataItem->getQueryFeatures(),
'concept_size' => $dataItem->getSize(),
'concept_depth' => $dataItem->getDepth()
];
}
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function getIndexField() {
return 'concept_txt';
}
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function getLabelField() {
return 'concept_txt';
}
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function dataItemFromDBKeys( $dbkeys ) {
if ( is_array( $dbkeys) && count( $dbkeys ) == 5 ) {
return new DIConcept(
$dbkeys[0],
smwfXMLContentEncode( $dbkeys[1] ),
$dbkeys[2],
$dbkeys[3],
$dbkeys[4]
);
}
throw new DataItemHandlerException( 'Failed to create data item from DB keys.' );
}
}
|