public CohortIdentificationConfigurationMenu(RDMPContextMenuStripArgs args, ProjectCohortIdentificationConfigurationAssociation association) : this(args, association.CohortIdentificationConfiguration) { _executeAndImportCommand.SetTarget((DatabaseEntity)association.Project); _executeCommandClone.SetTarget((DatabaseEntity)association.Project); }
public override void Execute() { if (_project == null) { //project is not known so get all projects var valid = Activator.RepositoryLocator.DataExportRepository.GetAllObjects <Project>(); //except if the cic is the launch point if (_cic != null) { valid = valid.Where(v => //in which case only add projects which are not already associated with the cic launch point !_existingAssociations.Any( a => a.CohortIdentificationConfiguration_ID == _cic.ID && v.ID == a.Project_ID)).ToArray(); } Project p; if (SelectOne(valid, out p)) { SetTarget(p); } else { return; } } if (_cic == null) { //cic is not known (but project is thanks to above block) var valid = Activator.RepositoryLocator.CatalogueRepository.GetAllObjects <CohortIdentificationConfiguration>(); //allow them to select any cic where it does not already belong to the project valid = valid.Where(v => !_existingAssociations.Any( a => a.Project_ID == _project.ID && v.ID == a.CohortIdentificationConfiguration_ID)).ToArray(); CohortIdentificationConfiguration cic; if (SelectOne(valid, out cic)) { SetTarget(cic); } else { return; } } //command might be impossible base.Execute(); var assoc = new ProjectCohortIdentificationConfigurationAssociation(Activator.RepositoryLocator.DataExportRepository, _project, _cic); Publish(_project); Publish(_cic); Emphasise(_cic); }