def perform_request_knowledge_base_show(kb_id, ln=CFG_SITE_LANG, sortby="to", startat=0, search_term=""): """ Show the content of a knowledge base @param ln language @param kb a knowledge base id @param sortby the sorting criteria ('from' or 'to') @param startat start showing mapping rules at what number @param search_term search for this string in kb @return the content of the given knowledge base """ name = bibknowledge_dblayer.get_kb_name(kb_id) mappings = bibknowledge_dblayer.get_kb_mappings(name, sortby) kb_type = bibknowledge_dblayer.get_kb_type(kb_id) #filter in only the requested rules if the user is searching.. if search_term: newmappings = [] for mapping in mappings: key = mapping['key'] value = mapping['value'] if key.count(search_term)> 0 or value.count(search_term)> 0: newmappings.append(mapping) #we were searching, so replace mappings = newmappings #if this bk is dynamic, get the configuration from the DB dyn_config = None if kb_type == 'd': dyn_config = bibknowledge_dblayer.get_kb_dyn_config(kb_id) return bibknowledge_templates.tmpl_admin_kb_show(ln, kb_id, name, mappings, sortby, startat, kb_type, search_term, dyn_config)
def perform_request_knowledge_base_show_dependencies(kb_id, ln=CFG_SITE_LANG, sortby="to"): """ Show the dependencies of a kb @param ln language @param kb a knowledge base id @param sortby the sorting criteria ('from' or 'to') @return the dependencies of the given knowledge base """ name = bibknowledge_dblayer.get_kb_name(kb_id) format_elements = bibknowledge.get_elements_that_use_kb(name) return bibknowledge_templates.tmpl_admin_kb_show_dependencies(ln, kb_id, name, sortby, format_elements)
def perform_request_knowledge_base_show_attributes(kb_id, ln=CFG_SITE_LANG, sortby="to"): """ Show the attributes of a knowledge base @param ln language @param kb a knowledge base id @param sortby the sorting criteria ('from' or 'to') @return the content of the given knowledge base """ name = bibknowledge_dblayer.get_kb_name(kb_id) description = bibknowledge_dblayer.get_kb_description(name) kb_type = bibknowledge_dblayer.get_kb_type(name) return bibknowledge_templates.tmpl_admin_kb_show_attributes(ln, kb_id, name, description, sortby, kb_type)
def perform_request_knowledge_base_show_dependencies(kb_id, ln=CFG_SITE_LANG, sortby="to"): """ Show the dependencies of a kb @param ln language @param kb a knowledge base id @param sortby the sorting criteria ('from' or 'to') @return the dependencies of the given knowledge base """ name = bibknowledge_dblayer.get_kb_name(kb_id) format_elements = bibknowledge.get_elements_that_use_kb(name) return bibknowledge_templates.tmpl_admin_kb_show_dependencies( ln, kb_id, name, sortby, format_elements)
def perform_request_knowledge_base_show_attributes(kb_id, ln=CFG_SITE_LANG, sortby="to"): """ Show the attributes of a knowledge base @param ln language @param kb a knowledge base id @param sortby the sorting criteria ('from' or 'to') @return the content of the given knowledge base """ name = bibknowledge_dblayer.get_kb_name(kb_id) description = bibknowledge_dblayer.get_kb_description(name) kb_type = bibknowledge_dblayer.get_kb_type(name) return bibknowledge_templates.tmpl_admin_kb_show_attributes( ln, kb_id, name, description, sortby, kb_type)
def perform_request_knowledge_base_show(kb_id, ln=CFG_SITE_LANG, sortby="to", startat=0, search_term=""): """ Show the content of a knowledge base @param ln language @param kb a knowledge base id @param sortby the sorting criteria ('from' or 'to') @param startat start showing mapping rules at what number @param search_term search for this string in kb @return the content of the given knowledge base """ name = bibknowledge_dblayer.get_kb_name(kb_id) mappings = bibknowledge_dblayer.get_kb_mappings(name, sortby) kb_type = bibknowledge_dblayer.get_kb_type(kb_id) #filter in only the requested rules if the user is searching.. if search_term: newmappings = [] for mapping in mappings: key = mapping['key'] value = mapping['value'] if key.count(search_term) > 0 or value.count(search_term) > 0: newmappings.append(mapping) #we were searching, so replace mappings = newmappings #if this bk is dynamic, get the configuration from the DB, and a list of #collections as a bonus dyn_config = None collections = None if kb_type == 'd': from invenio.search_engine import get_alphabetically_ordered_collection_list dyn_config = bibknowledge_dblayer.get_kb_dyn_config(kb_id) collections = [] collitems = get_alphabetically_ordered_collection_list() for collitem in collitems: collections.append(collitem[0]) return bibknowledge_templates.tmpl_admin_kb_show(ln, kb_id, name, mappings, sortby, startat, kb_type, search_term, dyn_config, collections)
def get_kb_name(kb_id): """ Returns the name of the kb given by id @param kb_id: the id of the knowledge base """ return bibknowledge_dblayer.get_kb_name(kb_id)