Skip to content

Commit

Permalink
Merge branch 'release-53.13.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Dec 7, 2023
2 parents 0e6db47 + 94f1b0e commit 01ee6a8
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"oat-sa/jig": "~0.2",
"oat-sa/composer-npm-bridge": "~0.4.2||dev-master",
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"oat-sa/generis": ">=15.32.0",
"oat-sa/generis": ">=15.33",
"composer/package-versions-deprecated": "^1.11",
"paragonie/random_compat": "^2.0",
"phpdocumentor/reflection-docblock": "^5.2",
Expand Down
2 changes: 2 additions & 0 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use oat\tao\model\featureVisibility\FeatureVisibilityServiceProvider;
use oat\tao\model\import\ServiceProvider\ImportServiceProvider;
use oat\tao\model\LanguageServiceProvider;
use oat\tao\model\listener\PropertyServiceProvider;
use oat\tao\model\Lists\ServiceProvider\ListsServiceProvider;
use oat\tao\model\menu\MenuServiceProvider;
use oat\tao\model\metadata\ServiceProvider\MetadataServiceProvider;
Expand Down Expand Up @@ -413,6 +414,7 @@
ClientConfigServiceProvider::class,
HelperServiceProvider::class,
MenuServiceProvider::class,
PropertyServiceProvider::class,
],
'middlewares' => [
MiddlewareConfig::class,
Expand Down
79 changes: 79 additions & 0 deletions migrations/Version202312011610042234_tao.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?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) 2023(original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace oat\tao\migrations;

use Doctrine\DBAL\Schema\Schema;
use oat\generis\model\data\event\CacheWarmupEvent;
use oat\generis\model\data\event\ResourceDeleted;
use oat\generis\model\data\event\ResourceUpdated;
use oat\oatbox\event\EventManager;
use oat\tao\model\listener\ClassPropertiesChangedListener;
use oat\tao\model\listener\ClassPropertyCacheWarmupListener;
use oat\tao\model\listener\ClassPropertyRemovedListener;
use oat\tao\scripts\tools\migrations\AbstractMigration;

final class Version202312011610042234_tao extends AbstractMigration
{
public function getDescription(): string
{
return 'Register property cache warmup and modify listeners.';
}

public function up(Schema $schema): void
{
/** @var EventManager $eventManager */
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID);
$eventManager->attach(
CacheWarmupEvent::class,
[ClassPropertyCacheWarmupListener::class, 'handleEvent']
);
$eventManager->attach(
ResourceDeleted::class,
[ClassPropertyRemovedListener::SERVICE_ID, 'handleDeletedEvent']
);
$eventManager->attach(
ResourceUpdated::class,
[ClassPropertiesChangedListener::SERVICE_ID, 'handleUpdatedEvent']
);
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager);
}

public function down(Schema $schema): void
{
/** @var EventManager $eventManager */
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID);
$eventManager->detach(
CacheWarmupEvent::class,
[ClassPropertyCacheWarmupListener::class, 'handleEvent']
);
$eventManager->detach(
ResourceDeleted::class,
[ClassPropertyRemovedListener::SERVICE_ID, 'handleDeletedEvent']
);
$eventManager->detach(
ResourceUpdated::class,
[ClassPropertiesChangedListener::SERVICE_ID, 'handleUpdatedEvent']
);
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager);
}
}
9 changes: 9 additions & 0 deletions models/classes/listener/ClassPropertiesChangedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace oat\tao\model\listener;

use core_kernel_classes_Property;
use oat\generis\model\data\event\ResourceUpdated;
use oat\oatbox\service\ConfigurableService;
use oat\tao\model\AdvancedSearch\AdvancedSearchChecker;
use oat\tao\model\dto\OldProperty;
Expand Down Expand Up @@ -72,4 +73,12 @@ function (array $property) {
$taskMessage
);
}

public function handleUpdatedEvent(ResourceUpdated $event): void
{
if ($event->getResource()->isProperty()) {
$classProperty = new \core_kernel_classes_Property($event->getResource());
$classProperty->clearCachedValues();
}
}
}
48 changes: 48 additions & 0 deletions models/classes/listener/ClassPropertyCacheWarmupListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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) 2023 (original work) Open Assessment Technologies SA;
*
*/

declare(strict_types=1);

namespace oat\tao\model\listener;

use oat\generis\Helper\PropertyCache;
use oat\generis\model\data\event\CacheWarmupEvent;
use oat\generis\model\data\Ontology;
use oat\oatbox\reporting\Report;

