ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTaxonomyDataSet Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilTaxonomyDataSet:
+ Collaboration diagram for ilTaxonomyDataSet:

Public Member Functions

 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 
- 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...
 
 setExportDirectories (string $a_relative, string $a_absolute)
 
 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 ...> ... 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...
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 Determine the dependent sets of data. 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)
 
 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=[])
 

Protected Attributes

ilObjTaxonomy $current_obj
 
- Protected Attributes inherited from ilDataSet
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $relative_export_dir = ""
 
string $absolute_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
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
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Taxonomy data set class This class implements the following entities:

  • tax: data from table tax_data/object_data
  • tax_usage: data from table tax_usage
  • tax_tree: data from a join on tax_tree and tax_node
  • tax_node_assignment: data from table tax_node_assignment
    Author
    Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Member Function Documentation

◆ getDependencies()

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

Determine the dependent sets of data.

Definition at line 168 of file class.ilTaxonomyDataSet.php.

173  : array {
174  switch ($a_entity) {
175  case "tax":
176  return array(
177  "tax_tree" => array("ids" => $a_rec["Id"] ?? null),
178  "tax_usage" => array("ids" => $a_rec["Id"] ?? null)
179  );
180  case "tax_tree":
181  return array(
182  "tax_node_assignment" => array("ids" => $a_rec["Child"] ?? null)
183  );
184  }
185  return [];
186  }

◆ getSupportedVersions()

ilTaxonomyDataSet::getSupportedVersions ( )

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

32  : array
33  {
34  return array("4.3.0");
35  }

◆ getTypes()

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

Definition at line 45 of file class.ilTaxonomyDataSet.php.

45  : array
46  {
47  // tax
48  if ($a_entity == "tax") {
49  switch ($a_version) {
50  case "4.3.0":
51  return array(
52  "Id" => "integer",
53  "Title" => "text",
54  "Description" => "text",
55  "SortingMode" => "integer"
56  );
57  }
58  }
59 
60  // tax_usage
61  if ($a_entity == "tax_usage") {
62  switch ($a_version) {
63  case "4.3.0":
64  return array(
65  "TaxId" => "integer",
66  "ObjId" => "integer"
67  );
68  }
69  }
70 
71  // tax_tree
72  if ($a_entity == "tax_tree") {
73  switch ($a_version) {
74  case "4.3.0":
75  return array(
76  "TaxId" => "integer",
77  "Child" => "integer",
78  "Parent" => "integer",
79  "Depth" => "integer",
80  "Type" => "text",
81  "Title" => "text",
82  "OrderNr" => "integer"
83  );
84  }
85  }
86 
87  // tax_node_assignment
88  if ($a_entity == "tax_node_assignment") {
89  switch ($a_version) {
90  case "4.3.0":
91  return array(
92  "NodeId" => "integer",
93  "Component" => "text",
94  "ItemType" => "text",
95  "ItemId" => "integer"
96  );
97  }
98  }
99  return [];
100  }

◆ getXmlNamespace()

ilTaxonomyDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

Definition at line 37 of file class.ilTaxonomyDataSet.php.

37  : string
38  {
39  return "http://www.ilias.de/xml/Services/Taxonomy/" . $a_entity;
40  }

◆ importRecord()

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

Definition at line 192 of file class.ilTaxonomyDataSet.php.

References ilTaxNodeAssignment\addAssignment(), ilImportMapping\addMapping(), ilImportMapping\getMapping(), ILIAS\Repository\int(), ilTaxonomyNode\putInTree(), and ilDataSet\stripTags().

