<?php
/**
 * Description of ResearchToolObject
 *
 * @author jkraaijeveld
 */
// Survey database interface class as intermediate for storing data from the site to the RDF database 
require_once 'rdfConstants.php';
// Include RAP Library to write RDF files
include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");


abstract class ResearchToolObject {

	public $uid;

	public function evaluate()
	{
		return true;
	}
	
	public static function load($filename)
	{
		$model = ModelFactory::getDefaultModel();
		if(file_exists($filename))
			$model->load($filename);
		return $model;
	}

	/**
	 * function createArguments()
	 * @param type $arguments
	 * Creates the arguments to be used in the query based on the
	 * arguments specified in the incoming array.
	 */
	public static function createArguments($arguments)
	{
		$argumentString = "";
		foreach(array_keys($arguments) as $key)
		{
			$addition = "";
			switch($key)
			{
				case "uid" : $addition = "predicates:uid '" . $arguments[$key] . "'\n"; break;
				case "question" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n"; break;
				case "values": foreach($arguments[$key] as $value) { $addition = $addition . "predicates:answered '" . $value . "'\n"; } break;
				case "survey" : $addition = "predicates:for_survey '" . $arguments[$key] . "'\n"; break;
				case "respondent" : $addition = "predicates:by_respondent '" . $arguments[$key] . "'\n"; break;
				case "answers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:given_answer '" . $answer . "'\n"; } break;
				case "title" : $addition = "predicates:title '" . $arguments[$key] . "'\n"; break;
				case "description" : $addition = "predicates:description '" . $arguments[$key] . "'\n"; break;
				case "style" : $addition = "predicates:style '" . $arguments[$key] . "'\n"; break;
				case "code" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n";break;
				case "type" : $addition = "predicates:question_type '" . $arguments[$key] . "'\n"; break;	
				case "category" : $addition = "predicates:question_category '" . $arguments[$key] . "'\n";
				case "definedanswers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:has_answer '" . $answer . "'\n"; } break;
				case "name" : $addition = "predicates:name '" . $arguments[$key] . "'\n"; break;
				case "password" : $addition = "predicates:password '" . $arguments[$key] . "'\n"; break;
				case "creator" : $addition = "predicates:creator '" . $arguments[$key] . "'\n"; break;
				case "creationdate" : $addition = "predicates:creationdate '" . $arguments[$key] . "'\n"; break;
				case "applications" : foreach($arguments[$key] as $application) { $addition = $addition . "predicates:has_application '" . $application . "'\n"; } break;
				case "surveys" : foreach($arguments[$key] as $survey) { $addition = $addition . "predicates:has_survey '" . $survey . "'\n"; } break;
				case "answersets" : foreach($arguments[$key] as $answerset) { $addition = $addition . "predicates:has_answerset '" . $answerset . "'\n"; } break;
				case "questions" : foreach($arguments[$key] as $question) { $addition = $addition . "predicates:has_question '" . $question . "'\n"; } break;
				case "location" : $addition = "predicates:location '" . $arguments[$key] . "\n"; break;
				case "facilitator" : $addition = "predicates:facilitator '" . $arguments[$key] . "\n"; break;
				case "starttime" : $addition = "predicates:starttime '" . $arguments[$key] . "\n"; break;
				case "endtime" : $addition = "predicates:endtime '" . $arguments[$key] . "\n"; break;
				case "session" : $addition = "predicates:of_session '" . $arguments[$key] . "\n"; break;
				case "resultset" : $addition = "predciates:has_resultset '" . $arguments[$key] . "\n"; break;
			}
			$argumentString = $argumentString . $addition;
		}
		return $argumentString;
	}

}

?>
