Skip to content

Commit

Permalink
Merge pull request #163 from oat-sa/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Jérôme Bogaerts committed Mar 10, 2016
2 parents 8fe9e2f + c5ba343 commit 170ec94
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 57 deletions.
3 changes: 2 additions & 1 deletion common/class.Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ public static function toHumanReadablePhpString($value, $indentation = 0)
}
$returnValue = "array(".substr($string, 0, -1).PHP_EOL.str_repeat(' ', $indentation).")";
} else {
$returnValue = self::toPHPVariableString($value);
$lines = explode(PHP_EOL, self::toPHPVariableString($value));
$returnValue = implode(PHP_EOL.str_repeat(' ', $indentation), $lines);
}

return (string) $returnValue;
Expand Down
5 changes: 3 additions & 2 deletions core/kernel/persistence/smoothsql/class.Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static public function buildSearchPattern(common_persistence_SqlPersistence $per
if (!$wildcard && $object === '%') {
$object = '%%';
}
$returnValue .= 'LIKE '. $persistence->quote($object);
$returnValue .= 'LIKE LOWER(' . $persistence->quote($object) . ')';
} else {
$returnValue .= '= '. $persistence->quote($patternToken);
}
Expand All @@ -201,7 +201,8 @@ static public function buildPropertyQuery(core_kernel_persistence_smoothsql_Smoo

$valuePatterns = array();
foreach ($values as $val) {
$valuePatterns[] = 'object ' . self::buildSearchPattern($persistence, $val, $like);
$pattern = $like ? 'LOWER(object) ' : 'object ';
$valuePatterns[] = $pattern . self::buildSearchPattern($persistence, $val, $like);
}

$sqlValues = implode(' OR ', $valuePatterns);
Expand Down
12 changes: 8 additions & 4 deletions core/kernel/persistence/wrapper/RdfWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,34 @@ public function get($subject, $predicate) {
* @see \oat\generis\model\data\RdfInterface::add()
*/
public function add(\core_kernel_classes_Triple $triple) {
$resource = new \core_kernel_classes_Resource($triple->subject);
switch ($triple->object) {
switch ($triple->predicate) {
case RDF_TYPE :
$resource = new \core_kernel_classes_Resource($triple->subject);
$class = new \core_kernel_classes_Class($triple->object);
return $this->rdfsInterface->getResourceImplementation()->setType($resource, $class);
break;

case RDFS_RANGE :
$class = new \core_kernel_classes_Class($triple->object);
$resource = new \core_kernel_classes_Property($triple->subject);
$class = new \core_kernel_classes_Class($triple->object);
return $this->rdfsInterface->getPropertyImplementation()->setRange($resource, $class);
break;

case PROPERTY_MULTIPLE :
$resource = new \core_kernel_classes_Property($triple->subject);
$value = $triple->object == GENERIS_TRUE;
return $this->rdfsInterface->getPropertyImplementation()->setMultiple($resource, $value);
break;

case PROPERTY_IS_LG_DEPENDENT :
$resource = new \core_kernel_classes_Property($triple->subject);
$value = $triple->object == GENERIS_TRUE;
return $this->rdfsInterface->getPropertyImplementation()->isLgDependent($resource, $value);
return $this->rdfsInterface->getPropertyImplementation()->setLgDependent($resource, $value);
break;

case RDFS_DOMAIN :
default:
$resource = new \core_kernel_classes_Resource($triple->subject);
$property = new \core_kernel_classes_Property($triple->predicate);
if (empty($triple->lg)) {
return $this->rdfsInterface->getResourceImplementation()->setPropertyValue($resource, $property, $triple->object);
Expand Down
64 changes: 30 additions & 34 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,39 @@
*/

/**
*
* @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
* @license GPLv2 http://www.opensource.org/licenses/gpl-2.0.php
* @license GPLv2 http://www.opensource.org/licenses/gpl-2.0.php
*/
return array(
'name' => 'generis',
'label' => 'Core',
'name' => 'generis',
'label' => 'Core',
'description' => 'Core extension, provide the low level framework and an API to manage ontologies',
'license' => 'GPL-2.0',
'version' => '2.15.0',
'author' => 'Open Assessment Technologies, CRP Henri Tudor',
'requires' => array(),
'models' => array(
'http://www.w3.org/1999/02/22-rdf-syntax-ns',
'http://www.w3.org/2000/01/rdf-schema',
'http://www.tao.lu/datatypes/WidgetDefinitions.rdf',
'http://www.tao.lu/middleware/Rules.rdf',
'http://www.tao.lu/Ontologies/generis.rdf'
),
'install' => array(
'rdf' => array(
array('ns' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns', 'file' => dirname(__FILE__). '/core/ontology/22-rdf-syntax-ns.rdf'),
array('ns' => 'http://www.w3.org/2000/01/rdf-schema', 'file' => dirname(__FILE__). '/core/ontology/rdf-schema.rdf'),
array('ns' => 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf', 'file' => dirname(__FILE__). '/core/ontology/widgetdefinitions.rdf'),
array('ns' => 'http://www.tao.lu/middleware/Rules.rdf', 'file' => dirname(__FILE__). '/core/ontology/rules.rdf'),
array('ns' => 'http://www.tao.lu/Ontologies/generis.rdf', 'file' => dirname(__FILE__). '/core/ontology/generis.rdf'),
),
'checks' => array(
//array('type' => 'CheckFileSystemComponent', 'value' => array('id' => 'fs_generis_data', 'location' => 'generis/data', 'rights' => 'rw'))
)
),
'update' => 'oat\\generis\\scripts\\update\\Updater',
'optimizableClasses' => array(
'http://www.tao.lu/Ontologies/generis.rdf#User',
'http://www.tao.lu/Ontologies/generis.rdf#ClassRole'
),
'optimizableProperties' => array(
'http://www.tao.lu/Ontologies/generis.rdf#login',
'http://www.tao.lu/Ontologies/generis.rdf#password'
)
'version' => '2.16.0',
'author' => 'Open Assessment Technologies, CRP Henri Tudor',
'requires' => array(),
'models' => array(
'http://www.w3.org/1999/02/22-rdf-syntax-ns',
'http://www.w3.org/2000/01/rdf-schema',
'http://www.tao.lu/datatypes/WidgetDefinitions.rdf',
'http://www.tao.lu/middleware/Rules.rdf',
'http://www.tao.lu/Ontologies/generis.rdf'),
'install' => array(
'rdf' => array(
array('ns' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns','file' => dirname(__FILE__) . '/core/ontology/22-rdf-syntax-ns.rdf'),
array('ns' => 'http://www.w3.org/2000/01/rdf-schema','file' => dirname(__FILE__) . '/core/ontology/rdf-schema.rdf'),
array('ns' => 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf','file' => dirname(__FILE__) . '/core/ontology/widgetdefinitions.rdf'),
array('ns' => 'http://www.tao.lu/middleware/Rules.rdf','file' => dirname(__FILE__) . '/core/ontology/rules.rdf'),
array('ns' => 'http://www.tao.lu/Ontologies/generis.rdf','file' => dirname(__FILE__) . '/core/ontology/generis.rdf')
),
'checks' => array()
),
'update' => 'oat\\generis\\scripts\\update\\Updater',
'optimizableClasses' => array(
'http://www.tao.lu/Ontologies/generis.rdf#User',
'http://www.tao.lu/Ontologies/generis.rdf#ClassRole'),
'optimizableProperties' => array(
'http://www.tao.lu/Ontologies/generis.rdf#login',
'http://www.tao.lu/Ontologies/generis.rdf#password')
);
2 changes: 1 addition & 1 deletion scripts/update/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function update($initialVersion) {
$this->setVersion('2.12.0');
}

$this->skip('2.12.0', '2.15.0');
$this->skip('2.12.0', '2.16.0');
}

private function getReadableModelIds() {
Expand Down
8 changes: 4 additions & 4 deletions test/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function testPHPRuntime() {
$this->assertTrue($php->isOptional());

// max & min test.
$php = new common_configuration_PHPRuntime('5.3', '5.5.x');
$php = new common_configuration_PHPRuntime('5.3', '5.6.x');
$report = $php->check();
$this->assertEquals($report->getStatus(), common_configuration_Report::VALID);

Expand Down Expand Up @@ -306,7 +306,7 @@ public function testSimpleComponentCollection(){
}

public function testComponentFactory(){
$component = common_configuration_ComponentFactory::buildPHPRuntime('5.0', '5.5.x', true);
$component = common_configuration_ComponentFactory::buildPHPRuntime('5.0', '5.6.x', true);
$this->assertIsA($component, 'common_configuration_PHPRuntime');
$this->assertEquals($component->getMin(), '5.0');
// 5.5.x will be replaced internally
Expand Down Expand Up @@ -364,7 +364,7 @@ public function testComponentFactory(){
$this->assertFalse($component->isOptional());*/


$array = array('type' => 'PHPRuntime', 'value' => array('min' => '5.0', 'max' => '5.5.x', 'optional' => true));
$array = array('type' => 'PHPRuntime', 'value' => array('min' => '5.0', 'max' => '5.6.x', 'optional' => true));
$component = common_configuration_ComponentFactory::buildFromArray($array);
$this->assertIsA($component, 'common_configuration_PHPRuntime');
$this->assertEquals($component->getMin(), '5.0');
Expand Down Expand Up @@ -452,4 +452,4 @@ public function testUserConfig()
$this->assertFalse($generis->getConfig(self::TESTKEY));

}
}
}
5 changes: 3 additions & 2 deletions test/RdfExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class RdfExportTest extends GenerisPhpUnitTestRunner
public function testFullExport()
{
$dbWrapper = core_kernel_classes_DbWrapper::singleton();
$result = $dbWrapper->query('SELECT count(*) FROM (SELECT DISTINCT subject, predicate, object, l_language FROM statements) as supercount')->fetch();
$triples = $result['count'];
$result = $dbWrapper->query('SELECT count(*) as count FROM (SELECT DISTINCT subject, predicate, object, l_language FROM statements) as supercount')->fetch();
$triples = $result['count'];


$result = $dbWrapper->query('SELECT modelid FROM "models"');
$modelIds = array();
Expand Down
9 changes: 7 additions & 2 deletions test/model/persistence/smoothsql/SmoothRdfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ public function testSearch()
*/
public function testAdd()
{
$platform = $this->prophesize('\common_persistence_sql_Platform');
$platform->getNowExpression()->willReturn('now');

$persistence = $this->prophesize('\common_persistence_SqlPersistence');
$query = "INSERT INTO statements ( modelId, subject, predicate, object, l_language) VALUES ( ? , ? , ? , ? , ? );";
$persistence->getPlatForm()->willReturn($platform->reveal());
$query = "INSERT INTO statements ( modelId, subject, predicate, object, l_language, epoch) VALUES ( ? , ? , ? , ? , ? , ?);";

$triple = new \core_kernel_classes_Triple();
$triple->modelid = 22;
Expand All @@ -91,7 +95,8 @@ public function testAdd()
'subjectUri',
'predicateUri',
'objectUri',
''
'',
'now'
))->willReturn(true);

$model = $this->prophesize('\core_kernel_persistence_smoothsql_SmoothModel');
Expand Down
14 changes: 7 additions & 7 deletions test/model/persistence/smoothsql/SmoothsqlUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ public function buildSearchPatternProvider()
{
return array(
array('hello', false, '= ' . $this->quote('hello')),
array('hello', true, 'LIKE ' . $this->quote('%hello%')),
array('*hello', true, 'LIKE ' . $this->quote('%hello')),
array('*hello*', true, 'LIKE ' . $this->quote('%hello%')),
array('*hel*lo*', true, 'LIKE ' . $this->quote('%hel%lo%')),
array('hello', true, 'LIKE LOWER(' . $this->quote('%hello%').')'),
array('*hello', true, 'LIKE LOWER(' . $this->quote('%hello').')'),
array('*hello*', true, 'LIKE LOWER(' . $this->quote('%hello%').')'),
array('*hel*lo*', true, 'LIKE LOWER(' . $this->quote('%hel%lo%').')'),
array('*hel*lo*', false, '= ' . $this->quote('*hel*lo*')),
array(25, false, '= ' . $this->quote('25')),
array(25.123, false, '= ' . $this->quote('25.123')),
array(true, false, '= ' . $this->quote('1')),
array(false, false, '= ' . $this->quote('')),
array(false, true, 'LIKE ' . $this->quote('%%')),
array('', true, 'LIKE ' . $this->quote('%%')),
array(false, true, 'LIKE LOWER(' . $this->quote('%%').')'),
array('', true, 'LIKE LOWER(' . $this->quote('%%').')'),
array(new core_kernel_classes_Resource('http://www.13.com/ontology#toto'), false, '= ' . $this->quote('http://www.13.com/ontology#toto')),
array(new core_kernel_classes_Resource('http://www.13.com/ontology#toto'), true, '= ' . $this->quote('http://www.13.com/ontology#toto')),
);
Expand Down Expand Up @@ -93,7 +93,7 @@ public function buildPropertyQueryProvider()
false
),
array(
"SELECT DISTINCT subject FROM statements WHERE (predicate = " . $this->quote('http://www.13.com/ontology#prop') . ") AND (object LIKE " . $this->quote('%hello%') . " OR object LIKE " . $this->quote('%world%') . ")",
"SELECT DISTINCT subject FROM statements WHERE (predicate = " . $this->quote('http://www.13.com/ontology#prop') . ") AND (LOWER(object) LIKE LOWER(" . $this->quote('%hello%') . ") OR LOWER(object) LIKE LOWER(" . $this->quote('%world%') . "))",
'http://www.13.com/ontology#prop',
array('hello', 'world'),
true
Expand Down

0 comments on commit 170ec94

Please sign in to comment.