Revision 58515
Added by Sandro La Bruzzo about 3 years ago
modules/dli-api/branches/ES_7/v1/responseModel.py | ||
---|---|---|
7 | 7 |
|
8 | 8 |
|
9 | 9 |
|
10 |
|
|
10 | 11 |
class LinkProvider(BaseModel): |
11 | 12 |
name:str = Schema(None, title= "The name of the Provider that provides the links", max_length= 300) |
12 | 13 |
totalRelationships:int=Schema(None, title= "The number of links that It provides") |
... | ... | |
54 | 55 |
target:ScholixItemType=None |
55 | 56 |
|
56 | 57 |
def convert_response(response): |
57 |
log = logging.getLogger("scholexplorer") |
|
58 |
log = logging.getLogger("scholexplorer")
|
|
58 | 59 |
for item in response.hits: |
59 |
result = item.__dict__['_d_'] |
|
60 |
result = item.__dict__['_d_']
|
|
60 | 61 |
result['linkProvider'] = result.pop('linkprovider') |
61 | 62 |
if 'creator' in result['source']: |
62 | 63 |
result['source']['creators']=result['source'].pop('creator') |
... | ... | |
72 | 73 |
result['target']['creators']=result['target'].pop('creator') |
73 | 74 |
result['target'].pop('objectSubType') |
74 | 75 |
result['target']['identifiers']=result['target'].pop('identifier') |
75 |
if result['target']['publisher'] is not None:
|
|
76 |
if result['target'].get('publisher') is not None:
|
|
76 | 77 |
result['target']['publisher'] = [x for x in result['target']['publisher'] if x.get('name') is not None] |
77 |
if 'collectedFrom' in result['target']:
|
|
78 |
if result['target'].get('collectedFrom') is not None:
|
|
78 | 79 |
result['target']['objectProvider'] = [s['provider'] for s in result['target'].get('collectedFrom',[])] |
79 | 80 |
else: |
80 | 81 |
result['target']['objectProvider'] = [] |
modules/dli-api/branches/ES_7/eu/dnetlib/ScholixConnector.py | ||
---|---|---|
125 | 125 |
q = q & item |
126 | 126 |
log.debug("REQUEST CREATED {}".format(q)) |
127 | 127 |
search_object = Search(using=self.connection_pool.get_connection(), index=self.index_name).doc_type('scholix').query(q) |
128 |
print (search_object.to_dict()) |
|
128 | 129 |
log.debug("Page request size is {}".format(page)) |
129 | 130 |
if page > 9999: |
130 | 131 |
return [] |
Also available in: Unified diff
fixed npe