Beispiel #1
0
        public override List <ProjectDescriptor> GetProjectDescriptions()
        {
            List <ProjectDescriptor> result = new List <ProjectDescriptor>();

            Task <ProjectSearchResponse> task = _jiraClient.GetJiraProjectsAsync();

            task.Wait();

            ProjectSearchResponse projectSearchResponse = task.Result;

            if (projectSearchResponse != null)
            {
                foreach (Project jiraProject in projectSearchResponse.Values)
                {
                    string projectID = JiraGuidConverter.ConvertToSpecIfGuid(jiraProject.Self, jiraProject.ID);

                    ProjectDescriptor projectDescriptor = new ProjectDescriptor
                    {
                        ID    = projectID,
                        Title = new List <MultilanguageText> {
                            new MultilanguageText(jiraProject.Name)
                        },
                        Generator        = _url,
                        GeneratorVersion = "Jira REST API 2",
                    };

                    result.Add(projectDescriptor);
                }
            }

            return(result);
        }
Beispiel #2
0
        public async Task <IActionResult> Search([FromQuery] ProjectSearchRequest model)
        {
            if (ModelState.IsValid)
            {
                InitUserCredentials();
                var results  = _mapper.Map(_projectService.Search(model, CompanyGuid), new List <ProjectResponse>());
                var response = new ProjectSearchResponse()
                {
                    Data = results
                };
                return(Ok(response));
            }

            return(new NoContentResult());
        }
Beispiel #3
0
        private void InitializeProjectInformations()
        {
            Debug.Write("Initializing Jira project informations...");

            _projectInformations = new Dictionary <string, Project>();

            Task <ProjectSearchResponse> projectsTask = _jiraClient.GetJiraProjectsAsync();

            projectsTask.Wait();

            ProjectSearchResponse projectSearchResponse = projectsTask.Result;

            if (projectSearchResponse != null)
            {
                foreach (Project project in projectSearchResponse.Values)
                {
                    Task <Project> projectTask = _jiraClient.GetJiraProjectByKeyAsync(project.Key);

                    projectTask.Wait();

                    Project projectInfo = projectTask.Result;

                    if (projectInfo != null)
                    {
                        string specIfProjectID = JiraGuidConverter.ConvertToSpecIfGuid(projectInfo.Self, projectInfo.ID);

                        _projectInformations.Add(specIfProjectID, projectInfo);
                    }
                }
            }

            _statusInformations = new List <Jira3.Status>();

            Task <List <Jira3.Status> > statusTask = _jiraClient.GetStatusesAsync();

            statusTask.Wait();

            if (statusTask.Result != null)
            {
                _statusInformations = statusTask.Result;
            }
        }
Beispiel #4
0
        private async Task <List <Node> > CreateProjectHierarchiesAsync(bool rootNodesOnly, string projectFilter = null)
        {
            List <Node> result = new List <Node>();

            try
            {
                ProjectRootResources = new List <Resource>();

                ProjectSearchResponse projectSearchResponse = await _jiraClient.GetJiraProjectsAsync();



                foreach (Project project in projectSearchResponse.Values)
                {
                    string projectID = JiraGuidConverter.ConvertToSpecIfGuid(project.Self, project.ID);


                    if (projectFilter == null || (projectFilter != null && projectID == projectFilter))
                    {
                        string projectResourceID = "_" + SpecIfGuidGenerator.CalculateSha1Hash(project.Key);

                        Key resourceClass = new Key("RC-Hierarchy", "1.1");

                        Resource projectHierarchyResource = SpecIfDataFactory.CreateResource(resourceClass, _metadataReader);

                        projectHierarchyResource.ID       = projectResourceID;
                        projectHierarchyResource.Revision = "1";

                        projectHierarchyResource.SetPropertyValue("dcterms:title", "Jira Project " + project.Key, _metadataReader);

                        projectHierarchyResource.SetPropertyValue("dcterms:description", project.Name, _metadataReader);


                        ProjectRootResources.Add(projectHierarchyResource);


                        Node projectNode = new Node
                        {
                            ID              = projectResourceID + "_Node",
                            Revision        = "1",
                            IsHierarchyRoot = true,
                            ProjectID       = project.Key,
                            ResourceObject  = new Key(projectHierarchyResource.ID, projectHierarchyResource.Revision)
                        };

                        result.Add(projectNode);

                        if (!rootNodesOnly)
                        {
                            IssueSearchResponse issueSearchResponse = await GetProjectIssuesAsync(project.Key);

                            if (issueSearchResponse != null)
                            {
                                foreach (Issue issue in issueSearchResponse.Issues)
                                {
                                    string issueResourceID = JiraGuidConverter.ConvertToSpecIfGuid(issue.Self, issue.ID);

                                    string issueRevision = SpecIfGuidGenerator.ConvertDateToRevision(issue.Fields.Updated.Value);

                                    Node requirementNode = new Node
                                    {
                                        ID              = issueResourceID + "_Node",
                                        Revision        = "1",
                                        IsHierarchyRoot = false,
                                        ProjectID       = project.Key,
                                        ResourceObject  = new Key(issueResourceID, issueRevision)
                                    };

                                    projectNode.Nodes.Add(requirementNode);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }

            return(result);
        }