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

HicServices / RDMP / 19852309549

02 Dec 2025 08:38AM UTC coverage: 55.8% (-1.4%) from 57.197%
19852309549

Pull #2279

github

JFriel
fix build
Pull Request #2279: [UI Overhaul] Spike/refresh

11249 of 21727 branches covered (51.77%)

Branch coverage included in aggregate %.

807 of 1108 new or added lines in 29 files covered. (72.83%)

724 existing lines in 67 files now uncovered.

31893 of 55588 relevant lines covered (57.37%)

16683.65 hits per line

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

58.7
/Rdmp.Core/DataExport/Data/ProjectCohortIdentificationConfigurationAssociation.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.Generic;
9
using System.Data.Common;
10
using System.Linq;
11
using Rdmp.Core.Curation.Data;
12
using Rdmp.Core.Curation.Data.Cohort;
13
using Rdmp.Core.MapsDirectlyToDatabaseTable;
14
using Rdmp.Core.MapsDirectlyToDatabaseTable.Injection;
15
using Rdmp.Core.Repositories;
16

17
namespace Rdmp.Core.DataExport.Data;
18

19
/// <inheritdoc cref="IProjectCohortIdentificationConfigurationAssociation"/>
20
public class ProjectCohortIdentificationConfigurationAssociation : DatabaseEntity,
21
    IProjectCohortIdentificationConfigurationAssociation, IInjectKnown<CohortIdentificationConfiguration>
22
{
23
    #region Database Properties
24

25
    private int _project_ID;
26
    private int _cohortIdentificationConfiguration_ID;
27

28
    #endregion
29

30
    /// <inheritdoc/>
31
    public int Project_ID
32
    {
33
        get => _project_ID;
46✔
34
        set => SetField(ref _project_ID, value);
92✔
35
    }
36

37
    /// <summary>
38
    /// The <see cref="Curation.Data.Cohort.CohortIdentificationConfiguration"/> which is associated with the given <see cref="Project_ID"/>.
39
    /// </summary>
40
    public int CohortIdentificationConfiguration_ID
41
    {
42
        get => _cohortIdentificationConfiguration_ID;
92✔
43
        set => SetField(ref _cohortIdentificationConfiguration_ID, value);
92✔
44
    }
45

46

47
    #region Relationships
48

49
    /// <inheritdoc cref="Project_ID"/>
50
    [NoMappingToDatabase]
51
    public IProject Project => Repository.GetObjectByID<Project>(Project_ID);
8✔
52

53
    private Lazy<CohortIdentificationConfiguration> _knownCic;
54

55
    /// <inheritdoc cref="CohortIdentificationConfiguration_ID"/>
56
    [NoMappingToDatabase]
57
    public CohortIdentificationConfiguration CohortIdentificationConfiguration =>
58
        //handles the object having been deleted and somehow that deletion is missed
59
        _knownCic.Value;
28✔
60

61
    #endregion
62

63
    public ProjectCohortIdentificationConfigurationAssociation()
×
64
    {
65
        ClearAllInjections();
×
66
    }
×
67

68
    /// <summary>
69
    /// Declares in the <paramref name="repository"/> database that the given <paramref name="cic"/> cohort query is associated with the supplied <paramref name="project"/>.
70
    /// This is usually done after using the query to build an <see cref="IExtractableCohort"/> (But it can be done manually by the user too).
71
    /// </summary>
72
    /// <param name="repository"></param>
73
    /// <param name="project"></param>
74
    /// <param name="cic"></param>
75
    public ProjectCohortIdentificationConfigurationAssociation(IDataExportRepository repository, Project project,
32✔
76
        CohortIdentificationConfiguration cic)
32✔
77
    {
78
        repository.InsertAndHydrate(this, new Dictionary<string, object>
32✔
79
        {
32✔
80
            { "Project_ID", project.ID },
32✔
81
            { "CohortIdentificationConfiguration_ID", cic.ID }
32✔
82
        });
32✔
83

84
        if (ID == 0 || Repository != repository)
32!
85
            throw new ArgumentException("Repository failed to properly hydrate this class");
×
86

87
        ClearAllInjections();
32✔
88
    }
32✔
89

90
    internal ProjectCohortIdentificationConfigurationAssociation(IDataExportRepository repository, DbDataReader r)
91
        : base(repository, r)
60✔
92
    {
93
        Project_ID = Convert.ToInt32(r["Project_ID"]);
60✔
94
        CohortIdentificationConfiguration_ID = Convert.ToInt32(r["CohortIdentificationConfiguration_ID"]);
60✔
95

96
        ClearAllInjections();
60✔
97
    }
60✔
98

99

100
    public void InjectKnown(CohortIdentificationConfiguration instance)
101
    {
UNCOV
102
        _knownCic = new Lazy<CohortIdentificationConfiguration>(instance);
×
UNCOV
103
    }
×
104

105
    public void ClearAllInjections()
106
    {
107
        _knownCic = new Lazy<CohortIdentificationConfiguration>(FetchCohortIdentificationConfiguration);
94✔
108
    }
94✔
109

110
    private CohortIdentificationConfiguration FetchCohortIdentificationConfiguration() =>
111
        DataExportRepository.CatalogueRepository.GetAllObjectsWhere<CohortIdentificationConfiguration>("ID",
16✔
112
            CohortIdentificationConfiguration_ID).SingleOrDefault();
16✔
113

114

115
    /// <summary>
116
    /// Returns the associated <see cref="CohortIdentificationConfiguration_ID"/> Name
117
    /// </summary>
118
    /// <returns></returns>
119
    public override string ToString()
120
    {
121
        var assoc = CohortIdentificationConfiguration;
×
122
        return assoc == null ? "Orphan Association" : assoc.Name;
×
123
    }
124

125
    public bool ShouldBeReadOnly(string context, out string reason)
126
    {
127
        reason = null;
×
128
        return CohortIdentificationConfiguration?.ShouldBeReadOnly(context,out reason) ?? false;
×
129
    }
130

131
    /// <inheritdoc/>
132
    public string GetDeleteMessage() => "remove CohortIdentificationConfiguration from the Project";
×
133

134
    /// <inheritdoc/>
135
    public string GetDeleteVerb() => "Remove";
×
136

137
    /// <summary>
138
    /// Returns the <see cref="CohortIdentificationConfiguration_ID"/>
139
    /// </summary>
140
    /// <returns></returns>
UNCOV
141
    public object MasqueradingAs() => CohortIdentificationConfiguration;
×
142
}
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