Module: Dor::Versionable

Extended by:
ActiveSupport::Concern, Deprecation
Included in:
Abstract
Defined in:
lib/dor/models/concerns/versionable.rb

Instance Method Summary collapse

Instance Method Details

#allows_modification?Boolean

This is used by Argo and the MergeService

Returns:

  • (Boolean)

    true if the object is in a state that allows it to be modified. States that will allow modification are: has not been submitted for accessioning, has an open version or has sdr-ingest set to hold



51
52
53
54
55
56
57
58
59
# File 'lib/dor/models/concerns/versionable.rb', line 51

def allows_modification?
  if Dor::Config.workflow.client.get_lifecycle('dor', pid, 'submitted') &&
     !VersionService.new(self).open? &&
     Dor::Config.workflow.client.get_workflow_status('dor', pid, 'accessionWF', 'sdr-ingest-transfer') != 'hold'
    false
  else
    true
  end
end

#close_version(opts = {}) ⇒ Object

Sets versioningWF:submit-version to completed and initiates accessionWF for the object

Parameters:

  • opts (Hash) (defaults to: {})

    optional params

Options Hash (opts):

  • :description (String)

    describes the version change

  • :significance (Symbol)

    which part of the version tag to increment :major, :minor, :admin (see Dor::VersionTag#increment)

  • :version_num (String)

    version number to archive rows with. Otherwise, current version is used

  • :start_accesion (Boolean)

    set to true if you want accessioning to start (default), false otherwise

Raises:

  • (Dor::Exception)

    if the object hasn’t been opened for versioning, or if accessionWF has already been instantiated or the current version is missing a tag or description



37
38
39
# File 'lib/dor/models/concerns/versionable.rb', line 37

def close_version(opts = {})
  VersionService.close(self, opts)
end

#current_versionObject



24
25
26
# File 'lib/dor/models/concerns/versionable.rb', line 24

def current_version
  .current_version_id
end

#new_version_open?Boolean

Returns true if ‘opened’ lifecycle is active, false otherwise.

Returns:

  • (Boolean)

    true if ‘opened’ lifecycle is active, false otherwise



43
44
45
# File 'lib/dor/models/concerns/versionable.rb', line 43

def new_version_open?
  VersionService.new(self).open?
end

#open_new_version(opts = {}) ⇒ Object

Increments the version number and initializes versioningWF for the object

Parameters:

  • opts (Hash) (defaults to: {})

    optional params

Options Hash (opts):

  • :assume_accessioned (Boolean)

    If true, does not check whether object has been accessioned.

  • :create_workflows_ds (Boolean)

    If false, create_workflow() will not initialize the workflows datastream.

  • :vers_md_upd_info (Hash)

    If present, used to add to the events datastream and set the desc and significance on the versionMetadata datastream

Raises:

  • (Dor::Exception)

    if the object hasn’t been accessioned, or if a version is already opened



19
20
21
# File 'lib/dor/models/concerns/versionable.rb', line 19

def open_new_version(opts = {})
  VersionService.open(self, opts)
end

#start_versionObject

Following chart of processes on this consul page: consul.stanford.edu/display/chimera/Versioning+workflows



62
63
64
# File 'lib/dor/models/concerns/versionable.rb', line 62

def start_version
  open_new_version
end

#submit_versionObject



67
68
69
# File 'lib/dor/models/concerns/versionable.rb', line 67

def submit_version
  close_version
end