Ejemplo n.º 1
0
    def test_format_search_results(self):
        '''Returns the citation summary for the given recids'''
        req = QueryRequest()
        rsp = SolrQueryResponse()

        message = self.bridge.createMessage('format_search_results') \
                    .setSender('InvenioFormatter') \
                    .setParam('response', rsp) \
                    .setParam('recids', JArray_int(range(0, 93)))
        self.bridge.sendMessage(message)

        result = unicode(rsp.getValues())
        assert 'inv_response' in result
        assert '<p>' in result
        assert 'Average citations per paper:' in result
Ejemplo n.º 2
0
def bigtest_www(message):
    req = SolrQueryRequest.cast_(message.getParam('request'))
    rsp = SolrQueryResponse.cast_(message.getParam('response'))

    params = req.getParams()
    action = params.get("action")

    start = time.time()

    if 'recids' in action:
        size = params.getInt("size", 5000)
        filled = int(params.getInt('filled', 1000).intValue())
        message.setParam('size', size)
        message.setParam('filled', filled)
        message.setParam('action', action)
        bigtest_www(message)
    else:
        help = '''
        action:args:description
        recids_int:@size(int):returns array of integers of the given size
        recids_str:@size(int):returns array of strings of the given size
        recids_hm_strstr:@size(int):returns hashmap of string:string of the given size
        recids_hm_strint:@size(int):returns hashmap of string:int of the given size
        recids_hm_intint:@size(int):returns hashmap of int:int of the given size
        recids_bitset:@size(int) - size of the bitset; @filled(int) - number of elements that are set:returns bit array (uses invenio bitset for the transfer)
        '''
        for line in help.split('\n'):
            rsp.add('python-message', line.strip())


    rsp.add('python-message', 'Python call finished in: %s ms.' % (time.time() - start))
Ejemplo n.º 3
0
def format_search_results(message):
    '''Returns the citation summary for the given recids. This method
    inserts the Invenio formatted citation summary directly into the
    response object
    
    @var message: 
        recids: Java int[]
        req: SolrQueryRequest
        rsp: SolrQueryResponse
    
    '''
    rsp = SolrQueryResponse.cast_(message.getParam('response'))
    
    recids = message.getParamArray_int("recids")
    start = time.time()
    if config.MONTYSOLR_BUGDEBUG:
        message.threadInfo("start: citation_summary")
    c_time = time.time()
    iset = intbitset(recids)
    if config.MONTYSOLR_BUGDEBUG:
        message.threadInfo("int[] converted to intbitset in: %s, size=%s" % (time.time() - c_time, len(iset)))
    (wid, (output)) = api_calls.dispatch('citation_summary', iset, 'hcs', 'en', '', '')
    if config.MONTYSOLR_BUGDEBUG:
        message.threadInfo("end: citation_summary pid=%s, finished in %s" % (wid, time.time() - start))
    rsp.add("inv_response", output)
Ejemplo n.º 4
0
def handle_request_body(message):
    rsp = SolrQueryResponse.cast_(message.getParam("rsp"))
    rsp.add("python", 'says hello!')