-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/nex 136/configure spanner #636
Changes from 63 commits
e1fdcd5
8052082
517bb8d
c55d854
bc4d9d3
4f95439
7bc6e55
e363a7a
6d11a56
0432cf5
fe81ec1
b43204a
6f1d3a3
d424b0b
5e3b903
33477d3
c80a0b7
909b164
f55f38b
c1c8b98
05078e2
2f7ec12
7ee367c
6b559fb
e79ab52
710c1c9
5cb5df3
b21434f
bd16e4a
90dc968
99317e3
03e832b
a768a64
76b32d1
d64e869
2cf8572
4900c30
08f3286
e90251b
6c1886d
fd45ee8
18052a8
9c5a791
261a59d
eb9cc5c
9dd2ba3
e0b556e
634889d
7940538
92163d3
9032ebe
949e004
de849cf
c8d7097
f397a74
ee36b3b
1c614d9
dfcd1fa
eee9d6a
6e020dc
472b511
d109921
6417cdb
e513237
d3f9565
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,4 +347,4 @@ public function toArray() | |
return (array) $returnValue; | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
/** | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2019 (original work) Open Assessment Technologies SA | ||
*/ | ||
|
||
namespace oat\generis\model\kernel\api; | ||
|
||
use core_kernel_api_ModelFactory as ModelFactory; | ||
use Doctrine\DBAL\Schema\Schema; | ||
use oat\generis\Helper\UuidPrimaryKeyTrait; | ||
use RuntimeException; | ||
|
||
class NewSqlModelFactory extends ModelFactory | ||
{ | ||
use UuidPrimaryKeyTrait; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function addNewModel($namespace) | ||
{ | ||
$modelId = md5($namespace); | ||
|
||
if ($this->getPersistence()->insert('models', ['modelid' => $modelId, 'modeluri' => $namespace]) === 0) { | ||
throw new RuntimeException('A problem occurred while creating a new model.'); | ||
} | ||
return $modelId; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function prepareStatement($modelId, $subject, $predicate, $object, $lang, $author) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Method |
||
{ | ||
$date = $this->getPersistence()->getPlatForm()->getNowExpression(); | ||
|
||
return [ | ||
'id' => $this->getUniquePrimaryKey(), | ||
'modelid' => $modelId, | ||
'subject' => $subject, | ||
'predicate' => $predicate, | ||
'object' => $object, | ||
'l_language' => $lang, | ||
'author' => $author ?? '', | ||
'epoch' => $date, | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function buildModelSqlCondition(array $models) | ||
{ | ||
$models = array_map( | ||
function ($a) { | ||
return "'" . $a . "'"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we use cast There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where adding the quotes, in fact. $a is supposed to be a string already. |
||
}, | ||
$models | ||
); | ||
return parent::buildModelSqlCondition($models); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getPropertySortingField() | ||
{ | ||
return 'epoch'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function createModelsTable(Schema $schema) | ||
{ | ||
$table = $schema->createTable('models'); | ||
$table->addColumn('modelid', 'string', ['length' => 36, 'notnull' => true]); | ||
$table->addColumn('modeluri', 'string', ['length' => 255]); | ||
$table->setPrimaryKey(['modelid']); | ||
|
||
return $table; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function createStatementsTable(Schema $schema) | ||
{ | ||
$table = $schema->createTable('statements'); | ||
$table->addColumn('id', 'string', ['length' => 36, 'notnull' => true]); | ||
$table->addColumn('modelid', 'string', ['length' => 23, 'notnull' => true]); | ||
$table->addColumn('subject', 'string', ['length' => 255]); | ||
$table->addColumn('predicate', 'string', ['length' => 255]); | ||
$table->addColumn('object', 'text', []); | ||
$table->addColumn('l_language', 'string', ['length' => 255]); | ||
$table->addColumn('author', 'string', ['length' => 255]); | ||
$table->addColumn('epoch', 'string', ['notnull' => true]); | ||
|
||
$table->setPrimaryKey(['id']); | ||
$table->addIndex(['subject', 'predicate'], 'k_sp'); | ||
$table->addIndex(['predicate', 'object'], 'k_po'); | ||
|
||
return $table; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already part of https://github.com/oat-sa/generis/pull/686/files#diff-cb45d9e73f3ab29ea11eadbdc095c55fR59