1 | <?php |
---|
2 | |
---|
3 | class SessionRDFReader |
---|
4 | { |
---|
5 | protected $model; |
---|
6 | |
---|
7 | protected $sessionUID; |
---|
8 | protected $filePath; |
---|
9 | |
---|
10 | public function __construct($sessionUID) |
---|
11 | { |
---|
12 | // Create empty MemModel |
---|
13 | $factory = new ModelFactory(); |
---|
14 | $this->model = $factory->getDefaultModel(); |
---|
15 | |
---|
16 | $this->sessionUID = $sessionUID; |
---|
17 | $this->filePath = 'data/sessions/session_'.$this->surveyUID.'.rdf'; |
---|
18 | } |
---|
19 | |
---|
20 | public function loadSurvey() |
---|
21 | { |
---|
22 | $this->model->load($this->filePath); |
---|
23 | } |
---|
24 | |
---|
25 | public function getSessionInfo() |
---|
26 | { |
---|
27 | $results[] = $this->readSessionInfo(); |
---|
28 | $results[] = $this->getPipeline(); |
---|
29 | |
---|
30 | return $results; |
---|
31 | } |
---|
32 | |
---|
33 | public function readSessionInfo() |
---|
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 | _session predicates:resource_type resources:session ; |
---|
42 | predicates:uid ?uid ; |
---|
43 | predicates:title ?title ; |
---|
44 | predicates:description ?description |
---|
45 | }'; |
---|
46 | |
---|
47 | $result = $this->model->sparqlQuery($querystring); |
---|
48 | |
---|
49 | return $result; |
---|
50 | } |
---|
51 | |
---|
52 | public function getPipeline() |
---|
53 | { |
---|
54 | $results[] = $this->readSurveys(); |
---|
55 | $results[] = $this->readApplications(); |
---|
56 | $results[] = $this->readDashboards(); |
---|
57 | |
---|
58 | return $results; |
---|
59 | } |
---|
60 | |
---|
61 | public function readSurveys() |
---|
62 | { |
---|
63 | $querystring = ' |
---|
64 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
65 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
66 | SELECT DISTINCT ?uid ?index |
---|
67 | WHERE |
---|
68 | { |
---|
69 | _survey predicates:resource_type resources:survey ; |
---|
70 | predicates:uid ?uid ; |
---|
71 | predicates:index ?index |
---|
72 | }'; |
---|
73 | |
---|
74 | $result = $this->model->sparqlQuery($querystring); |
---|
75 | |
---|
76 | return $result; |
---|
77 | } |
---|
78 | |
---|
79 | public function readApplications() |
---|
80 | { |
---|
81 | $querystring = ' |
---|
82 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
83 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
84 | SELECT DISTINCT ?uid ?index |
---|
85 | WHERE |
---|
86 | { |
---|
87 | _application predicates:resource_type resources:application ; |
---|
88 | predicates:uid ?uid ; |
---|
89 | predicates:index ?index |
---|
90 | }'; |
---|
91 | |
---|
92 | $result = $this->model->sparqlQuery($querystring); |
---|
93 | |
---|
94 | return $result; |
---|
95 | } |
---|
96 | |
---|
97 | public function readDashboards() |
---|
98 | { |
---|
99 | $querystring = ' |
---|
100 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
101 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
102 | SELECT DISTINCT ?uid ?index |
---|
103 | WHERE |
---|
104 | { |
---|
105 | _dashboard predicates:resource_type resources:dashboard ; |
---|
106 | predicates:uid ?uid ; |
---|
107 | predicates:index ?index |
---|
108 | }'; |
---|
109 | |
---|
110 | $result = $this->model->sparqlQuery($querystring); |
---|
111 | |
---|
112 | return $result; |
---|
113 | } |
---|
114 | |
---|
115 | public function getSessionTitleByID($sessionID) |
---|
116 | { |
---|
117 | // Create empty MemModel |
---|
118 | $factory = new ModelFactory(); |
---|
119 | $tempmodel= $factory->getDefaultModel(); |
---|
120 | $tempmodel->load('data/sessions/session_'.$sessionID.'/session_'.$sessionID.'.rdf'); |
---|
121 | |
---|
122 | $querystring = ' |
---|
123 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> |
---|
124 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> |
---|
125 | SELECT ?title |
---|
126 | WHERE |
---|
127 | { |
---|
128 | _session predicates:resource_type resources:session ; |
---|
129 | predicates:title ?title |
---|
130 | }'; |
---|
131 | |
---|
132 | $result = $tempmodel->sparqlQuery($querystring); |
---|
133 | |
---|
134 | return $result; |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | ?> |
---|