class Place(db.Model, CRUDMixin, MarshmallowMixin): """ Description. :param int id: the database object identifier :param str unique: alpha-numeric code for shorthand identifier :param str name: what the place is called :param int : :param int : :param int : :param int : :param int : :param int : """ __schema__ = PlaceSchema id = db.Column(db.Integer, primary_key=True) unique = db.Column(db.String(255), unique=True, default=id_generator) name = db.Column(db.String(255)) description = db.Column(db.String(8**7)) address = db.Column(db.String(4096)) lat = db.Column(db.Float()) lon = db.Column(db.Float()) owners = db.relationship('Person', secondary="places_owners", lazy='dynamic', backref="properties") excerpts = db.relationship('Excerpt', secondary="places_excerpts", lazy='dynamic') def __str__(self): return (self.name)
class Group(db.Model, CRUDMixin, MarshmallowMixin): """ Description. :param int id: the database object identifier :param str unique: alpha-numeric code for shorthand identifier :param str name: what the group is called :param int : :param int : """ __schema__ = GroupSchema id = db.Column(db.Integer, primary_key=True) unique = db.Column(db.String(255), unique=True, default=id_generator) name = db.Column(db.String(255)) members = db.relationship('Person', secondary="groups_members", lazy='dynamic', backref="groups") excerpts = db.relationship('Excerpt', secondary="groups_excerpts", lazy='dynamic') def __str__(self): return self.name
class Person(db.Model, CRUDMixin, MarshmallowMixin): """ Description. :param int id: the database object identifier :param str unique: alpha-numeric code for shorthand identifier :param str name: what the person is called :param str alias: that *other* thing the person is called :param str slug: a URL-friendly identifier :param [Excerpt] excerpts: null :param [Event] events: null :param [Place] places: null :param [Item] possessions: null :param [Place] properties: null :param [Group] groups: null :param [Acquaintance] acquaintances: null """ __schema__ = PersonSchema id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(255)) alias = db.Column(db.String(255)) unique = db.Column(db.String(255), unique=True, default=id_generator) excerpts = db.relationship('Excerpt', secondary="persons_excerpts", lazy='dynamic') def isa(self, isa_type, of=None): e = Acquaintance(person=self, isa=isa_type, acquainted=of) result = e.save() return result def __str__(self): return (self.name)
class RegisteredDevice(db.Model, CRUDMixin): "A Registered device is allowed to create Temperatures" __schema__ = RegisteredDeviceSchema id = db.Column(db.Integer(), primary_key=True) device_id = db.Column(db.String(16)) time_stamp = db.Column(db.DateTime, onupdate=datetime.datetime.now) client_hash = db.Column(db.String(64))
class Temperature(db.Model, CRUDMixin): "A Temperature is a single temperature log for a specific device/participant" id = db.Column(db.Integer(), primary_key=True) mac_address = db.Column(db.String(17)) android_id = db.Column(db.String(16)) device_id = db.Column(db.String(16)) system_time = db.Column(db.DateTime) time_stamp_device = db.Column(db.DateTime) temperature = db.Column(db.Float()) client_hash = db.Column(db.String(64)) participant_number = db.Column(db.Integer) study_number = db.Column(db.Integer)
class Resource(db.Model, CRUDMixin, MarshmallowMixin): """ A Resource is an authoritative information source from which evidence is drawn. Usually, a Resource is an artifact like a newspaper article, a report, or another document. These documents usually have an associated URL. Any time an Excerpt is used, that Excerpt must be directly quotable from a Resource. :param int id: the database object identifier :param str unique: alpha-numeric code for shorthand identifier :param str name: what the resource is called :param str url: the canonical URL for the resource :param str publisher: the name of the institution reputationally backing this resource :param str author: the name of the author(s) :param str description: a short summary of this resource """ __schema__ = ResourceSchema id = db.Column(db.Integer, primary_key=True) unique = db.Column(db.String(255), unique=True, default=id_generator) name = db.Column(db.String(4096)) url = db.Column(db.String(4096)) publisher = db.Column(db.String(4096)) author = db.Column(db.String(4096)) description = db.Column(db.String(8**7)) def __str__(self): return (self.url)
class Excerpt(db.Model, CRUDMixin, MarshmallowMixin): """ Description. :param int id: the database object identifier :param str unique: alpha-numeric code for shorthand identifier :param str content: the actual quoted material of the excerpt :param Resource resource: the Resource from which this excerpt comes :param str xpath: the xpath leading to this excerpt within the Resource """ __schema__ = ExcerptSchema id = db.Column(db.Integer, primary_key=True) unique = db.Column(db.String(255), unique=True, default=id_generator) content = db.Column(db.String(8**7)) resource = db.relationship('Resource', backref='excerpts') resource_id = db.Column(db.Integer, db.ForeignKey('resource.id'), nullable=False) xpath = db.Column(db.String(4096)) def __str__(self): return (self.content)
class Event(db.Model, CRUDMixin, MarshmallowMixin): """ Description. :param int id: the database object identifier :param str unique: alpha-numeric code for shorthand identifier :param str name: what the event is called :param int : :param int : :param int : :param int : :param int : :param int : :param int : """ __schema__ = EventSchema id = db.Column(db.Integer, primary_key=True) unique = db.Column(db.String(255), unique=True, default=id_generator) name = db.Column(db.String(255)) description = db.Column(db.String(8**7)) place_id = db.Column(db.Integer, db.ForeignKey('place.id')) place = db.relationship("Place", backref="events") phone = db.Column(db.Boolean(), default=False) timestamp = db.Column(db.DateTime()) actors = db.relationship('Person', secondary="events_actors", lazy='dynamic', backref="events") excerpts = db.relationship('Excerpt', secondary="events_excerpts", lazy='dynamic') items = db.relationship('Item', secondary="events_items", lazy='dynamic') def __str__(self): return self.name
class Temperature(db.Model, CRUDMixin): "A Temperature is a single temperature log for a specific device/participant" __schema__ = TemperatureSchema __table_args__ = (db.UniqueConstraint('client_hash', 'time_stamp_device', name='_client_time'), ) id = db.Column(db.Integer(), primary_key=True) # mac_address = db.Column(db.String(17)) # android_id = db.Column(db.String(16)) # device_id = db.Column(db.String(16)) system_time = db.Column(db.DateTime, onupdate=datetime.datetime.now) time_stamp_device = db.Column(db.DateTime) temperature = db.Column(db.Float()) client_hash = db.Column(db.String(64)) participant_number = db.Column(db.Integer) study_number = db.Column(db.Integer)
class Acquaintance(db.Model, CRUDMixin, MarshmallowMixin): """ Description. :param int id: the database object identifier :param int : :param int : :param int : :param int : :param int : """ __schema__ = AcquaintanceSchema isa = db.Column(db.String(64)) excerpts = db.relationship('Excerpt', secondary="acquaintance_excerpts", lazy='dynamic') person_id = db.Column(db.Integer(), db.ForeignKey('person.id'), primary_key=True) person = db.relationship(Person, primaryjoin=person_id == Person.id, backref='acquaintances') acquainted_id = db.Column(db.Integer(), db.ForeignKey('person.id'), primary_key=True) acquainted = db.relationship(Person, primaryjoin=acquainted_id == Person.id) def add_excerpt(self, excerpt): annotation = AcquaintanceExcerpt.create( excerpt_id=excerpt.id, person_id=self.person_id, acquainted_id=self.acquainted_id) return annotation def __str__(self): return ("%s isa %s of %s)" % (self.person, self.isa, self.acquainted))
class Registered_Device(db.Model, CRUDMixin): "A Registered device is allowed to create Temperatures" id = db.Column(db.Integer(), primary_key=True) device_id = db.Column(db.String(16)) time_stamp = db.Column(db.DateTime) client_hash = db.Column(db.String(64))