//---------------------------------------------------------------------- void EventTemplateDefinitionResource:: init(GroupConfigurationStructure& unitConfiguration, Manager* manager) { LOGINIT("LP::EventAnalysis"); m_language=manager->getInitializationParameters().language; string resourcesPath=Common::MediaticData::MediaticData::single().getResourcesPath(); EventTemplateStructure structure; // get name try { string name = unitConfiguration.getParamsValueAtKey("templateName"); structure.setName(name); } catch (NoSuchParam& ) { LERROR << "No param 'templateName' in EventTemplateDefinitionResource for language " << (int)m_language; throw InvalidConfiguration(); } // get template elements: role and entity types try { map<string,string> elts = unitConfiguration.getMapAtKey("templateElements"); for(map<string,string>::const_iterator it=elts.begin(),it_end=elts.end();it!=it_end;it++) { structure.addTemplateElement((*it).first,(*it).second); } } catch (NoSuchParam& ) { LERROR << "No param 'templateName' in EventTemplateDefinition for language " << (int)m_language; throw InvalidConfiguration(); } // get element mapping, for template merging try { map<string,string> mapping = unitConfiguration.getMapAtKey("elementMapping"); for(map<string,string>::const_iterator it=mapping.begin(),it_end=mapping.end();it!=it_end;it++) { const std::string& elements=(*it).second; // comma-separated list of elements boost::char_separator<char> sep(",; "); boost::tokenizer<boost::char_separator<char> > tok(elements,sep); for(boost::tokenizer<boost::char_separator<char> >::iterator e=tok.begin(),e_end=tok.end(); e!=e_end;e++) { LDEBUG << "EventTemplateDefinitionResource: add mapping " << (*it).first << ":" << *e; m_elementMapping[(*it).first].insert(*e); } } } catch (NoSuchParam& ) { LDEBUG << "No param 'elementMapping' in EventTemplateDefinition for language " << (int)m_language; } m_templates.push_back(structure); }
//---------------------------------------------------------------------- void EventTemplateDefinitionResource:: init(GroupConfigurationStructure& unitConfiguration, Manager* manager) { LOGINIT("LP::EventAnalysis"); m_language=manager->getInitializationParameters().language; EventTemplateStructure structure; // get name try { string name = unitConfiguration.getParamsValueAtKey("templateName"); structure.setName(name); LDEBUG << "Template name = "<< name; } catch (NoSuchParam& ) { LERROR << "No param 'templateName' in EventTemplateDefinitionResource for language " << (int)m_language; throw InvalidConfiguration(); } try{ string nameMention = unitConfiguration.getParamsValueAtKey("templateMention"); LDEBUG << "Template mention = "<< nameMention; structure.setMention(nameMention); } catch (NoSuchParam& ) { LERROR << "No param 'templateMention' in EventTemplateDefinitionResource for language " << (int)m_language; //throw InvalidConfiguration(); } // get template elements: role and entity types try { map<string,string> elts = unitConfiguration.getMapAtKey("templateElements"); LDEBUG << "templateElements .size " << elts.size(); for(auto it=elts.begin(),it_end=elts.end();it!=it_end;it++) { LDEBUG << "templateElement =" << (*it).first; structure.addTemplateElement((*it).first,(*it).second); } } catch (NoSuchParam& ) { LERROR << "No param 'templateName' in EventTemplateDefinition for language " << (int)m_language; throw InvalidConfiguration(); } // get element mapping, for template merging LDEBUG << "get elementMapping "; try { map<string,string> mapping = unitConfiguration.getMapAtKey("elementMapping"); LDEBUG << "after Getting map "; for(auto it=mapping.cbegin(),it_end=mapping.cend();it!=it_end;it++) { const std::string& elements=(*it).second; // comma-separated list of elements boost::char_separator<char> sep(",; "); boost::tokenizer<boost::char_separator<char> > tok(elements,sep); for(auto e=tok.begin(),e_end=tok.end(); e!=e_end;e++) { LDEBUG << "EventTemplateDefinitionResource: add mapping " << (*it).first << ":" << *e; m_elementMapping[(*it).first].insert(*e); } } } catch (NoSuchMap& ) { LDEBUG << "No param 'elementMapping' in EventTemplateDefinition for language " << (int)m_language; } LDEBUG << "Adding Structure "; m_templates.push_back(structure); }