Class: Dor::CreateWorkflowService

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/services/create_workflow_service.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ CreateWorkflowService

Returns a new instance of CreateWorkflowService.



15
16
17
# File 'lib/dor/services/create_workflow_service.rb', line 15

def initialize(item)
  @item = item
end

Class Method Details

.create_workflow(item, name:, create_ds: true, priority: 0) ⇒ Object

Initilizes workflow for the object in the workflow service

It will set the priorty of the new workflow to the current_priority if it is > 0
It will set lane_id from the item's APO default workflow lane

Parameters:

  • name (String)

    of the workflow to be initialized

  • create_ds (Boolean) (defaults to: true)

    create a ‘workflows’ datastream in Fedora for the object

  • priority (Integer) (defaults to: 0)

    the workflow’s priority level



11
12
13
# File 'lib/dor/services/create_workflow_service.rb', line 11

def self.create_workflow(item, name:, create_ds: true, priority: 0)
  new(item).create_workflow(name: name, create_ds: create_ds, priority: priority)
end

Instance Method Details

#create_workflow(name:, create_ds: true, priority: 0) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dor/services/create_workflow_service.rb', line 19

def create_workflow(name:, create_ds: true, priority: 0)
  priority = item.workflows.current_priority if priority == 0
  opts = { create_ds: create_ds, lane_id: default_workflow_lane }
  opts[:priority] = priority if priority > 0
  Dor::Config.workflow.client.create_workflow(Dor::WorkflowObject.initial_repo(name),
                                              item.pid,
                                              name,
                                              Dor::WorkflowObject.initial_workflow(name),
                                              opts)
  item.workflows.content(true) # refresh the copy of the workflows datastream
end