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

HicServices / RDMP / 16004090609

01 Jul 2025 03:47PM UTC coverage: 57.442% (+0.1%) from 57.314%
16004090609

Pull #2205

github

JFriel
add db change
Pull Request #2205: Multi-Project Catalogues

11417 of 21406 branches covered (53.34%)

Branch coverage included in aggregate %.

71 of 100 new or added lines in 8 files covered. (71.0%)

27 existing lines in 1 file now uncovered.

32373 of 54827 relevant lines covered (59.05%)

8775.92 hits per line

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

83.13
/Rdmp.Core/DataExport/Data/ProjectSpecificCatalogueManager.cs
1
using Rdmp.Core.Curation.Data;
2
using Rdmp.Core.Repositories;
3
using Spectre.Console;
4
using System;
5
using System.Collections.Generic;
6
using System.DirectoryServices.Protocols;
7
using System.Linq;
8
using System.Text;
9
using System.Threading.Tasks;
10

11
namespace Rdmp.Core.DataExport.Data
12
{
13
    static class ProjectSpecificCatalogueManager
14
    {
15

16
        public static bool CanMakeCatalogueProjectSpecific(IDataExportRepository dqeRepo, ICatalogue catalogue, IProject project, List<int> projectIdsToIgnore )
17
        {
18
            var status = catalogue.GetExtractabilityStatus(dqeRepo);
178✔
19

20
            if (!status.IsExtractable)
178!
NEW
21
                return false;
×
22

23
            var ei = catalogue.GetAllExtractionInformation(ExtractionCategory.Any);
178✔
24
            if (!ei.Any())
178!
NEW
25
                return false;
×
26
            if (ei.Count(e => e.IsExtractionIdentifier) < 1)
356!
NEW
27
                return false;
×
28
            var edss = dqeRepo.GetAllObjectsWithParent<ExtractableDataSet>(catalogue);
178✔
29
            if (edss.Any(e => e.Project_ID == project.ID))
356!
30
            {
31
                //already project specific
NEW
32
                return true;
×
33
            }
34
            foreach (var eds in edss)
637✔
35
            {
36
                var alreadyInConfiguration = eds.ExtractionConfigurations.FirstOrDefault(ec => ec.Project_ID != project.ID && !projectIdsToIgnore.Contains(ec.Project_ID));
258✔
37
                //already used in a project that we're not manipulating
38
                if (alreadyInConfiguration != null) return false;
253✔
39
            }
40

41
            return true;
103✔
42
        }
43

44
        public static void MakeCatalogueProjectSpecific(IDataExportRepository dqeRepo, ICatalogue catalogue, IProject project)
45
        {
46
            var eds = dqeRepo.GetAllObjectsWithParent<ExtractableDataSet>(catalogue).Where(eds => eds.Project_ID is null).SingleOrDefault();
32✔
47
            if (eds is null)
16✔
48
            {
49
                eds = new ExtractableDataSet(dqeRepo, catalogue, false);
6✔
50
            }
51
            eds.Project_ID = project.ID;
16✔
52
            foreach (var ei in catalogue.GetAllExtractionInformation(ExtractionCategory.Any).Where(ei => ei.ExtractionCategory is ExtractionCategory.Core))
68✔
53
            {
54
                ei.ExtractionCategory = ExtractionCategory.ProjectSpecific;
10✔
55
                ei.SaveToDatabase();
10✔
56
            }
57
            eds.SaveToDatabase();
16✔
58
        }
16✔
59

60
        public static bool CanMakeCatalogueNonProjectSpecific(IDataExportRepository dqeRepo, ICatalogue catalogue, ExtractableDataSet extractableDataSet)
61
        {
62
            var selectedDatasetsForEDS = dqeRepo.GetAllObjects<SelectedDataSets>().Where(sds => sds.ExtractableDataSet_ID == extractableDataSet.ID);
34✔
63
            if (selectedDatasetsForEDS.Any()) //used in an extraction
12✔
64
            {
65
                //check if catalgue is project specific to any other projects
66
                var otherEDs = dqeRepo.GetAllObjectsWithParent<ExtractableDataSet>(catalogue).Where(eds => eds.ID != extractableDataSet.ID && eds.Project_ID != null);
11✔
67
                if (otherEDs.Any())
4✔
68
                {
69
                    //it's used in this projects extractions and used in another project specific extraction;
70
                    return false;
3✔
71
                }
72
            }
73
            return true;
9✔
74
        }
75

76
        public static void MakeCatalogueNonProjectSpecific(IDataExportRepository dqeRepo, ICatalogue catalogue, ExtractableDataSet extractableDataSet)
77
        {
78
            var existingNullEntry = dqeRepo.GetAllObjects<ExtractableDataSet>().Where(eds => eds.Catalogue_ID == catalogue.ID && eds.Project_ID == null).FirstOrDefault();
36✔
79
            if (existingNullEntry is not null)
6✔
80
            {
81
                var selectedDatasets = dqeRepo.GetAllObjects<SelectedDataSets>().Where(sds => sds.ExtractableDataSet_ID == extractableDataSet.ID);
2✔
82
                foreach(var sds in selectedDatasets)
2!
83
                {
NEW
84
                    sds.ExtractableDataSet_ID = existingNullEntry.ID;
×
NEW
85
                    sds.SaveToDatabase();
×
86
                }
87
                var cumulativeExtractionResults = dqeRepo.GetAllObjects<CumulativeExtractionResults>().Where(cer => cer.ExtractableDataSet_ID == extractableDataSet.ID);
1✔
88
                foreach (var cer in cumulativeExtractionResults)
2!
89
                {
NEW
90
                    cer.ExtractableDataSet_ID = existingNullEntry.ID;
×
NEW
91
                    cer.SaveToDatabase();
×
92
                }
93
                extractableDataSet.DeleteInDatabase();
1✔
94
            }
95
            else
96
            {
97
                extractableDataSet.Project_ID = null;
5✔
98
                extractableDataSet.SaveToDatabase();
5✔
99
            }
100
            foreach (var ei in catalogue.GetAllExtractionInformation(ExtractionCategory.ProjectSpecific))
22✔
101
            {
102
                ei.ExtractionCategory = ExtractionCategory.Core;
5✔
103
                ei.SaveToDatabase();
5✔
104
            }
105
        }
6✔
106
    }
107
}
108

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