Commit b05e154d authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

EditAndLoad works with the run_all harvester.

parent 7ecfeb8c
...@@ -313,16 +313,13 @@ def run_all(): ...@@ -313,16 +313,13 @@ def run_all():
msg += '<hr/>' msg += '<hr/>'
return msg return msg
# tune harvester / selector parameters used in the report title # tune selector parameters used in the report title
harvester = Storage(controller='all harvesters',
collections=','.join(collections))
if query == None: if query == None:
selector.id_projects = None selector.id_projects = None
# delegate rendering to the report view # delegate rendering to the report view
response.view = 'harvest/layout.%s' % request.extension response.view = 'harvest/layout.%s' % request.extension
return dict(collection_logs=collection_logs, return dict(collection_logs=collection_logs,
harvester=harvester, controller='all harvesters',
logs=logs, logs=logs,
selector=selector) selector=selector)
...@@ -255,13 +255,43 @@ class Msg(Storage): ...@@ -255,13 +255,43 @@ class Msg(Storage):
- C{action}: action taken - C{action}: action taken
- C{collection}: the harvester collection - C{collection}: the harvester collection
- C{url}: URL used to access to the record in the store - C{harvester}: the harvester encoded as a JSON string
- C{record_id}; the store identifier of the record
- C{title}: title of the publication - C{title}: title of the publication
- C{txt}: text of the message - C{txt}: text of the message
- C{url}: url of the record
- C{year}: year of the publication - C{year}: year of the publication
""" """
def __init__(self,
collection=None,
harvester=None,
record_id=None,
title=None):
"""
@type collection: str
@param collection: the collection containing the record
@type harvester: gluon.dal.Row
@param harvester: the current harvester used to retrieve the record.
@type record_id: int
@param record_id: the store identifier of the record
@type title: str
@param title: the title associated to the record
"""
self.action = None
self.collection = collection
self.harvester = json.dumps(harvester.as_dict())
self.record_id = record_id
self.title = title
self.txt = None
self.url = OAI_URL % (harvester.host, record_id)
self.year = None
def idle(self, txt, year=None): def idle(self, txt, year=None):
"""Set the action as idle and the message as C{txt}. """Set the action as idle and the message as C{txt}.
...@@ -751,9 +781,10 @@ class PublicationsTool(object): ...@@ -751,9 +781,10 @@ class PublicationsTool(object):
except BaseException as e: except BaseException as e:
url = OAI_URL % (self.harvester.host, id) url = OAI_URL % (self.harvester.host, id)
self.logs.append(Msg(url=url)) self.logs.append(Msg(harvester=self.harvester,
self.logs[-1].title = url collection=title,
self.logs[-1].collection = title record_id=id,
title = url))
self.logs[-1].reject(e) self.logs[-1].reject(e)
...@@ -778,10 +809,10 @@ class PublicationsTool(object): ...@@ -778,10 +809,10 @@ class PublicationsTool(object):
print "record decoded" print "record decoded"
# start the log for the record # start the log for the record
url = OAI_URL % (self.harvester.host, record.id()) self.logs.append(Msg(harvester=self.harvester,
self.logs.append(Msg(url=url)) collection=self.collection_logs[-1].title,
self.logs[-1].title = record.title() record_id=record.id(),
self.logs[-1].collection = self.collection_logs[-1].title title=record.title()))
# additional selection stage # additional selection stage
# at this step the validity of the record is checked # at this step the validity of the record is checked
...@@ -804,17 +835,15 @@ class PublicationsTool(object): ...@@ -804,17 +835,15 @@ class PublicationsTool(object):
@rtype: dict @rtype: dict
@return: @return:
- C{cfg_statStore} (str) configuration of the statStore JSON encoded
- C{cfg_logsStore} (str) configuration of the logsStore JSON encoded
- C{collection_logs} (list) one L{MsgCollection}) for each collection - C{collection_logs} (list) one L{MsgCollection}) for each collection
- C{harvester} (Storage) - C{controller} (str)
- C{logs} (list) one L{Msg} for each publication - C{logs} (list) one L{Msg} for each publication
- C{selector} (Selector) - C{selector} (Selector)
""" """
return dict(collection_logs=self.collection_logs, return dict(collection_logs=self.collection_logs,
harvester=self.harvester, controller=self.harvester.controller,
logs=self.logs, logs=self.logs,
selector=self.selector) selector=self.selector)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# The python controller return: # The python controller return:
# - collection_logs (list of MsgCollection) one for each collection # - collection_logs (list of MsgCollection) one for each collection
# - harvester (Storage/Row) # - controller (String) harvester controller
# - logs (list of MSg) one for each publication # - logs (list of MSg) one for each publication
# - selector (Selector) # - selector (Selector)
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
...@@ -74,6 +74,8 @@ ...@@ -74,6 +74,8 @@
cfg['fields'] = [{'name': 'action', 'type': 'string'}, cfg['fields'] = [{'name': 'action', 'type': 'string'},
{'name': 'collection', 'type': 'string'}, {'name': 'collection', 'type': 'string'},
{'name': 'harvester', 'type': 'string'},
{'name': 'record_id', 'type': 'string'},
{'name': 'title', 'type': 'string'}, {'name': 'title', 'type': 'string'},
{'name': 'txt', 'type': 'string'}, {'name': 'txt', 'type': 'string'},
{'name': 'url', 'type': 'string'}, {'name': 'url', 'type': 'string'},
...@@ -83,6 +85,8 @@ ...@@ -83,6 +85,8 @@
for row in logs: for row in logs:
cfg['data'].append([row.action, cfg['data'].append([row.action,
row.collection, row.collection,
row.harvester,
row.record_id,
row.title, row.title,
row.txt, row.txt,
row.url, row.url,
...@@ -108,7 +112,7 @@ ...@@ -108,7 +112,7 @@
project = db.projects[selector.id_projects].project project = db.projects[selector.id_projects].project
pass pass
title = "%s %s %s" % (harvester.controller.title(), project, period) title = "%s %s %s" % (controller.title(), project, period)
style = ["font-size: 12px;", style = ["font-size: 12px;",
"font-variant: small-caps;", "font-variant: small-caps;",
...@@ -140,14 +144,6 @@ ...@@ -140,14 +144,6 @@
response.write(P(delta, _style="".join(style))) response.write(P(delta, _style="".join(style)))
#
# convert the harvester
# either Storage (run_all) or a Row depending on the controller
#
if isinstance(harvester, gluon.dal.Row):
harvester = harvester.as_dict()
pass
# #
# Export python variables to the javascript # Export python variables to the javascript
# #
...@@ -157,7 +153,6 @@ ...@@ -157,7 +153,6 @@
"divlogs = '%s'" % divlogs, "divlogs = '%s'" % divlogs,
"gridStat", "gridStat",
"gridLog", "gridLog",
"harvester = %s" % json.dumps(harvester),
"menu", "menu",
"trAction = '%s'" % T('Action'), "trAction = '%s'" % T('Action'),
"trAdded = '%s'" % T('Added'), "trAdded = '%s'" % T('Added'),
...@@ -189,7 +184,8 @@ ...@@ -189,7 +184,8 @@
"use strict"; "use strict";
var li, var harvester,
li,
mask, mask,
record = this.gridLog.getSelectionModel().getSelection()[0], record = this.gridLog.getSelectionModel().getSelection()[0],
record_id; record_id;
...@@ -206,10 +202,8 @@ ...@@ -206,10 +202,8 @@
}); });
mask.show(); mask.show();
// extract the record identifier from the publication URL // extract the harvester used to retrieve this record
// e.g "http://cds.cern.ch/record/1692474" harvester = JSON.parse(record.get('harvester'));
li = record.get('url').split("/");
record_id = li[li.length - 1];
// launch the EditAndInsert wizard using a loader // launch the EditAndInsert wizard using a loader
// NOTE 141112: the success function is used to remove the mask // NOTE 141112: the success function is used to remove the mask
...@@ -218,12 +212,12 @@ ...@@ -218,12 +212,12 @@
loader: { loader: {
url: 'harvest/edit_insert', url: 'harvest/edit_insert',
params: { params: {
Edit_insert_selectorId_teams: this.harvester.id_teams, Edit_insert_selectorId_teams: harvester.id_teams,
Edit_insert_selectorId_projects: this.harvester.id_projects, Edit_insert_selectorId_projects: harvester.id_projects,
Edit_insert_selectorHost: this.harvester.host, Edit_insert_selectorHost: harvester.host,
Edit_insert_selectorRecord_id: record_id, Edit_insert_selectorRecord_id: record.get('record_id'),
Edit_insert_selectorController: this.harvester.controller, Edit_insert_selectorController: harvester.controller,
Edit_insert_selectorId_categories: this.harvester.id_categories Edit_insert_selectorId_categories: harvester.id_categories
}, },
autoLoad: true, autoLoad: true,
failure: function () { failure: function () {
...@@ -328,7 +322,9 @@ ...@@ -328,7 +322,9 @@
{text: trAction, dataIndex: 'action', flex: 1, hidden: true}, {text: trAction, dataIndex: 'action', flex: 1, hidden: true},
{text: trTxt, dataIndex: 'txt', flex: 1, hidden: true}, {text: trTxt, dataIndex: 'txt', flex: 1, hidden: true},
{text: trCollection, dataIndex: 'collection', flex: 1, hidden: true}, {text: trCollection, dataIndex: 'collection', flex: 1, hidden: true},
{text: trYear, dataIndex: 'year', flex: 1, hidden: true} {text: trYear, dataIndex: 'year', flex: 1, hidden: true},
{text: 'harvester', dataIndex: 'harvester', flex: 1, hidden: true},
{text: 'record_id', dataIndex: 'record_id', flex: 1, hidden: true}
], ],
features: [ features: [
{ftype:'grouping', groupHeaderTpl: '{name}', startCollapsed: true} {ftype:'grouping', groupHeaderTpl: '{name}', startCollapsed: true}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment