Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
26 / 26 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| RdsResultStorage | |
100.00% |
26 / 26 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| getVariablesSortingField | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| prepareVariableDataForSchema | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| createVariablesTable | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
1 | |||
| 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) 2014-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | */ |
| 20 | |
| 21 | namespace oat\taoOutcomeRds\model; |
| 22 | |
| 23 | use Doctrine\DBAL\Schema\Schema; |
| 24 | use taoResultServer_models_classes_Variable as Variable; |
| 25 | |
| 26 | /** |
| 27 | * Implements tao results storage for RDS |
| 28 | */ |
| 29 | class RdsResultStorage extends AbstractRdsResultStorage |
| 30 | { |
| 31 | /** |
| 32 | * @inheritDoc |
| 33 | */ |
| 34 | protected function getVariablesSortingField() |
| 35 | { |
| 36 | return self::VARIABLES_TABLE_ID; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * @inheritdoc |
| 41 | */ |
| 42 | protected function prepareVariableDataForSchema($deliveryResultIdentifier, $test, Variable $variable, $callId) |
| 43 | { |
| 44 | $serializedVariable = $this->serializeVariableValue($variable); |
| 45 | |
| 46 | return [ |
| 47 | self::VARIABLES_FK_COLUMN => $deliveryResultIdentifier, |
| 48 | self::TEST_COLUMN => $test, |
| 49 | self::VARIABLE_IDENTIFIER => $variable->getIdentifier(), |
| 50 | self::VARIABLE_VALUE => $serializedVariable, |
| 51 | self::VARIABLE_HASH => $deliveryResultIdentifier |
| 52 | . md5($deliveryResultIdentifier . $serializedVariable . $callId), |
| 53 | ]; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @inheritDoc |
| 58 | */ |
| 59 | public function createVariablesTable(Schema $schema) |
| 60 | { |
| 61 | $table = $schema->createtable(self::VARIABLES_TABLENAME); |
| 62 | $table->addOption('engine', 'MyISAM'); |
| 63 | |
| 64 | $table->addColumn(self::VARIABLES_TABLE_ID, 'integer', ['autoincrement' => true]); |
| 65 | $table->addColumn(self::CALL_ID_TEST_COLUMN, 'string', ['notnull' => false, 'length' => 255]); |
| 66 | $table->addColumn(self::CALL_ID_ITEM_COLUMN, 'string', ['notnull' => false, 'length' => 255]); |
| 67 | $table->addColumn(self::TEST_COLUMN, 'string', ['notnull' => false, 'length' => 255]); |
| 68 | $table->addColumn(self::ITEM_COLUMN, 'string', ['notnull' => false, 'length' => 255]); |
| 69 | $table->addColumn(self::VARIABLE_VALUE, 'text', ['notnull' => false]); |
| 70 | $table->addColumn(self::VARIABLE_IDENTIFIER, 'string', ['notnull' => false, 'length' => 255]); |
| 71 | $table->addColumn(self::VARIABLES_FK_COLUMN, 'string', ['length' => 255]); |
| 72 | $table->addColumn(self::VARIABLE_HASH, 'string', ['length' => 255, 'notnull' => false]); |
| 73 | |
| 74 | $table->setPrimaryKey([self::VARIABLES_TABLE_ID]); |
| 75 | $table->addUniqueIndex([self::VARIABLE_HASH], self::UNIQUE_VARIABLE_INDEX); |
| 76 | $table->addIndex([self::CALL_ID_ITEM_COLUMN], self::CALL_ID_ITEM_INDEX); |
| 77 | $table->addIndex([self::CALL_ID_TEST_COLUMN], self::CALL_ID_TEST_INDEX); |
| 78 | |
| 79 | return $table; |
| 80 | } |
| 81 | } |