示例#1
0
class SbmCATEGORIES(db.Model):
    """Represent a SbmCATEGORIES record."""

    __tablename__ = 'sbmCATEGORIES'
    doctype = db.Column(db.String(10),
                        nullable=False,
                        server_default='',
                        primary_key=True,
                        index=True)
    sname = db.Column(db.String(75),
                      nullable=False,
                      server_default='',
                      primary_key=True,
                      index=True)
    lname = db.Column(db.String(75), nullable=False, server_default='')
    score = db.Column(db.TinyInteger(3, unsigned=True),
                      nullable=False,
                      server_default='0')
示例#2
0
class BibHOLDINGPEN(db.Model):
    """Represent a BibHOLDINGPEN record."""

    __tablename__ = 'bibHOLDINGPEN'
    changeset_id = db.Column(db.Integer(11),
                             primary_key=True,
                             autoincrement=True)
    changeset_date = db.Column(db.DateTime,
                               nullable=False,
                               server_default='1900-01-01 00:00:00',
                               index=True)
    changeset_xml = db.Column(db.Text, nullable=False)
    oai_id = db.Column(db.String(40), nullable=False, server_default='')
    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                          db.ForeignKey(Bibrec.id),
                          nullable=False,
                          server_default='0')
    bibrec = db.relationship(Bibrec, backref='holdingpen')
示例#3
0
class CmtSUBSCRIPTION(db.Model):
    """Represents a CmtSUBSCRIPTION record."""
    __tablename__ = 'cmtSUBSCRIPTION'

    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                          db.ForeignKey(Bibrec.id),
                          nullable=False,
                          primary_key=True)
    id_user = db.Column(db.Integer(15, unsigned=True),
                        db.ForeignKey(User.id),
                        nullable=False,
                        primary_key=True)
    creation_time = db.Column(db.DateTime,
                              nullable=False,
                              server_default='1900-01-01 00:00:00')

    bibrec = db.relationship(Bibrec)
    user = db.relationship(User, backref='comment_subscriptions')
示例#4
0
class BibEDITCACHE(db.Model):
    """Represent a BibEDITCACHE record."""

    __tablename__ = 'bibEDITCACHE'
    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                          db.ForeignKey(Bibrec.id),
                          autoincrement=False,
                          nullable=False,
                          primary_key=True)
    uid = db.Column(db.Integer(15, unsigned=True),
                    primary_key=True,
                    nullable=False,
                    autoincrement=False)
    data = db.Column(db.iBinary, nullable=False)
    post_date = db.Column(db.DateTime, nullable=False, index=True)
    is_active = db.Column(db.TinyInteger(1, unsigned=True),
                          server_default='1',
                          nullable=False)
示例#5
0
class CollectionFormat(db.Model):
    """Represent a CollectionFormat record."""
    __tablename__ = 'collection_format'
    id_collection = db.Column(db.MediumInteger(9, unsigned=True),
                              db.ForeignKey(Collection.id),
                              primary_key=True)
    id_format = db.Column(db.MediumInteger(9, unsigned=True),
                          db.ForeignKey(Format.id),
                          primary_key=True)
    score = db.Column(db.TinyInteger(4, unsigned=True),
                      nullable=False,
                      server_default='0')
    collection = db.relationship(Collection,
                                 backref='formats',
                                 order_by=db.desc(score))
    format = db.relationship(Format,
                             backref='collections',
                             order_by=db.desc(score))
示例#6
0
class UserAccROLE(db.Model):
    """Represent an user role relationship."""

    __tablename__ = 'user_accROLE'
    id_user = db.Column(db.Integer(15, unsigned=True),
                        db.ForeignKey(User.id),
                        nullable=False,
                        primary_key=True)
    id_accROLE = db.Column(db.Integer(15, unsigned=True),
                           db.ForeignKey(AccROLE.id),
                           nullable=False,
                           primary_key=True)
    expiration = db.Column(db.DateTime,
                           nullable=False,
                           server_default='9999-12-31 23:59:59')

    user = db.relationship(User, backref='roles')
    role = db.relationship(AccROLE, backref='users')
