Exemplo n.º 1
0
 /// <summary>
 ///     Extracts a value from <see cref="Atlassian.Jira.CustomFieldValueCollection"/> given a field code
 /// </summary>
 /// <param name="fields">An <see cref="Atlassian.Jira.CustomFieldValueCollection"/> to process</param>
 /// <param name="fieldCode">The field identifier to process for</param>
 /// <returns>An extracted value or an empty string is nothing is found</returns>
 private static string Get(this Atlassian.Jira.CustomFieldValueCollection fields, string fieldCode)
 {
     try
     {
         return(string.Join(CoreConstants.CommaSeparator,
                            fields[fieldCode] == null ? Enumerable.Empty <string>() : fields[fieldCode].Values));
     }
     catch
     {
         return(string.Empty);
     }
 }
Exemplo n.º 2
0
        private void Initialize(RemoteIssue remoteIssue)
        {
            _originalIssue = remoteIssue;

            _project        = remoteIssue.project;
            _key            = remoteIssue.key;
            _createDate     = remoteIssue.created;
            _dueDate        = remoteIssue.duedate;
            _updateDate     = remoteIssue.updated;
            _resolutionDate = remoteIssue.resolutionDateReadOnly;

            Assignee    = remoteIssue.assignee;
            Description = remoteIssue.description;
            Environment = remoteIssue.environment;
            Reporter    = remoteIssue.reporter;
            Summary     = remoteIssue.summary;
            Votes       = remoteIssue.votes;

            if (!String.IsNullOrEmpty(remoteIssue.parentKey))
            {
                _parentIssueKey = remoteIssue.parentKey;
            }

            // named entities
            _status    = String.IsNullOrEmpty(remoteIssue.status) ? null : new IssueStatus(_jira, remoteIssue.status);
            Priority   = String.IsNullOrEmpty(remoteIssue.priority) ? null : new IssuePriority(_jira, remoteIssue.priority);
            Resolution = String.IsNullOrEmpty(remoteIssue.resolution) ? null : new IssueResolution(_jira, remoteIssue.resolution);
            Type       = String.IsNullOrEmpty(remoteIssue.type) ? null : new IssueType(_jira, remoteIssue.type);

            // collections
            _affectsVersions = _originalIssue.affectsVersions == null ? new ProjectVersionCollection("versions", _jira, Project)
                : new ProjectVersionCollection("versions", _jira, Project, _originalIssue.affectsVersions.Select(v => new ProjectVersion(v)).ToList());

            _fixVersions = _originalIssue.fixVersions == null ? new ProjectVersionCollection("fixVersions", _jira, Project)
                : new ProjectVersionCollection("fixVersions", _jira, Project, _originalIssue.fixVersions.Select(v => new ProjectVersion(v)).ToList());

            _components = _originalIssue.components == null ? new ProjectComponentCollection("components", _jira, Project)
                : new ProjectComponentCollection("components", _jira, Project, _originalIssue.components.Select(c => new ProjectComponent(c)).ToList());

            _customFields = _originalIssue.customFieldValues == null ? new CustomFieldValueCollection(this)
                : new CustomFieldValueCollection(this, _originalIssue.customFieldValues.Select(f => new CustomFieldValue(f.customfieldId, this)
            {
                Values = f.values
            }).ToList());
        }
Exemplo n.º 3
0
        private void Initialize(RemoteIssue remoteIssue)
        {
            _originalIssue = remoteIssue;

            _project        = remoteIssue.project;
            _key            = remoteIssue.key;
            _createDate     = remoteIssue.created;
            _dueDate        = remoteIssue.duedate;
            _updateDate     = remoteIssue.updated;
            _resolutionDate = remoteIssue.resolutionDateReadOnly;
            _securityLevel  = remoteIssue.securityLevelReadOnly;

            Assignee     = remoteIssue.assignee;
            Description  = remoteIssue.description;
            Environment  = remoteIssue.environment;
            Reporter     = remoteIssue.reporter;
            Summary      = remoteIssue.summary;
            Votes        = remoteIssue.votesData?.votes;
            HasUserVoted = remoteIssue.votesData != null ? remoteIssue.votesData.hasVoted : false;

            if (!String.IsNullOrEmpty(remoteIssue.parentKey))
            {
                _parentIssueKey = remoteIssue.parentKey;
            }

            // named entities
            _status    = remoteIssue.status == null ? null : new IssueStatus(remoteIssue.status);
            Priority   = remoteIssue.priority == null ? null : new IssuePriority(remoteIssue.priority);
            Resolution = remoteIssue.resolution == null ? null : new IssueResolution(remoteIssue.resolution);
            Type       = remoteIssue.type == null ? null : new IssueType(remoteIssue.type);

            // collections
            _customFields = _originalIssue.customFieldValues == null ? new CustomFieldValueCollection(this)
                : new CustomFieldValueCollection(this, _originalIssue.customFieldValues.Select(f => new CustomFieldValue(f.customfieldId, this)
            {
                Values = f.values
            }).ToList());

            var affectsVersions = _originalIssue.affectsVersions ?? Enumerable.Empty <RemoteVersion>();

            _affectsVersions = new ProjectVersionCollection("versions", _jira, Project, affectsVersions.Select(v =>
            {
                v.ProjectKey = _originalIssue.project;
                return(new ProjectVersion(_jira, v));
            }).ToList());

            var fixVersions = _originalIssue.fixVersions ?? Enumerable.Empty <RemoteVersion>();

            _fixVersions = new ProjectVersionCollection("fixVersions", _jira, Project, fixVersions.Select(v =>
            {
                v.ProjectKey = _originalIssue.project;
                return(new ProjectVersion(_jira, v));
            }).ToList());

            var labels = _originalIssue.labels ?? new string[0];

            _labels = new IssueLabelCollection(labels.ToList());

            var components = _originalIssue.components ?? Enumerable.Empty <RemoteComponent>();

            _components = new ProjectComponentCollection("components", _jira, Project, components.Select(c =>
            {
                c.ProjectKey = _originalIssue.project;
                return(new ProjectComponent(c));
            }).ToList());
        }