source: Dev/branches/rest-dojo-ui/server/classes/models/ResearchToolObject.php @ 274

Last change on this file since 274 was 274, checked in by hendrikvanantwerpen, 13 years ago
  • [Client] Moved pages in subtree of rft/, allowing controllers next to them.
  • [Client] Created questions page, gives overview and allows adding.
  • [Client] Page controllers inherit from _Page, because the previous mechanism w

asn't working.

  • [Client] Added new user registration.
  • [Server] Changed user passwords to passwordHash/passwordSalt combination.
  • [Server] Added simple object marshalling and unmarshalling to preserve types.
  • [Server] Added ResearchToolObjectInterface? with static create() method. Implemented for all model classes.
File size: 4.3 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 implements ResearchToolObjectInterface {
14
15        public $uid = null;
16
17    public function getUid() {
18        return $this->uid;
19    }
20   
21        public function evaluate()
22        {
23                return true;
24        }
25       
26        public static function load($filename)
27        {
28                $model = ModelFactory::getDefaultModel();
29                if(file_exists($filename))
30                        $model->load($filename);
31                return $model;
32        }
33
34        /**
35         * function createArguments()
36         * @param type $arguments
37         * Creates the arguments to be used in the query based on the
38         * arguments specified in the incoming array.
39         */
40        public static function createArguments($arguments)
41        {
42                $argumentString = "";
43                foreach(array_keys($arguments) as $key)
44                {
45                        $addition = "";
46                        switch($key)
47                        {
48                                case "uid" : $addition = "predicates:uid '" . $arguments[$key] . "'\n"; break;
49                                case "question" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n"; break;
50                                case "values": foreach($arguments[$key] as $value) { $addition = $addition . "predicates:answered '" . $value . "'\n"; } break;
51                                case "survey" : $addition = "predicates:for_survey '" . $arguments[$key] . "'\n"; break;
52                                case "respondent" : $addition = "predicates:by_respondent '" . $arguments[$key] . "'\n"; break;
53                                case "answers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:given_answer '" . $answer . "'\n"; } break;
54                                case "title" : $addition = "predicates:title '" . $arguments[$key] . "'\n"; break;
55                                case "description" : $addition = "predicates:description '" . $arguments[$key] . "'\n"; break;
56                                case "style" : $addition = "predicates:style '" . $arguments[$key] . "'\n"; break;
57                                case "code" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n";break;
58                                case "type" : $addition = "predicates:question_type '" . $arguments[$key] . "'\n"; break;       
59                                case "category" : $addition = "predicates:question_category '" . $arguments[$key] . "'\n";
60                                case "definedanswers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:has_answer '" . $answer . "'\n"; } break;
61                                case "email" : $addition = "predicates:email '" . $arguments[$key] . "'\n"; break;
62                                case "password" : $addition = "predicates:password '" . $arguments[$key] . "'\n"; break;
63                                case "creator" : $addition = "predicates:creator '" . $arguments[$key] . "'\n"; break;
64                                case "creationdate" : $addition = "predicates:creationdate '" . $arguments[$key] . "'\n"; break;
65                                case "applications" : foreach($arguments[$key] as $application) { $addition = $addition . "predicates:has_application '" . $application . "'\n"; } break;
66                                case "surveys" : foreach($arguments[$key] as $survey) { $addition = $addition . "predicates:has_survey '" . $survey . "'\n"; } break;
67                                case "answersets" : foreach($arguments[$key] as $answerset) { $addition = $addition . "predicates:has_answerset '" . $answerset . "'\n"; } break;
68                                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;
76                                case "open" : $addition = "predicates:open '" . $arguments[$key] . "\n"; break;
77                        }
78                        $argumentString = $argumentString . $addition;
79                }
80                return $argumentString;
81        }
82
83}
84
85interface ResearchToolObjectInterface {
86    function getUid();
87    static function get($arguments);
88    static function create($obj);
89    function evaluate();
90    function save();
91}
92
93?>
Note: See TracBrowser for help on using the repository browser.