- Timestamp:
- 09/01/11 15:59:15 (14 years ago)
- Location:
- Dev/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/ApplicationRDFWriter.php
r88 r100 24 24 25 25 public function setApplicationInfo($aTitle, $aDescription, $aStyle) 26 { 26 { 27 27 $resourceApplication = new Resource(APPLICATION.'/'.$this->applicationID); 28 28 //remove the old values... 29 $this->model->subtract($this->model->find($resourceApplication, null, null)); 30 31 //...and add the new ones! 29 32 $resourceApplicationType = new Resource(APPLICATION); 30 33 $predicateRType = new Resource(RTYPE); 31 34 $this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType)); 32 33 35 $literalApplicationID = new Literal($this->applicationID); 34 36 $predicateUniqueID = new Resource(UID); … … 37 39 $applicationTitle = new Literal($aTitle); 38 40 $predicateTitle = new Resource(TITLE); 39 $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle)); 41 $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle)); 40 42 41 43 $applicationDescription = new Literal($aDescription); 42 44 $predicateDescription = new Resource(DESCRIPTION); 43 $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription)); 45 $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription)); 44 46 45 47 $applicationStyle = new Literal($aStyle); -
Dev/trunk/classes/DashboardCreationDatabaseInterface.php
r91 r100 9 9 class DashboardCreationDatabaseInterface 10 10 { 11 public function __construct() 11 protected $dashboardRDFWriter; 12 protected $dashboardRDFReader; 13 14 public function __construct($dashID) 12 15 { 16 if($dashID == null) 17 $dashboardID = md5( uniqid(rand(), true) ); 18 else 19 $dashboardID = $dashID; 13 20 21 $this->dashboardRDFWriter = new DashboardRDFWriter($dashboardID); 22 $this->dashboardRDFReader = new DashboardRDFReader($dashboardID); 23 } 24 25 public function setDashboardInfo($dashboard,$user) 26 { 27 $dTitle = $dashboard['dashboardTitle']; 28 $dDescription = $dashboard['dashboardDescription']; 29 30 $dCreatorID = $user['username']; 31 32 $this->dashboardRDFWriter->createDashboard($dTitle, $dDescription, $dCreatorID); 33 34 $gNumber = 1; 35 while (isset($dashboard['graphTitle'.$gNumber])) 36 { 37 if (isset($dashboard['graphID'.$gNumber])) 38 $gID = $dashboard['graphID'.$gNumber]; 39 else 40 $gID = md5( uniqid(rand(), true) ); 41 $gTitle = $dashboard['graphTitle'.$gNumber]; 42 $gDescription = $dashboard['graphDescription'.$gNumber]; 43 44 $gTypes = array(); 45 $tNumber = 1; 46 while(isset($dashboard['g'.$gNumber.'type'.$tNumber])) 47 { 48 49 } 50 51 } 14 52 } 15 53 } -
Dev/trunk/classes/DashboardRDFReader.php
r91 r100 33 33 public function getDashboardInfo() 34 34 { 35 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; 36 149 } 37 150 } -
Dev/trunk/classes/DashboardRDFWriter.php
r91 r100 1 1 <?php 2 2 3 class SurveyRDFWriter3 class DashboardRDFWriter 4 4 { 5 5 protected $model; … … 27 27 } 28 28 29 public function createDashboard($dTitle, $dDescription, $dRespondentGroup)29 public function createDashboard($dTitle, $dDescription, $dCreatorID) 30 30 { 31 31 $this->resourceDashboard = new Resource(DASHBOARD.'/'.$this->dashboardID); … … 46 46 $dashboardDescription = new Literal($dDescription); 47 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)); 48 52 } 49 53 50 public function addGraph($g Title,$gDescription,$gTypes,$gData)54 public function addGraph($gID,$gTitle,$gDescription,$gTypes,$gData) 51 55 { 52 56 $resourceGraph = new Resource(GRAPH); … … 60 64 $this->model->add(new Statement($resourceGraph,$predicateDescription,$graphDescription)); 61 65 66 $predicateUniqueID = new Resource(UID); 67 $graphID = new Literal($gID); 68 $this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$graphID)); 69 62 70 $predicateGraphType = new Resource(GRAPH_TYPE); 63 71 foreach($gTypes as $gType) … … 67 75 } 68 76 69 $predicateData = new Resource( DATA);77 $predicateData = new Resource(HAS_DATA); 70 78 foreach($gData as $gThis) 71 79 { 72 $graphData = new Literal($gThis); 73 $this->model->add(new Statement($resourceGraph,$predicateData,$graphData)); 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)); 74 89 } 75 90 -
Dev/trunk/rdfConstants.php
r91 r100 17 17 define('DASHBOARD',SURVEYTOOL_RESOURCES_NAMESPACE . 'dashboard'); 18 18 define('GRAPH',SURVEYTOOL_RESOURCES_NAMESPACE . 'graph'); 19 define('DATA',SURVEYTOOL_RESOURCES_NAMESPACE . 'data'); 20 define('APPDATA',SURVEYTOOL_RESOURCES_NAMESPACE . 'graph'); 19 21 20 22 // Predicates used for RDF triples … … 39 41 define('INDEX',SURVEYTOOL_PREDICATES_NAMESPACE . 'index'); 40 42 define('GRAPH_TYPE',SURVEYTOOL_PREDICATES_NAMESPACE . 'graph_type'); 41 define('DATA',SURVEYTOOL_PREDICATES_NAMESPACE . 'data'); 43 define('HAS_DATA',SURVEYTOOL_PREDICATES_NAMESPACE . 'has_data'); 44 define('DATA_TYPE',SURVEYTOOL_PREDICATES_NAMESPACE . 'data_type'); 42 45 43 46 ?>
Note: See TracChangeset
for help on using the changeset viewer.