Exemple #1
0
        public List <string> getFieldValues(string field, JiraIssue issue, object rawIssueObject)
        {
            string value = JiraIssueUtils.getRawIssueObjectPropertyValue <string>(rawIssueObject, "environment");

            return(value != null ? new List <string> {
                value
            } : null);
        }
        public List <string> getFieldValues(string field, JiraIssue issue, object rawIssueObject)
        {
            var issueToken = rawIssueObject as JToken;

            if (issueToken != null)
            {
                var value = JiraIssueUtils.getRawIssueObjectPropertyValue <object>(rawIssueObject, field);
                if (value == null || (value is JToken && !(value as JToken).HasValues))
                {
                    return(null);
                }
                var arr = value as JArray;
                return(arr != null?arr.Select(el => el.ToString()).ToList() : new List <string>
                {
                    value.ToString()
                });
            }

            var customFieldValues = JiraIssueUtils.getRawIssueObjectPropertyValueArray <object>(rawIssueObject, "customFieldValues");

            if (customFieldValues == null || customFieldValues.Length == 0)
            {
                return(null);
            }

            foreach (var customFieldValue in customFieldValues)
            {
                var property = customFieldValue.GetType().GetProperty("customfieldId");
                if (property == null)
                {
                    continue;
                }
                var fieldId = property.GetValue(customFieldValue, null) as string;
                if (fieldId == null || !fieldId.Equals(field))
                {
                    continue;
                }
                property = customFieldValue.GetType().GetProperty("values");
                if (property == null)
                {
                    continue;
                }
                var values = property.GetValue(customFieldValue, null) as object[];

                return((from val in values select val.ToString()).ToList());
            }
            return(null);
        }
Exemple #3
0
        public List <string> getFieldValues(string field, JiraIssue issue, object rawIssueObject)
        {
            DateTime?dueDate = JiraIssueUtils.getRawIssueObjectPropertyValue <DateTime?>(rawIssueObject, "duedate");

            if (!dueDate.HasValue)
            {
                return(new List <string>());
            }

            string        dateString = JiraIssueUtils.getShortDateStringFromDateTime(issue.ServerLanguage, dueDate.Value);
            List <string> result     = new List <string> {
                dateString
            };

            return(result);
        }
        private void createEditorWidget(IEnumerable <JiraNamedEntity> versions, IEnumerable <JiraNamedEntity> comps, object rawIssueObject)
        {
            PlvsLogger.log("FieldEditor.createEditorWidget()");

            switch (JiraActionFieldType.getFieldTypeForFieldId(fieldId))
            {
            case JiraActionFieldType.WidgetType.SUMMARY:
                editorProvider = new TextLineFieldEditorProvider(field, issue.Summary, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.DESCRIPTION:
                string descr = JiraIssueUtils.getRawIssueObjectPropertyValue <string>(rawIssueObject, "description") ?? "";
                editorProvider = new TextAreaFieldEditorProvider(facade, issue, field, descr, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.ENVIRONMENT:
                string env = JiraIssueUtils.getRawIssueObjectPropertyValue <string>(rawIssueObject, "environment") ?? "";
                editorProvider = new TextAreaFieldEditorProvider(facade, issue, field, env, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.VERSIONS:
                editorProvider = new NamedEntityListFieldEditorProvider(field, issue.Versions, versions, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.FIX_VERSIONS:
                editorProvider = new NamedEntityListFieldEditorProvider(field, issue.FixVersions, versions, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.ASSIGNEE:
                editorProvider = new UserFieldEditorProvider(issue.Server, field,
                                                             field.Values.IsNullOrEmpty() ? "" : field.Values[0], fieldValid, true);
                break;

            case JiraActionFieldType.WidgetType.COMPONENTS:
                editorProvider = new NamedEntityListFieldEditorProvider(field, issue.Components, comps, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.PRIORITY:
                editorProvider = new NamedEntityComboEditorProvider(issue.Server, field, issue.PriorityId,
                                                                    JiraServerCache.Instance.getPriorities(issue.Server),
                                                                    fieldValid);
                break;

            case JiraActionFieldType.WidgetType.TIMETRACKING:
                List <JiraField> fields = JiraActionFieldType.fillFieldValues(issue, rawIssueObject, new List <JiraField> {
                    field
                });
                editorProvider = new TimeTrackingEditorProvider(field, fields[0].Values[0], fieldValid);
                break;

            default:
                MessageBox.Show("Unsupported field type selected for editing",
                                Constants.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                break;
            }

            buttonCancel.Enabled = true;
            buttonOk.Enabled     = editorProvider != null ? editorProvider.FieldValid : false;
            if (editorProvider != null)
            {
                addEditorWidget(editorProvider);
            }
        }