Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 38 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| core_kernel_rules_ExpressionFactory | |
0.00% |
0 / 38 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| createTerminalExpression | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
6 | |||
| createRecursiveExpression | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
20 | |||
| 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 | |
| 26 | use oat\generis\model\RulesRdf; |
| 27 | |
| 28 | /** |
| 29 | * Short description of class core_kernel_rules_ExpressionFactory |
| 30 | * |
| 31 | * @access public |
| 32 | * @author firstname and lastname of author, <author@example.org> |
| 33 | * @package generis |
| 34 | |
| 35 | */ |
| 36 | class core_kernel_rules_ExpressionFactory |
| 37 | { |
| 38 | // --- ASSOCIATIONS --- |
| 39 | |
| 40 | |
| 41 | // --- ATTRIBUTES --- |
| 42 | |
| 43 | // --- OPERATIONS --- |
| 44 | |
| 45 | /** |
| 46 | * Short description of method createTerminalExpression |
| 47 | * |
| 48 | * @access public |
| 49 | * @author firstname and lastname of author, <author@example.org> |
| 50 | * @param Term term |
| 51 | * @return core_kernel_rules_Expression |
| 52 | */ |
| 53 | public static function createTerminalExpression(core_kernel_rules_Term $term) |
| 54 | { |
| 55 | $returnValue = null; |
| 56 | if ($term == null) { |
| 57 | var_dump($term); |
| 58 | throw new common_Exception('paramaters could not be null'); |
| 59 | } |
| 60 | $expressionClass = new core_kernel_classes_Class(RulesRdf::CLASS_URI_EXPRESSION, __METHOD__); |
| 61 | $label = 'Terminal Expression : ' . $term->getLabel(); |
| 62 | $comment = 'Terminal Expression : ' . $term->getUri(); |
| 63 | $expressionInst = core_kernel_classes_ResourceFactory::create($expressionClass, $label, $comment); |
| 64 | $terminalExpressionProperty = new core_kernel_classes_Property( |
| 65 | RulesRdf::PROPERTY_TERMINAL_EXPRESSION, |
| 66 | __METHOD__ |
| 67 | ); |
| 68 | $returnValue = new core_kernel_rules_Expression($expressionInst->getUri()); |
| 69 | $returnValue->setPropertyValue($terminalExpressionProperty, $term->getUri()); |
| 70 | $returnValue->debug = __METHOD__; |
| 71 | return $returnValue; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Short description of method createRecursiveExpression |
| 76 | * |
| 77 | * @access public |
| 78 | * @author firstname and lastname of author, <author@example.org> |
| 79 | * @param Expression exp1 |
| 80 | * @param Expression exp2 |
| 81 | * @param Resource operator |
| 82 | * @return core_kernel_rules_Expression |
| 83 | */ |
| 84 | public static function createRecursiveExpression( |
| 85 | core_kernel_rules_Expression $exp1, |
| 86 | core_kernel_rules_Expression $exp2, |
| 87 | core_kernel_classes_Resource $operator |
| 88 | ) { |
| 89 | $returnValue = null; |
| 90 | if ($exp1 == null || $exp2 == null || $operator == null) { |
| 91 | var_dump($exp1, $exp2, $operator); |
| 92 | throw new common_Exception('paramaters could not be null'); |
| 93 | } |
| 94 | |
| 95 | $expressionClass = new core_kernel_classes_Class(RulesRdf::CLASS_URI_EXPRESSION, __METHOD__); |
| 96 | $label = 'Expression : ' . $exp1->getLabel() . ' ' . $operator->getLabel() . ' ' . $exp2->getLabel(); |
| 97 | $comment = 'Expression : ' . $exp1->getUri() . ' ' . $operator->getUri() . ' ' . $exp2->getUri(); |
| 98 | $expressionInst = core_kernel_classes_ResourceFactory::create($expressionClass, $label, $comment); |
| 99 | $terminalExpressionProperty = new core_kernel_classes_Property( |
| 100 | RulesRdf::PROPERTY_TERMINAL_EXPRESSION, |
| 101 | __METHOD__ |
| 102 | ); |
| 103 | $logicalOperatorProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_HASLOGICALOPERATOR, __METHOD__); |
| 104 | $firstExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_FIRST_EXPRESSION, __METHOD__); |
| 105 | $secondExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_SECOND_EXPRESSION, __METHOD__); |
| 106 | $returnValue = new core_kernel_rules_Expression($expressionInst->getUri()); |
| 107 | $returnValue->debug = __METHOD__; |
| 108 | $returnValue->setPropertyValue($terminalExpressionProperty, RulesRdf::INSTANCE_EMPTY_TERM_URI); |
| 109 | $returnValue->setPropertyValue($firstExpressionProperty, $exp1->getUri()); |
| 110 | $returnValue->setPropertyValue($secondExpressionProperty, $exp2->getUri()); |
| 111 | $returnValue->setPropertyValue($logicalOperatorProperty, $operator->getUri()); |
| 112 | |
| 113 | |
| 114 | return $returnValue; |
| 115 | } |
| 116 | } |