示例#7
0
class OaiHARVEST(db.Model):

    """Represents a OaiHARVEST record."""

    __tablename__ = 'oaiHARVEST'

    id = db.Column(db.MediumInteger(9, unsigned=True), nullable=False,
                   primary_key=True, autoincrement=True)
    baseurl = db.Column(db.String(255), nullable=False, server_default='')
    metadataprefix = db.Column(db.String(255), nullable=False,
                               server_default='oai_dc')
    arguments = db.Column(db.MarshalBinary(default_value=get_default_arguments(),
                                           force_type=dict), nullable=False)
    comment = db.Column(db.Text, nullable=True)
    name = db.Column(db.String(255), nullable=False)
    lastrun = db.Column(db.DateTime, nullable=True)
    postprocess = db.Column(db.String(20), nullable=False,
                            server_default='h')
    workflows = db.Column(db.String(255),
                          nullable=False,
                          server_default='')
    setspecs = db.Column(db.Text, nullable=False)

    def to_dict(self):
        """Get model as dict."""
        dict_representation = self.__dict__
        del dict_representation["_sa_instance_state"]
        return dict_representation

    @classmethod
    def get(cls, *criteria, **filters):
        """Wrapper for filter and filter_by functions of SQLAlchemy.

        .. code-block:: python

            OaiHARVEST.get(OaiHARVEST.id == 1)
            OaiHARVEST.get(id=1)
        """
        return cls.query.filter(*criteria).filter_by(**filters)

    @session_manager
    def save(self):
        """Save object to persistent storage."""
        db.session.add(self)
示例#8
0
class SbmPUBLICATIONCOMM(db.Model):
    """Represents a SbmPUBLICATIONCOMM record."""
    __tablename__ = 'sbmPUBLICATIONCOMM'
    id = db.Column(db.Integer(11),
                   nullable=False,
                   primary_key=True,
                   autoincrement=True)
    id_parent = db.Column(db.Integer(11), server_default='0', nullable=True)
    rn = db.Column(db.String(100), nullable=False, server_default='')
    firstname = db.Column(db.String(100), nullable=True)
    secondname = db.Column(db.String(100), nullable=True)
    email = db.Column(db.String(100), nullable=True)
    date = db.Column(db.String(40), nullable=False, server_default='')
    synopsis = db.Column(db.String(255), nullable=False, server_default='')
    commentfulltext = db.Column(db.Text, nullable=True)
示例#9
0
class nwsSTORY(db.Model):
    """
    CREATE TABLE 'nwsSTORY' (
     'id' int(11) NOT NULL AUTO_INCREMENT,
     'title' varchar(256) NOT NULL,
     'body' text NOT NULL,
     'created' timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY ('id')
    );
    """
    __tablename__ = 'nwsSTORY'

    id = db.Column(db.Integer(11),
                   nullable=False,
                   primary_key=True,
                   autoincrement=True)
    title = db.Column(db.String(256), nullable=False)
    body = db.Column(db.Text, nullable=False)
    created = db.Column(db.DateTime, nullable=False, default=datetime.now())
示例#10
0
class UserQuery(db.Model):
    """Represent a UserQuery record."""

    __tablename__ = 'user_query'
    id_user = db.Column(db.Integer(15, unsigned=True),
                        db.ForeignKey(User.id),
                        primary_key=True,
                        server_default='0')
    id_query = db.Column(db.Integer(15, unsigned=True),
                         db.ForeignKey(WebQuery.id),
                         primary_key=True,
                         index=True,
                         server_default='0')
    hostname = db.Column(db.String(50),
                         nullable=True,
                         server_default='unknown host')
    date = db.Column(db.DateTime, nullable=True, default=datetime.datetime.now)

    webquery = db.relationship(WebQuery, backref='executions')
