private static Dictionary <string, EA.Element> ReadIssuesFromEA(EA.Repository Repository, EA.Collection EAElements) { Dictionary <string, EA.Element> result = new Dictionary <string, EA.Element>(); foreach (EA.Element EAIssue in EAElements) { if (EAGoatJira.IsElementJiraMetatype(EAIssue)) { result.Add(EAGoatJira.GetJiraKeyFromElement(Repository, EAIssue, EA.ObjectType.otElement), EAIssue); foreach (EA.Element EASubissue in EAIssue.Elements) { ///TODO: Zapřemýšlet, zda to nemůže vyhučet na tom, že v sobě bude mít issue, které se dostane i v původním resultu if (EAGoatJira.IsElementJiraMetatype(EASubissue)) { result.Add(EAGoatJira.GetJiraKeyFromElement(Repository, EASubissue, EA.ObjectType.otElement), EASubissue); } } } } return(result); }
/// <summary> /// Synchronization of an issue. /// </summary> /// <param name="Issue">Issue read from JIRA server that should be synchronized.</param> /// <param name="Repository">Sparx EA Repository.</param> /// <param name="Package">Packages that owns all issues that are not owned by any element withint this package.</param> /// <param name="Element">If it is not null then this element will be owner of the issue element instead of Package.</param> /// <param name="IssuesInEA">All issues that were within the packages just before the synchronization begins.</param> /// <returns>EA Element that represents synchronized issue.</returns> private static EA.Element SynchronizeItem(Atlassian.Jira.Issue Issue, EA.Repository Repository, EA.Package Package, EA.Element Element, Dictionary <string, EA.Element> IssuesInEA) { IssueOperation Operation; EA.Element EAElementForIssue; if (IssuesInEA.ContainsKey(Issue.Key.Value)) { //this issue is already saved in EA. Let's do something with it Operation = IssueOperation.Updated; EAElementForIssue = IssuesInEA[Issue.Key.Value]; Repository.WriteOutput(EAGoatJira.JiraOutputWindowName, $"Updating issue {Issue.Key.Value}", EAElementForIssue.ElementID); if (Element == null) { EAElementForIssue.PackageID = Package.PackageID; } else { EAElementForIssue.ParentID = Element.ElementID; } ///TODO: I should change the stereotype, if the type of issue has been chaged. /// On the other hand, some configuration of JIRA doesn't allow these changes to ordinary users. ///EAElementForIssue.Type = GetMetaclassFromIssueType(Issue); IssuesInEA.Remove(Issue.Key.Value); } else { //this issue is not in EA so far, let's create a new one EA.Element Operation = IssueOperation.Inserted; if (Element == null) { EAElementForIssue = Package.Elements.AddNew(GetEAJiraIssueName(Issue), EAGoatJira.GetMetaclassFromIssueType(Issue)); } else { EAElementForIssue = Element.Elements.AddNew(GetEAJiraIssueName(Issue), EAGoatJira.GetMetaclassFromIssueType(Issue)); } Repository.WriteOutput(EAGoatJira.JiraOutputWindowName, $"Inserting issue {Issue.Key.Value}", EAElementForIssue.ElementID); } FillIssue(EAElementForIssue, new JiraIssueViewModel(new AtlassianJiraIssueModelService(Issue), null), Operation); EAElementForIssue.Update(); return(EAElementForIssue); }