Skip to content
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

Closed
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e1fdcd5
Use DBAL now expression
jbout Jun 6, 2019
8052082
Move to a uuid statements primary key
jbout Jun 6, 2019
517bb8d
Fixed statements table creation.
julien-sebire Jun 6, 2019
c55d854
Fixed schema and typos...
julien-sebire Jun 6, 2019
bc4d9d3
Changes to make it work a little bit more.
Jun 6, 2019
4f95439
Merge branch 'feature/autoincrement-less-statements' of https://githu…
Jun 6, 2019
7bc6e55
Fixed wrong call to uuid generator.
julien-sebire Jun 6, 2019
e363a7a
Changed hard-coded value for writable model id with a key generated w…
julien-sebire Jun 6, 2019
6d11a56
Some codestyle.
julien-sebire Jun 6, 2019
0432cf5
Got rid of gcp Spanner reference in comments.
julien-sebire Jun 6, 2019
fe81ec1
PR fixes.
julien-sebire Jun 6, 2019
b43204a
Fixed insert return value testing.
julien-sebire Jun 6, 2019
6f1d3a3
Use the configured writable model id instead of hardcoded value.
julien-sebire Jun 6, 2019
d424b0b
Ensure that the searched model uri has a trailing #.
julien-sebire Jun 6, 2019
5e3b903
Merge branch 'develop' into feature/autoincrement-less-statements
Jun 7, 2019
33477d3
Upgraded dbal to version 2.9 and required doctrine/annotations.
julien-sebire Jun 11, 2019
c80a0b7
Added spanner dbal driver.
julien-sebire Jun 12, 2019
909b164
Added minimum stability dev to get lib-dbal-spanner:dev-develop.
julien-sebire Jun 12, 2019
f55f38b
Required branch feature/NEX-84/spanner-query-refactoring of lib-dbal-…
julien-sebire Jun 12, 2019
c1c8b98
Adding minimum stability:dev.
julien-sebire Jun 12, 2019
05078e2
Merge remote-tracking branch 'origin/feature/NEX-121/upgrade-php71' i…
julien-sebire Jun 13, 2019
2f7ec12
Merge remote-tracking branch 'origin/fix/now-expression' into feature…
julien-sebire Jun 13, 2019
7ee367c
Merge remote-tracking branch 'origin/feature/autoincrement-less-state…
julien-sebire Jun 13, 2019
6b559fb
requiring lib-search added quoting of modelId.
julien-sebire Jun 17, 2019
e79ab52
Merge branch 'feature/NEX-136/configure-spanner' of github.com:oat-sa…
julien-sebire Jun 17, 2019
710c1c9
Moved Uuid primary key generation to oat\generis\Helper\UuidPrimaryKe…
julien-sebire Jun 20, 2019
5cb5df3
Merge remote-tracking branch 'origin/feature/NEX-136/configure-spanne…
julien-sebire Jun 20, 2019
b21434f
Changed Uuid storing size to 23 bytes.
julien-sebire Jun 21, 2019
bd16e4a
Added enclosing quotes for model id.
julien-sebire Jul 16, 2019
90dc968
Merge remote-tracking branch 'origin/feature/NEX-136/configure-spanne…
julien-sebire Jul 16, 2019
99317e3
Merged develop.
julien-sebire Jul 16, 2019
03e832b
Opened statement type hinting to SpannerStatement also.
julien-sebire Jul 18, 2019
a768a64
Casted object property to string (Spanner is strict on field types).
julien-sebire Jul 18, 2019
76b32d1
Added temporary LIKE comparator for Spanner.
julien-sebire Jul 23, 2019
d64e869
Merge remote-tracking branch 'origin/develop' into feature/NEX-136/co…
julien-sebire Jul 31, 2019
2cf8572
Merge branch 'develop' into feature/NEX-136/configure-spanner
jbout Aug 7, 2019
4900c30
Merge branch 'develop' into feature/NEX-136/configure-spanner
julien-sebire Aug 20, 2019
08f3286
Removed Spanner dependency for AWS benchmark.
julien-sebire Aug 27, 2019
e90251b
Removed Spanner class in type hint for aws benchmark.
julien-sebire Sep 2, 2019
6c1886d
Casted boolean values to integer in prepared statement for postgres d…
julien-sebire Sep 5, 2019
fd45ee8
Set bin2hex as default uri provider.
julien-sebire Sep 6, 2019
18052a8
Added types to all queries.
julien-sebire Sep 9, 2019
9c5a791
Removed wrong fix for postgres boolean issue.
julien-sebire Sep 16, 2019
261a59d
Merged develop back into NEX-136
julien-sebire Sep 19, 2019
eb9cc5c
Added abstract changes to enable schema changes.
julien-sebire Sep 23, 2019
9dd2ba3
Merge branch 'feature/NEX-136/configure-spanner' of https://github.co…
julien-sebire Sep 23, 2019
e0b556e
Merge branch 'develop' into feature/NEX-136/configure-spanner
julien-sebire Sep 23, 2019
634889d
Removed forgotten TODOs.
julien-sebire Sep 23, 2019
7940538
Merge branch 'feature/NEX-136/configure-spanner' of https://github.co…
julien-sebire Sep 23, 2019
92163d3
Added an abstraction level for ModelFactory.
julien-sebire Oct 2, 2019
9032ebe
Revert CRLF change.
julien-sebire Oct 2, 2019
949e004
Merge branch 'develop' into feature/NEX-136/configure-spanner
julien-sebire Oct 2, 2019
de849cf
Merge branch 'develop' into feature/NEX-136/configure-spanner
julien-sebire Oct 3, 2019
c8d7097
Updated composer.json to require changes in lib-generis-search.
julien-sebire Oct 3, 2019
f397a74
Removed unrelated commits.
julien-sebire Oct 15, 2019
ee36b3b
Reverted CRLF changes in Namespace.
julien-sebire Oct 15, 2019
1c614d9
PR fixes.
julien-sebire Oct 17, 2019
dfcd1fa
Moved smooth tests to integration.
julien-sebire Oct 17, 2019
eee9d6a
FQCN fixes + code style.
julien-sebire Oct 17, 2019
6e020dc
Independent tests.
julien-sebire Oct 17, 2019
472b511
Removed getUniquePrimaryKey from persistence, provided by helper.
julien-sebire Oct 17, 2019
d109921
Merge branch 'feature/NEX-136/configure-spanner' of https://github.co…
julien-sebire Oct 17, 2019
6417cdb
Model ids as md5 of namespaces.
julien-sebire Oct 17, 2019
e513237
Removed GenerisInstaller, already in other PR.
julien-sebire Oct 17, 2019
d3f9565
Replaced dbWrapper with Persistence.
julien-sebire Oct 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions common/ext/class.GenerisInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ public function install()
}

