コード例 #1
0
        public override Resource SaveResource(Resource resource, string projectID = null)
        {
            Resource result = null;

            if (projectID != null)
            {
                if (_dataReader is SpecIfJiraDataReader)
                {
                    SpecIfJiraDataReader dataReader = _dataReader as SpecIfJiraDataReader;

                    Project jiraProject = dataReader.GetJiraProjectInfo(projectID);

                    string jiraTypeID = GetJiraTypeFromSpecIfResource(resource, projectID);

                    if (jiraProject != null && jiraTypeID != null)
                    {
                        string title = resource.GetPropertyValue("dcterms:title", _metadataReader);

                        string description = resource.GetPropertyValue("dcterms:description", _metadataReader);

                        SpecIfToJiraConverter specIfToJiraConverter = new SpecIfToJiraConverter();

                        Issue newIssue = new Issue
                        {
                            Fields = new Fields
                            {
                                Project = new Project
                                {
                                    ID = jiraProject.ID
                                },
                                Summary     = title,
                                Description = specIfToJiraConverter.ConvertDescription(description),
                                IssueType   = new IssueType
                                {
                                    ID = jiraTypeID
                                }
                            }
                        };

                        Task <Issue> issueCreateTask = _jiraClient.CreateJiraIssueAsync(newIssue);

                        issueCreateTask.Wait();

                        Issue newJiraResultIssue = issueCreateTask.Result;

                        if (newJiraResultIssue != null)
                        {
                            string newIssueGuid = JiraGuidConverter.ConvertToSpecIfGuid(newJiraResultIssue.Self, newJiraResultIssue.ID);

                            result = _dataReader.GetResourceByKey(new Key(newIssueGuid));
                        }
                    }
                }
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="classKey"></param>
        /// <param name="projectID">SpecIF project ID.</param>
        /// <returns></returns>
        private string GetJiraTypeFromSpecIfResource(Resource resource, string projectID)
        {
            string result = null;

            if (_dataReader is SpecIfJiraDataReader)
            {
                SpecIfJiraDataReader dataReader = _dataReader as SpecIfJiraDataReader;

                Project jiraProject = dataReader.GetJiraProjectInfo(projectID);

                if (jiraProject != null)
                {
                    if (resource.Class.ID == "RC-Requirement")
                    {
                        string perspecitve = resource.GetPropertyValue("SpecIF:Perspective", _metadataReader);

                        IssueType requirementIssueType;

                        if (!string.IsNullOrEmpty(perspecitve) && perspecitve == "V-perspective-1") // user
                        {
                            requirementIssueType = jiraProject.IssueTypes.Find(issueType => issueType.Name == "Customer Requirement");
                        }
                        else
                        {
                            requirementIssueType = jiraProject.IssueTypes.Find(issueType => issueType.Name == "Requirement");
                        }

                        if (requirementIssueType != null)
                        {
                            result = requirementIssueType.ID;
                        }
                    }
                }
            }

            return(result);
        }