Esempio n. 1
0
class CryptoHashRun(xbxr.Run):
    """Contains data specific to cryptographic hash runs

    Call run() to instantiate and run, do not use constructor

    Attributes of interest:
        msg_len     Message length
    """
    __tablename__ = "crypto_hash_run"

    id = Column(Integer, nullable=False)
    msg_len = Column(Integer)

    __mapper_args__ = {
        'polymorphic_identity':'crypto_hash_run',
    }

    __table_args__ = (
        PrimaryKeyConstraint("id"),
        ForeignKeyConstraint(["id"], ["run.id"]))

    def _assemble_params(self):
        data = os.urandom(self.msg_len)
        return data

    @classmethod
    def run(cls, build_exec, params=None):
        """Factory method that generates run instances and attaches them to
        build_exec. Call this instead of constructor"""
        _logger.info("Running benchmark on {} with msg length {}".
                     format(build_exec.build.buildid, params[0]))
        run = cls(build_exec, msg_len=params[0])
        run._execute(run._assemble_params())
        run._calculate_power()
        return run
Esempio n. 2
0
class ConfigImplAssociation(Base):
    __tablename__ = 'config_impl_dep_assoc'
    config_hash = Column(String, nullable=False)
    implementation_hash = Column(String, nullable=False)

    implementation = relationship(
        "Implementation",
        backref="config_impl_assocs",
    )

    config = relationship("Config",
                          backref=backref("config_impl_assocs",
                                          cascade="all, delete-orphan"))

    dependencies = relationship(
        "Implementation",
        secondary=_impl_dep_join_table,
        primaryjoin=and_(
            _impl_dep_join_table.c.dependent_impl_hash == implementation_hash,
            _impl_dep_join_table.c.config_hash == config_hash),
        secondaryjoin=(_impl_dep_join_table.c.dependency_impl_hash ==
                       Implementation.hash))

    __table_args__ = (
        PrimaryKeyConstraint("config_hash", "implementation_hash"),
        ForeignKeyConstraint(["config_hash"], ["config.hash"],
                             ondelete="CASCADE"),
        ForeignKeyConstraint(["implementation_hash"], ["implementation.hash"],
                             ondelete="CASCADE"),
    )
Esempio n. 3
0
class PhonebookAddress(Base):

    __tablename__ = 'phonebookaddress'
    __table_args__ = (
        PrimaryKeyConstraint('id'),
        ForeignKeyConstraint(('phonebookid', ), ('phonebook.id', ),
                             ondelete='CASCADE'),
        Index('phonebookaddress__uidx__phonebookid_type',
              'phonebookid',
              'type',
              unique=True),
    )

    id = Column(Integer)
    phonebookid = Column(Integer, nullable=False)
    address1 = Column(String(30), nullable=False, server_default='')
    address2 = Column(String(30), nullable=False, server_default='')
    city = Column(String(128), nullable=False, server_default='')
    state = Column(String(128), nullable=False, server_default='')
    zipcode = Column(String(16), nullable=False, server_default='')
    country = Column(String(3), nullable=False, server_default='')
    type = Column(Enum('home',
                       'office',
                       'other',
                       name='phonebookaddress_type',
                       metadata=Base.metadata),
                  nullable=False)

    phonebook = relationship('Phonebook')
Esempio n. 4
0
class Slusa(Base):
    __tablename__ = 'slusa'

    ucenik_id = Column(Integer)
    predmet_id = Column(Integer)
    predaje_profesor_id = Column(Integer)
    predaje_predmet_id = Column(Integer)
    ucenik = relationship('Ucenik', lazy='joined')
    predmet = relationship('Predmet', lazy='joined')
    predaje = relationship('Predaje', lazy='joined')
    ocene = relationship('Ocena', back_populates='slusa', lazy='joined')

    __table_args__ = (
        ForeignKeyConstraint([ucenik_id],
                             [Ucenik.id]),  # add on delete cascade
        ForeignKeyConstraint([predmet_id],
                             [Predmet.id]),  # add on delete cascade
        ForeignKeyConstraint([predaje_profesor_id, predaje_predmet_id],
                             [Predaje.profesor_id, Predaje.predmet_id
                              ]),  # add on delete set null
        PrimaryKeyConstraint(ucenik_id, predmet_id),
        {})

    def __init__(self, ucenik, predmet, profesor):
        self.ucenik_id = ucenik.id
        self.predmet_id = predmet.id
        self.predaje_predmet_id = predmet.id
        self.predaje_profesor_id = profesor.id

    def __repr__(self):
        return f'<Slusa()>'
