ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDataCollectionDataSet Class Reference

DataCollection dataset class. More...

+ Inheritance diagram for ilDataCollectionDataSet:
+ Collaboration diagram for ilDataCollectionDataSet:

Public Member Functions

 __construct ()
 
 getSupportedVersions ()
 
 getCache ($a_entity)
 Get cached data from a given entity. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from Cache for a given entity and ID(s) More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true, $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ($a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $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 ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. More...
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Map XML attributes of entities to datatypes (text, integer...) More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Return dependencies form entities to other entities (in our case these are all the DB relations) More...
 
 _readData ($a_entity, $a_ids)
 Build data array, data is read from cache except dcl object itself. More...
 
 buildCache ($a_entity, $set)
 Helper method to build cache for data of all entities. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=NULL)
 Parse export id. More...
 

Protected Attributes

 $db
 
 $data = array()
 
 $record_field_ids_2_storage = array()
 
 $caches
 
 $import_dc_object
 
 $count_imported_tables = 0
 
 $import_record_field_cache = array()
 
 $user
 
 $import_temp_refs = array()
 
 $import_temp_refs_props = array()
 
 $import_temp_new_mob_ids = array()
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
 
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
 

Detailed Description

DataCollection dataset class.

Author
Stefan Wanzenried sw@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 14 of file class.ilDataCollectionDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilDataCollectionDataSet::__construct ( )

Definition at line 95 of file class.ilDataCollectionDataSet.php.

References $DIC, $ilDB, $ilUser, and user().

95  {
96  global $DIC;
97  $ilDB = $DIC['ilDB'];
98  $ilUser = $DIC['ilUser'];
99  parent::__construct();
100  $this->db = $ilDB;
101  $this->user = $ilUser;
102  }
user()
Definition: user.php:4
$ilUser
Definition: imgupload.php:18
global $ilDB
global $DIC
+ Here is the call graph for this function:

Member Function Documentation

◆ _readData()

ilDataCollectionDataSet::_readData (   $a_entity,
  $a_ids 
)
protected

Build data array, data is read from cache except dcl object itself.

Parameters
$a_entity
$a_ids

Definition at line 699 of file class.ilDataCollectionDataSet.php.

References $data, ilObject\_lookupType(), array, data, and getCache().

Referenced by readData().

699  {
700  switch ($a_entity) {
701  case 'dcl':
702  foreach ($a_ids as $dcl_id) {
703  if (ilObject::_lookupType($dcl_id) == 'dcl') {
704  $obj = new ilObjDataCollection($dcl_id, false);
705  $data = array(
706  'id' => $dcl_id,
707  'title' => $obj->getTitle(),
708  'description' => $obj->getDescription(),
709  'is_online' => $obj->getOnline(),
710  'rating' => $obj->getRating(),
711  'public_notes' => $obj->getPublicNotes(),
712  'approval' => $obj->getApproval(),
713  'notification' => $obj->getNotification(),
714  );
715  $this->caches['dcl'][$dcl_id] = $data;
716  $this->data[] = $data;
717  }
718  }
719  break;
720  default:
721  $data = $this->getCache($a_entity);
722  foreach ($a_ids as $id) {
723  $this->data[] = $data[$id];
724  }
725  }
726  }
Add some data
getCache($a_entity)
Get cached data from a given entity.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilObjDataCollection.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildCache()

ilDataCollectionDataSet::buildCache (   $a_entity,
  $set 
)
protected

Helper method to build cache for data of all entities.

Parameters
$a_entity
Object$setilDB->query() object

Definition at line 738 of file class.ilDataCollectionDataSet.php.

References $data, array, and getTypes().

Referenced by getDependencies().

738  {
739  $fields = array_keys($this->getTypes($a_entity, ''));
740  $ids = array();
741  while ($rec = $this->db->fetchObject($set)) {
742  $data = array();
743  foreach ($fields as $field) {
744  $data[$field] = $rec->{$field};
745  }
746  $id = $rec->id;
747  $this->caches[$a_entity][$id] = $data;
748  $ids[] = $id;
749  }
750 
751  return $ids;
752  }
Create styles array
The data for the language used.
getTypes($a_entity, $a_version)
Map XML attributes of entities to datatypes (text, integer...)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCache()

