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():
msg += '<hr/>'
return msg
# tune harvester / selector parameters used in the report title
harvester = Storage(controller='all harvesters',
collections=','.join(collections))
# tune selector parameters used in the report title
if query == None:
selector.id_projects = None
# delegate rendering to the report view
response.view = 'harvest/layout.%s' % request.extension
return dict(collection_logs=collection_logs,
harvester=harvester,
controller='all harvesters',
logs=logs,
selector=selector)
......@@ -255,13 +255,43 @@ class Msg(Storage):
- C{action}: action taken
- 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{txt}: text of the message
- C{url}: url of the record
- 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):
"""Set the action as idle and the message as C{txt}.
......@@ -751,9 +781,10 @@ class PublicationsTool(object):
except BaseException as e:
url = OAI_URL % (self.harvester.host, id)
self.logs.append(Msg(url=url))
self.logs[-1].title = url
self.logs[-1].collection = title
self.logs.append(Msg(harvester=self.harvester,
collection=title,
record_id=id,
title = url))
self.logs[-1].reject(e)
......@@ -778,10 +809,10 @@ class PublicationsTool(object):
print "record decoded"
# start the log for the record
url = OAI_URL % (self.harvester.host, record.id())
self.logs.append(Msg(url=url))
self.logs[-1].title = record.title()
self.logs[-1].collection = self.collection_logs[-1].title
self.logs.append(Msg(harvester=self.harvester,
collection=self.collection_logs[-1].title,
record_id=record.id(),
title=record.title()))
# additional selection stage
# at this step the validity of the record is checked
......@@ -804,17 +835,15 @@ class PublicationsTool(object):
@rtype: dict
@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{harvester} (Storage)
- C{controller} (str)
- C{logs} (list) one L{Msg} for each publication
- C{selector} (Selector)
"""
return dict(collection_logs=self.collection_logs,
harvester=self.harvester,
controller=self.harvester.controller,
logs=self.logs,
selector=self.selector)
......
......@@ -3,7 +3,7 @@
#--------------------------------------------------------------------------
# The python controller return:
# - collection_logs (list of MsgCollection) one for each collection
# - harvester (Storage/Row)
# - controller (String) harvester controller
# - logs (list of MSg) one for each publication
# - selector (Selector)
#--------------------------------------------------------------------------
......@@ -74,6 +74,8 @@
cfg['fields'] = [{'name': 'action', 'type': 'string'},
{'name': 'collection', 'type': 'string'},
{'name': 'harvester', 'type': 'string'},
{'name': 'record_id', 'type': 'string'},
{'name': 'title', 'type': 'string'},
{'name': 'txt', 'type': 'string'},
{'name': 'url', 'type': 'string'},
......@@ -83,6 +85,8 @@
for row in logs:
cfg['data'].append([row.action,
row.collection,
row.harvester,
row.record_id,
row.title,
row.txt,
row.url,
......@@ -108,7 +112,7 @@
project = db.projects[selector.id_projects].project
pass
title = "%s %s %s" % (harvester.controller.title(), project, period)
title = "%s %s %s" % (controller.title(), project, period)
style = ["font-size: 12px;",
"font-variant: small-caps;",
......@@ -140,14 +144,6 @@
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
#
......@@ -157,7 +153,6 @@
"divlogs = '%s'" % divlogs,
"gridStat",
"gridLog",
"harvester = %s" % json.dumps(harvester),
"menu",
"trAction = '%s'" % T('Action'),
"trAdded = '%s'" % T('Added'),
......@@ -189,7 +184,8 @@
"use strict";
var li,
var harvester,
li,
mask,
record = this.gridLog.getSelectionModel().getSelection()[0],
record_id;
......@@ -206,10 +202,8 @@
});
mask.show();
// extract the record identifier from the publication URL
// e.g "http://cds.cern.ch/record/1692474"
li = record.get('url').split("/");
record_id = li[li.length - 1];
// extract the harvester used to retrieve this record
harvester = JSON.parse(record.get('harvester'));
// launch the EditAndInsert wizard using a loader
// NOTE 141112: the success function is used to remove the mask
......@@ -218,12 +212,12 @@
loader: {
url: 'harvest/edit_insert',
params: {
Edit_insert_selectorId_teams: this.harvester.id_teams,
Edit_insert_selectorId_projects: this.harvester.id_projects,
Edit_insert_selectorHost: this.harvester.host,
Edit_insert_selectorRecord_id: record_id,
Edit_insert_selectorController: this.harvester.controller,
Edit_insert_selectorId_categories: this.harvester.id_categories
Edit_insert_selectorId_teams: harvester.id_teams,
Edit_insert_selectorId_projects: harvester.id_projects,
Edit_insert_selectorHost: harvester.host,
Edit_insert_selectorRecord_id: record.get('record_id'),
Edit_insert_selectorController: harvester.controller,
Edit_insert_selectorId_categories: harvester.id_categories
},
autoLoad: true,
failure: function () {
......@@ -328,7 +322,9 @@
{text: trAction, dataIndex: 'action', flex: 1, hidden: true},
{text: trTxt, dataIndex: 'txt', 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: [
{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