added message correlations to message instance list api call w/ burnettk
This commit is contained in:
parent
bfde1c2a6e
commit
013cc56367
|
@ -44,6 +44,9 @@ class MessageCorrelationModel(SpiffworkflowBaseDBModel):
|
||||||
updated_at_in_seconds: int = db.Column(db.Integer)
|
updated_at_in_seconds: int = db.Column(db.Integer)
|
||||||
created_at_in_seconds: int = db.Column(db.Integer)
|
created_at_in_seconds: int = db.Column(db.Integer)
|
||||||
|
|
||||||
|
message_correlation_property = relationship(
|
||||||
|
"MessageCorrelationPropertyModel"
|
||||||
|
)
|
||||||
message_correlations_message_instances = relationship(
|
message_correlations_message_instances = relationship(
|
||||||
"MessageCorrelationMessageInstanceModel", cascade="delete"
|
"MessageCorrelationMessageInstanceModel", cascade="delete"
|
||||||
)
|
)
|
||||||
|
|
|
@ -59,6 +59,8 @@ class MessageInstanceModel(SpiffworkflowBaseDBModel):
|
||||||
updated_at_in_seconds: int = db.Column(db.Integer)
|
updated_at_in_seconds: int = db.Column(db.Integer)
|
||||||
created_at_in_seconds: int = db.Column(db.Integer)
|
created_at_in_seconds: int = db.Column(db.Integer)
|
||||||
|
|
||||||
|
message_correlations: dict | None = None
|
||||||
|
|
||||||
@validates("message_type")
|
@validates("message_type")
|
||||||
def validate_message_type(self, key: str, value: Any) -> Any:
|
def validate_message_type(self, key: str, value: Any) -> Any:
|
||||||
"""Validate_message_type."""
|
"""Validate_message_type."""
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""APIs for dealing with process groups, process models, and process instances."""
|
"""APIs for dealing with process groups, process models, and process instances."""
|
||||||
|
import dataclasses
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
@ -13,6 +14,10 @@ from typing import Union
|
||||||
import connexion # type: ignore
|
import connexion # type: ignore
|
||||||
import flask.wrappers
|
import flask.wrappers
|
||||||
import jinja2
|
import jinja2
|
||||||
|
from spiffworkflow_backend.models import message_correlation_message_instance
|
||||||
|
from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel
|
||||||
|
from spiffworkflow_backend.models.message_correlation_message_instance import MessageCorrelationMessageInstanceModel
|
||||||
|
from spiffworkflow_backend.models.message_correlation_property import MessageCorrelationPropertyModel
|
||||||
import werkzeug
|
import werkzeug
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
@ -581,16 +586,25 @@ def message_instance_list(
|
||||||
MessageInstanceModel.created_at_in_seconds.desc(), # type: ignore
|
MessageInstanceModel.created_at_in_seconds.desc(), # type: ignore
|
||||||
MessageInstanceModel.id.desc(), # type: ignore
|
MessageInstanceModel.id.desc(), # type: ignore
|
||||||
)
|
)
|
||||||
.join(MessageModel)
|
.join(MessageModel, MessageModel.id == MessageInstanceModel.message_model_id)
|
||||||
.join(ProcessInstanceModel)
|
.join(ProcessInstanceModel)
|
||||||
.add_columns(
|
.add_columns(
|
||||||
MessageModel.identifier.label("message_identifier"),
|
MessageModel.identifier.label("message_identifier"),
|
||||||
ProcessInstanceModel.process_model_identifier,
|
ProcessInstanceModel.process_model_identifier,
|
||||||
ProcessInstanceModel.process_group_identifier,
|
|
||||||
)
|
)
|
||||||
.paginate(page=page, per_page=per_page, error_out=False)
|
.paginate(page=page, per_page=per_page, error_out=False)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for message_instance in message_instances:
|
||||||
|
message_correlations: dict = {}
|
||||||
|
for mcmi in message_instance.MessageInstanceModel.message_correlations_message_instances:
|
||||||
|
mc = MessageCorrelationModel.query.filter_by(id=mcmi.message_correlation_id).all()
|
||||||
|
for m in mc:
|
||||||
|
if m.name not in message_correlations:
|
||||||
|
message_correlations[m.name] = {}
|
||||||
|
message_correlations[m.name][m.message_correlation_property.identifier] = m.value
|
||||||
|
message_instance.MessageInstanceModel.message_correlations = message_correlations
|
||||||
|
|
||||||
response_json = {
|
response_json = {
|
||||||
"results": message_instances.items,
|
"results": message_instances.items,
|
||||||
"pagination": {
|
"pagination": {
|
||||||
|
|
|
@ -65,7 +65,7 @@ export default function MessageInstanceList() {
|
||||||
</td>
|
</td>
|
||||||
<td>{rowToUse.message_identifier}</td>
|
<td>{rowToUse.message_identifier}</td>
|
||||||
<td>{rowToUse.message_type}</td>
|
<td>{rowToUse.message_type}</td>
|
||||||
<td>{rowToUse.failure_cause}</td>
|
<td>{rowToUse.failure_cause || '-'}</td>
|
||||||
<td>{rowToUse.status}</td>
|
<td>{rowToUse.status}</td>
|
||||||
<td>
|
<td>
|
||||||
{convertSecondsToFormattedDate(rowToUse.created_at_in_seconds)}
|
{convertSecondsToFormattedDate(rowToUse.created_at_in_seconds)}
|
||||||
|
|
|
@ -276,26 +276,6 @@ export default function ProcessInstanceList() {
|
||||||
</DatePicker>
|
</DatePicker>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSearchParamsAsQueryString = () => {
|
|
||||||
let queryParamString = '';
|
|
||||||
Object.keys(parametersToAlwaysFilterBy).forEach((paramName) => {
|
|
||||||
const searchParamValue = searchParams.get(paramName);
|
|
||||||
if (searchParamValue) {
|
|
||||||
queryParamString += `&${paramName}=${searchParamValue}`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.keys(parametersToGetFromSearchParams).forEach(
|
|
||||||
(paramName: string) => {
|
|
||||||
if (searchParams.get(paramName)) {
|
|
||||||
queryParamString += `&${paramName}=${searchParams.get(paramName)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return queryParamString;
|
|
||||||
};
|
|
||||||
|
|
||||||
const processStatusSearch = () => {
|
const processStatusSearch = () => {
|
||||||
return (
|
return (
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
|
@ -315,7 +295,6 @@ export default function ProcessInstanceList() {
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearFilters = () => {
|
const clearFilters = () => {
|
||||||
setProcessModelSelection(null);
|
setProcessModelSelection(null);
|
||||||
setProcessStatusSelection([]);
|
setProcessStatusSelection([]);
|
||||||
|
@ -324,7 +303,6 @@ export default function ProcessInstanceList() {
|
||||||
setEndFrom('');
|
setEndFrom('');
|
||||||
setEndTo('');
|
setEndTo('');
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterOptions = () => {
|
const filterOptions = () => {
|
||||||
if (!showFilterOptions) {
|
if (!showFilterOptions) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -385,6 +363,33 @@ export default function ProcessInstanceList() {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const toggleShowFilterOptions = () => {
|
||||||
|
setShowFilterOptions(!showFilterOptions);
|
||||||
|
};
|
||||||
|
const filterComponent = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Grid fullWidth>
|
||||||
|
<Column
|
||||||
|
sm={{ span: 1, offset: 3 }}
|
||||||
|
md={{ span: 1, offset: 7 }}
|
||||||
|
lg={{ span: 1, offset: 15 }}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
data-qa="filter-section-expand-toggle"
|
||||||
|
kind="ghost"
|
||||||
|
renderIcon={Filter}
|
||||||
|
iconDescription="Filter Options"
|
||||||
|
hasIconOnly
|
||||||
|
size="lg"
|
||||||
|
onClick={toggleShowFilterOptions}
|
||||||
|
/>
|
||||||
|
</Column>
|
||||||
|
</Grid>
|
||||||
|
{filterOptions()}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const buildTable = () => {
|
const buildTable = () => {
|
||||||
const headerLabels: Record<string, string> = {
|
const headerLabels: Record<string, string> = {
|
||||||
|
@ -493,12 +498,27 @@ export default function ProcessInstanceList() {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const processInstanceTitleElement = () => {
|
const getSearchParamsAsQueryString = () => {
|
||||||
return <h1>Process Instances</h1>;
|
let queryParamString = '';
|
||||||
|
Object.keys(parametersToAlwaysFilterBy).forEach((paramName) => {
|
||||||
|
const searchParamValue = searchParams.get(paramName);
|
||||||
|
if (searchParamValue) {
|
||||||
|
queryParamString += `&${paramName}=${searchParamValue}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.keys(parametersToGetFromSearchParams).forEach(
|
||||||
|
(paramName: string) => {
|
||||||
|
if (searchParams.get(paramName)) {
|
||||||
|
queryParamString += `&${paramName}=${searchParams.get(paramName)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return queryParamString;
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleShowFilterOptions = () => {
|
const processInstanceTitleElement = () => {
|
||||||
setShowFilterOptions(!showFilterOptions);
|
return <h1>Process Instances</h1>;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pagination) {
|
if (pagination) {
|
||||||
|
@ -507,24 +527,7 @@ export default function ProcessInstanceList() {
|
||||||
<>
|
<>
|
||||||
{processInstanceBreadcrumbElement()}
|
{processInstanceBreadcrumbElement()}
|
||||||
{processInstanceTitleElement()}
|
{processInstanceTitleElement()}
|
||||||
<Grid fullWidth>
|
{filterComponent()}
|
||||||
<Column
|
|
||||||
sm={{ span: 1, offset: 3 }}
|
|
||||||
md={{ span: 1, offset: 7 }}
|
|
||||||
lg={{ span: 1, offset: 15 }}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
data-qa="filter-section-expand-toggle"
|
|
||||||
kind="ghost"
|
|
||||||
renderIcon={Filter}
|
|
||||||
iconDescription="Filter Options"
|
|
||||||
hasIconOnly
|
|
||||||
size="lg"
|
|
||||||
onClick={toggleShowFilterOptions}
|
|
||||||
/>
|
|
||||||
</Column>
|
|
||||||
</Grid>
|
|
||||||
{filterOptions()}
|
|
||||||
<br />
|
<br />
|
||||||
<PaginationForTable
|
<PaginationForTable
|
||||||
page={page}
|
page={page}
|
||||||
|
|
Loading…
Reference in New Issue