sapiopycommons 2025.2.6a421__py3-none-any.whl → 2025.2.7a424__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sapiopycommons might be problematic. Click here for more details.
- sapiopycommons/callbacks/callback_util.py +363 -1217
- sapiopycommons/chem/Molecules.py +2 -0
- sapiopycommons/datatype/data_fields.py +1 -1
- sapiopycommons/eln/experiment_handler.py +1 -2
- sapiopycommons/eln/experiment_report_util.py +7 -7
- sapiopycommons/files/file_bridge.py +0 -76
- sapiopycommons/files/file_bridge_handler.py +110 -325
- sapiopycommons/files/file_data_handler.py +2 -2
- sapiopycommons/files/file_validator.py +5 -6
- sapiopycommons/flowcyto/flow_cyto.py +1 -1
- sapiopycommons/general/accession_service.py +1 -1
- sapiopycommons/general/aliases.py +27 -40
- sapiopycommons/general/audit_log.py +2 -2
- sapiopycommons/general/custom_report_util.py +1 -24
- sapiopycommons/general/exceptions.py +2 -41
- sapiopycommons/multimodal/multimodal.py +0 -1
- sapiopycommons/processtracking/custom_workflow_handler.py +3 -3
- sapiopycommons/recordmodel/record_handler.py +3 -5
- sapiopycommons/webhook/webhook_handlers.py +55 -445
- {sapiopycommons-2025.2.6a421.dist-info → sapiopycommons-2025.2.7a424.dist-info}/METADATA +1 -1
- {sapiopycommons-2025.2.6a421.dist-info → sapiopycommons-2025.2.7a424.dist-info}/RECORD +23 -27
- sapiopycommons/customreport/auto_pagers.py +0 -270
- sapiopycommons/elain/__init__.py +0 -0
- sapiopycommons/elain/tool_of_tools.py +0 -510
- sapiopycommons/general/directive_util.py +0 -86
- {sapiopycommons-2025.2.6a421.dist-info → sapiopycommons-2025.2.7a424.dist-info}/WHEEL +0 -0
- {sapiopycommons-2025.2.6a421.dist-info → sapiopycommons-2025.2.7a424.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import re
|
|
4
3
|
from abc import abstractmethod
|
|
5
4
|
from typing import Any
|
|
6
5
|
|
|
@@ -10,9 +9,9 @@ from sapiopylib.rest.pojo.datatype.FieldDefinition import VeloxIntegerFieldDefin
|
|
|
10
9
|
AbstractVeloxFieldDefinition
|
|
11
10
|
|
|
12
11
|
from sapiopycommons.callbacks.callback_util import CallbackUtil
|
|
13
|
-
from sapiopycommons.customreport.auto_pagers import QuickReportDictAutoPager
|
|
14
12
|
from sapiopycommons.files.file_data_handler import FileDataHandler, FilterList
|
|
15
13
|
from sapiopycommons.general.aliases import UserIdentifier, AliasUtil
|
|
14
|
+
from sapiopycommons.general.custom_report_util import CustomReportUtil
|
|
16
15
|
from sapiopycommons.general.exceptions import SapioUserCancelledException
|
|
17
16
|
from sapiopycommons.general.time_util import TimeUtil
|
|
18
17
|
|
|
@@ -312,8 +311,8 @@ class MatchesPatternRule(ColumnRule):
|
|
|
312
311
|
"""
|
|
313
312
|
pattern: str
|
|
314
313
|
|
|
315
|
-
def __init__(self, header: str, pattern: str
|
|
316
|
-
|
|
314
|
+
def __init__(self, header: str, pattern: str, *, reason: str | None = None, whitelist: FilterList = None,
|
|
315
|
+
blacklist: FilterList = None):
|
|
317
316
|
"""
|
|
318
317
|
:param header: The header that this rule acts upon.
|
|
319
318
|
:param pattern: A regex pattern.
|
|
@@ -530,7 +529,7 @@ class UniqueSystemValueRule(ColumnRule):
|
|
|
530
529
|
# Run a quick report for all records of this type that match these field values.
|
|
531
530
|
term = RawReportTerm(self.data_type_name, self.data_field_name, RawTermOperation.EQUAL_TO_OPERATOR,
|
|
532
531
|
"{" + ",".join(values) + "}")
|
|
533
|
-
results: list[dict[str, Any]] =
|
|
532
|
+
results: list[dict[str, Any]] = CustomReportUtil.run_quick_report(self.user, term)
|
|
534
533
|
existing_values: list[Any] = [x.get(self.data_field_name) for x in results]
|
|
535
534
|
return file_handler.get_in_list(self.header, existing_values)
|
|
536
535
|
|
|
@@ -564,6 +563,6 @@ class ExistingSystemValueRule(ColumnRule):
|
|
|
564
563
|
# Run a quick report for all records of this type that match these field values.
|
|
565
564
|
term = RawReportTerm(self.data_type_name, self.data_field_name, RawTermOperation.EQUAL_TO_OPERATOR,
|
|
566
565
|
"{" + ",".join(values) + "}")
|
|
567
|
-
results: list[dict[str, Any]] =
|
|
566
|
+
results: list[dict[str, Any]] = CustomReportUtil.run_quick_report(self.user, term)
|
|
568
567
|
existing_values: list[Any] = [x.get(self.data_field_name) for x in results]
|
|
569
568
|
return file_handler.get_not_in_list(self.header, existing_values)
|
|
@@ -2,8 +2,8 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from weakref import WeakValueDictionary
|
|
4
4
|
|
|
5
|
-
from databind.json import dumps
|
|
6
5
|
from sapiopylib.rest.User import SapioUser
|
|
6
|
+
from databind.json import dumps
|
|
7
7
|
|
|
8
8
|
from sapiopycommons.flowcyto.flowcyto_data import FlowJoWorkspaceInputJson, UploadFCSInputJson, \
|
|
9
9
|
ComputeFlowStatisticsInputJson
|
|
@@ -95,7 +95,7 @@ class AccessionWithPrefixSuffix(AbstractAccessionServiceOperator):
|
|
|
95
95
|
|
|
96
96
|
@property
|
|
97
97
|
def default_accessor_name(self):
|
|
98
|
-
return "PREFIX_AND_SUFFIX" + "(" + self.prefix + "," + self.suffix + ")"
|
|
98
|
+
return "PREFIX_AND_SUFFIX" + "(" + self.prefix + "," + self.suffix + ")";
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
class AccessionGlobalPrefixSuffix(AbstractAccessionServiceOperator):
|
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
from collections.abc import Iterable
|
|
2
|
-
from typing import Any
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
4
|
from sapiopylib.rest.User import SapioUser
|
|
5
5
|
from sapiopylib.rest.pojo.DataRecord import DataRecord
|
|
6
|
-
from sapiopylib.rest.pojo.datatype.FieldDefinition import FieldType
|
|
6
|
+
from sapiopylib.rest.pojo.datatype.FieldDefinition import FieldType
|
|
7
7
|
from sapiopylib.rest.pojo.eln.ElnExperiment import ElnExperiment
|
|
8
8
|
from sapiopylib.rest.pojo.eln.ExperimentEntry import ExperimentEntry
|
|
9
9
|
from sapiopylib.rest.pojo.eln.SapioELNEnums import ElnBaseDataType
|
|
10
10
|
from sapiopylib.rest.pojo.webhook.WebhookContext import SapioWebhookContext
|
|
11
11
|
from sapiopylib.rest.utils.Protocols import ElnExperimentProtocol, ElnEntryStep
|
|
12
|
-
from sapiopylib.rest.utils.recordmodel.PyRecordModel import PyRecordModel
|
|
12
|
+
from sapiopylib.rest.utils.recordmodel.PyRecordModel import PyRecordModel
|
|
13
13
|
from sapiopylib.rest.utils.recordmodel.RecordModelWrapper import WrappedRecordModel, WrappedType, WrapperField
|
|
14
14
|
|
|
15
15
|
from sapiopycommons.general.exceptions import SapioException
|
|
16
16
|
|
|
17
|
-
FieldValue
|
|
17
|
+
FieldValue = int | float | str | bool | None
|
|
18
18
|
"""Allowable values for fields in the system."""
|
|
19
|
-
RecordModel
|
|
19
|
+
RecordModel = PyRecordModel | WrappedRecordModel
|
|
20
20
|
"""Different forms that a record model could take."""
|
|
21
|
-
SapioRecord
|
|
21
|
+
SapioRecord = DataRecord | RecordModel
|
|
22
22
|
"""A record could be provided as either a DataRecord, PyRecordModel, or WrappedRecordModel (WrappedType)."""
|
|
23
|
-
RecordIdentifier
|
|
23
|
+
RecordIdentifier = SapioRecord | int
|
|
24
24
|
"""A RecordIdentifier is either a record type or an integer for the record's record ID."""
|
|
25
|
-
DataTypeIdentifier
|
|
25
|
+
DataTypeIdentifier = SapioRecord | type[WrappedType] | str
|
|
26
26
|
"""A DataTypeIdentifier is either a SapioRecord, a record model wrapper type, or a string."""
|
|
27
|
-
FieldIdentifier
|
|
27
|
+
FieldIdentifier = WrapperField | str | tuple[str, FieldType]
|
|
28
28
|
"""A FieldIdentifier is either wrapper field from a record model wrapper, a string, or a tuple of string
|
|
29
29
|
and field type."""
|
|
30
|
-
FieldIdentifierKey
|
|
30
|
+
FieldIdentifierKey = WrapperField | str
|
|
31
31
|
"""A FieldIdentifierKey is a FieldIdentifier, except it can't be a tuple, s tuples can't be used as keys in
|
|
32
32
|
dictionaries.."""
|
|
33
|
-
HasFieldWrappers
|
|
33
|
+
HasFieldWrappers = type[WrappedType] | WrappedRecordModel
|
|
34
34
|
"""An identifier for classes that have wrapper fields."""
|
|
35
|
-
ExperimentIdentifier
|
|
35
|
+
ExperimentIdentifier = ElnExperimentProtocol | ElnExperiment | int
|
|
36
36
|
"""An ExperimentIdentifier is either an experiment protocol, experiment, or an integer for the experiment's notebook
|
|
37
37
|
ID."""
|
|
38
|
-
ExperimentEntryIdentifier
|
|
38
|
+
ExperimentEntryIdentifier = ElnEntryStep | ExperimentEntry | int
|
|
39
39
|
"""An ExperimentEntryIdentifier is either an ELN entry step, experiment entry, or an integer for the entry's ID."""
|
|
40
|
-
FieldMap
|
|
40
|
+
FieldMap = dict[str, FieldValue]
|
|
41
41
|
"""A field map is simply a dict of data field names to values. The purpose of aliasing this is to help distinguish
|
|
42
42
|
any random dict in a webhook from one which is explicitly used for record fields."""
|
|
43
|
-
FieldIdentifierMap
|
|
43
|
+
FieldIdentifierMap = dict[FieldIdentifierKey, FieldValue]
|
|
44
44
|
"""A field identifier map is the same thing as a field map, except the keys can be field identifiers instead
|
|
45
45
|
of just strings. Note that although one of the allowed field identifiers is a tuple, you can't use tuples as
|
|
46
46
|
keys in a dictionary."""
|
|
47
|
-
UserIdentifier
|
|
47
|
+
UserIdentifier = SapioWebhookContext | SapioUser
|
|
48
48
|
"""An identifier for classes from which a user object can be used for sending requests."""
|
|
49
49
|
|
|
50
50
|
|
|
@@ -142,25 +142,23 @@ class AliasUtil:
|
|
|
142
142
|
@staticmethod
|
|
143
143
|
def to_data_field_name(value: FieldIdentifier) -> str:
|
|
144
144
|
"""
|
|
145
|
-
Convert
|
|
145
|
+
Convert a string or WrapperField to a data field name string.
|
|
146
146
|
|
|
147
|
-
:param value:
|
|
147
|
+
:param value: A string or WrapperField.
|
|
148
148
|
:return: A string of the data field name of the input value.
|
|
149
149
|
"""
|
|
150
150
|
if isinstance(value, tuple):
|
|
151
151
|
return value[0]
|
|
152
152
|
if isinstance(value, WrapperField):
|
|
153
153
|
return value.field_name
|
|
154
|
-
if isinstance(value, AbstractVeloxFieldDefinition):
|
|
155
|
-
return value.data_field_name
|
|
156
154
|
return value
|
|
157
155
|
|
|
158
156
|
@staticmethod
|
|
159
157
|
def to_data_field_names(values: Iterable[FieldIdentifier]) -> list[str]:
|
|
160
158
|
"""
|
|
161
|
-
Convert an iterable of
|
|
159
|
+
Convert an iterable of strings or WrapperFields to a list of data field name strings.
|
|
162
160
|
|
|
163
|
-
:param values: An iterable of
|
|
161
|
+
:param values: An iterable of strings or WrapperFields.
|
|
164
162
|
:return: A list of strings of the data field names of the input values.
|
|
165
163
|
"""
|
|
166
164
|
return [AliasUtil.to_data_field_name(x) for x in values]
|
|
@@ -206,32 +204,21 @@ class AliasUtil:
|
|
|
206
204
|
raise SapioException(f"The wrapper of data type \"{data_type.get_wrapper_data_type_name()}\" doesn't have a "
|
|
207
205
|
f"field with the name \"{field}\",")
|
|
208
206
|
|
|
209
|
-
@staticmethod
|
|
210
|
-
def to_field_map(record: SapioRecord) -> FieldMap:
|
|
211
|
-
"""
|
|
212
|
-
Convert a given record value to a field map. This includes the given RecordId of the given record.
|
|
213
|
-
|
|
214
|
-
:return: The field map for the input record.
|
|
215
|
-
"""
|
|
216
|
-
if isinstance(record, DataRecord):
|
|
217
|
-
# noinspection PyTypeChecker
|
|
218
|
-
fields: FieldMap = record.get_fields()
|
|
219
|
-
else:
|
|
220
|
-
fields: FieldMap = record.fields.copy_to_dict()
|
|
221
|
-
fields["RecordId"] = AliasUtil.to_record_id(record)
|
|
222
|
-
return fields
|
|
223
|
-
|
|
224
207
|
@staticmethod
|
|
225
208
|
def to_field_map_lists(records: Iterable[SapioRecord]) -> list[FieldMap]:
|
|
226
209
|
"""
|
|
227
|
-
Convert a list of variables that could either be DataRecords, PyRecordModels,
|
|
228
|
-
to a list of their field maps.
|
|
210
|
+
Convert a list of variables that could either be DataRecords, PyRecordModels,
|
|
211
|
+
or WrappedRecordModels to a list of their field maps.
|
|
229
212
|
|
|
230
213
|
:return: A list of field maps for the input records.
|
|
231
214
|
"""
|
|
232
215
|
field_map_list: list[FieldMap] = []
|
|
233
216
|
for record in records:
|
|
234
|
-
|
|
217
|
+
if isinstance(record, DataRecord):
|
|
218
|
+
# noinspection PyTypeChecker
|
|
219
|
+
field_map_list.append(record.get_fields())
|
|
220
|
+
else:
|
|
221
|
+
field_map_list.append(record.fields.copy_to_dict())
|
|
235
222
|
return field_map_list
|
|
236
223
|
|
|
237
224
|
@staticmethod
|
|
@@ -3,11 +3,11 @@ from enum import Enum
|
|
|
3
3
|
from sapiopylib.rest.User import SapioUser
|
|
4
4
|
from sapiopylib.rest.pojo.CustomReport import ReportColumn, CustomReportCriteria
|
|
5
5
|
|
|
6
|
-
from sapiopycommons.customreport.auto_pagers import CustomReportDictAutoPager
|
|
7
6
|
from sapiopycommons.customreport.column_builder import ColumnBuilder
|
|
8
7
|
from sapiopycommons.customreport.term_builder import TermBuilder
|
|
9
8
|
from sapiopycommons.datatype.pseudo_data_types import AuditLogPseudoDef
|
|
10
9
|
from sapiopycommons.general.aliases import RecordIdentifier, AliasUtil, UserIdentifier, FieldIdentifier, FieldValue
|
|
10
|
+
from sapiopycommons.general.custom_report_util import CustomReportUtil
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class EventType(Enum):
|
|
@@ -164,7 +164,7 @@ class AuditLogUtil:
|
|
|
164
164
|
criteria = AuditLogUtil.create_data_record_audit_log_report(records, fields)
|
|
165
165
|
|
|
166
166
|
# Then we must run the custom report using that criteria.
|
|
167
|
-
raw_report_data: list[dict[str, FieldValue]] =
|
|
167
|
+
raw_report_data: list[dict[str, FieldValue]] = CustomReportUtil.run_custom_report(self.user, criteria)
|
|
168
168
|
|
|
169
169
|
# This section will prepare a map matching the original RecordIdentifier by record id.
|
|
170
170
|
# This is because the audit log entries will have record ids, but we want the keys in our result map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import warnings
|
|
2
1
|
from collections.abc import Iterable
|
|
3
2
|
|
|
4
3
|
from sapiopylib.rest.DataMgmtService import DataMgmtServer
|
|
@@ -41,7 +40,6 @@ class CustomReportUtil:
|
|
|
41
40
|
had a Sample column with a data field name of Identifier and a Request column with the same data field name,
|
|
42
41
|
then the dictionary keys for these columns would be Sample.Identifier and Request.Identifier respectively.
|
|
43
42
|
"""
|
|
44
|
-
warnings.warn("Deprecated in favor of the SystemReportDictAutoPager class.", DeprecationWarning)
|
|
45
43
|
results: tuple = CustomReportUtil._exhaust_system_report(context, report_name, page_limit,
|
|
46
44
|
page_size, page_number)
|
|
47
45
|
columns: list[ReportColumn] = results[0]
|
|
@@ -84,7 +82,6 @@ class CustomReportUtil:
|
|
|
84
82
|
had a Sample column with a data field name of Identifier and a Request column with the same data field name,
|
|
85
83
|
then the dictionary keys for these columns would be Sample.Identifier and Request.Identifier respectively.
|
|
86
84
|
"""
|
|
87
|
-
warnings.warn("Deprecated in favor of the CustomReportDictAutoPager class.", DeprecationWarning)
|
|
88
85
|
results: tuple = CustomReportUtil._exhaust_custom_report(context, report_criteria, page_limit,
|
|
89
86
|
page_size, page_number)
|
|
90
87
|
columns: list[ReportColumn] = results[0]
|
|
@@ -120,7 +117,6 @@ class CustomReportUtil:
|
|
|
120
117
|
:return: The results of the report listed row by row, mapping each cell to the header it is under. The header
|
|
121
118
|
values in the dicts are the data field names of the columns.
|
|
122
119
|
"""
|
|
123
|
-
warnings.warn("Deprecated in favor of the QuickReportDictAutoPager class.", DeprecationWarning)
|
|
124
120
|
results: tuple = CustomReportUtil._exhaust_quick_report(context, report_term, page_limit,
|
|
125
121
|
page_size, page_number)
|
|
126
122
|
columns: list[ReportColumn] = results[0]
|
|
@@ -131,8 +127,7 @@ class CustomReportUtil:
|
|
|
131
127
|
def get_system_report_criteria(context: UserIdentifier, report_name: str) -> CustomReport:
|
|
132
128
|
"""
|
|
133
129
|
Retrieve a custom report from the system given the name of the report. This works by querying the system report
|
|
134
|
-
with a page number
|
|
135
|
-
report's config.
|
|
130
|
+
with a page number and size of 1 to minimize the amount of data transfer needed to retrieve the report's config.
|
|
136
131
|
|
|
137
132
|
System reports are also known as predefined searches in the system and must be defined in the data designer for
|
|
138
133
|
a specific data type. That is, saved searches created by users cannot be run using this function.
|
|
@@ -148,24 +143,6 @@ class CustomReportUtil:
|
|
|
148
143
|
report_man = DataMgmtServer.get_custom_report_manager(user)
|
|
149
144
|
return report_man.run_system_report_by_name(report_name, 1, 0)
|
|
150
145
|
|
|
151
|
-
@staticmethod
|
|
152
|
-
def get_quick_report_criteria(context: UserIdentifier, report_term: RawReportTerm) -> CustomReport:
|
|
153
|
-
"""
|
|
154
|
-
Retrieve a quick report from the system given a report term. This works by making a quick report query
|
|
155
|
-
with a page number of 0 and page size of 1 to minimize the amount of data transfer needed to retrieve the
|
|
156
|
-
report's config.
|
|
157
|
-
|
|
158
|
-
Using this, you can add to the root term of the search to then run a new search, or provide it to client
|
|
159
|
-
callbacks or directives that take CustomReports.
|
|
160
|
-
|
|
161
|
-
:param context: The current webhook context or a user object to send requests from.
|
|
162
|
-
:param report_term: The raw report term to use for the quick report.
|
|
163
|
-
:return: The CustomReport object for the given report term.
|
|
164
|
-
"""
|
|
165
|
-
user: SapioUser = AliasUtil.to_sapio_user(context)
|
|
166
|
-
report_man = DataMgmtServer.get_custom_report_manager(user)
|
|
167
|
-
return report_man.run_quick_report(report_term, 1, 0)
|
|
168
|
-
|
|
169
146
|
@staticmethod
|
|
170
147
|
def _exhaust_system_report(context: UserIdentifier,
|
|
171
148
|
report_name: str,
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class MessageDisplayType(Enum):
|
|
5
|
-
"""
|
|
6
|
-
An enum representing the different ways in which a message can be displayed to the user.
|
|
7
|
-
"""
|
|
8
|
-
TOASTER_SUCCESS = 0
|
|
9
|
-
TOASTER_INFO = 1
|
|
10
|
-
TOASTER_WARNING = 2
|
|
11
|
-
TOASTER_ERROR = 3
|
|
12
|
-
OK_DIALOG = 4
|
|
13
|
-
DISPLAY_INFO = 5
|
|
14
|
-
DISPLAY_WARNING = 6
|
|
15
|
-
DISPLAY_ERROR = 7
|
|
16
|
-
|
|
17
|
-
|
|
18
1
|
# FR-46064 - Initial port of PyWebhookUtils to sapiopycommons.
|
|
19
2
|
class SapioException(Exception):
|
|
20
3
|
"""
|
|
@@ -46,29 +29,7 @@ class SapioDialogTimeoutException(SapioException):
|
|
|
46
29
|
pass
|
|
47
30
|
|
|
48
31
|
|
|
49
|
-
class
|
|
50
|
-
"""
|
|
51
|
-
A generic exception that promises to return a user-friendly message explaining the error that should be displayed to
|
|
52
|
-
the user. Note that it is up to whichever class that catches this exception to actually display the message.
|
|
53
|
-
"""
|
|
54
|
-
msg: str
|
|
55
|
-
display_type: MessageDisplayType | None
|
|
56
|
-
title: str | None
|
|
57
|
-
|
|
58
|
-
def __init__(self, msg: str, display_type: MessageDisplayType | None = None, title: str | None = None):
|
|
59
|
-
"""
|
|
60
|
-
:param msg: The message that should be displayed to the user.
|
|
61
|
-
:param display_type: The manner in which the message should be displayed. If None, then the display type should
|
|
62
|
-
be controlled by the class that catches this exception.
|
|
63
|
-
:param title: If the display type is able to have a title, this is the title that will be displayed. If None,
|
|
64
|
-
then the title should be controlled by the class that catches this exception.
|
|
65
|
-
"""
|
|
66
|
-
self.msg = msg
|
|
67
|
-
self.display_type = display_type
|
|
68
|
-
self.title = title
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
class SapioUserErrorException(DisplayableException):
|
|
32
|
+
class SapioUserErrorException(SapioException):
|
|
72
33
|
"""
|
|
73
34
|
An exception caused by user error (e.g. user provided a CSV when an XLSX was expected), which promises to return a
|
|
74
35
|
user-friendly message explaining the error that should be displayed to the user.
|
|
@@ -78,7 +39,7 @@ class SapioUserErrorException(DisplayableException):
|
|
|
78
39
|
pass
|
|
79
40
|
|
|
80
41
|
|
|
81
|
-
class SapioCriticalErrorException(
|
|
42
|
+
class SapioCriticalErrorException(SapioException):
|
|
82
43
|
"""
|
|
83
44
|
A critical exception caused by user error, which promises to return a user-friendly message explaining the error
|
|
84
45
|
that should be displayed to the user.
|
|
@@ -6,7 +6,6 @@ from weakref import WeakValueDictionary
|
|
|
6
6
|
|
|
7
7
|
from databind.json import dumps, loads
|
|
8
8
|
from sapiopylib.rest.User import SapioUser
|
|
9
|
-
from sapiopylib.rest.pojo.DataRecord import DataRecord
|
|
10
9
|
|
|
11
10
|
from sapiopycommons.general.exceptions import SapioException
|
|
12
11
|
from sapiopycommons.multimodal.multimodal_data import *
|
|
@@ -5,10 +5,10 @@ from sapiopylib.rest.pojo.CustomReport import CustomReportCriteria
|
|
|
5
5
|
from sapiopylib.rest.pojo.webhook.WebhookContext import SapioWebhookContext
|
|
6
6
|
from sapiopylib.rest.utils.recordmodel.RecordModelWrapper import WrappedType
|
|
7
7
|
|
|
8
|
-
from sapiopycommons.customreport.auto_pagers import CustomReportDictAutoPager, CustomReportRecordAutoPager
|
|
9
8
|
from sapiopycommons.customreport.custom_report_builder import CustomReportBuilder
|
|
10
9
|
from sapiopycommons.datatype.data_fields import ProcessQueueItemFields, SystemFields, ProcessWorkflowTrackingFields
|
|
11
10
|
from sapiopycommons.general.aliases import UserIdentifier, AliasUtil, SapioRecord
|
|
11
|
+
from sapiopycommons.general.custom_report_util import CustomReportUtil
|
|
12
12
|
from sapiopycommons.general.exceptions import SapioException
|
|
13
13
|
from sapiopycommons.general.time_util import TimeUtil
|
|
14
14
|
from sapiopycommons.recordmodel.record_handler import RecordHandler
|
|
@@ -185,7 +185,7 @@ class QueueItemHandler:
|
|
|
185
185
|
:return: A list of every queue item in the system that matches the search criteria.
|
|
186
186
|
"""
|
|
187
187
|
report = self.build_queue_item_report(criteria)
|
|
188
|
-
return
|
|
188
|
+
return self.rec_handler.query_models_by_report(wrapper, report)
|
|
189
189
|
|
|
190
190
|
def get_records_from_item_report(self, wrapper: type[WrappedType],
|
|
191
191
|
criteria: QueueItemReportCriteria = QueueItemReportCriteria()) -> list[WrappedType]:
|
|
@@ -203,7 +203,7 @@ class QueueItemHandler:
|
|
|
203
203
|
criteria.not_data_type_names = None
|
|
204
204
|
report = self.build_queue_item_report(criteria)
|
|
205
205
|
record_ids: list[int] = [x[ProcessQueueItemFields.DATA_RECORD_ID__FIELD.field_name]
|
|
206
|
-
for x in
|
|
206
|
+
for x in CustomReportUtil.run_custom_report(self.user, report)]
|
|
207
207
|
return self.rec_handler.query_models_by_id(wrapper, record_ids)
|
|
208
208
|
|
|
209
209
|
def get_queue_items_for_records(self, records: Iterable[SapioRecord], wrapper: type[WrappedType],
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import warnings
|
|
4
3
|
from collections.abc import Iterable
|
|
5
4
|
from weakref import WeakValueDictionary
|
|
6
5
|
|
|
@@ -233,7 +232,7 @@ class RecordHandler:
|
|
|
233
232
|
:param page_size: The size of the pages to query. If None, the page size may be limited by the platform.
|
|
234
233
|
:return: The record models for the queried records mapped in a dictionary by their record ID.
|
|
235
234
|
"""
|
|
236
|
-
return {
|
|
235
|
+
return {x.record_id: x for x in self.query_models_by_id(wrapper_type, ids, page_limit, page_size)}
|
|
237
236
|
|
|
238
237
|
def query_all_models(self, wrapper_type: type[WrappedType], page_limit: int | None = None,
|
|
239
238
|
page_size: int | None = None) -> list[WrappedType]:
|
|
@@ -301,7 +300,6 @@ class RecordHandler:
|
|
|
301
300
|
not None, in which case it overwrites the given report's value. Note that the number of the first page is 0.
|
|
302
301
|
:return: The record models for the queried records that matched the given report.
|
|
303
302
|
"""
|
|
304
|
-
warnings.warn("Deprecated in favor of the [System/Custom/Quick]ReportRecordAutoPager classes.", DeprecationWarning)
|
|
305
303
|
if isinstance(report_name, str):
|
|
306
304
|
results: list[dict[str, FieldValue]] = CustomReportUtil.run_system_report(self.user, report_name, filters,
|
|
307
305
|
page_limit, page_size, page_number)
|
|
@@ -895,14 +893,14 @@ class RecordHandler:
|
|
|
895
893
|
|
|
896
894
|
@staticmethod
|
|
897
895
|
def values_to_field_maps(field_name: FieldIdentifier, values: Iterable[FieldValue],
|
|
898
|
-
existing_fields: list[
|
|
896
|
+
existing_fields: list[FieldIdentifier] | None = None) -> list[FieldMap]:
|
|
899
897
|
"""
|
|
900
898
|
Add a list of values for a specific field to a list of dictionaries pairing each value to that field name.
|
|
901
899
|
|
|
902
900
|
:param field_name: The name of the field that the values are from.
|
|
903
901
|
:param values: A list of field values.
|
|
904
902
|
:param existing_fields: An optional existing fields map list to add the new values to. Values are added in the
|
|
905
|
-
|
|
903
|
+
list in the same order that they appear. If no existing fields are provided, returns a new fields map list.
|
|
906
904
|
:return: A fields map list that contains the given values mapped by the given field name.
|
|
907
905
|
"""
|
|
908
906
|
# Update the existing fields map list if one is given.
|