JIRA-Client
view release on metacpan or search on metacpan
lib/JIRA/Client.pm view on Meta::CPAN
# converts the hash's key according with the %JRA12300 table. It goes
# a step further before invoking the methods UpdateIssue and
# progressWorkflowAction.
sub _flaten_components_and_versions {
my ($params) = @_;
# Flaten Component and Version fields
for my $field (grep {exists $params->{$_}} qw/components affectsVersions fixVersions/) {
$params->{$field} = [map {$_->{id}} @{$params->{$field}}];
}
# Flaten the customFieldValues field
if (my $custom_fields = delete $params->{custom_fields}) {
while (my ($id, $values) = each %$custom_fields) {
$params->{$id} = $values;
}
}
# Due to a bug in JIRA we have to substitute the names of some fields.
foreach my $field (grep {exists $params->{$_}} keys %JRA12300) {
$params->{$JRA12300{$field}} = delete $params->{$field};
}
return;
}
sub create_issue
{
my ($self, $params, $seclevel) = @_;
is_hash_ref($params) or croak "create_issue's requires a HASH-ref argument.\n";
for my $field (qw/project summary type/) {
croak "create_issue's HASH ref must define a '$field'.\n"
unless exists $params->{$field};
}
$params = $self->_convert_params($params, $params->{project});
# Substitute customFieldValues array for custom_fields hash
if (my $cfs = delete $params->{custom_fields}) {
$params->{customFieldValues} = [map {RemoteCustomFieldValue->new($_, $cfs->{$_})} keys %$cfs];
}
if (my $parent = delete $params->{parent}) {
if (defined $seclevel) {
return $self->createIssueWithParentWithSecurityLevel($params, $parent, _convert_security_level($self, $seclevel, $params->{project}));
} else {
return $self->createIssueWithParent($params, $parent);
}
} else {
if (defined $seclevel) {
return $self->createIssueWithSecurityLevel($params, _convert_security_level($self, $seclevel, $params->{project}));
} else {
return $self->createIssue($params);
}
}
}
sub update_issue
{
my ($self, $issue, $params) = @_;
my $key;
if (is_instance($issue => 'RemoteIssue')) {
$key = $issue->{key};
} else {
$key = $issue;
$issue = $self->getIssue($key);
}
is_hash_ref($params) or croak "update_issue second argument must be a HASH ref.\n";
my ($project) = ($key =~ /^([^-]+)/);
$params = $self->_convert_params($params, $project);
_flaten_components_and_versions($params);
return $self->updateIssue($key, $params);
}
sub get_issue_types {
my ($self) = @_;
$self->{cache}{issue_types} ||= {map {$_->{name} => $_} @{$self->getIssueTypes()}};
return $self->{cache}{issue_types};
}
sub get_subtask_issue_types {
my ($self) = @_;
$self->{cache}{subtask_issue_types} ||= {map {$_->{name} => $_} @{$self->getSubTaskIssueTypes()}};
return $self->{cache}{subtask_issue_types};
}
sub get_statuses {
my ($self) = @_;
$self->{cache}{statuses} ||= {map {$_->{name} => $_} @{$self->getStatuses()}};
return $self->{cache}{statuses};
}
sub get_priorities {
my ($self) = @_;
$self->{cache}{priorities} ||= {map {$_->{name} => $_} @{$self->getPriorities()}};
return $self->{cache}{priorities};
}
sub get_resolutions {
my ($self) = @_;
$self->{cache}{resolutions} ||= {map {$_->{name} => $_} @{$self->getResolutions()}};
return $self->{cache}{resolutions};
}
sub get_security_levels {
my ($self, $project_key) = @_;
$self->{cache}{seclevels}{$project_key} ||= {map {$_->{name} => $_} @{$self->getSecurityLevels($project_key)}};
( run in 0.527 second using v1.01-cache-2.11-cpan-bbe5e583499 )