ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilCmiXapiDataSet Class Reference
+ Inheritance diagram for ilCmiXapiDataSet:
+ Collaboration diagram for ilCmiXapiDataSet:

Public Member Functions

 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 Get xml namespace. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $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 (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Data Fields

array $_cmixSettingsProperties
 
- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
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
 
int $dircnt = 0
 

Protected Member Functions

 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 Determine the dependent sets of data. More...
 
 getTypes (string $a_entity, string $a_version)
 Get field types for entity. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Private Member Functions

 buildManifest ()
 
 buildProperties (mixed $a_entity, bool $a_omit_header=false)
 

Private Attributes

array $_data = []
 
array $_archive = []
 
array $_element_db_mapping = []
 

Additional Inherited Members

- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Detailed Description

Definition at line 28 of file class.ilCmiXapiDataSet.php.

Member Function Documentation

◆ buildManifest()

ilCmiXapiDataSet::buildManifest ( )
private

Definition at line 300 of file class.ilCmiXapiDataSet.php.

300 : string
301 {
302 $manWriter = new ilXmlWriter();
303 $manWriter->xmlHeader();
304 foreach ($this->_archive['files'] as $key => $value) {
305 $manWriter->xmlElement($key, null, $value, true, true);
306 }
307 #$manWriter->appendXML ("</content>\n");
308 return $manWriter->xmlDumpMem(true);
309 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ buildProperties()

ilCmiXapiDataSet::buildProperties ( mixed  $a_entity,
bool  $a_omit_header = false 
)
private

Definition at line 311 of file class.ilCmiXapiDataSet.php.

311 : string
312 {
313 $atts = array(
314 "InstallationId" => IL_INST_ID,
315 "InstallationUrl" => ILIAS_HTTP_PATH,
316 "TopEntity" => $a_entity
317 );
318
319 $writer = new ilXmlWriter();
320
321 $writer->xmlStartTag('DataSet', $atts);
322
323 if (!$a_omit_header) {
324 $writer->xmlHeader();
325 }
326
327 foreach ($this->data as $key => $value) {
328 $writer->xmlElement($key, null, $value, true, true);
329 }
330
331 $writer->xmlEndTag("DataSet");
332
333 return $writer->xmlDumpMem(true);
334 }
const IL_INST_ID
Definition: constants.php:40

References IL_INST_ID.

◆ getDependencies()

ilCmiXapiDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Determine the dependent sets of data.

Returns
mixed[]

Reimplemented from ilDataSet.

Definition at line 148 of file class.ilCmiXapiDataSet.php.

153 : array {
154 return [];
155 }

◆ getSupportedVersions()

ilCmiXapiDataSet::getSupportedVersions ( )

Get supported versions.

Returns
string[]

Reimplemented from ilDataSet.

Definition at line 375 of file class.ilCmiXapiDataSet.php.

375 : array
376 {
377 return array("5.1.0");
378 }

◆ getTypes()

ilCmiXapiDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
protected

Get field types for entity.

Parameters
string$a_entityentity
string$a_versionversion number
Returns
array types array

Reimplemented from ilDataSet.

Definition at line 231 of file class.ilCmiXapiDataSet.php.

231 : array
232 {
233 $types = [];
234 foreach ($this->_cmixSettingsProperties as $key => $value) {
235 $types[$key] = $value["db_type"];
236 }
237
238 if ($a_entity == "cmix") {
239 switch ($a_version) {
240 case "5.1.0":
241 $types = [];
242 foreach ($this->_cmixSettingsProperties as $key => $value) {
243 $types[$key] = $value["db_type"];
244 }
245 //return $types;
246 break;
247 }
248 }
249 return $types;
250 }

◆ getXmlNamespace()

ilCmiXapiDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)

Get xml namespace.

Reimplemented from ilDataSet.

Definition at line 383 of file class.ilCmiXapiDataSet.php.

383 : string
384 {
385 return "http://www.ilias.de/xml/Modules/CmiXapi/" . $a_entity;
386 }

◆ importRecord()

ilCmiXapiDataSet::importRecord ( string  $a_entity,
array  $a_types,
array  $a_rec,
ilImportMapping  $a_mapping,
string  $a_schema_version 
)

Needs to be overwritten for import use case.

Reimplemented from ilDataSet.

Definition at line 336 of file class.ilCmiXapiDataSet.php.

342 : void {
343 //var_dump( [$a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version] ); exit;
344 switch ($a_entity) {
345 case "cmix":
346
347 if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_rec['Id'])) {
348 $newObj = ilObjectFactory::getInstanceByObjId((int) $new_id, false);
349 } else {
350 $newObj = new ilObjCmiXapi();
351 $newObj->setType("cmix");
352 $newObj->create(true);
353 }
354
355 $newObj->setTitle($a_rec["Title"]);
356 $newObj->setDescription($a_rec["Description"]);
357 $newObj->update();
358
359 //$this->current_obj = $newObj;
360 $a_mapping->addMapping("components/ILIAS/CmiXapi", "cmix", $a_rec["Id"], (string) $newObj->getId());
361 $a_mapping->addMapping(
362 "components/ILIAS/MetaData",
363 "md",
364 $a_rec["Id"] . ":0:cmix",
365 $newObj->getId() . ":0:cmix"
366 );
367 break;
368 }
369 }
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id

References ilImportMapping\addMapping(), ilObjectFactory\getInstanceByObjId(), and ilImportMapping\getMapping().

+ Here is the call graph for this function:

◆ readData()

ilCmiXapiDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

Read data from DB.

This should result in the abstract field structure of the version set in the constructor.

Reimplemented from ilDataSet.

Definition at line 252 of file class.ilCmiXapiDataSet.php.

252 : void
253 {
254 global $DIC;
255
256 if (!is_array($a_ids)) {
257 $a_ids = array($a_ids);
258 }
259
260 //var_dump([$a_entity, $a_version, $a_id]); exit;
261 if ($a_entity == "cmix") {
262 switch ($a_version) {
263 case "5.1.0":
264 $this->getDirectDataFromQuery("SELECT obj_id id, title, description " .
265 " FROM object_data " .
266 "WHERE " .
267 $DIC->database()->in("obj_id", $a_ids, false, "integer"));
268 break;
269 } // EOF switch
270 } // EOF if( $a_entity == "cmix" )
271
272 foreach ($this->data as $key => $data) {
273 $query = "SELECT " . implode(",", array_keys($this->_element_db_mapping)) . " ";
274 $query .= "FROM `cmix_settings` ";
275 $query .= "WHERE " . $DIC->database()->in("obj_id", $a_ids, false, "integer");
276 $result = $DIC->database()->query($query);
277 //$this->data = [];
278 if ($dataset = $DIC->database()->fetchAssoc($result)) {
279 $this->_data = $dataset;
280 }
281
282 //foreach( $this->_data AS $key => $data ) {
283 foreach ($this->_data as $dbColName => $value) {
284 $attr = $this->_element_db_mapping[$dbColName];
285 $this->data[$key][$attr] = $value;
286 //$this->data[$key][$dbColName] = $value;
287 } // EOF foreach ($this->_dataSetMapping as $dbColName => $value)
288 } // EOF foreach( $this->_data AS $key => $data )
289 $this->data = $this->data[0];
290 //var_dump($this->data); exit;
291 }
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
global $DIC
Definition: shib_login.php:26

References $data, and $DIC.

Field Documentation

◆ $_archive

array ilCmiXapiDataSet::$_archive = []
private

Definition at line 31 of file class.ilCmiXapiDataSet.php.

◆ $_cmixSettingsProperties

array ilCmiXapiDataSet::$_cmixSettingsProperties

Definition at line 33 of file class.ilCmiXapiDataSet.php.

◆ $_data

array ilCmiXapiDataSet::$_data = []
private

Definition at line 30 of file class.ilCmiXapiDataSet.php.

◆ $_element_db_mapping

array ilCmiXapiDataSet::$_element_db_mapping = []
private

Definition at line 32 of file class.ilCmiXapiDataSet.php.


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