Ignore:
Timestamp:
02/24/12 15:54:20 (13 years ago)
Author:
jkraaijeveld
Message:

[Server] ApplicationInstance? now properly works with Resource links to Application. SPARQL query has been edited to make this work. Still has to be done for all other models.

Location:
Dev/branches/jos-branch/server/classes/models
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/jos-branch/server/classes/models/ApplicationInstance.php

    r285 r287  
    3232         * @param type $periodicresults: Periodical results from playing.
    3333         */
    34         public function __construct($uid = null, $application = null, $starttime = null, $endtime = null, $open = false, $playerresults = null, $groupresults = null, $periodicresults = null)
     34        public function __construct($uid = null, $application = null, $starttime = null, $endtime = null, $open = 0, $playerresults = null, $groupresults = null, $periodicresults = null)
    3535        {
    3636                if(!isset($uid))
     
    5656                if(is_string($this->application))
    5757                {
    58                         $result = Application::get(array("uid" => $this->application));
     58                        $app = ResearchToolObject::stripUri($this->application);
     59                        $result = Application::get(array("uid" => $app["uid"]));
    5960                        if(!isset($result[0]))
    6061                                return false;
     
    9697                $model->add(new Statement($resourceAI, $predicateUid, $AIUid));
    9798
    98                 $AIApplication = new Literal($this->application->uid);
     99                $AIApplication = new Resource(APPLICATION . '/' . $this->application->uid);
    99100                $predicateApplication = new Resource(OF_APPLICATION);
    100101                $model->add(new Statement($resourceAI, $predicateApplication, $AIApplication));
     
    108109                $model->add(new Statement($resourceAI, $predicateEndTime, $AIEndTime));
    109110
    110                 $AIOpen = new Literal($this->open);
     111                $AIOpen = new Literal((bool)$this->open);
    111112                $predicateOpen = new Resource(OPEN);
    112113                $model->add(new Statement($resourceAI, $predicateOpen, $AIOpen));
     
    127128        {
    128129                $model = ResearchToolObject::load(ApplicationInstance::$filename);
     130                $model->writeAsHTMLTable();
    129131
    130132                //Build the query string
     
    135137                        WHERE
    136138                        {
    137                                 _applicationinstance    predicates:resource_type        resources:applicationinstance ;
     139                                ?applicationinstance    predicates:resource_type        resources:applicationinstance ;
    138140                                predicates:uid ?uid ;
    139141                                predicates:of_application ?of_application ;
     
    141143                                predicates:endtime ?endtime ;
    142144                                predicates:open ?open ;
    143                                 ' . ResearchToolObject::createArguments($arguments) . '
    144                         }';
     145                        ' . ResearchToolObject::createArguments($arguments) . '
     146        }';
    145147                //Query the model
    146148                $results = $model->sparqlQuery($querystring);
    147 
    148149                //Create the corresponding ApplicationInstance objects
    149150                $aInstances = array();
     
    156157                                $endTime = new DateTime();
    157158                                $endTime->setTimestamp(intval($result['?endtime']->label));
    158                                 $open = false;
    159                                 if ($result['?open'] == 'true')
    160                                         $open = true;
    161 
    162                                 $aInstances[] = new ApplicationInstance($result['?uid']->label, $result['?of_application']->label, $startTime, $endTime, $open, null, null, null);
     159                                $open = (bool) $result['?open'];
     160                                $aInstances[] = new ApplicationInstance($result['?uid']->label, $result['?of_application']->uri, $startTime, $endTime, $open, null, null, null);
    163161                        }
    164162                }
  • Dev/branches/jos-branch/server/classes/models/ResearchToolObject.php

    r285 r287  
    3030                        $model->load($filename);
    3131                return $model;
     32        }
     33
     34        /**
     35         * function stripUri($inString)
     36         * @param type $inString
     37         * Takes a URI and creates a new array which contains the type and the uid of the object
     38         */
     39        public static function stripUri($inString)
     40        {
     41                $exp = explode('/', $inString);
     42                if(sizeof($exp) < 7)
     43                        return null;
     44                else
     45                        return array("type" => $exp[5], "uid" => $exp[6]);
    3246        }
    3347
     
    6781                                case "answersets" : foreach($arguments[$key] as $answerset) { $addition = $addition . "predicates:has_answerset '" . $answerset . "'\n"; } break;
    6882                                case "questions" : foreach($arguments[$key] as $question) { $addition = $addition . "predicates:has_question '" . $question . "'\n"; } break;
    69                                 case "location" : $addition = "predicates:location '" . $arguments[$key] . "\n"; break;
    70                                 case "facilitator" : $addition = "predicates:facilitator '" . $arguments[$key] . "\n"; break;
    71                                 case "starttime" : $addition = "predicates:starttime '" . $arguments[$key] . "\n"; break;
    72                                 case "endtime" : $addition = "predicates:endtime '" . $arguments[$key] . "\n"; break;
    73                                 case "session" : $addition = "predicates:of_session '" . $arguments[$key] . "\n"; break;
    74                                 case "resultset" : $addition = "predicates:has_resultset '" . $arguments[$key] . "\n"; break;
    75                                 case "of_application" : $addition = "predicates:of_application '" . $arguments[$key] . "\n"; break;
     83                                case "location" : $addition = "predicates:location '" . $arguments[$key] . "'\n"; break;
     84                                case "facilitator" : $addition = "predicates:facilitator '" . $arguments[$key] . "'\n"; break;
     85                                case "starttime" : $addition = "predicates:starttime '" . $arguments[$key] . "'\n"; break;
     86                                case "endtime" : $addition = "predicates:endtime '" . $arguments[$key] . "'\n"; break;
     87                                case "session" : $addition = "predicates:of_session '" . $arguments[$key] . "'\n"; break;
     88                                case "resultset" : $addition = "predicates:has_resultset '" . $arguments[$key] . "'\n"; break;
     89                                case "of_application" : $addition = "predicates:of_application <" . APPLICATION . '/' .  $arguments[$key] . ">\n"; break;
    7690                                case "open" : $addition = "predicates:open '" . $arguments[$key] . "\n"; break;
    7791                        }
Note: See TracChangeset for help on using the changeset viewer.