public ExecuteCommandShowSummaryOfCohorts(IActivateItems activator, CohortSourceUsedByProjectNode projectSource) : base(activator) { _commandName = "Show Detailed Summary of Project Cohorts"; if (projectSource.IsEmptyNode) { SetImpossible("Node is empty"); } else { _onlyCohorts = projectSource.CohortsUsed.Select(u => u.ObjectBeingUsed).ToArray(); } }
private List <CohortSourceUsedByProjectNode> GetAllCohortProjectUsageNodesFor(Project project) { //if the current project does not have a number or there are no cohorts associated with it if (project.ProjectNumber == null || !ProjectNumberToCohortsDictionary.ContainsKey(project.ProjectNumber.Value)) { return(new List <CohortSourceUsedByProjectNode>()); } List <CohortSourceUsedByProjectNode> toReturn = new List <CohortSourceUsedByProjectNode>(); foreach (var cohort in ProjectNumberToCohortsDictionary[project.ProjectNumber.Value]) { //get the source of the cohort var source = CohortSources.Single(s => s.ID == cohort.ExternalCohortTable_ID); //numbers match var existing = toReturn.SingleOrDefault(s => s.ObjectBeingUsed.ID == cohort.ExternalCohortTable_ID); //make sure we have a record of the source if (existing == null) { existing = new CohortSourceUsedByProjectNode(project, source); toReturn.Add(existing); } //add the cohort to the list of known cohorts from this source (a project can have lots of cohorts and even cohorts from different sources) var cohortUsedByProject = new ObjectUsedByOtherObjectNode <CohortSourceUsedByProjectNode, ExtractableCohort>(existing, cohort); existing.CohortsUsed.Add(cohortUsedByProject); DuplicatesByCohortSourceUsedByProjectNode.Add(cohortUsedByProject); } DuplicatesByProject.AddRange(toReturn); //if the project has no cohorts then add a ??? node if (!toReturn.Any()) { toReturn.Add(new CohortSourceUsedByProjectNode(project, null)); } return(toReturn); }
private void AddChildren(CohortSourceUsedByProjectNode cohortSourceUsedByProjectNode, DescendancyList descendancy) { AddToDictionaries(new HashSet <object>(cohortSourceUsedByProjectNode.CohortsUsed), descendancy); }