ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDataCollectionDataSet Class Reference

DataCollection dataset class. More...

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

Public Member Functions

 __construct ()
 Constructor.
 getSupportedVersions ()
 getCache ($a_entity)
 Get cached data from a given entity.
 getXmlNamespace ($a_entity, $a_schema_version)
 readData ($a_entity, $a_version, $a_ids)
 Read data from Cache for a given entity and ID(s)
- Public Member Functions inherited from ilDataSet
 init ($a_entity, $a_schema_version)
 Init.
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories.
 setImportDirectory ($a_val)
 Set import directory.
 getImportDirectory ()
 Get import directory.
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix.
 getDSPrefix ()
 Get XML dataset namespace prefix.
 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.
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string.
 getJsonRepresentation ()
 Get json representation.
 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 ...> ...
 addRecordsXml ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml.
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record.
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces.
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version.
 getJsonRecord ($a_set)
 Get json record for version.
 getXmlTypes ($a_entity, $a_version)
 Get xml types.
 getJsonTypes ($a_entity, $a_version)
 Get json types.
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten)
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag.
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten)
 setImport ($a_val)
 Set import object.
 getImport ()
 Get import object.

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Map XML attributes of entities to datatypes (text, integer...)
 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)
 _readData ($a_entity, $a_ids)
 Build data array, data is read from cache except dcl object itself.
 buildCache ($a_entity, $set)
 Helper method to build cache for data of all entities.
- Protected Member Functions inherited from ilDataSet
 createObjectExportId ($a_type, $a_id)
 Build ilias export id.
 parseObjectExportId ($a_id, $a_fallback_id=NULL)
 Parse export id.

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()

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

ilDataCollectionDataSet::__construct ( )

Constructor.

Reimplemented from ilDataSet.

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

References $ilDB, and $ilUser.

{
global $ilDB, $ilUser;
$this->db = $ilDB;
$this->user = $ilUser;
}

Member Function Documentation

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.

References ilObject\_lookupType().

{
switch ($a_entity) {
case 'dcl':
foreach ($a_ids as $dcl_id) {
if (ilObject::_lookupType($dcl_id) == 'dcl') {
$obj = new ilObjDataCollection($dcl_id, false);
$data = array(
'id' => $dcl_id,
'title' => $obj->getTitle(),
'description' => $obj->getDescription(),
'main_table_id' => $obj->getMainTableId(),
'is_online' => $obj->getOnline(),
'rating' => $obj->getRating(),
'public_notes' => $obj->getPublicNotes(),
'approval' => $obj->getApproval(),
'notification' => $obj->getNotification(),
);
$this->caches['dcl'][$dcl_id] = $data;
$this->data[] = $data;
}
}
break;
default:
$data = $this->getCache($a_entity);
foreach ($a_ids as $id) {
$this->data[] = $data[$id];
}
}
}

+ Here is the call graph for this function:

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.

Referenced by getDependencies().

{
$fields = array_keys($this->getTypes($a_entity, ''));
$ids = array();
while ($rec = $this->db->fetchObject($set)) {
$data = array();
foreach ($fields as $field) {
$data[$field] = $rec->{$field};
}
// il_dcl_viewdefinition is the only table that has no internal id, so we build primary from view_id AND field columns
$id = ($a_entity == 'il_dcl_viewdefinition') ? $rec->view_id . '_' . $rec->field : $rec->id;
$this->caches[$a_entity][$id] = $data;
$ids[] = $id;
}
return $ids;
}

+ Here is the caller graph for this function:

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.

{
if (!in_array($a_entity, array_keys($this->caches))) {
throw new ilException("Entity '$a_entity' does not exist in Cache");
}
return $this->caches[$a_entity];
}
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.

References buildCache().