Esempio n. 5
0
class Ucenik(Korisnik):
    __tablename__ = 'ucenik'

    id = Column(Integer)
    ime = Column(String(30), nullable=False)
    prezime = Column(String(30), nullable=False)
    razred_id = Column(Integer)
    razred = relationship('Razred', back_populates='ucenici', lazy='joined')

    __table_args__ = (ForeignKeyConstraint([id], [Korisnik.id]),
                      ForeignKeyConstraint([razred_id], [Razred.id]),
                      PrimaryKeyConstraint(id), {})

    __mapper_args__ = {'polymorphic_identity': 'ucenik'}

    def __init__(self, username, password, ime, prezime, razred):
        super(Ucenik, self).__init__(username, password)
        self.ime = ime
        self.prezime = prezime
        if isinstance(razred, int):
            self.razred_id = razred
        elif isinstance(razred, Razred):
            self.razred = razred
        else:
            raise ValueError('Cannot accept type of argument razred')

    def __repr__(self):
        return f'<Ucenik(id={self.id}, username={self.username}, ime={self.ime}, prezime={self.prezime}, razred={self.razred})>'
Esempio n. 6
0
def get_indicator_table(indicator_config, metadata, override_table_name=None):
    sql_columns = [column_to_sql(col) for col in indicator_config.get_columns()]
    table_name = override_table_name or get_table_name(indicator_config.domain, indicator_config.table_id)
    columns_by_col_id = {col.database_column_name.decode('utf-8') for col in indicator_config.get_columns()}
    extra_indices = []
    for index in indicator_config.sql_column_indexes:
        if set(index.column_ids).issubset(columns_by_col_id):
            extra_indices.append(Index(
                _custom_index_name(table_name, index.column_ids),
                *index.column_ids
            ))
        else:
            _assert = soft_assert('{}@{}'.format('jemord', 'dimagi.com'))
            _assert(False, "Invalid index specified on {}".format(table_name))
            break
    constraints = [PrimaryKeyConstraint(*indicator_config.pk_columns)]
    columns_and_indices = sql_columns + extra_indices + constraints
    # todo: needed to add extend_existing=True to support multiple calls to this function for the same table.
    # is that valid?
    return sqlalchemy.Table(
        table_name,
        metadata,
        extend_existing=True,
        *columns_and_indices
    )
Esempio n. 7
0
class DozvoljeniRazredi(Base):
    __tablename__ = 'dozvoljenirazredi'

    razred_id = Column(Integer)
    predmet_id = Column(Integer)
    razred = relationship('Razred')
    predmet = relationship('Predmet')

    __table_args__ = (ForeignKeyConstraint([razred_id], [Razred.id]),
                      ForeignKeyConstraint([predmet_id], [Predmet.id]),
                      PrimaryKeyConstraint(razred_id, predmet_id), {})

    def __init__(self, razred, predmet):
        if isinstance(razred, Razred):
            self.razred = razred
        elif isintance(razred, int):
            self.razred_id = razred
        else:
            raise ValueError('Cannot accept type of argument razred')
        if isinstance(predmet, Predmet):
            self.predmet = predmet
        elif isintance(predmet, int):
            self.predmet_id = predmet
        else:
            raise ValueError('Cannot accept type of argument predmet')

    def __repr__(self):
        return f'<DozvoljeniRazredi()>'
Esempio n. 8
0
class QueueFeatures(Base):

    __tablename__ = 'queuefeatures'
    __table_args__ = (
        PrimaryKeyConstraint('id'),
        UniqueConstraint('name'),
        Index('queuefeatures__idx__context', 'context'),
        Index('queuefeatures__idx__number', 'number'),
    )

    id = Column(Integer)
    name = Column(String(128), nullable=False)
    displayname = Column(String(128), nullable=False)
    number = Column(String(40), nullable=False, server_default='')
    context = Column(String(39))
    data_quality = Column(Integer, nullable=False, server_default='0')
    hitting_callee = Column(Integer, nullable=False, server_default='0')
    hitting_caller = Column(Integer, nullable=False, server_default='0')
    retries = Column(Integer, nullable=False, server_default='0')
    ring = Column(Integer, nullable=False, server_default='0')
    transfer_user = Column(Integer, nullable=False, server_default='0')
    transfer_call = Column(Integer, nullable=False, server_default='0')
    write_caller = Column(Integer, nullable=False, server_default='0')
    write_calling = Column(Integer, nullable=False, server_default='0')
    url = Column(String(255), nullable=False, server_default='')
    announceoverride = Column(String(128), nullable=False, server_default='')
    timeout = Column(Integer, nullable=False, server_default='0')
    preprocess_subroutine = Column(String(39))
    announce_holdtime = Column(Integer, nullable=False, server_default='0')
    waittime = Column(Integer)
    waitratio = Column(DOUBLE_PRECISION)
