• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 13159438705

05 Feb 2025 02:20PM UTC coverage: 57.451% (+0.01%) from 57.437%
13159438705

Pull #2125

github

JFriel
tidy up
Pull Request #2125: Task/rdmp 265 version data loads

11330 of 21275 branches covered (53.25%)

Branch coverage included in aggregate %.

966 of 1168 new or added lines in 8 files covered. (82.71%)

3 existing lines in 3 files now uncovered.

32228 of 54543 relevant lines covered (59.09%)

17081.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

16.52
/Rdmp.Core/CommandExecution/AtomicCommandFactory.cs
1
// Copyright (c) The University of Dundee 2018-2024
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System;
8
using System.Collections;
9
using System.Collections.Generic;
10
using System.Linq;
11
using FAnsi;
12
using Rdmp.Core.CommandExecution.AtomicCommands;
13
using Rdmp.Core.CommandExecution.AtomicCommands.Alter;
14
using Rdmp.Core.CommandExecution.AtomicCommands.CatalogueCreationCommands;
15
using Rdmp.Core.CommandExecution.AtomicCommands.CohortCreationCommands;
16
using Rdmp.Core.CommandExecution.AtomicCommands.Sharing;
17
using Rdmp.Core.Curation.Data;
18
using Rdmp.Core.Curation.Data.Aggregation;
19
using Rdmp.Core.Curation.Data.Cache;
20
using Rdmp.Core.Curation.Data.Cohort;
21
using Rdmp.Core.Curation.Data.DataLoad;
22
using Rdmp.Core.Curation.Data.Defaults;
23
using Rdmp.Core.Curation.Data.Pipelines;
24
using Rdmp.Core.Curation.Data.Referencing;
25
using Rdmp.Core.Curation.FilterImporting.Construction;
26
using Rdmp.Core.Databases;
27
using Rdmp.Core.DataExport.Data;
28
using Rdmp.Core.DataViewing;
29
using Rdmp.Core.Icons.IconProvision;
30
using Rdmp.Core.Logging;
31
using Rdmp.Core.MapsDirectlyToDatabaseTable;
32
using Rdmp.Core.MapsDirectlyToDatabaseTable.Versioning;
33
using Rdmp.Core.Providers.Nodes;
34
using Rdmp.Core.Providers.Nodes.CohortNodes;
35
using Rdmp.Core.Providers.Nodes.LoadMetadataNodes;
36
using Rdmp.Core.Providers.Nodes.PipelineNodes;
37
using Rdmp.Core.Providers.Nodes.ProjectCohortNodes;
38
using Rdmp.Core.Providers.Nodes.SharingNodes;
39
using Rdmp.Core.Providers.Nodes.UsedByProject;
40
using Rdmp.Core.ReusableLibraryCode.Checks;
41
using Rdmp.Core.ReusableLibraryCode.DataAccess;
42
using SixLabors.ImageSharp;
43
using SixLabors.ImageSharp.PixelFormats;
44

45
namespace Rdmp.Core.CommandExecution;
46

