JIRA-Client

 view release on metacpan or  search on metacpan

lib/JIRA/Client.pm  view on Meta::CPAN

        # space separated key list

        # Let's construct a JQL query in the form "issuekey IN (...)" to
        # pass to getIssuesFromJqlSearch.

        my %keys = map {($_ => undef)} split / /, $filter; # discard duplicates
        my @keys = keys %keys;

        # If the list is too big we split it up and invoke
        # getIssuesFromJqlSearch several times.
        my @issues;
        while (my @subkeys = splice(@keys, 0, 128)) {
            my $jql = 'issuekey IN (' . join(',', @subkeys) . ')';
            push @issues, @{$self->getIssuesFromJqlSearch($jql, 1000)};
        }
        return @issues;
    } elsif ($filter =~ /^[\w-]+$/i) {
        # saved filter
        return @{$self->getIssuesFromFilterWithLimit($filter, 0, $limit || 1000)};
    } else {
        # JQL filter
        return @{$self->getIssuesFromJqlSearch($filter, $limit || 1000)};
    }
}


sub filter_issues {
    my ($self, $filter, $limit) = @_;

    # Order the issues by project key and then by numeric value using
    # a Schwartzian transform.
    return
        map  {$_->[2]}
            sort {$a->[0] cmp $b->[0] or $a->[1] <=> $b->[1]}
                map  {my ($p, $n) = ($_->{key} =~ /([A-Z]+)-(\d+)/); [$p, $n, $_]}
                    filter_issues_unsorted($self, $filter, $limit);
}


## no critic (Modules::ProhibitMultiplePackages)

package RemoteFieldValue;
$RemoteFieldValue::VERSION = '0.45';
sub new {
    my ($class, $id, $values) = @_;

    # Due to a bug in JIRA we have to substitute the names of some fields.
    $id = $JRA12300{$id} if exists $JRA12300{$id};

    $values = [$values] unless ref $values;
    return bless({id => $id, values => $values}, $class);
}


package RemoteCustomFieldValue;
$RemoteCustomFieldValue::VERSION = '0.45';
sub new {
    my ($class, $id, $values) = @_;

    $values = [$values] unless ref $values;
    return bless({customfieldId => $id, key => undef, values => $values} => $class);
}


package RemoteComponent;
$RemoteComponent::VERSION = '0.45';
sub new {
    my ($class, $id, $name) = @_;
    my $o = bless({id => $id}, $class);
    $o->{name} = $name if $name;
    return $o;
}


package RemoteVersion;
$RemoteVersion::VERSION = '0.45';
sub new {
    my ($class, $id, $name) = @_;
    my $o = bless({id => $id}, $class);
    $o->{name} = $name if $name;
    return $o;
}

package JIRA::Client;

# Almost all of the JIRA API parameters are strings. The %typeof hash
# specifies the exceptions. It maps a method name to a hash mapping a
# parameter position to its type. (The parameter position is
# zero-based, after the authentication token.

my %typeof = (
    addActorsToProjectRole                   => {1 => \&_cast_remote_project_role},
    addAttachmentsToIssue              	     => \&_cast_attachments,
    addBase64EncodedAttachmentsToIssue 	     => \&_cast_base64encodedattachments,
    addComment                         	     => {0 => \&_cast_issue_key, 1 => \&_cast_remote_comment},
    addDefaultActorsToProjectRole            => {1 => \&_cast_remote_project_role},
    # addPermissionTo
    # addUserToGroup
    # addVersion
    addWorklogAndAutoAdjustRemainingEstimate => {0 => \&_cast_issue_key},
    addWorklogAndRetainRemainingEstimate     => {0 => \&_cast_issue_key},
    addWorklogWithNewRemainingEstimate       => {0 => \&_cast_issue_key},
    archiveVersion                     	     => {2 => 'boolean'},
    # createGroup
    # createIssue
    createIssueWithParent                    => {1 => \&_cast_issue_key},
    createIssueWithParentWithSecurityLevel   => {1 => \&_cast_issue_key, 2 => 'long'},
    createIssueWithSecurityLevel       	     => {1 => 'long'},
    # createPermissionScheme
    # createProject
    # createProjectFromObject
    createProjectRole                        => {0 => \&_cast_remote_project_role},
    # createUser
    # deleteGroup
    deleteIssue                 	     => {0 => \&_cast_issue_key},
    # deletePermissionFrom
    # deletePermissionScheme
    # deleteProject
    deleteProjectAvatar                	     => {0 => 'long'},
    deleteProjectRole                  	     => {0 => \&_cast_remote_project_role, 1 => 'boolean'},
    # deleteUser

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.531 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )