ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 

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
 

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

+ 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: