ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LOMDictionaryInitiator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\MetaData\Paths\FactoryInterface as PathFactoryInterface;
28
29class LOMDictionaryInitiator extends BaseDictionaryInitiator
30{
31 public const array TABLES = [
32 'annotation' => 'il_meta_annotation',
33 'classification' => 'il_meta_classification',
34 'contribute' => 'il_meta_contribute',
35 'description' => 'il_meta_description',
36 'educational' => 'il_meta_educational',
37 'entity' => 'il_meta_entity',
38 'format' => 'il_meta_format',
39 'general' => 'il_meta_general',
40 'identifier' => 'il_meta_identifier',
41 'identifier_' => 'il_meta_identifier_',
42 'keyword' => 'il_meta_keyword',
43 'language' => 'il_meta_language',
44 'lifecycle' => 'il_meta_lifecycle',
45 'location' => 'il_meta_location',
46 'meta_data' => 'il_meta_meta_data',
47 'relation' => 'il_meta_relation',
48 'requirement' => 'il_meta_requirement',
49 'rights' => 'il_meta_rights',
50 'tar' => 'il_meta_tar',
51 'taxon' => 'il_meta_taxon',
52 'taxon_path' => 'il_meta_taxon_path',
53 'technical' => 'il_meta_technical',
54 'coverage' => 'il_meta_coverage',
55 'meta_schema' => 'il_meta_meta_schema',
56 'or_composite' => 'il_meta_or_composite',
57 'lr_type' => 'il_meta_lr_type',
58 'end_usr_role' => 'il_meta_end_usr_role',
59 'context' => 'il_meta_context'
60 ];
61
62 public const array ID_NAME = [
63 'annotation' => 'meta_annotation_id',
64 'classification' => 'meta_classification_id',
65 'contribute' => 'meta_contribute_id',
66 'description' => 'meta_description_id',
67 'educational' => 'meta_educational_id',
68 'entity' => 'meta_entity_id',
69 'format' => 'meta_format_id',
70 'general' => 'meta_general_id',
71 'identifier' => 'meta_identifier_id',
72 'identifier_' => 'meta_identifier__id',
73 'keyword' => 'meta_keyword_id',
74 'language' => 'meta_language_id',
75 'lifecycle' => 'meta_lifecycle_id',
76 'location' => 'meta_location_id',
77 'meta_data' => 'meta_meta_data_id',
78 'relation' => 'meta_relation_id',
79 'requirement' => 'meta_requirement_id',
80 'rights' => 'meta_rights_id',
81 'tar' => 'meta_tar_id',
82 'taxon' => 'meta_taxon_id',
83 'taxon_path' => 'meta_taxon_path_id',
84 'technical' => 'meta_technical_id',
85 'coverage' => 'meta_coverage_id',
86 'meta_schema' => 'meta_meta_schema_id',
87 'or_composite' => 'meta_or_composite_id',
88 'lr_type' => 'meta_lr_type_id',
89 'end_usr_role' => 'meta_end_usr_role_id',
90 'context' => 'meta_context_id'
91 ];
92
94
95 public function __construct(
97 PathFactoryInterface $path_factory,
100 ) {
101 $this->tag_factory = $tag_factory;
103 }
104
105 public function get(): DictionaryInterface
106 {
107 $this->initDictionary();
108 return new LOMDictionary($this->path_factory, $this->navigator_factory, ...$this->getTagAssignments());
109 }
110
111 protected function initDictionary(): void
112 {
113 $structure = $this->getStructure();
114
124 }
125
126 protected function setTagsForGeneral(
128 ): void {
129 $this->addTagToElement(
130 $this->tag_factory->containerWithRowInTable('general'),
131 $general = $structure->getRoot()->getSubElement('general')
132 );
134 $general,
135 'identifier',
136 'meta_general'
137 );
139 $general->getSubElement('title'),
140 'general',
141 'title',
142 'title_language'
143 );
144 $this->addTagToElement(
145 $this->tag_factory->dataWithRowInTable(
146 'language',
147 'language',
148 'meta_general'
149 ),
150 $general->getSubElement('language')
151 );
152 $this->addTagToElement(
153 $this->tag_factory->containerWithRowInTable(
154 'description',
155 'meta_general'
156 ),
157 $description = $general->getSubElement('description')
158 );
160 $description,
161 'description',
162 'description',
163 'description_language',
164 'meta_general'
165 );
166 $this->addTagToElement(
167 $this->tag_factory->containerWithRowInTable(
168 'keyword',
169 'meta_general'
170 ),
171 $keyword = $general->getSubElement('keyword')
172 );
174 $keyword,
175 'keyword',
176 'keyword',
177 'keyword_language',
178 'meta_general'
179 );
180 $this->addTagToElement(
181 $this->tag_factory->containerWithRowInTable(
182 'coverage',
183 'meta_general'
184 ),
185 $coverage = $general->getSubElement('coverage')
186 );
188 $coverage,
189 'coverage',
190 'coverage',
191 'coverage_language',
192 'meta_general'
193 );
195 $general->getSubElement('structure'),
196 'general',
197 'general_structure',
198 'general_structure_src'
199 );
201 $general->getSubElement('aggregationLevel'),
202 'general',
203 'general_aggl',
204 'general_aggl_src'
205 );
206 }
207
208 protected function setTagsForLifecycle(
210 ): void {
211 $this->addTagToElement(
212 $this->tag_factory->containerWithRowInTable('lifecycle'),
213 $life_cycle = $structure->getRoot()->getSubElement('lifeCycle')
214 );
215 $this->setTagsForLangStringSubElements(
216 $life_cycle->getSubElement('version'),
217 'lifecycle',
218 'meta_version',
219 'version_language'
220 );
221 $this->setTagsForVocabSubElements(
222 $life_cycle->getSubElement('status'),
223 'lifecycle',
224 'lifecycle_status',
225 'lifecycle_status_src'
226 );
227 $this->setTagsForContribute(
228 $life_cycle,
229 'meta_lifecycle'
230 );
231 }
232
233 protected function setTagsForMetaMetadata(
235 ): void {
236 $this->addTagToElement(
237 $this->tag_factory->containerWithRowInTable('meta_data'),
238 $meta = $structure->getRoot()->getSubElement('metaMetadata')
239 );
240 $this->setTagsForIdentifier(
241 $meta,
242 'identifier',
243 'meta_meta_data'
244 );
245 $this->setTagsForContribute(
246 $meta,
247 'meta_meta_data'
248 );
249 $this->addTagToElement(
250 $this->tag_factory->dataWithRowInTable(
251 'meta_schema',
252 'meta_data_schema',
253 'meta_meta_data'
254 ),
255 $meta->getSubElement('metadataSchema')
256 );
257 $this->addTagToElement(
258 $this->tag_factory->data(
259 'meta_data',
260 'language'
261 ),
262 $meta->getSubElement('language')
263 );
264 }
265
266 protected function setTagsForTechnical(
268 ): void {
269 $this->addTagToElement(
270 $this->tag_factory->containerWithRowInTable('technical'),
271 $technical = $structure->getRoot()->getSubElement('technical')
272 );
273 $this->addTagToElement(
274 $this->tag_factory->dataWithRowInTable(
275 'format',
276 'format'
277 ),
278 $technical->getSubElement('format')
279 );
280 $this->addTagToElement(
281 $this->tag_factory->data(
282 'technical',
283 't_size'
284 ),
285 $technical->getSubElement('size')
286 );
287 $this->addTagToElement(
288 $this->tag_factory->dataWithRowInTable(
289 'location',
290 'location',
291 'meta_technical'
292 ),
293 $technical->getSubElement('location')
294 );
295 $this->addTagToElement(
296 $this->tag_factory->containerWithRowInTable(
297 'requirement',
298 'meta_technical'
299 ),
300 $requirement = $technical->getSubElement('requirement')
301 );
302 $this->addTagToElement(
303 $this->tag_factory->containerWithRowInTable(
304 'or_composite',
305 'meta_requirement'
306 ),
307 $or = $requirement->getSubElement('orComposite')
308 );
309 $this->setTagsForVocabSubElements(
310 $or->getSubElement('type'),
311 'or_composite',
312 'type',
313 'type_src',
314 'meta_requirement'
315 );
316 $this->setTagsForVocabSubElements(
317 $or->getSubElement('name'),
318 'or_composite',
319 'name',
320 'name_src',
321 'meta_requirement'
322 );
323 $this->addTagToElement(
324 $this->tag_factory->data(
325 'or_composite',
326 'min_version',
327 'meta_requirement'
328 ),
329 $or->getSubElement('minimumVersion')
330 );
331 $this->addTagToElement(
332 $this->tag_factory->data(
333 'or_composite',
334 'max_version',
335 'meta_requirement'
336 ),
337 $or->getSubElement('maximumVersion')
338 );
339 $this->setTagsForLangStringSubElements(
340 $technical->getSubElement('installationRemarks'),
341 'technical',
342 'ir',
343 'ir_language'
344 );
345 $this->setTagsForLangStringSubElements(
346 $technical->getSubElement('otherPlatformRequirements'),
347 'technical',
348 'opr',
349 'opr_language'
350 );
351 $duration = $technical->getSubElement('duration');
352 $this->addTagToElement(
353 $this->tag_factory->data(
354 'technical',
355 'duration'
356 ),
357 $duration->getSubElement('duration')
358 );
359 $this->setTagsForLangStringSubElements(
360 $duration->getSubElement('description'),
361 'technical',
362 'duration_descr',
363 'duration_descr_lang',
364 );
365 }
366
367 protected function setTagsForEducational(
369 ): void {
370 $this->addTagToElement(
371 $this->tag_factory->containerWithRowInTable('educational'),
372 $educational = $structure->getRoot()->getSubElement('educational')
373 );
374 $this->setTagsForVocabSubElements(
375 $educational->getSubElement('interactivityType'),
376 'educational',
377 'interactivity_type',
378 'interactivity_type_src'
379 );
380 $this->addTagToElement(
381 $this->tag_factory->containerWithRowInTable(
382 'lr_type',
383 'meta_educational'
384 ),
385 $lr_type = $educational->getSubElement('learningResourceType')
386 );
387 $this->setTagsForVocabSubElements(
388 $lr_type,
389 'lr_type',
390 'learning_resource_type',
391 'learning_resource_type_src',
392 'meta_educational'
393 );
394 $this->setTagsForVocabSubElements(
395 $educational->getSubElement('interactivityLevel'),
396 'educational',
397 'interactivity_level',
398 'interactivity_level_src'
399 );
400 $this->setTagsForVocabSubElements(
401 $educational->getSubElement('semanticDensity'),
402 'educational',
403 'semantic_density',
404 'semantic_density_src'
405 );
406 $this->addTagToElement(
407 $this->tag_factory->containerWithRowInTable(
408 'end_usr_role',
409 'meta_educational'
410 ),
411 $user_role = $educational->getSubElement('intendedEndUserRole')
412 );
413 $this->setTagsForVocabSubElements(
414 $user_role,
415 'end_usr_role',
416 'intended_end_user_role',
417 'intended_end_user_role_src',
418 'meta_educational'
419 );
420 $this->addTagToElement(
421 $this->tag_factory->containerWithRowInTable(
422 'context',
423 'meta_educational'
424 ),
425 $context = $educational->getSubElement('context')
426 );
427 $this->setTagsForVocabSubElements(
428 $context,
429 'context',
430 'context',
431 'context_src',
432 'meta_educational'
433 );
434 $this->addTagToElement(
435 $this->tag_factory->containerWithRowInTable(
436 'tar',
437 'meta_educational'
438 ),
439 $age_range = $educational->getSubElement('typicalAgeRange')
440 );
441 $this->setTagsForLangStringSubElements(
442 $age_range,
443 'tar',
444 'typical_age_range',
445 'tar_language',
446 'meta_educational'
447 );
448 $this->setTagsForVocabSubElements(
449 $educational->getSubElement('difficulty'),
450 'educational',
451 'difficulty',
452 'difficulty_src'
453 );
454 $tlt = $educational->getSubElement('typicalLearningTime');
455 $this->addTagToElement(
456 $this->tag_factory->data(
457 'educational',
458 'typical_learning_time'
459 ),
460 $tlt->getSubElement('duration')
461 );
462 $this->setTagsForLangStringSubElements(
463 $tlt->getSubElement('description'),
464 'educational',
465 'tlt_descr',
466 'tlt_descr_lang',
467 );
468 $this->addTagToElement(
469 $this->tag_factory->containerWithRowInTable(
470 'description',
471 'meta_educational'
472 ),
473 $description = $educational->getSubElement('description')
474 );
475 $this->setTagsForLangStringSubElements(
476 $description,
477 'description',
478 'description',
479 'description_language',
480 'meta_educational'
481 );
482 $this->addTagToElement(
483 $this->tag_factory->dataWithRowInTable(
484 'language',
485 'language',
486 'meta_educational'
487 ),
488 $educational->getSubElement('language')
489 );
490 }
491
492 protected function setTagsForRights(
494 ): void {
495 $this->addTagToElement(
496 $this->tag_factory->containerWithRowInTable('rights'),
497 $rights = $structure->getRoot()->getSubElement('rights')
498 );
499 $this->setTagsForVocabSubElements(
500 $rights->getSubElement('cost'),
501 'rights',
502 'costs',
503 'costs_src'
504 );
505 $this->setTagsForVocabSubElements(
506 $rights->getSubElement('copyrightAndOtherRestrictions'),
507 'rights',
508 'cpr_and_or',
509 'cpr_and_or_src'
510 );
511 $this->setTagsForLangStringSubElements(
512 $rights->getSubElement('description'),
513 'rights',
514 'description',
515 'description_language'
516 );
517 }
518
519 protected function setTagsForRelation(
521 ): void {
522 $this->addTagToElement(
523 $this->tag_factory->containerWithRowInTable('relation'),
524 $relation = $structure->getRoot()->getSubElement('relation')
525 );
526 $this->setTagsForVocabSubElements(
527 $relation->getSubElement('kind'),
528 'relation',
529 'kind',
530 'kind_src'
531 );
532 $resource = $relation->getSubElement('resource');
533 $this->setTagsForIdentifier(
534 $resource,
535 'identifier_',
536 'meta_relation'
537 );
538 $this->addTagToElement(
539 $this->tag_factory->containerWithRowInTable(
540 'description',
541 'meta_relation'
542 ),
543 $description = $resource->getSubElement('description')
544 );
545 $this->setTagsForLangStringSubElements(
546 $description,
547 'description',
548 'description',
549 'description_language',
550 'meta_relation'
551 );
552 }
553
554 protected function setTagsForAnnotation(
556 ): void {
557 $this->addTagToElement(
558 $this->tag_factory->containerWithRowInTable('annotation'),
559 $annotation = $structure->getRoot()->getSubElement('annotation')
560 );
561 $this->addTagToElement(
562 $this->tag_factory->data(
563 'annotation',
564 'entity'
565 ),
566 $annotation->getSubElement('entity')
567 );
568 $date = $annotation->getSubElement('date');
569 $this->addTagToElement(
570 $this->tag_factory->data(
571 'annotation',
572 'a_date'
573 ),
574 $date->getSubElement('dateTime')
575 );
576 $this->setTagsForLangStringSubElements(
577 $date->getSubElement('description'),
578 'annotation',
579 'a_date_descr',
580 'date_descr_lang'
581 );
582 $this->setTagsForLangStringSubElements(
583 $annotation->getSubElement('description'),
584 'annotation',
585 'description',
586 'description_language'
587 );
588 }
589
590 protected function setTagsForClassification(
592 ): void {
593 $this->addTagToElement(
594 $this->tag_factory->containerWithRowInTable('classification'),
595 $classification = $structure->getRoot()->getSubElement('classification')
596 );
597 $this->setTagsForVocabSubElements(
598 $classification->getSubElement('purpose'),
599 'classification',
600 'purpose',
601 'purpose_src'
602 );
603 $this->addTagToElement(
604 $this->tag_factory->containerWithRowInTable(
605 'taxon_path',
606 'meta_classification'
607 ),
608 $taxon_path = $classification->getSubElement('taxonPath')
609 );
610 $this->setTagsForLangStringSubElements(
611 $taxon_path->getSubElement('source'),
612 'taxon_path',
613 'source',
614 'source_language',
615 'meta_classification'
616 );
617 $this->addTagToElement(
618 $this->tag_factory->containerWithRowInTable(
619 'taxon',
620 'meta_taxon_path'
621 ),
622 $taxon = $taxon_path->getSubElement('taxon')
623 );
624 $this->addTagToElement(
625 $this->tag_factory->data(
626 'taxon',
627 'taxon_id',
628 'meta_taxon_path'
629 ),
630 $taxon->getSubElement('id')
631 );
632 $this->setTagsForLangStringSubElements(
633 $taxon->getSubElement('entry'),
634 'taxon',
635 'taxon',
636 'taxon_language'
637 );
638 $this->setTagsForLangStringSubElements(
639 $classification->getSubElement('description'),
640 'classification',
641 'description',
642 'description_language'
643 );
644 $this->addTagToElement(
645 $this->tag_factory->containerWithRowInTable(
646 'keyword',
647 'meta_classification'
648 ),
649 $keyword = $classification->getSubElement('keyword')
650 );
651 $this->setTagsForLangStringSubElements(
652 $keyword,
653 'keyword',
654 'keyword',
655 'keyword_language',
656 'meta_classification'
657 );
658 }
659
660 protected function setTagsForIdentifier(
662 string $table,
663 string $parent
664 ): void {
665 $this->addTagToElement(
666 $this->tag_factory->containerWithRowInTable(
667 $table,
668 $parent
669 ),
670 $identifier = $element->getSubElement('identifier')
671 );
672 $this->addTagToElement(
673 $this->tag_factory->data(
674 $table,
675 'catalog',
676 $parent
677 ),
678 $identifier->getSubElement('catalog')
679 );
680 $this->addTagToElement(
681 $this->tag_factory->data(
682 $table,
683 'entry',
684 $parent
685 ),
686 $identifier->getSubElement('entry')
687 );
688 }
689
690 protected function setTagsForContribute(
692 string $parent
693 ): void {
694 $this->addTagToElement(
695 $this->tag_factory->containerWithRowInTable(
696 'contribute',
697 $parent
698 ),
699 $contribute = $element->getSubElement('contribute')
700 );
701 $this->setTagsForVocabSubElements(
702 $contribute->getSubElement('role'),
703 'contribute',
704 'role',
705 'role_src',
706 $parent
707 );
708 $this->addTagToElement(
709 $this->tag_factory->dataWithRowInTable(
710 'entity',
711 'entity',
712 'meta_contribute'
713 ),
714 $contribute->getSubElement('entity')
715 );
716 $date = $contribute->getSubElement('date');
717 $this->addTagToElement(
718 $this->tag_factory->data(
719 'contribute',
720 'c_date',
721 $parent
722 ),
723 $date->getSubElement('dateTime')
724 );
725 $this->setTagsForLangStringSubElements(
726 $date->getSubElement('description'),
727 'contribute',
728 'c_date_descr',
729 'descr_lang',
730 $parent
731 );
732 }
733
735 StructureElementInterface $lang_string,
736 string $table,
737 string $field_string,
738 string $field_lang,
739 string $parent = ''
740 ): void {
741 $string_tag = $this->tag_factory->data(
742 $table,
743 $field_string,
744 $parent
745 );
746 $lang_tag = $this->tag_factory->data(
747 $table,
748 $field_lang,
749 $parent
750 );
751 $this->addTagToElement(
752 $string_tag,
753 $lang_string->getSubElement('string')
754 );
755 $this->addTagToElement(
756 $lang_tag,
757 $lang_string->getSubElement('language')
758 );
759 }
760
761 protected function setTagsForVocabSubElements(
763 string $table,
764 string $field_value,
765 string $field_source,
766 string $parent = ''
767 ): void {
768 $value_tag = $this->tag_factory->data(
769 $table,
770 $field_value,
771 $parent
772 );
773 $this->addTagToElement(
774 $value_tag,
775 $vocab->getSubElement('value')
776 );
777 $source_tag = $this->tag_factory->data(
778 $table,
779 $field_source,
780 $parent
781 );
782 $this->addTagToElement(
783 $source_tag,
784 $vocab->getSubElement('source')
785 );
786 }
787}
$vocab
$classification
$technical
$general
SECTIONS.
$structure
TOTAL STRUCTURE.
$annotation
$relation
$rights
$educational
$duration
setTagsForLangStringSubElements(StructureElementInterface $lang_string, string $table, string $field_string, string $field_lang, string $parent='')
setTagsForIdentifier(StructureElementInterface $element, string $table, string $parent)
setTagsForContribute(StructureElementInterface $element, string $parent)
setTagsForVocabSubElements(StructureElementInterface $vocab, string $table, string $field_value, string $field_source, string $parent='')
__construct(TagFactory $tag_factory, PathFactoryInterface $path_factory, NavigatorFactoryInterface $navigator_factory, StructureSetInterface $structure)
addTagToElement(TagInterface $tag, StructureElementInterface $element)
When indices are added, the tag applies only to copies of the element with those indices (beginning w...
NavigatorFactoryInterface $navigator_factory
only needed to instantiate dictionaries, which is done in inheritors
getSubElement(string $name)
Return the first sub-element with the given name, if one exists.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$context
Definition: webdav.php:31