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

HicServices / RDMP / 6658089448

26 Oct 2023 06:10PM UTC coverage: 56.911% (-0.07%) from 56.985%
6658089448

push

github

web-flow
RDMP-15 Use .bak files as Data Loads (#1656)

* basic ui triggers
* working dl

---------

Co-authored-by: James A Sutherland <j@sutherland.pw>

10695 of 20239 branches covered (0.0%)

Branch coverage included in aggregate %.

89 of 89 new or added lines in 6 files covered. (100.0%)

30536 of 52209 relevant lines covered (58.49%)

7341.8 hits per line

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

17.01
/Rdmp.Core/CommandExecution/AtomicCommandFactory.cs
1
// Copyright (c) The University of Dundee 2018-2019
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

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

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

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

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

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

99
            if (!isApiCall)
×
100
            {
101
                yield return new ExecuteCommandViewData(_activator, c, ViewType.TOP_100)
×
102
                {
×
103
                    Weight = -99.2f,
×
104
                    OverrideCommandName = "Catalogue SQL/Data",
×
105
                    SuggestedCategory = View
×
106
                };
×
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

131
            if (!isApiCall)
×
132
            {
133
                yield return new ExecuteCommandChangeExtractability(_activator, c)
×
134
                {
×
135
                    Weight = -99.0010f,
×
136
                    SuggestedCategory = Extraction
×
137
                };
×
138

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

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

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

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

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

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

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

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

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

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

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

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

232
        if (Is(o, out CatalogueItem ci))
6!
233
        {
234
            yield return new ExecuteCommandCreateNewFilter(_activator, ci) { OverrideCommandName = "Add New Filter" };
×
235
            yield return new ExecuteCommandLinkCatalogueItemToColumnInfo(_activator, ci);
×
236
            yield return new ExecuteCommandMakeCatalogueItemExtractable(_activator, ci);
×
237
            yield return new ExecuteCommandChangeExtractionCategory(_activator, new[] { ci.ExtractionInformation });
×
238
            yield return new ExecuteCommandImportCatalogueItemDescription(_activator, ci)
×
239
            { SuggestedShortcut = "I", Ctrl = true };
×
240

241
            var ciExtractionInfo = ci.ExtractionInformation;
×
242
            if (ciExtractionInfo != null)
×
243
            {
244
                yield return new ExecuteCommandViewData(_activator, ViewType.TOP_100, ciExtractionInfo)
×
245
                { SuggestedCategory = View };
×
246
                yield return new ExecuteCommandViewData(_activator, ViewType.Aggregate, ciExtractionInfo)
×
247
                { SuggestedCategory = View };
×
248
                yield return new ExecuteCommandViewData(_activator, ViewType.Distribution, ciExtractionInfo)
×
249
                { SuggestedCategory = View };
×
250
            }
251
        }
×
252

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

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

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

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

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

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

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

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

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

307

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

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

321
            //yield return new ExecuteCommandCreateNewCatalogueByExecutingAnAggregateConfiguration(_activator,ac);
322
        }
323

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

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

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

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

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

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

356
            yield return new ExecuteCommandExportObjectsToFile(_activator, _activator.CoreChildProvider.AllANOTables);
×
357
        }
358

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

468
            yield return commit;
×
469

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

473
            yield return new ExecuteCommandFreezeCohortIdentificationConfiguration(_activator, cic, !cic.Frozen)
×
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
        {
505
            yield return new ExecuteCommandExportObjectsToFile(_activator, new IMapsDirectlyToDatabaseTable[] { lmd });
×
506

507
            yield return new ExecuteCommandOverrideRawServer(_activator, lmd);
×
508
            yield return new ExecuteCommandCreateNewLoadMetadata(_activator);
×
509

510

511
            yield return new ExecuteCommandSetGlobalDleIgnorePattern(_activator) { SuggestedCategory = Advanced };
×
512
            yield return new ExecuteCommandSetIgnoredColumns(_activator, lmd) { SuggestedCategory = Advanced };
×
513
            yield return new ExecuteCommandSetIgnoredColumns(_activator, lmd, null)
×
514
            { OverrideCommandName = "Clear Ignored Columns", SuggestedCategory = Advanced };
×
515

516
            yield return new ExecuteCommandSetExtendedProperty(_activator, new[] { lmd },
×
517
                ExtendedProperty.PersistentRaw, null)
×
518
            {
×
519
                OverrideCommandName = "Persistent RAW",
×
520
                PromptForValue = true,
×
521
                PromptForValueTaskDescription = ExtendedProperty.PersistentRawDescription,
×
522
                SuggestedCategory = Advanced
×
523
            };
×
524

525
            yield return new ExecuteCommandSet(_activator, lmd,
×
526
                typeof(LoadMetadata).GetProperty(nameof(LoadMetadata.IgnoreTrigger)))
×
527
            {
×
528
                OverrideCommandName = $"Ignore Trigger (Current value:{lmd.IgnoreTrigger})",
×
529
                SuggestedCategory = Advanced
×
530
            };
×
531
        }
532

533

534
        if (Is(o, out LoadMetadataScheduleNode scheduleNode))
6!
535
            yield return new ExecuteCommandCreateNewLoadProgress(_activator, scheduleNode.LoadMetadata);
×
536

537
        if (Is(o, out LoadProgress loadProgress))
6!
538
            yield return new ExecuteCommandCreateNewCacheProgress(_activator, loadProgress);
×
539

540
        if (Is(o, out LoadStageNode lsn))
6!
541
        {
542
            yield return new ExecuteCommandCreateNewClassBasedProcessTask(_activator, lsn.LoadMetadata, lsn.LoadStage,
×
543
                null);
×
544
            yield return new ExecuteCommandCreateNewFileBasedProcessTask(_activator, ProcessTaskType.SQLFile,
×
545
                lsn.LoadMetadata, lsn.LoadStage);
×
546
            yield return new ExecuteCommandCreateNewFileBasedProcessTask(_activator, ProcessTaskType.Executable,
×
547
                lsn.LoadMetadata, lsn.LoadStage);
×
548
            yield return new ExecuteCommandCreateNewFileBasedProcessTask(_activator, ProcessTaskType.SQLBakFile,
×
549
                lsn.LoadMetadata, lsn.LoadStage);
×
550
        }
551

552
        if (Is(o, out LoadDirectoryNode ldn))
6!
553
        {
554
            yield return new ExecuteCommandSet(_activator, ldn.LoadMetadata,
×
555
                typeof(LoadMetadata).GetProperty(nameof(LoadMetadata.LocationOfFlatFiles)));
×
556
            yield return new ExecuteCommandCreateNewDataLoadDirectory(_activator, ldn.LoadMetadata, null);
×
557
        }
558

559
        if (Is(o, out AllObjectImportsNode _))
6!
560
            yield return new ExecuteCommandImportShareDefinitionList(_activator);
×
561

562
        if (Is(o, out AllPermissionWindowsNode _))
6!
563
            yield return new ExecuteCommandCreateNewPermissionWindow(_activator);
×
564

565
        if (Is(o, out AllPluginsNode _))
6!
566
        {
567
            yield return new ExecuteCommandAddPlugins(_activator);
×
568
            yield return new ExecuteCommandPrunePlugin(_activator);
×
569
            yield return new ExecuteCommandExportPlugins(_activator);
×
570
        }
571

572
        if (Is(o, out AllRDMPRemotesNode _))
6!
573
            yield return new ExecuteCommandCreateNewRemoteRDMP(_activator);
×
574

575
        if (Is(o, out AllServersNode _))
6!
576
        {
577
            yield return new ExecuteCommandImportTableInfo(_activator, null, false);
×
578
            yield return new ExecuteCommandBulkImportTableInfos(_activator);
×
579
        }
580

581
        if (Is(o, out IFilter filter))
6!
582
        {
583
            if (filter.GetAllParameters().Any())
×
584
                yield return new ExecuteCommandSet(_activator,
×
585
                        () => _activator.SelectOne("Select Parameter to change Value for...",
×
586
                            filter.GetAllParameters().OfType<IMapsDirectlyToDatabaseTable>().ToArray()),
×
587
                        typeof(ISqlParameter).GetProperty(nameof(ISqlParameter.Value))
×
588
                    )
×
589
                { OverrideCommandName = "Set Parameter Value(s)", Weight = -10 };
×
590
            yield return new ExecuteCommandViewFilterMatchData(_activator, filter, ViewType.TOP_100);
×
591
            yield return new ExecuteCommandViewFilterMatchData(_activator, filter, ViewType.Aggregate);
×
592
        }
593

594

595
        if (Is(o, out TableInfo ti))
6!
596
        {
597
            yield return new ExecuteCommandViewData(_activator, ti);
×
598

599
            yield return new ExecuteCommandImportTableInfo(_activator, null, false) { SuggestedCategory = New };
×
600
            yield return new ExecuteCommandCreateNewCatalogueFromTableInfo(_activator, ti) { SuggestedCategory = New };
×
601

602
            yield return new ExecuteCommandUseCredentialsToAccessTableInfoData(_activator, null, ti);
×
603

604
            yield return new ExecuteCommandScriptTable(_activator, ti);
×
605

606
            IAtomicCommand[] alterCommands = null;
×
607
            try
608
            {
609
                alterCommands = new IAtomicCommand[]
×
610
                {
×
611
                    new ExecuteCommandAlterTableName(_activator, ti) { SuggestedCategory = Alter },
×
612
                    new ExecuteCommandAlterTableCreatePrimaryKey(_activator, ti) { SuggestedCategory = Alter },
×
613
                    new ExecuteCommandAlterTableAddArchiveTrigger(_activator, ti) { SuggestedCategory = Alter },
×
614
                    new ExecuteCommandAlterTableMakeDistinct(_activator, ti) { SuggestedCategory = Alter }
×
615
                };
×
616
            }
×
617
            catch (Exception ex)
×
618
            {
619
                _activator.GlobalErrorCheckNotifier.OnCheckPerformed(
×
620
                    new CheckEventArgs("Failed to build Alter commands", CheckResult.Fail, ex));
×
621
            }
×
622

623
            if (alterCommands != null)
×
624
                foreach (var item in alterCommands)
×
625
                    yield return item;
×
626

627
            yield return new ExecuteCommandSyncTableInfo(_activator, ti, false, false);
×
628
            yield return new ExecuteCommandSyncTableInfo(_activator, ti, true, false);
×
629
            yield return new ExecuteCommandNewObject(_activator,
×
630
                () => new ColumnInfo(_activator.RepositoryLocator.CatalogueRepository, Guid.NewGuid().ToString(),
×
631
                    "fish", ti))
×
632
            { OverrideCommandName = "Add New ColumnInfo" };
×
633
        }
634

635
        if (Is(o, out ColumnInfo colInfo))
6!
636
        {
637
            yield return new ExecuteCommandViewData(_activator, ViewType.TOP_100, colInfo) { SuggestedCategory = View };
×
638
            yield return new ExecuteCommandViewData(_activator, ViewType.Aggregate, colInfo)
×
639
            { SuggestedCategory = View };
×
640
            yield return new ExecuteCommandViewData(_activator, ViewType.Distribution, colInfo)
×
641
            { SuggestedCategory = View };
×
642

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

645
            yield return new ExecuteCommandSet(_activator, colInfo,
×
646
                    typeof(ColumnInfo).GetProperty(nameof(ColumnInfo.IgnoreInLoads)))
×
647
            { OverrideCommandName = $"Ignore In Loads ({colInfo.IgnoreInLoads})" };
×
648
        }
649

650
        if (Is(o, out AllStandardRegexesNode _))
6!
651
            yield return new ExecuteCommandCreateNewStandardRegex(_activator);
×
652

653
        if (Is(o, out ArbitraryFolderNode f))
6✔
654
            if (f.CommandGetter != null)
6✔
655
                foreach (var cmd in f.CommandGetter())
10✔
656
                    yield return cmd;
2✔
657

658
        if (Is(o, out CacheProgress cp))
4!
659
            yield return new ExecuteCommandSetPermissionWindow(_activator, cp);
×
660

661
        if (Is(o, out SelectedDataSets sds))
4!
662
        {
663
            yield return new ExecuteCommandSetExtractionIdentifier(_activator, sds.GetCatalogue(),
×
664
                    sds.ExtractionConfiguration, null)
×
665
            { Weight = -99.8f };
×
666

667
            ////////////// Add submenu ///////////////
668

669
            yield return new ExecuteCommandCreateNewFilter(_activator, sds)
×
670
            { OverrideCommandName = "New Filter", SuggestedCategory = Add };
×
671
            yield return new ExecuteCommandCreateNewFilter(_activator, sds)
×
672
            {
×
673
                OfferCatalogueFilters = true,
×
674
                OverrideCommandName = "Existing Filter (copy of)",
×
675
                SuggestedCategory = Add
×
676
            };
×
677

678
            yield return new ExecuteCommandAddNewFilterContainer(_activator, sds)
×
679
            { OverrideCommandName = "New Filter Container", SuggestedCategory = Add };
×
680
            yield return new ExecuteCommandImportFilterContainerTree(_activator, sds)
×
681
            { OverrideCommandName = "Existing Filter Container (copy of)", SuggestedCategory = Add };
×
682

683

684
            yield return new ExecuteCommandViewExtractionSql(_activator, sds);
×
685
            yield return new ExecuteCommandAddExtractionProgress(_activator, sds)
×
686
            { SuggestedCategory = Batching, Weight = 1.1f };
×
687
            yield return new ExecuteCommandResetExtractionProgress(_activator, sds)
×
688
            { SuggestedCategory = Batching, Weight = 1.2f };
×
689
        }
690

691
        if (Is(o, out ExtractionProgress progress))
4!
692
            yield return new ExecuteCommandResetExtractionProgress(_activator, progress);
×
693

694
        if (Is(o, out ExtractionConfiguration ec))
4!
695
        {
696
            ///////////////////Add//////////////
697

698
            yield return new ExecuteCommandChooseCohort(_activator, ec)
×
699
            { Weight = -99.8f, SuggestedCategory = Add, OverrideCommandName = "Existing Cohort" };
×
700
            yield return new ExecuteCommandAddDatasetsToConfiguration(_activator, ec)
×
701
            { Weight = -99.7f, SuggestedCategory = Add, OverrideCommandName = "Existing Datasets" };
×
702
            yield return new ExecuteCommandAddPackageToConfiguration(_activator, ec)
×
703
            { Weight = -99.6f, SuggestedCategory = Add, OverrideCommandName = "Existing Package" };
×
704
            yield return new ExecuteCommandAddParameter(_activator, ec, null, null, null)
×
705
            {
×
706
                Weight = -99.5f,
×
707
                SuggestedCategory = Add,
×
708
                OverrideCommandName = "New Extraction Filter Parameter"
×
709
            };
×
710

711

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

714
            yield return ec.IsReleased
×
715
                ? new ExecuteCommandUnfreezeExtractionConfiguration(_activator, ec) { Weight = 1.2f }
×
716
                : new ExecuteCommandFreezeExtractionConfiguration(_activator, ec) { Weight = 1.2f };
×
717

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

720
            yield return new ExecuteCommandResetExtractionProgress(_activator, ec, null) { Weight = 1.4f };
×
721
        }
722

723
        if (Is(o, out Project proj))
4!
724
        {
725
            yield return new ExecuteCommandCreateNewCohortIdentificationConfiguration(_activator)
×
726
            { OverrideCommandName = "New Cohort Builder Query", SuggestedCategory = Add, Weight = -5f }
×
727
                .SetTarget(proj);
×
728
            yield return
×
729
                new ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration(_activator, null)
×
730
                {
×
731
                    OverrideCommandName = "New Cohort From Cohort Builder Query",
×
732
                    SuggestedCategory = Add,
×
733
                    Weight = -4.9f
×
734
                }.SetTarget(proj);
×
735
            yield return new ExecuteCommandCreateNewCohortFromFile(_activator, null)
×
736
            { OverrideCommandName = "New Cohort From File", SuggestedCategory = Add, Weight = -4.8f }
×
737
                .SetTarget(proj);
×
738
            yield return new ExecuteCommandCreateNewCohortFromCatalogue(_activator, (Catalogue)null)
×
739
            { OverrideCommandName = "New Cohort From Catalogue", SuggestedCategory = Add, Weight = -4.7f }
×
740
                .SetTarget(proj);
×
741
            yield return new ExecuteCommandCreateNewCohortFromTable(_activator, null)
×
742
            { OverrideCommandName = "New Cohort From Table", SuggestedCategory = Add, Weight = -4.6f }
×
743
                .SetTarget(proj);
×
744
            yield return new ExecuteCommandCreateNewExtractionConfigurationForProject(_activator, proj)
×
745
            {
×
746
                OverrideCommandName = "New Extraction Configuration",
×
747
                SuggestedCategory = Add,
×
748
                Weight = -2f
×
749
            };
×
750
            yield return new ExecuteCommandCreateNewCatalogueByImportingFile(_activator)
×
751
            {
×
752
                OverrideCommandName = "New Project Specific Catalogue From File...",
×
753
                SuggestedCategory = Add,
×
754
                Weight = -1.9f
×
755
            }.SetTarget(proj);
×
756
            yield return new ExecuteCommandCreateNewCatalogueByImportingExistingDataTable(_activator)
×
757
            {
×
758
                OverrideCommandName = "New Project Specific Catalogue From Database...",
×
759
                SuggestedCategory = Add,
×
760
                Weight = -1.8f
×
761
            }.SetTarget(proj);
×
762
        }
763

764
        if (Is(o, out ProjectCataloguesNode pcn))
4!
765
        {
766
            yield return new ExecuteCommandMakeCatalogueProjectSpecific(_activator)
×
767
            { OverrideCommandName = "Add Existing Catalogue", Weight = -10 }.SetTarget(pcn.Project);
×
768
            yield return new ExecuteCommandCreateNewCatalogueByImportingFile(_activator)
×
769
            { OverrideCommandName = "Add New Catalogue From File", Weight = -9.5f }.SetTarget(pcn.Project);
×
770
            yield return new ExecuteCommandCreateNewCatalogueByImportingExistingDataTable(_activator)
×
771
            { OverrideCommandName = "Add New Catalogue From Existing Data Table", Weight = -9.4f }
×
772
                .SetTarget(pcn.Project);
×
773
        }
774

775
        if (Is(o, out ProjectCohortsNode projCohorts))
4!
776
        {
777
            yield return new ExecuteCommandCreateNewCohortIdentificationConfiguration(_activator)
×
778
            { OverrideCommandName = "Add New Cohort Builder Query", Weight = -5.1f }.SetTarget(projCohorts.Project);
×
779
            yield return new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(_activator)
×
780
            { OverrideCommandName = "Add Existing Cohort Builder Query (link to)", Weight = -5f }
×
781
                .SetTarget(projCohorts.Project);
×
782
            yield return
×
783
                new ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration(_activator, null)
×
784
                { OverrideCommandName = "Add New Cohort From Cohort Builder Query", Weight = -4.9f }
×
785
                    .SetTarget(projCohorts.Project);
×
786
            yield return new ExecuteCommandCreateNewCohortFromFile(_activator, null)
×
787
            { OverrideCommandName = "Add New Cohort From File", Weight = -4.8f }.SetTarget(projCohorts.Project);
×
788
            yield return new ExecuteCommandCreateNewCohortFromCatalogue(_activator, (Catalogue)null)
×
789
            { OverrideCommandName = "Add New Cohort From Catalogue", Weight = -4.7f }
×
790
                .SetTarget(projCohorts.Project);
×
791
            yield return new ExecuteCommandCreateNewCohortFromTable(_activator, null)
×
792
            { OverrideCommandName = "Add New Cohort From Table", Weight = -4.6f }.SetTarget(projCohorts.Project);
×
793
        }
794

795
        if (Is(o, out ProjectCohortIdentificationConfigurationAssociationsNode pccan))
4!
796
        {
797
            yield return new ExecuteCommandCreateNewCohortIdentificationConfiguration(_activator)
×
798
            { OverrideCommandName = "Add New Cohort Builder Query", Weight = -5.1f }.SetTarget(pccan.Project);
×
799
            yield return new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(_activator)
×
800
            { OverrideCommandName = "Add Existing Cohort Builder Query (link to)", Weight = -5f }
×
801
                .SetTarget(pccan.Project);
×
802
        }
803

804
        if (Is(o, out ProjectSavedCohortsNode savedCohortsNode))
4!
805
        {
806
            yield return
×
807
                new ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration(_activator, null)
×
808
                { OverrideCommandName = "Add New Cohort From Cohort Builder Query", Weight = -4.9f }
×
809
                    .SetTarget(savedCohortsNode.Project);
×
810
            yield return new ExecuteCommandCreateNewCohortFromFile(_activator, null)
×
811
            { OverrideCommandName = "Add New Cohort From File", Weight = -4.8f }
×
812
                .SetTarget(savedCohortsNode.Project);
×
813
            yield return new ExecuteCommandCreateNewCohortFromCatalogue(_activator, (Catalogue)null)
×
814
            { OverrideCommandName = "Add New Cohort From Catalogue", Weight = -4.7f }
×
815
                .SetTarget(savedCohortsNode.Project);
×
816
            yield return new ExecuteCommandCreateNewCohortFromTable(_activator, null)
×
817
            { OverrideCommandName = "Add New Cohort From Table", Weight = -4.6f }
×
818
                .SetTarget(savedCohortsNode.Project);
×
819
            yield return new ExecuteCommandImportAlreadyExistingCohort(_activator, null, savedCohortsNode.Project);
×
820
        }
821

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

826
        if (Is(o, out ExternalCohortTable ect))
4!
827
        {
828
            var ectProj = o is CohortSourceUsedByProjectNode csbpn ? csbpn.User : null;
×
829

830
            yield return new ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration(_activator,
×
831
                    null)
×
832
            {
×
833
                OverrideCommandName = "New Cohort From Cohort Builder Query",
×
834
                Weight = -4.9f,
×
835
                SuggestedCategory = "Add"
×
836
            }
×
837
                .SetTarget(ect)
×
838
                .SetTarget(ectProj);
×
839
            yield return new ExecuteCommandCreateNewCohortFromFile(_activator, null)
×
840
            { OverrideCommandName = "New Cohort From File", Weight = -4.8f, SuggestedCategory = "Add" }
×
841
                .SetTarget(ect)
×
842
                .SetTarget(ectProj);
×
843
            yield return new ExecuteCommandCreateNewCohortFromCatalogue(_activator, (Catalogue)null)
×
844
            { OverrideCommandName = "New Cohort From Catalogue", Weight = -4.7f, SuggestedCategory = "Add" }
×
845
                .SetTarget(ect)
×
846
                .SetTarget(ectProj);
×
847

848
            yield return new ExecuteCommandCreateNewCohortFromTable(_activator, null)
×
849
            { OverrideCommandName = "New Cohort From Table", Weight = -4.6f, SuggestedCategory = Add }
×
850
                .SetTarget(ect)
×
851
                .SetTarget(ectProj);
×
852

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

856
            yield return new ExecuteCommandRefreshBrokenCohorts(_activator, ect) { Weight = 1 };
×
857
        }
×
858

859
        if (Is(o, out ExtractableCohort cohort))
4!
860
        {
861
            yield return new ExecuteCommandViewData(_activator, cohort, ViewType.TOP_100) { Weight = -99.9f };
×
862
            yield return new ExecuteCommandViewData(_activator, cohort, ViewType.All)
×
863
            {
×
864
                AskForFile = true,
×
865
                OverrideCommandName = "Save Cohort To File...",
×
866
                OverrideIcon = Image.Load<Rgba32>(FamFamFamIcons.disk),
×
867
                Weight = -99.8f
×
868
            };
×
869
            yield return new ExecuteCommandCreateNewExtractionConfigurationForProject(_activator)
×
870
            {
×
871
                CohortIfAny = cohort,
×
872
                OverrideCommandName = "New Extraction Configuration using Cohort"
×
873
            };
×
874
        }
875

876
        if (Is(o, out IMightBeDeprecated d))
4!
877
        {
878
            yield return new ExecuteCommandDeprecate(_activator, new[] { d }, !d.IsDeprecated)
×
879
            {
×
880
                OverrideCommandName = d.IsDeprecated ? "Un Deprecate" : "Deprecate",
×
881
                SuggestedCategory = Deprecation,
×
882
                Weight = -99.7f
×
883
            };
×
884
            yield return new ExecuteCommandReplacedBy(_activator, d, null)
×
885
            {
×
886
                PromptToPickReplacement = true,
×
887
                SuggestedCategory = Deprecation,
×
888
                Weight = -99.6f,
×
889
                OverrideCommandName = "Set Replaced By"
×
890
            };
×
891
        }
892

893
        if (Is(o, out CohortAggregateContainer cohortAggregateContainer))
4!
894
        {
895
            yield return new ExecuteCommandAddCatalogueToCohortIdentificationSetContainer(_activator,
×
896
                cohortAggregateContainer, null, null)
×
897
            { SuggestedCategory = Add, OverrideCommandName = "Catalogue" };
×
898
            yield return new ExecuteCommandAddCohortSubContainer(_activator, cohortAggregateContainer)
×
899
            { SuggestedCategory = Add, OverrideCommandName = "Sub Container" };
×
900
            yield return new ExecuteCommandAddAggregateConfigurationToCohortIdentificationSetContainer(_activator,
×
901
                    cohortAggregateContainer, true)
×
902
            { SuggestedCategory = Add, OverrideCommandName = "Existing Cohort Set (copy of)" };
×
903
            yield return new ExecuteCommandAddAggregateConfigurationToCohortIdentificationSetContainer(_activator,
×
904
                cohortAggregateContainer, false)
×
905
            { SuggestedCategory = Add, OverrideCommandName = "Aggregate" };
×
906
            yield return new ExecuteCommandImportCohortIdentificationConfiguration(_activator, null,
×
907
                    cohortAggregateContainer)
×
908
            { SuggestedCategory = Add, OverrideCommandName = "Existing Cohort Builder Query (copy of)" };
×
909

910
            //Set Operation
911
            yield return new ExecuteCommandSetContainerOperation(_activator, cohortAggregateContainer,
×
912
                SetOperation.UNION)
×
913
            { SuggestedCategory = SetContainerOperation, OverrideCommandName = "UNION" };
×
914
            yield return new ExecuteCommandSetContainerOperation(_activator, cohortAggregateContainer,
×
915
                SetOperation.EXCEPT)
×
916
            { SuggestedCategory = SetContainerOperation, OverrideCommandName = "EXCEPT" };
×
917
            yield return new ExecuteCommandSetContainerOperation(_activator, cohortAggregateContainer,
×
918
                    SetOperation.INTERSECT)
×
919
            { SuggestedCategory = SetContainerOperation, OverrideCommandName = "INTERSECT" };
×
920

921
            yield return new ExecuteCommandUnMergeCohortIdentificationConfiguration(_activator,
×
922
                cohortAggregateContainer)
×
923
            { OverrideCommandName = "Separate Cohort Builder Query" };
×
924
        }
925

926
        if (Is(o, out IDisableable disable))
4!
927
            yield return new ExecuteCommandDisableOrEnable(_activator, disable);
×
928

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

933
        if (Is(o, out ReferenceOtherObjectDatabaseEntity reference))
4!
934
            yield return new ExecuteCommandShowRelatedObject(_activator, reference);
×
935

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

939
        if (Is(o, out PipelineCompatibleWithUseCaseNode pcu))
4!
940
        {
941
            yield return new ExecuteCommandNewObject(_activator, typeof(Pipeline))
×
942
            { OverrideCommandName = "New Pipeline" };
×
943
            yield return new ExecuteCommandClonePipeline(_activator, pcu.Pipeline);
×
944
            yield return new ExecuteCommandAddPipelineComponent(_activator, pcu.Pipeline, pcu.UseCase);
×
945
        }
946
        else if (Is(o, out Pipeline pipeline))
4!
947
        {
948
            yield return new ExecuteCommandNewObject(_activator, typeof(Pipeline))
×
949
            { OverrideCommandName = "New Pipeline" };
×
950
            yield return new ExecuteCommandClonePipeline(_activator, pipeline);
×
951
            yield return new ExecuteCommandAddPipelineComponent(_activator, pipeline, null);
×
952
        }
953

954
        if (Is(o, out StandardPipelineUseCaseNode psu))
4!
955
            yield return new ExecuteCommandNewObject(_activator, typeof(Pipeline))
×
956
            { OverrideCommandName = "New Pipeline" };
×
957
    }
