Module: UU::OS::ActivityCondition

Extended by:
ActivityCondition
Included in:
ActivityCondition
Defined in:
uu_os-0.29.16/lib/uu/os/activity_condition.rb,
uu_os-0.29.16/lib/uu/os/activity_condition/activity_condition_type.rb,
uu_os-0.29.16/lib/uu/os/activity_condition/activity_condition_create.rb,
uu_os-0.29.16/lib/uu/os/activity_condition/activity_condition_attributes.rb,
uu_os-0.29.16/lib/uu/os/activity_condition/activity_condition_validity_type.rb,
uu_os-0.29.16/lib/uu/os/activity_condition/activity_condition_get_attributes.rb,
uu_os-0.29.16/lib/uu/os/activity_condition/activity_condition_get_activity_condition_list.rb

Overview

Module Activity Condition.

Defined Under Namespace

Classes: ActivityConditionAttributes, ActivityConditionCreate, ActivityConditionGetActivityConditionList, ActivityConditionGetAttributes, ActivityConditionType, ActivityConditionValidityType

Constant Summary

PATH =

Service path

'uu/os/ActivityCondition'

Instance Method Summary (collapse)

Instance Method Details

- (String) create(entity_uri, options)

Creates a new activity condition for the specified activity template or activity instance. According to the entered type, following parameters must be specified:

  • For time condition, the parameter date_of_fulfilling must be specified

  • For artifact state condition, the parameter artifact_state_template_uri must be specified

  • For activity state condition, the parameter activity_state_template_uri must be specified

  • For composed condition, the parameters expression and condition_list must be specified

Examples:

# Create a time condition.
UU::OS::ActivityCondition.create('ues:TERRITORY:ARTIFACT:ENTITY',
   :condition_code => 'CONDITION_CODE',
   :type => 'TIME_CONDITION',
   :validity_type => 'IMPULSE',
   :date_of_fulfilling => '2014-09-04T00:00:00.000+01:00')

# Create a condition that responds to an artifact state.      
UU::OS::ActivityCondition.create('ues:TERRITORY:ARTIFACT:ENTITY',
   :condition_code => 'CONDITION_CODE',
   :type => 'ARTIFACT_STATE_CONDITION',
   :recurring => true,
   :validity_type => 'IMPULSE',
   :delay => 'PT1H0M0.000S',
   :artifact_state_template_uri => 'ues:TERRITORY:META_ARTIFACT:ARTIFACT_STATE_TEMPLATE',
   :previous_artifact_state_template_uri => 'ues:TERRITORY:META_ARTIFACT:ARTIFACT_STATE_TEMPLATE')

# Create a condition that responds to an activity state.
UU::OS::ActivityCondition.create('ues:TERRITORY:ARTIFACT:ENTITY',
   :condition_code => 'CONDITION_CODE',
   :type => 'ACTIVITY_STATE_CONDITION',
   :recurring => true,
   :validity_type => 'IMPULSE',
   :delay => 'PT1H0M0.000S',
   :activity_state_template_uri => 'ues:TERRITORY:META_ARTIFACT:ACTIVITY_STATE_TEMPLATE',
   :previous_activity_state_template_uri => 'ues:TERRITORY:META_ARTIFACT:ACTIVITY_STATE_TEMPLATE')   

# Create a composed condition.
time_condition = UU::OS::ActivityCondition::ActivityConditionCreate.new(
   :id => 'C1',
   :type => 'TIME_CONDITION',
   :validity_type => 'LEVEL',
   :date_of_fulfilling => '2014-09-04T00:00:00.000+01:00'
)
artifact_state_condition = UU::OS::ActivityCondition::ActivityConditionCreate.new(
   :id => 'C2',
   :type => 'ARTIFACT_STATE_CONDITION',
   :validity_type => 'LEVEL',
   :recurring => true,
   :delay => 'PT1H0M0.000S',
   :artifact_state_template_uri => 'ues:TERRITORY:META_ARTIFACT:ARTIFACT_STATE_TEMPLATE',
   :previous_artifact_state_template_uri => 'ues:TERRITORY:META_ARTIFACT:ARTIFACT_STATE_TEMPLATE'
)
activity_state_condition = UU::OS::ActivityCondition::ActivityConditionCreate.new(
   :id => 'C3',
   :type => 'ACTIVITY_STATE_CONDITION',
   :validity_type => 'LEVEL',
   :recurring => true,
   :delay => 'PT1H0M0.000S',
   :activity_state_template_uri => 'ues:TERRITORY:META_ARTIFACT:ACTIVITY_STATE_TEMPLATE',
   :previous_activity_state_template_uri => 'ues:TERRITORY:META_ARTIFACT:ACTIVITY_STATE_TEMPLATE'
)
UU::OS::ActivityCondition.create('ues:TERRITORY:ARTIFACT:ENTITY',
   :condition_code => 'CONDITION_CODE',
   :type => 'COMPOSED_CONDITION',
   :expression => 'C1 and (not C2 or C3)',
   :condition_list => [time_condition, artifact_state_condition, activity_state_condition])

Parameters:

