Skip to content

Commit

Permalink
Merge branch 'release-1.19.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 22, 2024
2 parents c4d0a2a + 9f4fbde commit 7b33eed
Show file tree
Hide file tree
Showing 16 changed files with 333 additions and 57 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"ext-json": "*",
"oat-sa/generis": ">=15.22",
"oat-sa/tao-core": ">=54.21.0",
"oat-sa/tao-core": ">=54.24.0",
"oat-sa/extension-tao-testqti": ">=48.11.0",
"oat-sa/extension-tao-delivery": ">=14.10.1",
"oat-sa/extension-tao-outcome": ">=13.0.0",
"oat-sa/extension-tao-test": ">=15.15.1",
"oat-sa/extension-tao-test": ">=16.4.0",
"oat-sa/extension-tao-mediamanager": ">=12.32.1",
"elasticsearch/elasticsearch": "^8.0"
},
Expand Down
14 changes: 9 additions & 5 deletions migrations/Version202106011320101488_taoAdvancedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

final class Version202106011320101488_taoAdvancedSearch extends AbstractMigration
{

public function getDescription(): string
{
return 'Adds task queue for indexation events.';
Expand All @@ -26,10 +25,15 @@ public function up(Schema $schema): void
$this->propagate($registrationService);
$registrationService->__invoke([]);

if ( BrokerFactory::BROKER_MEMORY !== $this->getAssocitationService()->guessDefaultBrokerType()){
$this->addReport(Report::createWarning(
sprintf('New worker must be created to proceed tasks from queue named `%s`',$registrationService->getQueueName())
));
if (BrokerFactory::BROKER_MEMORY !== $this->getAssocitationService()->guessDefaultBrokerType()) {
$this->addReport(
Report::createWarning(
sprintf(
'New worker must be created to proceed tasks from queue named `%s`',
$registrationService->getQueueName()
)
)
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion migrations/Version202209081525261488_taoAdvancedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function up(Schema $schema): void

/** @var ServiceOptions $serviceOptions */
$serviceOptions = $this->getServiceManager()->get(ServiceOptions::SERVICE_ID);

if ($oldElasticSearch) {
$serviceOptions->save(ElasticSearchConfig::class, 'hosts', $oldElasticSearch->getOption('hosts'));
}
Expand Down
3 changes: 1 addition & 2 deletions model/Index/Report/IndexSummarizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ private function createReport(
string $label,
string $index,
int $totalInDb
): array
{
): array {
$totalIndexed = $this->getTotalResults($index);
$percentageIndexed = $totalIndexed === 0 || $totalInDb === 0
? 0
Expand Down
1 change: 0 additions & 1 deletion model/Metadata/Listener/MetadataInheritanceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ private function getIndexer(): IndexerInterface
);
return $indexer;
}

}
5 changes: 3 additions & 2 deletions model/Metadata/Repository/ClassUriCachedRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@

class ClassUriCachedRepository extends ConfigurableService implements ClassUriRepositoryInterface
{
use OntologyAwareTrait;

private const CLASSES_INDEX = self::class . '::CLASSES_URIS';
private const CLASSES_INDEX_TOTAL = self::class . '::CLASSES_URIS_TOTAL';

use OntologyAwareTrait;
private const CLASSES_INDEX_TOTAL = self::class . '::CLASSES_URIS_TOTAL';

public function cacheWarmup(): void
{
Expand Down
50 changes: 40 additions & 10 deletions model/Metadata/Service/AdvancedSearchSettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,47 @@

use oat\generis\model\OntologyRdfs;
use oat\tao\model\AdvancedSearch\AdvancedSearchChecker;
use oat\tao\model\featureFlag\FeatureFlagCheckerInterface;
use oat\tao\model\featureFlag\Service\FeatureFlagPropertiesMapping;
use oat\tao\model\Lists\Business\Contract\ClassMetadataSearcherInterface;
use oat\tao\model\Lists\Business\Domain\ClassMetadataSearchRequest;
use oat\tao\model\Lists\Business\Input\ClassMetadataSearchInput;
use oat\tao\model\search\Contract\SearchSettingsServiceInterface;
use oat\tao\model\search\ResultColumn;
use oat\tao\model\search\SearchSettings;
use oat\tao\model\TaoOntology;

class AdvancedSearchSettingsService implements SearchSettingsServiceInterface
{
private const OMIT_PROPERTIES = [
OntologyRdfs::RDFS_LABEL
OntologyRdfs::RDFS_LABEL,
TaoOntology::PROPERTY_TRANSLATION_TYPE,
TaoOntology::PROPERTY_TRANSLATION_PROGRESS,
TaoOntology::PROPERTY_TRANSLATION_ORIGINAL_RESOURCE_URI,
];

public const DEFAULT_SORT_COLUMN = 'label.raw';

/** @var ClassMetadataSearcherInterface */
private $classMetadataSearcher;
private ClassMetadataSearcherInterface $classMetadataSearcher;

/** @var AdvancedSearchChecker */
private $advancedSearchChecker;
private AdvancedSearchChecker $advancedSearchChecker;

/** @var SearchSettingsServiceInterface */
private $defaultSearchSettingsService;
private SearchSettingsServiceInterface $defaultSearchSettingsService;
private FeatureFlagCheckerInterface $featureFlagChecker;
private FeatureFlagPropertiesMapping $featureFlagPropertiesMapping;

public function __construct(
ClassMetadataSearcherInterface $classMetadataSearcher,
SearchSettingsServiceInterface $defaultSearchSettingsService,
AdvancedSearchChecker $advancedSearchChecker
AdvancedSearchChecker $advancedSearchChecker,
FeatureFlagCheckerInterface $featureFlagChecker,
FeatureFlagPropertiesMapping $featureFlagPropertiesMapping
) {
$this->classMetadataSearcher = $classMetadataSearcher;
$this->advancedSearchChecker = $advancedSearchChecker;
$this->defaultSearchSettingsService = $defaultSearchSettingsService;
$this->featureFlagChecker = $featureFlagChecker;
$this->featureFlagPropertiesMapping = $featureFlagPropertiesMapping;
}

public function getSettingsByClassMetadataSearchRequest(
Expand All @@ -68,7 +77,9 @@ public function getSettingsByClassMetadataSearchRequest(
->getSettingsByClassMetadataSearchRequest($classMetadataSearchRequest);
}

$classCollection = $this->classMetadataSearcher->findAll(new ClassMetadataSearchInput($classMetadataSearchRequest));
$classCollection = $this->classMetadataSearcher->findAll(
new ClassMetadataSearchInput($classMetadataSearchRequest)
);

if ($classMetadataSearchRequest->getStructure() === 'results') {
return new SearchSettings(
Expand Down Expand Up @@ -168,9 +179,11 @@ public function getSettingsByClassMetadataSearchRequest(
)
];

$propertiesToHide = $this->getPropertiesToHide();

foreach ($classCollection->getIterator() as $class) {
foreach ($class->getMetaData()->getIterator() as $metadata) {
if (in_array($metadata->getPropertyUri(), self::OMIT_PROPERTIES, true)) {
if (in_array($metadata->getPropertyUri(), $propertiesToHide, true)) {
continue;
}

Expand All @@ -190,4 +203,21 @@ public function getSettingsByClassMetadataSearchRequest(

return new SearchSettings($out);
}

private function getPropertiesToHide(): array
{
$propertiesToHide = self::OMIT_PROPERTIES;

foreach ($this->featureFlagPropertiesMapping->getAllProperties() as $featureFlag => $properties) {
if (!$this->featureFlagChecker->isEnabled($featureFlag)) {
foreach ($properties as $property) {
if (!in_array($property, $propertiesToHide, true)) {
$propertiesToHide[] = $property;
}
}
}
}

return $propertiesToHide;
}
}
45 changes: 43 additions & 2 deletions model/Metadata/Service/ClassMetadataSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
use oat\generis\model\OntologyAwareTrait;
use oat\oatbox\service\ConfigurableService;
use oat\tao\model\AdvancedSearch\AdvancedSearchChecker;
use oat\tao\model\featureFlag\FeatureFlagChecker;
use oat\tao\model\featureFlag\FeatureFlagCheckerInterface;
use oat\tao\model\featureFlag\Service\FeatureFlagPropertiesMapping;
use oat\tao\model\Lists\Business\Contract\ClassMetadataSearcherInterface;
use oat\tao\model\Lists\Business\Domain\ClassCollection;
use oat\tao\model\Lists\Business\Domain\ClassMetadata;
Expand All @@ -36,14 +39,21 @@
use oat\tao\model\Lists\Business\Service\GetClassMetadataValuesService;
use oat\tao\model\search\ResultSet;
use oat\tao\model\search\SearchProxy;
use oat\tao\model\TaoOntology;
use oat\taoAdvancedSearch\model\SearchEngine\Driver\Elasticsearch\ElasticSearch;
use oat\taoAdvancedSearch\model\SearchEngine\Query;

class ClassMetadataSearcher extends ConfigurableService implements ClassMetadataSearcherInterface
{
use OntologyAwareTrait;

private const BASE_LIST_ITEMS_URI = '/tao/PropertyValues/get?propertyUri=%s';

use OntologyAwareTrait;
private const UNACCEPTABLE_PROPERTIES = [
TaoOntology::PROPERTY_TRANSLATION_TYPE,
TaoOntology::PROPERTY_TRANSLATION_PROGRESS,
TaoOntology::PROPERTY_TRANSLATION_ORIGINAL_RESOURCE_URI,
];

public function findAll(ClassMetadataSearchInput $input): ClassCollection
{
Expand Down Expand Up @@ -89,8 +99,11 @@ private function getProperties(string $classUri): array
$allProperties = [$result];
$allProperties = $this->getRelatedProperties($result, $allProperties);
$allProperties = $this->getClassPathProperties($classUri, $allProperties);
$allProperties = $this->filterDuplicatedProperties($allProperties);

return $this->filterDuplicatedProperties($allProperties);
$propertiesToHide = $this->getPropertiesToHide();

return array_diff_key($allProperties, array_flip($propertiesToHide));
}

private function getClassPathProperties(string $classUri, array $allProperties): array
Expand Down Expand Up @@ -258,6 +271,24 @@ private function isAllowedWidget(core_kernel_classes_Property $property, array $
return $widget && $widget->getUri() && !in_array($widget->getUri(), $ignoredWidgets, true);
}

private function getPropertiesToHide(): array
{
$propertiesToHide = self::UNACCEPTABLE_PROPERTIES;
$featureFlagChecker = $this->getFeatureFlagChecker();

foreach ($this->getFeatureFlagPropertiesMapping()->getAllProperties() as $featureFlag => $properties) {
if (!$featureFlagChecker->isEnabled($featureFlag)) {
foreach ($properties as $property) {
if (!in_array($property, $propertiesToHide, true)) {
$propertiesToHide[] = $property;
}
}
}
}

return $propertiesToHide;
}

private function getClassMetadataSearcher(): ClassMetadataSearcherInterface
{
return $this->getServiceLocator()->get(ClassMetadataService::SERVICE_ID);
Expand All @@ -277,4 +308,14 @@ private function getSearch(): SearchProxy
{
return $this->getServiceLocator()->get(SearchProxy::SERVICE_ID);
}

private function getFeatureFlagPropertiesMapping(): FeatureFlagPropertiesMapping
{
return $this->getServiceLocator()->getContainer()->get(FeatureFlagPropertiesMapping::class);
}

private function getFeatureFlagChecker(): FeatureFlagCheckerInterface
{
return $this->getServiceLocator()->getContainer()->get(FeatureFlagChecker::class);
}
}
5 changes: 5 additions & 0 deletions model/Metadata/ServiceProvider/MetadataServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\generis\persistence\PersistenceServiceProvider;
use oat\tao\model\AdvancedSearch\AdvancedSearchChecker;
use oat\tao\model\featureFlag\FeatureFlagChecker;
use oat\tao\model\featureFlag\Service\FeatureFlagPropertiesMapping;
use oat\tao\model\Lists\Business\Service\ClassMetadataSearcherProxy;
use oat\tao\model\search\Service\DefaultSearchSettingsService;
use oat\taoAdvancedSearch\model\Metadata\Service\AdvancedSearchSettingsService;
use oat\taoAdvancedSearch\model\Metadata\Service\ListSavedEventListener;
use oat\taoAdvancedSearch\model\Metadata\Specification\PropertyAllowedSpecification;
use oat\taoAdvancedSearch\model\Resource\Service\ResourceIndexer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

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

Expand Down Expand Up @@ -59,6 +62,8 @@ public function __invoke(ContainerConfigurator $configurator): void
service(ClassMetadataSearcherProxy::SERVICE_ID),
service(DefaultSearchSettingsService::class),
service(AdvancedSearchChecker::class),
service(FeatureFlagChecker::class),
service(FeatureFlagPropertiesMapping::class),
]
)->public();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private function logIndexFailure(
LoggerInterface $logger,
Throwable $e,
string $method,
string $script='',
string $script = '',
$type = null,
array $query = []
): void {
Expand Down
Loading

0 comments on commit 7b33eed

Please sign in to comment.