示例#11
0
class BskBASKET(db.Model):
    """Represents a BskBASKET record."""
    __tablename__ = 'bskBASKET'
    id = db.Column(db.Integer(15, unsigned=True),
                   nullable=False,
                   primary_key=True)
    id_owner = db.Column(db.Integer(15, unsigned=True),
                         db.ForeignKey(User.id),
                         nullable=False,
                         server_default='0')
    name = db.Column(db.String(50),
                     nullable=False,
                     server_default='',
                     index=True)
    date_modification = db.Column(db.DateTime,
                                  nullable=False,
                                  server_default='1900-01-01 00:00:00')
    nb_views = db.Column(db.Integer(15), nullable=False, server_default='0')
    owner = db.relationship(User, backref='baskets')
示例#12
0
class BskEXTFMT(db.Model):
    """Represents a BskEXTFMT record."""
    __tablename__ = 'bskEXTFMT'
    id = db.Column(db.Integer(15, unsigned=True),
                   nullable=False,
                   primary_key=True)
    id_bskEXTREC = db.Column(db.Integer(15, unsigned=True),
                             db.ForeignKey(BskEXTREC.id),
                             nullable=False,
                             server_default='0')
    format = db.Column(db.String(10),
                       nullable=False,
                       index=True,
                       server_default='')
    last_updated = db.Column(db.DateTime,
                             nullable=False,
                             server_default='1900-01-01 00:00:00')
    value = db.Column(db.iLargeBinary, nullable=True)
    EXTREC = db.relationship(BskEXTREC, backref='EXTFMTs')
示例#13
0
class AccAuthorization(db.Model):
    """Represent an authorization."""

    __tablename__ = 'accROLE_accACTION_accARGUMENT'
    id = db.Column(db.Integer(15, unsigned=True),
                   primary_key=True,
                   autoincrement=True)
    id_accROLE = db.Column(db.Integer(15, unsigned=True),
                           db.ForeignKey(AccROLE.id),
                           nullable=True,
                           index=True)
    id_accACTION = db.Column(db.Integer(15, unsigned=True),
                             db.ForeignKey(AccACTION.id),
                             nullable=True,
                             index=True)
    _id_accARGUMENT = db.Column(db.Integer(15),
                                nullable=True,
                                name="id_accARGUMENT",
                                index=True)
    argumentlistid = db.Column(db.MediumInteger(8), nullable=True)

    role = db.relationship(AccROLE, backref='authorizations')
    action = db.relationship(AccACTION, backref='authorizations')
    argument = db.relationship(
        AccARGUMENT,
        backref='authorizations',
        primaryjoin=db.and_(AccARGUMENT.id == _id_accARGUMENT,
                            _id_accARGUMENT != -1, _id_accARGUMENT
                            is not None),
        foreign_keys=_id_accARGUMENT,
        uselist=False,
        cascade="all, delete",
    )

    @db.hybrid_property
    def id_accARGUMENT(self):
        """get id_accARGUMENT."""
        return self._id_accARGUMENT

    @id_accARGUMENT.setter
    def id_accARGUMENT(self, value):
        """set id_accARGUMENT."""
        self._id_accARGUMENT = value or None
示例#14
0
class Collection_bsrMETHOD(db.Model):

    """Represent a Collection_bsrMETHOD record."""

    __tablename__ = 'collection_bsrMETHOD'

    id_collection = db.Column(db.MediumInteger(9, unsigned=True),
                              db.ForeignKey(Collection.id),
                              primary_key=True, nullable=False,
                              autoincrement=False)
    id_bsrMETHOD = db.Column(db.MediumInteger(9, unsigned=True),
                             db.ForeignKey(BsrMETHOD.id),
                             primary_key=True, nullable=False,
                             autoincrement=False)
    score = db.Column(db.TinyInteger(4, unsigned=True), server_default='0',
                      nullable=False)

    collection = db.relationship(Collection, backref='bsrMETHODs')
    bsrMETHOD = db.relationship(BsrMETHOD, backref='collections')
