コード例 #1
0
class ActorDetails(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    actor_id = db.Column(db.Integer, db.ForeignKey('aktoren.id'))
    service_id = db.Column(db.Integer, db.ForeignKey('sub_service.id'))
    role_id = db.Column(db.Integer, db.ForeignKey('actors.id'))

    def __repr__(self):
        return '(actor_id: {}, component_id: {}, role_id: {})'.format(
            self.actor_id, self.service_id, self.role_id)
コード例 #2
0
class Aktoren(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    details = db.relationship('ActorDetails', backref='actor', lazy='dynamic')
    attackers = db.relationship('Attacker',
                                secondary=act_atk,
                                backref=db.backref('attacker', lazy='dynamic'),
                                lazy='dynamic')

    # components = db.relationship('SubService',
    #                              secondary=actor_component,
    #                              backref=db.backref('actors', lazy='dynamic'),
    #                              lazy='dynamic')

    def alrdy_used(self, atk):
        return self.attackers.filter(
            act_atk.c.attacker_id == atk.id).count() > 0

    def add_atk(self, atk):
        if not self.alrdy_used(atk):
            self.attackers.append(atk)
            return self

    def remove_atk(self, atk):
        if self.alrdy_used(atk):
            self.attackers.remove(atk)
            return self
コード例 #3
0
class ExtraFreqReq(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    bbm_id = db.Column(db.Integer, db.ForeignKey('bb_mechanisms.id'))

    def __repr__(self):
        return self.name
コード例 #4
0
class Attacker(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    soft_goals = db.relationship('SoftGoal',
                                 secondary=atk_sg,
                                 backref=db.backref('attackers',
                                                    lazy='dynamic'),
                                 lazy='dynamic')

    def alrdy_used(self, sg):
        return self.soft_goals.filter(
            atk_sg.c.softgoal_id == sg.id).count() > 0

    def add_sg(self, sg):
        if not self.alrdy_used(sg):
            self.soft_goals.append(sg)
            return self

    def remove_sg(self, sg):
        if self.alrdy_used(sg):
            self.soft_goals.remove(sg)
            return self

    def has_sg(self):
        sg = [s for s in self.soft_goals]
        if sg:
            return True
        else:
            return False
コード例 #5
0
class FunctionalRequirement(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(280))
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    hard_goals = db.relationship('HardGoal', backref='functionalreq')
    services = db.relationship('SubService',
                               secondary=freq_serv,
                               backref=db.backref('functionalreqs',
                                                  lazy='dynamic'),
                               lazy='dynamic')

    def alrdy_used(self, serv):
        return self.services.filter(freq_serv.c.serv_id == serv.id).count() > 0

    def add_serv(self, serv):
        if not self.alrdy_used(serv):
            self.services.append(serv)
            return self

    def remove_serv(self, serv):
        if self.alrdy_used(serv):
            self.services.remove(serv)
            return self

    def __repr__(self):
        return '{}'.format(self.description)
コード例 #6
0
class Good(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(140))
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    stakeholders = db.relationship('Stakeholder',
                                   secondary=good_stakeholder,
                                   backref=db.backref('goods', lazy='dynamic'),
                                   lazy='dynamic')

    def alrdy_used(self, sh):
        return self.stakeholders.filter(
            good_stakeholder.c.stakeholder_id == sh.id).count() > 0

    def add_stakeholder(self, sh):
        if not self.alrdy_used(sh):
            self.stakeholders.append(sh)
            return self

    def remove_stakeholder(self, sh):
        if self.alrdy_used(sh):
            self.stakeholders.remove(sh)
            return self

    def __repr__(self):
        return '{}'.format(self.description)
コード例 #7
0
class HardGoal(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    authenticity = db.Column(db.String(280))
    confidentiality = db.Column(db.String(280))
    integrity = db.Column(db.String(280))
    # applications = db.Column(db.String(280))
    component_id = db.Column(db.Integer, db.ForeignKey('sub_service.id'))
    freq_id = db.Column(db.Integer, db.ForeignKey('functional_requirement.id'))
    sg_id = db.Column(db.Integer, db.ForeignKey('soft_goal.id'))
    priority = db.Column(db.Boolean(), default=False)
    cb_value = db.Column(db.String(300))
    description = db.Column(db.String(500))
    extra_hg_used = db.Column(db.Boolean)
    extra_hg = db.Column(db.Boolean)
    original_hg = db.Column(db.Integer)
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    unique_id = db.Column(db.String(200), unique=True)
    # soft_goals = db.relationship('SoftGoal', backref='hardgoals', lazy='dynamic')
    correctly_implemented = db.Column(db.Integer, default=4)
    bbmechanisms = db.relationship(
        'BbMechanisms',
        secondary=hard_mechanism,
        # primaryjoin=(hard_mechanism.c.hg_id == id),
        # secondaryjoin=(hard_mechanism.c.bbmech_id == id),
        backref=db.backref('hardgoals', lazy='dynamic'),
        lazy='dynamic')

    def alrdy_used(self, bbm):
        return self.bbmechanisms.filter(
            hard_mechanism.c.bbmech_id == bbm.id).count() > 0

    def add_bb(self, bbm):
        if not self.alrdy_used(bbm):
            self.bbmechanisms.append(bbm)
            return self

    def remove_bb(self, bbm):
        if self.alrdy_used(bbm):
            self.bbmechanisms.remove(bbm)
            return self

    def __repr__(self):
        if self.description is not None:
            return '{}'.format(self.description)
        else:
            return '<Hard Goal Place Holder {} NOT TO BE USED OR REMOVED>'.format(
                self.id)
コード例 #8
0
class Stakeholder(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(64))
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))

    def __repr__(self):
        return '{}'.format(self.nickname)

    def as_dict(self):
        return {'nickname': self.nickname}
コード例 #9
0
class SubService(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    hard_goals = db.relationship('HardGoal', backref='component')
    actor_details = db.relationship('ActorDetails',
                                    backref='component',
                                    lazy='dynamic')

    def __repr__(self):
        return '{}'.format(self.name)
コード例 #10
0
class SoftGoal(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    cb_value = db.Column(db.String(300))
    authenticity = db.Column(db.String(280))
    confidentiality = db.Column(db.String(280))
    integrity = db.Column(db.String(280))
    priority = db.Column(db.Boolean)
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    # hardgoal_id = db.Column(db.Integer, db.ForeignKey(HardGoal.id))
    hard_goals = db.relationship('HardGoal', backref='softgoal')

    def __repr__(self):
        return '{}'.format(self.cb_value)
コード例 #11
0
from editorapp import db, app, login
from flask_login import LoginManager
from flask_security import RoleMixin, UserMixin


# lm = LoginManager(app)
@login.user_loader
def load_user(id):
    return Users.query.get(int(id))


wprojects = db.Table(
    'wprojects', db.Column('user_id', db.Integer, db.ForeignKey('users.id')),
    db.Column('project_id', db.Integer, db.ForeignKey('projects.id')))

roles_users = db.Table(
    'roles_users', db.Column('user_id', db.Integer, db.ForeignKey('users.id')),
    db.Column('role_id', db.Integer, db.ForeignKey('role.id')))

hard_mechanism = db.Table(
    'hard_mechanism',
    db.Column('hg_id', db.Integer, db.ForeignKey('hard_goal.id')),
    db.Column('bbmech_id', db.Integer, db.ForeignKey('bb_mechanisms.id')))

bb_assumptions = db.Table(
    'bb_assumptions',
    db.Column('bb_id', db.Integer, db.ForeignKey('bb_mechanisms.id')),
    db.Column('assumptions_id', db.Integer, db.ForeignKey('assumptions.id')))

bb_actors = db.Table(
    'bb_actors',