Class: JIRA::Issue

Inherits:
DynamicEntity show all
Defined in:
lib/jiraSOAP/entities/issue.rb

Overview

TODO:

Add attributes for the comments and the attachment metadata

Note:

Issues with an UNRESOLVED status will have nil for the value for #resolution_id.

Contains most of the data and metadata for a JIRA issue, but does not contain the Comments or Attachments.

This class is easily the most convoluted structure in the API, and will likely be the greatest source of bugs. The irony of the situation is that this structure is also the most critical to have in working order.

Instance Method Summary collapse

Methods inherited from DynamicEntity

#id

Methods inherited from Entity

add_attribute, inherited, #initialize_with_xml, new_with_xml

Instance Method Details

#affects_versionsArray<JIRA::Version>

Returns:



63
# File 'lib/jiraSOAP/entities/issue.rb', line 63

add_attribute :affects_versions, 'affectsVersions', [:children_as_objects, JIRA::Version]

#assignee_usernameString

Returns:

  • (String)


30
# File 'lib/jiraSOAP/entities/issue.rb', line 30

add_attribute :assignee_username, 'assignee', :content

#attachment_namesArray<String>

Returns:



75
# File 'lib/jiraSOAP/entities/issue.rb', line 75

add_attribute :attachment_names, 'attachmentNames', :contents_of_children

#componentsArray<JIRA::Component>

Returns:



69
# File 'lib/jiraSOAP/entities/issue.rb', line 69

add_attribute :components, 'components', [:children_as_objects, JIRA::Component]

#create_timeTime

Returns:

  • (Time)


54
# File 'lib/jiraSOAP/entities/issue.rb', line 54

add_attribute :create_time, 'created', :to_iso_date

#custom_field(id) ⇒ JIRA::CustomFieldValue?

Get the value of a custom field given the custom field id, returns nil if the issue does not have a value for that field.

Parameters:

  • id (String)

    the custom field id (e.g. 'customfield_10150')

Returns:



83
84
85
# File 'lib/jiraSOAP/entities/issue.rb', line 83

def custom_field id
  custom_field_values.find { |field_value| field_value.id == id }
end

#custom_field_valuesArray<JIRA::CustomFieldValue>



72
# File 'lib/jiraSOAP/entities/issue.rb', line 72

add_attribute :custom_field_values, 'customFieldValues', [:children_as_objects, JIRA::CustomFieldValue]

#descriptionString

Returns:

  • (String)


21
# File 'lib/jiraSOAP/entities/issue.rb', line 21

add_attribute :description, 'description', :content

#due_dateTime

This is actually a Time object with no time resolution.

Returns:

  • (Time)


60
# File 'lib/jiraSOAP/entities/issue.rb', line 60

add_attribute :due_date, 'duedate', :to_iso_date

#environmentString

Returns:

  • (String)


45
# File 'lib/jiraSOAP/entities/issue.rb', line 45

add_attribute :environment, 'environment', :content

#fix_versionsArray<JIRA::Version>

Returns:



66
# File 'lib/jiraSOAP/entities/issue.rb', line 66

add_attribute :fix_versions, 'fixVersions', [:children_as_objects, JIRA::Version]

#keyString

Returns:

  • (String)


15
# File 'lib/jiraSOAP/entities/issue.rb', line 15

add_attribute :key, 'key', :content

#last_updated_timeTime

Returns:

  • (Time)


51
# File 'lib/jiraSOAP/entities/issue.rb', line 51

add_attribute :last_updated_time, 'updated', :to_iso_date

#priority_idString

Returns:

  • (String)


36
# File 'lib/jiraSOAP/entities/issue.rb', line 36

add_attribute :priority_id, 'priority', :content

#project_nameString

Returns:

  • (String)


39
# File 'lib/jiraSOAP/entities/issue.rb', line 39

add_attribute :project_name, 'project', :content

#reporter_usernameString

Returns:

  • (String)


33
# File 'lib/jiraSOAP/entities/issue.rb', line 33

add_attribute :reporter_username, 'reporter', :content

#resolution_idString

Returns:

  • (String)


42
# File 'lib/jiraSOAP/entities/issue.rb', line 42

add_attribute :resolution_id, 'resolution', :content

#soapify_for(msg) ⇒ Object

TODO:

see if we can use the simple and complex array builders

Generate the SOAP message fragment for an issue. Can you spot the oddities and inconsistencies? (hint: there are many).

We don't bother including fields that are ignored. I tried to only ignore fields that will never be needed at creation time, but I may have messed up.

We don't wrap the whole thing in 'issue' tags for JIRA::Issue#RemoteAPI#RemoteAPI#create_issue_with_issue calls; this is an inconsistency in the way jiraSOAP works and may need to be worked around for other RemoteAPI methods.

Servers only seem to accept issues if components/versions are just ids and do not contain the rest of the Component/Version structure.

To get the automatic assignee we pass '-1' as the value for @assignee.

Passing an environment/due date field with a value of nil causes the server to complain about the formatting of the message.

Parameters:



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/jiraSOAP/entities/issue.rb', line 112

def soapify_for msg
  msg.add 'priority', @priority_id
  msg.add 'type', @type_id
  msg.add 'project', @project_name

  msg.add 'summary', @summary
  msg.add 'description', @description

  msg.add 'components' do |submsg|
    (@components || []).each { |component|
      submsg.add 'components' do |component_msg|
        component_msg.add 'id', component.id
      end
    }
  end
  msg.add 'affectsVersions' do |submsg|
    (@affects_versions || []).each { |version|
      submsg.add 'affectsVersions' do |version_msg|
        version_msg.add 'id', version.id
      end
    }
  end
  msg.add 'fixVersions' do |submsg|
    (@fix_versions || []).each { |version|
      submsg.add 'fixVersions' do |version_msg|
        version_msg.add 'id', version.id end
    }
  end

  msg.add 'reporter', @reporter_username unless @reporter_username.nil?
  msg.add 'assignee', (@assignee_username || '-1')
  msg.add_complex_array 'customFieldValues', (@custom_field_values || [])

  msg.add 'environment', @environment unless @environment.nil?
  msg.add 'duedate', @due_date.xmlschema unless @due_date.nil?
end

#status_idString

Returns:

  • (String)


27
# File 'lib/jiraSOAP/entities/issue.rb', line 27

add_attribute :status_id, 'status', :content

#summaryString

Returns:

  • (String)


18
# File 'lib/jiraSOAP/entities/issue.rb', line 18

add_attribute :summary, 'summary', :content

#type_idString

Returns:

  • (String)


24
# File 'lib/jiraSOAP/entities/issue.rb', line 24

add_attribute :type_id, 'type', :content

#votesNumber

Returns:

  • (Number)


48
# File 'lib/jiraSOAP/entities/issue.rb', line 48

add_attribute :votes, 'votes', :to_i