select task_id, transition_key, state, case_id
from wf_tasks
where case_id = :case_id
order by case when state = 'started' then 1 when state = 'enabled' then 2 when state = 'finished' then 3 else 4 end
select token_id, place_key, case_id, state, locked_task_id
from wf_tokens
where case_id = :case_id
and state in ('free', 'locked')
select token_id, place_key, case_id, state, locked_task_id,
to_char(produced_date, 'YYYY-MM-DD HH24:MI:SS') as produced_date_pretty,
to_char(locked_date, 'YYYY-MM-DD HH24:MI:SS') as locked_date_pretty,
to_char(consumed_date, 'YYYY-MM-DD HH24:MI:SS') as consumed_date_pretty,
to_char(canceled_date, 'YYYY-MM-DD HH24:MI:SS') as canceled_date_pretty
from wf_tokens
where case_id = :case_id
and state in ('consumed', 'canceled')
select case_id, transition_key, transition_name, trigger_type
from wf_enabled_transitions
where case_id = :case_id