Esempio n. 9
0
def get_indicator_table(indicator_config, metadata, override_table_name=None):
    sql_columns = [
        column_to_sql(col) for col in indicator_config.get_columns()
    ]
    table_name = override_table_name or get_table_name(
        indicator_config.domain, indicator_config.table_id)
    columns_by_col_id = {
        col.database_column_name.decode('utf-8')
        for col in indicator_config.get_columns()
    }
    extra_indices = []

    citus_config = indicator_config.sql_settings.citus_config
    if citus_config.distribution_type == 'hash':
        # Create hash index on doc_id for distributed tables
        extra_indices.append(
            Index(_custom_index_name(table_name, ['doc_id']),
                  'doc_id',
                  postgresql_using='hash'))

    for index in indicator_config.sql_column_indexes:
        if set(index.column_ids).issubset(columns_by_col_id):
            extra_indices.append(
                Index(_custom_index_name(table_name, index.column_ids),
                      *index.column_ids))
        else:
            logger.error(
                f"Invalid index specified on {table_name} ({index.column_ids})"
            )
    constraints = [PrimaryKeyConstraint(*indicator_config.pk_columns)]
    columns_and_indices = sql_columns + extra_indices + constraints
    current_table = metadata.tables.get(table_name)
    if current_table is not None:
        metadata.remove(current_table)
    return sqlalchemy.Table(table_name, metadata, *columns_and_indices)
Esempio n. 10
0
class Links(Base):
    __tablename__ = 'links'
    __table_args__ = (
        PrimaryKeyConstraint('employeeid', 'skillid'),
    )
    employeeid=Column(Integer, ForeignKey('employees.id', onupdate='CASCADE', ondelete='CASCADE'))
    skillid=Column(Integer, ForeignKey('skills.id', onupdate='CASCADE', ondelete='CASCADE'))
Esempio n. 11
0
def _add_metadef_objects_table():
    ns_id_name_constraint = 'uq_metadef_objects_namespace_id_name'

    op.create_table('metadef_objects',
                    Column('id', Integer(), nullable=False),
                    Column('namespace_id', Integer(), nullable=False),
                    Column('name', String(length=80), nullable=False),
                    Column('description', Text(), nullable=True),
                    Column('required', Text(), nullable=True),
                    Column('json_schema', JSONEncodedDict(), nullable=False),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=True),
                    ForeignKeyConstraint(['namespace_id'],
                                         ['metadef_namespaces.id'], ),
                    PrimaryKeyConstraint('id'),
                    UniqueConstraint('namespace_id',
                                     'name',
                                     name=ns_id_name_constraint),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_metadef_objects_name',
                    'metadef_objects',
                    ['name'],
                    unique=False)
Esempio n. 12
0
class TestScore(Base):
    __tablename__ = "testscores"
    __table_args__ = (PrimaryKeyConstraint('test_id', 'participation_id'), )

    test_id = Column(Integer,
                     ForeignKey(Test.id,
                                onupdate="CASCADE",
                                ondelete="CASCADE"),
                     nullable=False,
                     index=True)
    test = relationship(Test,
                        backref=backref('test_scores',
                                        order_by=[test_id],
                                        cascade="all, delete-orphan",
                                        passive_deletes=True))

    # I do not know what happens here, but if I refer to SocialParticipation.id
    # then everything breaks down.
    participation_id = Column(Integer,
                              ForeignKey(Participation.id,
                                         onupdate="CASCADE",
                                         ondelete="CASCADE"),
                              nullable=False,
                              index=True)
    participation = relationship(Participation,
                                 backref=backref('test_scores',
                                                 order_by=[test_id],
                                                 cascade="all, delete-orphan",
                                                 passive_deletes=True))

    score = Column(Integer, default=0)
