ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDataSet Class Reference

A dataset contains in data in a common structure that can be shared and transformed for different purposes easily, examples. More...

+ Inheritance diagram for ilDataSet:
+ Collaboration diagram for ilDataSet:

Public Member Functions

 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Data Fields

const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 
int $dircnt = 0
 

Protected Member Functions

 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Private Member Functions

 addTypesXml (ilXmlWriter $a_writer, string $a_entity, string $a_schema_version)
 

Detailed Description

A dataset contains in data in a common structure that can be shared and transformed for different purposes easily, examples.

  • transform associative arrays into (set-)xml and back (e.g. for import/export)
  • transform assiciative arrays into json and back (e.g. for ajax requests)

The general structure is:

  • entity name (many times this corresponds to a table name)
  • structure (this is a set of field names and types pairs) currently supported types: text, integer, timestamp planned: date, time, clob types correspond to db types, see http://www.ilias.de/docu/goto.php?target=pg_25354_42&client_id=docu
  • records (similar to records of a database query; associative arrays)
Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilDataSet::__construct ( )

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

References $DIC, and ilLoggerFactory\getLogger().

71  {
72  global $DIC;
73 
74  $this->db = $DIC->database();
75  $this->ds_log = ilLoggerFactory::getLogger('ds');
76  $this->irss = $DIC->resourceStorage();
77  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ addRecordsXml()

ilDataSet::addRecordsXml ( ilXmlWriter  $a_writer,
array  $a_prefixes,
string  $a_entity,
string  $a_schema_version,
array  $a_ids,
?string  $a_field = "" 
)

Definition at line 287 of file class.ilDataSet.php.

References $c, Vendor\Package\$d, $dircnt, Vendor\Package\$f, afterXmlRecordWriting(), getCollection(), getContainerExportConfig(), getDependencies(), getDSPrefixString(), getExportDirInContainer(), getIRSSContainerExportConfig(), getXMLEntityName(), getXMLEntityTag(), getXmlRecord(), getXmlTypes(), null, readData(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXmlRepresentation().

294  : void {
295  $types = $this->getXmlTypes($a_entity, $a_schema_version);
296  $this->ds_log->debug("...read data");
297  $this->readData($a_entity, $a_schema_version, $a_ids);
298  $this->ds_log->debug("...data: " . print_r($this->data, true));
299  foreach ($this->data as $d) {
300  $a_writer->xmlStartTag(
301  $this->getDSPrefixString() . "Rec",
302  array("Entity" => $this->getXMLEntityName($a_entity, $a_schema_version))
303  );
304  $a_writer->xmlStartTag($this->getXMLEntityTag($a_entity, ''));
305  $rec = $this->getXmlRecord($a_entity, $a_schema_version, $d);
306  foreach ($rec as $f => $c) {
307  if (isset($this->export) and ($types[$f] ?? "") === "directory") {
308  $sdir = realpath($c);
309  $path_in_container = $this->export->getPathToComponentExpDirInContainer() . "/dsDir_" . $this->dircnt;
310  $this->export->getExportWriter()->writeDirectory(
311  $sdir,
312  $path_in_container
313  );
314  $c = $this->getExportDirInContainer($path_in_container); // note: this corrects the path, see above
315  $this->dircnt++;
316  }
317  if (isset($this->export) and ($types[$f] ?? "") === "rscollection") {
318  $path_in_container = $this->export->getPathToComponentExpDirInContainer() . "/dsDir_" . $this->dircnt;
319  $collection = $this->getCollection($rec, $a_entity, $a_schema_version, $f, $c);
320  if (!is_null($collection)) {
321  $this->export->getExportWriter()->writeFilesByResourceCollection(
322  $collection,
323  $path_in_container
324  );
325  }
326 
327  $c = $this->getExportDirInContainer($path_in_container); // note: this corrects the path, see above
328  $this->dircnt++;
329  }
330  if (isset($this->export) and ($types[$f] ?? "") === "rscontainer") {
331  $path_in_container = $this->export->getPathToComponentExpDirInContainer() . "/dsDir_" . $this->dircnt;
332  if ($config = $this->getContainerExportConfig($rec, $a_entity, $a_schema_version, $f, $c)) {
333  $this->export->getExportWriter()->writeFilesByResourceContainer(
335  $config->getSourceContainer(),
336  $config->getSourcePath(),
337  $path_in_container
338  )
339  );
340  }
341  $c = $this->getExportDirInContainer($path_in_container); // note: this corrects the path, see above
342  $this->dircnt++;
343  }
344  // this changes schema/dtd
345  //$a_writer->xmlElement($a_prefixes[$a_entity].":".$f,
346  // array(), $c);
347  $a_writer->xmlElement($f, array(), $c);
348  }
349 
350  $a_writer->xmlEndTag($this->getXMLEntityTag($a_entity, ''));
351 
352  $a_writer->xmlEndTag($this->getDSPrefixString() . "Rec");
353 
354  $this->afterXmlRecordWriting($a_entity, $a_schema_version, $d);
355 
356  // foreach record records of dependent entities
357  $this->ds_log->debug("...get dependencies");
358  $deps = $this->getDependencies($a_entity, $a_schema_version, $rec, $a_ids);
359  $this->ds_log->debug("...dependencies: " . print_r($deps, true));
360  foreach ($deps as $dp => $par) {
361  $ids = !is_array($par["ids"])
362  ? [$par["ids"]]
363  : $par["ids"];
364  $this->addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $ids, $par["field"] ?? null);
365  }
366  }
367  }
getXMLEntityName(string $a_entity, string $a_version)
Get entity name for xml (may be overwritten)
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
getCollection(array $record, string $entity, string $schema_version, string $field, string $value)
getXmlRecord(string $a_entity, string $a_version, array $a_set)
Get xml record for version.
getContainerExportConfig(array $record, string $entity, string $schema_version, string $field, string $value)
getXmlTypes(string $a_entity, string $a_version)
Get xml types.
getExportDirInContainer(string $exp_dir)
$c
Definition: deliver.php:25
addRecordsXml(ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
getIRSSContainerExportConfig(StorableResource $source_container, string $source_path, string $target_path="")
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
afterXmlRecordWriting(string $a_entity, string $a_version, array $a_set)
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
getXMLEntityTag(string $a_entity, string $a_schema_version)
Get entity tag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addTypesXml()

ilDataSet::addTypesXml ( ilXmlWriter  $a_writer,
string  $a_entity,
string  $a_schema_version 
)
private

Definition at line 396 of file class.ilDataSet.php.

References Vendor\Package\$f, getDependencies(), getDSPrefixString(), getXMLEntityName(), getXmlTypes(), null, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXmlRepresentation().

396  : void
397  {
398  $types = $this->getXmlTypes($a_entity, $a_schema_version);
399 
400  // add types of current entity
401  if (count($types) > 0) {
402  $a_writer->xmlStartTag(
403  $this->getDSPrefixString() . "Types",
404  array("Entity" => $this->getXMLEntityName($a_entity, $a_schema_version),
405  "SchemaVersion" => $a_schema_version)
406  );
407  foreach ($this->getXmlTypes($a_entity, $a_schema_version) as $f => $t) {
408  $a_writer->xmlElement(
409  $this->getDSPrefixString() . 'FieldType',
410  array("Name" => $f, "Type" => $t)
411  );
412  }
413  $a_writer->xmlEndTag($this->getDSPrefixString() . "Types");
414  }
415 
416  // add types of dependent entities
417  $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
418  foreach ($deps as $dp => $w) {
419  $this->addTypesXml($a_writer, $dp, $a_schema_version);
420  }
421  }
getXMLEntityName(string $a_entity, string $a_version)
Get entity name for xml (may be overwritten)
getXmlTypes(string $a_entity, string $a_version)
Get xml types.
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
addTypesXml(ilXmlWriter $a_writer, string $a_entity, string $a_schema_version)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ afterXmlRecordWriting()

ilDataSet::afterXmlRecordWriting ( string  $a_entity,
string  $a_version,
array  $a_set 
)

Definition at line 391 of file class.ilDataSet.php.

Referenced by addRecordsXml().

391  : void
392  {
393  }
+ Here is the caller graph for this function:

◆ convertToLeadingUpper()

ilDataSet::convertToLeadingUpper ( string  $a_str)

Make xyz_abc a XyzAbc string.

Definition at line 189 of file class.ilDataSet.php.

Referenced by getDirectDataFromQuery(), getXMLEntityTag(), ilUserDataSet\importRecord(), ilMediaPoolDataSet\readData(), and ilLearningModuleDataSet\readData().

189  : string
190  {
191  $a_str = strtoupper(substr($a_str, 0, 1)) . substr($a_str, 1);
192  while (($pos = strpos($a_str, "_")) !== false) {
193  $a_str = substr($a_str, 0, $pos) .
194  strtoupper(substr($a_str, $pos + 1, 1)) .
195  substr($a_str, $pos + 2);
196  }
197  return $a_str;
198  }
+ Here is the caller graph for this function:

◆ createObjectExportId()

ilDataSet::createObjectExportId ( string  $a_type,
string  $a_id 
)
protected

Build ilias export id.

Definition at line 495 of file class.ilDataSet.php.

References IL_INST_ID.

Referenced by ilBlogDataSet\readData().

495  : string
496  {
497  return "il_" . IL_INST_ID . "_" . $a_type . "_" . $a_id;
498  }
const IL_INST_ID
Definition: constants.php:40
+ Here is the caller graph for this function:

◆ getCollection()

ilDataSet::getCollection ( array  $record,
string  $entity,
string  $schema_version,
string  $field,
string  $value 
)

Definition at line 567 of file class.ilDataSet.php.

References null.

Referenced by addRecordsXml().

573  : ?ResourceCollection {
574  return null;
575  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getContainerExportConfig()

ilDataSet::getContainerExportConfig ( array  $record,
string  $entity,
string  $schema_version,
string  $field,
string  $value 
)

Definition at line 577 of file class.ilDataSet.php.

References null.

Referenced by addRecordsXml().

584  return null;
585  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getCurrentInstallationId()

ilDataSet::getCurrentInstallationId ( )

Definition at line 487 of file class.ilDataSet.php.

References $current_installation_id.

Referenced by ilSurveyDataSet\importRecord(), ilGlossaryDataSet\importRecord(), ilMediaObjectDataSet\importRecord(), ilLearningModuleDataSet\importRecord(), and ilSkillDataSet\importRecord().

487  : string
488  {
490  }
string $current_installation_id
+ Here is the caller graph for this function:

◆ getDependencies()

ilDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Definition at line 381 of file class.ilDataSet.php.

Referenced by addRecordsXml(), addTypesXml(), and getNamespaces().

386  : array {
387  return [];
388  }
+ Here is the caller graph for this function:

◆ getDirectDataFromQuery()

ilDataSet::getDirectDataFromQuery ( string  $a_query,
bool  $a_convert_to_leading_upper = true,
bool  $a_set = true 
)

Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields.

Definition at line 158 of file class.ilDataSet.php.

References $db, $ilDB, and convertToLeadingUpper().

Referenced by ilObjectDataSet\getTypes(), ilCmiXapiDataSet\getTypes(), ilHTMLLearningModuleDataSet\readData(), ilRatingDataSet\readData(), ilItemGroupDataSet\readData(), ilCOPageDataSet\readData(), ilSurveyDataSet\readData(), ilNewsDataSet\readData(), ilNotesDataSet\readData(), ilMediaCastDataSet\readData(), ilHelpDataSet\readData(), ilPortfolioDataSet\readData(), ilTaxonomyDataSet\readData(), ilCalendarDataSet\readData(), ilGlossaryDataSet\readData(), ilMediaPoolDataSet\readData(), ilPollDataSet\readData(), ilUserDataSet\readData(), ilMediaObjectDataSet\readData(), ilSessionDataSet\readData(), ilWikiDataSet\readData(), ilBlogDataSet\readData(), ilSkillDataSet\readData(), ilStyleDataSet\readData(), ilLearningModuleDataSet\readData(), and ilExerciseDataSet\readData().

162  : array {
163  $ilDB = $this->db;
164 
165  $set = $ilDB->query($a_query);
166  $this->data = array();
167  $ret = [];
168  while ($rec = $ilDB->fetchAssoc($set)) {
169  if ($a_convert_to_leading_upper) {
170  $tmp = array();
171  foreach ($rec as $k => $v) {
172  $tmp[$this->convertToLeadingUpper($k)]
173  = $v;
174  }
175  $rec = $tmp;
176  }
177 
178  if ($a_set) {
179  $this->data[] = $rec;
180  }
181  $ret[] = $rec;
182  }
183  return $ret;
184  }
convertToLeadingUpper(string $a_str)
Make xyz_abc a XyzAbc string.
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDSPrefix()

ilDataSet::getDSPrefix ( )

Definition at line 141 of file class.ilDataSet.php.

References $ds_prefix.

Referenced by getDSPrefixString(), and getXmlRepresentation().

141  : string
142  {
143  return $this->ds_prefix;
144  }
string $ds_prefix
+ Here is the caller graph for this function:

◆ getDSPrefixString()

ilDataSet::getDSPrefixString ( )

Definition at line 146 of file class.ilDataSet.php.

References getDSPrefix().

Referenced by addRecordsXml(), addTypesXml(), and getXmlRepresentation().

146  : string
147  {
148  if ($this->getDSPrefix() !== "") {
149  return $this->getDSPrefix() . ":";
150  }
151  return "";
152  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportDirInContainer()

ilDataSet::getExportDirInContainer ( string  $exp_dir)
protected

Definition at line 273 of file class.ilDataSet.php.

Referenced by addRecordsXml().

273  : string
274  {
275  // note, the export returns in ILIAS 10 (Jan 2024) something like
276  // 1737382047__0__cat_436/components/ILIAS/Style/set_0/dsDir_1
277  // whereas ILIAS 9 returned
278  // Services/Style/set_1/expDir_1/dsDir_1
279  // thus we skip the 1737382047__0__cat_436/ part since it would be redundant
280  // an make import fail
281  if (str_contains($exp_dir, "components/")) {
282  $exp_dir = substr($exp_dir, strpos($exp_dir, "components/"));
283  }
284  return $exp_dir;
285  }
+ Here is the caller graph for this function:

◆ getImport()

ilDataSet::getImport ( )

Definition at line 477 of file class.ilDataSet.php.

References $import.

Referenced by ilSurveyDataSet\importRecord().

478  {
479  return $this->import;
480  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilSurveyImporter $import
+ Here is the caller graph for this function:

◆ getImportDirectory()

◆ getIRSSContainerExportConfig()

ilDataSet::getIRSSContainerExportConfig ( StorableResource  $source_container,
string  $source_path,
string  $target_path = "" 
)
protected

Definition at line 369 of file class.ilDataSet.php.

Referenced by addRecordsXml(), ilMediaObjectDataSet\getContainerExportConfig(), and ilStyleDataSet\getContainerExportConfig().

374  return new IRSSContainerExportConfig(
375  $source_container,
376  $source_path,
377  $target_path
378  );
379  }
+ Here is the caller graph for this function:

◆ getNamespaces()

ilDataSet::getNamespaces ( array &  $namespaces,
string  $a_entity,
string  $a_schema_version 
)

Definition at line 424 of file class.ilDataSet.php.

References getDependencies(), getXmlNamespace(), and null.

Referenced by getXmlRepresentation().

424  : void
425  {
426  $ns = $this->getXmlNamespace($a_entity, $a_schema_version);
427  if ($ns !== "") {
428  $namespaces[$a_entity] = $ns;
429  }
430  // add types of dependent entities
431  $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
432  foreach ($deps as $dp => $w) {
433  $this->getNamespaces($namespaces, $dp, $a_schema_version);
434  }
435  }
getNamespaces(array &$namespaces, string $a_entity, string $a_schema_version)
getXmlNamespace(string $a_entity, string $a_schema_version)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSupportedVersions()

ilDataSet::getSupportedVersions ( )
abstract

Referenced by init().

+ Here is the caller graph for this function:

◆ getTypes()

ilDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
abstractprotected

Get (abstract) types for (abstract) field names.

Please note that the abstract fields/types only depend on the version! Not on a choosen representation!

Returns
array types array, e.g. array("field_1" => "text", "field_2" => "integer", ...)

Referenced by getXmlTypes(), and init().

+ Here is the caller graph for this function:

◆ getXMLEntityName()

ilDataSet::getXMLEntityName ( string  $a_entity,
string  $a_version 
)

Get entity name for xml (may be overwritten)

Definition at line 459 of file class.ilDataSet.php.

Referenced by addRecordsXml(), and addTypesXml().

459  : string
460  {
461  return $a_entity;
462  }
+ Here is the caller graph for this function:

◆ getXMLEntityTag()

ilDataSet::getXMLEntityTag ( string  $a_entity,
string  $a_schema_version 
)

Get entity tag.

Definition at line 467 of file class.ilDataSet.php.

References convertToLeadingUpper().

Referenced by addRecordsXml().

467  : string
468  {
469  return $this->convertToLeadingUpper($a_entity);
470  }
convertToLeadingUpper(string $a_str)
Make xyz_abc a XyzAbc string.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXmlNamespace()

ilDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
abstractprotected

Referenced by getNamespaces(), and init().

+ Here is the caller graph for this function:

◆ getXmlRecord()

ilDataSet::getXmlRecord ( string  $a_entity,
string  $a_version,
array  $a_set 
)

Get xml record for version.

Parameters
array$a_setabstract data record

Definition at line 441 of file class.ilDataSet.php.

Referenced by addRecordsXml().

441  : array
442  {
443  return $a_set;
444  }
+ Here is the caller graph for this function:

◆ getXmlRepresentation()

ilDataSet::getXmlRepresentation ( string  $a_entity,
string  $a_schema_version,
?array  $a_ids,
string  $a_field = "",
bool  $a_omit_header = false,
bool  $a_omit_types = false 
)
final

Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ...

</types> <set entity="table_name"> <rec> <field_1>content</field_1> <field_2>my_date</field_2> <field_3>my_number</field_3> </rec> ... </set> </dataset>

Definition at line 222 of file class.ilDataSet.php.

References $entity, addRecordsXml(), addTypesXml(), getDSPrefix(), getDSPrefixString(), getNamespaces(), and IL_INST_ID.

229  : string {
230  $this->dircnt = 1;
231 
232  // init writer
233  $writer = new ilXmlWriter();
234  if (!$a_omit_header) {
235  $writer->xmlHeader();
236  }
237 
238  // collect namespaces
239  $namespaces = $prefixes = array();
240  $this->getNamespaces($namespaces, $a_entity, $a_schema_version);
241  $atts = array("InstallationId" => IL_INST_ID,
242  "InstallationUrl" => ILIAS_HTTP_PATH, "TopEntity" => $a_entity);
243  $cnt = 1;
244  foreach ($namespaces as $entity => $ns) {
245  $prefix = "ns" . $cnt;
246  $prefixes[$entity] = $prefix;
247  // $atts["xmlns:".$prefix] = $ns;
248  $cnt++;
249  }
250  $this->ds_log->debug("Start writing Dataset, entity: " . $a_entity . ", schema version: " . $a_schema_version .
251  ", ids: " . print_r($a_ids, true));
252 
253  if ($this->getDSPrefix() !== '') {
254  $atts['xmlns:' . $this->getDSPrefix()] = self::DATASET_NS;
255  } else {
256  $atts['xmlns'] = self::DATASET_NS;
257  }
258  $writer->xmlStartTag($this->getDSPrefixString() . 'DataSet', $atts);
259  // add types
260  if (!$a_omit_types) {
261  $this->ds_log->debug("...write types");
262  $this->addTypesXml($writer, $a_entity, $a_schema_version);
263  }
264  // add records
265  $this->ds_log->debug("...write records");
266  $this->addRecordsXml($writer, $prefixes, $a_entity, $a_schema_version, $a_ids, $a_field);
267 
268  $writer->xmlEndTag($this->getDSPrefixString() . "DataSet");
269 
270  return $writer->xmlDumpMem(false);
271  }
const IL_INST_ID
Definition: constants.php:40
getNamespaces(array &$namespaces, string $a_entity, string $a_schema_version)
addRecordsXml(ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
addTypesXml(ilXmlWriter $a_writer, string $a_entity, string $a_schema_version)
string $entity
+ Here is the call graph for this function:

◆ getXmlTypes()

ilDataSet::getXmlTypes ( string  $a_entity,
string  $a_version 
)

Get xml types.

Returns
array types array for xml/version set in constructor

Definition at line 450 of file class.ilDataSet.php.

References getTypes().

Referenced by addRecordsXml(), and addTypesXml().

450  : array
451  {
452  return $this->getTypes($a_entity, $a_version);
453  }
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importRecord()

ilDataSet::importRecord ( string  $a_entity,
array  $a_types,
array  $a_rec,
ilImportMapping  $a_mapping,
string  $a_schema_version 
)

Needs to be overwritten for import use case.

Definition at line 558 of file class.ilDataSet.php.

Referenced by ilItemGroupDataSet\getDependencies(), ilObjectDataSet\getDependencies(), ilBibliographicDataSet\getXmlNamespace(), ilDataCollectionDataSet\getXmlNamespace(), ilHTMLLearningModuleDataSet\getXmlRecord(), and ilPollDataSet\getXmlRecord().

564  : void {
565  }
+ Here is the caller graph for this function:

◆ init()

ilDataSet::init ( string  $a_entity,
string  $a_schema_version 
)
final

Init.

Parameters
string(abstract) entity name
stringversion string, always the ILIAS release versions that defined the a structure or made changes to it, never use another version. Example: structure is defined in 4.1.0 and changed in 4.3.0 -> use these values only, not 4.2.0 (ask for the 4.1.0 version in ILIAS 4.2.0)

Definition at line 91 of file class.ilDataSet.php.

References getSupportedVersions(), getTypes(), getXmlNamespace(), and readData().

91  : void
92  {
93  $this->entity = $a_entity;
94  $this->schema_version = $a_schema_version;
95  $this->data = array();
96  }
+ Here is the call graph for this function:

◆ initByExporter()

ilDataSet::initByExporter ( ilXmlExporter  $xml_exporter)

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

References ilXmlExporter\getExport().

121  : void
122  {
123  $this->export = $xml_exporter->getExport();
124  }
+ Here is the call graph for this function:

◆ parseObjectExportId()

ilDataSet::parseObjectExportId ( string  $a_id,
?string  $a_fallback_id = null 
)
protected

Parse export id.

Returns
array type, id

Definition at line 504 of file class.ilDataSet.php.

References $id, $parts, ilObject\_getIdForImportId(), ilObject\_lookupType(), and IL_INST_ID.

Referenced by ilBlogDataSet\importRecord().

504  : array
505  {
506  // ilias export id?
507  if (strpos($a_id, "il_") === 0) {
508  $parts = explode("_", $a_id);
509  if (count($parts) !== 4) {
510  throw new ilException("Invalid import ID '" . $a_id . "'.");
511  }
512  $inst_id = $parts[1];
513  $type = $parts[2];
514  $id = $parts[3];
515 
516  // missing installation ids?
517  if (($inst_id == 0 || IL_INST_ID === "0") && !DEVMODE) {
518  return array("type" => self::EXPORT_NO_INST_ID, "id" => $a_fallback_id);
519  }
520 
521  // same installation?
522  if ($inst_id == IL_INST_ID) {
523  // still existing?
524  if (ilObject::_lookupType($id) === $type) {
525  return array("type" => self::EXPORT_ID_ILIAS_LOCAL, "id" => $id);
526  }
527  // not found
528  else {
529  return array("type" => self::EXPORT_ID_ILIAS_LOCAL_INVALID, "id" => $a_fallback_id);
530  }
531  }
532  // different installation
533  else {
535  // matching type?
536  if ($id && ilObject::_lookupType($id) === $type) {
537  return array("type" => self::EXPORT_ID_ILIAS_REMOTE, "id" => $id);
538  }
539  // not found
540  else {
541  return array("type" => self::EXPORT_ID_ILIAS_REMOTE_INVALID, "id" => $a_fallback_id);
542  }
543  }
544  } else {
545  // external id
547  if ($id) {
548  return array("type" => self::EXPORT_ID, "id" => $id);
549  } else {
550  return array("type" => self::EXPORT_ID_INVALID, "id" => $a_fallback_id);
551  }
552  }
553  }
const IL_INST_ID
Definition: constants.php:40
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
static _getIdForImportId(string $import_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readData()

ilDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)
abstract

Read data from DB.

This should result in the abstract field structure of the version set in the constructor.

Referenced by addRecordsXml(), ilCmiXapiDataSet\getDependencies(), ilObjectDataSet\getTypes(), ilCmiXapiDataSet\getTypes(), and init().

+ Here is the caller graph for this function:

◆ setCurrentInstallationId()

ilDataSet::setCurrentInstallationId ( string  $a_val)

Definition at line 482 of file class.ilDataSet.php.

482  : void
483  {
484  $this->current_installation_id = $a_val;
485  }

◆ setDSPrefix()

ilDataSet::setDSPrefix ( string  $a_val)

Definition at line 136 of file class.ilDataSet.php.

136  : void
137  {
138  $this->ds_prefix = $a_val;
139  }

◆ setImport()

ilDataSet::setImport ( ilSurveyImporter  $a_val)

Definition at line 472 of file class.ilDataSet.php.

472  : void
473  {
474  $this->import = $a_val;
475  }

◆ setImportDirectory()

ilDataSet::setImportDirectory ( string  $a_val)

Definition at line 126 of file class.ilDataSet.php.

126  : void
127  {
128  $this->import_directory = $a_val;
129  }

◆ stripTags()

ilDataSet::stripTags ( array  $rec,
array  $omit_keys = [] 
)
protected

Definition at line 587 of file class.ilDataSet.php.

References ilUtil\stripSlashes().

Referenced by ilItemGroupDataSet\getDependencies(), ilHTMLLearningModuleDataSet\getXmlRecord(), ilPollDataSet\getXmlRecord(), ilRatingDataSet\importRecord(), ilNotesDataSet\importRecord(), ilCOPageDataSet\importRecord(), ilNewsDataSet\importRecord(), ilSurveyDataSet\importRecord(), ilHelpDataSet\importRecord(), ilPortfolioDataSet\importRecord(), ilMediaCastDataSet\importRecord(), ilTaxonomyDataSet\importRecord(), ilMediaPoolDataSet\importRecord(), ilGlossaryDataSet\importRecord(), ilBlogDataSet\importRecord(), ilWikiDataSet\importRecord(), ilMediaObjectDataSet\importRecord(), ilStyleDataSet\importRecord(), ilLearningModuleDataSet\importRecord(), and ilExerciseDataSet\importRecord().

587  : array
588  {
589  $ret_rec = [];
590  foreach ($rec as $k => $v) {
591  if (in_array($k, $omit_keys, true)) {
592  $ret_rec[$k] = $v;
593  } else {
594  $ret_rec[$k] = ilUtil::stripSlashes($v);
595  }
596  }
597  return $ret_rec;
598  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $component_export_dir

string ilDataSet::$component_export_dir = ""
protected

Definition at line 64 of file class.ilDataSet.php.

◆ $current_installation_id

string ilDataSet::$current_installation_id = ""
protected

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

Referenced by getCurrentInstallationId().

◆ $data

◆ $db

◆ $dircnt

int ilDataSet::$dircnt = 0

Definition at line 56 of file class.ilDataSet.php.

Referenced by addRecordsXml().

◆ $ds_log

ilLogger ilDataSet::$ds_log
protected

Definition at line 60 of file class.ilDataSet.php.

◆ $ds_prefix

string ilDataSet::$ds_prefix = "ds"
protected

Definition at line 65 of file class.ilDataSet.php.

Referenced by getDSPrefix().

◆ $entity

string ilDataSet::$entity = ""
protected

◆ $export

ilExport ilDataSet::$export
protected

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

◆ $import

ilSurveyImporter ilDataSet::$import
protected

Definition at line 67 of file class.ilDataSet.php.

Referenced by getImport().

◆ $import_directory

string ilDataSet::$import_directory = ""
protected

Definition at line 61 of file class.ilDataSet.php.

Referenced by getImportDirectory().

◆ $irss

ILIAS ResourceStorage Services ilDataSet::$irss
protected

Definition at line 54 of file class.ilDataSet.php.

◆ $schema_version

string ilDataSet::$schema_version = ""
protected

Definition at line 63 of file class.ilDataSet.php.

Referenced by ilObjectDataSet\getDependencies().

◆ $version

string ilDataSet::$version = ""
protected

Definition at line 66 of file class.ilDataSet.php.

Referenced by ilObjectDataSet\getTypes().

◆ DATASET_NS

const ilDataSet::DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'

◆ DATASET_NS_PREFIX

const ilDataSet::DATASET_NS_PREFIX = 'ds'

◆ EXPORT_ID

const ilDataSet::EXPORT_ID = 6

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

◆ EXPORT_ID_ILIAS_LOCAL

const ilDataSet::EXPORT_ID_ILIAS_LOCAL = 2

Definition at line 48 of file class.ilDataSet.php.

◆ EXPORT_ID_ILIAS_LOCAL_INVALID

const ilDataSet::EXPORT_ID_ILIAS_LOCAL_INVALID = 3

Definition at line 49 of file class.ilDataSet.php.

◆ EXPORT_ID_ILIAS_REMOTE

const ilDataSet::EXPORT_ID_ILIAS_REMOTE = 4

Definition at line 50 of file class.ilDataSet.php.

◆ EXPORT_ID_ILIAS_REMOTE_INVALID

const ilDataSet::EXPORT_ID_ILIAS_REMOTE_INVALID = 5

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

◆ EXPORT_ID_INVALID

const ilDataSet::EXPORT_ID_INVALID = 7

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

◆ EXPORT_NO_INST_ID

const ilDataSet::EXPORT_NO_INST_ID = 1

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


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