mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-02-05 14:44:12 +00:00
Adding a very simple api endpoint that just returns a list of every process known to the system.
This commit is contained in:
parent
88a40c73ea
commit
22d1186236
@ -1,8 +1,8 @@
|
|||||||
"""empty message
|
"""empty message
|
||||||
|
|
||||||
Revision ID: 3e2a826ac720
|
Revision ID: 7d1662ea1227
|
||||||
Revises:
|
Revises:
|
||||||
Create Date: 2022-11-14 14:59:43.265173
|
Create Date: 2022-11-14 21:48:34.469311
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
|||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = '3e2a826ac720'
|
revision = '7d1662ea1227'
|
||||||
down_revision = None
|
down_revision = None
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
@ -42,6 +42,7 @@ def upgrade():
|
|||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('identifier', sa.String(length=255), nullable=True),
|
sa.Column('identifier', sa.String(length=255), nullable=True),
|
||||||
sa.Column('display_name', sa.String(length=255), nullable=True),
|
sa.Column('display_name', sa.String(length=255), nullable=True),
|
||||||
|
sa.Column('process_model_id', sa.String(length=255), nullable=True),
|
||||||
sa.Column('type', sa.String(length=255), nullable=True),
|
sa.Column('type', sa.String(length=255), nullable=True),
|
||||||
sa.Column('file_name', sa.String(length=255), nullable=True),
|
sa.Column('file_name', sa.String(length=255), nullable=True),
|
||||||
sa.Column('relative_path', sa.String(length=255), nullable=True),
|
sa.Column('relative_path', sa.String(length=255), nullable=True),
|
@ -371,6 +371,23 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/OkTrue"
|
$ref: "#/components/schemas/OkTrue"
|
||||||
|
# process_model_list
|
||||||
|
/processes:
|
||||||
|
get:
|
||||||
|
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_list
|
||||||
|
summary: Return a list of all processes (not just primary process of a process model)
|
||||||
|
useful for finding processes for call activites.
|
||||||
|
tags:
|
||||||
|
- Process Models
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Successfully return the requested processes
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Process"
|
||||||
|
|
||||||
/process-instances:
|
/process-instances:
|
||||||
parameters:
|
parameters:
|
||||||
@ -1530,7 +1547,26 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
x-nullable: true
|
x-nullable: true
|
||||||
example: Some Value
|
example: Some Value
|
||||||
|
Process:
|
||||||
|
properties:
|
||||||
|
identifier:
|
||||||
|
type: string
|
||||||
|
display_name:
|
||||||
|
type: string
|
||||||
|
process_group_id:
|
||||||
|
type: string
|
||||||
|
process_model_id:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
file_name:
|
||||||
|
type: string
|
||||||
|
has_lanes:
|
||||||
|
type: boolean
|
||||||
|
is_executable:
|
||||||
|
type: boolean
|
||||||
|
is_primary:
|
||||||
|
type: boolean
|
||||||
ProcessModel:
|
ProcessModel:
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
|
@ -19,6 +19,7 @@ class SpecReference:
|
|||||||
|
|
||||||
identifier: str # The id of the process or decision. "Process_1234"
|
identifier: str # The id of the process or decision. "Process_1234"
|
||||||
display_name: str # The name of the process or decision. "Invoice Submission"
|
display_name: str # The name of the process or decision. "Invoice Submission"
|
||||||
|
process_model_id: str
|
||||||
type: str # can be 'process' or 'decision'
|
type: str # can be 'process' or 'decision'
|
||||||
file_name: str # The name of the file where this process or decision is defined.
|
file_name: str # The name of the file where this process or decision is defined.
|
||||||
relative_path: str # The path to the file.
|
relative_path: str # The path to the file.
|
||||||
@ -38,6 +39,7 @@ class SpecReferenceCache(SpiffworkflowBaseDBModel):
|
|||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
identifier = db.Column(db.String(255), unique=True, index=True)
|
identifier = db.Column(db.String(255), unique=True, index=True)
|
||||||
display_name = db.Column(db.String(255), index=True)
|
display_name = db.Column(db.String(255), index=True)
|
||||||
|
process_model_id = db.Column(db.String(255))
|
||||||
type = db.Column(db.String(255), index=True) # either 'process' or 'decision'
|
type = db.Column(db.String(255), index=True) # either 'process' or 'decision'
|
||||||
file_name = db.Column(db.String(255))
|
file_name = db.Column(db.String(255))
|
||||||
relative_path = db.Column(db.String(255))
|
relative_path = db.Column(db.String(255))
|
||||||
@ -52,5 +54,8 @@ class SpecReferenceSchema(Schema):
|
|||||||
"""Meta."""
|
"""Meta."""
|
||||||
|
|
||||||
model = SpecReference
|
model = SpecReference
|
||||||
fields = ["identifier", "display_name", "type"]
|
fields = ["identifier", "display_name",
|
||||||
|
"process_group_id", "process_model_id",
|
||||||
|
"type", "file_name", "has_lanes",
|
||||||
|
"is_executable", "is_primary"]
|
||||||
unknown = INCLUDE
|
unknown = INCLUDE
|
@ -59,6 +59,7 @@ from spiffworkflow_backend.models.process_model import ProcessModelInfo
|
|||||||
from spiffworkflow_backend.models.process_model import ProcessModelInfoSchema
|
from spiffworkflow_backend.models.process_model import ProcessModelInfoSchema
|
||||||
from spiffworkflow_backend.models.secret_model import SecretModel
|
from spiffworkflow_backend.models.secret_model import SecretModel
|
||||||
from spiffworkflow_backend.models.secret_model import SecretModelSchema
|
from spiffworkflow_backend.models.secret_model import SecretModelSchema
|
||||||
|
from spiffworkflow_backend.models.spec_reference import SpecReferenceCache, SpecReferenceSchema
|
||||||
from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel
|
from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel
|
||||||
from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel
|
from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel
|
||||||
from spiffworkflow_backend.models.user import UserModel
|
from spiffworkflow_backend.models.user import UserModel
|
||||||
@ -336,10 +337,16 @@ def process_model_list(
|
|||||||
"pages": pages,
|
"pages": pages,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response(json.dumps(response_json), status=200, mimetype="application/json")
|
return Response(json.dumps(response_json), status=200, mimetype="application/json")
|
||||||
|
|
||||||
|
|
||||||
|
def process_list() -> any:
|
||||||
|
"""Returns a list of all known processes - this includes processes that are not the
|
||||||
|
primary process - helpful for finding possible call activities. """
|
||||||
|
references = SpecReferenceCache.query.filter_by(type = "process")
|
||||||
|
return SpecReferenceSchema(many=True).dump(references)
|
||||||
|
|
||||||
|
|
||||||
def get_file(modified_process_model_id: str, file_name: str) -> Any:
|
def get_file(modified_process_model_id: str, file_name: str) -> Any:
|
||||||
"""Get_file."""
|
"""Get_file."""
|
||||||
process_model_identifier = modified_process_model_id.replace(":", "/")
|
process_model_identifier = modified_process_model_id.replace(":", "/")
|
||||||
|
@ -124,7 +124,9 @@ class SpecFileService(FileSystemService):
|
|||||||
start_messages = sub_parser.start_messages()
|
start_messages = sub_parser.start_messages()
|
||||||
is_primary = sub_parser.get_id() == process_model_info.primary_process_id
|
is_primary = sub_parser.get_id() == process_model_info.primary_process_id
|
||||||
references.append(SpecReference(
|
references.append(SpecReference(
|
||||||
identifier=sub_parser.get_id(), display_name=sub_parser.get_name(), type=parser_type,
|
identifier=sub_parser.get_id(), display_name=sub_parser.get_name(),
|
||||||
|
process_model_id=process_model_info.id,
|
||||||
|
type=parser_type,
|
||||||
file_name=file.name, relative_path=file_path, has_lanes=has_lanes,
|
file_name=file.name, relative_path=file_path, has_lanes=has_lanes,
|
||||||
is_executable=is_executable, messages=messages, is_primary=is_primary,
|
is_executable=is_executable, messages=messages, is_primary=is_primary,
|
||||||
correlations=correlations, start_messages=start_messages
|
correlations=correlations, start_messages=start_messages
|
||||||
@ -235,9 +237,13 @@ class SpecFileService(FileSystemService):
|
|||||||
process_id_lookup = SpecReferenceCache(
|
process_id_lookup = SpecReferenceCache(
|
||||||
identifier=ref.identifier,
|
identifier=ref.identifier,
|
||||||
display_name=ref.display_name,
|
display_name=ref.display_name,
|
||||||
relative_path=ref.relative_path,
|
process_model_id=ref.process_model_id,
|
||||||
type=ref.type,
|
type=ref.type,
|
||||||
is_executable=ref.is_executable
|
file_name=ref.file_name,
|
||||||
|
has_lanes=ref.has_lanes,
|
||||||
|
is_executable=ref.is_executable,
|
||||||
|
is_primary=ref.is_primary,
|
||||||
|
relative_path=ref.relative_path,
|
||||||
)
|
)
|
||||||
db.session.add(process_id_lookup)
|
db.session.add(process_id_lookup)
|
||||||
else:
|
else:
|
||||||
|
@ -467,6 +467,18 @@ class TestProcessApi(BaseTest):
|
|||||||
# When adding a process model with 4 processes and a decision, 5 new records will be in the Cache
|
# When adding a process model with 4 processes and a decision, 5 new records will be in the Cache
|
||||||
assert(len(SpecReferenceCache.query.all()) == 6)
|
assert(len(SpecReferenceCache.query.all()) == 6)
|
||||||
|
|
||||||
|
# get the results
|
||||||
|
response = client.get("/v1.0/processes", headers=self.logged_in_headers(with_super_admin_user),
|
||||||
|
)
|
||||||
|
assert response.json is not None
|
||||||
|
# We should get 5 back, as one of the items in the cache is a decision.
|
||||||
|
assert len(response.json) == 5
|
||||||
|
simple_form = next(p for p in response.json if p['identifier'] == 'Proccess_WithForm')
|
||||||
|
assert(simple_form['display_name'] == 'Process With Form')
|
||||||
|
assert(simple_form['process_model_id'] == 'test_group_one/simple_form')
|
||||||
|
assert(simple_form['has_lanes'] == False)
|
||||||
|
assert(simple_form['is_executable'] == True)
|
||||||
|
assert(simple_form['is_primary'] == True)
|
||||||
|
|
||||||
|
|
||||||
def test_process_group_add(
|
def test_process_group_add(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user