Exemplo n.º 1
0
 def type(cls):
     return db.Column(db.Enum('CURRENT',
                              'FUTURE',
                              'TEMPORARY',
                              name=cls.__tablename__ + '_type'),
                      nullable=False,
                      server_default='CURRENT',
                      primary_key=True)
Exemplo n.º 2
0
class RnkCITATIONDATAERR(db.Model):
    """Represent a RnkCITATIONDATAERR record."""

    __tablename__ = 'rnkCITATIONDATAERR'
    type = db.Column(db.Enum('multiple-matches',
                             'not-well-formed',
                             name='rnkcitattiondataerr_type'),
                     primary_key=True)
    citinfo = db.Column(db.String(255), primary_key=True, server_default='')
Exemplo n.º 3
0
class BibARXIVPDF(db.Model):

    """Represent a bibARXIVPDF record."""

    __tablename__ = 'bibARXIVPDF'
    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True), primary_key=True)
    status = db.Column(db.Enum('ok', 'missing', name='bibarxivpdf_status'),
                       nullable=False, index=True)
    date_harvested = db.Column(db.DateTime, nullable=False)
    version = db.Column(db.TinyInteger(2), nullable=False)
Exemplo n.º 4
0
class IdxPAIR29R(db.Model):
    """Represents a IdxPAIR28R record."""

    __tablename__ = 'idxPAIR29R'

    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                          db.ForeignKey(Bibrec.id),
                          primary_key=True)
    termlist = db.Column(db.iLargeBinary, nullable=True)
    type = db.Column(db.Enum('CURRENT', 'FUTURE', 'TEMPORARY'),
                     nullable=False,
                     server_default='CURRENT',
                     primary_key=True)
Exemplo n.º 5
0
class AccACTION(db.Model):

    """Represent an access action."""

    __tablename__ = 'accACTION'
    id = db.Column(db.Integer(15, unsigned=True),
                   primary_key=True, autoincrement=True)
    name = db.Column(db.String(32), unique=True, nullable=True)
    description = db.Column(db.String(255), nullable=True)
    allowedkeywords = db.Column(db.String(255), nullable=True)
    optional = db.Column(db.Enum('yes', 'no', name='yes_no'), nullable=False,
                         server_default='no')

    def __repr__(self):
        return "{0.name}".format(self)
Exemplo n.º 6
0
class RnkCITATIONLOG(db.Model):
    """Represents a RnkCITATIONLOG record."""

    __tablename__ = 'rnkCITATIONLOG'
    id = db.Column(db.Integer(11, unsigned=True),
                   primary_key=True,
                   autoincrement=True,
                   nullable=False)
    citee = db.Column(db.Integer(10, unsigned=True), nullable=False)
    citer = db.Column(db.Integer(10, unsigned=True), nullable=False)
    type = db.Column(db.Enum('added', 'removed', name='rnkcitationlog_type'),
                     nullable=True)
    action_date = db.Column(db.DateTime, nullable=False)
    __table_args__ = (db.Index('citee', citee), db.Index('citer', citer),
                      db.Model.__table_args__)
Exemplo n.º 7
0
class RnkWORD01R(db.Model):
    """Represent a RnkWORD01R record."""

    __tablename__ = 'rnkWORD01R'
    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                          db.ForeignKey(Bibrec.id),
                          nullable=False,
                          primary_key=True)
    termlist = db.Column(db.LargeBinary, nullable=True)
    type = db.Column(db.Enum('CURRENT',
                             'FUTURE',
                             'TEMPORARY',
                             name='rnkword_type'),
                     nullable=False,
                     server_default='CURRENT',
                     primary_key=True)
    bibrec = db.relationship(Bibrec, backref='word01rs')
Exemplo n.º 8
0
class Signature(db.Model):
    """Represents a signature of an author on a publication.

    A signature is the event when an author "signs" a publication.
    For example, "author A has written publication P" is a valid
    signature.

    Each signature has a unique id, an author and a publication.
    Additionally, each signature is associated to a curator and a JSON
    field representing raw metadata from the corresponding publication.

    Finally, each signature has an attribution field which represents
    a certainty level: a signature may be either attributed
    automatically (default), verified by a curator or rejected by a
    curator.
    """

    __tablename__ = 'authors_signature'
    __mapper_args__ = {'confirm_deleted_rows': False}

    id = db.Column(db.Integer(15, unsigned=True),
                   primary_key=True,
                   autoincrement=True,
                   nullable=False)
    """Id of the signature (required)."""

    id_author = db.Column(db.Integer(15, unsigned=True),
                          db.ForeignKey(Author.id, ondelete="SET NULL"))
    """Id of the associated author."""

    id_publication = db.Column(db.Integer(15, unsigned=True),
                               db.ForeignKey(Publication.id),
                               nullable=False)
    """Id of the associated publication."""

    id_curator = db.Column(db.Integer(15, unsigned=True),
                           db.ForeignKey(User.id))
    """Id of the last curator (User) of this signature."""

    raw_metadata = db.Column(db.JSON, default=None)
    """Raw metadata of the record in JSON format."""

    attribution = db.Column(db.Enum('unknown',
                                    'rejected',
                                    'verified',
                                    name='authors_attribution'),
                            default='unknown')
    """Attribution may be "unknown" (default), "verified", "rejected."""

    author = db.relationship('Author', backref='signatures')
    """Author who signs."""

    publication = db.relationship('Publication', backref='signatures')
    """Publication signed."""

    curator = db.relationship('User')
    """User who last curated this signature
           (disambiguation algorithm if None)"""
    def __repr__(self):
        """Return a printable representation of a Signature."""
        return 'Signature(id=%s)' % self.id

    @utils.session_manager
    def claim(self, curator):
        """Claim that the signature is a true event.

        :param curator: the User who verifies the truth
        """
        self.curator = curator
        self.attribution = 'verified'
        db.session.add(self)

    @utils.session_manager
    def disclaim(self, curator):
        """Disclaim that the signature is a true event.

        :param curator: the User who verifies the falseness
        """
        self.curator = curator
        self.attribution = 'rejected'
        db.session.add(self)

    @utils.session_manager
    def move(self, author, curator=None):
        """Modify the author in the signature.

        The attribution of the signature is not altered.

        :param author: the Author to move the signature to
        :param curator: the User who performs the move (optional)
        """
        self.curator = curator
        self.author = author
        db.session.add(self)

    @staticmethod
    @utils.session_manager
    def reassign(author, curator, signature):
        """Reassign a signature to a different author.

        The current author of a signature rejects the signature. Then,
        a new signature is created and claimed for the given author.

        :param author: the Author to reassign the signature to
        :param curator: the User who performs the reassignment
        :param signature: the signature to reassign

        :raise SignatureExistsError: the given author already has
                                     the given signature.
        """
        try:
            sig = Signature.query.filter_by(publication=signature.publication,
                                            author=author).scalar()
            if sig:
                raise SignatureExistsError(
                    "Cannot reassign signature {signature} to author {author} "
                    "for publication {signature.publication}. The author "
                    "already has a signature for this publication.".format(
                        signature=signature, author=author))
            signature.disclaim(curator)
            new_signature = Signature(publication=signature.publication,
                                      author=author)
            new_signature.claim(curator)
        except MultipleResultsFound as e:
            # This should not happen.
            raise e