source: Dev/trunk/classes/ApplicationRDFReader.php @ 88

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

application reader changed to work

File size: 3.9 KB
RevLine 
[40]1<?php
2
3class ApplicationRDFReader
4{
[62]5    protected $model;
[88]6    protected $fileName;
[62]7
[40]8    public function __construct()
9    {
[88]10        $this->fileName = 'data/applications/applications.rdf';
11   
12        $this->reloadApplications();
[40]13    }
[88]14   
15    public function reloadApplications()
16    {
17        // Create empty MemModel   
18        $factory = new ModelFactory();
19        $this->model = $factory->getDefaultModel();
20       
21        if(file_exists($this->fileName))
22            $this->model->load($this->fileName);
23    }
[62]24
25    public function readApplicationInfo($applicationID)
[88]26    {       
27        $this->reloadApplications();
28       
[62]29        $querystring = '
30            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
31            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
32            SELECT  ?title ?description ?style
33            WHERE       
34            {
35                    _application        predicates:resource_type        resources:application ;
36                                        predicates:uid                  "' . $applicationID . '"        ;
37                                        predicates:title                ?title  ;
[78]38                                        predicates:description          ?description    ;
[62]39                                        predicates:style                ?style
40            }';
41
42        $result = $this->model->sparqlQuery($querystring);
43
44        return $result;
45    }
46
47    public function readAllApplications()
48    {
49        $result = array();
50        $result[] = $this->readApplicationIDs();
51        $result[] = $this->readApplicationTitles();                             
52        $result[] = $this->readApplicationDescriptions();
53        $result[] = $this->readApplicationStyles();
54
[78]55        return $result;
[62]56    }
57
58    public function readApplicationIDs()
59    {
60        $querystring = '
61            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
62            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
63            SELECT  ?uid
64            WHERE       
65            {
66                    _application        predicates:resource_type        resources:application ;
67                                        predicates:uid                  ?uid
68            }';
69
70        $result = $this->model->sparqlQuery($querystring);
71
72        return $result;
73    }
74
75    public function readApplicationTitles()
76    {
77        $querystring = '
78            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
79            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
80            SELECT  ?title
81            WHERE       
82            {
83                    _application        predicates:resource_type        resources:application ;
84                                        predicates:title                ?title
85            }';
86
87        $result = $this->model->sparqlQuery($querystring);
88
89        return $result;
90    }
91
92    public function readApplicationDescriptions()
93    {
94        $querystring = '
95            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
96            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
97            SELECT  ?description
98            WHERE       
99            {
100                    _application        predicates:resource_type        resources:application ;
[78]101                                        predicates:description          ?description   
[62]102            }';
103
104        $result = $this->model->sparqlQuery($querystring);
105
106        return $result;
107    }
108
109    public function readApplicationStyles()
110    {
111        $querystring = '
112            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
113            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
114            SELECT  ?style
115            WHERE       
116            {
117                    _application        predicates:resource_type        resources:application ;
118                                        predicates:style                ?style
119            }';
120
121        $result = $this->model->sparqlQuery($querystring);
122
123        return $result;
124    }
[40]125}
126
127?>
Note: See TracBrowser for help on using the repository browser.