Esempio n. 13
0
class ObjectEvent(db.Model, Timestamp):
    """Event related to an Identifier or Relationship."""

    __tablename__ = 'objectevent'
    __table_args__ = (PrimaryKeyConstraint('event_id',
                                           'object_uuid',
                                           'payload_type',
                                           'payload_index',
                                           name='pk_objectevent'), )

    event_id = db.Column(UUIDType, db.ForeignKey(Event.id), nullable=False)
    object_uuid = db.Column(UUIDType, nullable=False)
    payload_type = db.Column(db.Enum(PayloadType), nullable=False)
    payload_index = db.Column(db.Integer, nullable=False)

    event = db.relationship(Event, backref='object_events')

    @property
    def object(self) -> Union[Identifier, Relationship]:
        """Get the associated Identifier or Relationship."""
        if self.payload_type == PayloadType.Identifier:
            return Identifier.query.get(self.object_uuid)
        else:
            return Relationship.query.get(self.object_uuid)

    def __repr__(self):
        """String representation of the object event."""
        return f"<{self.event_id}: {self.object_uuid}>"
Esempio n. 14
0
class FuncKeyDestCustom(Base):

    DESTINATION_TYPE_ID = 10

    __tablename__ = 'func_key_dest_custom'
    __table_args__ = (
        PrimaryKeyConstraint('func_key_id', 'destination_type_id'),
        ForeignKeyConstraint(['func_key_id', 'destination_type_id'],
                             ['func_key.id', 'func_key.destination_type_id']),
        CheckConstraint(
            'destination_type_id = {}'.format(DESTINATION_TYPE_ID)),
    )

    func_key_id = Column(Integer)
    destination_type_id = Column(
        Integer, server_default="{}".format(DESTINATION_TYPE_ID))
    exten = Column(String(40), nullable=False)

    type = 'custom'

    func_key = relationship(FuncKey,
                            cascade='all,delete-orphan',
                            single_parent=True)

    def to_tuple(self):
        return (('exten', self.exten), )
Esempio n. 15
0
class QueueMember(Base):

    __tablename__ = 'queuemember'
    __table_args__ = (
        PrimaryKeyConstraint('queue_name', 'interface'),
        UniqueConstraint('queue_name', 'channel', 'usertype', 'userid',
                         'category'),
        Index('queuemember__idx__category', 'category'),
        Index('queuemember__idx__channel', 'channel'),
        Index('queuemember__idx__userid', 'userid'),
        Index('queuemember__idx__usertype', 'usertype'),
    )

    queue_name = Column(String(128))
    interface = Column(String(128))
    penalty = Column(Integer, nullable=False, server_default='0')
    commented = Column(Integer, nullable=False, server_default='0')
    usertype = Column(Enum('agent',
                           'user',
                           name='queuemember_usertype',
                           metadata=Base.metadata),
                      nullable=False)
    userid = Column(Integer, nullable=False)
    channel = Column(String(25), nullable=False)
    category = Column(Enum('queue',
                           'group',
                           name='queue_category',
                           metadata=Base.metadata),
                      nullable=False)
    position = Column(Integer, nullable=False, server_default='0')
Esempio n. 16
0
class CtiProfileXlet(Base):

    __tablename__ = 'cti_profile_xlet'
    __table_args__ = (
        PrimaryKeyConstraint('xlet_id', 'profile_id'),
        ForeignKeyConstraint(('xlet_id', ), ('cti_xlet.id', ),
                             ondelete='CASCADE'),
        ForeignKeyConstraint(('profile_id', ), ('cti_profile.id', ),
                             ondelete='CASCADE'),
        ForeignKeyConstraint(('layout_id', ), ('cti_xlet_layout.id', ),
                             ondelete='RESTRICT'),
    )

    xlet_id = Column(Integer)
    profile_id = Column(Integer)
    layout_id = Column(Integer)
    closable = Column(Boolean, server_default='True')
    movable = Column(Boolean, server_default='True')
    floating = Column(Boolean, server_default='True')
    scrollable = Column(Boolean, server_default='True')
    order = Column(Integer)

    cti_xlet = relationship("CtiXlet")
    cti_profile = relationship("CtiProfile")
    cti_xlet_layout = relationship("CtiXletLayout")
