ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ...> ... 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 = ""
 

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 192 of file class.ilTaxonomyDataSet.php.

References array.

193  {
194  switch ($a_entity)
195  {
196  case "tax":
197  return array (
198  "tax_tree" => array("ids" => $a_rec["Id"]),
199  "tax_usage" => array("ids" => $a_rec["Id"])
200  );
201  case "tax_tree":
202  return array (
203  "tax_node_assignment" => array("ids" => $a_rec["Child"])
204  );
205  }
206  return false;
207  }
Create styles array
The data for the language used.

◆ getSupportedVersions()

ilTaxonomyDataSet::getSupportedVersions ( )

Get supported versions.

Parameters

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

References array.

28  {
29  return array("4.3.0");
30  }
Create styles array
The data for the language used.

◆ getTypes()

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

Get field types for entity.

Parameters

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

References array.

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

◆ getXmlNamespace()

ilTaxonomyDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

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

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

References ilTaxNodeAssignment\addAssignment(), and ilTaxonomyNode\putInTree().

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

◆ readData()

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

Read data.

Parameters

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

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

120  {
121  global $ilDB;
122 
123  if (!is_array($a_ids))
124  {
125  $a_ids = array($a_ids);
126  }
127 
128  // tax
129  if ($a_entity == "tax")
130  {
131  switch ($a_version)
132  {
133  case "4.3.0":
134  $this->getDirectDataFromQuery("SELECT id, title, description, ".
135  " sorting_mode".
136  " FROM tax_data JOIN object_data ON (tax_data.id = object_data.obj_id) ".
137  "WHERE ".
138  $ilDB->in("id", $a_ids, false, "integer"));
139  break;
140  }
141  }
142 
143  // tax usage
144  if ($a_entity == "tax_usage")
145  {
146  switch ($a_version)
147  {
148  case "4.3.0":
149  $this->getDirectDataFromQuery("SELECT tax_id, obj_id ".
150  " FROM tax_usage ".
151  "WHERE ".
152  $ilDB->in("tax_id", $a_ids, false, "integer"));
153  break;
154  }
155  }
156 
157  // tax_tree
158  if ($a_entity == "tax_tree")
159  {
160  switch ($a_version)
161  {
162  case "4.3.0":
163  $this->getDirectDataFromQuery("SELECT tax_id, child ".
164  " ,parent,depth,type,title,order_nr ".
165  " FROM tax_tree JOIN tax_node ON (child = obj_id) ".
166  " WHERE ".
167  $ilDB->in("tax_id", $a_ids, false, "integer").
168  " ORDER BY depth");
169  break;
170  }
171  }
172 
173  // tax node assignment
174  if ($a_entity == "tax_node_assignment")
175  {
176  switch ($a_version)
177  {
178  case "4.3.0":
179  $this->getDirectDataFromQuery("SELECT node_id, component, item_type, item_id ".
180  " FROM tax_node_assignment ".
181  "WHERE ".
182  $ilDB->in("node_id", $a_ids, false, "integer"));
183  break;
184  }
185  }
186 
187  }
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 ...
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

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