Skip to content

Service: Rewrite template CRUD for linked list step model #613

Description

@b-at-neu

Summary

Rewrite all ProcessStep service functions to work with the previousStepId linked list model instead of order Int. Supersedes #595 and #596.

Functions to Rewrite

getProcessTemplateAsSequence(id)

  • Fetch all steps for template
  • Resolve linked list into ProcessStepSequence[] tree starting from root steps (parentStepId=null, previousStepId=null)
  • For each step, collect its branches (steps with parentStepId=step.id) as separate sequences

addProcessStep(templateId, data)

  • Append to root sequence: find last step in root (step with parentStepId=null where no other step has previousStepId=that.id), set new step's previousStepId to it
  • Support optional afterStepId to insert mid-sequence

addBranchStep(templateId, parentStepId, data)

  • Start a new branch off parentStepId
  • Find last step in existing branches for that parent, or create first step with previousStepId=null
  • Each distinct branch is a separate linked sequence

deleteProcessStep(stepId, templateId)

  • Re-link: set previousStepId of step's successor to step's previousStepId
  • Soft-delete the step

moveProcessStep(templateId, stepId, direction)

  • Swap previousStepId links with the adjacent step in the same sequence

Purchase queries

  • Update getPurchaseProcess and getBatchPurchaseProcessData to include previousStepId

Blocked By

Blocked by #611 (schema) and #612 (types)

Supersedes #595, #596

Part of #530

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions