Class: IssueLink

Inherits:
Services show all
Defined in:
lib/jirarest2/services/issuelink.rb

Overview

This class is responsible for the Linking of Issues

No real getter as of yet (I just didn't need it)

Instance Method Summary collapse

Methods inherited from Services

#delete, #get, #post, #put

Constructor Details

#initialize(connection) ⇒ IssueLink

Returns a new instance of IssueLink.



28
29
30
31
32
# File 'lib/jirarest2/services/issuelink.rb', line 28

def initialize(connection)
  @uritail = "issueLink"
  super(connection)
  @linktype = IssueLinkType.new(@connection)
end

Instance Method Details

does the linking ig you don’t want to bother with the exact result

Parameters:

  • thisIssue (String, Issue)

    Issue to connect from

  • remoteIssue (String, Issue)

    Issue to connect to

  • type (String)

    Link type

  • comment (String) (defaults to: nil)

    If a comment should be set while linking

Returns:

  • (Boolean)

    Only true if successfully linked false if something happened. Elseway exactly as link_issue.



98
99
100
101
102
103
104
# File 'lib/jirarest2/services/issuelink.rb', line 98

def link(thisIssue,remoteIssue,type,comment = nil)
  if link_issue(thisIssue,remoteIssue,type,comment).code == "201" then
    return true
  else
    return false
  end
end

Links two issues Right now the visibility feature for comments is not supported

Parameters:

  • thisIssue (String, Issue)

    Issue to connect from

  • remoteIssue (String, Issue)

    Issue to connect to

  • type (String)

    Link type

  • comment (String) (defaults to: nil)

    If a comment should be set while linking

Returns:

Raises:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/jirarest2/services/issuelink.rb', line 63

def link_issue(thisIssue,remoteIssue,type,comment = nil)
  inwardIssue = key(thisIssue)
  outwardIssue = key(remoteIssue)
  
  # lets see if we have the right name
  if ! @linktype.internal_name?(type) then # time to find the correct name and see if we have to exchange tickets
    realname = @linktype.name(type)
    if realname.nil? then
      raise Jirarest2::ValueNotAllowedException.new(type,valid_issuelinktypes), type 
    else
      type = realname[0]
      if realname[1] == "inward" then # we have to change the issues as jira only knows one direction.
        temp = inwardIssue
        inwardIssue = outwardIssue
        outwardIssue = temp
      end
    end
  end # if ! linktype.internal_name?
  
  
  #create the hashes for JSON
  json = Hash.new
  json["type"] = { "name" => type }
  json["inwardIssue"] = { "key" => inwardIssue }
  json["outwardIssue"] = { "key" => outwardIssue }
  json["comment"] = { "body" => comment}     if comment
  return post(json)
end

#valid_issuelinktypes(delimiter = ", ") ⇒ Object

Show the possible answers for the issuelinktypes

Returns:

  • String



51
52
53
# File 'lib/jirarest2/services/issuelink.rb', line 51

def valid_issuelinktypes(delimiter = ", ")
  return @linktype.valid_names(delimiter)
end