Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 41
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
RdfWrapper
0.00% covered (danger)
0.00%
0 / 41
0.00% covered (danger)
0.00%
0 / 6
182
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 add
0.00% covered (danger)
0.00%
0 / 36
0.00% covered (danger)
0.00%
0 / 1
72
 remove
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 search
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getIterator
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2002-2017 (original work) 2014 Open Assessment Technologies SA
19 *
20 */
21
22namespace oat\generis\model\kernel\persistence\wrapper;
23
24use oat\generis\model\data\RdfsInterface;
25use oat\generis\model\GenerisRdf;
26use oat\generis\model\OntologyRdf;
27use oat\generis\model\OntologyRdfs;
28
29/**
30 * Wraps the RdfsInterface in a Rdf interface
31 *
32 * @author Joel Bout
33 */
34class RdfWrapper implements \oat\generis\model\data\RdfInterface
35{
36    /**
37     * @var RdfsInterface
38     */
39    private $rdfsInterface;
40
41    public function __construct(RdfsInterface $rdfsInterface)
42    {
43        $this->rdfsInterface = $rdfsInterface;
44    }
45
46    /**
47     * (non-PHPdoc)
48     * @see \oat\generis\model\data\RdfInterface::get()
49     */
50    public function get($subject, $predicate)
51    {
52        throw new \common_Exception('Not implemented');
53    }
54
55    /**
56     * (non-PHPdoc)
57     * @see \oat\generis\model\data\RdfInterface::add()
58     */
59    public function add(\core_kernel_classes_Triple $triple)
60    {
61        switch ($triple->predicate) {
62            case OntologyRdf::RDF_TYPE:
63                $resource = new \core_kernel_classes_Resource($triple->subject);
64                $class = new \core_kernel_classes_Class($triple->object);
65                return $this->rdfsInterface->getResourceImplementation()->setType($resource, $class);
66                break;
67
68            case OntologyRdfs::RDFS_RANGE:
69                $resource = new \core_kernel_classes_Property($triple->subject);
70                $class = new \core_kernel_classes_Class($triple->object);
71                return $this->rdfsInterface->getPropertyImplementation()->setRange($resource, $class);
72                break;
73
74            case GenerisRdf::PROPERTY_MULTIPLE:
75                $resource = new \core_kernel_classes_Property($triple->subject);
76                $value = $triple->object == GenerisRdf::GENERIS_TRUE;
77                return $this->rdfsInterface->getPropertyImplementation()->setMultiple($resource, $value);
78                break;
79
80            case GenerisRdf::PROPERTY_IS_LG_DEPENDENT:
81                $resource = new \core_kernel_classes_Property($triple->subject);
82                $value = $triple->object == GenerisRdf::GENERIS_TRUE;
83                return $this->rdfsInterface->getPropertyImplementation()->setLgDependent($resource, $value);
84                break;
85
86            case OntologyRdfs::RDFS_DOMAIN:
87            default:
88                $resource = new \core_kernel_classes_Resource($triple->subject);
89                $property = new \core_kernel_classes_Property($triple->predicate);
90                if (empty($triple->lg)) {
91                    return $this->rdfsInterface->getResourceImplementation()->setPropertyValue(
92                        $resource,
93                        $property,
94                        $triple->object
95                    );
96                } else {
97                    return $this->rdfsInterface->getResourceImplementation()->setPropertyValueByLg(
98                        $resource,
99                        $property,
100                        $triple->object,
101                        $triple->lg
102                    );
103                }
104        }
105    }
106
107    /**
108     * (non-PHPdoc)
109     * @see \oat\generis\model\data\RdfInterface::remove()
110     */
111    public function remove(\core_kernel_classes_Triple $triple)
112    {
113        throw new \common_Exception('Not implemented');
114    }
115
116    /**
117     * (non-PHPdoc)
118     * @see \oat\generis\model\data\RdfInterface::search()
119     */
120    public function search($predicate, $object)
121    {
122        throw new \common_Exception('Not implemented');
123    }
124
125    public function getIterator()
126    {
127        throw new \common_Exception('Not implemented');
128    }
129}