Esempio n. 17
0
class TopoMapAssociation(Base):
    """Associations between documents and maps.

    Used to cache which documents are within the area of a map. The entries in
    this table are created automatically when a maps is changed/added, when a
    document is added or a document geometry changes.
    """
    __tablename__ = 'map_associations'

    document_id = Column(
        Integer, ForeignKey(schema + '.documents.document_id'),
        nullable=False)
    document = relationship(
        Document, primaryjoin=document_id == Document.document_id
    )

    topo_map_id = Column(
        Integer, ForeignKey(schema + '.maps.document_id'),
        nullable=False)
    topo_map = relationship(
        TopoMap, primaryjoin=topo_map_id == TopoMap.document_id)

    __table_args__ = (
        PrimaryKeyConstraint(document_id, topo_map_id),
        Base.__table_args__
    )
Esempio n. 18
0
def create_table(metadata, iso_request_tbl, user_tbl, rack_layout_tbl,
                 reservoir_specs_tbl):
    "Table factory."
    tbl = Table(
        'lab_iso_request', metadata,
        Column('iso_request_id',
               Integer,
               ForeignKey(iso_request_tbl.c.iso_request_id,
                          ondelete='CASCADE',
                          onupdate='CASCADE'),
               nullable=False),
        Column('requester_id',
               Integer,
               ForeignKey(user_tbl.c.db_user_id),
               nullable=False), Column('delivery_date', Date),
        Column('comment', Text),
        Column('rack_layout_id',
               Integer,
               ForeignKey(rack_layout_tbl.c.rack_layout_id,
                          onupdate='CASCADE',
                          ondelete='CASCADE'),
               nullable=False),
        Column('iso_plate_reservoir_specs_id',
               Integer,
               ForeignKey(reservoir_specs_tbl.c.reservoir_specs_id,
                          ondelete='NO ACTION',
                          onupdate='NO ACTION'),
               nullable=False),
        Column('process_job_first', Boolean, nullable=False))
    PrimaryKeyConstraint(tbl.c.iso_request_id)
    return tbl
Esempio n. 19
0
class Predmet(Base):
    __tablename__ = 'predmet'

    id = Column(Integer)
    naziv = Column(String(50), nullable=False)
    profesori = relationship('Profesor', secondary='predaje')
    razredi = relationship('Razred', secondary='dozvoljenirazredi')

    __table_args__ = (PrimaryKeyConstraint(id), UniqueConstraint(naziv), {})

    def __init__(self, naziv):
        self.razredi = []
        self.naziv = naziv

    def __eq__(self, obj):
        if self is obj:
            return True
        if obj is None:
            return False
        if not isinstance(obj, Predmet):
            return False
        return self.id == obj.id

    def __repr__(self):
        return f'<Predmet(id={self.id}, naziv={self.naziv})>'
Esempio n. 20
0
File: db.py Progetto: znamy/obspy
        class TSIndexSummaryTable(Base):
            """
            DB table containing tsindex.
            """
            __tablename__ = table_name
            __table_args__ = (
                PrimaryKeyConstraint('network', 'station',
                                     'location', 'channel',
                                     'earliest', 'latest'),
                {'keep_existing': True}
            )

            network = Column(String)
            station = Column(String)
            location = Column(String)
            channel = Column(String)
            earliest = Column(String)
            latest = Column(String)
            updt = Column(String,
                          default=datetime.datetime.utcnow)

            def __repr__(self):
                return "<TSIndexSummaryTable('%s %s %s %s %s %s %s')>" % \
                        (self.network, self.station, self.location,
                         self.channel, self.earliest, self.latest, self.updt)
Esempio n. 21
0
class Predaje(Base):
    __tablename__ = 'predaje'

    profesor_id = Column(Integer)
    predmet_id = Column(Integer)
    profesor = relationship('Profesor', lazy='joined')
    predmet = relationship('Predmet')

    __table_args__ = (
        ForeignKeyConstraint([profesor_id],
                             [Profesor.id]),  # add on delete cascade
        ForeignKeyConstraint([predmet_id],
                             [Predmet.id]),  # add on delete cascade
        PrimaryKeyConstraint(profesor_id, predmet_id),
        {})

    def __init__(self, profesor, predmet):
        if isinstance(profesor, Profesor):
            self.profesor = profesor
        elif isintance(profesor, int):
            self.profesor_id = profesor
        else:
            raise ValueError('Cannot accept type of argument profesor')
        if isinstance(predmet, Predmet):
            self.predmet = predmet
        elif isintance(predmet, int):
            self.predmet_id = predmet
        else:
            raise ValueError('Cannot accept type of argument predmet')

    def __repr__(self):
        return f'<Predaje()>'