class ClassPropertyCacheWarmupListener
{
public function __construct(Ontology $model)
{
$this->model = $model;
}

public function handleEvent(CacheWarmupEvent $event): void
{
$class = new \core_kernel_classes_Class('http://www.w3.org/1999/02/22-rdf-syntax-ns#Property');
$properties = $class->getInstances(true);
$properties = array_unique(array_keys($properties));

PropertyCache::warmupCachedValuesByProperties($properties);

$event->addReport(Report::createInfo('Generated property cache.'));
}
}
8 changes: 8 additions & 0 deletions models/classes/listener/ClassPropertyRemovedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ public function handleEvent(ClassPropertyRemovedEvent $event): void
$taskMessage
);
}

public function handleDeletedEvent(ResourceDeleted $event): void
{
if ($event->getResource()->isProperty()) {
$classProperty = new \core_kernel_classes_Property($event->getResource());
$classProperty->clearCachedValues();
}
}
}
55 changes: 55 additions & 0 deletions models/classes/listener/PropertyServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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) 2023 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace oat\tao\model\listener;

use common_ext_ExtensionsManager;
use oat\generis\model\data\Ontology;
use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\oatbox\cache\SimpleCache;
use oat\tao\model\ClientLibConfigRegistry;
use oat\tao\model\featureFlag\Listener\FeatureFlagCacheWarmupListener;
use oat\tao\model\featureFlag\Repository\FeatureFlagRepository;
use oat\tao\model\featureFlag\Repository\FeatureFlagRepositoryInterface;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

/**
* @codeCoverageIgnore
*/
class PropertyServiceProvider implements ContainerServiceProviderInterface
{
public function __invoke(ContainerConfigurator $configurator): void
{
$services = $configurator->services();

$services
->set(ClassPropertyCacheWarmupListener::class, ClassPropertyCacheWarmupListener::class)
->public()
->args(
[
service(Ontology::SERVICE_ID)
]
);
}
}
20 changes: 19 additions & 1 deletion scripts/install/RegisterEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
namespace oat\tao\scripts\install;

use oat\generis\model\data\event\CacheWarmupEvent;
use oat\generis\model\data\event\ResourceDeleted;
use oat\generis\model\data\event\ResourceUpdated;
use oat\generis\model\OntologyAwareTrait;
use oat\oatbox\event\EventManager;
use oat\oatbox\extension\InstallAction;
use oat\generis\model\OntologyAwareTrait;
use oat\oatbox\reporting\Report;
use oat\tao\model\featureFlag\Listener\FeatureFlagCacheWarmupListener;
use oat\tao\model\Language\Listener\LanguageCacheWarmupListener;
use oat\tao\model\listener\ClassPropertiesChangedListener;
use oat\tao\model\listener\ClassPropertyCacheWarmupListener;
use oat\tao\model\listener\ClassPropertyRemovedListener;
use oat\tao\model\menu\Listener\MenuCacheWarmupListener;
use oat\tao\model\migrations\MigrationsService;
use oat\tao\model\routing\Listener\AnnotationCacheWarmupListener;
Expand Down Expand Up @@ -66,6 +71,19 @@ public function __invoke($params)
CacheWarmupEvent::class,
[MenuCacheWarmupListener::class, 'handleEvent']
);
$eventManager->attach(
CacheWarmupEvent::class,
[ClassPropertyCacheWarmupListener::class, 'handleEvent']
);
$eventManager->attach(
ResourceDeleted::class,
[ClassPropertyRemovedListener::SERVICE_ID, 'handleDeletedEvent']
);
$eventManager->attach(
ResourceUpdated::class,
[ClassPropertiesChangedListener::SERVICE_ID, 'handleUpdatedEvent']
);

$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager);

return Report::createSuccess('Events registered');
Expand Down
2 changes: 2 additions & 0 deletions scripts/update/OntologyUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use AppendIterator;
use common_ext_ExtensionsManager;
use helpers_RdfDiff;
use oat\generis\Helper\PropertyCache;
use oat\generis\model\data\Model;
use oat\generis\model\data\ModelManager;
use oat\generis\model\GenerisRdf;
Expand All @@ -45,6 +46,7 @@ public static function syncModels()
self::logDiff($diff);

$diff->applyTo($currentModel);
PropertyCache::clearCachedValuesByTriples($diff->getTriplesToRemove());
}

public static function correctModelId($rdfFile)
Expand Down

0 comments on commit 01ee6a8

Please sign in to comment.