forked from CapivaraProjects/database
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassifier.py
More file actions
42 lines (37 loc) · 1.47 KB
/
Classifier.py
File metadata and controls
42 lines (37 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from sqlalchemy import Column, String, Integer, ForeignKey
from sqlalchemy.orm import relationship
import database.Plant
import database.Analysis
from models.Classifier import Classifier as ClassifierModel
from repository.base import Base
class Classifier(Base.Base):
__tablename__ = 'classifiers'
id = Column(Integer, primary_key=True)
idPlant = Column('id_plant', Integer, ForeignKey('plants.id'))
tag = Column('tag', String(2000))
path = Column('path', String(2000))
plant = relationship('Plant', back_populates='classifiers')
analysis = relationship('database.Analysis.Analysis', lazy='subquery',
back_populates='classifier')
def __init__(self,
id=0,
idPlant=0,
tag="",
path="",
plant=object(),
analyses=[],
classifier=ClassifierModel()):
if (classifier.id or classifier.tag or classifier.path):
self.id = classifier.id
self.idPlant = classifier.plant.id
self.tag = classifier.tag
self.path = classifier.path
self.analyses = []
for analysis in classifier.analyses:
self.analyses.append(database.Analysis.Analysis(analysis))
else:
self.id = id
self.idPlant = idPlant
self.tag = tag
self.path = path
self.analyses = analyses