Skip to content

Commit

Permalink
chore: introduced constants and added comments for better readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
vbyndych committed Oct 13, 2023
1 parent 1354923 commit ed38ea6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 3 additions & 2 deletions scripts/tools/MigrateSqlToNeo4j.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,13 @@ protected function run(): Report
private function addSystemLabel($neo4j, int $sqlChunkSize, int $neo4jChunkSize)
{
$sql = $this->getSqlAdapter();
$nonSystemModelId = \core_kernel_persistence_smoothsql_SmoothModel::DEFAULT_WRITABLE_MODEL;

/** @var \Doctrine\DBAL\ForwardCompatibility\Result $idResult */
$result = $sql->query(<<<'SQL'
$result = $sql->query(<<<SQL
SELECT subject
FROM statements
WHERE modelid <> 1
WHERE modelid <> {$nonSystemModelId}
GROUP BY subject;
SQL);

Expand Down
13 changes: 10 additions & 3 deletions scripts/update/OntologyUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
use helpers_RdfDiff;
use oat\generis\model\data\Model;
use oat\generis\model\data\ModelManager;
use oat\generis\model\GenerisRdf;
use oat\generis\model\kernel\persistence\file\FileModel;
use oat\tao\model\extension\ExtensionModel;
use oat\tao\model\user\TaoRoles;

class OntologyUpdater
{
Expand Down Expand Up @@ -88,10 +90,15 @@ public static function getCurrentTriples(Model $currentModel): \Traversable
return new \CallbackFilterIterator(
$currentModel->getRdfInterface()->getIterator(),
function (\core_kernel_classes_Triple $item) {
$isAutomaticIncludeRole = $item->subject === 'http://www.tao.lu/Ontologies/TAO.rdf#GlobalManagerRole'
&& $item->predicate === 'http://www.tao.lu/Ontologies/generis.rdf#includesRole';
$isGrantAccess = $item->predicate === 'http://www.tao.lu/Ontologies/taoFuncACL.rdf#GrantAccess';
/**
* Those includes generated with a script and created in non-system space, so we ignore them.
* @see \tao_install_ExtensionInstaller::installManagementRole
*/
$isAutomaticIncludeRole = $item->subject === TaoRoles::GLOBAL_MANAGER
&& $item->predicate === GenerisRdf::PROPERTY_ROLE_INCLUDESROLE;

// GrantAccess field added to entities in non-system space and also should be ignored for now.
$isGrantAccess = $item->predicate === 'http://www.tao.lu/Ontologies/taoFuncACL.rdf#GrantAccess';

return !$isGrantAccess && !$isAutomaticIncludeRole;
}
Expand Down

0 comments on commit ed38ea6

Please sign in to comment.