source: Dev/trunk/classes/SessionRDFReader.php @ 78

Last change on this file since 78 was 78, checked in by basvannuland, 14 years ago

save and load application
start with save and load session

File size: 3.3 KB
RevLine 
[78]1<?php
2
3class 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
116?>
Note: See TracBrowser for help on using the repository browser.