ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCalendarCopyFilesToTempDirectoryJob Class Reference

Description of class class. More...

+ Inheritance diagram for ilCalendarCopyFilesToTempDirectoryJob:
+ Collaboration diagram for ilCalendarCopyFilesToTempDirectoryJob:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getInputTypes ()
 
 getOutputType ()
 
 isStateless ()
 
 run (array $input, Observer $observer)
 run the job More...
 
 getExpectedTimeOfTaskInSeconds ()
 
Returns
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount of data, try to set a possible high value of try to calculate it. If a task duration exceeds this value, it will be displayed as "possibly failed" to the user
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
 getInput ()
 
Returns
mixed returns the input array
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 setInput (array $values)
 
 getOutput ()
 
 getInput ()
 
 getType ()
 
 unfoldTask ()
 Unfold the task. More...
 
 getRemoveOption ()
 
Returns
Option An Option to remove the current task and do some cleanup if possible. This Option is displayed if the Bucket is completed. You do not have to provide an additional Option to remove in your UserInteraction, the remove-Option is added to the list of Options (last position)
See also
self::getAbortOption();
More...
 
 getAbortOption ()
 
Returns
Option In case a Job is failed or did not respond for some time, an Abort-Option is displayed. There is already a Standard-Abort-Option registered, you can override with your own and do some cleanup if possible.
More...
 

Protected Member Functions

 createUniqueTempDirectory ()
 
 createTargetDirectory ($a_tmpdir)
 
 copyFiles ($tmpdir, ilCalendarCopyDefinition $definition)
 Copy files. More...
 
- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes ($values)
 
 extractType ($value)
 

Protected Attributes

 $target_directory
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 $input = []
 
 $output
 

Private Attributes

 $logger = null
 

Additional Inherited Members

- Data Fields inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
const MAIN_REMOVE = 'bt_main_remove'
 
const MAIN_ABORT = 'bt_main_abort'
 

Detailed Description

Description of class class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 19 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarCopyFilesToTempDirectoryJob::__construct ( )

Constructor.

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

References $GLOBALS.

35  {
36  $this->logger = $GLOBALS['DIC']->logger()->cal();
37  }
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

Member Function Documentation

◆ copyFiles()

ilCalendarCopyFilesToTempDirectoryJob::copyFiles (   $tmpdir,
ilCalendarCopyDefinition  $definition 
)
protected

Copy files.

Parameters
string$tmpdir
ilCalendarCopyDefinition$definition

Definition at line 121 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

References ilCalendarCopyDefinition\COPY_SOURCE_DIR, ilCalendarCopyDefinition\COPY_TARGET_DIR, ilCalendarCopyDefinition\getCopyDefinitions(), and ilUtil\makeDirParents().

Referenced by run().

122  {
123  foreach ($definition->getCopyDefinitions() as $copy_task) {
124  if (!file_exists($copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR])) {
125  $this->logger->notice('Cannot find file: ' . $copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR]);
126  continue;
127  }
128  $this->logger->debug('Creating directory: ' . $tmpdir . '/' . dirname($copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR]));
130  $tmpdir . '/' . dirname($copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR])
131  );
132 
133  $this->logger->debug(
134  'Copying from: ' .
135  $copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR] .
136  ' to ' .
137  $tmpdir . '/' . $copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR]
138  );
139 
140  copy(
141  $copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR],
142  $tmpdir . '/' . $copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR]
143  );
144  }
145  return;
146  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getCopyDefinitions()
Get copy definitions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createTargetDirectory()

ilCalendarCopyFilesToTempDirectoryJob::createTargetDirectory (   $a_tmpdir)
protected

Definition at line 108 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

References $target_directory, and ilUtil\makeDirParents().

Referenced by run().

109  {
110  $final_dir = $a_tmpdir . "/" . $this->target_directory;
111  ilUtil::makeDirParents($final_dir);
112  $this->logger->info('New final directory: ' . $final_dir);
113  return $final_dir;
114  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createUniqueTempDirectory()

ilCalendarCopyFilesToTempDirectoryJob::createUniqueTempDirectory ( )
protected
Todo:
refactor to new file system access Create unique temp directory
Returns
string absolute path to new temp directory

Definition at line 100 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

References ilUtil\ilTempnam(), and ilUtil\makeDirParents().

Referenced by run().

101  {
102  $tmpdir = ilUtil::ilTempnam();
103  ilUtil::makeDirParents($tmpdir);
104  $this->logger->info('New temp directory: ' . $tmpdir);
105  return $tmpdir;
106  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExpectedTimeOfTaskInSeconds()

ilCalendarCopyFilesToTempDirectoryJob::getExpectedTimeOfTaskInSeconds ( )

Returns
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount of data, try to set a possible high value of try to calculate it. If a task duration exceeds this value, it will be displayed as "possibly failed" to the user

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 152 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

153  {
154  return 30;
155  }

◆ getInputTypes()

ilCalendarCopyFilesToTempDirectoryJob::getInputTypes ( )
Returns
Type[] A list of types that are taken as input.

Implements ILIAS\BackgroundTasks\Task.

Definition at line 41 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

42  {
43  return
44  [
45  new SingleType(ilCalendarCopyDefinition::class)
46  ];
47  }

◆ getOutputType()

ilCalendarCopyFilesToTempDirectoryJob::getOutputType ( )
Todo:
output should be file type
Returns
SingleType

Implements ILIAS\BackgroundTasks\Task.

Definition at line 53 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

54  {
55  return new SingleType(StringValue::class);
56  }

◆ isStateless()

ilCalendarCopyFilesToTempDirectoryJob::isStateless ( )
Returns
bool returns true iff the job's output ONLY depends on the input. Stateless task results may be cached!

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 58 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

59  {
60  return true;
61  }

◆ run()

ilCalendarCopyFilesToTempDirectoryJob::run ( array  $input,
Observer  $observer 
)

run the job

Parameters
Value$input
Observer$observer

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 68 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

References $out, copyFiles(), createTargetDirectory(), and createUniqueTempDirectory().

69  {
70  $cal_copy_def = $input[0];
71 
72  $this->logger->info('Called copy files job');
73 
74  $this->target_directory = $cal_copy_def->getTempDir();
75  //$this->target_directory = $input[1]->getValue();
76 
77  // create temp directory
78  $tmpdir = $this->createUniqueTempDirectory();
79  $targetdir = $this->createTargetDirectory($tmpdir);
80 
81  // copy files from source to temp directory
82  //$this->copyFiles($targetdir, $input[0]);
83  $this->copyFiles($targetdir, $cal_copy_def);
84 
85  // zip
86 
87  // return zip file name
88  $this->logger->debug('Returning new tempdirectory: ' . $targetdir);
89 
90  $out = new StringValue();
91  $out->setValue($targetdir);
92  return $out;
93  }
copyFiles($tmpdir, ilCalendarCopyDefinition $definition)
Copy files.
+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilCalendarCopyFilesToTempDirectoryJob::$logger = null
private

◆ $target_directory

ilCalendarCopyFilesToTempDirectoryJob::$target_directory
protected

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