ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 = ""
 
 $db
 
 $ds_log
 

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 10 of file class.ilDataCollectionDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilDataCollectionDataSet::__construct ( )

Definition at line 94 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  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
$ilUser
Definition: imgupload.php:18
global $ilDB
+ 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 725 of file class.ilDataCollectionDataSet.php.

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

Referenced by readData().

726  {
727  switch ($a_entity) {
728  case 'dcl':
729  foreach ($a_ids as $dcl_id) {
730  if (ilObject::_lookupType($dcl_id) == 'dcl') {
731  $obj = new ilObjDataCollection($dcl_id, false);
732  $data = array(
733  'id' => $dcl_id,
734  'title' => $obj->getTitle(),
735  'description' => $obj->getDescription(),
736  'is_online' => $obj->getOnline(),
737  'rating' => $obj->getRating(),
738  'public_notes' => $obj->getPublicNotes(),
739  'approval' => $obj->getApproval(),
740  'notification' => $obj->getNotification(),
741  );
742  $this->caches['dcl'][$dcl_id] = $data;
743  $this->data[] = $data;
744  }
745  }
746  break;
747  default:
748  $data = $this->getCache($a_entity);
749  foreach ($a_ids as $id) {
750  $this->data[] = $data[$id];
751  }
752  }
753  }
if(!array_key_exists('StateId', $_REQUEST)) $id
getCache($a_entity)
Get cached data from a given entity.
static _lookupType($a_id, $a_reference=false)
lookup object type
$this data['403_header']
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 765 of file class.ilDataCollectionDataSet.php.

References $data, $id, and getTypes().

Referenced by getDependencies().

766  {
767  $fields = array_keys($this->getTypes($a_entity, ''));
768  $ids = array();
769  while ($rec = $this->db->fetchObject($set)) {
770  $data = array();
771  foreach ($fields as $field) {
772  $data[$field] = $rec->{$field};
773  }
774  $id = $rec->id;
775  $this->caches[$a_entity][$id] = $data;
776  $ids[] = $id;
777  }
778 
779  return $ids;
780  }
if(!array_key_exists('StateId', $_REQUEST)) $id
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 122 of file class.ilDataCollectionDataSet.php.

Referenced by _readData().

123  {
124  if (!in_array($a_entity, array_keys($this->caches))) {
125  throw new ilException("Entity '$a_entity' does not exist in Cache");
126  }
127 
128  return $this->caches[$a_entity];
129  }
+ 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 608 of file class.ilDataCollectionDataSet.php.

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

