module PIM::Services::ProcessTaskService

Public Instance Methods

__gae_utils(default_value = false, &block) click to toggle source
# File services.rb, line 3932
def __gae_utils default_value = false, &block
  return default_value unless PIM.has_java?
  begin
    java_import 'com.lansa.lax.pim.gae.GaeUtils'
    return block.call(com.lansa.lax.pim.gae.GaeUtils)
  rescue NameError
    return default_value
  end
end
check_task_retry_exception(exception, &block) click to toggle source

If the specified exception can be “retried”, either execute the code-block, if supplied, or re-raise the exception. Simply return otherwise.

# File services.rb, line 3878
def check_task_retry_exception exception, &block
  if is_task_retry_exception?(exception)
    if block
      block.call(exception)
    else
      raise exception
    end
  end
end
ensure_task_rest_time_percentage(rest_percentage = 5) click to toggle source

Ensures that the current task still has more time left to spent than the specified amount in percentage. Will throw a “task-retry” exception otherwise Uses a default value of 5

# File services.rb, line 3928
def ensure_task_rest_time_percentage rest_percentage = 5
  raise_task_retry_exception("Task has less than #{rest_percentage}% of the rest task time") if get_task_rest_time_percentage < rest_percentage
end
ensure_task_total_time_percentage(total_percentage = 95) click to toggle source

Ensures that the current task has spent less than the specified amount in percentage of it’s maximum time. Will throw a “task-retry” exception otherwise Uses a default value of 95

# File services.rb, line 3920
def ensure_task_total_time_percentage total_percentage = 95
  raise_task_retry_exception("Task took more than #{total_percentage}% of the total task time") if get_task_total_time_percentage > total_percentage
end
get_task_rest_time_millis() click to toggle source

Returns the time the current task has left compared to its maximum in milliseconds. Value returned as Ruby Integer (Java long)

# File services.rb, line 3898
def get_task_rest_time_millis
  return __gae_utils(10 * 60 * 1000) { |gae_utils| gae_utils.getTaskRestTimeMillis() }
end
get_task_rest_time_percentage() click to toggle source

Returns the time the current task has left compared to its maximum as percentage value. Value returned as Ruby Float (Java double) and ranges between 0.0-100.0

# File services.rb, line 3912
def get_task_rest_time_percentage
  return __gae_utils(100) { |gae_utils| gae_utils.getTaskRestTimePercentage() }
end
get_task_total_time_millis() click to toggle source

Returns the time the current task has already spend in milliseconds. Value returned as Ruby Integer (Java long)

# File services.rb, line 3891
def get_task_total_time_millis
  return __gae_utils(-1) { |gae_utils| gae_utils.getTaskTotalTimeMillis() }
end
get_task_total_time_percentage() click to toggle source

Returns the time the current task has already spend compared to its maximum as percentage value. Value returned as Ruby Float (Java double) and ranges between 0.0-100.0

# File services.rb, line 3905
def get_task_total_time_percentage
  return __gae_utils(-1) { |gae_utils| gae_utils.getTaskTotalTimePercentage() }
end
handle_task_retry_exception(exception, &block) click to toggle source

Executes a code-block if the specified exception can be “retried”, i.e. was caused by an exceeded deadline or timeout error. Will re-throw the exception otherwise.

# File services.rb, line 3866
def handle_task_retry_exception exception, &block
  if is_task_retry_exception?(exception)
    block.call(exception) if block
  elsif not exception.nil?
    raise exception
  end
end
is_task_retry_exception(exception)
is_task_retry_exception?(exception) click to toggle source

Returns true if the specified exception can be “retried”, i.e. was caused by an exceeded deadline or timeout error

# File services.rb, line 3849
def is_task_retry_exception? exception
  return false if exception.nil?
  return __gae_utils(false) do |gae_utils|
    exception = PIM.to_java_exception(exception)
    return gae_utils.isTaskRetryException(exception)
  end
end
Also aliased as: is_task_retry_exception
raise_task_retry_exception(msg) click to toggle source
# File services.rb, line 3942
def raise_task_retry_exception msg
  raise java.util.concurrent.CancellationException.new(msg)
end