Skip to content

Commit

Permalink
Changes for new rest endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sumesh-aot committed Oct 11, 2024
1 parent 82de145 commit 0f141e1
Show file tree
Hide file tree
Showing 17 changed files with 916 additions and 27 deletions.
1 change: 1 addition & 0 deletions spiffworkflow-backend/migrations/alembic.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# A generic, single database configuration.

[alembic]
script_location = migrations
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s

Expand Down
40 changes: 40 additions & 0 deletions spiffworkflow-backend/migrations/versions/da22d9039670_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""empty message
Revision ID: da22d9039670
Revises: 384e2bbda36b
Create Date: 2024-09-17 15:13:48.384925
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'da22d9039670'
down_revision = '384e2bbda36b'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('human_task_user', schema=None) as batch_op:
batch_op.add_column(sa.Column('ended_at_in_seconds', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('created_at_in_seconds', sa.Integer(), nullable=True))

# with op.batch_alter_table('task', schema=None) as batch_op:
# batch_op.drop_constraint('guid', type_='unique')

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
# with op.batch_alter_table('task', schema=None) as batch_op:
# batch_op.create_unique_constraint('guid', ['guid'])

with op.batch_alter_table('human_task_user', schema=None) as batch_op:
batch_op.drop_column('created_at_in_seconds')
batch_op.drop_column('ended_at_in_seconds')

# ### end Alembic commands ###
304 changes: 304 additions & 0 deletions spiffworkflow-backend/src/spiffworkflow_backend/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3422,6 +3422,135 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Workflow"
/task-filters:
post:
summary: Retrieve filtered tasks based on pagination and other criteria
operationId: spiffworkflow_backend.routes.ff_tasks_controller.filter_tasks
parameters:
- name: firstResult
in: query
required: true
description: The starting index of the results to return
schema:
type: integer
- name: maxResults
in: query
required: true
description: The maximum number of results to return
schema:
type: integer
responses:
"200":
description: Successfully retrieved filtered tasks
content:
application/json:
schema:
type: array
items:
type: object
properties:
_links:
type: object
properties:
self:
type: object
properties:
href:
type: string
_embedded:
type: object
# properties:
# assignee:
# type: array
# items:
# $ref: '#/components/schemas/FfUser'
# processDefinition:
# type: array
# items:
# $ref: '#/components/schemas/ProcessDefinition'
# task:
# type: array
# items:
# $ref: '#/components/schemas/FfTask'
count:
type: integer
/task/{task_id}:
parameters:
- name: task_id
in: path
required: true
description: "The unique id of an existing process group."
schema:
type: string
get:
tags:
- Tasks
operationId: spiffworkflow_backend.routes.ff_tasks_controller.get_task_by_id
summary: "Gets one task that a user wants to complete"
responses:
"200":
description: "One task"
content:
application/json:
schema:
$ref: "#/components/schemas/Task"


/task/{task_id}/claim:
post:
summary: "Claim task"
operationId: spiffworkflow_backend.routes.ff_tasks_controller.claim_task
parameters:
- name: task_id
in: path
required: true
description: "The unique id of an existing process group."
schema:
type: string
responses:
"200":
description: "Successfully claimed task"
content:
application/json:
schema:
type: object
/task/{task_id}/unclaim:
post:
summary: "Unclaim task"
operationId: spiffworkflow_backend.routes.ff_tasks_controller.unclaim_task
parameters:
- name: task_id
in: path
required: true
description: "The unique id of an existing process group."
schema:
type: string
responses:
"200":
description: "Successfully unclaimed task"
content:
application/json:
schema:
type: object

/task/{task_id}/submit-form:
post:
summary: "Submit form"
operationId: spiffworkflow_backend.routes.ff_tasks_controller.submit_task
parameters:
- name: task_id
in: path
required: true
description: "The unique id of an existing process group."
schema:
type: string
responses:
"200":
description: "Successfully submitted task"
content:
application/json:
schema:
type: object

components:
securitySchemes:
Expand Down Expand Up @@ -4105,3 +4234,178 @@ components:
type: number
example: 1
nullable: false

# FfUser:
# type: object
# properties:
# _links:
# type: object
# properties:
# self:
# type: object
# properties:
# href:
# type: string
# _embedded:
# type: object
# id:
# type: string
# firstName:
# type: string
# lastName:
# type: string
# email:
# type: string
# ProcessDefinition:
# type: object
# properties:
# _links:
# type: object
# additionalProperties:
# type: object
# properties:
# href:
# type: string
# _embedded:
# type: object
# id:
# type: string
# key:
# type: string
# category:
# type: string
# description:
# type: string
# name:
# type: string
# versionTag:
# type: string
# version:
# type: integer
# resource:
# type: string
# deploymentId:
# type: string
# diagram:
# type: string
# suspended:
# type: boolean
# contextPath:
# type: string
# FfTask:
# type: object
# properties:
# _links:
# type: object
# additionalProperties:
# type: object
# properties:
# href:
# type: string
# _embedded:
# type: object
# properties:
# candidateGroups:
# type: array
# items:
# $ref: '#/components/schemas/CandidateGroup'
# variable:
# type: array
# items:
# $ref: '#/components/schemas/Variable'
# id:
# type: string
# name:
# type: string
# assignee:
# type: string
# created:
# type: string
# format: date-time
# due:
# type: string
# format: date-time
# followUp:
# type: string
# format: date-time
# delegationState:
# type: string
# description:
# type: string
# executionId:
# type: string
# owner:
# type: string
# parentTaskId:
# type: string
# priority:
# type: integer
# processDefinitionId:
# type: string
# processInstanceId:
# type: string
# taskDefinitionKey:
# type: string
# caseExecutionId:
# type: string
# caseInstanceId:
# type: string
# caseDefinitionId:
# type: string
# suspended:
# type: boolean
# formKey:
# type: string
# camundaFormRef:
# type: string
# tenantId:
# type: string
# CandidateGroup:
# type: object
# properties:
# _links:
# type: object
# properties:
# group:
# type: object
# properties:
# href:
# type: string
# task:
# type: object
# properties:
# href:
# type: string
# _embedded:
# type: object
# type:
# type: string
# userId:
# type: string
# groupId:
# type: string
# taskId:
# type: string
# Variable:
# type: object
# properties:
# _links:
# type: object
# properties:
# self:
# type: object
# properties:
# href:
# type: string
# _embedded:
# type: object
# name:
# type: string
# value:
# type: string
# type:
# type: string
# valueInfo:
# type: object
# additionalProperties:
# type: string
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ class HumanTaskUserModel(SpiffworkflowBaseDBModel):
id = db.Column(db.Integer, primary_key=True)
human_task_id = db.Column(ForeignKey(HumanTaskModel.id), nullable=False, index=True) # type: ignore
user_id = db.Column(ForeignKey(UserModel.id), nullable=False, index=True) # type: ignore
ended_at_in_seconds: int = db.Column(db.Integer)
created_at_in_seconds: int = db.Column(db.Integer)

human_task = relationship(HumanTaskModel, back_populates="human_task_users")
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from spiffworkflow_backend.models.future_task import FutureTaskModel
from spiffworkflow_backend.models.task import TaskModel # noqa: F401
from spiffworkflow_backend.models.user import UserModel

from flask import current_app

class ProcessInstanceNotFoundError(Exception):
pass
Expand Down Expand Up @@ -212,7 +212,9 @@ def get_last_completed_task(self) -> TaskModel | None:
def get_data(self) -> dict:
"""Returns the data of the last completed task in this process instance."""
last_completed_task = self.get_last_completed_task()
current_app.logger.info(f"get_data::last_completed_task : {last_completed_task}")
if last_completed_task: # pragma: no cover
current_app.logger.info(f"last_completed_task : {last_completed_task.json_data()}")
return last_completed_task.json_data()
else:
return {}
Expand Down
Loading

0 comments on commit 0f141e1

Please sign in to comment.