4✔
958

959
    public IEnumerable<IAtomicCommand> CreateManyObjectCommands(ICollection many)
960
    {
961
        if (many.Cast<object>().All(d => d is IDisableable))
×
962
            yield return new ExecuteCommandDisableOrEnable(_activator, many.Cast<IDisableable>().ToArray());
×
963
        if (many.Cast<object>().All(d => d is IHasFolder))
×
964
            yield return new ExecuteCommandPutIntoFolder(_activator, many.Cast<IHasFolder>().ToArray(), null);
×
965

966
        if (many.Cast<object>().All(t => t is TableInfo))
×
967
            yield return new ExecuteCommandScriptTables(_activator, many.Cast<TableInfo>().ToArray(), null, null, null);
×
968
        if (many.Cast<object>().All(t => t is CatalogueItem))
×
969
            yield return new ExecuteCommandChangeExtractionCategory(_activator,
×
970
                many.Cast<CatalogueItem>()
×
971
                    .Select(ci => ci.ExtractionInformation)
×
972
                    .Where(ei => ei != null).ToArray(), null);
×
973

974
        if (many.Cast<object>().All(d => d is IDeleteable))
×
975
            yield return new ExecuteCommandDelete(_activator, many.Cast<IDeleteable>().ToArray())
×
976
            { SuggestedShortcut = "Delete" };
×
977

978
        if (many.Cast<object>().All(d => d is ExtractionFilterParameterSet))
×
979
            yield return new ExecuteCommandAddMissingParameters(_activator,
×
980
                many.Cast<ExtractionFilterParameterSet>().ToArray());
×
981

982
        // Deprecate/UnDeprecate many items at once if all share the same state (all true or all false)
983
        if (many.Cast<object>().All(d => d is IMightBeDeprecated))
×
984
        {
985
            var dep = many.Cast<IMightBeDeprecated>().ToArray();
×
986

987
            if (dep.All(d => d.IsDeprecated))
×
988
                yield return new ExecuteCommandDeprecate(_activator, dep, false)
×
989
                {
×
990
                    SuggestedShortcut = "UnDeprecate"
×
991
                };
×
992
            else if (dep.All(d => !d.IsDeprecated))
×
993
                yield return new ExecuteCommandDeprecate(_activator, dep, true)
×
994
                {
×
995
                    SuggestedShortcut = "Deprecate"
×
996
                };
×
997
        }
998
    }
×
999
}
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