Esempio n. 1
0
def get_kbd_values_for_bibedit(tag, collection="", searchwith="", expression=""):
    """
    Dynamically create a dynamic KB for a specific search; search; then destroy it.

    This probably isn't the method you want.

    Example1: tag=100__a : return values of 100__a
    Example2: tag=100__a, searchwith=Jill: return values of 100__a that match with Jill
    Example3: tag=100__a, searchwith=Ellis, expression="700__a:*%*: return values of
              100__a for which Ellis matches some 700__a

    Note: the performace of this function is ok compared to a plain
          perform_request_search / get most popular fields -pair. The overhead
          is about 5% with large record sets; the lookups are the xpensive part.

    @param tag:        the tag like 100__a
    @param collection: collection id
    @param searchwith: the string to search. If empty, match all.
    @param expression: the search expression for perform_request_search; if
                       present, '%' is substituted with /searcwith/.  If absent,
                       /searchwith/ is searched for in /tag/.
    """
    dkbname = "tmp_dynamic_"+tag+'_'+expression
    kb_id = add_kb(kb_name=dkbname, kb_type='dynamic')
    #get the kb name since it may be catenated by a number
    #in case there are concurrent calls.
    kb_name = get_kb_name(kb_id)
    bibknowledge_dblayer.save_kb_dyn_config(kb_id, tag, expression, collection)
    #now, get stuff
    myvalues = get_kbd_values(kb_name, searchwith)
    #the tmp dyn kb is now useless, delete it
    delete_kb(kb_name)
    return myvalues
Esempio n. 2
0
def get_kbd_values_for_bibedit(tag, collection="", searchwith="", expression=""):
    """
    Dynamically create a dynamic KB for a specific search; search; then destroy it.

    This probably isn't the method you want.

    Example1: tag=100__a : return values of 100__a
    Example2: tag=100__a, searchwith=Jill: return values of 100__a that match with Jill
    Example3: tag=100__a, searchwith=Ellis, expression="700__a:*%*: return values of
              100__a for which Ellis matches some 700__a

    Note: the performace of this function is ok compared to a plain
          perform_request_search / get most popular fields -pair. The overhead
          is about 5% with large record sets; the lookups are the xpensive part.

    @param tag:        the tag like 100__a
    @param collection: collection id
    @param searchwith: the string to search. If empty, match all.
    @param expression: the search expression for perform_request_search; if
                       present, '%' is substituted with /searcwith/.  If absent,
                       /searchwith/ is searched for in /tag/.
    """
    dkbname = "tmp_dynamic_"+tag+'_'+expression
    kb_id = add_kb(kb_name=dkbname, kb_type='dynamic')
    #get the kb name since it may be catenated by a number
    #in case there are concurrent calls.
    kb_name = get_kb_name(kb_id)
    bibknowledge_dblayer.save_kb_dyn_config(kb_id, tag, expression, collection)
    #now, get stuff
    myvalues = get_kbd_values(kb_name, searchwith)
    #the tmp dyn kb is now useless, delete it
    delete_kb(kb_name)
    return myvalues
def perform_update_kb_config(kb_id, field, expression, collection):
    """
    Updates config by calling a db function.
    Parameters:
    @param kb_id knowledge base id
    @param field field configured to be used
    @param expression search expression
    @param collection search in this collection
    """
    #this will complain if the collection does not exist
    return bibknowledge_dblayer.save_kb_dyn_config(kb_id, field, expression, collection)
Esempio n. 4
0
def get_kbd_values_for_bibedit(tag, collection="", searchwith=""):
    """
    A specific convenience method: based on a tag and collection, create a temporary dynamic knowledge base
    a return its values.
    Note: the performace of this function is ok compared to a plain
    perform req search / get most popular fields -pair. The overhead is about 5% with large record sets.
    @param tag: the tag like 100__a
    @param collection: collection id
    @param searchwith: the string to search. If empty, match all.
    """
    kb_id = add_kb(kb_name="tmp_dynamic", kb_type='dynamic')
    #get the kb name since it may be catenated by a number
    #in case there are concurrent calls.
    kb_name = get_kb_name(kb_id)
    bibknowledge_dblayer.save_kb_dyn_config(kb_id, tag, collection, searchwith)
    #now, get stuff
    myvalues = get_kbd_values(kb_name, searchwith)
    #the tmp dyn kb is now useless, delete it
    delete_kb(kb_name)
    return myvalues
Esempio n. 5
0
def get_kbd_values_for_bibedit(tag, collection="", searchwith=""):
    """
    A specific convenience method: based on a tag and collection, create a temporary dynamic knowledge base
    a return its values.
    Note: the performace of this function is ok compared to a plain
    perform req search / get most popular fields -pair. The overhead is about 5% with large record sets.
    @param tag: the tag like 100__a
    @param collection: collection id
    @param searchwith: the string to search. If empty, match all.
    """
    kb_id = add_kb(kb_name="tmp_dynamic", kb_type='dynamic')
    #get the kb name since it may be catenated by a number
    #in case there are concurrent calls.
    kb_name = get_kb_name(kb_id)
    bibknowledge_dblayer.save_kb_dyn_config(kb_id, tag, collection, searchwith)
    #now, get stuff
    myvalues = get_kbd_values(kb_name, searchwith)
    #the tmp dyn kb is now useless, delete it
    delete_kb(kb_name)
    return myvalues
Esempio n. 6
0
def perform_update_kb_config(kb_id, field, expression, collection):
    """
    Updates config by calling a db function.
    Parameters:
    @param kb_id knowledge base id
    @param field field configured to be used
    @param expression search expression
    @param collection search in this collection
    """
    #this will complain if the collection does not exist
    return bibknowledge_dblayer.save_kb_dyn_config(kb_id, field, expression,
                                                   collection)
Esempio n. 7
0
def add_dynamic_kb(kbname, tag, collection="", searchwith=""):
    """A convenience method"""
    kb_id = add_kb(kb_name=kbname, kb_type='dynamic')
    bibknowledge_dblayer.save_kb_dyn_config(kb_id, tag, searchwith, collection)
    return kb_id
Esempio n. 8
0
def add_dynamic_kb(kbname, tag, collection="", searchwith=""):
    """A convenience method"""
    kb_id = add_kb(kb_name=kbname, kb_type='dynamic')
    bibknowledge_dblayer.save_kb_dyn_config(kb_id, tag, searchwith, collection)
    return kb_id