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 334/global newsql schema branch #693

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
044de79
User-modifiable model id is not hardcoded any more.
julien-sebire Oct 14, 2019
365534e
Model id in namespace is not typed anymore.
julien-sebire Oct 15, 2019
80c98fa
Added types to queries to persistence.
julien-sebire Oct 15, 2019
a7b9338
Added Spanner driver.
julien-sebire Oct 15, 2019
ffd9a2c
Merging branch for unique version bump.
julien-sebire Oct 16, 2019
530a59d
Merge pull request #684 from oat-sa/feature/NEX-334/add-types-to-queries
jbout Oct 16, 2019
b25a5d2
Merge pull request #685 from oat-sa/feature/NEX-334/add-spanner-driver
jbout Oct 17, 2019
2241bf9
Added NewSql model factory.
julien-sebire Oct 18, 2019
199f5dc
Moved getUniquePrimaryKey to UuidPrimaryKeyTrait.
julien-sebire Oct 18, 2019
4c1f394
Fixing use statements location.
julien-sebire Oct 18, 2019
6175dfe
Moved SmoothRdf tests to integration.
julien-sebire Oct 18, 2019
d22475a
Merge branch 'develop' into feature/NEX-336/newsql-schema
julien-sebire Oct 18, 2019
8911d11
Merge branch 'feature/NEX-336/newsql-schema' into feature/NEX-334/abs…
julien-sebire Oct 18, 2019
ce523c0
Merge branch 'feature/NEX-336/newsql-schema' into feature/NEX-334/cle…
julien-sebire Oct 18, 2019
a3d3436
Fixed stashed material.
julien-sebire Oct 22, 2019
499a890
Made all calls to addSmoothTables non-static.
julien-sebire Oct 22, 2019
09a86fc
Merge branch 'feature/NEX-334/cleaning' into feature/NEX-334/global-n…
julien-sebire Oct 22, 2019
c6cfe7d
Merge branch 'feature/NEX-334/namespace-model-id-not-typed' into feat…
julien-sebire Oct 22, 2019
2896986
Merge branch 'feature/NEX-336/user-model-not-hardcoded' into feature/…
julien-sebire Oct 22, 2019
80b93c3
Added missing use statement.
julien-sebire Oct 22, 2019
cab9be5
Skipped logger, not available at the installation time.
julien-sebire Oct 23, 2019
2e86667
Update UuidPrimaryKeyTrait.php
boajer Oct 24, 2019
67f0161
UUID should be string instead of object to be persisted to storage.
julien-sebire Oct 24, 2019
c924b65
Merge pull request #694 from oat-sa/fix/typecasting_for_UUID
julien-sebire Oct 25, 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
7 changes: 4 additions & 3 deletions common/class.Utils.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
use oat\oatbox\PhpSerializable;
use oat\oatbox\service\ServiceManager;
use oat\generis\model\kernel\uri\UriProvider;
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -23,6 +20,10 @@
*
*/

use oat\oatbox\PhpSerializable;
use oat\oatbox\service\ServiceManager;
use oat\generis\model\kernel\uri\UriProvider;

/**
*
* Generis Object Oriented API - common/class.Utils.php
Expand Down
15 changes: 10 additions & 5 deletions common/ext/class.GenerisInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
* 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);
* 2013-2014 (update and modification) Open Assessment Technologies SA;
*
*/

use core_kernel_api_ModelFactory as ModelFactory;
use oat\generis\model\data\ModelManager;
use oat\generis\model\kernel\persistence\smoothsql\search\ComplexSearchService;
use oat\oatbox\service\ServiceManager;
Expand Down Expand Up @@ -48,16 +49,20 @@ public function install()
}

$this->installLoadDefaultConfig();

// Id of the writable model.
$modelFactory = $this->getServiceManager()->get(ModelFactory::SERVICE_ID);
$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],
\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
));
$model->setServiceLocator(ServiceManager::getServiceManager());
$model->setServiceLocator($this->getServiceManager());
ModelManager::setModel($model);

$this->installOntology();
Expand Down
129 changes: 40 additions & 89 deletions common/ext/class.Namespace.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?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);
*
*/

/**
* Short description of class common_ext_Namespace
Expand All @@ -40,130 +40,81 @@ class common_ext_Namespace
* @access protected
* @var int
*/
protected $modelId = 0;
protected $modelId;

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

// --- OPERATIONS ---

/**
* Create a namespace instance
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @param int id
* @param string uri
* @return mixed
* @param string|int id
* @param string uri
*/
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|int
*/
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
*/
public function remove()
{
$returnValue = (bool) false;


$db = core_kernel_classes_DbWrapper::singleton();

// TODO refactor this to use triple store abstraction.
if (false === $db->exec("DELETE FROM statements WHERE modelid = ?", array($this->getModelId()))){
$returnValue = false;
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 = ?", array($this->getModelId()))){
return false;
}



return (bool) $returnValue;
return true;
}

}
}
11 changes: 1 addition & 10 deletions common/persistence/class.Persistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @package generis
*
*/

abstract class common_persistence_Persistence
{
/**
Expand Down Expand Up @@ -102,15 +103,5 @@ protected function getParams(){
protected function setParams($params){
$this->params = $params;
}

/**
* Generates a unique, not auto-increment based, primary key.
*
* @return string
*/
public function getUniquePrimaryKey()
{
return strrev(uniqid('', true));
}
}

Loading