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

HicServices / RDMP / 19129669231

06 Nov 2025 08:36AM UTC coverage: 57.107% (-0.2%) from 57.309%
19129669231

push

github

JFriel
bump version

11418 of 21469 branches covered (53.18%)

Branch coverage included in aggregate %.

32412 of 55282 relevant lines covered (58.63%)

17597.55 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);
660✔
21

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

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

43
            return true;
482✔
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
            {
51
                eds = new ExtractableDataSet(dqeRepo, catalogue, false);
×
52
                eds.SaveToDatabase();
×
53
            }
54

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

65
        public static bool CanMakeCatalogueNonProjectSpecific(IDataExportRepository dqeRepo, ICatalogue catalogue, ExtractableDataSet extractableDataSet, IProject project)
66
        {
67
            bool usedInExtraction = project.ExtractionConfigurations.Where(ec => ec.SelectedDataSets.Select(sds => sds.ExtractableDataSet).Contains(extractableDataSet)).Any();
28✔
68
            if (!usedInExtraction) return true;
26✔
69
            if (usedInExtraction && extractableDataSet.Projects.Count == 1) return true;
8✔
70
            return false;
4✔
71
        }
72

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

79
            var p = dqeRepo.GetAllObjects<ExtractableDataSetProject>().Where(edsp => edsp.ExtractableDataSet_ID == extractableDataSet.ID && edsp.Project_ID == project.ID).FirstOrDefault();
×
80
            if (p is not null)
×
81
            {
82
                p.DeleteInDatabase();
×
83
            }
84
            extractableDataSet.Projects.Remove(project);
×
85

86
            foreach (var ei in catalogue.GetAllExtractionInformation(ExtractionCategory.ProjectSpecific))
×
87
            {
88
                ei.ExtractionCategory = ExtractionCategory.Core;
×
89
                ei.SaveToDatabase();
×
90
            }
91
        }
×
92
    }
93
}
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