sapiopycommons 2025.4.8a474__py3-none-any.whl → 2025.4.9a150__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 +392 -1262
- sapiopycommons/callbacks/field_builder.py +0 -2
- sapiopycommons/chem/Molecules.py +2 -0
- sapiopycommons/customreport/term_builder.py +1 -1
- sapiopycommons/datatype/attachment_util.py +2 -4
- sapiopycommons/datatype/data_fields.py +1 -23
- sapiopycommons/eln/experiment_handler.py +279 -933
- sapiopycommons/eln/experiment_report_util.py +10 -15
- sapiopycommons/eln/plate_designer.py +59 -159
- 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_util.py +15 -40
- sapiopycommons/files/file_validator.py +5 -6
- sapiopycommons/files/file_writer.py +1 -1
- sapiopycommons/flowcyto/flow_cyto.py +1 -1
- sapiopycommons/general/accession_service.py +3 -3
- sapiopycommons/general/aliases.py +28 -51
- sapiopycommons/general/audit_log.py +2 -2
- sapiopycommons/general/custom_report_util.py +1 -24
- sapiopycommons/general/exceptions.py +2 -41
- sapiopycommons/general/popup_util.py +2 -2
- sapiopycommons/multimodal/multimodal.py +0 -1
- sapiopycommons/processtracking/custom_workflow_handler.py +30 -46
- sapiopycommons/recordmodel/record_handler.py +159 -547
- sapiopycommons/rules/eln_rule_handler.py +30 -41
- sapiopycommons/rules/on_save_rule_handler.py +30 -41
- sapiopycommons/webhook/webhook_handlers.py +55 -448
- sapiopycommons/webhook/webservice_handlers.py +2 -2
- {sapiopycommons-2025.4.8a474.dist-info → sapiopycommons-2025.4.9a150.dist-info}/METADATA +1 -1
- sapiopycommons-2025.4.9a150.dist-info/RECORD +59 -0
- sapiopycommons/customreport/auto_pagers.py +0 -281
- sapiopycommons/eln/experiment_cache.py +0 -173
- sapiopycommons/eln/experiment_step_factory.py +0 -474
- sapiopycommons/eln/experiment_tags.py +0 -7
- sapiopycommons/eln/step_creation.py +0 -235
- sapiopycommons/general/data_structure_util.py +0 -115
- sapiopycommons/general/directive_util.py +0 -86
- sapiopycommons/samples/aliquot.py +0 -48
- sapiopycommons-2025.4.8a474.dist-info/RECORD +0 -67
- {sapiopycommons-2025.4.8a474.dist-info → sapiopycommons-2025.4.9a150.dist-info}/WHEEL +0 -0
- {sapiopycommons-2025.4.8a474.dist-info → sapiopycommons-2025.4.9a150.dist-info}/licenses/LICENSE +0 -0
|
@@ -6,12 +6,11 @@ from sapiopylib.rest.User import SapioUser
|
|
|
6
6
|
from sapiopylib.rest.pojo.DataRecord import DataRecord
|
|
7
7
|
from sapiopylib.rest.pojo.eln.SapioELNEnums import ElnBaseDataType
|
|
8
8
|
from sapiopylib.rest.pojo.webhook.WebhookContext import SapioWebhookContext
|
|
9
|
-
from sapiopylib.rest.utils.recordmodel.
|
|
9
|
+
from sapiopylib.rest.utils.recordmodel.RecordModelManager import RecordModelManager, RecordModelInstanceManager
|
|
10
10
|
from sapiopylib.rest.utils.recordmodel.RecordModelWrapper import WrappedType
|
|
11
11
|
|
|
12
12
|
from sapiopycommons.general.aliases import FieldMap, AliasUtil, DataTypeIdentifier
|
|
13
13
|
from sapiopycommons.general.exceptions import SapioException
|
|
14
|
-
from sapiopycommons.recordmodel.record_handler import RecordHandler
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
# FR-46064 - Initial port of PyWebhookUtils to sapiopycommons.
|
|
@@ -19,23 +18,23 @@ class ElnRuleHandler:
|
|
|
19
18
|
"""
|
|
20
19
|
A class which helps with the parsing and navigation of the ELN rule result map of a webhook context.
|
|
21
20
|
"""
|
|
22
|
-
|
|
21
|
+
__context: SapioWebhookContext
|
|
23
22
|
"""The context that this handler is working from."""
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
"""The record
|
|
24
|
+
__inst_man: RecordModelInstanceManager
|
|
25
|
+
"""The record model instance manager, used for wrapping the data records as record models."""
|
|
27
26
|
|
|
28
27
|
# Reformatted and cached version of the Velox ELN rule result map for easier handling.
|
|
29
|
-
|
|
28
|
+
__records: dict[str, set[DataRecord]]
|
|
30
29
|
"""A mapping of data type to the set of data records from the context that match that data type."""
|
|
31
|
-
|
|
30
|
+
__entry_to_records: dict[str, dict[str, set[DataRecord]]]
|
|
32
31
|
"""A mapping of entry name to the sets of data records for that entry, each set of records being mapped by its
|
|
33
32
|
data type."""
|
|
34
|
-
|
|
33
|
+
__field_maps: dict[str, dict[int, FieldMap]]
|
|
35
34
|
"""A mapping of data type to the field maps from the context that match that data type. In order to prevent
|
|
36
35
|
duplicate field maps, each field map is in a dict keyed by the RecordId field in the field map, since field maps
|
|
37
36
|
are just dictionaries and dictionaries aren't hashable and therefore can't go in a set."""
|
|
38
|
-
|
|
37
|
+
__entry_to_field_maps: dict[str, dict[str, dict[int, FieldMap]]]
|
|
39
38
|
"""A mapping of entry name to the lists of field maps for that entry, each grouping of field maps being mapped by
|
|
40
39
|
its data type."""
|
|
41
40
|
|
|
@@ -60,8 +59,8 @@ class ElnRuleHandler:
|
|
|
60
59
|
|
|
61
60
|
if context.velox_eln_rule_result_map is None:
|
|
62
61
|
raise SapioException("No Velox ELN rule result map in context for ElnRuleHandler to parse.")
|
|
63
|
-
self.
|
|
64
|
-
self.
|
|
62
|
+
self.__context = context
|
|
63
|
+
self.__inst_man = RecordModelManager(context.user).instance_manager
|
|
65
64
|
self.__cache_records()
|
|
66
65
|
|
|
67
66
|
def __cache_records(self) -> None:
|
|
@@ -71,10 +70,10 @@ class ElnRuleHandler:
|
|
|
71
70
|
from to another dict that maps the data types to the records of that type.
|
|
72
71
|
Doesn't cache any relationship info from the VeloxRuleType of the rule results.
|
|
73
72
|
"""
|
|
74
|
-
self.
|
|
75
|
-
self.
|
|
73
|
+
self.__records = {}
|
|
74
|
+
self.__entry_to_records = {}
|
|
76
75
|
# Each entry in the context has a list of results for that entry.
|
|
77
|
-
for entry, entry_results in self.
|
|
76
|
+
for entry, entry_results in self.__context.velox_eln_rule_result_map.items():
|
|
78
77
|
# Keep track of the records for this specific entry.
|
|
79
78
|
entry_dict: dict[str, set[DataRecord]] = {}
|
|
80
79
|
# Entry results consist of a record ID of the record in the entry and a list of results tied to that record.
|
|
@@ -90,16 +89,16 @@ class ElnRuleHandler:
|
|
|
90
89
|
if ElnBaseDataType.is_eln_type(data_type):
|
|
91
90
|
data_type = ElnBaseDataType.get_base_type(data_type).data_type_name
|
|
92
91
|
# Update the list of records of this type that exist so far globally.
|
|
93
|
-
self.
|
|
92
|
+
self.__records.setdefault(data_type, set()).add(record)
|
|
94
93
|
# Do the same for the list of records of this type for this specific entry.
|
|
95
94
|
entry_dict.setdefault(data_type, set()).add(record)
|
|
96
95
|
# Update the records for this entry.
|
|
97
|
-
self.
|
|
96
|
+
self.__entry_to_records.update({entry: entry_dict})
|
|
98
97
|
|
|
99
|
-
self.
|
|
100
|
-
self.
|
|
98
|
+
self.__field_maps = {}
|
|
99
|
+
self.__entry_to_field_maps = {}
|
|
101
100
|
# Repeat the same thing for the field map results.
|
|
102
|
-
for entry, entry_results in self.
|
|
101
|
+
for entry, entry_results in self.__context.velox_eln_rule_field_map_result_map.items():
|
|
103
102
|
entry_dict: dict[str, dict[int, FieldMap]] = {}
|
|
104
103
|
for record_result in entry_results:
|
|
105
104
|
for result in record_result.velox_type_rule_field_map_result_list:
|
|
@@ -108,41 +107,37 @@ class ElnRuleHandler:
|
|
|
108
107
|
data_type = ElnBaseDataType.get_base_type(data_type).data_type_name
|
|
109
108
|
for field_map in result.field_map_list:
|
|
110
109
|
rec_id: int = field_map.get("RecordId")
|
|
111
|
-
self.
|
|
110
|
+
self.__field_maps.setdefault(data_type, {}).update({rec_id: field_map})
|
|
112
111
|
entry_dict.setdefault(data_type, {}).update({rec_id: field_map})
|
|
113
|
-
self.
|
|
112
|
+
self.__entry_to_field_maps.update({entry: entry_dict})
|
|
114
113
|
|
|
115
114
|
def get_entry_names(self) -> list[str]:
|
|
116
115
|
"""
|
|
117
116
|
:return: A list of the entry names that may be used with the get_records and get_models functions. These are the
|
|
118
117
|
entries from the experiment that the records in the rule context originate from.
|
|
119
118
|
"""
|
|
120
|
-
return list(self.
|
|
119
|
+
return list(self.__entry_to_records.keys())
|
|
121
120
|
|
|
122
121
|
def get_field_maps_entry_names(self) -> list[str]:
|
|
123
122
|
"""
|
|
124
123
|
:return: A list of the entry names that may be used with the get_field_maps function. These are the
|
|
125
124
|
entries from the experiment that the field maps in the rule context originate from.
|
|
126
125
|
"""
|
|
127
|
-
return list(self.
|
|
126
|
+
return list(self.__entry_to_field_maps.keys())
|
|
128
127
|
|
|
129
|
-
# CR-47529: Add info about HVDT behavior to the docstring of these functions.
|
|
130
128
|
def get_records(self, data_type: DataTypeIdentifier, entry: str | None = None) -> list[DataRecord]:
|
|
131
129
|
"""
|
|
132
130
|
Get records from the cached context with the given data type. Capable of being filtered to searching within
|
|
133
131
|
the context of an entry name. If the given data type or entry does not exist in the context,
|
|
134
132
|
returns an empty list.
|
|
135
133
|
|
|
136
|
-
Note that if you are attempting to retrieve record that are high volume data types and are receiving nothing,
|
|
137
|
-
the HVDTs may have been sent as field maps. Consider using the get_field_maps function if this occurs.
|
|
138
|
-
|
|
139
134
|
:param data_type: The data type of the records to return.
|
|
140
135
|
:param entry: The name of the entry to grab the records from. If None, returns the records that match the data
|
|
141
136
|
type from every entry. If an entry is provided, but it does not exist in the context, returns an empty list.
|
|
142
137
|
:return: The records from the context that match the input parameters.
|
|
143
138
|
"""
|
|
144
139
|
data_type: str = AliasUtil.to_data_type_name(data_type)
|
|
145
|
-
records: dict[str, set[DataRecord]] = self.
|
|
140
|
+
records: dict[str, set[DataRecord]] = self.__entry_to_records.get(entry, {}) if entry else self.__records
|
|
146
141
|
return list(records.get(data_type, []))
|
|
147
142
|
|
|
148
143
|
# FR-46701: Add functions to the rule handlers for accessing the field maps of inaccessible records in the context.
|
|
@@ -154,7 +149,7 @@ class ElnRuleHandler:
|
|
|
154
149
|
|
|
155
150
|
Field maps will only exist in the context if the data record that the fields are from is no longer accessible
|
|
156
151
|
to the user. This can occur because the data record was deleted, or because the user does not have access to the
|
|
157
|
-
record due to ACL.
|
|
152
|
+
record due to ACL.
|
|
158
153
|
|
|
159
154
|
:param data_type: The data type of the field maps to return.
|
|
160
155
|
:param entry: The name of the entry to grab the field maps from. If None, returns the field maps that match the
|
|
@@ -163,25 +158,19 @@ class ElnRuleHandler:
|
|
|
163
158
|
:return: The field maps from the context that match the input parameters.
|
|
164
159
|
"""
|
|
165
160
|
data_type: str = AliasUtil.to_data_type_name(data_type)
|
|
166
|
-
field_maps: dict[str, dict[int, FieldMap]] = self.
|
|
161
|
+
field_maps: dict[str, dict[int, FieldMap]] = self.__entry_to_field_maps.get(entry, {}) if entry else self.__field_maps
|
|
167
162
|
return list(field_maps.get(data_type, {}).values())
|
|
168
163
|
|
|
169
|
-
|
|
170
|
-
def get_models(self, wrapper_type: type[WrappedType] | str, entry: str | None = None) \
|
|
171
|
-
-> list[WrappedType] | list[PyRecordModel]:
|
|
164
|
+
def get_models(self, wrapper_type: type[WrappedType], entry: str | None = None) -> list[WrappedType]:
|
|
172
165
|
"""
|
|
173
166
|
Get record models from the cached context with the given data type. Capable of being filtered to searching
|
|
174
167
|
within the context of an entry name. If the given data type or entry does not exist in the context,
|
|
175
168
|
returns an empty list.
|
|
176
169
|
|
|
177
|
-
|
|
178
|
-
the HVDTs may have been sent as field maps. Consider using the get_field_maps function if this occurs.
|
|
179
|
-
|
|
180
|
-
:param wrapper_type: The record model wrapper or data type name of the record to get from the context.
|
|
170
|
+
:param wrapper_type: The record model wrapper to use.
|
|
181
171
|
:param entry: The name of the entry to grab the records from. If None, returns the records that match the data
|
|
182
172
|
type from every entry. If an entry is provided, but it does not exist in the context, returns an empty list.
|
|
183
|
-
:return: The record models from the context that match the input parameters.
|
|
184
|
-
instead of a model wrapper, then the returned records will be PyRecordModels instead of WrappedRecordModels.
|
|
173
|
+
:return: The record models from the context that match the input parameters.
|
|
185
174
|
"""
|
|
186
|
-
dt: str =
|
|
187
|
-
return self.
|
|
175
|
+
dt: str = wrapper_type.get_wrapper_data_type_name()
|
|
176
|
+
return self.__inst_man.add_existing_records_of_type(self.get_records(dt, entry), wrapper_type)
|
|
@@ -6,12 +6,11 @@ from sapiopylib.rest.User import SapioUser
|
|
|
6
6
|
from sapiopylib.rest.pojo.DataRecord import DataRecord
|
|
7
7
|
from sapiopylib.rest.pojo.eln.SapioELNEnums import ElnBaseDataType
|
|
8
8
|
from sapiopylib.rest.pojo.webhook.WebhookContext import SapioWebhookContext
|
|
9
|
-
from sapiopylib.rest.utils.recordmodel.
|
|
9
|
+
from sapiopylib.rest.utils.recordmodel.RecordModelManager import RecordModelManager, RecordModelInstanceManager
|
|
10
10
|
from sapiopylib.rest.utils.recordmodel.RecordModelWrapper import WrappedType
|
|
11
11
|
|
|
12
12
|
from sapiopycommons.general.aliases import FieldMap, DataTypeIdentifier, AliasUtil
|
|
13
13
|
from sapiopycommons.general.exceptions import SapioException
|
|
14
|
-
from sapiopycommons.recordmodel.record_handler import RecordHandler
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
# FR-46064 - Initial port of PyWebhookUtils to sapiopycommons.
|
|
@@ -19,23 +18,23 @@ class OnSaveRuleHandler:
|
|
|
19
18
|
"""
|
|
20
19
|
A class which helps with the parsing and navigation of the on save rule result map of a webhook context.
|
|
21
20
|
"""
|
|
22
|
-
|
|
21
|
+
__context: SapioWebhookContext
|
|
23
22
|
"""The context that this handler is working from."""
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
"""The record
|
|
24
|
+
__inst_man: RecordModelInstanceManager
|
|
25
|
+
"""The record model instance manager, used for wrapping the data records as record models."""
|
|
27
26
|
|
|
28
27
|
# Reformatted and cached version of the Velox on save rule result map for easier handling.
|
|
29
|
-
|
|
28
|
+
__records: dict[str, set[DataRecord]]
|
|
30
29
|
"""A mapping of data type to the set of data records from the context that match that data type."""
|
|
31
|
-
|
|
30
|
+
__base_id_to_records: dict[int, dict[str, set[DataRecord]]]
|
|
32
31
|
"""A mapping of record IDs of records in the context.data_record_list to the sets of data records related to that
|
|
33
32
|
record, each set of records being mapped by its data type."""
|
|
34
|
-
|
|
33
|
+
__field_maps: dict[str, dict[int, FieldMap]]
|
|
35
34
|
"""A mapping of data type to the field maps from the context that match that data type. In order to prevent
|
|
36
35
|
duplicate field maps, each field map is in a dict keyed by the RecordId field in the field map, since field maps
|
|
37
36
|
are just dictionaries and dictionaries aren't hashable and therefore can't go in a set."""
|
|
38
|
-
|
|
37
|
+
__base_id_to_field_maps: dict[int, dict[str, dict[int, FieldMap]]]
|
|
39
38
|
"""A mapping of record IDs of records in the context.data_record_list to the field maps related to that
|
|
40
39
|
record, each grouping of field maps being mapped by its data type."""
|
|
41
40
|
|
|
@@ -60,8 +59,8 @@ class OnSaveRuleHandler:
|
|
|
60
59
|
|
|
61
60
|
if context.velox_on_save_result_map is None:
|
|
62
61
|
raise SapioException("No Velox on save rule result map in context for OnSaveRuleHandler to parse.")
|
|
63
|
-
self.
|
|
64
|
-
self.
|
|
62
|
+
self.__context = context
|
|
63
|
+
self.__inst_man = RecordModelManager(context.user).instance_manager
|
|
65
64
|
self.__cache_records()
|
|
66
65
|
|
|
67
66
|
def __cache_records(self) -> None:
|
|
@@ -70,10 +69,10 @@ class OnSaveRuleHandler:
|
|
|
70
69
|
each record to a set of all records of that data type. The other cache maps the record ID that the records relate
|
|
71
70
|
to with another dict that maps the data types to the records of that type. Doesn't cache any relationship info.
|
|
72
71
|
"""
|
|
73
|
-
self.
|
|
74
|
-
self.
|
|
72
|
+
self.__records = {}
|
|
73
|
+
self.__base_id_to_records = {}
|
|
75
74
|
# Each record ID in the context has a list of results for that record.
|
|
76
|
-
for record_id, rule_results in self.
|
|
75
|
+
for record_id, rule_results in self.__context.velox_on_save_result_map.items():
|
|
77
76
|
# Keep track of the records for this specific record ID.
|
|
78
77
|
id_dict: dict[str, set[DataRecord]] = {}
|
|
79
78
|
# The list of results for a record consist of a list of data records and a VeloxType that specifies
|
|
@@ -87,16 +86,16 @@ class OnSaveRuleHandler:
|
|
|
87
86
|
if ElnBaseDataType.is_eln_type(data_type):
|
|
88
87
|
data_type = ElnBaseDataType.get_base_type(data_type).data_type_name
|
|
89
88
|
# Update the list of records of this type that exist so far globally.
|
|
90
|
-
self.
|
|
89
|
+
self.__records.setdefault(data_type, set()).add(record)
|
|
91
90
|
# Do the same for the list of records of this type that relate to this record ID.
|
|
92
91
|
id_dict.setdefault(data_type, set()).add(record)
|
|
93
92
|
# Update the related records for this record ID.
|
|
94
|
-
self.
|
|
93
|
+
self.__base_id_to_records.update({record_id: id_dict})
|
|
95
94
|
|
|
96
|
-
self.
|
|
97
|
-
self.
|
|
95
|
+
self.__field_maps = {}
|
|
96
|
+
self.__base_id_to_field_maps = {}
|
|
98
97
|
# Repeat the same thing for the field map results.
|
|
99
|
-
for record_id, rule_results in self.
|
|
98
|
+
for record_id, rule_results in self.__context.velox_on_save_field_map_result_map.items():
|
|
100
99
|
id_dict: dict[str, dict[int, FieldMap]] = {}
|
|
101
100
|
for record_result in rule_results:
|
|
102
101
|
data_type: str = record_result.velox_type_pojo.data_type_name
|
|
@@ -104,41 +103,37 @@ class OnSaveRuleHandler:
|
|
|
104
103
|
data_type = ElnBaseDataType.get_base_type(data_type).data_type_name
|
|
105
104
|
for field_map in record_result.field_map_list:
|
|
106
105
|
rec_id: int = field_map.get("RecordId")
|
|
107
|
-
self.
|
|
106
|
+
self.__field_maps.setdefault(data_type, {}).update({rec_id: field_map})
|
|
108
107
|
id_dict.setdefault(data_type, {}).update({rec_id: field_map})
|
|
109
|
-
self.
|
|
108
|
+
self.__base_id_to_field_maps.update({record_id: id_dict})
|
|
110
109
|
|
|
111
110
|
def get_base_record_ids(self) -> list[int]:
|
|
112
111
|
"""
|
|
113
112
|
:return: A list of the record IDs that may be used with the get_records and get_models functions. These are the
|
|
114
113
|
record IDs to the records that caused the rule to trigger.
|
|
115
114
|
"""
|
|
116
|
-
return list(self.
|
|
115
|
+
return list(self.__base_id_to_records.keys())
|
|
117
116
|
|
|
118
117
|
def get_field_maps_base_record_ids(self) -> list[int]:
|
|
119
118
|
"""
|
|
120
119
|
:return: A list of the record IDs that may be used with the get_field_maps function. These are the
|
|
121
120
|
record IDs to the records that caused the rule to trigger.
|
|
122
121
|
"""
|
|
123
|
-
return list(self.
|
|
122
|
+
return list(self.__base_id_to_field_maps.keys())
|
|
124
123
|
|
|
125
|
-
# CR-47529: Add info about HVDT behavior to the docstring of these functions.
|
|
126
124
|
def get_records(self, data_type: DataTypeIdentifier, record_id: int | None = None) -> list[DataRecord]:
|
|
127
125
|
"""
|
|
128
126
|
Get records from the cached context with the given data type. Capable of being filtered to searching within
|
|
129
127
|
the context of a record ID. If the given data type or record ID does not exist in the context,
|
|
130
128
|
returns an empty list.
|
|
131
129
|
|
|
132
|
-
Note that if you are attempting to retrieve record that are high volume data types and are receiving nothing,
|
|
133
|
-
the HVDTs may have been sent as field maps. Consider using the get_field_maps function if this occurs.
|
|
134
|
-
|
|
135
130
|
:param data_type: The data type of the records to return.
|
|
136
131
|
:param record_id: The record ID of the base record to search from. If None, returns the records that match the
|
|
137
132
|
data type from every ID. If an ID is provided, but it does not exist in the context, returns an empty list.
|
|
138
133
|
:return: The records from the context that match the input parameters.
|
|
139
134
|
"""
|
|
140
135
|
data_type: str = AliasUtil.to_data_type_name(data_type)
|
|
141
|
-
records: dict[str, set[DataRecord]] = self.
|
|
136
|
+
records: dict[str, set[DataRecord]] = self.__base_id_to_records.get(record_id, {}) if record_id else self.__records
|
|
142
137
|
return list(records.get(data_type, []))
|
|
143
138
|
|
|
144
139
|
# FR-46701: Add functions to the rule handlers for accessing the field maps of inaccessible records in the context.
|
|
@@ -150,7 +145,7 @@ class OnSaveRuleHandler:
|
|
|
150
145
|
|
|
151
146
|
Field maps will only exist in the context if the data record that the fields are from is no longer accessible
|
|
152
147
|
to the user. This can occur because the data record was deleted, or because the user does not have access to the
|
|
153
|
-
record due to ACL.
|
|
148
|
+
record due to ACL.
|
|
154
149
|
|
|
155
150
|
:param data_type: The data type of the field maps to return.
|
|
156
151
|
:param record_id: The record ID of the base record to search from. If None, returns the field maps that match
|
|
@@ -159,25 +154,19 @@ class OnSaveRuleHandler:
|
|
|
159
154
|
:return: The field maps from the context that match the input parameters.
|
|
160
155
|
"""
|
|
161
156
|
data_type: str = AliasUtil.to_data_type_name(data_type)
|
|
162
|
-
field_maps: dict[str, dict[int, FieldMap]] = self.
|
|
157
|
+
field_maps: dict[str, dict[int, FieldMap]] = self.__base_id_to_field_maps.get(record_id, {}) if record_id else self.__field_maps
|
|
163
158
|
return list(field_maps.get(data_type, {}).values())
|
|
164
159
|
|
|
165
|
-
|
|
166
|
-
def get_models(self, wrapper_type: type[WrappedType] | str, record_id: int | None = None) \
|
|
167
|
-
-> list[WrappedType] | list[PyRecordModel]:
|
|
160
|
+
def get_models(self, wrapper_type: type[WrappedType], record_id: int | None = None) -> list[WrappedType]:
|
|
168
161
|
"""
|
|
169
162
|
Get records from the cached context with the given data type. Capable of being filtered to searching within
|
|
170
163
|
the context of a record ID. If the given data type or record ID does not exist in the context,
|
|
171
164
|
returns an empty list.
|
|
172
165
|
|
|
173
|
-
|
|
174
|
-
the HVDTs may have been sent as field maps. Consider using the get_field_maps function if this occurs.
|
|
175
|
-
|
|
176
|
-
:param wrapper_type: The record model wrapper or data type name of the record to get from the context.
|
|
166
|
+
:param wrapper_type: The record model wrapper to use.
|
|
177
167
|
:param record_id: The record ID of the base record to search from. If None, returns the records that match the
|
|
178
168
|
data type from ID. If an ID is provided, but it does not exist in the context, returns an empty list.
|
|
179
|
-
:return: The record models from the context that match the input parameters.
|
|
180
|
-
instead of a model wrapper, then the returned records will be PyRecordModels instead of WrappedRecordModels.
|
|
169
|
+
:return: The record models from the context that match the input parameters.
|
|
181
170
|
"""
|
|
182
|
-
dt: str =
|
|
183
|
-
return self.
|
|
171
|
+
dt: str = wrapper_type.get_wrapper_data_type_name()
|
|
172
|
+
return self.__inst_man.add_existing_records_of_type(self.get_records(dt, record_id), wrapper_type)
|