47
/// <summary>
48
/// Builds lists of <see cref="IAtomicCommand"/> for any given RDMP object
49
/// </summary>
50
public class AtomicCommandFactory : CommandFactoryBase
51
{
52
    private readonly IBasicActivateItems _activator;
53
    private readonly GoToCommandFactory _goto;
54
    public const string Add = "Add";
55
    public const string Batching = "Batching";
56
    public const string New = "New";
57
    public const string GoTo = "Go To";
58
    public const string Extraction = "Extractability";
59
    public const string Metadata = "Metadata";
60
    public const string Alter = "Alter";
61
    public const string SetUsageContext = "Set Context";
62
    public const string SetContainerOperation = "Set Operation";
63
    public const string Dimensions = "Dimensions";
64
    public const string Advanced = "Advanced";
65
    public const string View = "View";
66
    public const string Deprecation = "Deprecation";
67
    public const string ViewParentTree = "View Parent Tree";
68

69
    public AtomicCommandFactory(IBasicActivateItems activator)
6✔
70
    {
71
        _activator = activator;
6✔
72
        _goto = new GoToCommandFactory(_activator);
6✔
73
    }
6✔
74

75
    /// <summary>
76
    /// Returns all commands that could be run involving <paramref name="o"/> in order of most useful to least useful
77
    /// </summary>
78
    /// <param name="o"></param>
79
    /// <returns></returns>
80
    public IEnumerable<IAtomicCommand> CreateCommands(object o)
81
    {
82
        foreach (var cmd in _goto.GetCommands(o))
12!
83
        {
84
            cmd.SuggestedCategory = GoTo;
×
85
            yield return cmd;
×
86
        }
87

88
        if (_activator.CanActivate(o))
6!
89
            yield return new ExecuteCommandActivate(_activator, o);
×
90

91
        if (Is(o, out ILoggedActivityRootObject root)) yield return new ExecuteCommandViewLogs(_activator, root);
6!
92

93
        if (Is(o, out IArgument a))
6!
94
            if (!_activator.IsWinForms)
×
95
                yield return new ExecuteCommandSetArgument(_activator, a);
×
96
        if (Is(o, out Catalogue c))
6!
97
        {
98
            var isApiCall = c.IsApiCall();
×
99

100
            if (!isApiCall)
×
101
            {
102
                yield return new ExecuteCommandViewData(_activator, c, ViewType.TOP_100)
×
103
                {
×
104
                    Weight = -99.2f,
×
105
                    OverrideCommandName = "Catalogue SQL/Data",
×
106
                    SuggestedCategory = View
×
107
                };
×
108
                yield return new ExecuteCommandAddNewCatalogueItem(_activator, c)
×
109
                { Weight = -99.9f, SuggestedCategory = Add, OverrideCommandName = "New Catalogue Item" };
×
110
                yield return new ExecuteCommandAddNewAggregateGraph(_activator, c)
×
111
                {
×
112
                    Weight = -98.9f,
×
113
                    SuggestedCategory = Add,
×
114
                    OverrideCommandName = "New Aggregate Graph"
×
115
                };
×
116
            }
117

118
            yield return new ExecuteCommandAddNewSupportingSqlTable(_activator, c)
×
119
            {
×
120
                Weight = -87.9f,
×
121
                SuggestedCategory = Add,
×
122
                OverrideCommandName = "New Supporting SQL Table"
×
123
            };
×
124
            yield return new ExecuteCommandAddNewSupportingDocument(_activator, c)
×
125
            {
×
126
                Weight = -87.8f,
×
127
                SuggestedCategory = Add,
×
128
                OverrideCommandName = "New Supporting Document"
×
129
            };
×
130
            if (!isApiCall)
×
131
            {
132
                yield return new ExecuteCommandChangeExtractability(_activator, c)
×
133
                {
×
134
                    Weight = -99.0010f,
×
135
                    SuggestedCategory = Extraction
×
136
                };
×
137

138
                yield return c.IsProjectSpecific(_activator.RepositoryLocator.DataExportRepository)
×
139
                    ? new ExecuteCommandMakeProjectSpecificCatalogueNormalAgain(_activator, c)
×
140
                    {
×
141
                        Weight = -99.0009f,
×
142
                        SuggestedCategory = Extraction
×
143
                    }
×
144
                    : new ExecuteCommandMakeCatalogueProjectSpecific(_activator, c, null)
×
145
                    {
×
146
                        Weight = -99.0009f,
×
147
                        SuggestedCategory = Extraction
×
148
                    };
×
149

150
                yield return new ExecuteCommandSetExtractionIdentifier(_activator, c, null, null)
×
151
                {
×
152
                    Weight = -99.0008f,
×
153
                    SuggestedCategory = Extraction
×
154
                };
×
155

156
                yield return new ExecuteCommandSetExtractionPrimaryKeys(_activator, c, null, null)
×
157
                {
×
158
                    Weight = -99.0007f,
×
159
                    SuggestedCategory = Extraction
×
160
                };
×
161
            }
162

163
            yield return new ExecuteCommandExportObjectsToFile(_activator, new[] { c })
×
164
            {
×
165
                Weight = -95.10f,
×
166
                SuggestedCategory = Metadata
×
167
            };
×
168
            yield return new ExecuteCommandExtractMetadata(_activator, new[] { c }, null, null, null, false, null)
×
169
            {
×
170
                OverrideCommandName = "Generate Metadata Report (with custom template)",
×
171
                Weight = -99.058f,
×
172
                SuggestedCategory = Metadata
×
173
            };
×
174
        }
175

176
        if (Is(o, out IHasFolder folderable))
6!
177
            yield return new ExecuteCommandPutIntoFolder(_activator, new[] { folderable }, null);
×
178

179
        if (Is(o, out FolderNode<Catalogue> cf))
6!
180
        {
181
            yield return new ExecuteCommandCreateNewCatalogueByImportingFile(_activator)
×
182
            {
×
183
                OverrideCommandName = "New Catalogue From File...",
×
184
                TargetFolder = cf.FullName,
×
185
                SuggestedCategory = Add,
×
186
                Weight = -90.9f
×
187
            };
×
188
            yield return new ExecuteCommandCreateNewCatalogueByImportingExistingDataTable(_activator)
×
189
            {
×
190
                OverrideCommandName = "New Catalogue From Database...",
×
191
                TargetFolder = cf.FullName,
×
192
                SuggestedCategory = Add,
×
193
                Weight = -90.8f
×
194
            };
×
195
            yield return new ExecuteCommandCreateNewEmptyCatalogue(_activator)
×
196
            {
×
197
                OverrideCommandName = "New Empty Catalogue (Advanced)",
×
198
                TargetFolder = cf.FullName,
×
199
                SuggestedCategory = Add,
×
200
                Weight = -90.7f
×
201
            };
×
202
        }
203

204
        if (Is(o, out ExtractionInformation ei))
6!
205
        {
206
            yield return new ExecuteCommandCreateNewFilter(_activator, new ExtractionFilterFactory(ei))
×
207
            { OverrideCommandName = "Add New Filter" };
×
208
            yield return new ExecuteCommandCreateNewCohortFromCatalogue(_activator, ei);
×
209
            yield return new ExecuteCommandChangeExtractionCategory(_activator, new[] { ei });
×
210

211
            yield return new ExecuteCommandViewData(_activator, ViewType.TOP_100, ei) { SuggestedCategory = View };
×
212
            yield return new ExecuteCommandViewData(_activator, ViewType.Aggregate, ei) { SuggestedCategory = View };
×
213
            yield return new ExecuteCommandViewData(_activator, ViewType.Distribution, ei) { SuggestedCategory = View };
×
214
        }
215

216
        if (Is(o, out ExtractionFilter cataFilter))
6!
217
            yield return new ExecuteCommandAddNewExtractionFilterParameterSet(_activator, cataFilter);
×
218

219
        if (Is(o, out ExtractionFilterParameterSet efps))
6!
220
            yield return new ExecuteCommandAddMissingParameters(_activator, efps);
×
221

222
        if (Is(o, out ISqlParameter p) && p is IMapsDirectlyToDatabaseTable m)
6!
223
        {
224
            yield return new ExecuteCommandSet(_activator, m, p.GetType().GetProperty(nameof(ISqlParameter.Value)));
×
225

226
            if (p is not ExtractionFilterParameterSetValue)
×
227
                yield return new ExecuteCommandSet(_activator, m,
×
228
                    p.GetType().GetProperty(nameof(ISqlParameter.ParameterSQL)));
×
229
        }
230

231
        if (Is(o, out CatalogueItem ci))
6!
232
        {
233
            yield return new ExecuteCommandCreateNewFilter(_activator, ci) { OverrideCommandName = "Add New Filter" };
×
234
            yield return new ExecuteCommandLinkCatalogueItemToColumnInfo(_activator, ci);
×
235
            yield return new ExecuteCommandMakeCatalogueItemExtractable(_activator, ci);
×
236
            yield return new ExecuteCommandChangeExtractionCategory(_activator, new[] { ci.ExtractionInformation });
×
237
            yield return new ExecuteCommandImportCatalogueItemDescription(_activator, ci)
×
238
            { SuggestedShortcut = "I", Ctrl = true };
×
239
            var ciExtractionInfo = ci.ExtractionInformation;
×
240
            if (ciExtractionInfo != null)
×
241
            {
242
                yield return new ExecuteCommandViewData(_activator, ViewType.TOP_100, ciExtractionInfo)
×
243
                { SuggestedCategory = View };
×
244
                yield return new ExecuteCommandViewData(_activator, ViewType.Aggregate, ciExtractionInfo)
×
245
                { SuggestedCategory = View };
×
246
                yield return new ExecuteCommandViewData(_activator, ViewType.Distribution, ciExtractionInfo)
×
247
                { SuggestedCategory = View };
×
248
            }
249
        }
×
250

251
        if (Is(o, out SupportingSQLTable sqlTable))
6!
252
            yield return new ExecuteCommandRunSupportingSql(_activator, sqlTable, null);
×
253

254
        if (Is(o, out AggregateConfiguration ac) && !ac.Catalogue.IsApiCall())
6!
255
        {
256
            yield return new ExecuteCommandSet(_activator, ac,
×
257
                typeof(AggregateConfiguration).GetProperty(nameof(AggregateConfiguration.Description)));
×
258

259
            yield return new ExecuteCommandCreateNewFilter(_activator, ac)
×
260
            { SuggestedCategory = Add, OverrideCommandName = "New Filter" };
×
261
            yield return new ExecuteCommandCreateNewFilter(_activator, ac)
×
262
            {
×
263
                OfferCatalogueFilters = true,
×
264
                SuggestedCategory = Add,
×
265
                OverrideCommandName = "Existing Filter"
×
266
            };
×
267

268
            yield return new ExecuteCommandAddNewFilterContainer(_activator, ac)
×
269
            { SuggestedCategory = Add, OverrideCommandName = "New Filter Container" };
×
270
            yield return new ExecuteCommandImportFilterContainerTree(_activator, ac)
×
271
            { SuggestedCategory = Add, OverrideCommandName = "Existing Filter Container (copy of)" };
×
272

273
            yield return new ExecuteCommandAddParameter(_activator, ac, null, null, null)
×
274
            { SuggestedCategory = Add, OverrideCommandName = "New Catalogue Filter Parameter" };
×
275

276
            yield return new ExecuteCommandViewData(_activator, ac) { OverrideCommandName = "View Sample SQL/Data" };
×
277

278
            if (ac.IsCohortIdentificationAggregate)
×
279
            {
280
                yield return new ExecuteCommandSetAggregateDimension(_activator, ac);
×
281

282
                yield return _activator.RepositoryLocator.CatalogueRepository
×
283
                    .GetExtendedProperties(ExtendedProperty.IsTemplate, ac)
×
284
                    .Any(v => v.Value.Equals("true"))
×
285
                    ? new ExecuteCommandSetExtendedProperty(_activator, new[] { ac }, ExtendedProperty.IsTemplate, null)
×
286
                    {
×
287
                        OverrideCommandName = "Make Non Template"
×
288
                    }
×
289
                    : (IAtomicCommand)new ExecuteCommandSetExtendedProperty(_activator, new[] { ac },
×
290
                        ExtendedProperty.IsTemplate, "true")
×
291
                    {
×
292
                        OverrideCommandName = "Make Reusable Template"
×
293
                    };
×
294
            }
295

296
            // graph options
297
            yield return new ExecuteCommandAddDimension(_activator, ac) { SuggestedCategory = Dimensions };
×
298
            yield return new ExecuteCommandSetPivot(_activator, ac) { SuggestedCategory = Dimensions };
×
299
            yield return new ExecuteCommandSetPivot(_activator, ac, null)
×
300
            { OverrideCommandName = "Clear Pivot", SuggestedCategory = Dimensions };
×
301
            yield return new ExecuteCommandSetAxis(_activator, ac) { SuggestedCategory = Dimensions };
×
302
            yield return new ExecuteCommandSetAxis(_activator, ac, null)
×
303
            { OverrideCommandName = "Clear Axis", SuggestedCategory = Dimensions };
×
304

305

306
            /*if(ac.OverrideFiltersByUsingParentAggregateConfigurationInstead_ID != null)
307
            {
308
                yield return new ExecuteCommandSetFilterTreeShortcut(_activator, ac, null) { OverrideCommandName = "Clear Filter Tree Shortcut" };
309
            }
310
            else
311
            {
312
                yield return new ExecuteCommandSetFilterTreeShortcut(_activator, ac);
313
            }*/
314

315
            //only allow them to execute graph if it is normal aggregate graph
316
            if (!ac.IsCohortIdentificationAggregate)
×
317
                yield return new ExecuteCommandExecuteAggregateGraph(_activator, ac);
×
318

319
            //yield return new ExecuteCommandCreateNewCatalogueByExecutingAnAggregateConfiguration(_activator,ac);
320
        }
321

322
        if (Is(o, out IContainer container))
6!
323
        {
324
            var targetOperation = container.Operation == FilterContainerOperation.AND ? "OR" : "AND";
×
325
            yield return new ExecuteCommandSet(_activator, container, nameof(IContainer.Operation), targetOperation)
×
326
            { OverrideCommandName = $"Set Operation to {targetOperation}" };
×
327

328
            yield return new ExecuteCommandCreateNewFilter(_activator, container.GetFilterFactory(), container)
×
329
            { SuggestedCategory = Add, OverrideCommandName = "New Filter" };
×
330
            yield return new ExecuteCommandCreateNewFilter(_activator, container, null)
×
331
            {
×
332
                OfferCatalogueFilters = true,
×
333
                SuggestedCategory = Add,
×
334
                OverrideCommandName = "Existing Filter"
×
335
            };
×
336
            yield return new ExecuteCommandAddNewFilterContainer(_activator, container)
×
337
            { SuggestedCategory = Add, OverrideCommandName = "Sub Container" };
×
338

339
            yield return new ExecuteCommandViewFilterMatchData(_activator, container, ViewType.TOP_100);
×
340
            yield return new ExecuteCommandViewFilterMatchData(_activator, container, ViewType.Aggregate);
×
341
        }
342

343
        if (Is(o, out AggregatesNode an))
6!
344
            yield return new ExecuteCommandAddNewAggregateGraph(_activator, an.Catalogue);
×
345

346
        if (Is(o, out AllANOTablesNode _))
6!
347
        {
348
            yield return new ExecuteCommandCreateNewANOTable(_activator);
×
349

350
            yield return new ExecuteCommandCreateNewExternalDatabaseServer(_activator,
×
351
                    new ANOStorePatcher(), PermissableDefaults.ANOStore)
×
352
            { OverrideCommandName = "Create ANOStore Database" };
×
353

354
            yield return new ExecuteCommandExportObjectsToFile(_activator, _activator.CoreChildProvider.AllANOTables);
×
355
        }
356

357
        if (Is(o, out AllCataloguesUsedByLoadMetadataNode aculmd))
6!
358
            yield return new ExecuteCommandAssociateCatalogueWithLoadMetadata(_activator, aculmd.LoadMetadata);
×
359

360
        if (Is(o, out AllDataAccessCredentialsNode _))
6!
361
            yield return new ExecuteCommandNewObject(_activator,
×
362
                () => new DataAccessCredentials(_activator.RepositoryLocator.CatalogueRepository,
×
363
                    $"New Blank Credentials {Guid.NewGuid()}"))
×
364
            {
×
365
                OverrideCommandName = "Add New Credentials"
×
366
            };
×
367

368
        if (Is(o, out DataAccessCredentialUsageNode usage))
6!
369
        {
370
            var existingUsages =
×
371
                _activator.RepositoryLocator.CatalogueRepository.TableInfoCredentialsManager.GetCredentialsIfExistsFor(
×
372
                    usage.TableInfo);
×
373

374
            foreach (DataAccessContext context in Enum.GetValues(typeof(DataAccessContext)))
×
375
                yield return new ExecuteCommandSetDataAccessContextForCredentials(_activator, usage, context,
×
376
                    existingUsages)
×
377
                {
×
378
                    SuggestedCategory = SetUsageContext
×
379
                };
×
380
        }
×
381

382
        if (Is(o, out AllConnectionStringKeywordsNode _))
6!
383
            yield return new ExecuteCommandNewObject(_activator,
×
384
                () => new ConnectionStringKeyword(_activator.RepositoryLocator.CatalogueRepository,
×
385
                    DatabaseType.MicrosoftSQLServer, "NewKeyword", "v"))
×
386
            {
×
387
                OverrideCommandName = "Add New Connection String Keyword"
×
388
            };
×
389

390
        if (Is(o, out AllExternalServersNode _))
6!
391
        {
392
            yield return new ExecuteCommandCreateNewExternalDatabaseServer(_activator, null, PermissableDefaults.None);
×
393

394
            var assemblyDictionary = new Dictionary<PermissableDefaults, IPatcher>
×
395
            {
×
396
                { PermissableDefaults.DQE, new DataQualityEnginePatcher() },
×
397
                { PermissableDefaults.WebServiceQueryCachingServer_ID, new QueryCachingPatcher() },
×
398
                { PermissableDefaults.LiveLoggingServer_ID, new LoggingDatabasePatcher() },
×
399
                { PermissableDefaults.IdentifierDumpServer_ID, new IdentifierDumpDatabasePatcher() },
×
400
                { PermissableDefaults.ANOStore, new ANOStorePatcher() },
×
401
                { PermissableDefaults.CohortIdentificationQueryCachingServer_ID, new QueryCachingPatcher() }
×
402
            };
×
403

404
            foreach (var kvp in assemblyDictionary)
×
405
                yield return new ExecuteCommandCreateNewExternalDatabaseServer(_activator, kvp.Value, kvp.Key);
×
406
        }
407

408
        if (Is(o, out ExternalDatabaseServer eds))
6!
409
        {
410
            if (eds.WasCreatedBy(new LoggingDatabasePatcher()))
×
411
            {
412
                yield return new ExecuteCommandViewLogs(_activator, eds,
×
413
                    new LogViewerFilter(LoggingTables.DataLoadRun));
×
414
                yield return new ExecuteCommandViewLogs(_activator, eds, new LogViewerFilter(LoggingTables.FatalError));
×
415
                yield return new ExecuteCommandViewLogs(_activator, eds,
×
416
                    new LogViewerFilter(LoggingTables.ProgressLog));
×
417
                yield return new ExecuteCommandViewLogs(_activator, eds,
×
418
                    new LogViewerFilter(LoggingTables.TableLoadRun));
×
419
            }
420

421
            yield return new ExecuteCommandQueryPlatformDatabase(_activator, eds) { OverrideCommandName = View };
×
422
        }
423

424
        if (Is(o, out QueryCacheUsedByCohortIdentificationNode cicQueryCache))
6!
425
            yield return new ExecuteCommandClearQueryCache(_activator, cicQueryCache.User);
×
426

427
        if (Is(o, out FolderNode<CohortIdentificationConfiguration> cicFolder))
6!
428
            yield return new ExecuteCommandCreateNewCohortIdentificationConfiguration(_activator)
×
429
            {
×
430
                PromptToPickAProject = true,
×
431
                Folder = cicFolder.FullName
×
432
            };
×
433

434
        if (Is(o, out IJoin j))
6!
435
        {
436
            yield return new ExecuteCommandSetExtendedProperty(_activator, new[] { (IMapsDirectlyToDatabaseTable)j },
×
437
                ExtendedProperty.CustomJoinSql, null)
×
438
            {
×
439
                OverrideCommandName = "Set CustomJoinSql",
×
440
                PromptForValue = true,
×
441
                PromptForValueTaskDescription = ExtendedProperty.CustomJoinSqlDescription,
×
442
                SuggestedCategory = "Custom Join"
×
443
            };
×
444

445
            yield return new ExecuteCommandSetExtendedProperty(_activator, new[] { (IMapsDirectlyToDatabaseTable)j },
×
446
                ExtendedProperty.CustomJoinSql, null)
×
447
            {
×
448
                OverrideCommandName = "Clear CustomJoinSql",
×
449
                SuggestedCategory = "Custom Join"
×
450
            };
×
451
        }
452

453
        CohortIdentificationConfiguration cic = null;
6✔
454
        if (Is(o, out ProjectCohortIdentificationConfigurationAssociation pcic) || Is(o, out cic))
6!
455
        {
456
            if (pcic != null) cic = pcic.CohortIdentificationConfiguration;
×
457

458
            var commit =
×
459
                new ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration(_activator, null)
×
460
                {
×
461
                    OverrideCommandName = "Commit Cohort",
×
462
                    Weight = -99.8f
×
463
                }.SetTarget(cic);
×
464
            if (pcic != null) commit.SetTarget((DatabaseEntity)pcic.Project);
×
465

466
            yield return commit;
×
467

468
            yield return new ExecuteCommandViewData(_activator, cic, ViewType.All, null, true) { Weight = -99.7f };
×
469
            yield return new ExecuteCommandViewData(_activator, cic, ViewType.All, null, false) { Weight = -99.6f };
×
470

471
            yield return new ExecuteCommandFreezeCohortIdentificationConfiguration(_activator, cic, !cic.Frozen)
×
472
            { Weight = -50.5f };
×
473
            yield return new ExecuteCommandCreateHoldoutLookup(_activator, cic)
×
474
            { Weight = -50.5f };
×
475

476
            var clone = new ExecuteCommandCloneCohortIdentificationConfiguration(_activator)
×
477
            { Weight = -50.4f, OverrideCommandName = "Clone" }.SetTarget(cic);
×
478
            if (pcic != null) clone.SetTarget((DatabaseEntity)pcic.Project);
×
479
            yield return clone;
×
480
            //associate with project
481
            yield return new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(_activator)
×
482
            { Weight = -50.3f, OverrideCommandName = "Associate with Project" }.SetTarget(cic);
×
483

484
            yield return new ExecuteCommandSetQueryCachingDatabase(_activator, cic)
×
485
            { Weight = -50.4f, OverrideCommandName = "Change Query Cache" };
×
486
        }
487

488
        if (Is(o, out AllGovernanceNode _))
6!
489
        {
490
            yield return new ExecuteCommandCreateNewGovernancePeriod(_activator)
×
491
            { OverrideCommandName = "Add New Governance Period" };
×
492
            yield return new ExecuteCommandAddNewGovernanceDocument(_activator, null)
×
493
            { OverrideCommandName = "Add New Governance Document" };
×
494
        }
495

496
        if (Is(o, out FolderNode<LoadMetadata> lmdFolder))
6!
497
        {
498
            yield return new ExecuteCommandCreateNewLoadMetadata(_activator) { Folder = lmdFolder.FullName };
×
499
            yield return new ExecuteCommandImportShareDefinitionList(_activator)
×
500
            { OverrideCommandName = "Import Load" };
×
501
        }
502

503
        if (Is(o, out LoadMetadata lmd))
6!
504
        {
NEW
505
            if (lmd.RootLoadMetadata_ID is null)
×
506
            {
NEW
507
                yield return new ExecuteCommandExportObjectsToFile(_activator, new IMapsDirectlyToDatabaseTable[] { lmd });
×
508

NEW
509
                yield return new ExecuteCommandOverrideRawServer(_activator, lmd);
×
NEW
510
                yield return new ExecuteCommandCreateNewLoadMetadata(_activator);
×
NEW
511
                var reservedTest = lmd.AllowReservedPrefix ? "Drop" : "Allow";
×
NEW
512
                yield return new ExecuteCommandToggleAllowReservedPrefixForLoadMetadata(lmd)
×
NEW
513
                {
×
NEW
514
                    OverrideCommandName = $"{reservedTest} Reserved Prefix Columns"
×
NEW
515
                };
×
NEW
516
                yield return new ExecuteCommandCreateLoadMetadataVersion(_activator, lmd)
×
NEW
517
                {
×
NEW
518
                    OverrideCommandName = "Save Version"
×
NEW
519
                };
×
NEW
520
                yield return new ExecuteCommandCloneLoadMetadata(_activator, lmd)
×
NEW
521
                {
×
NEW
522
                    OverrideCommandName = "Clone Load Metadata"
×
NEW
523
                };
×
524

NEW
525
                yield return new ExecuteCommandSetGlobalDleIgnorePattern(_activator) { SuggestedCategory = Advanced };
×
NEW
526
                yield return new ExecuteCommandSetIgnoredColumns(_activator, lmd) { SuggestedCategory = Advanced };
×
NEW
527
                yield return new ExecuteCommandSetIgnoredColumns(_activator, lmd, null)
×
NEW
528
                { OverrideCommandName = "Clear Ignored Columns", SuggestedCategory = Advanced };
×
529

NEW
530
                yield return new ExecuteCommandSetExtendedProperty(_activator, new[] { lmd },
×
NEW
531
                    ExtendedProperty.PersistentRaw, null)
×
NEW
532
                {
×
NEW
533
                    OverrideCommandName = "Persistent RAW",
×
NEW
534
                    PromptForValue = true,
×
NEW
535
                    PromptForValueTaskDescription = ExtendedProperty.PersistentRawDescription,
×
NEW
536
                    SuggestedCategory = Advanced
×
NEW
537
                };
×
538

NEW
539
                yield return new ExecuteCommandSet(_activator, lmd,
×
NEW
540
                    typeof(LoadMetadata).GetProperty(nameof(LoadMetadata.IgnoreTrigger)))
×
NEW
541
                {
×
NEW
542
                    OverrideCommandName = $"Ignore Trigger (Current value:{lmd.IgnoreTrigger})",
×
NEW
543
                    SuggestedCategory = Advanced
×
NEW
544
                };
×
545
            }
546
            else
547
            {
NEW
548
                yield return new ExecuteCommandRestoreLoadMetadataVersion(_activator, lmd)
×
NEW
549
                {
×
NEW
550
                    OverrideCommandName = "Restore Version"
×
NEW
551
                };
×
NEW
552
                yield return new ExecuteCommandCloneLoadMetadata(_activator, lmd)
×
NEW
553
                {
×
NEW
554
                    OverrideCommandName = "Clone Load Metadata"
×
NEW
555
                };
×
556
            }
557
        }
558

559
        if (Is(o, out LoadMetadataScheduleNode scheduleNode))
6!
UNCOV
560
            yield return new ExecuteCommandCreateNewLoadProgress(_activator, scheduleNode.LoadMetadata);
×
561

562
        if (Is(o, out LoadProgress loadProgress))
6!
563
            yield return new ExecuteCommandCreateNewCacheProgress(_activator, loadProgress);
×
564

565
        if (Is(o, out LoadStageNode lsn))
6!
566
        {
567
            yield return new ExecuteCommandCreateNewClassBasedProcessTask(_activator, lsn.LoadMetadata, lsn.LoadStage,
×
568
                null);
×
569
            yield return new ExecuteCommandCreateNewFileBasedProcessTask(_activator, ProcessTaskType.SQLFile,
×
570
                lsn.LoadMetadata, lsn.LoadStage);
×
571
            yield return new ExecuteCommandCreateNewFileBasedProcessTask(_activator, ProcessTaskType.Executable,
×
572
                lsn.LoadMetadata, lsn.LoadStage);
×
573
            yield return new ExecuteCommandCreateNewFileBasedProcessTask(_activator, ProcessTaskType.SQLBakFile,
×
574
                lsn.LoadMetadata, lsn.LoadStage);
×
575
        }
576

577
        if (Is(o, out LoadDirectoryNode ldn))
6!
578
        {
579
            yield return new ExecuteCommandCreateNewDataLoadDirectory(_activator, ldn.LoadMetadata, null);
×
580
        }
581

582
        if (Is(o, out AllObjectImportsNode _))
6!
583
            yield return new ExecuteCommandImportShareDefinitionList(_activator);
×
584

585
        if (Is(o, out AllPermissionWindowsNode _))
6!
586
            yield return new ExecuteCommandCreateNewPermissionWindow(_activator);
×
587

588
        if (Is(o, out AllPluginsNode _))
6!
589
        {
590
            yield return new ExecuteCommandAddPlugins(_activator);
×
591
            yield return new ExecuteCommandPrunePlugin(_activator);
×
592
            yield return new ExecuteCommandExportPlugins(_activator);
×
593
        }
594

595
        if (Is(o, out AllRDMPRemotesNode _))
6!
596
            yield return new ExecuteCommandCreateNewRemoteRDMP(_activator);
×
597

598
        if (Is(o, out AllServersNode _))
6!
599
        {
600
            yield return new ExecuteCommandImportTableInfo(_activator, null, false);
×
601
            yield return new ExecuteCommandBulkImportTableInfos(_activator);
×
602
        }
603

604
        if (Is(o, out IFilter filter))
6!
605
        {
606
            if (filter.GetAllParameters().Any())
×
607
                yield return new ExecuteCommandSet(_activator,
×
608
                        () => _activator.SelectOne("Select Parameter to change Value for...",
×
609
                            filter.GetAllParameters().OfType<IMapsDirectlyToDatabaseTable>().ToArray()),
×
610
                        typeof(ISqlParameter).GetProperty(nameof(ISqlParameter.Value))
×
611
                    )
×
612
                { OverrideCommandName = "Set Parameter Value(s)", Weight = -10 };
×
613
            yield return new ExecuteCommandViewFilterMatchData(_activator, filter, ViewType.TOP_100);
×
614
            yield return new ExecuteCommandViewFilterMatchData(_activator, filter, ViewType.Aggregate);
×
615
        }
616

617

618
        if (Is(o, out TableInfo ti))
6!
619
        {
620
            yield return new ExecuteCommandViewData(_activator, ti);
×
621

622
            yield return new ExecuteCommandImportTableInfo(_activator, null, false) { SuggestedCategory = New };
×
623
            yield return new ExecuteCommandCreateNewCatalogueFromTableInfo(_activator, ti) { SuggestedCategory = New };
×
624

625
            yield return new ExecuteCommandUseCredentialsToAccessTableInfoData(_activator, null, ti);
×
626

627
            yield return new ExecuteCommandScriptTable(_activator, ti);
×
628

629
            IAtomicCommand[] alterCommands = null;
×
630
            try
631
            {
632
                alterCommands = new IAtomicCommand[]
×
633
                {
×
634
                    new ExecuteCommandAlterTableName(_activator, ti) { SuggestedCategory = Alter },
×
635
                    new ExecuteCommandAlterTableCreatePrimaryKey(_activator, ti) { SuggestedCategory = Alter },
×
636
                    new ExecuteCommandAlterTableAddArchiveTrigger(_activator, ti) { SuggestedCategory = Alter },
×
637
                    new ExecuteCommandAlterTableMakeDistinct(_activator, ti) { SuggestedCategory = Alter }
×
638
                };
×
639
            }
×
640
            catch (Exception ex)
×
641
            {
642
                _activator.GlobalErrorCheckNotifier.OnCheckPerformed(
×
643
                    new CheckEventArgs("Failed to build Alter commands", CheckResult.Fail, ex));
×
644
            }
×
645

646
            if (alterCommands != null)
×
647
                foreach (var item in alterCommands)
×
648
                    yield return item;
×
649

650
            yield return new ExecuteCommandSyncTableInfo(_activator, ti, false, false);
×
651
            yield return new ExecuteCommandSyncTableInfo(_activator, ti, true, false);
×
652
            yield return new ExecuteCommandNewObject(_activator,
×
653
                () => new ColumnInfo(_activator.RepositoryLocator.CatalogueRepository, Guid.NewGuid().ToString(),
×
654
                    "fish", ti))
×
655
            { OverrideCommandName = "Add New ColumnInfo" };
×
656
        }
657

658
        if (Is(o, out ColumnInfo colInfo))
6!
659
        {
660
            yield return new ExecuteCommandViewData(_activator, ViewType.TOP_100, colInfo) { SuggestedCategory = View };
×
661
            yield return new ExecuteCommandViewData(_activator, ViewType.Aggregate, colInfo)
×
662
            { SuggestedCategory = View };
×
663
            yield return new ExecuteCommandViewData(_activator, ViewType.Distribution, colInfo)
×
664
            { SuggestedCategory = View };
×
665

666
            yield return new ExecuteCommandAlterColumnType(_activator, colInfo) { SuggestedCategory = Alter };
×
667

668
            yield return new ExecuteCommandSet(_activator, colInfo,
×
669
                    typeof(ColumnInfo).GetProperty(nameof(ColumnInfo.IgnoreInLoads)))
×
670
            { OverrideCommandName = $"Ignore In Loads ({colInfo.IgnoreInLoads})" };
×
671
        }
672

673
        if (Is(o, out AllStandardRegexesNode _))
6!
674
            yield return new ExecuteCommandCreateNewStandardRegex(_activator);
×
675

676
        if (Is(o, out ArbitraryFolderNode f))
6✔
677
            if (f.CommandGetter != null)
6✔
678
                foreach (var cmd in f.CommandGetter())
10✔
679
                    yield return cmd;
2✔
680

681
        if (Is(o, out CacheProgress cp))
4!
682
            yield return new ExecuteCommandSetPermissionWindow(_activator, cp);
×
683

684
        if (Is(o, out SelectedDataSets sds))
4!
685
        {
686
            yield return new ExecuteCommandSetExtractionIdentifier(_activator, sds.GetCatalogue(),
×
687
                    sds.ExtractionConfiguration, null)
×
688
            { Weight = -99.8f };
×
689

690
            ////////////// Add submenu ///////////////
691

692
            yield return new ExecuteCommandCreateNewFilter(_activator, sds)
×
693
            { OverrideCommandName = "New Filter", SuggestedCategory = Add };
×
694
            yield return new ExecuteCommandCreateNewFilter(_activator, sds)
×
695
            {
×
696
                OfferCatalogueFilters = true,
×
697
                OverrideCommandName = "Existing Filter (copy of)",
×
698
                SuggestedCategory = Add
×
699
            };
×
700

701
            yield return new ExecuteCommandAddNewFilterContainer(_activator, sds)
×
702
            { OverrideCommandName = "New Filter Container", SuggestedCategory = Add };
×
703
            yield return new ExecuteCommandImportFilterContainerTree(_activator, sds)
×
704
            { OverrideCommandName = "Existing Filter Container (copy of)", SuggestedCategory = Add };
×
705

706

707
            yield return new ExecuteCommandViewExtractionSql(_activator, sds);
×
708
            yield return new ExecuteCommandAddExtractionProgress(_activator, sds)
×
709
            { SuggestedCategory = Batching, Weight = 1.1f };
×
710
            yield return new ExecuteCommandResetExtractionProgress(_activator, sds)
×
711
            { SuggestedCategory = Batching, Weight = 1.2f };
×
712
        }
713

714
        if (Is(o, out ExtractionProgress progress))
4!
715
            yield return new ExecuteCommandResetExtractionProgress(_activator, progress);
×
716

717
        if (Is(o, out ExtractionConfiguration ec))
4!
718
        {
719
            ///////////////////Add//////////////
720

721
            yield return new ExecuteCommandChooseCohort(_activator, ec)
×
722
            { Weight = -99.8f, SuggestedCategory = Add, OverrideCommandName = "Existing Cohort" };
×
723
            yield return new ExecuteCommandAddDatasetsToConfiguration(_activator, ec)
×
724
            { Weight = -99.7f, SuggestedCategory = Add, OverrideCommandName = "Existing Datasets" };
×
725
            yield return new ExecuteCommandAddPackageToConfiguration(_activator, ec)
×
726
            { Weight = -99.6f, SuggestedCategory = Add, OverrideCommandName = "Existing Package" };
×
727
            yield return new ExecuteCommandAddParameter(_activator, ec, null, null, null)
×
728
            {
×
729
                Weight = -99.5f,
×
730
                SuggestedCategory = Add,
×
731
                OverrideCommandName = "New Extraction Filter Parameter"
×
732
            };
×
733

734

735
            yield return new ExecuteCommandGenerateReleaseDocument(_activator, ec) { Weight = -99.4f };
×
736

737
            yield return ec.IsReleased
×
738
                ? new ExecuteCommandUnfreezeExtractionConfiguration(_activator, ec) { Weight = 1.2f }
×
739
                : new ExecuteCommandFreezeExtractionConfiguration(_activator, ec) { Weight = 1.2f };
×
740

741
            yield return new ExecuteCommandCloneExtractionConfiguration(_activator, ec) { Weight = 1.3f };
×
742

743
            yield return new ExecuteCommandResetExtractionProgress(_activator, ec, null) { Weight = 1.4f };
×
744
        }
745

746
        if (Is(o, out Project proj))
4!
747
        {
748
            yield return new ExecuteCommandCreateNewCohortIdentificationConfiguration(_activator)
×
749
            { OverrideCommandName = "New Cohort Builder Query", SuggestedCategory = Add, Weight = -5f }
×
750
                .SetTarget(proj);
×
751
            yield return
×
752
                new ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration(_activator, null)
×
753
                {
×
754
                    OverrideCommandName = "New Cohort From Cohort Builder Query",
×
755
                    SuggestedCategory = Add,
×
756
                    Weight = -4.9f
×
757
                }.SetTarget(proj);
×
758
            yield return new ExecuteCommandCreateNewCohortFromFile(_activator, null)
×
759
            { OverrideCommandName = "New Cohort From File", SuggestedCategory = Add, Weight = -4.8f }
×
760
                .SetTarget(proj);
×
761
            yield return new ExecuteCommandCreateNewCohortFromCatalogue(_activator, (Catalogue)null)
×
762
            { OverrideCommandName = "New Cohort From Catalogue", SuggestedCategory = Add, Weight = -4.7f }
×
763
                .SetTarget(proj);
×
764
            yield return new ExecuteCommandCreateNewCohortFromTable(_activator, null)
×
765
            { OverrideCommandName = "New Cohort From Table", SuggestedCategory = Add, Weight = -4.6f }
×
766
                .SetTarget(proj);
×
767
            yield return new ExecuteCommandCreateNewExtractionConfigurationForProject(_activator, proj)
×
768
            {
×
769
                OverrideCommandName = "New Extraction Configuration",
×
770
                SuggestedCategory = Add,
×
771
                Weight = -2f
×
772
            };
×
773
            yield return new ExecuteCommandCreateNewCatalogueByImportingFile(_activator)
×
774
            {
×
775
                OverrideCommandName = "New Project Specific Catalogue From File...",
×
776
                SuggestedCategory = Add,
×
777
                Weight = -1.9f
×
778
            }.SetTarget(proj);
×
779
            yield return new ExecuteCommandCreateNewCatalogueByImportingExistingDataTable(_activator)
×
780
            {
×
781
                OverrideCommandName = "New Project Specific Catalogue From Database...",
×
782
                SuggestedCategory = Add,
×
783
                Weight = -1.8f
×
784
            }.SetTarget(proj);
×
785
        }
786

787
        if (Is(o, out ProjectCataloguesNode pcn))
4!
788
        {
789
            yield return new ExecuteCommandMakeCatalogueProjectSpecific(_activator)
×
790
            { OverrideCommandName = "Add Existing Catalogue", Weight = -10 }.SetTarget(pcn.Project);
×
791
            yield return new ExecuteCommandCreateNewCatalogueByImportingFile(_activator)
×
792
            { OverrideCommandName = "Add New Catalogue From File", Weight = -9.5f }.SetTarget(pcn.Project);
×
793
            yield return new ExecuteCommandCreateNewCatalogueByImportingExistingDataTable(_activator)
×
794
            { OverrideCommandName = "Add New Catalogue From Existing Data Table", Weight = -9.4f }
×
795
                .SetTarget(pcn.Project);
×
796
        }
797

798
        if (Is(o, out ProjectCohortsNode projCohorts))
4!
799
        {
800
            yield return new ExecuteCommandCreateNewCohortIdentificationConfiguration(_activator)
×
801
            { OverrideCommandName = "Add New Cohort Builder Query", Weight = -5.1f }.SetTarget(projCohorts.Project);
×
802
            yield return new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(_activator)
×
803
            { OverrideCommandName = "Add Existing Cohort Builder Query (link to)", Weight = -5f }
×
804
                .SetTarget(projCohorts.Project);
×
805
            yield return
×
806
                new ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration(_activator, null)
×
807
                { OverrideCommandName = "Add New Cohort From Cohort Builder Query", Weight = -4.9f }
×
808
                    .SetTarget(projCohorts.Project);
×
809
            yield return new ExecuteCommandCreateNewCohortFromFile(_activator, null)
×
810
            { OverrideCommandName = "Add New Cohort From File", Weight = -4.8f }.SetTarget(projCohorts.Project);
×
811
            yield return new ExecuteCommandCreateNewCohortFromCatalogue(_activator, (Catalogue)null)
×
812
            { OverrideCommandName = "Add New Cohort From Catalogue", Weight = -4.7f }
×
813
                .SetTarget(projCohorts.Project);
×
814
            yield return new ExecuteCommandCreateNewCohortFromTable(_activator, null)
×
815
            { OverrideCommandName = "Add New Cohort From Table", Weight = -4.6f }.SetTarget(projCohorts.Project);
×
816
        }
817

818
        if (Is(o, out ProjectCohortIdentificationConfigurationAssociationsNode pccan))
4!
819
        {
820
            yield return new ExecuteCommandCreateNewCohortIdentificationConfiguration(_activator)
×
821
            { OverrideCommandName = "Add New Cohort Builder Query", Weight = -5.1f }.SetTarget(pccan.Project);
×
822
            yield return new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(_activator)
×
823
            { OverrideCommandName = "Add Existing Cohort Builder Query (link to)", Weight = -5f }
×
824
                .SetTarget(pccan.Project);
×
825
        }
826

827
        if (Is(o, out ProjectSavedCohortsNode savedCohortsNode))
4!
828
        {
829
            yield return
×
830
                new ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration(_activator, null)
×
831
                { OverrideCommandName = "Add New Cohort From Cohort Builder Query", Weight = -4.9f }
×
832
                    .SetTarget(savedCohortsNode.Project);
×
833
            yield return new ExecuteCommandCreateNewCohortFromFile(_activator, null)
×
834
            { OverrideCommandName = "Add New Cohort From File", Weight = -4.8f }
×
835
                .SetTarget(savedCohortsNode.Project);
×
836
            yield return new ExecuteCommandCreateNewCohortFromCatalogue(_activator, (Catalogue)null)
×
837
            { OverrideCommandName = "Add New Cohort From Catalogue", Weight = -4.7f }
×
838
                .SetTarget(savedCohortsNode.Project);
×
839
            yield return new ExecuteCommandCreateNewCohortFromTable(_activator, null)
×
840
            { OverrideCommandName = "Add New Cohort From Table", Weight = -4.6f }
×
841
                .SetTarget(savedCohortsNode.Project);
×
842
            yield return new ExecuteCommandImportAlreadyExistingCohort(_activator, null, savedCohortsNode.Project);
×
843
        }
844

845
        if (Is(o, out ExtractionConfigurationsNode ecn))
4!
846
            yield return new ExecuteCommandCreateNewExtractionConfigurationForProject(_activator, ecn.Project)
×
847
            { OverrideCommandName = "Add New Extraction Configuration", Weight = -4.7f };
×
848

849
        if (Is(o, out ExternalCohortTable ect))
4!
850
        {
851
            var ectProj = o is CohortSourceUsedByProjectNode csbpn ? csbpn.User : null;
×
852

853
            yield return new ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration(_activator,
×
854
                    null)
×
855
            {
×
856
                OverrideCommandName = "New Cohort From Cohort Builder Query",
×
857
                Weight = -4.9f,
×
858
                SuggestedCategory = "Add"
×
859
            }
×
860
                .SetTarget(ect)
×
861
                .SetTarget(ectProj);
×
862
            yield return new ExecuteCommandCreateNewCohortFromFile(_activator, null)
×
863
            { OverrideCommandName = "New Cohort From File", Weight = -4.8f, SuggestedCategory = "Add" }
×
864
                .SetTarget(ect)
×
865
                .SetTarget(ectProj);
×
866
            yield return new ExecuteCommandCreateNewCohortFromCatalogue(_activator, (Catalogue)null)
×
867
            { OverrideCommandName = "New Cohort From Catalogue", Weight = -4.7f, SuggestedCategory = "Add" }
×
868
                .SetTarget(ect)
×
869
                .SetTarget(ectProj);
×
870

871
            yield return new ExecuteCommandCreateNewCohortFromTable(_activator, null)
×
872
            { OverrideCommandName = "New Cohort From Table", Weight = -4.6f, SuggestedCategory = Add }
×
873
                .SetTarget(ect)
×
874
                .SetTarget(ectProj);
×
875

876
            yield return new ExecuteCommandImportAlreadyExistingCohort(_activator, ect, null)
×
877
            { OverrideCommandName = "Existing Cohort", Weight = -4.6f, SuggestedCategory = "Add" };
×
878

879
            yield return new ExecuteCommandRefreshBrokenCohorts(_activator, ect) { Weight = 1 };
×
880
        }
×
881

882
        if (Is(o, out ExtractableCohort cohort))
4!
883
        {
884
            yield return new ExecuteCommandViewData(_activator, cohort, ViewType.TOP_100) { Weight = -99.9f };
×
885
            yield return new ExecuteCommandViewData(_activator, cohort, ViewType.All)
×
886
            {
×
887
                AskForFile = true,
×
888
                OverrideCommandName = "Save Cohort To File...",
×
889
                OverrideIcon = Image.Load<Rgba32>(FamFamFamIcons.disk),
×
890
                Weight = -99.8f
×
891
            };
×
892
            yield return new ExecuteCommandCreateNewExtractionConfigurationForProject(_activator)
×
893
            {
×
894
                CohortIfAny = cohort,
×
895
                OverrideCommandName = "New Extraction Configuration using Cohort"
×
896
            };
×
897
        }
898

899
        if (Is(o, out IMightBeDeprecated d))
4!
900
        {
901
            yield return new ExecuteCommandDeprecate(_activator, new[] { d }, !d.IsDeprecated)
×
902
            {
×
903
                OverrideCommandName = d.IsDeprecated ? "Un Deprecate" : "Deprecate",
×
904
                SuggestedCategory = Deprecation,
×
905
                Weight = -99.7f
×
906
            };
×
907
            yield return new ExecuteCommandReplacedBy(_activator, d, null)
×
908
            {
×
909
                PromptToPickReplacement = true,
×
910
                SuggestedCategory = Deprecation,
×
911
                Weight = -99.6f,
×
912
                OverrideCommandName = "Set Replaced By"
×
913
            };
×
914
        }
915

916
        if (Is(o, out CohortAggregateContainer cohortAggregateContainer))
4!
917
        {
918
            yield return new ExecuteCommandAddCatalogueToCohortIdentificationSetContainer(_activator,
×
919
                cohortAggregateContainer, null, null)
×
920
            { SuggestedCategory = Add, OverrideCommandName = "Catalogue" };
×
921
            yield return new ExecuteCommandAddCohortSubContainer(_activator, cohortAggregateContainer)
×
922
            { SuggestedCategory = Add, OverrideCommandName = "Sub Container" };
×
923
            yield return new ExecuteCommandAddAggregateConfigurationToCohortIdentificationSetContainer(_activator,
×
924
                    cohortAggregateContainer, true)
×
925
            { SuggestedCategory = Add, OverrideCommandName = "Existing Cohort Set (copy of)" };
×
926
            yield return new ExecuteCommandAddAggregateConfigurationToCohortIdentificationSetContainer(_activator,
×
927
                cohortAggregateContainer, false)
×
928
            { SuggestedCategory = Add, OverrideCommandName = "Aggregate" };
×
929
            yield return new ExecuteCommandImportCohortIdentificationConfiguration(_activator, null,
×
930
                    cohortAggregateContainer)
×
931
            { SuggestedCategory = Add, OverrideCommandName = "Existing Cohort Builder Query (copy of)" };
×
932

933
            //Set Operation
934
            yield return new ExecuteCommandSetContainerOperation(_activator, cohortAggregateContainer,
×
935
                SetOperation.UNION)
×
936
            { SuggestedCategory = SetContainerOperation, OverrideCommandName = "UNION" };
×
937
            yield return new ExecuteCommandSetContainerOperation(_activator, cohortAggregateContainer,
×
938
                SetOperation.EXCEPT)
×
939
            { SuggestedCategory = SetContainerOperation, OverrideCommandName = "EXCEPT" };
×
940
            yield return new ExecuteCommandSetContainerOperation(_activator, cohortAggregateContainer,
×
941
                    SetOperation.INTERSECT)
×
942
            { SuggestedCategory = SetContainerOperation, OverrideCommandName = "INTERSECT" };
×
943

944
            yield return new ExecuteCommandUnMergeCohortIdentificationConfiguration(_activator,
×
945
                cohortAggregateContainer)
×
946
            { OverrideCommandName = "Separate Cohort Builder Query" };
×
947
        }
948

949
        if (Is(o, out IDisableable disable))
4!
950
            yield return new ExecuteCommandDisableOrEnable(_activator, disable);
×
951

952
        // If the root object is deletable offer deleting
953
        if (Is(o, out IDeleteable deletable))
4!
954
            yield return new ExecuteCommandDelete(_activator, deletable) { SuggestedShortcut = "Delete" };
×
955

956
        if (Is(o, out ReferenceOtherObjectDatabaseEntity reference))
4!
957
            yield return new ExecuteCommandShowRelatedObject(_activator, reference);
×
958

959
        if (Is(o, out INamed n))
4!
960
            yield return new ExecuteCommandRename(_activator, n) { SuggestedShortcut = "F2" };
×
961

962
        if (Is(o, out PipelineCompatibleWithUseCaseNode pcu))
4!
963
        {
964
            yield return new ExecuteCommandNewObject(_activator, typeof(Pipeline))
×
965
            { OverrideCommandName = "New Pipeline" };
×
966
            yield return new ExecuteCommandClonePipeline(_activator, pcu.Pipeline);
×
967
            yield return new ExecuteCommandAddPipelineComponent(_activator, pcu.Pipeline, pcu.UseCase);
×
968
        }
969
        else if (Is(o, out Pipeline pipeline))
4!
970
        {
971
            yield return new ExecuteCommandNewObject(_activator, typeof(Pipeline))
×
972
            { OverrideCommandName = "New Pipeline" };
×
973
            yield return new ExecuteCommandClonePipeline(_activator, pipeline);
×
974
            yield return new ExecuteCommandAddPipelineComponent(_activator, pipeline, null);
×
975
        }
976

977
        if (Is(o, out StandardPipelineUseCaseNode psu))
4!
978
            yield return new ExecuteCommandNewObject(_activator, typeof(Pipeline))
×
979
            { OverrideCommandName = "New Pipeline" };
×
980
    }
4✔
981

982
    public IEnumerable<IAtomicCommand> CreateManyObjectCommands(ICollection many)
983
    {
984
        if (many.Cast<object>().All(d => d is IDisableable))
×
985
            yield return new ExecuteCommandDisableOrEnable(_activator, many.Cast<IDisableable>().ToArray());
×
986
        if (many.Cast<object>().All(d => d is IHasFolder))
×
987
            yield return new ExecuteCommandPutIntoFolder(_activator, many.Cast<IHasFolder>().ToArray(), null);
×
988

989
        if (many.Cast<object>().All(t => t is TableInfo))
×
990
            yield return new ExecuteCommandScriptTables(_activator, many.Cast<TableInfo>().ToArray(), null, null, null);
×
991
        if (many.Cast<object>().All(t => t is CatalogueItem))
×
992
            yield return new ExecuteCommandChangeExtractionCategory(_activator,
×
993
                many.Cast<CatalogueItem>()
×
994
                    .Select(ci => ci.ExtractionInformation)
×
995
                    .Where(ei => ei != null).ToArray(), null);
×
996

997
        if (many.Cast<object>().All(d => d is IDeleteable))
×
998
            yield return new ExecuteCommandDelete(_activator, many.Cast<IDeleteable>().ToArray())
×
999
            { SuggestedShortcut = "Delete" };
×
1000

1001
        if (many.Cast<object>().All(d => d is ExtractionFilterParameterSet))
×
1002
            yield return new ExecuteCommandAddMissingParameters(_activator,
×
1003
                many.Cast<ExtractionFilterParameterSet>().ToArray());
×
1004

1005
        // Deprecate/UnDeprecate many items at once if all share the same state (all true or all false)
1006
        if (many.Cast<object>().All(d => d is IMightBeDeprecated))
×
1007
        {
1008
            var dep = many.Cast<IMightBeDeprecated>().ToArray();
×
1009

1010
            if (dep.All(d => d.IsDeprecated))
×
1011
                yield return new ExecuteCommandDeprecate(_activator, dep, false)
×
1012
                {
×
1013
                    SuggestedShortcut = "UnDeprecate"
×
1014
                };
×
1015
            else if (dep.All(d => !d.IsDeprecated))
×
1016
                yield return new ExecuteCommandDeprecate(_activator, dep, true)
×
1017
                {
×
1018
                    SuggestedShortcut = "Deprecate"
×
1019
                };
×
1020
        }
1021
    }
×
1022
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc