1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# |
3
|
|
|
# This file is part of SENAITE.CORE. |
4
|
|
|
# |
5
|
|
|
# SENAITE.CORE is free software: you can redistribute it and/or modify it under |
6
|
|
|
# the terms of the GNU General Public License as published by the Free Software |
7
|
|
|
# Foundation, version 2. |
8
|
|
|
# |
9
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT |
10
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
11
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
12
|
|
|
# details. |
13
|
|
|
# |
14
|
|
|
# You should have received a copy of the GNU General Public License along with |
15
|
|
|
# this program; if not, write to the Free Software Foundation, Inc., 51 |
16
|
|
|
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17
|
|
|
# |
18
|
|
|
# Copyright 2018-2021 by it's authors. |
19
|
|
|
# Some rights reserved, see README and LICENSE. |
20
|
|
|
|
21
|
|
|
from bika.lims import config |
22
|
|
|
from bika.lims.content.bikaschema import BikaSchema |
23
|
|
|
from bika.lims.interfaces import IAutoImportLog |
24
|
|
|
from DateTime import DateTime |
25
|
|
|
from Products.Archetypes import atapi |
26
|
|
|
from Products.Archetypes.public import BaseContent |
27
|
|
|
from Products.Archetypes.public import DateTimeField |
28
|
|
|
from Products.Archetypes.public import ReferenceField |
29
|
|
|
from Products.Archetypes.public import StringField |
30
|
|
|
from Products.Archetypes.public import TextField |
31
|
|
|
from Products.Archetypes.references import HoldingReference |
32
|
|
|
from zope.interface import implements |
33
|
|
|
|
34
|
|
|
schema = BikaSchema.copy() + atapi.Schema(( |
35
|
|
|
|
36
|
|
|
# Results File that system wanted to import |
37
|
|
|
StringField( |
38
|
|
|
"ImportFile", |
39
|
|
|
default="", |
40
|
|
|
), |
41
|
|
|
|
42
|
|
|
ReferenceField( |
43
|
|
|
"Instrument", |
44
|
|
|
allowed_types=("Instrument",), |
45
|
|
|
referenceClass=HoldingReference, |
46
|
|
|
relationship="InstrumentImportLogs", |
47
|
|
|
), |
48
|
|
|
|
49
|
|
|
StringField( |
50
|
|
|
"Interface", |
51
|
|
|
default="", |
52
|
|
|
), |
53
|
|
|
|
54
|
|
|
TextField( |
55
|
|
|
"Results", |
56
|
|
|
default="", |
57
|
|
|
), |
58
|
|
|
|
59
|
|
|
DateTimeField( |
60
|
|
|
"LogTime", |
61
|
|
|
default=DateTime(), |
62
|
|
|
), |
63
|
|
|
)) |
64
|
|
|
|
65
|
|
|
schema["title"].widget.visible = False |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
class AutoImportLog(BaseContent): |
69
|
|
|
""" |
70
|
|
|
This object will have some information/log about auto-import process |
71
|
|
|
once they are done(failed). |
72
|
|
|
""" |
73
|
|
|
implements(IAutoImportLog) |
74
|
|
|
schema = schema |
|
|
|
|
75
|
|
|
_at_rename_after_creation = True |
76
|
|
|
|
77
|
|
|
def _renameAfterCreation(self, check_auto_id=False): |
78
|
|
|
from bika.lims.idserver import renameAfterCreation |
79
|
|
|
renameAfterCreation(self) |
80
|
|
|
|
81
|
|
|
def getInstrumentUID(self): |
82
|
|
|
if self.getInstrument(): |
83
|
|
|
return self.getInstrument().UID() |
84
|
|
|
return None |
85
|
|
|
|
86
|
|
|
def getInstrumentTitle(self): |
87
|
|
|
if self.getInstrument(): |
88
|
|
|
return self.getInstrument().Title() |
89
|
|
|
return None |
90
|
|
|
|
91
|
|
|
def getInstrumentUrl(self): |
92
|
|
|
if self.getInstrument(): |
93
|
|
|
return self.getInstrument().absolute_url_path() |
94
|
|
|
return None |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
# Activating the content type in Archetypes' internal types registry |
98
|
|
|
atapi.registerType(AutoImportLog, config.PROJECTNAME) |
99
|
|
|
|