class GeoHydra::Task

Constants

STATUS

Attributes

druid[RW]
flags[RW]

Public Class Methods

new(data = {}) click to toggle source
# File lib/geohydra/workflow/task.rb, line 14
def initialize(data = {})
  @flags = {}
  @flags[:debug] = data[:debug] || false
  @flags[:geoserver] = data[:geoserver] || GeoHydra::Config.ogp.geoserver || 'http://127.0.0.1:8080/geoserver'
  @flags[:purl] = data[:purl] || GeoHydra::Config.ogp.purl || 'http://purl.stanford.edu'
  @flags[:solr] = data[:solr] || GeoHydra::Config.ogp.solr || 'http://127.0.0.1:8983/solr'
  @flags[:stagedir] = data[:stagedir] || GeoHydra::Config.geohydra.stage || 'stage'
  @flags[:tmpdir] = data[:tmpdir] || GeoHydra::Config.geohydra.tmpdir || 'tmp'
  @flags[:verbose] = data[:verbose] || false
  @flags[:workspacedir] = data[:workspacedir] || GeoHydra::Config.geohydra.workspace || 'workspace'
  
  @druid = nil
  @druid = _setup_druid(data[:druid]) unless data[:druid].nil?
end

Public Instance Methods

druid=(druid) click to toggle source

@param [String] druid ‘aa111bb2222`

# File lib/geohydra/workflow/task.rb, line 37
def druid= druid
  _init_druid druid
end
log_debug(args) click to toggle source
# File lib/geohydra/workflow/task.rb, line 55
def log_debug(args)
  ap({:debug => args}) if flags[:debug]
end
log_error(args) click to toggle source
# File lib/geohydra/workflow/task.rb, line 59
def log_error(args)
  ap({:error => args})
end
log_info(args) click to toggle source
# File lib/geohydra/workflow/task.rb, line 47
def log_info(args)
  puts args
end
log_verbose(args) click to toggle source
# File lib/geohydra/workflow/task.rb, line 51
def log_verbose(args)
  ap({:verbose => args}) if flags[:verbose]
end
perform(data = {}) click to toggle source

Perform the task @param [Hash] data @return [String] one of the ‘Task.STATUS` values

# File lib/geohydra/workflow/task.rb, line 32
def perform(data = {})
  raise NotImplementedError, 'abstract method'
end
to_purl() click to toggle source

Converts the current @druid into a PURL @return [String] ‘purl.stanford.edu/aa111bb2222`

# File lib/geohydra/workflow/task.rb, line 43
def to_purl
  File.join(flags[:purl], @druid.id)
end
valid_status?(status) click to toggle source

@param [String] status @return [Boolean] true if the given status is one of the valid Task.STATUS values

# File lib/geohydra/workflow/task.rb, line 8
def valid_status? status
  STATUS.include? status.upcase
end

Private Instance Methods

_setup_druid(s) click to toggle source
# File lib/geohydra/workflow/task.rb, line 64
def _setup_druid s
  druid = DruidTools::Druid.new(s, flags[:workspacedir])
  raise ArgumentError if druid.nil? or not DruidTools::Druid.valid?(druid.druid)
  druid
end