using an array for metadata extraction paths now instead of dictionaries w/ burnettk
This commit is contained in:
parent
6b75fc32a3
commit
bfb2c5627a
|
@ -38,7 +38,7 @@ class ProcessModelInfo:
|
|||
fault_or_suspend_on_exception: str = NotificationType.fault.value
|
||||
exception_notification_addresses: list[str] = field(default_factory=list)
|
||||
parent_groups: list[dict] | None = None
|
||||
metadata_extraction_paths: dict[str, str] | None = None
|
||||
metadata_extraction_paths: list[dict[str, str]] | None = None
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
"""__post_init__."""
|
||||
|
@ -77,8 +77,13 @@ class ProcessModelInfoSchema(Schema):
|
|||
exception_notification_addresses = marshmallow.fields.List(
|
||||
marshmallow.fields.String
|
||||
)
|
||||
metadata_extraction_paths = marshmallow.fields.Dict(keys=marshmallow.fields.Str(required=False), values=marshmallow.fields.Str(required=False), required=False)
|
||||
|
||||
metadata_extraction_paths = marshmallow.fields.List(
|
||||
marshmallow.fields.Dict(
|
||||
keys=marshmallow.fields.Str(required=False),
|
||||
values=marshmallow.fields.Str(required=False),
|
||||
required=False,
|
||||
)
|
||||
)
|
||||
|
||||
@post_load
|
||||
def make_spec(
|
||||
|
|
|
@ -952,17 +952,26 @@ def process_instance_list(
|
|||
continue
|
||||
instance_metadata_alias = aliased(ProcessInstanceMetadataModel)
|
||||
|
||||
filter_for_column = next((f for f in process_instance_report.report_metadata['filter_by'] if f['field_name'] == column['accessor']), None)
|
||||
filter_for_column = next(
|
||||
(
|
||||
f
|
||||
for f in process_instance_report.report_metadata["filter_by"]
|
||||
if f["field_name"] == column["accessor"]
|
||||
),
|
||||
None,
|
||||
)
|
||||
isouter = True
|
||||
conditions = [ProcessInstanceModel.id == instance_metadata_alias.process_instance_id,
|
||||
instance_metadata_alias.key == column["accessor"]]
|
||||
conditions = [
|
||||
ProcessInstanceModel.id == instance_metadata_alias.process_instance_id,
|
||||
instance_metadata_alias.key == column["accessor"],
|
||||
]
|
||||
if filter_for_column:
|
||||
isouter = False
|
||||
conditions.append(instance_metadata_alias.value == filter_for_column["field_value"])
|
||||
conditions.append(
|
||||
instance_metadata_alias.value == filter_for_column["field_value"]
|
||||
)
|
||||
process_instance_query = process_instance_query.join(
|
||||
instance_metadata_alias,
|
||||
and_(*conditions),
|
||||
isouter=isouter
|
||||
instance_metadata_alias, and_(*conditions), isouter=isouter
|
||||
).add_columns(func.max(instance_metadata_alias.value).label(column["accessor"]))
|
||||
|
||||
process_instances = (
|
||||
|
@ -1154,9 +1163,7 @@ def process_instance_report_show(
|
|||
"""Process_instance_report_show."""
|
||||
process_instances = ProcessInstanceModel.query.order_by(
|
||||
ProcessInstanceModel.start_in_seconds.desc(), ProcessInstanceModel.id.desc() # type: ignore
|
||||
).paginate(
|
||||
page=page, per_page=per_page, error_out=False
|
||||
)
|
||||
).paginate(page=page, per_page=per_page, error_out=False)
|
||||
|
||||
process_instance_report = ProcessInstanceReportModel.query.filter_by(
|
||||
id=report_id,
|
||||
|
|
|
@ -84,7 +84,11 @@ class ProcessInstanceReportService:
|
|||
|
||||
# TODO replace with system reports that are loaded on launch (or similar)
|
||||
temp_system_metadata_map = {
|
||||
"default": {"columns": cls.builtin_column_options(), "filter_by": [], 'order_by': ['-start_in_seconds', '-id']},
|
||||
"default": {
|
||||
"columns": cls.builtin_column_options(),
|
||||
"filter_by": [],
|
||||
"order_by": ["-start_in_seconds", "-id"],
|
||||
},
|
||||
"system_report_instances_initiated_by_me": {
|
||||
"columns": [
|
||||
{"Header": "id", "accessor": "id"},
|
||||
|
@ -96,13 +100,15 @@ class ProcessInstanceReportService:
|
|||
{"Header": "end_in_seconds", "accessor": "end_in_seconds"},
|
||||
{"Header": "status", "accessor": "status"},
|
||||
],
|
||||
"filter_by": [{"field_name": "initiated_by_me", "field_value": True}],'order_by': ['-start_in_seconds', '-id']
|
||||
"filter_by": [{"field_name": "initiated_by_me", "field_value": True}],
|
||||
"order_by": ["-start_in_seconds", "-id"],
|
||||
},
|
||||
"system_report_instances_with_tasks_completed_by_me": {
|
||||
"columns": cls.builtin_column_options(),
|
||||
"filter_by": [
|
||||
{"field_name": "with_tasks_completed_by_me", "field_value": True}
|
||||
],'order_by': ['-start_in_seconds', '-id']
|
||||
],
|
||||
"order_by": ["-start_in_seconds", "-id"],
|
||||
},
|
||||
"system_report_instances_with_tasks_completed_by_my_groups": {
|
||||
"columns": cls.builtin_column_options(),
|
||||
|
@ -111,7 +117,8 @@ class ProcessInstanceReportService:
|
|||
"field_name": "with_tasks_completed_by_my_group",
|
||||
"field_value": True,
|
||||
}
|
||||
],'order_by': ['-start_in_seconds', '-id']
|
||||
],
|
||||
"order_by": ["-start_in_seconds", "-id"],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -333,7 +333,9 @@ class TestProcessApi(BaseTest):
|
|||
process_model.display_name = "Updated Display Name"
|
||||
process_model.primary_file_name = "superduper.bpmn"
|
||||
process_model.primary_process_id = "superduper"
|
||||
process_model.metadata_extraction_paths = {'extraction1': 'path1'}
|
||||
process_model.metadata_extraction_paths = [
|
||||
{"key": "extraction1", "path": "path1"}
|
||||
]
|
||||
|
||||
modified_process_model_identifier = process_model_identifier.replace("/", ":")
|
||||
response = client.put(
|
||||
|
@ -347,7 +349,9 @@ class TestProcessApi(BaseTest):
|
|||
assert response.json["display_name"] == "Updated Display Name"
|
||||
assert response.json["primary_file_name"] == "superduper.bpmn"
|
||||
assert response.json["primary_process_id"] == "superduper"
|
||||
assert response.json["metadata_extraction_paths"] == {'extraction1': 'path1'}
|
||||
assert response.json["metadata_extraction_paths"] == [
|
||||
{"key": "extraction1", "path": "path1"}
|
||||
]
|
||||
|
||||
def test_process_model_list_all(
|
||||
self,
|
||||
|
|
|
@ -6,7 +6,7 @@ import { Button, ButtonSet, Form, Stack, TextInput } from '@carbon/react';
|
|||
import { AddAlt } from '@carbon/icons-react';
|
||||
import { modifyProcessIdentifierForPathParam, slugifyString } from '../helpers';
|
||||
import HttpService from '../services/HttpService';
|
||||
import { MetadataExtractionPaths, ProcessModel } from '../interfaces';
|
||||
import { MetadataExtractionPath, ProcessModel } from '../interfaces';
|
||||
|
||||
type OwnProps = {
|
||||
mode: string;
|
||||
|
@ -92,31 +92,34 @@ export default function ProcessModelForm({
|
|||
};
|
||||
|
||||
const metadataExtractionPathForm = (
|
||||
metadataKey: string,
|
||||
metadataPath: string
|
||||
index: number,
|
||||
metadataExtractionPath: MetadataExtractionPath
|
||||
) => {
|
||||
return (
|
||||
<>
|
||||
<TextInput
|
||||
id="process-model-metadata-extraction-path-key"
|
||||
labelText="Extraction Key"
|
||||
value={metadataKey}
|
||||
value={metadataExtractionPath.key}
|
||||
onChange={(event: any) => {
|
||||
const cep: MetadataExtractionPaths =
|
||||
processModel.metadata_extraction_paths || {};
|
||||
delete cep[metadataKey];
|
||||
cep[event.target.value] = metadataPath;
|
||||
const cep: MetadataExtractionPath[] =
|
||||
processModel.metadata_extraction_paths || [];
|
||||
const newMeta = { ...metadataExtractionPath };
|
||||
newMeta.key = event.target.value;
|
||||
cep[index] = newMeta;
|
||||
updateProcessModel({ metadata_extraction_paths: cep });
|
||||
}}
|
||||
/>
|
||||
<TextInput
|
||||
id="process-model-metadata-extraction-path"
|
||||
labelText="Extraction Path"
|
||||
value={metadataPath}
|
||||
value={metadataExtractionPath.path}
|
||||
onChange={(event: any) => {
|
||||
const cep: MetadataExtractionPaths =
|
||||
processModel.metadata_extraction_paths || {};
|
||||
cep[metadataKey] = event.target.value;
|
||||
const cep: MetadataExtractionPath[] =
|
||||
processModel.metadata_extraction_paths || [];
|
||||
const newMeta = { ...metadataExtractionPath };
|
||||
newMeta.path = event.target.value;
|
||||
cep[index] = newMeta;
|
||||
updateProcessModel({ metadata_extraction_paths: cep });
|
||||
}}
|
||||
/>
|
||||
|
@ -130,14 +133,9 @@ export default function ProcessModelForm({
|
|||
'processModel.metadata_extraction_paths',
|
||||
processModel.metadata_extraction_paths
|
||||
);
|
||||
return Object.keys(processModel.metadata_extraction_paths).map(
|
||||
(metadataKey: string) => {
|
||||
return metadataExtractionPathForm(
|
||||
metadataKey,
|
||||
processModel.metadata_extraction_paths
|
||||
? processModel.metadata_extraction_paths[metadataKey]
|
||||
: ''
|
||||
);
|
||||
return processModel.metadata_extraction_paths.map(
|
||||
(metadataExtractionPath: MetadataExtractionPath, index: number) => {
|
||||
return metadataExtractionPathForm(index, metadataExtractionPath);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -145,9 +143,9 @@ export default function ProcessModelForm({
|
|||
};
|
||||
|
||||
const addBlankMetadataExtractionPath = () => {
|
||||
const cep: MetadataExtractionPaths =
|
||||
processModel.metadata_extraction_paths || {};
|
||||
Object.assign(cep, { '': '' });
|
||||
const cep: MetadataExtractionPath[] =
|
||||
processModel.metadata_extraction_paths || [];
|
||||
cep.push({ key: '', path: '' });
|
||||
updateProcessModel({ metadata_extraction_paths: cep });
|
||||
};
|
||||
|
||||
|
|
|
@ -98,8 +98,9 @@ export interface ProcessGroupLite {
|
|||
display_name: string;
|
||||
}
|
||||
|
||||
export interface MetadataExtractionPaths {
|
||||
[key: string]: string;
|
||||
export interface MetadataExtractionPath {
|
||||
key: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface ProcessModel {
|
||||
|
@ -109,7 +110,7 @@ export interface ProcessModel {
|
|||
primary_file_name: string;
|
||||
files: ProcessFile[];
|
||||
parent_groups?: ProcessGroupLite[];
|
||||
metadata_extraction_paths?: MetadataExtractionPaths;
|
||||
metadata_extraction_paths?: MetadataExtractionPath[];
|
||||
}
|
||||
|
||||
export interface ProcessGroup {
|
||||
|
|
Loading…
Reference in New Issue