source: Dev/branches/jos-branch/server/classes/models/ResearchToolObject.php @ 266

Last change on this file since 266 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 4.0 KB
Line 
1<?php
2/**
3 * Description of ResearchToolObject
4 *
5 * @author jkraaijeveld
6 */
7// Survey database interface class as intermediate for storing data from the site to the RDF database
8require_once 'rdfConstants.php';
9// Include RAP Library to write RDF files
10include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");
11
12
13abstract class ResearchToolObject {
14
15        public $uid;
16
17        public function evaluate()
18        {
19                return true;
20        }
21       
22        public static function load($filename)
23        {
24                $model = ModelFactory::getDefaultModel();
25                if(file_exists($filename))
26                        $model->load($filename);
27                return $model;
28        }
29
30        /**
31         * function createArguments()
32         * @param type $arguments
33         * Creates the arguments to be used in the query based on the
34         * arguments specified in the incoming array.
35         */
36        public static function createArguments($arguments)
37        {
38                $argumentString = "";
39                foreach(array_keys($arguments) as $key)
40                {
41                        $addition = "";
42                        switch($key)
43                        {
44                                case "uid" : $addition = "predicates:uid '" . $arguments[$key] . "'\n"; break;
45                                case "question" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n"; break;
46                                case "values": foreach($arguments[$key] as $value) { $addition = $addition . "predicates:answered '" . $value . "'\n"; } break;
47                                case "survey" : $addition = "predicates:for_survey '" . $arguments[$key] . "'\n"; break;
48                                case "respondent" : $addition = "predicates:by_respondent '" . $arguments[$key] . "'\n"; break;
49                                case "answers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:given_answer '" . $answer . "'\n"; } break;
50                                case "title" : $addition = "predicates:title '" . $arguments[$key] . "'\n"; break;
51                                case "description" : $addition = "predicates:description '" . $arguments[$key] . "'\n"; break;
52                                case "style" : $addition = "predicates:style '" . $arguments[$key] . "'\n"; break;
53                                case "code" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n";break;
54                                case "type" : $addition = "predicates:question_type '" . $arguments[$key] . "'\n"; break;       
55                                case "category" : $addition = "predicates:question_category '" . $arguments[$key] . "'\n";
56                                case "definedanswers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:has_answer '" . $answer . "'\n"; } break;
57                                case "email" : $addition = "predicates:email '" . $arguments[$key] . "'\n"; break;
58                                case "password" : $addition = "predicates:password '" . $arguments[$key] . "'\n"; break;
59                                case "creator" : $addition = "predicates:creator '" . $arguments[$key] . "'\n"; break;
60                                case "creationdate" : $addition = "predicates:creationdate '" . $arguments[$key] . "'\n"; break;
61                                case "applications" : foreach($arguments[$key] as $application) { $addition = $addition . "predicates:has_application '" . $application . "'\n"; } break;
62                                case "surveys" : foreach($arguments[$key] as $survey) { $addition = $addition . "predicates:has_survey '" . $survey . "'\n"; } break;
63                                case "answersets" : foreach($arguments[$key] as $answerset) { $addition = $addition . "predicates:has_answerset '" . $answerset . "'\n"; } break;
64                                case "questions" : foreach($arguments[$key] as $question) { $addition = $addition . "predicates:has_question '" . $question . "'\n"; } break;
65                                case "location" : $addition = "predicates:location '" . $arguments[$key] . "\n"; break;
66                                case "facilitator" : $addition = "predicates:facilitator '" . $arguments[$key] . "\n"; break;
67                                case "starttime" : $addition = "predicates:starttime '" . $arguments[$key] . "\n"; break;
68                                case "endtime" : $addition = "predicates:endtime '" . $arguments[$key] . "\n"; break;
69                                case "session" : $addition = "predicates:of_session '" . $arguments[$key] . "\n"; break;
70                                case "resultset" : $addition = "predicates:has_resultset '" . $arguments[$key] . "\n"; break;
71                                case "of_application" : $addition = "predicates:of_application '" . $arguments[$key] . "\n"; break;
72                                case "open" : $addition = "predicates:open '" . $arguments[$key] . "\n"; break;
73                        }
74                        $argumentString = $argumentString . $addition;
75                }
76                return $argumentString;
77        }
78
79}
80
81?>
Note: See TracBrowser for help on using the repository browser.