Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void GetDemographics_ReturnsBasicDemographics_WhenNoExtendedDataExists()
// Assert
Assert.NotNull(result);
Assert.Equal(assessmentId, result.AssessmentId);
Assert.Empty(result.SsgSectorIds);
Assert.Empty(result.SsgModelIds);
}

[Fact]
Expand Down Expand Up @@ -278,10 +278,10 @@ public void GetDemographics_LoadsSsgSectors_WhenSsgDataExists()

// Assert
Assert.NotNull(result);
Assert.Equal(3, result.SsgSectorIds.Count);
Assert.Contains(1, result.SsgSectorIds);
Assert.Contains(2, result.SsgSectorIds);
Assert.Contains(3, result.SsgSectorIds);
Assert.Equal(3, result.SsgModelIds.Count);
Assert.Contains(1, result.SsgModelIds);
Assert.Contains(2, result.SsgModelIds);
Assert.Contains(3, result.SsgModelIds);
}

[Fact]
Expand Down Expand Up @@ -321,7 +321,7 @@ public void SaveDemographics_RemovesAndReplacesSSGSectors()
var demographics = new Demographics
{
AssessmentId = assessmentId,
SsgSectorIds = new List<int> { 1, 2, 3 }
SsgModelIds = new List<int> { 1, 2, 3 }
};

var existingSSG = new List<DETAILS_DEMOGRAPHICS>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Demographics GetDemographics(int assessmentId)
}


demographics.SsgSectorIds.AddRange(new CpgBusiness(_context, "en").DetermineSsgModels(assessmentId));
demographics.SsgModelIds.AddRange(new CpgBusiness(_context, "en").DetermineSsgModels(assessmentId));



Expand Down
34 changes: 17 additions & 17 deletions CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Maturity/CpgBusiness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,33 +123,33 @@ private List<Series> InitializeSeries()
/// <summary>
/// Figures out if an SSG model is applicable as a bonus.
/// The SSG is based on the assessment's sector.
/// Returns null if no SSG is applicable.
/// Returns an empty list if no SSG is applicable.
/// </summary>
/// <returns></returns>
public List<int> DetermineSsgModels(int assessmentId)
{
List<int> list = [];

var ddSectors = _context.ASSESSMENT_SECTOR_SUBSECTOR.Where(x => x.Assessment_Id == assessmentId).ToList();

foreach (var s in ddSectors)
var sectorToModelMap = new Dictionary<int, int>
{
// CHEMICAL
var chemicalSectors = new List<int>() { 1, 19 };
if (chemicalSectors.Contains((int)s.SectorId))
{
list.Add(Constants.Constants.Model_SSG_CHEM);
}
{ 1, Constants.Constants.Model_SSG_CHEM },
{ 19, Constants.Constants.Model_SSG_CHEM },
{ 13, Constants.Constants.Model_SSG_IT },
{ 28, Constants.Constants.Model_SSG_IT },
};

var ssgModels = new HashSet<int>();
var sectors = _context.ASSESSMENT_SECTOR_SUBSECTOR
.Where(x => x.Assessment_Id == assessmentId)
.ToList();

// INFORMATION TECHNOLOGY (IT)
var itSectors = new List<int>() { 13, 28 };
if (itSectors.Contains((int)s.SectorId))
foreach (var sector in sectors)
{
if (sectorToModelMap.TryGetValue((int)sector.SectorId, out var modelId))
{
list.Add(Constants.Constants.Model_SSG_IT);
ssgModels.Add(modelId);
}
}

return list;
return ssgModels.ToList();
}


Expand Down
2 changes: 1 addition & 1 deletion CSETWebApi/CSETWeb_Api/CSETWebCore.Helpers/CpgStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void LoadStructure()
Top.ModelName = mm.Model_Name;
Top.ModelId = (int)this.ModelId;

Top.TechDomain = _context.DETAILS_DEMOGRAPHICS.Where(x => x.DataItemName == "TECH-DOMAIN").FirstOrDefault()?.StringValue ?? null;
Top.TechDomain = _context.DETAILS_DEMOGRAPHICS.Where(x => x.Assessment_Id == this.AssessmentId && x.DataItemName == "TECH-DOMAIN").FirstOrDefault()?.StringValue ?? null;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ private void GetSubgroups(object oParent, int? parentID)
DisplayNumber = myQ.Question_Title,
ParentQuestionId = myQ.Parent_Question_Id,
QuestionType = myQ.Mat_Question_Type,
IsAnswerable = myQ.Is_Answerable,
AnswerText = answer?.Answer_Text,
AltAnswerText = answer?.Alternate_Justification,
Comment = answer?.Comment,
Expand Down Expand Up @@ -260,6 +261,9 @@ private List<Question> GetFollowupQuestions(int parentId)
DisplayNumber = myQ.Question_Title,
ParentQuestionId = myQ.Parent_Question_Id,
QuestionType = myQ.Mat_Question_Type,
IsAnswerable = myQ.Is_Answerable,
AnswerText = answer?.Answer_Text,
AltAnswerText = answer?.Alternate_Justification,
Comment = answer?.Comment ?? "",
Options = GetOptions(myQ.Mat_Question_Id)
};
Expand Down Expand Up @@ -323,6 +327,7 @@ private List<Option> GetOptions(int questionId)
ParentQuestionId = myQ.Parent_Question_Id,
ParentOptionId = myQ.Parent_Option_Id,
QuestionType = myQ.Mat_Question_Type,
IsAnswerable = myQ.Is_Answerable,
Options = GetOptions(myQ.Mat_Question_Id)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public class Demographics
public List<SectorSubsector> SectorSubsectors { get; set; } = [];


