server/src/app/Libraries/RdfModel/RdfModelResource.php
author ymh <ymh.work@gmail.com>
Fri, 15 Jan 2016 15:35:00 +0100
changeset 28 b0b56e0f8c7f
parent 4 f55970e41793
child 277 bd4bc1db4f40
permissions -rw-r--r--
Add contributor edition - added viaf resolver - improve contributors list display - add update of document objects - propagate update to back office - update back office - add bo-client to back office - setup language initializer - add options mechanism - add language information in language list - add lexvo resolver service + api - add language and lexvo resolver to js app - correct env template - refresh bootstrap - download google font - add version information - update dev virtual machine to centos7 - add a readme + clean folders - add local .env file to start commands
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
namespace CorpusParole\Libraries\RdfModel;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
use CorpusParole\Libraries\RdfModel\RdfModelDelta;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
use EasyRdf\Resource;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
/**
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 *
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 */
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
class RdfModelResource extends Resource {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
    public function __construct($uri, $graph = null) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
        parent::__construct($uri, $graph);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
        $this->uri = $uri;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    protected $deltaList = [];
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    protected $currentDelta = null;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    protected $uri = null;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    public function isDirty() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
        return !is_null($this->deltaList) && count($this->deltaList)>0;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    public function deltaCount() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
        return is_null($this->deltaList)?0:count($this->deltaList);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
    public function getDeltaList() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
        return $this->deltaList;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
    public function getUri() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
        return $this->uri;
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    37
    public function getCurrentDelta() {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    38
        return $this->getCurrentDelta;
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    39
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    40
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
    public function startDelta() {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
        $this->currentDelta = new RdfModelDelta($this->getGraph()->getUri());
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
        array_push($this->deltaList, $this->currentDelta);
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    44
        return $this->currentDelta;
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    45
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    46
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    47
    protected function setSimpleProperty($baseNode, $property, $oldValue, $newValue) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    48
        $delta = $this->startDelta();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    49
        $baseNode->delete($property, $oldValue);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    50
        $delta->getDeletedGraph()->add($baseNode, $property, $oldValue);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    51
        $baseNode->add($property, $newValue);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    52
        $delta->getAddedGraph()->add($baseNode, $property, $newValue);
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
    }
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
}