ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 11 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 732 of file class.ilDataCollectionDataSet.php.

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

Referenced by readData().

733  {
734  switch ($a_entity) {
735  case 'dcl':
736  foreach ($a_ids as $dcl_id) {
737  if (ilObject::_lookupType($dcl_id) == 'dcl') {
738  $obj = new ilObjDataCollection($dcl_id, false);
739  $data = array(
740  'id' => $dcl_id,
741  'title' => $obj->getTitle(),
742  'description' => $obj->getDescription(),
743  'is_online' => $obj->getOnline(),
744  'rating' => $obj->getRating(),
745  'public_notes' => $obj->getPublicNotes(),
746  'approval' => $obj->getApproval(),
747  'notification' => $obj->getNotification(),
748  );
749  $this->caches['dcl'][$dcl_id] = $data;
750  $this->data[] = $data;
751  }
752  }
753  break;
754  default:
755  $data = $this->getCache($a_entity);
756  foreach ($a_ids as $id) {
757  $this->data[] = $data[$id];
758  }
759  }
760  }
Add some data
if(!array_key_exists('StateId', $_REQUEST)) $id
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 772 of file class.ilDataCollectionDataSet.php.

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

Referenced by getDependencies().

773  {
774  $fields = array_keys($this->getTypes($a_entity, ''));
775  $ids = array();
776  while ($rec = $this->db->fetchObject($set)) {
777  $data = array();
778  foreach ($fields as $field) {
779  $data[$field] = $rec->{$field};
780  }
781  $id = $rec->id;
782  $this->caches[$a_entity][$id] = $data;
783  $ids[] = $id;
784  }
785 
786  return $ids;
787  }
if(!array_key_exists('StateId', $_REQUEST)) $id
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 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 615 of file class.ilDataCollectionDataSet.php.

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

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

109  {
110  return array( '4.5.0' );
111  }
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 479 of file class.ilDataCollectionDataSet.php.

References array.

Referenced by buildCache().

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

References _readData(), array, and data.

717  {
718  $this->data = array();
719  if (!is_array($a_ids)) {
720  $a_ids = array( $a_ids );
721  }
722  $this->_readData($a_entity, $a_ids);
723  }
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_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 21 of file class.ilDataCollectionDataSet.php.

Referenced by _readData(), and buildCache().

◆ $db

ilDataCollectionDataSet::$db
protected

Definition at line 17 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 27 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: