1 | <?php |
---|
2 | |
---|
3 | class DashboardRDFReader |
---|
4 | { |
---|
5 | protected $model; |
---|
6 | |
---|
7 | protected $dashboardID; |
---|
8 | protected $filePath; |
---|
9 | |
---|
10 | public function __construct($dashboardID) |
---|
11 | { |
---|
12 | // Create empty MemModel |
---|
13 | $factory = new ModelFactory(); |
---|
14 | $this->model = $factory->getDefaultModel(); |
---|
15 | |
---|
16 | $this->dashboardID = $dashboardID; |
---|
17 | $this->filePath = 'data/dashboards/dashboard_'.$this->dashboardID.'.rdf'; |
---|
18 | } |
---|
19 | |
---|
20 | public function loadDashboard() |
---|
21 | { |
---|
22 | if(file_exists($this->filePath)) |
---|
23 | { |
---|
24 | $this->model->load($this->filePath); |
---|
25 | return true; |
---|
26 | } |
---|
27 | else |
---|
28 | { |
---|
29 | return false; |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | public function getDashboardInfo() |
---|
34 | { |
---|
35 | $querystring = ' |
---|
36 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
37 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
38 | SELECT ?uid ?title ?description ?creator |
---|
39 | WHERE |
---|
40 | { |
---|
41 | _dashboard predicates:resource_type resources:dashboard ; |
---|
42 | predicates:uid ?uid ; |
---|
43 | predicates:title ?title ; |
---|
44 | predicates:description ?description ; |
---|
45 | predicates:creator ?creator |
---|
46 | }'; |
---|
47 | |
---|
48 | $result = $this->model->sparqlQuery($querystring); |
---|
49 | |
---|
50 | return $result; |
---|
51 | } |
---|
52 | |
---|
53 | public function readDashboardGraphs() |
---|
54 | { |
---|
55 | $result = array(); |
---|
56 | $result[] = $this->readSDashboardGraphsTitle(); |
---|
57 | $result[] = $this->readDashboardGraphsDescription(); |
---|
58 | |
---|
59 | return $result; |
---|
60 | } |
---|
61 | |
---|
62 | public function readDashboardGraphsTitle() |
---|
63 | { |
---|
64 | $querystring = ' |
---|
65 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
66 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
67 | SELECT ?graphTitle |
---|
68 | WHERE |
---|
69 | { |
---|
70 | _graph predicates:resource_type resources:graph ; |
---|
71 | predicates:title ?graphTitle |
---|
72 | }'; |
---|
73 | |
---|
74 | $result = $this->model->sparqlQuery($querystring); |
---|
75 | |
---|
76 | return $result; |
---|
77 | } |
---|
78 | |
---|
79 | public function readDashboardGraphsDescription() |
---|
80 | { |
---|
81 | $querystring = ' |
---|
82 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
83 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
84 | SELECT ?graphDescription |
---|
85 | WHERE |
---|
86 | { |
---|
87 | _graph predicates:resource_type resources:graph ; |
---|
88 | predicates:description ?graphDescription |
---|
89 | }'; |
---|
90 | |
---|
91 | $result = $this->model->sparqlQuery($querystring); |
---|
92 | |
---|
93 | return $result; |
---|
94 | } |
---|
95 | |
---|
96 | public function readDashboardGraphsID() |
---|
97 | { |
---|
98 | $querystring = ' |
---|
99 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
100 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
101 | SELECT ?graphID |
---|
102 | WHERE |
---|
103 | { |
---|
104 | _graph predicates:resource_type resources:graph ; |
---|
105 | predicates:uid ?graphID |
---|
106 | }'; |
---|
107 | |
---|
108 | $result = $this->model->sparqlQuery($querystring); |
---|
109 | |
---|
110 | return $result; |
---|
111 | } |
---|
112 | |
---|
113 | public function readGraphTypes($graphID) |
---|
114 | { |
---|
115 | $querystring = ' |
---|
116 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
117 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
118 | SELECT ?type |
---|
119 | WHERE |
---|
120 | { |
---|
121 | _graph predicates:resource_type resources:graph ; |
---|
122 | predicates:uid "' . $graphID . '" ; |
---|
123 | predicates:graph_type ?type |
---|
124 | }'; |
---|
125 | |
---|
126 | $result = $this->model->sparqlQuery($querystring); |
---|
127 | |
---|
128 | return $result; |
---|
129 | } |
---|
130 | |
---|
131 | public function readGraphData($graphID) |
---|
132 | { |
---|
133 | $querystring = ' |
---|
134 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
135 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
136 | SELECT ?datatype ?dataid |
---|
137 | WHERE |
---|
138 | { |
---|
139 | _graph predicates:resource_type resources:graph ; |
---|
140 | predicates:uid "' . $graphID . '" . |
---|
141 | _data predicates:has_data resources:data ; |
---|
142 | predicates:data_type ?datatype ; |
---|
143 | predicates:uid ?dataid |
---|
144 | }'; |
---|
145 | |
---|
146 | $result = $this->model->sparqlQuery($querystring); |
---|
147 | |
---|
148 | return $result; |
---|
149 | } |
---|
150 | } |
---|
151 | ?> |
---|