class EntityProperty(db.Model): """key-value property pairs for entity or event """ __tablename__ = 'entity_properties' __table_args__ = {'mysql_engine': 'InnoDB'} id = db.Column(db.Integer, primary_key=True) label = db.Column(db.String(64)) value = db.Column(db.String(64)) entity = db.Column(db.ForeignKey(Entity.id), nullable=False) def __repr__(self): return "<Entity Property(key='%s', value='%s')>" % self.key, self.value
class User(db.Model): __tablename__ = 'users' __table_args__ = {'mysql_engine': 'InnoDB'} id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(32), unique=True) password = db.Column(db.String(32)) def __init__(self, username, password): self.username = username self.password = password def __repr__(self): return "<User(name='%s')>" % self.username
class Document(db.Model): __tablename__ = 'documents' __table_args__ = {'mysql_engine': 'InnoDB'} id = db.Column(db.Integer, primary_key=True) document_id = db.Column(db.String(64)) text = db.Column(db.Text) def __repr__(self): return "<Document(id='%s', text='%s')>" % self.doc_id, self.text
class ArgumentRole(db.Model): __tablename__ = 'argument_roles' __table_args__ = {'mysql_engine': 'InnoDB'} id = db.Column(db.Integer, primary_key=True) role = db.Column(db.String(32)) version = db.Column(db.Integer, db.ForeignKey(Version.id)) def __repr__(self): return "<Argument Role(role='%s', start='%s', end='%s', text='%s')>" % self.role
class EventCategory(db.Model): __tablename__ = 'event_category' __table_args__ = {'mysql_engine': 'InnoDB'} id = db.Column(db.Integer, primary_key=True) category = db.Column(db.String(32)) version = db.Column(db.Integer, db.ForeignKey(Version.id)) def __repr__(self): return "<Event Category(category='%s')>" % self.category
class Version(db.Model): __tablename__ = 'versions' __table_args__ = {'mysql_engine': 'InnoDB'} id = db.Column(db.Integer, primary_key=True) # TODO: how to get the user from a version object, currently it is just user id not user object user = db.Column(db.Integer, db.ForeignKey(User.id)) datetime = db.Column(db.DateTime, default=datetime.datetime.utcnow()) version = db.Column(db.String(64)) entities = db.relationship('Entity') events = db.relationship('Event') entity_categories = db.relationship('EntityCategory') event_categories = db.relationship('EventCategory') def __init__(self, user, version): self.user = user self.version = version def __repr__(self): return "<Version(user='******', version='%s')>" % self.user.username, self.version