source: Dev/trunk/classes/DashboardRDFWriter.php @ 111

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

application bug multiple values fixed
more dashboard rdf work

File size: 3.6 KB
Line 
1<?php
2
3class DashboardRDFWriter
4{
5    protected $model;
6
7    protected $resourceDashboard;
8    protected $dashboardID;
9
10    protected $filePath;
11
12    public function __construct($dashboardID)
13    {
14        // Create empty MemModel
15        $factory = new ModelFactory();
16        $this->model = $factory->getDefaultModel();
17
18        $this->dashboardID = $dashboardID;     
19        $this->filePath = 'data/dashboards/';
20        if (!is_dir($this->filePath))
21            mkdir($this->filePath);     
22    }   
23
24    public function saveDashboard()
25    {   
26        $this->model->saveAs($this->filePath.'dashboard_'.$this->dashboardID.'.rdf','rdf');
27    }
28   
29    public function createDashboard($dTitle, $dDescription, $dCreatorID)
30    {
31        $this->resourceDashboard = new Resource(DASHBOARD.'/'.$this->dashboardID);
32
33        $resourceDashboardType = new Resource(DASHBOARD);
34        $predicateRType = new Resource(RTYPE);
35        $this->model->add(new Statement($this->resourceDashboard,$predicateRType,$resourceDashboardType));
36
37        $literalDashboardID = new Literal($this->dashboardID);
38        $predicateUniqueID = new Resource(UID);
39        $this->model->add(new Statement($this->resourceDashboard,$predicateUniqueID,$literalDashboardID));
40
41        $predicateTitle = new Resource(TITLE);         
42        $dashboardTitle = new Literal($dTitle);
43        $this->model->add(new Statement($this->resourceDashboard,$predicateTitle,$dashboardTitle));             
44
45        $predicateDescription = new Resource(DESCRIPTION);
46        $dashboardDescription = new Literal($dDescription);
47        $this->model->add(new Statement($this->resourceDashboard,$predicateDescription,$dashboardDescription));
48       
49        $predicateCreator = new Resource(CREATOR);
50        $userID = new Literal($dCreatorID);
51        $this->model->add(new Statement($this->resourceDashboard,$predicateCreator,$userID));
52    }
53   
54    public function addGraph($gID,$gTitle,$gDescription,$gTypes,$gData)
55    {
56        $resourceGraph = new Resource(GRAPH);
57       
58        $predicateTitle = new Resource(TITLE);         
59        $graphTitle = new Literal($gTitle);
60        $this->model->add(new Statement($resourceGraph,$predicateTitle,$graphTitle));           
61
62        $predicateDescription = new Resource(DESCRIPTION);
63        $graphDescription = new Literal($gDescription);
64        $this->model->add(new Statement($resourceGraph,$predicateDescription,$graphDescription));
65       
66        $predicateUniqueID = new Resource(UID);
67        $graphID = new Literal($gID);
68        $this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$graphID));
69       
70        $predicateGraphType = new Resource(GRAPH_TYPE);
71        foreach($gTypes as $gType)
72        {
73            $graphType = new Literal($gType);
74            $this->model->add(new Statement($resourceGraph,$predicateGraphType,$gType));
75        }
76       
77        $predicateData = new Resource(HAS_DATA);
78        foreach($gData as $gThis)
79        {
80            $resourceData = new Resource(DATA);
81            $this->model->add(new Statement($resourceGraph,$predicateData,$resourceData));
82           
83            $dataType = new Literal($gThis['type']);
84            $predicateDataType = new Resource(DATA_TYPE);
85            $this->model->add(new Statement($resourceData,$predicateDataType,$dataType));
86           
87            $dataID = new Literal($gThis['id']);
88            $this->model->add(new Statement($resourceData,$predicateUniqueID,$dataID));           
89        }
90       
91        $predicateHasGraph = new Resource(HAS_GRAPH);
92        $this->model->add(new Statement($this->resourceDashboard,$predicateHasGraph,$resourceGraph));
93    }
94}
95?>
Note: See TracBrowser for help on using the repository browser.