Options Hash (options):

  • :condition_code (String)

    Activity condition identifier. If it is not specified, it is generated automatically using the system sequence. The condition_code must be unique in the scope of the related artifact. It must not be specified for conditions contained in condition_list because such conditions are identified by the parameter “id” instead.

  • :id (String)

    Not nil for conditions contained in condition_list. Identifier of conditions contained in condition_list. It is used to identify such conditions to enable their usage in the parameter "expression". The id must be unique in the scope of the created composed condition.

  • :type (String, UU::OS::ActivityCondition::ActivityConditionType)

    Not nil. Type of the new activity condition. All possible types can be found as constants in ActivityConditionType class.

  • :validity_type (String, UU::OS::ActivityCondition::ActivityConditionValidityType)

    Validity type of the activity condition. Impulse activity condition is fulfilled when the condition is met. Level activity condition is fulfilled from the time when the condition is met and subsequently throughout the given condition existence. All possible types can be found as constants in ActivityConditionValidityType class. The default value is IMPULSE.

  • :date_of_fulfilling (String)

    Not nil if the type is TIME_CONDITION. Date of fulfilling of the time condition. The entered value must be in ISO 8601 format.

  • :recurring (Boolean)

    Specifies whether the condition will be executed every time when the given conditions are fulfilled or it will be transformed into a simple time condition after its first evaluation. This parameter can be used only when the user creates an artifact state or an activity state condition. The default value is true.

  • :delay (String)

    Specifies the duration which must be elapsed for condition fulfillment. The duration value must be greater or equal to zero. The entered value must be in ISO 8601 format. This parameter can be used only when the user creates an artifact state or an activity state condition.

  • :artifact_state_template_uri (String, UU::OS::UESURI)

    Not nil if the type is ARTIFACT_STATE_CONDITION. URI of an artifact state template. The condition is fulfilled when the related artifact is set to the state specified by this template. It is not allowed to use a system state template.

  • :previous_artifact_state_template_uri (String, UU::OS::UESURI)

    URI of an artifact state template. The condition that uses this parameter is fulfilled only if the related artifact was set to the state specified by this template right before it was set into the state specified in artifact_state_template_uri. It is not allowed to use a system state template. This parameter can be used only when the user creates an artifact state condition.

  • :activity_state_template_uri (String, UU::OS::UESURI)

    Not nil if the type is ACTIVITY_STATE_CONDITION. URI of an activity state template. The condition is fulfilled when an activity instance created according to the related activity template is set to the state specified by this activity state template.

  • :previous_activity_state_template_uri (String, UU::OS::UESURI)

    URI of an activity state template. The condition that uses this parameter is fulfilled only when an activity instance created according to the related activity template was set to the state specified by this template right before it was set into the state specified in activity_state_template_uri. This state template must belong to the same activity template as activity_state_template_uri. This parameter can be used only when the user creates an activity state condition.

  • :expression (String)

    Not nil if the type is COMPOSED_CONDITION. Logical expression of the composed activity condition. Allowed logical characters are: conjunction (AND), disjunction (OR), negation (not) or round brackets. The expression must also contain identifiers (id parameters) of all conditions contained in condition_list. For example: "a AND (b OR not c)".

  • :condition_list (List<UU::OS::ActivityCondition::ActivityConditionCreate>)

    Not nil if the type is COMPOSED_CONDITION. Definition of conditions this composed condition consists of. Every composed condition must contain at least one condition in this list.

Returns:

  • (String)

    Identifier (condition_code) of the new activity condition.



108
109
110
111
112
113
114
115
116
# File 'uu_os-0.29.16/lib/uu/os/activity_condition.rb', line 108

def create(entity_uri, options)
  svc = UU::OS::REST::RemoteClient.new(ActivityCondition)
  payload = UU::OS::ActivityCondition::ActivityConditionCreate.new(options).to_json
  
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('create', entity_uri, payload)
    return res.tr('"', '')
  end
end

- (Object) delete(entity_uri, options)

Deletes the specified activity condition.

Examples:

# Delete an activity condition
UU::OS::ActivityCondition.delete('ues:TERRITORY:ARTIFACT:ENTITY',
   :condition_code => "CONDITION_CODE")

Parameters:

Options Hash (options):

  • :condition_code (String)

    Not nil. Identifier of the activity condition which is to be deleted.



128
129
130
131
132
133
134
# File 'uu_os-0.29.16/lib/uu/os/activity_condition.rb', line 128

def delete(entity_uri, options)
  svc = UU::OS::REST::RemoteClient.new(ActivityCondition)  
  payload = UU::OS::ActivityCondition::ActivityConditionGetAttributes.new(options).to_json        
  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('delete', entity_uri, payload)
  end
end

- (UU::OS::REST::ResultList<ActivityCondition::ActivityConditionGetActivityConditionList, ActivityCondition::ActivityConditionAttributes>) get_activity_condition_list(entity_uri, criteria = nil)

Returns a list of activity conditions for the specified entity. Activity template or activity instance can be entered as the mentioned entity. The list is sorted by the attribute condition_code of activity conditions by default.

Examples:

# Return list of conditions of an activity instance or template
UU::OS::ActivityCondition.get_activity_condition_list('ues:TERRITORY:ARTIFACT:ENTITY')

Parameters:

Returns:



147
148
149
150
151
152
153
154
155
156
157
# File 'uu_os-0.29.16/lib/uu/os/activity_condition.rb', line 147

def get_activity_condition_list(entity_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(ActivityCondition)
  dto = ActivityCondition::ActivityConditionGetActivityConditionList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)

  UU::OS::QoS::QoSHandler.auto_retry do
      res = svc.get('getActivityConditionList', entity_uri)
      return UU::OS::REST::ResultList.new(ActivityCondition::ActivityConditionGetActivityConditionList, ActivityCondition::ActivityConditionAttributes, res)
  end
end