ilDataCollectionDataSet::getCache (   $a_entity)

Get cached data from a given entity.

Parameters
$a_entity
Returns
mixed
Exceptions
ilException

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

Referenced by _readData().

121  {
122  if (!in_array($a_entity, array_keys($this->caches))) {
123  throw new ilException("Entity '$a_entity' does not exist in Cache");
124  }
125 
126  return $this->caches[$a_entity];
127  }
Base class for ILIAS Exception handling.
+ Here is the caller graph for this function:

◆ getDependencies()

ilDataCollectionDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Return dependencies form entities to other entities (in our case these are all the DB relations)

Parameters
$a_entity
$a_version
$a_rec
$a_ids
Returns
array

Definition at line 588 of file class.ilDataCollectionDataSet.php.

References array, buildCache(), and ilDclCache\getFieldCache().

588  {
589  if (!$a_rec && !$a_ids) {
590  return false;
591  }
592  switch ($a_entity) {
593  case 'dcl':
594  $set = $this->db->query('SELECT * FROM il_dcl_table WHERE obj_id = ' . $this->db->quote($a_rec['id'], 'integer') . ' ORDER BY id');
595  $ids = $this->buildCache('il_dcl_table', $set);
596 
597  return array(
598  'il_dcl_table' => array( 'ids' => $ids ),
599  );
600  break;
601  case 'il_dcl_table':
602  $set = $this->db->query('SELECT * FROM il_dcl_record WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
603  $ids_records = $this->buildCache('il_dcl_record', $set);
604  $set = $this->db->query('SELECT * FROM il_dcl_field WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
605  $ids_fields = $this->buildCache('il_dcl_field', $set);
606  $set = $this->db->query('SELECT * FROM il_dcl_tableview WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
607  $ids_tableviews = $this->buildCache('il_dcl_tableview', $set);
608  $set = $this->db->query('SELECT * FROM il_dcl_tfield_set WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
609  $ids_tablefield_settings = $this->buildCache('il_dcl_tfield_set', $set);
610 
611  return array(
612  'il_dcl_field' => array( 'ids' => $ids_fields ),
613  'il_dcl_record' => array( 'ids' => $ids_records ),
614  'il_dcl_tableview' => array( 'ids' => $ids_tableviews ),
615  'il_dcl_tfield_set' => array( 'ids' => $ids_tablefield_settings ),
616  );
617  case 'il_dcl_field':
618  $set = $this->db->query('SELECT * FROM il_dcl_field_prop WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
619  $ids = $this->buildCache('il_dcl_field_prop', $set);
620 
621  return array(
622  'il_dcl_field_prop' => array( 'ids' => $ids ),
623  );
624  case 'il_dcl_record':
625  $sql = 'SELECT rf.*, d.storage_location FROM il_dcl_record_field AS rf' . ' INNER JOIN il_dcl_field AS f ON (f.id = rf.field_id)'
626  . ' INNER JOIN il_dcl_datatype AS d ON (f.datatype_id = d.id) ' . ' WHERE rf.record_id = '
627  . $this->db->quote($a_rec['id'], 'integer');
628  $set = $this->db->query($sql);
629  $ids = $this->buildCache('il_dcl_record_field', $set);
630 
631  $set = $this->db->query($sql);
632  while ($rec = $this->db->fetchObject($set)) {
633  $this->record_field_ids_2_storage[$rec->id] = ilDclCache::getFieldCache($rec->field_id)->getStorageLocation();
634  }
635  // Also build a cache of all values, no matter in which table they are (il_dcl_stloc(1|2|3)_value)
636  $sql =
637  'SELECT rf.id AS record_field_id, st1.value AS value1, st2.value AS value2, st3.value AS value3 FROM il_dcl_record_field AS rf '
638  . 'LEFT JOIN il_dcl_stloc1_value AS st1 ON (st1.record_field_id = rf.id) '
639  . 'LEFT JOIN il_dcl_stloc2_value AS st2 ON (st2.record_field_id = rf.id) '
640  . 'LEFT JOIN il_dcl_stloc3_value AS st3 ON (st3.record_field_id = rf.id) ' . 'WHERE rf.record_id = '
641  . $this->db->quote($a_rec['id'], 'integer');
642  $set = $this->db->query($sql);
643 
644  while ($rec = $this->db->fetchObject($set)) {
645  $stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
646  $value = "value{$stloc}";
647  // Save reocrd field id. Internal ID is not used currently
648  $this->caches["il_dcl_stloc{$stloc}_value"][$rec->record_field_id] = array(
649  'record_field_id' => $rec->record_field_id,
650  'value' => $rec->{$value}
651  );
652  }
653 
654  return array(
655  'il_dcl_record_field' => array( 'ids' => $ids )
656  );
657  case 'il_dcl_tableview':
658  $set = $this->db->query('SELECT * FROM il_dcl_tview_set WHERE tableview_id = ' . $this->db->quote($a_rec['id'], 'integer'));
659  $ids = $this->buildCache('il_dcl_tview_set', $set);
660 
661  return array(
662  'il_dcl_tview_set' => array( 'ids' => $ids )
663  );
664  case 'il_dcl_record_field':
665  $record_field_id = $a_rec['id'];
666  $storage_loc = $this->record_field_ids_2_storage[$record_field_id];
667 
668  return array(
669  "il_dcl_stloc{$storage_loc}_value" => array( 'ids' => array( $record_field_id ) )
670  );
671  }
672 
673  return false;
674  }
static getFieldCache($field_id=0)
buildCache($a_entity, $set)
Helper method to build cache for data of all entities.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getSupportedVersions()

ilDataCollectionDataSet::getSupportedVersions ( )
Returns
array

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

References array.

108  {
109  return array( '4.5.0' );
110  }
Create styles array
The data for the language used.

◆ getTypes()

ilDataCollectionDataSet::getTypes (   $a_entity,
  $a_version 
)
protected

Map XML attributes of entities to datatypes (text, integer...)

Parameters
string$a_entity
string$a_version
Returns
array

Definition at line 461 of file class.ilDataCollectionDataSet.php.

References array.

Referenced by buildCache().

461  {
462  switch ($a_entity) {
463  case 'dcl':
464  return array(
465  "id" => "integer",
466  "title" => "text",
467  "description" => "text",
468  'is_online' => 'integer',
469  'rating' => 'integer',
470  'public_notes' => 'integer',
471  'approval' => 'integer',
472  'notification' => 'integer',
473  );
474  case 'il_dcl_table':
475  return array(
476  'id' => 'integer',
477  'obj_id' => 'integer',
478  'title' => 'text',
479  'add_perm' => 'integer',
480  'edit_perm' => 'integer',
481  'delete_perm' => 'integer',
482  'edit_by_owner' => 'integer',
483  'limited' => 'integer',
484  'limit_start' => 'text',
485  'limit_end' => 'text',
486  'is_visible' => 'integer',
487  'export_enabled' => 'integer',
488  'import_enabled' => 'integer',
489  'default_sort_field_id' => 'text',
490  'default_sort_field_order' => 'text',
491  'description' => 'text',
492  'public_comments' => 'integer',
493  'view_own_records_perm' => 'integer',
494  'delete_by_owner' => 'integer',
495  'save_confirmation' => 'integer',
496  'table_order' => 'integer',
497  );
498  case 'il_dcl_tableview':
499  return array(
500  'id' => 'integer',
501  'table_id' => 'integer',
502  'title' => 'text',
503  'roles' => 'text',
504  'description' => 'text',
505  'tableview_order' => 'integer',
506  );
507  case 'il_dcl_field':
508  return array(
509  'id' => 'integer',
510  'table_id' => 'integer',
511  'title' => 'text',
512  'description' => 'text',
513  'datatype_id' => 'integer',
514  'required' => 'integer',
515  'is_unique' => 'integer',
516  'is_locked' => 'integer',
517  );
518  case 'il_dcl_tview_set':
519  return array(
520  'id' => 'integer',
521  'tableview_id' => 'integer',
522  'field' => 'text',
523  'visible' => 'integer',
524  'in_filter' => 'integer',
525  'filter_value' => 'text',
526  'filter_changeable' => 'integer',
527  );
528  case 'il_dcl_tfield_set':
529  return array(
530  'id' => 'integer',
531  'table_id' => 'integer',
532  'field' => 'text',
533  'field_order' => 'integer',
534  'exportable' => 'integer',
535  );
536  case 'il_dcl_field_prop':
537  return array(
538  'id' => 'integer',
539  'field_id' => 'integer',
540  'name' => 'text',
541  'value' => 'integer',
542  );
543  case 'il_dcl_record':
544  return array(
545  'id' => 'integer',
546  'table_id' => 'integer',
547  );
548  case 'il_dcl_record_field':
549  return array(
550  'id' => 'integer',
551  'record_id' => 'integer',
552  'field_id' => 'integer',
553  );
554  case 'il_dcl_stloc1_value':
555  return array(
556  'id' => 'integer',
557  'record_field_id' => 'integer',
558  'value' => 'text',
559  );
560  case 'il_dcl_stloc2_value':
561  return array(
562  'id' => 'integer',
563  'record_field_id' => 'integer',
564  'value' => 'text',
565  );
566  case 'il_dcl_stloc3_value':
567  return array(
568  'id' => 'integer',
569  'record_field_id' => 'integer',
570  'value' => 'text',
571  );
572  default:
573  return array();
574  }
575  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getXmlNamespace()

◆ readData()

ilDataCollectionDataSet::readData (   $a_entity,
  $a_version,
  $a_ids 
)

Read data from Cache for a given entity and ID(s)

Parameters
string$a_entity
string$a_version
array$a_idsone or multiple ids

Definition at line 684 of file class.ilDataCollectionDataSet.php.

References _readData(), array, and data.

684  {
685  $this->data = array();
686  if (!is_array($a_ids)) {
687  $a_ids = array( $a_ids );
688  }
689  $this->_readData($a_entity, $a_ids);
690  }
Add some data
_readData($a_entity, $a_ids)
Build data array, data is read from cache except dcl object itself.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Field Documentation

◆ $caches

ilDataCollectionDataSet::$caches
protected
Initial value:
'dcl' => array(),
'il_dcl_table' => array(),
'il_dcl_field' => array(),
'il_dcl_field_prop' => array(),
'il_dcl_record' => array(),
'il_dcl_record_field' => array(),
'il_dcl_stloc1_value' => array(),
'il_dcl_stloc2_value' => array(),
'il_dcl_stloc3_value' => array(),
'il_dcl_tfield_set' => array(),
'il_dcl_tableview' => array(),
'il_dcl_tview_set' => array(),
)

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

◆ $count_imported_tables

ilDataCollectionDataSet::$count_imported_tables = 0
protected

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

◆ $data

ilDataCollectionDataSet::$data = array()
protected

Definition at line 23 of file class.ilDataCollectionDataSet.php.

Referenced by _readData(), and buildCache().

◆ $db

ilDataCollectionDataSet::$db
protected

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

◆ $import_dc_object

ilDataCollectionDataSet::$import_dc_object
protected

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

◆ $import_record_field_cache

ilDataCollectionDataSet::$import_record_field_cache = array()
protected

Definition at line 76 of file class.ilDataCollectionDataSet.php.

◆ $import_temp_new_mob_ids

ilDataCollectionDataSet::$import_temp_new_mob_ids = array()
protected

Definition at line 92 of file class.ilDataCollectionDataSet.php.

◆ $import_temp_refs

ilDataCollectionDataSet::$import_temp_refs = array()
protected

Definition at line 84 of file class.ilDataCollectionDataSet.php.

◆ $import_temp_refs_props

ilDataCollectionDataSet::$import_temp_refs_props = array()
protected

Definition at line 88 of file class.ilDataCollectionDataSet.php.

◆ $record_field_ids_2_storage

ilDataCollectionDataSet::$record_field_ids_2_storage = array()
protected

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

◆ $user

ilDataCollectionDataSet::$user
protected

Definition at line 80 of file class.ilDataCollectionDataSet.php.


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