ILIAS  release_7 Revision v7.30-3-g800a261c036
ilTaxonomyDataSet Class Reference

Taxonomy data set class. More...

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

Public Member Functions

 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. 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 ...> ... </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)
 Get field types for entity. More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data. 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...
 
 stripTags (array $rec, array $omit_keys=[])
 

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
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 
 $ds_namespace = 'ds'
 

Detailed Description

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
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ getDependencies()

ilTaxonomyDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

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

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

◆ getSupportedVersions()

ilTaxonomyDataSet::getSupportedVersions ( )

Get supported versions.

Parameters

return

Reimplemented from ilDataSet.

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

28 {
29 return array("4.3.0");
30 }

◆ getTypes()

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

Get field types for entity.

Parameters

return

Reimplemented from ilDataSet.

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

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

◆ getXmlNamespace()

ilTaxonomyDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

return

Reimplemented from ilDataSet.

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

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

◆ importRecord()

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

Import record.

Parameters

return

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

201 {
202 $a_rec = $this->stripTags($a_rec);
203
204 switch ($a_entity) {
205 case "tax":
206 include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
207
208// if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
209// {
210// $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
211// }
212// else
213// {
214 $newObj = new ilObjTaxonomy();
215 $newObj->create();
216// }
217
218 $newObj->setTitle($a_rec["Title"]);
219 $newObj->setDescription($a_rec["Description"]);
220 $newObj->setSortingMode($a_rec["SortingMode"]);
221 $newObj->update();
222
223 $this->current_obj = $newObj;
224 $a_mapping->addMapping("Services/Taxonomy", "tax", $a_rec["Id"], $newObj->getId());
225 break;
226
227 case "tax_tree":
228 switch ($a_rec["Type"]) {
229 case "taxn":
230 $parent = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_tree", $a_rec["Parent"]);
231 $tax_id = $a_mapping->getMapping("Services/Taxonomy", "tax", $a_rec["TaxId"]);
232 if ($parent == 0) {
233 $parent = $this->current_obj->getTree()->readRootId();
234 }
235 $node = new ilTaxonomyNode();
236 $node->setTitle($a_rec["Title"]);
237 $node->setOrderNr($a_rec["OrderNr"]);
238 $node->setTaxonomyId($tax_id);
239 $node->create();
240 ilTaxonomyNode::putInTree($tax_id, $node, (int) $parent, "", $a_rec["OrderNr"]);
241 $a_mapping->addMapping(
242 "Services/Taxonomy",
243 "tax_tree",
244 $a_rec["Child"],
245 $node->getId()
246 );
247 break;
248
249 }
250
251 // no break
252 case "tax_node_assignment":
253 $new_item_id = (int) $a_mapping->getMapping(
254 "Services/Taxonomy",
255 "tax_item",
256 $a_rec["Component"] . ":" . $a_rec["ItemType"] . ":" . $a_rec["ItemId"]
257 );
258 $new_node_id = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_tree", $a_rec["NodeId"]);
259
260 // this is needed since 4.4 (but not exported with 4.3)
261 // with 4.4 this should be part of export/import
262 $new_item_id_obj = (int) $a_mapping->getMapping(
263 "Services/Taxonomy",
264 "tax_item_obj_id",
265 $a_rec["Component"] . ":" . $a_rec["ItemType"] . ":" . $a_rec["ItemId"]
266 );
267 if ($new_item_id > 0 && $new_node_id > 0 && $new_item_id_obj > 0) {
268 include_once("./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
269 $node_ass = new ilTaxNodeAssignment($a_rec["Component"], $new_item_id_obj, $a_rec["ItemType"], $this->current_obj->getId());
270 $node_ass->addAssignment($new_node_id, $new_item_id);
271 }
272 break;
273
274 case "tax_usage":
275 $usage = $a_mapping->getMapping("Services/Taxonomy", "tax_usage_of_obj", $a_rec["ObjId"]);
276 if ($usage != "") {
277 $usage .= ":";
278 }
279 $a_mapping->addMapping(
280 "Services/Taxonomy",
281 "tax_usage_of_obj",
282 $a_rec["ObjId"],
283 $usage . $this->current_obj->getId()
284 );
285 break;
286 }
287 }
stripTags(array $rec, array $omit_keys=[])
Taxonomy node <-> item assignment.
static putInTree( $a_tax_id, $a_node, $a_parent_id="", $a_target_node_id="", $a_order_nr=0)
Put this node into the taxonomy tree.

References ilTaxonomyNode\putInTree(), and ilDataSet\stripTags().

+ Here is the call graph for this function:

◆ readData()

ilTaxonomyDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

return

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

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

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

+ Here is the call graph for this function:

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