Commit 5453f846 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

More strict algorithm Automaton._is_record_in_db.

When categories are different between the publication
and the harvester, keep only publication = PRE and harvester = ACL.
parent e7f75e14
......@@ -132,6 +132,11 @@ class Automaton(object):
controller=self.controller,
id_categories=self.id_category)
# Identifier of the categories preprint and articles
# Used by the method _is_record_in_db
self._id_preprint = get_id(db.categories, code="PRE")
self._id_article = get_id(db.categories, code="ACL")
def _insert_in_db(self, log_year="", **fields):
"""Insert the record in the database, handling database exception.
......@@ -226,10 +231,21 @@ class Automaton(object):
# Note:
# The category for the publication and the harvester have to be equal.
# However, keep the record if it is not the case.
# This is required to transform a preprint into article
# However, keep the record if it is a preprint when the harvester
# looks for articles. This is required to transform a preprint
# into article
#
# Category can disagree when the publication is an article and
# the harvester look for preprint. In that case, keep the article
#
if publication.id_categories != harvester.id_categories:
return 0
is_preprint_to_article = \
publication.id_categories == self._id_preprint \
and harvester.id_categories == self._id_article
if is_preprint_to_article:
return 0
# log
self.logs.append(Msg(harvester=harvester,
......
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