ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilDataCollectionDataSet Class Reference

DataCollection dataset class. More...

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

Public Member Functions

 __construct ()
 Constructor. More...
 
 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)
 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 ...> ... </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> 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 ( )

Constructor.

Reimplemented from ilDataSet.

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

94 {
95 global $ilDB, $ilUser;
96 parent::__construct();
97 $this->db = $ilDB;
98 $this->user = $ilUser;
99 }
global $ilDB
global $ilUser
Definition: imgupload.php:15

References $ilDB, and $ilUser.

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

619 {
620 switch ($a_entity) {
621 case 'dcl':
622 foreach ($a_ids as $dcl_id) {
623 if (ilObject::_lookupType($dcl_id) == 'dcl') {
624 $obj = new ilObjDataCollection($dcl_id, false);
625 $data = array(
626 'id' => $dcl_id,
627 'title' => $obj->getTitle(),
628 'description' => $obj->getDescription(),
629 'main_table_id' => $obj->getMainTableId(),
630 'is_online' => $obj->getOnline(),
631 'rating' => $obj->getRating(),
632 'public_notes' => $obj->getPublicNotes(),
633 'approval' => $obj->getApproval(),
634 'notification' => $obj->getNotification(),
635 );
636 $this->caches['dcl'][$dcl_id] = $data;
637 $this->data[] = $data;
638 }
639 }
640 break;
641 default:
642 $data = $this->getCache($a_entity);
643 foreach ($a_ids as $id) {
644 $this->data[] = $data[$id];
645 }
646 }
647 }
getCache($a_entity)
Get cached data from a given entity.
Class ilObjDataCollection.
static _lookupType($a_id, $a_reference=false)
lookup object type

References $data, and ilObject\_lookupType().

+ Here is the call 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 659 of file class.ilDataCollectionDataSet.php.

659 {
660 $fields = array_keys($this->getTypes($a_entity, ''));
661 $ids = array();
662 while ($rec = $this->db->fetchObject($set)) {
663 $data = array();
664 foreach ($fields as $field) {
665 $data[$field] = $rec->{$field};
666 }
667 // il_dcl_viewdefinition is the only table that has no internal id, so we build primary from view_id AND field columns
668 $id = ($a_entity == 'il_dcl_viewdefinition') ? $rec->view_id . '_' . $rec->field : $rec->id;
669 $this->caches[$a_entity][$id] = $data;
670 $ids[] = $id;
671 }
672
673 return $ids;
674 }
getTypes($a_entity, $a_version)
Map XML attributes of entities to datatypes (text, integer...)

References $data.

Referenced by getDependencies().

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

118 {
119 if (!in_array($a_entity, array_keys($this->caches))) {
120 throw new ilException("Entity '$a_entity' does not exist in Cache");
121 }
122
123 return $this->caches[$a_entity];
124 }
Base class for ILIAS Exception handling.

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