{
if (!$a_rec && !$a_ids) {
return false;
}
switch ($a_entity) {
case 'dcl':
$set = $this->db->query('SELECT * FROM il_dcl_table WHERE obj_id = ' . $this->db->quote($a_rec['id'], 'integer') . ' ORDER BY id');
$ids = $this->buildCache('il_dcl_table', $set);
return array(
'il_dcl_table' => array( 'ids' => $ids ),
);
break;
case 'il_dcl_table':
$set = $this->db->query('SELECT * FROM il_dcl_record WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids_records = $this->buildCache('il_dcl_record', $set);
$set = $this->db->query('SELECT * FROM il_dcl_field WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids_fields = $this->buildCache('il_dcl_field', $set);
$set = $this->db->query('SELECT * FROM il_dcl_view WHERE table_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids_views = $this->buildCache('il_dcl_view', $set);
return array(
'il_dcl_field' => array( 'ids' => $ids_fields ),
'il_dcl_record' => array( 'ids' => $ids_records ),
'il_dcl_view' => array( 'ids' => $ids_views ),
);
case 'il_dcl_field':
$set = $this->db->query('SELECT * FROM il_dcl_field_prop WHERE field_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids = $this->buildCache('il_dcl_field_prop', $set);
return array(
'il_dcl_field_prop' => array( 'ids' => $ids ),
);
case 'il_dcl_record':
$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)'
. ' INNER JOIN il_dcl_datatype AS d ON (f.datatype_id = d.id) ' . ' WHERE rf.record_id = '
. $this->db->quote($a_rec['id'], 'integer');
$set = $this->db->query($sql);
$ids = $this->buildCache('il_dcl_record_field', $set);
$set = $this->db->query($sql);
while ($rec = $this->db->fetchObject($set)) {
$this->record_field_ids_2_storage[$rec->id] = $rec->storage_location;
}
// Also build a cache of all values, no matter in which table they are (il_dcl_stloc(1|2|3)_value)
$sql =
'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 '
. 'LEFT JOIN il_dcl_stloc1_value AS st1 ON (st1.record_field_id = rf.id) '
. 'LEFT JOIN il_dcl_stloc2_value AS st2 ON (st2.record_field_id = rf.id) '
. 'LEFT JOIN il_dcl_stloc3_value AS st3 ON (st3.record_field_id = rf.id) ' . 'WHERE rf.record_id = '
. $this->db->quote($a_rec['id'], 'integer');
$set = $this->db->query($sql);
while ($rec = $this->db->fetchObject($set)) {
$stloc = $this->record_field_ids_2_storage[$rec->record_field_id];
$value = "value{$stloc}";
// Save reocrd field id. Internal ID is not used currently
$this->caches["il_dcl_stloc{$stloc}_value"][$rec->record_field_id] = array(
'record_field_id' => $rec->record_field_id,
'value' => $rec->{$value}
);
}
return array(
'il_dcl_record_field' => array( 'ids' => $ids )
);
case 'il_dcl_view':
$set = $this->db->query('SELECT * FROM il_dcl_viewdefinition WHERE view_id = ' . $this->db->quote($a_rec['id'], 'integer'));
$ids = $this->buildCache('il_dcl_viewdefinition', $set);
return array(
'il_dcl_viewdefinition' => array( 'ids' => $ids )
);
case 'il_dcl_record_field':
$record_field_id = $a_rec['id'];
$storage_loc = $this->record_field_ids_2_storage[$record_field_id];
return array(
"il_dcl_stloc{$storage_loc}_value" => array( 'ids' => array( $record_field_id ) )
);
}
return false;
}

+ Here is the call graph for this function:

ilDataCollectionDataSet::getSupportedVersions ( )
Returns
array

Reimplemented from ilDataSet.

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

{
return array( '4.5.0' );
}
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.

{
switch ($a_entity) {
case 'dcl':
return array(
"id" => "integer",
"title" => "text",
"description" => "text",
'main_table_id' => 'integer',
'is_online' => 'integer',
'rating' => 'integer',
'public_notes' => 'integer',
'approval' => 'integer',
'notification' => 'integer',
);
case 'il_dcl_table':
return array(
'id' => 'integer',
'obj_id' => 'integer',
'title' => 'text',
'add_perm' => 'integer',
'edit_perm' => 'integer',
'delete_perm' => 'integer',
'edit_by_owner' => 'integer',
'limited' => 'integer',
'limit_start' => 'text',
'limit_end' => 'text',
'is_visible' => 'integer',
'export_enabled' => 'integer',
'default_sort_field_id' => 'text',
'default_sort_field_order' => 'text',
'description' => 'text',
'public_comments' => 'integer',
'view_own_records_perm' => 'integer',
);
case 'il_dcl_field':
return array(
'id' => 'integer',
'table_id' => 'integer',
'title' => 'text',
'description' => 'text',
'datatype_id' => 'integer',
'required' => 'integer',
'is_unique' => 'integer',
'is_locked' => 'integer',
);
case 'il_dcl_field_prop':
return array(
'id' => 'integer',
'field_id' => 'integer',
'datatype_prop_id' => 'integer',
'value' => 'integer',
);
case 'il_dcl_record':
return array(
'id' => 'integer',
'table_id' => 'integer',
);
case 'il_dcl_record_field':
return array(
'id' => 'integer',
'record_id' => 'integer',
'field_id' => 'integer',
);
case 'il_dcl_stloc1_value':
return array(
'id' => 'integer',
'record_field_id' => 'integer',
'value' => 'text',
);
case 'il_dcl_stloc2_value':
return array(
'id' => 'integer',
'record_field_id' => 'integer',
'value' => 'text',
);
case 'il_dcl_stloc3_value':
return array(
'id' => 'integer',
'record_field_id' => 'integer',
'value' => 'text',
);
case 'il_dcl_view':
return array(
'id' => 'integer',
'table_id' => 'integer',
'type' => 'integer',
'formtype' => 'integer',
);
case 'il_dcl_viewdefinition':
return array(
'view_id' => 'integer',
'field' => 'string',
'field_order' => 'integer',
'is_set' => 'integer',
);
default:
return array();
}
}
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.

{
return 'http://www.ilias.de/xml/Modules/DataCollection/' . $a_entity;
}
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.

{
$this->data = array();
if (!is_array($a_ids)) {
$a_ids = array( $a_ids );
}
$this->_readData($a_entity, $a_ids);
}

Field Documentation

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.

ilDataCollectionDataSet::$count_imported_tables = 0
protected

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

ilDataCollectionDataSet::$data = array()
protected

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

ilDataCollectionDataSet::$db
protected

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

ilDataCollectionDataSet::$import_dc_object
protected

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

ilDataCollectionDataSet::$import_record_field_cache = array()
protected

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

ilDataCollectionDataSet::$import_temp_new_mob_ids = array()
protected

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

ilDataCollectionDataSet::$import_temp_refs = array()
protected

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

ilDataCollectionDataSet::$import_temp_refs_props = array()
protected

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

ilDataCollectionDataSet::$record_field_ids_2_storage = array()
protected

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

ilDataCollectionDataSet::$user
protected

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


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