609  {
610  if (!$a_rec && !$a_ids) {
611  return false;
612  }
613  switch ($a_entity) {
614  case 'dcl':
615  $set = $this->db->query('SELECT * FROM il_dcl_table WHERE obj_id = ' . $this->db->quote($a_rec['id'], 'integer') . ' ORDER BY id');
616  $ids = $this->buildCache('il_dcl_table', $set);
617 
618  return array(
619  'il_dcl_table' => array('ids' => $ids),
620  );
621  break;
622  case 'il_dcl_table':
623  $set = $this->db->query('SELECT * FROM il_dcl_record WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
624  $ids_records = $this->buildCache('il_dcl_record', $set);
625  $set = $this->db->query('SELECT * FROM il_dcl_field WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
626  $ids_fields = $this->buildCache('il_dcl_field', $set);
627  $set = $this->db->query('SELECT * FROM il_dcl_tableview WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
628  $ids_tableviews = $this->buildCache('il_dcl_tableview', $set);
629  $set = $this->db->query('SELECT * FROM il_dcl_tfield_set WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
630  $ids_tablefield_settings = $this->buildCache('il_dcl_tfield_set', $set);
631 
632  return array(
633  'il_dcl_field' => array('ids' => $ids_fields),
634  'il_dcl_record' => array('ids' => $ids_records),
635  'il_dcl_tableview' => array('ids' => $ids_tableviews),
636  'il_dcl_tfield_set' => array('ids' => $ids_tablefield_settings),
637  );
638  case 'il_dcl_field':
639  $set = $this->db->query('SELECT * FROM il_dcl_field_prop WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
640  $prop_ids = $this->buildCache('il_dcl_field_prop', $set);
641 
642  $set = $this->db->query('SELECT * FROM il_dcl_sel_opts WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
643  $opt_ids = $this->buildCache('il_dcl_sel_opts', $set);
644 
645  return array(
646  'il_dcl_field_prop' => array('ids' => $prop_ids),
647  'il_dcl_sel_opts' => array('ids' => $opt_ids),
648  );
649  case 'il_dcl_record':
650  $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)'
651  . ' INNER JOIN il_dcl_datatype AS d ON (f.datatype_id = d.id) ' . ' WHERE rf.record_id = '
652  . $this->db->quote($a_rec['id'], 'integer');
653  $set = $this->db->query($sql);
654  $ids = $this->buildCache('il_dcl_record_field', $set);
655 
656  $set = $this->db->query($sql);
657  while ($rec = $this->db->fetchObject($set)) {
658  $this->record_field_ids_2_storage[$rec->id] = ilDclCache::getFieldCache($rec->field_id)->getStorageLocation();
659  }
660  // Also build a cache of all values, no matter in which table they are (il_dcl_stloc(1|2|3)_value)
661  $sql
662  = '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 '
663  . 'LEFT JOIN il_dcl_stloc1_value AS st1 ON (st1.record_field_id = rf.id) '
664  . 'LEFT JOIN il_dcl_stloc2_value AS st2 ON (st2.record_field_id = rf.id) '
665  . 'LEFT JOIN il_dcl_stloc3_value AS st3 ON (st3.record_field_id = rf.id) ' . 'WHERE rf.record_id = '
666  . $this->db->quote($a_rec['id'], 'integer');
667  $set = $this->db->query($sql);
668 
669  while ($rec = $this->db->fetchObject($set)) {
670  $stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
671  $value = "value{$stloc}";
672  // Save reocrd field id. Internal ID is not used currently
673  $this->caches["il_dcl_stloc{$stloc}_value"][$rec->record_field_id] = array(
674  'record_field_id' => $rec->record_field_id,
675  'value' => $rec->{$value},
676  );
677  }
678 
679  return array(
680  'il_dcl_record_field' => array('ids' => $ids),
681  );
682  case 'il_dcl_tableview':
683  $set = $this->db->query('SELECT * FROM il_dcl_tview_set WHERE tableview_id = ' . $this->db->quote($a_rec['id'], 'integer'));
684  $ids = $this->buildCache('il_dcl_tview_set', $set);
685 
686  return array(
687  'il_dcl_tview_set' => array('ids' => $ids),
688  );
689  case 'il_dcl_record_field':
690  $record_field_id = $a_rec['id'];
691  $storage_loc = $this->record_field_ids_2_storage[$record_field_id];
692 
693  return array(
694  "il_dcl_stloc{$storage_loc}_value" => array('ids' => array($record_field_id)),
695  );
696  }
697 
698  return false;
699  }
static getFieldCache($field_id=0)
buildCache($a_entity, $set)
Helper method to build cache for data of all entities.
+ Here is the call graph for this function:

◆ getSupportedVersions()

ilDataCollectionDataSet::getSupportedVersions ( )
Returns
array

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

109  {
110  return array('4.5.0');
111  }

◆ 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 472 of file class.ilDataCollectionDataSet.php.

Referenced by buildCache().

473  {
474  switch ($a_entity) {
475  case 'dcl':
476  return array(
477  "id" => "integer",
478  "title" => "text",
479  "description" => "text",
480  'is_online' => 'integer',
481  'rating' => 'integer',
482  'public_notes' => 'integer',
483  'approval' => 'integer',
484  'notification' => 'integer',
485  );
486  case 'il_dcl_table':
487  return array(
488  'id' => 'integer',
489  'obj_id' => 'integer',
490  'title' => 'text',
491  'add_perm' => 'integer',
492  'edit_perm' => 'integer',
493  'delete_perm' => 'integer',
494  'edit_by_owner' => 'integer',
495  'limited' => 'integer',
496  'limit_start' => 'text',
497  'limit_end' => 'text',
498  'is_visible' => 'integer',
499  'export_enabled' => 'integer',
500  'import_enabled' => 'integer',
501  'default_sort_field_id' => 'text',
502  'default_sort_field_order' => 'text',
503  'description' => 'text',
504  'public_comments' => 'integer',
505  'view_own_records_perm' => 'integer',
506  'delete_by_owner' => 'integer',
507  'save_confirmation' => 'integer',
508  'table_order' => 'integer',
509  );
510  case 'il_dcl_tableview':
511  return array(
512  'id' => 'integer',
513  'table_id' => 'integer',
514  'title' => 'text',
515  'roles' => 'text',
516  'description' => 'text',
517  'tableview_order' => 'integer',
518  );
519  case 'il_dcl_field':
520  return array(
521  'id' => 'integer',
522  'table_id' => 'integer',
523  'title' => 'text',
524  'description' => 'text',
525  'datatype_id' => 'integer',
526  'required' => 'integer',
527  'is_unique' => 'integer',
528  'is_locked' => 'integer',
529  );
530  case 'il_dcl_tview_set':
531  return array(
532  'id' => 'integer',
533  'tableview_id' => 'integer',
534  'field' => 'text',
535  'visible' => 'integer',
536  'in_filter' => 'integer',
537  'filter_value' => 'text',
538  'filter_changeable' => 'integer',
539  );
540  case 'il_dcl_tfield_set':
541  return array(
542  'id' => 'integer',
543  'table_id' => 'integer',
544  'field' => 'text',
545  'field_order' => 'integer',
546  'exportable' => 'integer',
547  );
548  case 'il_dcl_field_prop':
549  return array(
550  'id' => 'integer',
551  'field_id' => 'integer',
552  'name' => 'text',
553  'value' => 'integer',
554  );
555  case 'il_dcl_sel_opts':
556  return array(
557  'id' => 'integer',
558  'field_id' => 'integer',
559  'opt_id' => 'integer',
560  'sorting' => 'integer',
561  'value' => 'text',
562  );
563  case 'il_dcl_record':
564  return array(
565  'id' => 'integer',
566  'table_id' => 'integer',
567  );
568  case 'il_dcl_record_field':
569  return array(
570  'id' => 'integer',
571  'record_id' => 'integer',
572  'field_id' => 'integer',
573  );
574  case 'il_dcl_stloc1_value':
575  return array(
576  'id' => 'integer',
577  'record_field_id' => 'integer',
578  'value' => 'text',
579  );
580  case 'il_dcl_stloc2_value':
581  return array(
582  'id' => 'integer',
583  'record_field_id' => 'integer',
584  'value' => 'text',
585  );
586  case 'il_dcl_stloc3_value':
587  return array(
588  'id' => 'integer',
589  'record_field_id' => 'integer',
590  'value' => 'text',
591  );
592  default:
593  return array();
594  }
595  }
+ 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 709 of file class.ilDataCollectionDataSet.php.

References _readData(), and data.

710  {
711  $this->data = array();
712  if (!is_array($a_ids)) {
713  $a_ids = array($a_ids);
714  }
715  $this->_readData($a_entity, $a_ids);
716  }
_readData($a_entity, $a_ids)
Build data array, data is read from cache except dcl object itself.
$this data['403_header']
+ Here is the call graph for this function:

Field Documentation

◆ $caches

ilDataCollectionDataSet::$caches
protected
Initial value:
= array(
'dcl' => array(),
'il_dcl_table' => array(),
'il_dcl_field' => array(),
'il_dcl_field_prop' => array(),
'il_dcl_sel_opts' => 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 47 of file class.ilDataCollectionDataSet.php.

◆ $count_imported_tables

ilDataCollectionDataSet::$count_imported_tables = 0
protected

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

◆ $data

ilDataCollectionDataSet::$data = array()
protected

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

Referenced by _readData(), and buildCache().

◆ $db

ilDataCollectionDataSet::$db
protected

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

◆ $import_dc_object

ilDataCollectionDataSet::$import_dc_object
protected

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

◆ $import_record_field_cache

ilDataCollectionDataSet::$import_record_field_cache = array()
protected

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

◆ $import_temp_new_mob_ids

ilDataCollectionDataSet::$import_temp_new_mob_ids = array()
protected

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

◆ $import_temp_refs

ilDataCollectionDataSet::$import_temp_refs = array()
protected

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

◆ $import_temp_refs_props

ilDataCollectionDataSet::$import_temp_refs_props = array()
protected

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

◆ $record_field_ids_2_storage

ilDataCollectionDataSet::$record_field_ids_2_storage = array()
protected

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

◆ $user

ilDataCollectionDataSet::$user
protected

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


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