ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
IndAssStorageMigration Class Reference
+ Inheritance diagram for IndAssStorageMigration:
+ Collaboration diagram for IndAssStorageMigration:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 
 getPreconditions (Environment $environment)
 
 prepare (Environment $environment)
 
 step (Environment $environment)
 
 getRemainingAmountOfSteps ()
 

Private Attributes

const DEFAULT_AMOUNT_OF_STEPS = 200
 
ilDBInterface $db
 
ILIAS DI Container $dic
 
ilResourceStorageMigrationHelper $helper = null
 
mixed $io
 

Detailed Description

Definition at line 25 of file class.IndAssStorageMigration.php.

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

IndAssStorageMigration::getDefaultAmountOfStepsPerRun ( )

Definition at line 42 of file class.IndAssStorageMigration.php.

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

◆ getLabel()

IndAssStorageMigration::getLabel ( )

Definition at line 37 of file class.IndAssStorageMigration.php.

37  : string
38  {
39  return "Migrate FSStorage to IRSS";
40  }

◆ getPreconditions()

IndAssStorageMigration::getPreconditions ( Environment  $environment)

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

References ilResourceStorageMigrationHelper\getPreconditions().

+ Here is the call graph for this function:

◆ getRemainingAmountOfSteps()

IndAssStorageMigration::getRemainingAmountOfSteps ( )

Definition at line 124 of file class.IndAssStorageMigration.php.

124  : int
125  {
126  $query = "SELECT COUNT(*) AS amount FROM iass_members WHERE file_name LIKE '%.%';";
127  $result = $this->db->query($query);
128  $row = $this->db->fetchAssoc($result);
129  return (int) $row['amount'];
130  }

◆ prepare()

IndAssStorageMigration::prepare ( Environment  $environment)

Definition at line 57 of file class.IndAssStorageMigration.php.

References $db, $DIC, $GLOBALS, ILIAS\Setup\Environment\getResource(), and ILIAS\FileDelivery\Init\init().

57  : void
58  {
59  $this->db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
60  $settings_factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
61  $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
62 
63  $DIC = $GLOBALS["DIC"];
64  $GLOBALS["DIC"] = new ILIAS\DI\Container();
65  $GLOBALS["DIC"]["ilDB"] = $this->db;
66  $GLOBALS["DIC"]["ilSetting"] = $settings_factory->settingsFor();
67  $GLOBALS["DIC"]["ilClientIniFile"] = $client_ini;
68 
70  ilInitialisation::bootstrapFilesystems();
71 
72  $this->dic = $GLOBALS["DIC"];
73  $GLOBALS["DIC"] = $DIC;
74 
75  $stakeholder = new ilIndividualAssessmentGradingStakeholder();
76  $this->helper = new \ilResourceStorageMigrationHelper(
77  $stakeholder,
78  $environment
79  );
80  }
static init(Container $c)
Definition: Init.php:40
global $DIC
Definition: feed.php:28
$GLOBALS["DIC"]
Definition: wac.php:31
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
+ Here is the call graph for this function:

◆ step()

IndAssStorageMigration::step ( Environment  $environment)
Exceptions
Exception

Definition at line 85 of file class.IndAssStorageMigration.php.

References $dic, $filename, $GLOBALS, ilIndividualAssessmentFileStorage\getInstance(), and ILIAS\Repository\int().

85  : void
86  {
87  $GLOBALS["DIC"] = $this->dic;
88 
89  $query = "SELECT obj_id, usr_id, file_name FROM iass_members WHERE file_name LIKE '%.%' LIMIT 1;";
90  $result = $this->db->query($query);
91  $row = $this->db->fetchAssoc($result);
92 
93  $obj_id = (int) $row['obj_id'];
94  $usr_id = (int) $row['usr_id'];
96  $fs_storage->setUserId($usr_id);
97 
98  $filename = $row['file_name'];
99  $filename_cb = static fn(string $fn) => $filename;
100  $filepath = $fs_storage->getAbsolutePath() . '/' . $filename;
101 
102  if (! file_exists($filepath)) {
103  $dir = scandir($fs_storage->getAbsolutePath());
104  if ($dir === false) {
105  throw new \Exception('cannot scan directory:' . $fs_storage->getAbsolutePath());
106  }
107  $files = array_diff($dir, ['.', '..']);
108  $filepath = $fs_storage->getAbsolutePath() . '/' . current($files);
109  if (file_exists($filepath) === false || count($files) < 1) {
110  throw new \Exception('no file in:' . $filepath);
111  }
112  }
113 
114  $resource_id = $this->helper->movePathToStorage($filepath, 6, $filename_cb);
115  if (! $resource_id) {
116  throw new \Exception('not stored:' . $filepath);
117  }
118 
119  $identifier = $resource_id->serialize();
120  $query = "UPDATE iass_members SET file_name = '$identifier' WHERE obj_id = $obj_id AND usr_id = $usr_id";
121  $this->db->manipulate($query);
122  }
$GLOBALS["DIC"]
Definition: wac.php:31
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface IndAssStorageMigration::$db
private

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

Referenced by prepare().

◆ $dic

ILIAS DI Container IndAssStorageMigration::$dic
private

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

Referenced by step().

◆ $helper

ilResourceStorageMigrationHelper IndAssStorageMigration::$helper = null
private

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

◆ $io

mixed IndAssStorageMigration::$io
private

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

◆ DEFAULT_AMOUNT_OF_STEPS

const IndAssStorageMigration::DEFAULT_AMOUNT_OF_STEPS = 200
private

Definition at line 27 of file class.IndAssStorageMigration.php.


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