[137] | 1 | <?php |
---|
| 2 | |
---|
| 3 | class SessionRDFWriter |
---|
| 4 | { |
---|
| 5 | protected $model; |
---|
| 6 | |
---|
| 7 | protected $sessionUID; |
---|
| 8 | protected $resourceSession; |
---|
| 9 | |
---|
| 10 | protected $filePath; |
---|
| 11 | |
---|
| 12 | public function __construct($sessionUID) |
---|
| 13 | { |
---|
| 14 | // Create empty MemModel |
---|
| 15 | $factory = new ModelFactory(); |
---|
| 16 | $this->model = $factory->getDefaultModel(); |
---|
| 17 | |
---|
| 18 | $this->sessionUID = $sessionUID; |
---|
| 19 | $this->filePath = 'data/sessions/'; |
---|
| 20 | if (!is_dir($this->filePath)) |
---|
| 21 | mkdir($this->filePath); |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | public function saveAs() |
---|
| 25 | { |
---|
| 26 | $this->model->saveAs($this->filePath. |
---|
| 27 | 'session_' . $this->surveyUID . '/.' . |
---|
| 28 | $this->surveyUID .'.rdf', |
---|
| 29 | 'rdf'); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | public function createSession($sTitle,$sDescription) |
---|
| 33 | { |
---|
| 34 | $this->resourceSession = new Resource(SESSION.'/'.$this->sessionUID); |
---|
| 35 | |
---|
| 36 | $resourceSessionType = new Resource(SESSION); |
---|
| 37 | $predicateRType = new Resource(RTYPE); |
---|
| 38 | $this->model->add(new Statement($this->resourceSession,$predicateRType,$resourceSessionType)); |
---|
| 39 | |
---|
| 40 | $literalSessionID = new Literal($this->sessionUID); |
---|
| 41 | $predicateUniqueID = new Resource(UID); |
---|
| 42 | $this->model->add(new Statement($this->resourceSession,$predicateUniqueID,$literalSessionID)); |
---|
| 43 | |
---|
| 44 | $predicateTitle = new Resource(TITLE); |
---|
| 45 | $sessionTitle = new Literal($sTitle); |
---|
| 46 | $this->model->add(new Statement($this->resourceSession,$predicateTitle,$sessionTitle)); |
---|
| 47 | |
---|
| 48 | $predicateDescription = new Resource(DESCRIPTION); |
---|
| 49 | $sessionDescription = new Literal($sDescription); |
---|
| 50 | $this->model->add(new Statement($this->resourceSession,$predicateDescription,$sessionDescription)); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | public function addSurveyToPipeline($uid,$index) |
---|
| 54 | { |
---|
| 55 | $resourceSurvey = new Resource(SURVEY); |
---|
| 56 | $predicateHasProcess = new Resource(HAS_PROCESS); |
---|
| 57 | $this->model->add(new Statement($this->resourceSession,$predicateHasProcess,$resourceSurvey)); |
---|
| 58 | |
---|
| 59 | $literalSurveyID = new Literal($uid); |
---|
| 60 | $predicateUID = new Resource(UID); |
---|
| 61 | $this->model->add(new Statement($$resourceSurvey,$predicateUID,$literalSurveyID)); |
---|
| 62 | |
---|
| 63 | $literalIndex = new Literal($index); |
---|
| 64 | $predicateIndex = new Resource(INDEX); |
---|
| 65 | $this->model->add(new Statement($resourceSurvey,$predicateIndex,$literalIndex)); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | public function addApplicationToPipeline($uid,$index) |
---|
| 69 | { |
---|
| 70 | $resourceApplication = new Resource(APPLICATION); |
---|
| 71 | $predicateHasProcess = new Resource(HAS_PROCESS); |
---|
| 72 | $this->model->add(new Statement($this->resourceSession,$predicateHasProcess,$resourceApplication)); |
---|
| 73 | |
---|
| 74 | $literalApplicationID = new Literal($uid,$index); |
---|
| 75 | $predicateUID = new Resource(UID); |
---|
| 76 | $this->model->add(new Statement($resourceApplication,$predicateUID,$literalApplicationID)); |
---|
| 77 | |
---|
| 78 | $literalIndex = new Literal($index); |
---|
| 79 | $predicateIndex = new Resource(INDEX); |
---|
| 80 | $this->model->add(new Statement($resourceApplication,$predicateIndex,$literalIndex)); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | public function addDashboardToPipeline($uid,$index) |
---|
| 84 | { |
---|
| 85 | $resourceDashboard = new Resource(DASHBOARD); |
---|
| 86 | $predicateHasProcess = new Resource(HAS_PROCESS); |
---|
| 87 | $this->model->add(new Statement($this->resourceSession,$predicateHasProcess,$resourceDashboard)); |
---|
| 88 | |
---|
| 89 | $literalDashboardID = new Literal($uid); |
---|
| 90 | $predicateUID = new Resource(UID); |
---|
| 91 | $this->model->add(new Statement($resourceDashboard,$predicateUID,$literalDashboardID)); |
---|
| 92 | |
---|
| 93 | $literalIndex = new Literal($index); |
---|
| 94 | $predicateIndex = new Resource(INDEX); |
---|
| 95 | $this->model->add(new Statement($resourceDashboard,$predicateIndex,$literalIndex)); |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | ?> |
---|