58 final public function init($a_entity, $a_schema_version)
60 $this->entity = $a_entity;
61 $this->schema_version = $a_schema_version;
80 abstract protected function getTypes($a_entity, $a_version);
86 abstract protected function getXmlNamespace($a_entity, $a_schema_version);
94 abstract function readData($a_entity, $a_version, $a_ids);
104 $this->relative_export_dir = $a_relative;
105 $this->absolute_export_dir = $a_absolute;
115 $this->import_directory = $a_val;
125 return $this->import_directory;
168 $set = $ilDB->query($a_query);
171 while ($rec = $ilDB->fetchAssoc($set))
173 if ($a_convert_to_leading_upper)
176 foreach ($rec as $k => $v)
186 $this->
data[] = $rec;
201 $a_str = strtoupper(substr($a_str, 0, 1)).substr($a_str, 1);
202 while (is_int($pos = strpos($a_str,
"_")))
204 $a_str = substr($a_str, 0, $pos).
205 strtoupper(substr($a_str, $pos+1, 1)).
206 substr($a_str, $pos+2);
217 if ($this->version ===
false)
224 $arr[
"install_id"] = IL_INST_ID;
225 $arr[
"install_url"] = ILIAS_HTTP_PATH;
227 $arr[
"set"] =
array();
228 foreach ($this->
data as
$d)
233 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
260 $a_ids, $a_field =
"", $a_omit_header =
false, $a_omit_types =
false)
269 include_once
"./Services/Xml/classes/class.ilXmlWriter.php";
273 $writer->xmlHeader();
277 $namespaces = $prefixes =
array();
278 $this->
getNamespaces($namespaces, $a_entity, $a_schema_version);
279 $atts =
array(
"InstallationId" => IL_INST_ID,
280 "InstallationUrl" => ILIAS_HTTP_PATH,
"TopEntity" => $a_entity);
282 foreach ($namespaces as $entity => $ns)
285 $prefixes[$entity] = $prefix;
290 $this->ds_log->debug(
"Start writing Dataset, entity: ".$a_entity.
", schema version: ".$a_schema_version.
291 ", ids: ".print_r($a_ids,
true));
297 $this->ds_log->debug(
"...write types");
298 $this->
addTypesXml($writer, $a_entity, $a_schema_version);
302 $this->ds_log->debug(
"...write records");
303 $this->
addRecordsXml($writer, $prefixes, $a_entity, $a_schema_version, $a_ids, $a_field);
311 return $writer->xmlDumpMem(
false);
321 function addRecordsXml($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field =
"")
323 $types = $this->
getXmlTypes($a_entity, $a_schema_version);
325 $this->ds_log->debug(
"...read data");
326 $this->
readData($a_entity, $a_schema_version, $a_ids, $a_field);
327 $this->ds_log->debug(
"...data: ".print_r($this->
data,
true));
328 if (is_array($this->
data))
330 foreach ($this->
data as
$d)
333 array(
"Entity" => $this->getXmlEntityName($a_entity, $a_schema_version)));
336 $a_writer->xmlStartTag($this->getXmlEntityTag($a_entity, $a_schema_version));
338 $rec = $this->
getXmlRecord($a_entity, $a_schema_version, $d);
339 foreach ($rec as $f => $c)
344 if ($this->absolute_export_dir !=
"" && $this->relative_export_dir !=
"")
347 ilUtil::rCopy($c, $this->absolute_export_dir.
"/dsDir_".$this->dircnt);
357 $a_writer->xmlElement($f,
array(), $c);
360 $a_writer->xmlEndTag($this->getXmlEntityTag($a_entity, $a_schema_version));
367 $this->ds_log->debug(
"...get dependencies");
368 $deps = $this->getDependencies($a_entity, $a_schema_version, $rec, $a_ids);
369 $this->ds_log->debug(
"...dependencies: ".print_r($deps,
true));
372 foreach ($deps as $dp => $par)
374 $this->
addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par[
"ids"], $par[
"field"]);
379 else if ($this->
data ===
false)
382 $this->ds_log->debug(
"...get dependencies (no record)");
383 $deps = $this->getDependencies($a_entity, $a_schema_version, null, $a_ids);
386 foreach ($deps as $dp => $par)
388 $this->
addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par[
"ids"], $par[
"field"]);
409 private function addTypesXml($a_writer, $a_entity, $a_schema_version)
411 $types = $this->
getXmlTypes($a_entity, $a_schema_version);
414 if (is_array($types))
417 array(
"Entity" => $this->getXmlEntityName($a_entity, $a_schema_version),
418 "SchemaVersion" => $a_schema_version));
419 foreach ($this->
getXmlTypes($a_entity, $a_schema_version) as $f =>
$t)
422 array(
"Name" => $f,
"Type" =>
$t));
428 $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
431 foreach ($deps as $dp =>
$w)
433 $this->
addTypesXml($a_writer, $dp, $a_schema_version);
451 $namespaces[$a_entity] = $ns;
454 $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
457 foreach ($deps as $dp =>
$w)
493 return $this->
getTypes($a_entity, $a_version);
503 return $this->
getTypes($a_entity, $a_version);
544 $this->
import = $a_val;
554 return $this->import;
564 $this->current_installation_id = $a_val;
586 return "il_".IL_INST_ID.
"_".
$a_type.
"_".$a_id;
599 if(substr($a_id, 0, 3) ==
"il_")
601 $parts = explode(
"_", $a_id);
602 $inst_id = $parts[1];
607 if(($inst_id == 0 || IL_INST_ID == 0) && !DEVMODE)
609 return array(
"type"=>self::EXPORT_NO_INST_ID,
"id"=>$a_fallback_id);
613 if($inst_id == IL_INST_ID)
618 return array(
"type"=>self::EXPORT_ID_ILIAS_LOCAL,
"id"=>$id);
623 return array(
"type"=>self::EXPORT_ID_ILIAS_LOCAL_INVALID,
"id"=>$a_fallback_id);
633 return array(
"type"=>self::EXPORT_ID_ILIAS_REMOTE,
"id"=>$id);
638 return array(
"type"=>self::EXPORT_ID_ILIAS_REMOTE_INVALID,
"id"=>$a_fallback_id);
647 return array(
"type"=>self::EXPORT_ID,
"id"=>$id);
651 return array(
"type"=>self::EXPORT_ID_INVALID,
"id"=>$a_fallback_id);
getJsonEntityName($a_entity, $a_version)
Get entity name for json (may be overwritten)
static makeDirParents($a_dir)
Create a new directory and all parent directories.
init($a_entity, $a_schema_version)
Init.
const EXPORT_ID_ILIAS_REMOTE
setExportDirectories($a_relative, $a_absolute)
Set export directories.
setImportDirectory($a_val)
Set import directory.
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 ...
getTypes($a_entity, $a_version)
Get (abstract) types for (abstract) field names.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
const EXPORT_ID_ILIAS_LOCAL_INVALID
createObjectExportId($a_type, $a_id)
Build ilias export id.
afterXmlRecordWriting($a_entity, $a_version, $a_set)
After xml record writing hook record.
addTypesXml($a_writer, $a_entity, $a_schema_version)
Add types to xml writer.
getDSPrefix()
Get XML dataset namespace prefix.
getImportDirectory()
Get import directory.
readData($a_entity, $a_version, $a_ids)
Read data from DB.
__construct()
Constructor.
getJsonTypes($a_entity, $a_version)
Get json types.
parseObjectExportId($a_id, $a_fallback_id=NULL)
Parse export id.
getXMLEntityName($a_entity, $a_version)
Get entity name for xml (may be overwritten)
convertToLeadingUpper($a_str)
Make xyz_abc a XyzAbc string.
getXmlRecord($a_entity, $a_version, $a_set)
Get xml record for version.
for($col=0; $col< 50; $col++) $d
getImport()
Get import object.
const EXPORT_ID_ILIAS_REMOTE_INVALID
static encode($mixed, $suppress_native=false)
const EXPORT_ID_ILIAS_LOCAL
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
getJsonRepresentation()
Get json representation.
getSupportedVersions()
Get supported version.
getNamespaces(&$namespaces, $a_entity, $a_schema_version)
Get xml namespaces.
setCurrentInstallationId($a_val)
Set current installation id.
getCurrentInstallationId()
Get current installation id.
getJsonRecord($a_set)
Get json record for version.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
getXmlTypes($a_entity, $a_version)
Get xml types.
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" versio...
setImport($a_val)
Set import object.
static getLogger($a_component_id)
Get component logger.
getXMLEntityTag($a_entity, $a_schema_version)
Get entity tag.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
setDSPrefix($a_val)
Set XML dataset namespace prefix.
addRecordsXml($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
Add records xml.
static _getIdForImportId($a_import_id)
get current object id for import id (static)