198  : void {
199  $a_rec = $this->stripTags($a_rec);
200  switch ($a_entity) {
201  case "tax":
202  $newObj = new ilObjTaxonomy();
203  $newObj->create();
204 
205  $newObj->setTitle($a_rec["Title"]);
206  $newObj->setDescription($a_rec["Description"]);
207  $newObj->setSortingMode((int) $a_rec["SortingMode"]);
208  $newObj->update();
209 
210  $this->current_obj = $newObj;
211  $a_mapping->addMapping("Services/Taxonomy", "tax", $a_rec["Id"], $newObj->getId());
212  break;
213 
214  case "tax_tree":
215  switch ($a_rec["Type"]) {
216  case "taxn":
217  $parent = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_tree", $a_rec["Parent"]);
218  $tax_id = $a_mapping->getMapping("Services/Taxonomy", "tax", $a_rec["TaxId"]);
219  if ($parent == 0) {
220  $parent = $this->current_obj->getTree()->readRootId();
221  }
222  $node = new ilTaxonomyNode();
223  $node->setTitle($a_rec["Title"]);
224  $node->setOrderNr((int) $a_rec["OrderNr"]);
225  $node->setTaxonomyId((int) $tax_id);
226  $node->create();
227  ilTaxonomyNode::putInTree((int) $tax_id, $node, (int) $parent, 0, (int) $a_rec["OrderNr"]);
228  $a_mapping->addMapping(
229  "Services/Taxonomy",
230  "tax_tree",
231  $a_rec["Child"],
232  $node->getId()
233  );
234  break;
235 
236  }
237 
238  // no break
239  case "tax_node_assignment":
240  $new_item_id = (int) $a_mapping->getMapping(
241  "Services/Taxonomy",
242  "tax_item",
243  ($a_rec["Component"] ?? "") .
244  ":" . ($a_rec["ItemType"] ?? "") . ":" .
245  ($a_rec["ItemId"] ?? "")
246  );
247  $new_node_id = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_tree", $a_rec["NodeId"] ?? "");
248 
249  // this is needed since 4.4 (but not exported with 4.3)
250  // with 4.4 this should be part of export/import
251  $new_item_id_obj = (int) $a_mapping->getMapping(
252  "Services/Taxonomy",
253  "tax_item_obj_id",
254  ($a_rec["Component"] ?? "") .
255  ":" . ($a_rec["ItemType"] ?? "") . ":" .
256  ($a_rec["ItemId"] ?? "")
257  );
258  if ($new_item_id > 0 && $new_node_id > 0 && $new_item_id_obj > 0) {
259  $node_ass = new ilTaxNodeAssignment(
260  $a_rec["Component"],
261  $new_item_id_obj,
262  $a_rec["ItemType"],
263  $this->current_obj->getId()
264  );
265  $node_ass->addAssignment($new_node_id, $new_item_id);
266  }
267  break;
268 
269  case "tax_usage":
270  $usage = $a_mapping->getMapping("Services/Taxonomy", "tax_usage_of_obj", $a_rec["ObjId"]);
271  if ($usage != "") {
272  $usage .= ":";
273  }
274  $a_mapping->addMapping(
275  "Services/Taxonomy",
276  "tax_usage_of_obj",
277  $a_rec["ObjId"],
278  $usage . $this->current_obj->getId()
279  );
280  break;
281  }
282  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addAssignment(int $a_node_id, int $a_item_id, int $a_order_nr=0)
Add assignment.
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 putInTree(int $a_tax_id, ilTaxonomyNode $a_node, int $a_parent_id=0, int $a_target_node_id=0, int $a_order_nr=0)
stripTags(array $rec, array $omit_keys=[])
+ Here is the call graph for this function:

◆ readData()

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

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

References ilDataSet\$db, $ilDB, and ilDataSet\getDirectDataFromQuery().

105  : void
106  {
107  $ilDB = $this->db;
108 
109  if (!is_array($a_ids)) {
110  $a_ids = array($a_ids);
111  }
112 
113  // tax
114  if ($a_entity == "tax") {
115  switch ($a_version) {
116  case "4.3.0":
117  $this->getDirectDataFromQuery("SELECT id, title, description, " .
118  " sorting_mode" .
119  " FROM tax_data JOIN object_data ON (tax_data.id = object_data.obj_id) " .
120  "WHERE " .
121  $ilDB->in("id", $a_ids, false, "integer"));
122  break;
123  }
124  }
125 
126  // tax usage
127  if ($a_entity == "tax_usage") {
128  switch ($a_version) {
129  case "4.3.0":
130  $this->getDirectDataFromQuery("SELECT tax_id, obj_id " .
131  " FROM tax_usage " .
132  "WHERE " .
133  $ilDB->in("tax_id", $a_ids, false, "integer"));
134  break;
135  }
136  }
137 
138  // tax_tree
139  if ($a_entity == "tax_tree") {
140  switch ($a_version) {
141  case "4.3.0":
142  $this->getDirectDataFromQuery("SELECT tax_id, child " .
143  " ,parent,depth,type,title,order_nr " .
144  " FROM tax_tree JOIN tax_node ON (child = obj_id) " .
145  " WHERE " .
146  $ilDB->in("tax_id", $a_ids, false, "integer") .
147  " ORDER BY depth");
148  break;
149  }
150  }
151 
152  // tax node assignment
153  if ($a_entity == "tax_node_assignment") {
154  switch ($a_version) {
155  case "4.3.0":
156  $this->getDirectDataFromQuery("SELECT node_id, component, item_type, item_id " .
157  " FROM tax_node_assignment " .
158  "WHERE " .
159  $ilDB->in("node_id", $a_ids, false, "integer"));
160  break;
161  }
162  }
163  }
ilDBInterface $db
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 ...
+ Here is the call graph for this function:

Field Documentation

◆ $current_obj

ilObjTaxonomy ilTaxonomyDataSet::$current_obj
protected

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


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