示例#15
0
class FacetCollection(db.Model):

    """Facet configuration for collection."""

    __tablename__ = 'facet_collection'

    id = db.Column(db.Integer, primary_key=True)
    id_collection = db.Column(db.MediumInteger(9, unsigned=True),
                              db.ForeignKey(Collection.id))
    order = db.Column(db.Integer)
    facet_name = db.Column(db.String(80))

    collection = db.relationship(Collection, backref='facets')

    def __repr__(self):
        """Return class representation."""
        return ('FacetCollection <id: {0.id}, id_collection: '
                '{0.id_collection}, order: {0.order}, '
                'facet_name: {0.facet_name}>'.format(self))

    @classmethod
    def is_place_taken(cls, id_collection, order):
        """Check if there is already a facet on the given position.

        .. note:: This works well as a pre-check, however saving can still fail
            if somebody else creates the same record in other session
            (phantom reads).
        """
        return bool(cls.query.filter(
            cls.id_collection == id_collection,
            cls.order == order).count())

    @classmethod
    def is_duplicated(cls, id_collection, facet_name):
        """Check if the given facet is already assigned to this collection.

        .. note:: This works well as a pre-check, however saving can still fail
            if somebody else creates the same record in other session
            (phantom reads).
        """
        return bool(cls.query.filter(
            cls.id_collection == id_collection,
            cls.facet_name == facet_name).count())