Esempio n. 22
0
class PagingUser(Base):

    __tablename__ = 'paginguser'
    __table_args__ = (
        PrimaryKeyConstraint('pagingid', 'userfeaturesid', 'caller'),
        Index('paginguser__idx__pagingid', 'pagingid'),
    )

    pagingid = Column(Integer, ForeignKey('paging.id'), nullable=False)
    userfeaturesid = Column(Integer,
                            ForeignKey('userfeatures.id'),
                            nullable=False)
    caller = Column(Integer, nullable=False, autoincrement=False)

    paging = relationship('Paging')
    user = relationship('UserFeatures')

    @hybrid_property
    def paging_id(self):
        return self.pagingid

    @paging_id.setter
    def paging_id(self, value):
        self.pagingid = value

    @hybrid_property
    def user_id(self):
        return self.userfeaturesid

    @user_id.setter
    def user_id(self, value):
        self.userfeaturesid = value
Esempio n. 23
0
class Ocena(Base):
    __tablename__ = 'ocena'

    slusa_ucenik_id = Column(Integer)
    slusa_predmet_id = Column(Integer)
    ocena_id = Column(Integer, default=random_integer)
    datum = Column(DateTime, default=datetime.datetime.utcnow)
    vrednost = Column(Integer, nullable=False)
    slusa = relationship('Slusa', back_populates='ocene', lazy='joined')

    def __init__(self, vrednost, ucenik, predmet):
        self.vrednost = vrednost
        self.ucenik_id = ucenik.id
        self.predmet_id = predmet.id

    def __init__(self, vrednost, slusa):
        self.vrednost = vrednost
        self.slusa = slusa

    __table_args__ = (
        ForeignKeyConstraint(
            [slusa_ucenik_id, slusa_predmet_id],
            [Slusa.ucenik_id, Slusa.predmet_id]),  # add on delete cascade
        PrimaryKeyConstraint(slusa_ucenik_id, slusa_predmet_id, ocena_id),
        {})

    def __repr__(self):
        return f'<Ocena(vrednost={vrednost})>'
class IoTRawDataCount(DeclarativeBase, SQLSourceMixin):
    __tablename__ = 'rawdata.iot.count'
    __table_args__ = (PrimaryKeyConstraint("date", "device_id"), {
        "mysql_engine": "RocksDB",
    })

    date = Column(Date, )
    device_id = Column(String(15, collation='utf8_bin'), )

    ampere = Column(SmallInteger, )
    co = Column(SmallInteger, )
    devstat = Column(SmallInteger, )
    humidity = Column(SmallInteger, )
    humidity_main = Column(SmallInteger, )
    no2 = Column(SmallInteger, )
    noise = Column(SmallInteger, )
    o3 = Column(SmallInteger, )
    pm1 = Column(SmallInteger, )
    pm2_5 = Column(SmallInteger, )
    pm10 = Column(SmallInteger, )
    temperature = Column(SmallInteger, )
    temperature_main = Column(SmallInteger, )
    voc = Column(SmallInteger, )
    volt = Column(SmallInteger, )

    _created_at = Column(TIMESTAMP(), server_default=func.now())
    _updated_at = Column(
        TIMESTAMP(),
        server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))
Esempio n. 25
0
class Implementation(Base):
    __tablename__ = "implementation"
    hash = Column(String, nullable=False)
    name = Column(String, nullable=False)
    operation_name = Column(String, nullable=False)
    primitive_name = Column(String, nullable=False)
    path = Column(String)  #Path relative to algobase
    macros = Column(JSONEncodedDict)

    __table_args__ = (
        PrimaryKeyConstraint("hash"),
        ForeignKeyConstraint(
            ["primitive_name", "operation_name"],
            ["primitive.name", "primitive.operation_name"],
        ),
    )

    def validate_hash(self, platforms_path):
        """Verifies if hash still valid"""
        hash = dirchecksum(os.path.join(platforms_path, self.path))
        return hash == self.hash

    def get_config_assoc(self, config):
        s = xbxdb.scoped_session()
        a = s.query(ConfigImplAssociation).filter(
            ConfigImplAssociation.config_hash == config.hash,
            ConfigImplAssociation.implementation_hash == self.hash).one()
        return a
