[171] | 1 | <?php
|
---|
| 2 | // Survey database interface class as intermediate for storing data from the site to the RDF database
|
---|
| 3 | require_once 'rdfConstants.php';
|
---|
| 4 | // Include RAP Library to write RDF files
|
---|
| 5 | include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");
|
---|
| 6 |
|
---|
| 7 | /**
|
---|
| 8 | * Connector
|
---|
| 9 | *
|
---|
| 10 | * @author jkraaijeveld
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | abstract class Connector implements IConnector
|
---|
| 14 | {
|
---|
| 15 | protected $model;
|
---|
| 16 | protected $fileName;
|
---|
| 17 |
|
---|
| 18 | /**
|
---|
| 19 | * function load()
|
---|
| 20 | * Loads the file into the standard MemModel
|
---|
| 21 | */
|
---|
| 22 | public function load()
|
---|
| 23 | {
|
---|
| 24 | $this->model = ModelFactory::getDefaultModel();
|
---|
| 25 | if(file_exists($this->fileName))
|
---|
| 26 | $this->model->load($this->fileName);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | * function save()
|
---|
| 31 | * Saves the MemModel into the given file.
|
---|
| 32 | */
|
---|
| 33 | public function save()
|
---|
| 34 | {
|
---|
| 35 | $this->model->saveAs($this->fileName, 'rdf');
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | /**
|
---|
| 39 | * function createArguments()
|
---|
| 40 | * @param type $arguments
|
---|
| 41 | * Creates the arguments to be used in the query based on the
|
---|
| 42 | * arguments specified in the incoming array.
|
---|
| 43 | */
|
---|
| 44 | public function createArguments($arguments)
|
---|
| 45 | {
|
---|
| 46 | $argumentString = "";
|
---|
| 47 | foreach(array_keys($arguments) as $key)
|
---|
| 48 | {
|
---|
| 49 | $addition = "";
|
---|
| 50 | switch($key)
|
---|
| 51 | {
|
---|
| 52 | case "uid" : $addition = "predicates:uid '" . $arguments[$key] . "'\n"; break;
|
---|
| 53 | case "question" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n"; break;
|
---|
| 54 | case "values": foreach($arguments[$key] as $value) { $addition = $addition . "predicates:answered '" . $value . "'\n"; } break;
|
---|
| 55 | case "survey" : $addition = "predicates:for_survey '" . $arguments[$key] . "'\n"; break;
|
---|
| 56 | case "respondent" : $addition = "predicates:by_respondent '" . $arguments[$key] . "'\n"; break;
|
---|
| 57 | case "answers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:given_answer '" . $answer . "'\n"; } break;
|
---|
| 58 | case "title" : $addition = "predicates:title '" . $arguments[$key] . "'\n"; break;
|
---|
| 59 | case "description" : $addition = "predicates:description '" . $arguments[$key] . "'\n"; break;
|
---|
| 60 | case "style" : $addition = "predicates:style '" . $arguments[$key] . "'\n"; break;
|
---|
| 61 | case "code" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n";break;
|
---|
| 62 | case "type" : $addition = "predicates:question_type '" . $arguments[$key] . "'\n"; break;
|
---|
| 63 | case "category" : $addition = "predicates:question_category '" . $arguments[$key] . "'\n";
|
---|
| 64 | case "definedanswers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:has_answer '" . $answer . "'\n"; } break;
|
---|
| 65 | case "name" : $addition = "predicates:name '" . $arguments[$key] . "'\n"; break;
|
---|
| 66 | case "password" : $addition = "predicates:password '" . $arguments[$key] . "'\n"; break;
|
---|
| 67 | case "creator" : $addition = "predicates:creator '" . $arguments[$key] . "'\n"; break;
|
---|
[195] | 68 | case "creationdate" : $addition = "predicates:creationdate '" . $arguments[$key] . "'\n"; break;
|
---|
[171] | 69 | case "applications" : foreach($arguments[$key] as $application) { $addition = $addition . "predicates:has_application '" . $application . "'\n"; } break;
|
---|
| 70 | case "surveys" : foreach($arguments[$key] as $survey) { $addition = $addition . "predicates:has_survey '" . $survey . "'\n"; } break;
|
---|
| 71 | case "answersets" : foreach($arguments[$key] as $answerset) { $addition = $addition . "predicates:has_answerset '" . $answerset . "'\n"; } break;
|
---|
| 72 | case "questions" : foreach($arguments[$key] as $question) { $addition = $addition . "predicates:has_question '" . $question . "'\n"; } break;
|
---|
[195] | 73 | case "location" : $addition = "predicates:location '" . $arguments[$key] . "\n"; break;
|
---|
| 74 | case "facilitator" : $addition = "predicates:facilitator '" . $arguments[$key] . "\n"; break;
|
---|
| 75 | case "starttime" : $addition = "predicates:starttime '" . $arguments[$key] . "\n"; break;
|
---|
| 76 | case "endtime" : $addition = "predicates:endtime '" . $arguments[$key] . "\n"; break;
|
---|
| 77 | case "session" : $addition = "predicates:of_session '" . $arguments[$key] . "\n"; break;
|
---|
| 78 | case "resultset" : $addition = "predciates:has_resultset '" . $arguments[$key] . "\n"; break;
|
---|
[171] | 79 | }
|
---|
| 80 | $argumentString = $argumentString . $addition;
|
---|
| 81 | }
|
---|
| 82 | return $argumentString;
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | ?>
|
---|
| 89 |
|
---|