fileName = 'data/users/users.rdf'; //Ensure the required folder for this connector exists if (!is_dir('data/users/')) mkdir('data/users/'); } /** * function get($arguments) * Gets the array of User 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 { _user predicates:resource_type resources:user ; predicates:uid ?uid ; predicates:name ?name ; predicates:password ?password ; ' . $this->createArguments($arguments) . ' }'; //Query the model $results = $this->model->sparqlQuery($querystring); $users = array(); if(!empty($results)) { //Run over all results and create appropriate Application objets foreach($results as $result) { $users[] = new User($result['?uid']->label, $result['?name']->label, $result['?password']->label); } } return $users; } /** * Save the given User object in the file. * @param type $rToolObject */ public function set($rToolObject) { $this->load(); $resourceUser = new Resource(USER . '/' . $rToolObject->uid); //Remove the old value stored with the given id $this->model->subtract($this->model->find($resourceUser, null, null)); $resourceUserType = new Resource(USER); $predicateRType = new Resource(RTYPE); $this->model->add(new Statement($resourceUser,$predicateRType,$resourceUserType)); $literalUserID = new Literal($rToolObject->uid); $predicateUniqueID = new Resource(UID); $this->model->add(new Statement($resourceUser,$predicateUniqueID,$literalUserID)); $literalUserName = new Literal($rToolObject->name); $predicateName = new Resource(NAME); $this->model->add(new Statement($resourceUser,$predicateName,$literalUserName)); $literalPassword = new Literal($rToolObject->password); $predicatePassword = new Resource(PASSWORD); $this->model->add(new Statement($resourceUser,$predicatePassword,$literalPassword)); $this->save(); } } ?>