/** * * @param string $initialVersion * @return void */ public function update($initialVersion) { if ($this->isBetween('0', '0.2')) { $this->setVersion('0.2'); } if ($this->isVersion('0.2')) { $oldRepository = $this->getServiceManager()->get(Repository::SERVICE_ID); $this->getServiceManager()->register('taoWorkspace/innerRevision', $oldRepository); $newService = new RevisionWrapper(array(RevisionWrapper::OPTION_INNER_IMPLEMENTATION => 'taoWorkspace/innerRevision')); $this->getServiceManager()->register(Repository::SERVICE_ID, $newService); $this->setVersion('0.3.0'); } $this->skip('0.3.0', '0.4.1'); if ($this->isVersion('0.4.1')) { $service = $this->getServiceManager()->get(Repository::SERVICE_ID); $service->setOption(RepositoryService::OPTION_FS, 'revisions'); $this->getServiceManager()->register(Repository::SERVICE_ID, $service); $this->setVersion('0.5.0'); } $this->skip('0.5.0', '0.6.0'); if ($this->isVersion('0.6.0')) { /* @var $modelWrapper WrapperModel */ $modelWrapper = ModelManager::getModel(); $inner = $modelWrapper->getInnerModel(); $inner->setOption(core_kernel_persistence_smoothsql_SmoothModel::OPTION_SEARCH_SERVICE, ComplexSearchService::SERVICE_ID); $workspace = $modelWrapper->getWorkspaceModel(); $workspace->setOption(core_kernel_persistence_smoothsql_SmoothModel::OPTION_SEARCH_SERVICE, ComplexSearchService::SERVICE_ID); $wrapedModel = WrapperModel::wrap($inner, $workspace); $wrapedModel->setServiceLocator($this->getServiceManager()); ModelManager::setModel($wrapedModel); $this->setVersion('0.6.1'); } }
public function __invoke($params) { $lock = $this->getServiceManager()->get(LockSystemInterface::SERVICE_ID); if (!$lock instanceof LockSystem) { throw new \common_exception_InconsistentData('Expected Workspace Lock not found, found ' . get_class($lock)); } $model = ModelManager::getModel(); if (!$model instanceof WrapperModel) { throw new \common_exception_InconsistentData('Expected Ontology Wrapper not found, found ' . get_class($model)); } $repositoryStore = $this->getServiceManager()->get(Repository::SERVICE_ID); if (!$repositoryStore instanceof RevisionWrapper) { throw new \common_exception_InconsistentData('Expected Revision Wrapper not found, found ' . get_class($repositoryStore)); } $this->releaseAll($lock); $innerModel = $model->getInnerModel(); ModelManager::setModel($innerModel); $innerKey = $repositoryStore->getOption(RevisionWrapper::OPTION_INNER_IMPLEMENTATION); $innerStore = $this->getServiceManager()->get($innerKey); $this->registerService(Repository::SERVICE_ID, $innerStore); $this->getServiceManager()->unregister($innerKey); $storageSql = $lock->getStorage()->getPersistence(); $this->registerService(LockSystemInterface::SERVICE_ID, new NoLock()); $storageSql->exec('DROP TABLE workspace'); return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Successfully removed workspace wrappers')); }
/** * * @param string $currentVersion * @return string $versionUpdatedTo */ public function update($initialVersion) { $currentVersion = $initialVersion; if ($currentVersion == '2.7') { $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'widgetdefinitions_2.7.1.rdf'; $api = core_kernel_impl_ApiModelOO::singleton(); $success = $api->importXmlRdf('http://www.tao.lu/datatypes/WidgetDefinitions.rdf', $file); if ($success) { $currentVersion = '2.7.1'; } else { common_Logger::w('Import failed for ' . $file); } } if ($currentVersion == '2.7.1') { $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'widgetdefinitions_2.7.2.rdf'; $api = core_kernel_impl_ApiModelOO::singleton(); $success = $api->importXmlRdf('http://www.tao.lu/datatypes/WidgetDefinitions.rdf', $file); if ($success) { $currentVersion = '2.7.2'; } else { common_Logger::w('Import failed for ' . $file); } } if ($currentVersion == '2.7.2') { $implClass = common_ext_ExtensionsManager::singleton()->getExtensionById('generis')->getConfig(PermissionManager::CONFIG_KEY); if (is_string($implClass)) { if (class_exists($implClass)) { $impl = new $implClass(); PermissionManager::setPermissionModel($impl); $currentVersion = '2.7.3'; } else { common_Logger::w('Unexpected permission manager config type: ' . gettype($implClass)); } } else { common_Logger::w('Unexpected permission manager config type: ' . gettype($implClass)); } } if ($currentVersion == '2.7.3') { ModelManager::setModel(new \core_kernel_persistence_smoothsql_SmoothModel(array(\core_kernel_persistence_smoothsql_SmoothModel::OPTION_PERSISTENCE => 'default', \core_kernel_persistence_smoothsql_SmoothModel::OPTION_READABLE_MODELS => $this->getReadableModelIds(), \core_kernel_persistence_smoothsql_SmoothModel::OPTION_WRITEABLE_MODELS => array('1'), \core_kernel_persistence_smoothsql_SmoothModel::OPTION_NEW_TRIPLE_MODEL => '1'))); $currentVersion = '2.7.4'; } if ($currentVersion == '2.7.4' && defined('GENERIS_URI_PROVIDER')) { if (in_array(GENERIS_URI_PROVIDER, array('DatabaseSerialUriProvider', 'AdvKeyValueUriProvider'))) { $uriProviderClassName = '\\core_kernel_uri_' . GENERIS_URI_PROVIDER; $options = array(\core_kernel_uri_DatabaseSerialUriProvider::OPTION_PERSISTENCE => 'default', \core_kernel_uri_DatabaseSerialUriProvider::OPTION_NAMESPACE => LOCAL_NAMESPACE . '#'); $provider = new $uriProviderClassName($options); } else { $uriProviderClassName = '\\common_uri_' . GENERIS_URI_PROVIDER; $provider = new $uriProviderClassName(); } \core_kernel_uri_UriService::singleton()->setUriProvider($provider); $currentVersion = '2.7.5'; } // service manager support if ($currentVersion == '2.7.5' || $currentVersion == '2.7.6' || $currentVersion == '2.7.7' || $currentVersion == '2.8.0') { $currentVersion = '2.9.0'; } return $currentVersion; }
/** * Short description of method install * * @access public * @author Joel Bout, <*****@*****.**> * @return mixed */ public function install() { if ($this->extension->getId() != 'generis') { throw new common_ext_ExtensionException('Tried to install "' . $this->extension->getId() . '" extension using the GenerisInstaller'); } //$this->installCustomScript(); $this->installLoadDefaultConfig(); ModelManager::setModel(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'))); $this->installOntology(); //$this->installLocalData(); //$this->installModuleModel(); $this->installRegisterExt(); common_cache_FileCache::singleton()->purge(); common_Logger::d('Installing custom script for extension ' . $this->extension->getId()); $this->installCustomScript(); }
public function __invoke($params) { SqlStorage::createTable(); $code = 666; $workspaceModel = new core_kernel_persistence_smoothsql_SmoothModel(array(core_kernel_persistence_smoothsql_SmoothModel::OPTION_PERSISTENCE => 'default', core_kernel_persistence_smoothsql_SmoothModel::OPTION_READABLE_MODELS => array($code), core_kernel_persistence_smoothsql_SmoothModel::OPTION_WRITEABLE_MODELS => array($code), core_kernel_persistence_smoothsql_SmoothModel::OPTION_NEW_TRIPLE_MODEL => $code, core_kernel_persistence_smoothsql_SmoothModel::OPTION_SEARCH_SERVICE => ComplexSearchService::SERVICE_ID)); $model = ModelManager::getModel(); $model->setOption(core_kernel_persistence_smoothsql_SmoothModel::OPTION_SEARCH_SERVICE, ComplexSearchService::SERVICE_ID); $wrapedModel = WrapperModel::wrap($model, $workspaceModel); $wrapedModel->setServiceLocator($this->getServiceLocator()); ModelManager::setModel($wrapedModel); LockManager::setImplementation(new LockSystem()); $oldRepository = $this->getServiceManager()->get(Repository::SERVICE_ID); $this->registerService('taoWorkspace/innerRevision', $oldRepository); $newService = new RevisionWrapper(array(RevisionWrapper::OPTION_INNER_IMPLEMENTATION => 'taoWorkspace/innerRevision', RepositoryService::OPTION_FS => 'revisions')); $this->registerService(Repository::SERVICE_ID, $newService); }
public function addReadableModel($modelId) { common_Logger::i('Adding model ' . $modelId . ' via wrapper'); $this->getInnerModel()->addReadableModel($modelId); // update in persistence ModelManager::setModel($this); }
<?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) 2014 (original work) Open Assessment Technologies SA; * * */ use oat\generisHard\models\HardModel; use oat\generis\model\data\ModelManager; ModelManager::setModel(new HardModel(array('persistence' => 'default')));
/** * Defines a model as readable * * @param string $id */ public function addReadableModel($id) { common_Logger::i('ADDING MODEL ' . $id); $readables = $this->getOption(self::OPTION_READABLE_MODELS); $this->setOption(self::OPTION_READABLE_MODELS, array_unique(array_merge($readables, array($id)))); // update in persistence ModelManager::setModel($this); }
/** * @param string $initialVersion * @return string $versionUpdatedTo */ public function update($initialVersion) { $currentVersion = $initialVersion; if ($currentVersion == '2.7') { $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'widgetdefinitions_2.7.1.rdf'; $api = core_kernel_impl_ApiModelOO::singleton(); $success = $api->importXmlRdf('http://www.tao.lu/datatypes/WidgetDefinitions.rdf', $file); if ($success) { $currentVersion = '2.7.1'; } else { common_Logger::w('Import failed for ' . $file); } } if ($currentVersion == '2.7.1') { $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'widgetdefinitions_2.7.2.rdf'; $api = core_kernel_impl_ApiModelOO::singleton(); $success = $api->importXmlRdf('http://www.tao.lu/datatypes/WidgetDefinitions.rdf', $file); if ($success) { $currentVersion = '2.7.2'; } else { common_Logger::w('Import failed for ' . $file); } } if ($currentVersion == '2.7.2') { $implClass = common_ext_ExtensionsManager::singleton()->getExtensionById('generis')->getConfig(PermissionManager::CONFIG_KEY); if (is_string($implClass)) { if (class_exists($implClass)) { $impl = new $implClass(); PermissionManager::setPermissionModel($impl); $currentVersion = '2.7.3'; } else { common_Logger::w('Unexpected permission manager config type: ' . gettype($implClass)); } } else { common_Logger::w('Unexpected permission manager config type: ' . gettype($implClass)); } } if ($currentVersion == '2.7.3') { ModelManager::setModel(new core_kernel_persistence_smoothsql_SmoothModel(array(core_kernel_persistence_smoothsql_SmoothModel::OPTION_PERSISTENCE => 'default', core_kernel_persistence_smoothsql_SmoothModel::OPTION_READABLE_MODELS => $this->getReadableModelIds(), core_kernel_persistence_smoothsql_SmoothModel::OPTION_WRITEABLE_MODELS => array('1'), core_kernel_persistence_smoothsql_SmoothModel::OPTION_NEW_TRIPLE_MODEL => '1'))); $currentVersion = '2.7.4'; } if ($currentVersion == '2.7.4' && defined('GENERIS_URI_PROVIDER')) { if (in_array(GENERIS_URI_PROVIDER, array('DatabaseSerialUriProvider', 'AdvKeyValueUriProvider'))) { $uriProviderClassName = '\\core_kernel_uri_' . GENERIS_URI_PROVIDER; $options = array(core_kernel_uri_DatabaseSerialUriProvider::OPTION_PERSISTENCE => 'default', core_kernel_uri_DatabaseSerialUriProvider::OPTION_NAMESPACE => LOCAL_NAMESPACE . '#'); $provider = new $uriProviderClassName($options); } else { $uriProviderClassName = '\\common_uri_' . GENERIS_URI_PROVIDER; $provider = new $uriProviderClassName(); } core_kernel_uri_UriService::singleton()->setUriProvider($provider); $currentVersion = '2.7.5'; } // service manager support if ($currentVersion == '2.7.5' || $currentVersion == '2.7.6' || $currentVersion == '2.7.7' || $currentVersion == '2.8.0') { $currentVersion = '2.9.0'; } if ($currentVersion == '2.9.0') { // skip, unused //try { // $this->getServiceManager()->get('generis/FsManager'); //} catch (ServiceNotFoundException $e) { // $FsManager = new \common_persistence_fileSystem_Manager(array( // \common_persistence_fileSystem_Manager::OPTION_FILE_PATH => FILES_PATH // )); // // $this->getServiceManager()->register('generis/FsManager', $FsManager); //} // update persistences $persistenceConfig = $this->getServiceManager()->get('generis/persistences'); if (is_array($persistenceConfig)) { $service = new common_persistence_Manager(array(common_persistence_Manager::OPTION_PERSISTENCES => $persistenceConfig)); $this->getServiceManager()->register('generis/persistences', $service); } // update cache try { $this->getServiceManager()->get('generis/cache'); } catch (ServiceNotFoundException $e) { $cache = new common_cache_KeyValueCache(array(common_cache_KeyValueCache::OPTION_PERSISTENCE => 'cache')); $cache->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register('generis/cache', $cache); } $currentVersion = '2.10.0'; } if ($currentVersion == '2.10.0') { $eventManager = new EventManager(); $eventManager->attach('oat\\generis\\model\\data\\event\\ResourceCreated', array('oat\\generis\\model\\data\\permission\\PermissionManager', 'catchEvent')); $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager); $currentVersion = '2.11.0'; } $this->setVersion($currentVersion); if ($this->isVersion('2.11.0')) { $FsManager = new FileSystemService(array(FileSystemService::OPTION_FILE_PATH => FILES_PATH, FileSystemService::OPTION_ADAPTERS => array())); $class = new core_kernel_classes_Class(GENERIS_NS . '#VersionedRepository'); foreach ($class->getInstances(true) as $resource) { $oldFs = new core_kernel_versioning_Repository($resource); $path = core_kernel_fileSystem_Cache::getFileSystemPath($oldFs); $FsManager->registerLocalFileSystem($resource->getUri(), $path); } $this->getServiceManager()->register(FileSystemService::SERVICE_ID, $FsManager); $this->setVersion('2.12.0'); } $this->skip('2.12.0', '2.18.0'); if ($this->isVersion('2.18.0')) { $this->getServiceManager()->register(ActionService::SERVICE_ID, new ActionService()); $this->setVersion('2.19.0'); } if ($this->isVersion('2.19.0')) { try { $this->getServiceManager()->get(Queue::CONFIG_ID); } catch (ServiceNotFoundException $e) { $service = new SyncQueue([]); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(Queue::CONFIG_ID, $service); } $this->setVersion('2.20.0'); } $this->skip('2.20.0', '2.29.1'); if ($this->isVersion('2.29.1')) { $this->getServiceManager()->register(FileReferenceSerializer::SERVICE_ID, new ResourceFileSerializer()); $this->setVersion('2.30.0'); } $this->skip('2.30.0', '2.31.6'); if ($this->isVersion('2.31.6')) { $complexSearch = new ComplexSearchService(array('shared' => array('search.query.query' => false, 'search.query.builder' => false, 'search.query.criterion' => false, 'search.tao.serialyser' => false, 'search.tao.result' => false), 'invokables' => array('search.query.query' => '\\oat\\search\\Query', 'search.query.builder' => '\\oat\\search\\QueryBuilder', 'search.query.criterion' => '\\oat\\search\\QueryCriterion', 'search.driver.postgres' => '\\oat\\search\\DbSql\\Driver\\PostgreSQL', 'search.driver.mysql' => '\\oat\\search\\DbSql\\Driver\\MySQL', 'search.driver.tao' => '\\oat\\generis\\model\\kernel\\persistence\\smoothsql\\search\\driver\\TaoSearchDriver', 'search.tao.serialyser' => '\\oat\\search\\DbSql\\TaoRdf\\UnionQuerySerialyser', 'search.factory.query' => '\\oat\\search\\factory\\QueryFactory', 'search.factory.builder' => '\\oat\\search\\factory\\QueryBuilderFactory', 'search.factory.criterion' => '\\oat\\search\\factory\\QueryCriterionFactory', 'search.tao.gateway' => '\\oat\\generis\\model\\kernel\\persistence\\smoothsql\\search\\GateWay', 'search.tao.result' => '\\oat\\generis\\model\\kernel\\persistence\\smoothsql\\search\\TaoResultSet'), 'abstract_factories' => array('\\oat\\search\\Command\\OperatorAbstractfactory'), 'services' => array('search.options' => array('table' => 'statements', 'driver' => 'taoRdf')))); $this->getServiceManager()->register(ComplexSearchService::SERVICE_ID, $complexSearch); $this->setVersion('3.0.0'); } $this->skip('3.0.0', '3.6.1'); if ($this->isVersion('3.6.1')) { $model = ModelManager::getModel(); if ($model instanceof \core_kernel_persistence_smoothsql_SmoothModel) { $model->setOption(\core_kernel_persistence_smoothsql_SmoothModel::OPTION_SEARCH_SERVICE, ComplexSearchService::SERVICE_ID); ModelManager::setModel($model); } $this->setVersion('3.7.0'); } if ($this->isBetween('3.7.0', '3.8.3')) { /* @var $modelWrapper WrapperModel */ $modelWrapper = ModelManager::getModel(); if ($modelWrapper instanceof WrapperModel) { $inner = $modelWrapper->getInnerModel(); $inner->setOption(\core_kernel_persistence_smoothsql_SmoothModel::OPTION_SEARCH_SERVICE, ComplexSearchService::SERVICE_ID); $workspace = $modelWrapper->getWorkspaceModel(); $workspace->setOption(core_kernel_persistence_smoothsql_SmoothModel::OPTION_SEARCH_SERVICE, ComplexSearchService::SERVICE_ID); $wrapedModel = WrapperModel::wrap($inner, $workspace); $wrapedModel->setServiceLocator($this->getServiceManager()); ModelManager::setModel($wrapedModel); } $this->setVersion('3.8.4'); } $this->skip('3.8.4', '3.8.5'); }
/** * 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) 2015 (original work) Open Assessment Technologies SA; * * */ use oat\taoWorkspace\model\lockStrategy\LockSystem; use oat\generis\model\data\ModelManager; use oat\tao\model\lock\LockManager; use oat\taoWorkspace\model\generis\WrapperModel; use oat\taoWorkspace\model\lockStrategy\SqlStorage; SqlStorage::createTable(); $code = 666; $workspaceModel = new \core_kernel_persistence_smoothsql_SmoothModel(array(\core_kernel_persistence_smoothsql_SmoothModel::OPTION_PERSISTENCE => 'default', \core_kernel_persistence_smoothsql_SmoothModel::OPTION_READABLE_MODELS => array($code), \core_kernel_persistence_smoothsql_SmoothModel::OPTION_WRITEABLE_MODELS => array($code), \core_kernel_persistence_smoothsql_SmoothModel::OPTION_NEW_TRIPLE_MODEL => $code)); $wrapedModel = WrapperModel::wrap(ModelManager::getModel(), $workspaceModel); ModelManager::setModel($wrapedModel); LockManager::setImplementation(new LockSystem());
public function run() { ModelManager::setModel(new \core_kernel_persistence_smoothsql_SmoothModel(array('persistence' => 'default'))); }