511 {
512 if (!$a_rec && !$a_ids) {
513 return false;
514 }
515 switch ($a_entity) {
516 case 'dcl':
517 $set = $this->db->query('SELECT * FROM il_dcl_table WHERE obj_id = ' . $this->db->quote($a_rec['id'], 'integer') . ' ORDER BY id');
518 $ids = $this->buildCache('il_dcl_table', $set);
519
520 return array(
521 'il_dcl_table' => array( 'ids' => $ids ),
522 );
523 break;
524 case 'il_dcl_table':
525 $set = $this->db->query('SELECT * FROM il_dcl_record WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
526 $ids_records = $this->buildCache('il_dcl_record', $set);
527 $set = $this->db->query('SELECT * FROM il_dcl_field WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
528 $ids_fields = $this->buildCache('il_dcl_field', $set);
529 $set = $this->db->query('SELECT * FROM il_dcl_view WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
530 $ids_views = $this->buildCache('il_dcl_view', $set);
531
532 return array(
533 'il_dcl_field' => array( 'ids' => $ids_fields ),
534 'il_dcl_record' => array( 'ids' => $ids_records ),
535 'il_dcl_view' => array( 'ids' => $ids_views ),
536 );
537 case 'il_dcl_field':
538 $set = $this->db->query('SELECT * FROM il_dcl_field_prop WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
539 $ids = $this->buildCache('il_dcl_field_prop', $set);
540
541 return array(
542 'il_dcl_field_prop' => array( 'ids' => $ids ),
543 );
544 case 'il_dcl_record':
545 $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)'
546 . ' INNER JOIN il_dcl_datatype AS d ON (f.datatype_id = d.id) ' . ' WHERE rf.record_id = '
547 . $this->db->quote($a_rec['id'], 'integer');
548 $set = $this->db->query($sql);
549 $ids = $this->buildCache('il_dcl_record_field', $set);
550
551 $set = $this->db->query($sql);
552 while ($rec = $this->db->fetchObject($set)) {
553 $this->record_field_ids_2_storage[$rec->id] = $rec->storage_location;
554 }
555 // Also build a cache of all values, no matter in which table they are (il_dcl_stloc(1|2|3)_value)
556 $sql =
557 '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 '
558 . 'LEFT JOIN il_dcl_stloc1_value AS st1 ON (st1.record_field_id = rf.id) '
559 . 'LEFT JOIN il_dcl_stloc2_value AS st2 ON (st2.record_field_id = rf.id) '
560 . 'LEFT JOIN il_dcl_stloc3_value AS st3 ON (st3.record_field_id = rf.id) ' . 'WHERE rf.record_id = '
561 . $this->db->quote($a_rec['id'], 'integer');
562 $set = $this->db->query($sql);
563
564 while ($rec = $this->db->fetchObject($set)) {
565 $stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
566 $value = "value{$stloc}";
567 // Save reocrd field id. Internal ID is not used currently
568 $this->caches["il_dcl_stloc{$stloc}_value"][$rec->record_field_id] = array(
569 'record_field_id' => $rec->record_field_id,
570 'value' => $rec->{$value}
571 );
572 }
573
574 return array(
575 'il_dcl_record_field' => array( 'ids' => $ids )
576 );
577 case 'il_dcl_view':
578 $set = $this->db->query('SELECT * FROM il_dcl_viewdefinition WHERE view_id = ' . $this->db->quote($a_rec['id'], 'integer'));
579 $ids = $this->buildCache('il_dcl_viewdefinition', $set);
580
581 return array(
582 'il_dcl_viewdefinition' => array( 'ids' => $ids )
583 );
584 case 'il_dcl_record_field':
585 $record_field_id = $a_rec['id'];
586 $storage_loc = $this->record_field_ids_2_storage[$record_field_id];
587
588 return array(
589 "il_dcl_stloc{$storage_loc}_value" => array( 'ids' => array( $record_field_id ) )
590 );
591 }
592
593 return false;
594 }
buildCache($a_entity, $set)
Helper method to build cache for data of all entities.

References buildCache().

+ Here is the call graph for this function:

◆ getSupportedVersions()

ilDataCollectionDataSet::getSupportedVersions ( )
Returns
array

Reimplemented from ilDataSet.

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

105 {
106 return array( '4.5.0' );
107 }

◆ 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

Reimplemented from ilDataSet.

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

400 {
401 switch ($a_entity) {
402 case 'dcl':
403 return array(
404 "id" => "integer",
405 "title" => "text",
406 "description" => "text",
407 'main_table_id' => 'integer',
408 'is_online' => 'integer',
409 'rating' => 'integer',
410 'public_notes' => 'integer',
411 'approval' => 'integer',
412 'notification' => 'integer',
413 );
414 case 'il_dcl_table':
415 return array(
416 'id' => 'integer',
417 'obj_id' => 'integer',
418 'title' => 'text',
419 'add_perm' => 'integer',
420 'edit_perm' => 'integer',
421 'delete_perm' => 'integer',
422 'edit_by_owner' => 'integer',
423 'limited' => 'integer',
424 'limit_start' => 'text',
425 'limit_end' => 'text',
426 'is_visible' => 'integer',
427 'export_enabled' => 'integer',
428 'default_sort_field_id' => 'text',
429 'default_sort_field_order' => 'text',
430 'description' => 'text',
431 'public_comments' => 'integer',
432 'view_own_records_perm' => 'integer',
433 );
434 case 'il_dcl_field':
435 return array(
436 'id' => 'integer',
437 'table_id' => 'integer',
438 'title' => 'text',
439 'description' => 'text',
440 'datatype_id' => 'integer',
441 'required' => 'integer',
442 'is_unique' => 'integer',
443 'is_locked' => 'integer',
444 );
445 case 'il_dcl_field_prop':
446 return array(
447 'id' => 'integer',
448 'field_id' => 'integer',
449 'datatype_prop_id' => 'integer',
450 'value' => 'integer',
451 );
452 case 'il_dcl_record':
453 return array(
454 'id' => 'integer',
455 'table_id' => 'integer',
456 );
457 case 'il_dcl_record_field':
458 return array(
459 'id' => 'integer',
460 'record_id' => 'integer',
461 'field_id' => 'integer',
462 );
463 case 'il_dcl_stloc1_value':
464 return array(
465 'id' => 'integer',
466 'record_field_id' => 'integer',
467 'value' => 'text',
468 );
469 case 'il_dcl_stloc2_value':
470 return array(
471 'id' => 'integer',
472 'record_field_id' => 'integer',
473 'value' => 'text',
474 );
475 case 'il_dcl_stloc3_value':
476 return array(
477 'id' => 'integer',
478 'record_field_id' => 'integer',
479 'value' => 'text',
480 );
481 case 'il_dcl_view':
482 return array(
483 'id' => 'integer',
484 'table_id' => 'integer',
485 'type' => 'integer',
486 'formtype' => 'integer',
487 );
488 case 'il_dcl_viewdefinition':
489 return array(
490 'view_id' => 'integer',
491 'field' => 'string',
492 'field_order' => 'integer',
493 'is_set' => 'integer',
494 );
495 default:
496 return array();
497 }
498 }

◆ getXmlNamespace()

ilDataCollectionDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)
Parameters
string$a_entity
string$a_schema_version
Returns
string

Reimplemented from ilDataSet.

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

133 {
134 return 'http://www.ilias.de/xml/Modules/DataCollection/' . $a_entity;
135 }

◆ 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

Reimplemented from ilDataSet.

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

604 {
605 $this->data = array();
606 if (!is_array($a_ids)) {
607 $a_ids = array( $a_ids );
608 }
609 $this->_readData($a_entity, $a_ids);
610 }
_readData($a_entity, $a_ids)
Build data array, data is read from cache except dcl object itself.

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_record' => array(),
'il_dcl_record_field' => array(),
'il_dcl_stloc1_value' => array(),
'il_dcl_stloc2_value' => array(),
'il_dcl_stloc3_value' => array(),
'il_dcl_view' => array(),
'il_dcl_viewdefinition' => array(),
)

Definition at line 49 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 23 of file class.ilDataCollectionDataSet.php.

◆ $db

ilDataCollectionDataSet::$db
protected

Definition at line 19 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 29 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: