model = ModelFactory::getDefaultModel(); //Ensure the required file exists before loading if(file_exists($this->fileName)) $this->model->load($this->fileName); } /** * function save() * Saves the MemModel into the given file. */ public function save() { $this->model->saveAs($this->fileName,'rdf'); } /** * function get($arguments) * Gets the array of Application objects belonging to arguments supplied. * @param type $arguments : An array containing zero or more of the following keys: * 'id', 'title', 'description', 'style' */ public function get($arguments) { $this->load(); //Determine which arguments are supplied $keys = array_keys($arguments); //Set default values for arguments $id = "?uid"; $title = "?title"; $description = "?description"; $style = "?style"; //Set the arguments if they are supplied if(in_array("id", $keys)) $id = "\"".$arguments["id"]."\""; if(in_array("title", $keys)) $title = '\''.$arguments["title"].'\''; if(in_array("description", $keys)) $description = "\"".$arguments["description"]."\""; if(in_array("style", $keys)) $style = "\"".$arguments["style"]."\""; //Create the querystring $querystring = ' PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> SELECT ?uid, ?title, ?description, ?style WHERE { _application predicates:resource_type resources:application ; predicates:uid '. $id . '; predicates:title '. $title . '; predicates:description '. $description . '; predicates:style '. $style .' }'; //Query the model echo $querystring; $results = $this->model->sparqlQuery($querystring); $applications = array(); echo count($results); //Run over all results and create appropriate Application objets foreach($results as $result) { $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label); } //Return the list of application objects return $applications; } /** * function set() * Finds the required databaseentry matching the given objects and removes * it from the rdf file. * @param type $rToolObject */ public function set($rToolObject) { //TODO } } ?>