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

HicServices / RDMP / 16076023032

04 Jul 2025 02:31PM UTC coverage: 57.437% (+0.1%) from 57.314%
16076023032

Pull #2205

github

JFriel
fux test
Pull Request #2205: Multi-Project Catalogues

11420 of 21420 branches covered (53.31%)

Branch coverage included in aggregate %.

103 of 146 new or added lines in 16 files covered. (70.55%)

32 existing lines in 4 files now uncovered.

32391 of 54856 relevant lines covered (59.05%)

17569.41 hits per line

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

58.97
/Rdmp.Core/DataExport/Data/ProjectSpecificCatalogueManager.cs
1
using NPOI.OpenXmlFormats.Spreadsheet;
2
using Org.BouncyCastle.Crypto.Signers;
3
using Rdmp.Core.Curation.Data;
4
using Rdmp.Core.Repositories;
5
using Spectre.Console;
6
using System;
7
using System.Collections.Generic;
8
using System.DirectoryServices.Protocols;
9
using System.Linq;
10
using System.Text;
11
using System.Threading.Tasks;
12

13
namespace Rdmp.Core.DataExport.Data
14
{
15
    static class ProjectSpecificCatalogueManager
16
    {
17

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

22
            if (!status.IsExtractable)
706!
NEW
23
                return false;
×
24

25
            var ei = catalogue.GetAllExtractionInformation(ExtractionCategory.Any);
706✔
26
            if (!ei.Any())
706!
NEW
27
                return false;
×
28
            if (ei.Count(e => e.IsExtractionIdentifier) < 1)
1,412!
NEW
29
                return false;
×
30
            var edss = dqeRepo.GetAllObjectsWithParent<ExtractableDataSet>(catalogue);
706✔
31
            if (edss.Any(e => e.Projects.Select(p => p.ID).Contains(project.ID)))
1,648!
32
            {
33
                //already project specific
NEW
34
                return true;
×
35
            }
36
            foreach (var eds in edss)
2,448✔
37
            {
38
                var alreadyInConfiguration = eds.ExtractionConfigurations.FirstOrDefault(ec => ec.Project_ID != project.ID && !projectIdsToIgnore.Contains(ec.Project_ID));
1,186✔
39
                //already used in a project that we're not manipulating
40
                if (alreadyInConfiguration != null) return false;
1,082✔
41
            }
42

43
            return true;
330✔
44
        }
45

46
        public static ExtractableDataSet MakeCatalogueProjectSpecific(IDataExportRepository dqeRepo, ICatalogue catalogue, IProject project)
47
        {
48
            var eds = dqeRepo.GetAllObjectsWithParent<ExtractableDataSet>(catalogue).SingleOrDefault();
36✔
49
            if (eds is null)
36!
50
            {
NEW
51
                eds = new ExtractableDataSet(dqeRepo, catalogue, false);
×
NEW
52
                eds.SaveToDatabase();
×
53
            }
54

55
            var edsp = new ExtractableDataSetProject(dqeRepo, eds, project);
36✔
56
            edsp.SaveToDatabase();
36✔
57
            //eds.Projects.Add(edsp.Project);
58
            //eds.SaveToDatabase();
59
            foreach (var ei in catalogue.GetAllExtractionInformation(ExtractionCategory.Any).Where(ei => ei.ExtractionCategory is ExtractionCategory.Core))
152✔
60
            {
61
                ei.ExtractionCategory = ExtractionCategory.ProjectSpecific;
22✔
62
                ei.SaveToDatabase();
22✔
63
            }
64
            return eds;
36✔
65
        }
66

67
        public static bool CanMakeCatalogueNonProjectSpecific(IDataExportRepository dqeRepo, ICatalogue catalogue, ExtractableDataSet extractableDataSet,IProject project)
68
        {
69
            bool usedInExtraction = project.ExtractionConfigurations.Where(ec => ec.SelectedDataSets.Select(sds => sds.ExtractableDataSet).Contains(extractableDataSet)).Any();
36✔
70
            if (!usedInExtraction) return true;
32✔
71
            if(usedInExtraction && extractableDataSet.Projects.Count ==1) return true;
10✔
72
            return false;
6✔
73
        }
74

75
        public static void MakeCatalogueNonProjectSpecific(IDataExportRepository dqeRepo, ICatalogue catalogue, ExtractableDataSet extractableDataSet, Project project)
76
        {
77
            if (project is null) return;
24!
NEW
78
            if (extractableDataSet is null) return;
×
NEW
79
            if (catalogue is null) return;
×
80

NEW
81
            var p = dqeRepo.GetAllObjects<ExtractableDataSetProject>().Where(edsp => edsp.ExtractableDataSet_ID == extractableDataSet.ID && edsp.Project_ID == project.ID).FirstOrDefault();
×
NEW
82
            if (p is not null)
×
83
            {
NEW
84
                p.DeleteInDatabase();
×
85
            }
NEW
86
            extractableDataSet.Projects.Remove(project);
×
87
            
NEW
88
            foreach (var ei in catalogue.GetAllExtractionInformation(ExtractionCategory.ProjectSpecific))
×
89
            {
NEW
90
                ei.ExtractionCategory = ExtractionCategory.Core;
×
NEW
91
                ei.SaveToDatabase();
×
92
            }
NEW
93
        }
×
94
    }
95
}
96

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