Esempio n. 26
0
def _add_artifact_properties_table():
    op.create_table('artifact_properties',
                    Column('id', String(length=36), nullable=False),
                    Column('artifact_id', String(length=36), nullable=False),
                    Column('name', String(length=255), nullable=False),
                    Column('string_value', String(length=255), nullable=True),
                    Column('int_value', Integer(), nullable=True),
                    Column('numeric_value', Numeric(), nullable=True),
                    Column('bool_value', Boolean(), nullable=True),
                    Column('text_value', Text(), nullable=True),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=False),
                    Column('position', Integer(), nullable=True),
                    ForeignKeyConstraint(
                        ['artifact_id'],
                        ['artifacts.id'],
                    ),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_artifact_properties_artifact_id',
                    'artifact_properties', ['artifact_id'],
                    unique=False)
    op.create_index('ix_artifact_properties_name',
                    'artifact_properties', ['name'],
                    unique=False)
Esempio n. 27
0
def upgrade():
    op.create_table(
        'user', Column('id', UUID(), nullable=False),
        Column('created_at', DateTime(timezone=True), nullable=False),
        Column('email', Unicode(), nullable=False),
        Column('password', PasswordType(), nullable=False),
        PrimaryKeyConstraint('id'), UniqueConstraint('email'))
Esempio n. 28
0
def _add_artifact_blobs_table():
    op.create_table('artifact_blobs',
                    Column('id', String(length=36), nullable=False),
                    Column('artifact_id', String(length=36), nullable=False),
                    Column('size', BigInteger(), nullable=False),
                    Column('checksum', String(length=32), nullable=True),
                    Column('name', String(length=255), nullable=False),
                    Column('item_key', String(length=329), nullable=True),
                    Column('position', Integer(), nullable=True),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=False),
                    ForeignKeyConstraint(
                        ['artifact_id'],
                        ['artifacts.id'],
                    ),
                    PrimaryKeyConstraint('id'),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)

    op.create_index('ix_artifact_blobs_artifact_id',
                    'artifact_blobs', ['artifact_id'],
                    unique=False)
    op.create_index('ix_artifact_blobs_name',
                    'artifact_blobs', ['name'],
                    unique=False)
Esempio n. 29
0
class Association(Base):
    """Associations between documents.

    Certain associations build a hierarchy between the documents (e.g. between
    summits), in this case it's important which document is the "parent" and
    which is the "child" of the association. For other undirected associations
    it doesn't matter which document is the "parent" or "child".
    """
    __tablename__ = 'associations'

    parent_document_id = Column(Integer,
                                ForeignKey(schema + '.documents.document_id'),
                                nullable=False)
    parent_document = relationship(
        Document, primaryjoin=parent_document_id == Document.document_id)

    child_document_id = Column(Integer,
                               ForeignKey(schema + '.documents.document_id'),
                               nullable=False)
    child_document = relationship(
        Document, primaryjoin=child_document_id == Document.document_id)

    __table_args__ = (PrimaryKeyConstraint(parent_document_id,
                                           child_document_id),
                      Base.__table_args__)

    def get_log(self, user_id, is_creation=True):
        return AssociationLog(parent_document_id=self.parent_document_id,
                              child_document_id=self.child_document_id,
                              user_id=user_id,
                              is_creation=is_creation)
Esempio n. 30
0
class FuncKeyDestBSFilter(Base):

    DESTINATION_TYPE_ID = 12

    __tablename__ = 'func_key_dest_bsfilter'
    __table_args__ = (
        PrimaryKeyConstraint('func_key_id', 'destination_type_id', 'filtermember_id'),
        ForeignKeyConstraint(['func_key_id', 'destination_type_id'],
                             ['func_key.id', 'func_key.destination_type_id']),
        CheckConstraint('destination_type_id = {}'.format(DESTINATION_TYPE_ID)),
    )

    func_key_id = Column(Integer)
    destination_type_id = Column(Integer, server_default="{}".format(DESTINATION_TYPE_ID))
    filtermember_id = Column(Integer, ForeignKey('callfiltermember.id'), nullable=False)

    type = 'bsfilter'

    func_key = relationship(FuncKey, cascade='all,delete-orphan', single_parent=True)
    filtermember = relationship(Callfiltermember)

    def to_tuple(self):
        return (('filter_member_id', self.filtermember_id),)

    @hybrid_property
    def filter_member_id(self):
        return self.filtermember_id

    @filter_member_id.setter
    def filter_member_id(self, value):
        self.filtermember_id = value