ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 stripTags (array $rec, array $omit_keys=[])
 

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
 
 $ds_namespace = 'ds'
 

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, ILIAS\GlobalScreen\Provider\__construct(), and user().

95  {
96  global $DIC;
97  $ilDB = $DIC['ilDB'];
98  $ilUser = $DIC['ilUser'];
100  $this->db = $ilDB;
101  $this->user = $ilUser;
102  }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
global $ilDB
$ilUser
Definition: imgupload.php:18
+ 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 745 of file class.ilDataCollectionDataSet.php.

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

Referenced by readData().

746  {
747  switch ($a_entity) {
748  case 'dcl':
749  foreach ($a_ids as $dcl_id) {
750  if (ilObject::_lookupType($dcl_id) == 'dcl') {
751  $obj = new ilObjDataCollection($dcl_id, false);
752  $data = array(
753  'id' => $dcl_id,
754  'title' => $obj->getTitle(),
755  'description' => $obj->getDescription(),
756  'is_online' => $obj->getOnline(),
757  'rating' => $obj->getRating(),
758  'public_notes' => $obj->getPublicNotes(),
759  'approval' => $obj->getApproval(),
760  'notification' => $obj->getNotification(),
761  );
762  $this->caches['dcl'][$dcl_id] = $data;
763  $this->data[] = $data;
764  }
765  }
766  break;
767  default:
768  $data = $this->getCache($a_entity);
769  foreach ($a_ids as $id) {
770  $this->data[] = $data[$id];
771  }
772  }
773  }
getCache($a_entity)
Get cached data from a given entity.
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
Returns
array of newly added IDs

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

References $data, and getTypes().

Referenced by getDependencies().

786  {
787  $fields = array_keys($this->getTypes($a_entity, ''));
788  $ids = array();
789  while ($rec = $this->db->fetchObject($set)) {
790  $data = array();
791  foreach ($fields as $field) {
792  $data[$field] = $rec->{$field};
793  }
794  $id = $rec->id;
795  $this->caches[$a_entity][$id] = $data;
796  $ids[] = $id;
797  }
798 
799  return $ids;
800  }
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 628 of file class.ilDataCollectionDataSet.php.

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

629  {
630  if (!$a_rec && !$a_ids) {
631  return false;
632  }
633  switch ($a_entity) {
634  case 'dcl':
635  $set = $this->db->query('SELECT * FROM il_dcl_table WHERE obj_id = ' . $this->db->quote($a_rec['id'], 'integer') . ' ORDER BY id');
636  $ids = $this->buildCache('il_dcl_table', $set);
637 
638  return array(
639  'il_dcl_table' => array('ids' => $ids),
640  );
641  break;
642  case 'il_dcl_table':
643  $set = $this->db->query('SELECT * FROM il_dcl_record WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
644  $ids_records = $this->buildCache('il_dcl_record', $set);
645  $set = $this->db->query('SELECT * FROM il_dcl_field WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
646  $ids_fields = $this->buildCache('il_dcl_field', $set);
647  $set = $this->db->query('SELECT * FROM il_dcl_tableview WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
648  $ids_tableviews = $this->buildCache('il_dcl_tableview', $set);
649  $set = $this->db->query('SELECT * FROM il_dcl_tfield_set WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
650  $ids_tablefield_settings = $this->buildCache('il_dcl_tfield_set', $set);
651 
652  return array(
653  'il_dcl_field' => array('ids' => $ids_fields),
654  'il_dcl_record' => array('ids' => $ids_records),
655  'il_dcl_tableview' => array('ids' => $ids_tableviews),
656  'il_dcl_tfield_set' => array('ids' => $ids_tablefield_settings),
657  );
658  case 'il_dcl_field':
659  $set = $this->db->query('SELECT * FROM il_dcl_field_prop WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
660  $prop_ids = $this->buildCache('il_dcl_field_prop', $set);
661 
662  $set = $this->db->query('SELECT * FROM il_dcl_sel_opts WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
663  $opt_ids = $this->buildCache('il_dcl_sel_opts', $set);
664 
665  return array(
666  'il_dcl_field_prop' => array('ids' => $prop_ids),
667  'il_dcl_sel_opts' => array('ids' => $opt_ids),
668  );
669  case 'il_dcl_record':
670  $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)'
671  . ' INNER JOIN il_dcl_datatype AS d ON (f.datatype_id = d.id) ' . ' WHERE rf.record_id = '
672  . $this->db->quote($a_rec['id'], 'integer');
673  $set = $this->db->query($sql);
674  $ids = $this->buildCache('il_dcl_record_field', $set);
675 
676  $set = $this->db->query($sql);
677  while ($rec = $this->db->fetchObject($set)) {
678  $this->record_field_ids_2_storage[$rec->id] = ilDclCache::getFieldCache($rec->field_id)->getStorageLocation();
679  }
680  // Also build a cache of all values, no matter in which table they are (il_dcl_stloc(1|2|3)_value)
681  $sql
682  = '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 '
683  . 'LEFT JOIN il_dcl_stloc1_value AS st1 ON (st1.record_field_id = rf.id) '
684  . 'LEFT JOIN il_dcl_stloc2_value AS st2 ON (st2.record_field_id = rf.id) '
685  . 'LEFT JOIN il_dcl_stloc3_value AS st3 ON (st3.record_field_id = rf.id) ' . 'WHERE rf.record_id = '
686  . $this->db->quote($a_rec['id'], 'integer');
687  $set = $this->db->query($sql);
688 
689  while ($rec = $this->db->fetchObject($set)) {
690  $stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
691  $value = "value{$stloc}";
692  // Save reocrd field id. Internal ID is not used currently
693  $this->caches["il_dcl_stloc{$stloc}_value"][$rec->record_field_id] = array(
694  'record_field_id' => $rec->record_field_id,
695  'value' => $rec->{$value},
696  );
697  }
698 
699  return array(
700  'il_dcl_record_field' => array('ids' => $ids),
701  );
702  case 'il_dcl_tableview':
703  $set = $this->db->query('SELECT * FROM il_dcl_tview_set WHERE tableview_id = ' . $this->db->quote($a_rec['id'], 'integer'));
704  $ids = $this->buildCache('il_dcl_tview_set', $set);
705 
706  return array(
707  'il_dcl_tview_set' => array('ids' => $ids),
708  );
709  case 'il_dcl_record_field':
710  $record_field_id = $a_rec['id'];
711  $storage_loc = $this->record_field_ids_2_storage[$record_field_id];
712 
713  return array(
714  "il_dcl_stloc{$storage_loc}_value" => array('ids' => array($record_field_id)),
715  );
716  }
717 
718  return false;
719  }
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 482 of file class.ilDataCollectionDataSet.php.

Referenced by buildCache().

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

References _readData().

730  {
731  $this->data = array();
732  if (!is_array($a_ids)) {
733  $a_ids = array($a_ids);
734  }
735  $this->_readData($a_entity, $a_ids);
736  }
_readData($a_entity, $a_ids)
Build data array, data is read from cache except dcl object itself.
+ 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: