ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilDataCollectionSelectionFieldMigration Class Reference
+ Inheritance diagram for ilDataCollectionSelectionFieldMigration:
+ Collaboration diagram for ilDataCollectionSelectionFieldMigration:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 
 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 

Data Fields

const DEFAULT_AMOUNT_OF_STEPS = 10000
 
- Data Fields inherited from ILIAS\Setup\Migration
const INFINITE = -1
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

ilDataCollectionSelectionFieldMigration::getDefaultAmountOfStepsPerRun ( )

Tell the default amount of steps to be executed for one run of the migration.

Return Migration::INFINITE if all units should be migrated at once.

Implements ILIAS\Setup\Migration.

Definition at line 34 of file class.ilDataCollectionSelectionFieldMigration.php.

References DEFAULT_AMOUNT_OF_STEPS.

◆ getLabel()

ilDataCollectionSelectionFieldMigration::getLabel ( )
Returns
string - a meaningful and concise description for your migration.

Implements ILIAS\Setup\Migration.

Definition at line 29 of file class.ilDataCollectionSelectionFieldMigration.php.

29 : string
30 {
31 return "Migration of DataCollection selection field values";
32 }

◆ getPreconditions()

ilDataCollectionSelectionFieldMigration::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 39 of file class.ilDataCollectionSelectionFieldMigration.php.

◆ getRemainingAmountOfSteps()

ilDataCollectionSelectionFieldMigration::getRemainingAmountOfSteps ( )

Count up how many "things" need to be migrated.

This helps the admin to decide how big he can create the steps and also how long a migration takes

Implements ILIAS\Setup\Migration.

Definition at line 77 of file class.ilDataCollectionSelectionFieldMigration.php.

77 : int
78 {
79 $legacy_file_field_amount = $this->db->fetchObject(
80 $this->db->queryF(
81 'SELECT COUNT(il_dcl_stloc1_value.id) AS amount FROM il_dcl_stloc1_value ' .
82 'INNER JOIN il_dcl_record_field on il_dcl_record_field.id = il_dcl_stloc1_value.record_field_id ' .
83 'INNER JOIN il_dcl_field ON il_dcl_field.id = il_dcl_record_field.field_id ' .
84 'WHERE (datatype_id = %s OR datatype_id = %s) AND value LIKE %s AND value NOT LIKE %s AND value != "[]"',
87 )
88 );
89
90 return (int) $legacy_file_field_amount?->amount;
91 }
const INPUTFORMAT_TEXT_SELECTION
const INPUTFORMAT_DATE_SELECTION

References ilDclDatatype\INPUTFORMAT_DATE_SELECTION, ilDclDatatype\INPUTFORMAT_TEXT_SELECTION, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

◆ prepare()

ilDataCollectionSelectionFieldMigration::prepare ( Environment  $environment)

Prepare the migration by means of some environment.

This is not supposed to modify the environment, but will be run to prime the migration object to run step and getRemainingAmountOfSteps afterwards.

Implements ILIAS\Setup\Migration.

Definition at line 47 of file class.ilDataCollectionSelectionFieldMigration.php.

47 : void
48 {
49 $this->db = $environment->getResource(Environment::RESOURCE_DATABASE);
50 }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.

References ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ step()

ilDataCollectionSelectionFieldMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 52 of file class.ilDataCollectionSelectionFieldMigration.php.

52 : void
53 {
54 $stmt = $this->db->queryF(
55 'SELECT il_dcl_stloc1_value.* FROM il_dcl_stloc1_value ' .
56 'INNER JOIN il_dcl_record_field on il_dcl_record_field.id = il_dcl_stloc1_value.record_field_id ' .
57 'INNER JOIN il_dcl_field ON il_dcl_field.id = il_dcl_record_field.field_id ' .
58 'WHERE (datatype_id = %s OR datatype_id = %s) AND value LIKE %s AND value NOT LIKE %s AND value != "[]"',
61 );
62
63 while ($row = $this->db->fetchAssoc($stmt)) {
64 $old_values = json_decode($row['value']);
65 $new_values = [];
66 foreach ($old_values as $old_value) {
67 $new_values[] = (string) $old_value;
68 }
69 $this->db->update(
70 'il_dcl_stloc1_value',
71 ['value' => [ilDBConstants::T_TEXT, json_encode($new_values)]],
72 ['id' => [ilDBConstants::T_INTEGER, $row['id']]]
73 );
74 }
75 }

References ilDclDatatype\INPUTFORMAT_DATE_SELECTION, ilDclDatatype\INPUTFORMAT_TEXT_SELECTION, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

Field Documentation

◆ $db

ilDBInterface ilDataCollectionSelectionFieldMigration::$db
protected

◆ DEFAULT_AMOUNT_OF_STEPS

const ilDataCollectionSelectionFieldMigration::DEFAULT_AMOUNT_OF_STEPS = 10000

The documentation for this class was generated from the following file: