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

get persistence from ontology model #389

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"oat-sa/oatbox-extension-installer": "dev-master",
"php" : ">=5.3.2",
"psr/log": "~1.0",
"oat-sa/lib-generis-search": "2.0.1"
"oat-sa/lib-generis-search": "2.1.0"
},
"replace": {
"oat-sa/generis":"dev-master"
Expand Down
15 changes: 12 additions & 3 deletions core/kernel/persistence/smoothsql/search/GateWay.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,21 @@ class GateWay extends TaoSearchGateWay {
protected $resultSetClassName = '\\oat\\generis\\model\\kernel\\persistence\\smoothsql\\search\\TaoResultSet';

public function __construct() {
$this->connector = ServiceManager::getServiceManager()
->get(common_persistence_Manager::SERVICE_ID)
->getPersistenceById('default');

}

public function init()
{
$options = $this->getServiceLocator()->get('search.options');
/**
* @var $model \core_kernel_persistence_smoothsql_SmoothModel
*/
$model = $options['model'];
$this->persistence = $model->getPersistence();
return parent::init();
}

/**
* try to connect to database. throw an exception
* if connection failed.
*
Expand Down
31 changes: 21 additions & 10 deletions core/kernel/persistence/smoothsql/search/driver/TaoSearchDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,22 @@ class TaoSearchDriver extends EscaperAbstract {
protected $persistence;

public function __construct() {
$this->persistence = ServiceManager::getServiceManager()
->get(\common_persistence_Manager::SERVICE_ID)
->getPersistenceById('default');

}


public function getPersistence() {
if(is_null($this->persistence)) {
$options = $this->getOptions();
/**
* @var $model \core_kernel_persistence_smoothsql_SmoothModel
*/
$model = $options['model'];
$this->persistence = $model->getPersistence();
}

return $this->persistence;
}

/**
* @inherit
*/
Expand All @@ -47,21 +58,21 @@ public function escape($stringValue) {
* return quoted empty string
*/
public function getEmpty() {
return $this->persistence->getPlatForm()->getNullString();
return $this->getPersistence()->getPlatForm()->getNullString();
}

/**
* @inherit
*/
public function quote($stringValue) {
return $this->persistence->quote($stringValue);
return $this->getPersistence()->quote($stringValue);
}

/**
* @inherit
*/
public function reserved($stringValue) {
return $this->persistence->getPlatForm()->quoteIdentifier($stringValue);
return $this->getPersistence()->getPlatForm()->quoteIdentifier($stringValue);
}

/**
Expand All @@ -73,7 +84,7 @@ public function random() {
'postgresql' => 'random()',
'mssql' => 'NEWID()',
];
$name = $this->persistence->getPlatForm()->getName();
$name = $this->getPersistence()->getPlatForm()->getName();
return $random[$name];
}

Expand All @@ -84,7 +95,7 @@ public function groupAggregation($variable , $separator) {
'postgresql' => 'string_agg',
];

$name = $this->persistence->getPlatForm()->getName();
$name = $this->getPersistence()->getPlatForm()->getName();
return $group[$name] . '(' . $variable . ',' . $this->escape($this->quote($separator)) . ')';
}

Expand All @@ -98,7 +109,7 @@ public function like() {
'postgresql' => 'ILIKE',
];

$name = $this->persistence->getPlatForm()->getName();
$name = $this->getPersistence()->getPlatForm()->getName();
return $like[$name];
}

Expand Down
2 changes: 1 addition & 1 deletion manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'label' => 'Generis Core',
'description' => 'Core extension, provide the low level framework and an API to manage ontologies',
'license' => 'GPL-2.0',
'version' => '4.1.2',
'version' => '4.2.0',
'author' => 'Open Assessment Technologies, CRP Henri Tudor',
'requires' => array(),
'models' => array(
Expand Down
2 changes: 1 addition & 1 deletion scripts/update/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public function update($initialVersion) {
$this->setVersion('3.35.2');
}

$this->skip('3.35.2', '4.1.2');
$this->skip('3.35.2', '4.2.0');
}

private function getReadableModelIds() {
Expand Down