Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| core_kernel_rules_TermFactory | |
0.00% |
0 / 28 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| createConst | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
2 | |||
| createSPX | |
0.00% |
0 / 11 |
|
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) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg |
| 19 | * (under the project TAO-QUAL); |
| 20 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung |
| 21 | * (under the project TAO-TRANSFER); |
| 22 | * 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 23 | */ |
| 24 | |
| 25 | use oat\generis\model\RulesRdf; |
| 26 | |
| 27 | /** |
| 28 | * Short description of class core_kernel_rules_TermFactory |
| 29 | * |
| 30 | * @access public |
| 31 | * @author firstname and lastname of author, <author@example.org> |
| 32 | * @package generis |
| 33 | |
| 34 | */ |
| 35 | class core_kernel_rules_TermFactory |
| 36 | { |
| 37 | // --- ASSOCIATIONS --- |
| 38 | |
| 39 | |
| 40 | // --- ATTRIBUTES --- |
| 41 | |
| 42 | // --- OPERATIONS --- |
| 43 | |
| 44 | /** |
| 45 | * Short description of method createConst |
| 46 | * |
| 47 | * @access public |
| 48 | * @author firstname and lastname of author, <author@example.org> |
| 49 | * @param string $constant |
| 50 | * @return core_kernel_rules_Term |
| 51 | */ |
| 52 | public static function createConst($constant) |
| 53 | { |
| 54 | $returnValue = null; |
| 55 | $termConstClass = new core_kernel_classes_Class(RulesRdf::CLASS_TERM_CONST, __METHOD__); |
| 56 | $termValueProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERM_VALUE, __METHOD__); |
| 57 | $logicalOperatorProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_HASLOGICALOPERATOR, __METHOD__); |
| 58 | $terminalExpressionProperty = new core_kernel_classes_Property( |
| 59 | RulesRdf::PROPERTY_TERMINAL_EXPRESSION, |
| 60 | __METHOD__ |
| 61 | ); |
| 62 | $label = 'Def Term Constant Label : ' . $constant; |
| 63 | $comment = 'Def Term Constant Comment : ' . $constant; |
| 64 | $constantResource = core_kernel_classes_ResourceFactory::create($termConstClass, $label, $comment); |
| 65 | $returnValue = new core_kernel_rules_Term($constantResource->getUri()); |
| 66 | $returnValue->setPropertyValue($terminalExpressionProperty, $returnValue->getUri()); |
| 67 | $returnValue->setPropertyValue($logicalOperatorProperty, RulesRdf::INSTANCE_EXISTS_OPERATOR_URI); |
| 68 | $returnValue->setPropertyValue($termValueProperty, $constant); |
| 69 | $returnValue->debug = __METHOD__; |
| 70 | return $returnValue; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Short description of method createSPX |
| 75 | * |
| 76 | * @access public |
| 77 | * @author firstname and lastname of author, <author@example.org> |
| 78 | * @param Resource $subject |
| 79 | * @param Property $predicate |
| 80 | * @return core_kernel_rules_Term |
| 81 | */ |
| 82 | public static function createSPX(core_kernel_classes_Resource $subject, core_kernel_classes_Property $predicate) |
| 83 | { |
| 84 | $returnValue = null; |
| 85 | $termSPXClass = new core_kernel_classes_Class(RulesRdf::CLASS_TERM_SUJET_PREDICATE_X, __METHOD__); |
| 86 | $label = 'Def Term SPX Label : ' . $subject->getLabel() . ' - ' . $predicate->getLabel(); |
| 87 | $comment = 'Def Term SPX Label : ' . $subject->getUri() . ' ' . $predicate->getUri(); |
| 88 | $SPXResource = core_kernel_classes_ResourceFactory::create($termSPXClass, $label, $comment); |
| 89 | $returnValue = new core_kernel_rules_Term($SPXResource->getUri()); |
| 90 | |
| 91 | $subjectProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERM_SPX_SUBJET, __METHOD__); |
| 92 | $predicateProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERM_SPX_PREDICATE, __METHOD__); |
| 93 | $returnValue->setPropertyValue($subjectProperty, $subject->getUri()); |
| 94 | $returnValue->setPropertyValue($predicateProperty, $predicate->getUri()); |
| 95 | return $returnValue; |
| 96 | } |
| 97 | } |