fileName = 'data/users/respondents.rdf'; if (!is_dir('data/users/')) mkdir('data/users/'); } /** * function get() * Gets the array of Respondent objects belonging to arguments supplied. * @param type $arguments : An array containing zero or more of the following keys: * 'uid', 'name', 'password' */ public function get($arguments) { $this->load(); //Create the querystring $querystring = ' PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> SELECT ?uid, ?name, ?password WHERE { _respondent predicates:resource_type resources:respondent ; predicates:uid ?uid ; predicates:name ?name ; predicates:password ?password ; ' . $this->createArguments($arguments) . ' }'; //Query the model $results = $this->model->sparqlQuery($querystring); $respondents = array(); if(!empty($results)) { //Run over all results and create appropriate Respondent objets foreach($results as $result) { $respondents[] = new Respondent($result['?uid']->label, $result['?name']->label, $result['?password']->label); } } return $respondents; } /** * function set() * @param type $rToolObject : The ResearchToolObject to be saved. */ public function set($rToolObject) { $this->load(); $resourceRespondent = new Resource(RESPONDENT . '/' . $rToolObject->uid); //Remove the old value stored with the given id $this->model->subtract($this->model->find($resourceRespondent, null, null)); //Set the new values $resourceRespondentType = new Resource(RESPONDENT); $predicateRType = new Resource(RTYPE); $this->model->add(new Statement($resourceRespondent,$predicateRType,$resourceRespondentType)); $literalRespondentID = new Literal($rToolObject->uid); $predicateUniqueID = new Resource(UID); $this->model->add(new Statement($resourceRespondent,$predicateUniqueID,$literalRespondentID)); $literalRespondentName = new Literal($rToolObject->name); $predicateName = new Resource(NAME); $this->model->add(new Statement($resourceRespondent,$predicateName,$literalRespondentName)); $literalPassword = new Literal($rToolObject->password); $predicatePassword = new Resource(PASSWORD); $this->model->add(new Statement($resourceRespondent,$predicatePassword,$literalPassword)); $this->save(); } } ?>