Sha256: 05b4d16bb125277d80d79282d218ec6dfbfb220e6b0d143f91f60b26cc9c557f

Contents?: true

Size: 1.39 KB

Versions: 4

Compression:

Stored size: 1.39 KB

Contents

class Camunda::Deployment < Camunda::Model
  collection_path 'deployment'
  # Only supporting .create which uses a POST on deployment/create.
  def self.create(file_names:, tenant_id: nil, deployment_source: 'Camunda Workflow Gem', deployment_name: nil)
    deployment_name ||= file_names.map { |file_name| File.basename(file_name) }.join(", ")
    tenant_id ||= Camunda::Workflow.configuration.tenant_id
    args = file_data(file_names).merge('deployment-name' => deployment_name, 'deployment-source' => deployment_source)
    args.merge!("tenant-id": tenant_id) if tenant_id
    response = post_raw('deployment/create', args)

    deployed_process_definitions(response[:parsed_data][:data][:deployed_process_definitions])
  end

  def self.file_data(file_names)
    file_names.map do |file_name|
      [file_name, UploadIO.new(file_name, 'text/plain')]
    end.to_h
  end

  def self.deployed_process_definitions(definitions_hash)
    # Currently only returning the process definitions. But this Deployment.create can create a DMN, CMMN also
    # It returns :deployed_process_definitions, :deployed_case_definitions, :deployed_decision_definitions,
    # :deployed_decision_requirements_definitions

    raise Camunda::ProcessEngineException, "No Process Definition created" if definitions_hash.nil?

    definitions_hash.values.map { |process_definition| Camunda::ProcessDefinition.new process_definition }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
camunda-workflow-0.1.3 lib/camunda/deployment.rb
camunda-workflow-0.1.2 lib/camunda/deployment.rb
camunda-workflow-0.1.1 lib/camunda/deployment.rb
camunda-workflow-0.1 lib/camunda/deployment.rb