19 declare(strict_types=1);
36 return "Migration of some LOM elements that should be non-unique to their own tables.";
41 return Migration::INFINITE;
55 $this->db = $environment->
getResource(Environment::RESOURCE_DATABASE);
57 $io = $environment->
getResource(Environment::RESOURCE_ADMIN_INTERACTION);
118 return $this->db->indexExistsByFields($table, [
'rbac_id',
'obj_id']);
125 $this->db->addIndex($table, [
'rbac_id',
'obj_id'],
'i1');
141 $this->db->setLimit($limit);
142 $coverages = $this->db->query(
143 "SELECT meta_general_id, rbac_id, obj_id, obj_type, coverage, 144 coverage_language FROM il_meta_general WHERE CHAR_LENGTH(coverage) > 0 145 OR CHAR_LENGTH(coverage_language) > 0 ORDER BY meta_general_id" 148 while ($coverage = $this->db->fetchAssoc($coverages)) {
149 $this->
logDetailed(
'Insert coverage from meta_general_id ' . $coverage[
'meta_general_id']);
150 $next_id = $this->db->nextId(
'il_meta_coverage');
151 $this->db->manipulate(
152 "INSERT INTO il_meta_coverage (meta_coverage_id, rbac_id, obj_id, 153 obj_type, parent_type, parent_id, coverage, coverage_language) VALUES (" .
164 $this->db->manipulate(
165 "UPDATE il_meta_general SET coverage = '', coverage_language = '' 173 $res = $this->db->query(
174 "SELECT COUNT(*) AS count FROM il_meta_general WHERE CHAR_LENGTH(coverage) > 0 175 OR CHAR_LENGTH(coverage_language) > 0" 177 while ($rec = $this->db->fetchAssoc(
$res)) {
178 return (
int) $rec[
'count'];
195 $this->db->setLimit($limit);
196 $schemas = $this->db->query(
197 "SELECT meta_meta_data_id, rbac_id, obj_id, obj_type, meta_data_scheme 198 FROM il_meta_meta_data WHERE CHAR_LENGTH(meta_data_scheme) > 0 ORDER BY meta_meta_data_id" 201 while ($schema = $this->db->fetchAssoc($schemas)) {
202 $this->
logDetailed(
'Insert schema from meta_meta_data_id ' . $schema[
'meta_meta_data_id']);
203 $next_id = $this->db->nextId(
'il_meta_meta_schema');
204 $this->db->manipulate(
205 "INSERT INTO il_meta_meta_schema (meta_meta_schema_id, rbac_id, obj_id, 206 obj_type, parent_type, parent_id, meta_data_schema) VALUES (" .
216 $this->db->manipulate(
217 "UPDATE il_meta_meta_data SET meta_data_scheme = '' WHERE meta_meta_data_id = " .
225 $res = $this->db->query(
226 "SELECT COUNT(*) AS count FROM il_meta_meta_data WHERE CHAR_LENGTH(meta_data_scheme) > 0" 228 while ($rec = $this->db->fetchAssoc(
$res)) {
229 return (
int) $rec[
'count'];
241 $this->
logSuccess(
'Migrated all orComposites.');
246 $this->db->setLimit($limit);
247 $ors = $this->db->query(
248 "SELECT meta_requirement_id, rbac_id, obj_id, obj_type, operating_system_name, 249 os_min_version, os_max_version, browser_name, browser_minimum_version, 250 browser_maximum_version FROM il_meta_requirement WHERE 251 CHAR_LENGTH(operating_system_name) > 0 OR CHAR_LENGTH(os_min_version) > 0 252 OR CHAR_LENGTH(os_max_version) > 0 OR CHAR_LENGTH(browser_name) > 0 253 OR CHAR_LENGTH(browser_minimum_version) > 0 OR CHAR_LENGTH(browser_maximum_version) > 0 254 ORDER BY meta_requirement_id" 257 while ($or = $this->db->fetchAssoc($ors)) {
259 ($or[
'operating_system_name'] ??
'') !==
'' ||
260 ($or[
'os_min_version'] ??
'') !==
'' ||
261 ($or[
'os_max_version'] ??
'') !==
'';
263 ($or[
'browser_name'] ??
'') !==
'' ||
264 ($or[
'browser_minimum_version'] ??
'') !==
'' ||
265 ($or[
'browser_maximum_version'] ??
'') !==
'';
268 $this->
logDetailed(
'Insert orComposite (type os) from meta_requirement_id ' . $or[
'meta_requirement_id']);
269 $next_id = $this->db->nextId(
'il_meta_or_composite');
271 $this->db->manipulate(
272 "INSERT INTO il_meta_or_composite (meta_or_composite_id, rbac_id, obj_id, 273 obj_type, parent_type, parent_id, type, name, min_version, max_version) VALUES (" .
286 $this->db->manipulate(
287 "UPDATE il_meta_requirement SET operating_system_name = '', os_min_version = '', 288 os_max_version = '' WHERE meta_requirement_id = " .
294 $this->
logDetailed(
'Insert orComposite (type browser) from meta_requirement_id ' . $or[
'meta_requirement_id']);
295 $next_id = $this->db->nextId(
'il_meta_or_composite');
297 $this->db->manipulate(
298 "INSERT INTO il_meta_or_composite (meta_or_composite_id, rbac_id, obj_id, 299 obj_type, parent_type, parent_id, type, name, min_version, max_version) VALUES (" .
312 $this->db->manipulate(
313 "UPDATE il_meta_requirement SET browser_name = '', browser_minimum_version = '', 314 browser_maximum_version = '' WHERE meta_requirement_id = " .
323 $res = $this->db->query(
324 "SELECT COUNT(*) AS count FROM il_meta_requirement WHERE 325 CHAR_LENGTH(operating_system_name) > 0 OR CHAR_LENGTH(os_min_version) > 0 326 OR CHAR_LENGTH(os_max_version) > 0 OR CHAR_LENGTH(browser_name) > 0 327 OR CHAR_LENGTH(browser_minimum_version) > 0 OR CHAR_LENGTH(browser_maximum_version) > 0" 329 while ($rec = $this->db->fetchAssoc(
$res)) {
330 return (
int) $rec[
'count'];
339 'NetscapeCommunicator' =>
'netscape communicator',
340 'MS-InternetExplorer' =>
'ms-internet explorer',
343 'PC-DOS' =>
'pc-dos',
344 'MS-Windows' =>
'ms-windows',
347 'Multi-OS' =>
'multi-os',
351 if (key_exists($name, $dict)) {
364 $this->
logSuccess(
'Migrated all learningResourceTypes, intendedEndUserRoles, and contexts.');
369 $this->db->setLimit($limit);
370 $educationals = $this->db->query(
371 "SELECT meta_educational_id, rbac_id, obj_id, obj_type, 372 learning_resource_type, intended_end_user_role, context FROM il_meta_educational 373 WHERE CHAR_LENGTH(learning_resource_type) > 0 OR CHAR_LENGTH(intended_end_user_role) > 0 374 OR CHAR_LENGTH(context) > 0 ORDER BY meta_educational_id" 377 while (
$educational = $this->db->fetchAssoc($educationals)) {
378 $has_type = (
$educational[
'learning_resource_type'] ??
'') !==
'';
379 $has_role = (
$educational[
'intended_end_user_role'] ??
'') !==
'';
383 $this->
logDetailed(
'Insert learningResourceType from meta_educational_id ' .
$educational[
'meta_educational_id']);
384 $next_id = $this->db->nextId(
'il_meta_lr_type');
386 $this->db->manipulate(
387 "INSERT INTO il_meta_lr_type (meta_lr_type_id, rbac_id, obj_id, obj_type, 388 parent_type, parent_id, learning_resource_type) VALUES (" .
398 $this->db->manipulate(
399 "UPDATE il_meta_educational SET learning_resource_type = '' WHERE meta_educational_id = " .
405 $this->
logDetailed(
'Insert intendedEndUserRole from meta_educational_id ' .
$educational[
'meta_educational_id']);
406 $next_id = $this->db->nextId(
'il_meta_end_usr_role');
408 $this->db->manipulate(
409 "INSERT INTO il_meta_end_usr_role (meta_end_usr_role_id, rbac_id, obj_id, obj_type, 410 parent_type, parent_id, intended_end_user_role) VALUES (" .
420 $this->db->manipulate(
421 "UPDATE il_meta_educational SET intended_end_user_role = '' WHERE meta_educational_id = " .
428 $next_id = $this->db->nextId(
'il_meta_context');
430 $this->db->manipulate(
431 "INSERT INTO il_meta_context (meta_context_id, rbac_id, obj_id, obj_type, 432 parent_type, parent_id, context) VALUES (" .
442 $this->db->manipulate(
443 "UPDATE il_meta_educational SET context = '' WHERE meta_educational_id = " .
452 $res = $this->db->query(
453 "SELECT COUNT(*) AS count FROM il_meta_educational WHERE 454 CHAR_LENGTH(learning_resource_type) > 0 OR CHAR_LENGTH(intended_end_user_role) > 0 455 OR CHAR_LENGTH(context) > 0" 457 while ($rec = $this->db->fetchAssoc(
$res)) {
458 return (
int) $rec[
'count'];
466 'Exercise' =>
'exercise',
467 'Simulation' =>
'simulation',
468 'Questionnaire' =>
'questionnaire',
469 'Diagram' =>
'diagram',
470 'Figure' =>
'figure',
475 'NarrativeText' =>
'narrative text',
477 'Experiment' =>
'experiment',
478 'ProblemStatement' =>
'problem statement',
479 'SelfAssessment' =>
'self assessment',
480 'Lecture' =>
'lecture' 483 if (key_exists($name, $dict)) {
492 'Teacher' =>
'teacher',
493 'Author' =>
'author',
494 'Learner' =>
'learner',
495 'Manager' =>
'manager' 498 if (key_exists($name, $dict)) {
507 'School' =>
'school',
508 'HigherEducation' =>
'higher education',
509 'Training' =>
'training',
513 if (key_exists($name, $dict)) {
521 if (!isset($this->io) || !$this->io->isVerbose()) {
524 $this->io->inform($str);
529 if (!isset($this->io)) {
532 $this->io->success($str);
537 if (!isset($this->io)) {
Wrapper around symfonies input and output facilities to provide just the functionality required for t...
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.