diff --git a/common/class.Utils.php b/common/class.Utils.php index 94c99c439..cee99d59a 100644 --- a/common/class.Utils.php +++ b/common/class.Utils.php @@ -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; diff --git a/core/kernel/persistence/smoothsql/class.Utils.php b/core/kernel/persistence/smoothsql/class.Utils.php index ba133eebe..459cd4201 100644 --- a/core/kernel/persistence/smoothsql/class.Utils.php +++ b/core/kernel/persistence/smoothsql/class.Utils.php @@ -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); } @@ -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); diff --git a/core/kernel/persistence/wrapper/RdfWrapper.php b/core/kernel/persistence/wrapper/RdfWrapper.php index 71cd67654..2a7b4f518 100644 --- a/core/kernel/persistence/wrapper/RdfWrapper.php +++ b/core/kernel/persistence/wrapper/RdfWrapper.php @@ -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); diff --git a/manifest.php b/manifest.php index 10d2885c8..30e2ed1ed 100755 --- a/manifest.php +++ b/manifest.php @@ -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') ); diff --git a/scripts/update/Updater.php b/scripts/update/Updater.php index 93d928b93..46a57f69b 100644 --- a/scripts/update/Updater.php +++ b/scripts/update/Updater.php @@ -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() { diff --git a/test/ConfigurationTest.php b/test/ConfigurationTest.php index fe05c6bcd..9ed90b54d 100755 --- a/test/ConfigurationTest.php +++ b/test/ConfigurationTest.php @@ -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); @@ -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 @@ -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'); @@ -452,4 +452,4 @@ public function testUserConfig() $this->assertFalse($generis->getConfig(self::TESTKEY)); } -} \ No newline at end of file +} diff --git a/test/RdfExportTest.php b/test/RdfExportTest.php index ffdce6faa..c69552d4e 100755 --- a/test/RdfExportTest.php +++ b/test/RdfExportTest.php @@ -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(); diff --git a/test/model/persistence/smoothsql/SmoothRdfTest.php b/test/model/persistence/smoothsql/SmoothRdfTest.php index f288273f5..6df87aadc 100644 --- a/test/model/persistence/smoothsql/SmoothRdfTest.php +++ b/test/model/persistence/smoothsql/SmoothRdfTest.php @@ -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; @@ -91,7 +95,8 @@ public function testAdd() 'subjectUri', 'predicateUri', 'objectUri', - '' + '', + 'now' ))->willReturn(true); $model = $this->prophesize('\core_kernel_persistence_smoothsql_SmoothModel'); diff --git a/test/model/persistence/smoothsql/SmoothsqlUtilsTest.php b/test/model/persistence/smoothsql/SmoothsqlUtilsTest.php index 57cdaf4db..75da48708 100644 --- a/test/model/persistence/smoothsql/SmoothsqlUtilsTest.php +++ b/test/model/persistence/smoothsql/SmoothsqlUtilsTest.php @@ -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')), ); @@ -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