ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDataCollectionStorageMigration Class Reference

AutoloadingIssuesInspection More...

+ Inheritance diagram for ilDataCollectionStorageMigration:
+ Collaboration diagram for ilDataCollectionStorageMigration:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 
 getPreconditions (\ILIAS\Setup\Environment $environment)
 
 prepare (\ILIAS\Setup\Environment $environment)
 
 step (\ILIAS\Setup\Environment $environment)
 
 getRemainingAmountOfSteps ()
 
- Public Member Functions inherited from ILIAS\Setup\Migration
 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...
 

Data Fields

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

Protected Attributes

ilResourceStorageMigrationHelper $helper
 

Detailed Description

AutoloadingIssuesInspection

Definition at line 26 of file class.ilDataCollectionStorageMigration.php.

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

ilDataCollectionStorageMigration::getDefaultAmountOfStepsPerRun ( )

Implements ILIAS\Setup\Migration.

Definition at line 43 of file class.ilDataCollectionStorageMigration.php.

43  : int
44  {
45  return self::DEFAULT_AMOUNT_OF_STEPS;
46  }

◆ getLabel()

ilDataCollectionStorageMigration::getLabel ( )

Implements ILIAS\Setup\Migration.

Definition at line 35 of file class.ilDataCollectionStorageMigration.php.

35  : string
36  {
37  return "Migration of DataCollection files to the Resource Storage Service.";
38  }

◆ getPreconditions()

ilDataCollectionStorageMigration::getPreconditions ( \ILIAS\Setup\Environment  $environment)

Definition at line 51 of file class.ilDataCollectionStorageMigration.php.

References ilResourceStorageMigrationHelper\getPreconditions().

+ Here is the call graph for this function:

◆ getRemainingAmountOfSteps()

ilDataCollectionStorageMigration::getRemainingAmountOfSteps ( )

Implements ILIAS\Setup\Migration.

Definition at line 162 of file class.ilDataCollectionStorageMigration.php.

162  : int
163  {
164  $legacy_file_field_amount = $this->helper->getDatabase()->fetchObject(
165  $this->helper->getDatabase()->query(
166  "SELECT COUNT(field.id) AS amount FROM il_dcl_field AS field WHERE field.datatype_id = 6;"
167  )
168  );
169 
170  return (int) $legacy_file_field_amount?->amount;
171  }

◆ prepare()

ilDataCollectionStorageMigration::prepare ( \ILIAS\Setup\Environment  $environment)

Definition at line 59 of file class.ilDataCollectionStorageMigration.php.

59  : void
60  {
61  $this->helper = new ilResourceStorageMigrationHelper(
63  $environment
64  );
65  }

◆ step()

ilDataCollectionStorageMigration::step ( \ILIAS\Setup\Environment  $environment)

Definition at line 70 of file class.ilDataCollectionStorageMigration.php.

References ilDclDatatype\INPUTFORMAT_FILE, ILIAS\Repository\int(), and null.

70  : void
71  {
72  $integer_storage = "il_dcl_stloc2_value";
73  $string_storage = "il_dcl_stloc1_value";
74  $db = $this->helper->getDatabase();
75 
76  // Find next field with a fileupload datatype.
77 
78  $legacy_file_field = $db->fetchObject(
79  $db->query(
80  "SELECT * FROM il_dcl_field AS field WHERE datatype_id = 6 LIMIT 1;"
81  )
82  );
83 
84  // Loop through all records of the field.
85  $legacy_file_records = $db->queryF(
86  "SELECT * FROM il_dcl_record_field AS record_field WHERE record_field.field_id = %s;",
87  ['integer'],
88  [$legacy_file_field->id]
89  );
90  while ($record = $db->fetchObject($legacy_file_records)) {
91  // Get the file id from the storage.
92  $legacy_file_record = $db->fetchObject(
93  $db->queryF(
94  "SELECT id, rid, file_id, record_field_id
95  FROM $integer_storage AS storage
96  JOIN file_data AS file ON file.file_id = storage.value
97  WHERE storage.record_field_id = %s;",
98  ['integer'],
99  [$record->id]
100  )
101  );
102  if ($legacy_file_record === null) {
103  continue;
104  }
105  // Store RID as new value in string storage.
106  $rid = $legacy_file_record->rid ?? null;
107 
108  $db->insert($string_storage, [
109  'id' => ['integer', $db->nextId($string_storage)],
110  'record_field_id' => ['integer', (int) $legacy_file_record->record_field_id],
111  'value' => ['text', $rid],
112  ]);
113 
114  // Remove file_id from integer storage.
115  $db->manipulateF(
116  "DELETE FROM $integer_storage WHERE id = %s;",
117  ['integer'],
118  [(int) $legacy_file_record->id]
119  );
120 
121  // Switch Stakeholder
122  $this->helper->moveResourceToNewStakeholderAndOwner(
123  new ResourceIdentification($rid),
124  new ilObjFileStakeholder(),
125  $this->helper->getStakeholder()
126  );
127 
128  // Delete File-object
129  try {
130  $file_id = (int) $legacy_file_record->file_id;
131  $db->manipulateF(
132  "DELETE FROM file_data WHERE file_id = %s",
133  ['integer'],
134  [$file_id]
135  );
136  $db->manipulateF(
137  "DELETE FROM history WHERE obj_id = %s",
138  ['integer'],
139  [(int) $legacy_file_record->id]
140  );
141  $db->manipulateF(
142  "DELETE FROM object_data WHERE obj_id = %s AND type = %s",
143  ['integer', 'text'],
144  [(int) $legacy_file_record->id, 'file']
145  );
146  } catch (Exception) {
147  continue;
148  }
149  }
150 
151  // update datatype of legacy entry, so it now reads from string-storage.
152  $db->update("il_dcl_field", [
153  'datatype_id' => ['integer', ilDclDatatype::INPUTFORMAT_FILE],
154  ], [
155  'id' => ['integer', (int) $legacy_file_field->id],
156  ]);
157  }
Class ilObjFileStakeholder.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

Field Documentation

◆ $helper

ilResourceStorageMigrationHelper ilDataCollectionStorageMigration::$helper
protected

Definition at line 30 of file class.ilDataCollectionStorageMigration.php.

◆ DEFAULT_AMOUNT_OF_STEPS

const ilDataCollectionStorageMigration::DEFAULT_AMOUNT_OF_STEPS = 10000

Definition at line 28 of file class.ilDataCollectionStorageMigration.php.


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