$this->installLoadDefaultConfig();


// Id of the writable model.
$modelFactory = new \core_kernel_api_ModelFactory();
$writableModelId = $modelFactory->getModelId(LOCAL_NAMESPACE);

$model = new \core_kernel_persistence_smoothsql_SmoothModel(array(
\core_kernel_persistence_smoothsql_SmoothModel::OPTION_PERSISTENCE => 'default',
\core_kernel_persistence_smoothsql_SmoothModel::OPTION_READABLE_MODELS => array('1'),
\core_kernel_persistence_smoothsql_SmoothModel::OPTION_WRITEABLE_MODELS => array('1'),
\core_kernel_persistence_smoothsql_SmoothModel::OPTION_NEW_TRIPLE_MODEL => '1',
\core_kernel_persistence_smoothsql_SmoothModel::OPTION_READABLE_MODELS => [$writableModelId],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\core_kernel_persistence_smoothsql_SmoothModel::OPTION_WRITEABLE_MODELS => [$writableModelId],
\core_kernel_persistence_smoothsql_SmoothModel::OPTION_NEW_TRIPLE_MODEL => $writableModelId,
\core_kernel_persistence_smoothsql_SmoothModel::OPTION_SEARCH_SERVICE => ComplexSearchService::SERVICE_ID,
\core_kernel_persistence_smoothsql_SmoothModel::OPTION_CACHE_SERVICE => common_cache_Cache::SERVICE_ID
));
Expand Down
146 changes: 47 additions & 99 deletions common/ext/class.Namespace.php
Original file line number Diff line number Diff line change
@@ -1,169 +1,117 @@
<?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) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
*
*/
<?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) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
ferenckiss89 marked this conversation as resolved.
Show resolved Hide resolved
*
*/

/**
* Short description of class common_ext_Namespace
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @package generis

*/
class common_ext_Namespace
{
// --- ASSOCIATIONS ---
// generateAssociationEnd :

// --- ATTRIBUTES ---

/**
* A unique identifier of the namespace
*
* @access protected
* @var int
* @var string
*/
protected $modelId = 0;
protected $modelId;

/**
* the namespace URI
*
* @access protected
* @var string
*/
protected $uri = '';

// --- OPERATIONS ---
protected $uri;

/**
* Create a namespace instance
* Namespace constructor.
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @param int id
*
* @param string id
* @param string uri
* @return mixed
*/
public function __construct($id = 0, $uri = '')
public function __construct($id = '', $uri = '')
{


if($id > 0){
$this->modelId = $id;
}
if(!empty($uri)){
$this->uri = $uri;
}


$this->modelId = $id;
$this->uri = $uri;
}

/**
* Get the identifier of the namespace instance
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @return int
* @return string
*/
public function getModelId()
{
$returnValue = (int) 0;



$returnValue = $this->modelId;



return (int) $returnValue;
return $this->modelId;
}

/**
* Get the namespace URI
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @return string
*/
public function getUri()
{
$returnValue = (string) '';



$returnValue = $this->uri;



return (string) $returnValue;
return $this->uri;
}

/**
* Magic method, return the Namespace URI
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @return string
*/
public function __toString()
{
$returnValue = (string) '';



$returnValue = $this->getUri();



return (string) $returnValue;
return $this->getUri();
}

/**
* Remove a namespace from the ontology. All triples bound to the model will
* be removed.
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
*
* @return boolean
* @throws core_kernel_persistence_Exception
*/
public function remove()
{
$returnValue = (bool) false;


$db = core_kernel_classes_DbWrapper::singleton();
if (false === $db->exec("DELETE FROM statements WHERE modelid = ?", array($this->getModelId()))){
$returnValue = false;

// TODO refactor this to use triple store abstraction.
if (false === $db->exec("DELETE FROM statements WHERE modelid = ?", [$this->getModelId()])) {
return false;
}
else{
if (false === $db->exec("DELETE FROM models WHERE modelid = ?", array($this->getModelId()))){
$returnValue = false;
}
else{
$returnValue = true;
}

// TODO refactor this to use triple store abstraction.
if (false === $db->exec("DELETE FROM models WHERE modelid = ?", [$this->getModelId()])) {
return false;
}



return (bool) $returnValue;
return true;
}

}
}
1 change: 1 addition & 0 deletions common/persistence/class.SqlPersistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function getPlatForm(){
* @author "Lionel Lecaque, <lionel@taotesting.com>"
* @param string $tableName
* @param array $data
* @return int
*/
public function insert($tableName, array $data)
{
Expand Down
5 changes: 1 addition & 4 deletions common/persistence/sql/class.Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@ public function getName(){
* @return string
*/
public function getNowExpression(){
$datetime = new DateTime('now', new \DateTimeZone('UTC'));
$date = $datetime->format('Y-m-d H:i:s');
// return $this->dbalPlatform->getNowExpression();
return $date;
return $this->dbalPlatform->getNowExpression();
}

/**
Expand Down
15 changes: 12 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,24 @@
"extra": {
"tao-extension-name": "generis"
},
"repositories": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repositories added in non root composer.json will be ignored an lead to confussion

{
"type": "vcs",
"url": "git@github.com:oat-sa/lib-dbal-spanner.git"
}
],
"require": {
"clearfw/clearfw": "~1.2.0",
"easyrdf/easyrdf": "^0.9.0",
"doctrine/dbal": "~2.5.0",
"doctrine/dbal": "^2.9.0",
"doctrine/annotations": "1.*",
"zendframework/zend-servicemanager": "~2.5.0",
"league/flysystem": "~1.0",
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"php": "^7.1",
ferenckiss89 marked this conversation as resolved.
Show resolved Hide resolved
"psr/log": "~1.0",
"oat-sa/lib-generis-search": "^2.0.1",
"oat-sa/lib-generis-search": "dev-feature/NEX-84/spanner-compatible-statements",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop branches should not be references

"oat-sa/lib-dbal-spanner": "dev-feature/NEX-84/spanner-query-refactoring",
"monolog/monolog": "^1.23.0",
"fluent/logger": "^1.0.1",
"symfony/lock": "^3.4",
Expand Down Expand Up @@ -90,5 +98,6 @@
"psr-4": {
"oat\\generis\\test\\": "generis/test/"
}
}
},
"minimum-stability" : "dev"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimum-stability is ignored in non root composer.json and can be confussing

}
Loading