/**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     $role_folder_id = $a_mapping->getMapping('Services/AccessControl', 'rolf', 0);
     include_once './Services/AccessControl/classes/class.ilRoleXmlImporter.php';
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $importer = new ilRoleXmlImporter($role_folder_id);
     $importer->setXml($a_xml);
     $importer->setRole(new ilObjRole());
     $importer->import();
 }
 /**
  * Parse template action from xml
  * @param ilDidacticTemplateSetting $set
  * @param SimpleXMLElement $root
  * @return void
  */
 protected function parseActions(ilDidacticTemplateSetting $set, SimpleXMLElement $actions = NULL)
 {
     include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
     if ($actions === NULL) {
         return void;
     }
     ////////////////////////////////////////////////
     // Local role action
     ///////////////////////////////////////////////
     foreach ($actions->localRoleAction as $ele) {
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalRoleAction.php';
         $act = new ilDidacticTemplateLocalRoleAction();
         $act->setTemplateId($set->getId());
         foreach ($ele->roleTemplate as $tpl) {
             // extract role
             foreach ($tpl->role as $roleDef) {
                 include_once './Services/AccessControl/classes/class.ilRoleXmlImporter.php';
                 $rimporter = new ilRoleXmlImporter(ROLE_FOLDER_ID);
                 $role_id = $rimporter->importSimpleXml($roleDef);
                 $act->setRoleTemplateId($role_id);
             }
             $act->save();
         }
     }
     ////////////////////////////////////////////////
     // Block role action
     //////////////////////////////////////////////
     foreach ($actions->blockRoleAction as $ele) {
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateBlockRoleAction.php';
         $act = new ilDidacticTemplateBlockRoleAction();
         $act->setTemplateId($set->getId());
         // Role filter
         foreach ($ele->roleFilter as $rfi) {
             $act->setFilterType((string) $rfi->attributes()->source);
             foreach ($rfi->includePattern as $pat) {
                 // @TODO other subtypes
                 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
                 $pattern = new ilDidacticTemplateIncludeFilterPattern();
                 $pattern->setPatternSubType(ilDidacticTemplateFilterPattern::PATTERN_SUBTYPE_REGEX);
                 $pattern->setPattern((string) $pat->attributes()->preg);
                 $act->addFilterPattern($pattern);
             }
             foreach ($rfi->excludePattern as $pat) {
                 // @TODO other subtypes
                 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
                 $pattern = new ilDidacticTemplateExcludeFilterPattern();
                 $pattern->setPatternSubType(ilDidacticTemplateFilterPattern::PATTERN_SUBTYPE_REGEX);
                 $pattern->setPattern((string) $pat->attributes()->preg);
                 $act->addFilterPattern($pattern);
             }
         }
         $act->save();
     }
     ////////////////////////////////////////////
     // Local policy action
     /////////////////////////////////////////////
     foreach ($actions->localPolicyAction as $ele) {
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalPolicyAction.php';
         $act = new ilDidacticTemplateLocalPolicyAction();
         $act->setTemplateId($set->getId());
         // Role filter
         foreach ($ele->roleFilter as $rfi) {
             $act->setFilterType((string) $rfi->attributes()->source);
             foreach ($rfi->includePattern as $pat) {
                 // @TODO other subtypes
                 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
                 $pattern = new ilDidacticTemplateIncludeFilterPattern();
                 $pattern->setPatternSubType(ilDidacticTemplateFilterPattern::PATTERN_SUBTYPE_REGEX);
                 $pattern->setPattern((string) $pat->attributes()->preg);
                 $act->addFilterPattern($pattern);
             }
             foreach ($rfi->excludePattern as $pat) {
                 // @TODO other subtypes
                 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
                 $pattern = new ilDidacticTemplateExcludeFilterPattern();
                 $pattern->setPatternSubType(ilDidacticTemplateFilterPattern::PATTERN_SUBTYPE_REGEX);
                 $pattern->setPattern((string) $pat->attributes()->preg);
                 $act->addFilterPattern($pattern);
             }
         }
         // role template assignment
         foreach ($ele->localPolicyTemplate as $lpo) {
             $act->setFilterType(ilDidacticTemplateLocalPolicyAction::FILTER_SOURCE_TITLE);
             switch ((string) $lpo->attributes()->type) {
                 case 'overwrite':
                     $act->setRoleTemplateType(ilDidacticTemplateLocalPolicyAction::TPL_ACTION_OVERWRITE);
                     break;
                 case 'union':
                     $act->setRoleTemplateType(ilDidacticTemplateLocalPolicyAction::TPL_ACTION_UNION);
                     break;
                 case 'intersect':
                     $act->setRoleTemplateType(ilDidacticTemplateLocalPolicyAction::TPL_ACTION_INTERSECT);
                     break;
             }
             // extract role
             foreach ($lpo->role as $roleDef) {
                 include_once './Services/AccessControl/classes/class.ilRoleXmlImporter.php';
                 $rimporter = new ilRoleXmlImporter(ROLE_FOLDER_ID);
                 $role_id = $rimporter->importSimpleXml($roleDef);
                 $act->setRoleTemplateId($role_id);
             }
         }
         // Save action including all filter patterns
         $act->save();
     }
 }