public List<int> SsgSectorIds { get; set; } = [];
/// <summary>
/// The list of all in-scope SSG models due to the assessment's
/// current state.
/// </summary>
public List<int> SsgModelIds { get; set; } = [];


public int? Size { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public IActionResult Post([FromBody] Demographics demographics)
});
}

return Ok(assessmentId);
return Ok(_demographic.GetDemographics(assessmentId));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class AssessmentConfigIodComponent implements OnInit {
ngOnInit() {
this.demoSvc.getDemographic().subscribe((data: any) => {
this.demographics = data;
this.assessSvc.assessment.ssgModelIds = data.ssgModelIds;
});

this.iodDemoSvc.getDemographics().subscribe((data: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ export class AssessmentDemographicsComponent implements OnInit {
if (this.demoSvc.id) {
this.getDemographics();
}

this.refreshContacts();
this.getOrganizationTypes();
}

// Functionality to import demographic information, excluding contacts, organization point of contact, facilitator, critical service point of contact
/**
* Functionality to import demographic information, excluding contacts,
* organization point of contact, facilitator, critical service point of contact
*/
importClick(event) {
let dialogRef = null;
this.unsupportedImportFile = false;
Expand All @@ -134,19 +138,12 @@ export class AssessmentDemographicsComponent implements OnInit {
}


//Functionality to export demographic information, excluding contacts, organization point of contact, facilitator, critical service point of contact
exportClick() {
this.demoSvc.exportDemographics()
}

/**
*
* Functionality to export demographic information, excluding contacts,
* organization point of contact, facilitator, critical service point of contact
*/
onChangeSsg(list: number[]) {
this.demographicData.ssgSectorIds = list;
this.assessSvc.assessment.ssgSectorIds = list;
this.assessSvc.assessmentStateChanged$.next(this.c.NAV_REFRESH_TREE_ONLY);
this.updateDemographics();
exportClick() {
this.demoSvc.exportDemographics()
}

/**
Expand All @@ -156,6 +153,8 @@ export class AssessmentDemographicsComponent implements OnInit {
this.demoSvc.getDemographic().subscribe(
(data: Demographic) => {
this.demographicData = data;
this.assessSvc.assessment.ssgModelIds = data.ssgModelIds;

if (this.demographicData.organizationType == "3") {
this.isSLTT = true;
}
Expand Down Expand Up @@ -225,7 +224,6 @@ export class AssessmentDemographicsComponent implements OnInit {
&& (moduleBehavior?.showCriticalServiceDemog ?? true);
}


showEdmFields() {
return this.assessSvc.assessment?.maturityModel?.modelName == 'EDM';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class AssessmentDetailComponent implements OnInit {

this.demoSvc.getDemographic().subscribe((data: any) => {
this.demographics = data;
this.assessSvc.assessment.ssgModelIds = data.ssgModelIds;


if (data.acknowledgement == true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ export class DemographicsIodComponent implements OnInit {
})
}

/**
*
*/
onChangeSsg(list: number[]) {
this.demographicData.ssgSectors = list;
this.assessSvc.assessment.ssgSectorIds = list;
this.assessSvc.assessmentStateChanged$.next(this.c.NAV_REFRESH_TREE_ONLY);
this.updateDemographics();
}

/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
import { CsiService } from '../../../../services/cis-csi.service';
import { ConfigService } from './../../../../services/config.service';
import { DemographicService } from '../../../../services/demographic.service';
import { AssessmentService } from '../../../../services/assessment.service';

@Component({
selector: 'app-csi-service-demographics',
Expand Down Expand Up @@ -92,7 +93,12 @@ export class CsiServiceDemographicsComponent implements OnInit {

demographics: any = {};

constructor(private csiSvc: CsiService, private demoSvc: DemographicService, private configSvc: ConfigService) { }
constructor(
private assessSvc: AssessmentService,
private csiSvc: CsiService,
private demoSvc: DemographicService,
private configSvc: ConfigService
) { }

ngOnInit(): void {
this.csiSvc.getAllCsiBudgetBases().subscribe(
Expand Down Expand Up @@ -136,6 +142,7 @@ export class CsiServiceDemographicsComponent implements OnInit {

this.demoSvc.getDemographic().subscribe((data: any) => {
this.demographics = data;
this.assessSvc.assessment.ssgModelIds = data.ssgModelIds;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
////////////////////////////////
import { Component, OnInit } from '@angular/core';
import { SsgService } from '../../../../services/ssg.service';
import { AssessmentService } from '../../../../services/assessment.service';

@Component({
selector: 'app-cpg-practices',
Expand All @@ -38,6 +39,7 @@ export class CpgPracticesComponent implements OnInit {
*
*/
constructor(
public assessSvc: AssessmentService,
public ssgSvc: SsgService
) { }

Expand All @@ -46,7 +48,7 @@ export class CpgPracticesComponent implements OnInit {
*
*/
ngOnInit(): void {
this.ssgBonusModels = this.ssgSvc.activeSsgModelIds;
this.ssgBonusModels = this.assessSvc.assessment.ssgModelIds;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
<div>
<div class="white-panel d-flex flex-column flex-11a" *transloco="let t">
<h3 class="d-flex flex-column flex-00a">{{t('reports.core.cpg.report.performance summary')}}</h3>
<p>
<p class="mb-5">
{{t('reports.core.cpg.report.p.a')}}
</p>


<div *ngIf="assessorWorkflow">
<div *ngIf="assessorWorkflow" class="mb-5">
<h4>
{{t('reports.core.cpg.report.compliance score')}}
</h4>
Expand All @@ -50,15 +50,15 @@ <h4>

<!-- CPG 2.0 chart/table -->
<ng-container *ngIf="modelId == 21">
<div class="mb-4" *ngIf="techDomain == 'OT' || techDomain == 'OT+IT' || techDomain == null">
<div class="mb-5" *ngIf="techDomain == 'OT' || techDomain == 'OT+IT' || techDomain == null">
<h4>{{t('reports.core.cpg.ot')}}</h4>
<app-cpg-domain-summary [distrib]="answerDistribByDomainOt?.distrib"></app-cpg-domain-summary>

<p>{{t('reports.core.cpg.report.p.2')}}</p>
<app-cpg-domain-summary-table [data]="answerDistribByDomainOt?.distrib"></app-cpg-domain-summary-table>
</div>

<div class="mb-4" *ngIf="techDomain == 'IT' || techDomain == 'OT+IT' || techDomain == null">
<div class="mb-5" *ngIf="techDomain == 'IT' || techDomain == 'OT+IT' || techDomain == null">
<h4>{{t('reports.core.cpg.it')}}</h4>
<app-cpg-domain-summary [distrib]="answerDistribByDomainIt?.distrib"></app-cpg-domain-summary>

Expand All @@ -70,7 +70,7 @@ <h4>{{t('reports.core.cpg.it')}}</h4>

<!-- SSG chart/table -->
<ng-container *ngFor="let s of answerDistribsSsg">
<div class="mt-4 mb-4">
<div class="mt-4 mb-5">
<h4>{{ t('reports.core.cpg.report.ssg.2') }} - {{t(`reports.core.ssg.${s.modelId}`)}}</h4>
<app-cpg-domain-summary [distrib]="s.distribution"></app-cpg-domain-summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class CpgSummaryComponent implements OnInit {
this.assessorWorkflow = this.assessSvc.assessment.assessorMode ?? false;

var demog: Demographic = await firstValueFrom(this.demoSvc.getDemographic());
this.assessSvc.assessment.ssgModelIds = demog.ssgModelIds;
this.techDomain = demog.techDomain;

// CPG 1.1
Expand All @@ -94,7 +95,7 @@ export class CpgSummaryComponent implements OnInit {
}

// SSG
const ssgPromises = this.ssgSvc.activeSsgModelIds.map(async id => {
const ssgPromises = this.assessSvc.assessment.ssgModelIds.map(async id => {
const d = await this.getAnswerDistribution(id, '');
return {
modelId: id,
Expand Down
4 changes: 2 additions & 2 deletions CSETWebNg/src/app/models/assessment-info.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface AssessmentDetail {

// sectors
sectorSubsectors?: SectorSub[];
ssgSectorIds?: number[];
ssgModelIds?: number[];


useStandard?: boolean;
Expand Down Expand Up @@ -125,7 +125,7 @@ export interface Demographic {
industryId?: number;
sectorSubsectors?: SectorSub[];

ssgSectorIds?: number[];
ssgModelIds?: number[];

size?: number;
assetValue?: number;
Expand Down
2 changes: 1 addition & 1 deletion CSETWebNg/src/app/models/demographics-iod.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface DemographicsIod {
sectorSubsectors?: SectorSub[];


ssgSectors?: number[];
// TODO-3261 ssgSectors?: number[];

// Technology Domain (IT vs OT)
techDomain?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class CpgDeficiencyComponent implements OnInit {
*/
getSsgModels() {
this.loadingSsg = true;
this.ssgBonusModels = this.ssgSvc.activeSsgModelIds;
this.ssgBonusModels = this.assessSvc.assessment.ssgModelIds;

const obs: Observable<any>[] = [];
this.ssgBonusModels.forEach(m => obs.push(this.maturitySvc.getMaturityDeficiency(m)));
Expand Down
Loading