Changeset 100 for Dev


Ignore:
Timestamp:
09/01/11 15:59:15 (14 years ago)
Author:
basvannuland
Message:

application bug multiple values fixed
more dashboard rdf work

Location:
Dev/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/ApplicationRDFWriter.php

    r88 r100  
    2424
    2525    public function setApplicationInfo($aTitle, $aDescription, $aStyle)
    26     {
     26    {             
    2727        $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!
    2932        $resourceApplicationType = new Resource(APPLICATION);
    3033        $predicateRType = new Resource(RTYPE);
    3134        $this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType));
    32 
    3335        $literalApplicationID = new Literal($this->applicationID);
    3436        $predicateUniqueID = new Resource(UID);
     
    3739        $applicationTitle = new Literal($aTitle);
    3840        $predicateTitle = new Resource(TITLE); 
    39         $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle));               
     41        $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle));
    4042
    4143        $applicationDescription = new Literal($aDescription);
    4244        $predicateDescription = new Resource(DESCRIPTION);
    43         $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription));           
     45        $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription));
    4446
    4547        $applicationStyle = new Literal($aStyle);
  • Dev/trunk/classes/DashboardCreationDatabaseInterface.php

    r91 r100  
    99class DashboardCreationDatabaseInterface
    1010{   
    11     public function __construct()
     11    protected $dashboardRDFWriter;
     12    protected $dashboardRDFReader;
     13   
     14    public function __construct($dashID)
    1215    {
     16        if($dashID == null)
     17            $dashboardID = md5( uniqid(rand(), true) );
     18        else
     19            $dashboardID = $dashID;
    1320       
     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        }
    1452    }
    1553}
  • Dev/trunk/classes/DashboardRDFReader.php

    r91 r100  
    3333    public function getDashboardInfo()
    3434    {
    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;
    36149    }
    37150}
  • Dev/trunk/classes/DashboardRDFWriter.php

    r91 r100  
    11<?php
    22
    3 class SurveyRDFWriter
     3class DashboardRDFWriter
    44{
    55    protected $model;
     
    2727    }
    2828   
    29     public function createDashboard($dTitle, $dDescription,$dRespondentGroup)
     29    public function createDashboard($dTitle, $dDescription, $dCreatorID)
    3030    {
    3131        $this->resourceDashboard = new Resource(DASHBOARD.'/'.$this->dashboardID);
     
    4646        $dashboardDescription = new Literal($dDescription);
    4747        $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));
    4852    }
    4953   
    50     public function addGraph($gTitle,$gDescription,$gTypes,$gData)
     54    public function addGraph($gID,$gTitle,$gDescription,$gTypes,$gData)
    5155    {
    5256        $resourceGraph = new Resource(GRAPH);
     
    6064        $this->model->add(new Statement($resourceGraph,$predicateDescription,$graphDescription));
    6165       
     66        $predicateUniqueID = new Resource(UID);
     67        $graphID = new Literal($gID);
     68        $this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$graphID));
     69       
    6270        $predicateGraphType = new Resource(GRAPH_TYPE);
    6371        foreach($gTypes as $gType)
     
    6775        }
    6876       
    69         $predicateData = new Resource(DATA);
     77        $predicateData = new Resource(HAS_DATA);
    7078        foreach($gData as $gThis)
    7179        {
    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));           
    7489        }
    7590       
  • Dev/trunk/rdfConstants.php

    r91 r100  
    1717define('DASHBOARD',SURVEYTOOL_RESOURCES_NAMESPACE . 'dashboard');
    1818define('GRAPH',SURVEYTOOL_RESOURCES_NAMESPACE . 'graph');
     19define('DATA',SURVEYTOOL_RESOURCES_NAMESPACE . 'data');
     20define('APPDATA',SURVEYTOOL_RESOURCES_NAMESPACE . 'graph');
    1921
    2022// Predicates used for RDF triples
     
    3941define('INDEX',SURVEYTOOL_PREDICATES_NAMESPACE . 'index');
    4042define('GRAPH_TYPE',SURVEYTOOL_PREDICATES_NAMESPACE . 'graph_type');
    41 define('DATA',SURVEYTOOL_PREDICATES_NAMESPACE . 'data');
     43define('HAS_DATA',SURVEYTOOL_PREDICATES_NAMESPACE . 'has_data');
     44define('DATA_TYPE',SURVEYTOOL_PREDICATES_NAMESPACE . 'data_type');
    4245
    4346?>
Note: See TracChangeset for help on using the changeset viewer.