示例#16
0
class SbmCOLLECTIONSbmCOLLECTION(db.Model):
    """Represents a SbmCOLLECTIONSbmCOLLECTION record."""

    __tablename__ = 'sbmCOLLECTION_sbmCOLLECTION'

    id = db.Column(db.Integer(11),
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    _id_father = db.Column(db.Integer(11),
                           db.ForeignKey(SbmCOLLECTION.id),
                           nullable=True,
                           name='id_father')
    id_son = db.Column(db.Integer(11),
                       db.ForeignKey(SbmCOLLECTION.id),
                       nullable=False)
    catalogue_order = db.Column(db.Integer(11),
                                nullable=False,
                                server_default='0')

    son = db.relationship(
        SbmCOLLECTION,
        backref=db.backref('father', uselist=False),
        single_parent=True,
        primaryjoin="and_(SbmCOLLECTIONSbmCOLLECTION.id_son==SbmCOLLECTION.id) "
    )
    father = db.relationship(
        SbmCOLLECTION,
        backref=db.backref('son', uselist=False),
        single_parent=True,
        primaryjoin=
        "and_(SbmCOLLECTIONSbmCOLLECTION.id_father==SbmCOLLECTION.id) ")

    @db.hybrid_property
    def id_father(self):
        """Get id_father."""
        return self._id_father

    @id_father.setter
    def id_father(self, value):
        """Set id_father."""
        self._id_father = value or None
示例#17
0
class CollectionPortalbox(db.Model):

    """Represent a CollectionPortalbox record."""

    __tablename__ = 'collection_portalbox'
    id_collection = db.Column(db.MediumInteger(9, unsigned=True),
                              db.ForeignKey(Collection.id), primary_key=True)
    id_portalbox = db.Column(db.MediumInteger(9, unsigned=True),
                             db.ForeignKey(Portalbox.id), primary_key=True)
    ln = db.Column(db.Char(5), primary_key=True, server_default='',
                   nullable=False)
    position = db.Column(db.Char(3), nullable=False,
                         server_default='top')
    score = db.Column(db.TinyInteger(4, unsigned=True),
                      nullable=False,
                      server_default='0')
    collection = db.relationship(Collection, backref='portalboxes',
                                 order_by=score)
    portalbox = db.relationship(Portalbox, backref='collections',
                                order_by=score)
示例#18
0
class BsrMETHOD(db.Model):
    """Represents a BsrMETHOD record."""

    __tablename__ = 'bsrMETHOD'

    id = db.Column(db.MediumInteger(9, unsigned=True),
                   primary_key=True,
                   nullable=False)
    name = db.Column(db.String(20), nullable=False, unique=True)
    definition = db.Column(db.String(255), nullable=False)
    washer = db.Column(db.String(255), nullable=False)

    def get_name_ln(self, ln=None):
        """Return localized method name."""
        try:
            if ln is None:
                ln = g.ln
            return self.names.filter_by(ln=g.ln, type='ln').one().value
        except:
            return self.name
示例#19
0
class CollectionCollection(db.Model):

    """Represent a CollectionCollection record."""

    __tablename__ = 'collection_collection'
    id_dad = db.Column(db.MediumInteger(9, unsigned=True),
                       db.ForeignKey(Collection.id), primary_key=True)
    id_son = db.Column(db.MediumInteger(9, unsigned=True),
                       db.ForeignKey(Collection.id), primary_key=True)
    type = db.Column(db.Char(1), nullable=False,
                     server_default='r')
    score = db.Column(db.TinyInteger(4, unsigned=True), nullable=False,
                      server_default='0')
    son = db.relationship(Collection, primaryjoin=id_son == Collection.id,
                          backref='dads',
                          # FIX
                          # collection_class=db.attribute_mapped_collection('score'),
                          order_by=db.asc(score))
    dad = db.relationship(Collection, primaryjoin=id_dad == Collection.id,
                          backref='sons', order_by=db.asc(score))
示例#20
0
class UsergroupBskBASKET(db.Model):
    """Represents a UsergroupBskBASKET record."""
    __tablename__ = 'usergroup_bskBASKET'
    id_usergroup = db.Column(db.Integer(15, unsigned=True),
                             db.ForeignKey(Usergroup.id),
                             nullable=False,
                             server_default='0',
                             primary_key=True)
    id_bskBASKET = db.Column(db.Integer(15, unsigned=True),
                             db.ForeignKey(BskBASKET.id),
                             nullable=False,
                             server_default='0',
                             primary_key=True)
    topic = db.Column(db.String(50), nullable=False, server_default='')
    date_shared = db.Column(db.DateTime,
                            nullable=False,
                            server_default='1900-01-01 00:00:00')
    share_level = db.Column(db.Char(2), nullable=False, server_default='')
    usergroup = db.relationship(Usergroup, backref='usergroup_baskets')
    usergroup_basket = db.relationship(BskBASKET, backref='usergroups')
示例#21
0
class CollectionFormat(db.Model):

    """Represent a CollectionFormat record."""

    __tablename__ = 'collection_format'
    id_collection = db.Column(db.MediumInteger(9, unsigned=True),
                              db.ForeignKey(Collection.id), primary_key=True)
    format_code = db.Column('format', db.String(10), primary_key=True)
    score = db.Column(db.TinyInteger(4, unsigned=True),
                      nullable=False, server_default='0')

    collection = db.relationship(
        Collection, backref=db.backref(
            'formats', order_by=db.desc(score)
        ), order_by=db.desc(score))

    @property
    def format(self):
        """Return output format definition."""
        return output_formats[self.format_code]
示例#22
0
class AccAuthorization(db.Model):

    """Represent an authorization."""

    __tablename__ = 'accROLE_accACTION_accARGUMENT'
    id_accROLE = db.Column(db.Integer(15, unsigned=True),
                           db.ForeignKey(AccROLE.id), nullable=True,
                           autoincrement=False, primary_key=True, index=True)
    id_accACTION = db.Column(db.Integer(15, unsigned=True),
                             db.ForeignKey(AccACTION.id), nullable=True,
                             autoincrement=False, primary_key=True, index=True)
    id_accARGUMENT = db.Column(db.Integer(15), db.ForeignKey(AccARGUMENT.id),
                               nullable=True, primary_key=True,
                               autoincrement=False, index=True)
    argumentlistid = db.Column(db.MediumInteger(8), nullable=True,
                               autoincrement=False, primary_key=True)

    role = db.relationship(AccROLE, backref='authorizations')
    action = db.relationship(AccACTION, backref='authorizations')
    argument = db.relationship(AccARGUMENT, backref='authorizations')
示例#23
0
def do_upgrade():
    """Implement your upgrades here."""
    # modify the database
    op.add_column('knwKB',
                  db.Column('is_api_accessible', db.Boolean(), nullable=False))
    op.add_column(
        'knwKB',
        db.Column('slug', db.String(length=255), nullable=False, default=True))

    # update knwKB table values
    res = run_sql("SELECT name FROM knwKB")
    for record in res:
        name = record[0]
        slug = generate_slug(name)
        run_sql(
            "UPDATE knwKB SET is_api_accessible = 1, slug = %s "
            "WHERE name = %s", (slug, name))

    # define unique constraint
    op.create_unique_constraint(None, 'knwKB', ['slug'])
示例#24
0
class UserMsgMESSAGE(db.Model):
    """Represents a UserMsgMESSAGE record."""
    __tablename__ = 'user_msgMESSAGE'
    id_user_to = db.Column(db.Integer(15, unsigned=True),
                           db.ForeignKey(User.id),
                           nullable=False,
                           server_default='0',
                           primary_key=True)
    id_msgMESSAGE = db.Column(db.Integer(15, unsigned=True),
                              db.ForeignKey(MsgMESSAGE.id),
                              nullable=False,
                              server_default='0',
                              primary_key=True)
    status = db.Column(db.Char(1), nullable=False, server_default='N')
    user_to = db.relationship(User,
                              backref='received_messages',
                              collection_class=set)
    message = db.relationship(MsgMESSAGE,
                              backref='sent_to_users',
                              collection_class=set)
示例#25
0
class UserQueryBasket(db.Model):
    """Represent a UserQueryBasket record."""

    __tablename__ = 'user_query_basket'

    id_user = db.Column(db.Integer(15, unsigned=True),
                        db.ForeignKey(User.id),
                        nullable=False,
                        server_default='0',
                        primary_key=True)
    id_query = db.Column(db.Integer(15, unsigned=True),
                         db.ForeignKey(WebQuery.id),
                         nullable=False,
                         server_default='0',
                         primary_key=True,
                         index=True)
    id_basket = db.Column(db.Integer(15, unsigned=True),
                          db.ForeignKey(BskBASKET.id),
                          nullable=False,
                          server_default='0',
                          primary_key=True,
                          index=True)
    frequency = db.Column(db.String(5),
                          nullable=False,
                          server_default='',
                          primary_key=True)
    date_creation = db.Column(db.Date, nullable=True)
    date_lastrun = db.Column(db.Date,
                             nullable=True,
                             server_default='1900-01-01')
    alert_name = db.Column(db.String(30),
                           nullable=False,
                           server_default='',
                           index=True)
    alert_desc = db.Column(db.Text)
    alert_recipient = db.Column(db.Text)
    notification = db.Column(db.Char(1), nullable=False, server_default='y')

    user = db.relationship(User, backref='query_baskets')
    webquery = db.relationship(WebQuery, backref='user_baskets')
    basket = db.relationship(BskBASKET, backref='user_queries')
示例#26
0
class BsrMETHODDATA(db.Model):

    """Represent a BsrMETHODDATA record."""

    __tablename__ = 'bsrMETHODDATA'

    id_bsrMETHOD = db.Column(db.MediumInteger(9, unsigned=True),
                             db.ForeignKey(BsrMETHOD.id),
                             primary_key=True, nullable=False,
                             autoincrement=False)
    data_dict = db.Column(db.LargeBinary)
    data_dict_ordered = db.Column(db.LargeBinary)
    data_list_sorted = db.Column(db.LargeBinary)
    last_updated = db.Column(db.DateTime)

    @property
    def ordered(self):
        """Return deserialized orderd dict."""
        return deserialize_via_marshal(self.data_dict_ordered)

    method = db.relationship(BsrMETHOD, backref='methoddata')
示例#27
0
def do_upgrade():
    """Add the table with facets configuration."""
    if not op.has_table('facet_collection'):
        op.create_table('facet_collection',
                        db.Column('id', mysql.INTEGER(), nullable=False),
                        db.Column('id_collection',
                                  mysql.INTEGER(),
                                  nullable=False),
                        db.Column('order', mysql.INTEGER(), nullable=False),
                        db.Column('facet_name',
                                  db.String(length=80),
                                  nullable=False),
                        db.ForeignKeyConstraint(
                            ['id_collection'],
                            ['collection.id'],
                        ),
                        db.PrimaryKeyConstraint('id'),
                        mysql_charset='utf8',
                        mysql_engine='MyISAM')
    else:
        warnings.warn("*** Creation of table 'facet_collection' skipped!")
示例#28
0
def do_upgrade():
    """Migrate format references."""
    op.add_column('collection_format',
                  db.Column('format', db.String(length=10), nullable=False))
    run_sql('UPDATE collection_format cf JOIN format f ON f.id = cf.id_format '
            'SET cf.format = f.code')
    op.drop_constraint(None, 'collection_format', type_='primary')
    op.create_primary_key(None, 'collection_format',
                          ['id_collection', 'format'])
    op.drop_column('collection_format', 'id_format')
    op.drop_table('formatname')
    op.drop_table('format')
示例#29
0
class IdxINDEXIdxINDEX(db.Model):
    """Represent an IdxINDEXIdxINDEX record."""

    __tablename__ = 'idxINDEX_idxINDEX'
    id_virtual = db.Column(db.MediumInteger(9, unsigned=True),
                           db.ForeignKey(IdxINDEX.id),
                           nullable=False,
                           server_default='0',
                           primary_key=True)
    id_normal = db.Column(db.MediumInteger(9, unsigned=True),
                          db.ForeignKey(IdxINDEX.id),
                          nullable=False,
                          server_default='0',
                          primary_key=True)

    @staticmethod
    def is_virtual(id_virtual):
        """Check if index is virtual."""
        return db.session.query(
            IdxINDEXIdxINDEX.query.filter_by(
                id_virtual=id_virtual).exists()).scalar()
示例#30
0
class CollectionFieldFieldvalue(db.Model):
    """Represent a CollectionFieldFieldvalue record."""

    __tablename__ = 'collection_field_fieldvalue'
    id_collection = db.Column(db.MediumInteger(9, unsigned=True),
                              db.ForeignKey(Collection.id),
                              primary_key=True,
                              nullable=False)
    id_field = db.Column(db.MediumInteger(9, unsigned=True),
                         db.ForeignKey(Field.id),
                         primary_key=True,
                         nullable=False)
    id_fieldvalue = db.Column(db.MediumInteger(9, unsigned=True),
                              db.ForeignKey(Fieldvalue.id),
                              primary_key=True,
                              nullable=True)
    type = db.Column(db.Char(3), nullable=False, server_default='src')
    score = db.Column(db.TinyInteger(4, unsigned=True),
                      nullable=False,
                      server_default='0')
    score_fieldvalue = db.Column(db.TinyInteger(4, unsigned=True),
                                 nullable=False,
                                 server_default='0')

    collection = db.relationship(Collection,
                                 backref='field_fieldvalues',
                                 order_by=score)
    field = db.relationship(Field,
                            backref='collection_fieldvalues',
                            lazy='joined')
    fieldvalue = db.relationship(Fieldvalue,
                                 backref='collection_fields',
                                 lazy='joined')