Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flesh out SSG answers if needed to run the Deficiency Report #4044

Merged
merged 3 commits into from
Sep 11, 2024
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 @@ -112,6 +112,12 @@ public List<MatRelevantAnswers> GetQuestionsList(int? modelId = null)

_context.FillEmptyMaturityQuestionsForAnalysis(_assessmentId);

// flesh out model-specific questions
if (modelId != null)
{
_context.FillEmptyMaturityQuestionsForModel(_assessmentId, (int)modelId);
}

var query = from a in _context.ANSWER
join m in _context.MATURITY_QUESTIONS.Include(x => x.Maturity_Level)
on a.Question_Or_Requirement_Id equals m.Mat_Question_Id
Expand Down Expand Up @@ -175,6 +181,8 @@ on a.Question_Or_Requirement_Id equals m.Mat_Question_Id

/// <summary>
/// Returns a list of MatRelevantAnswers that are considered deficient for the assessment.
///
/// TODO: Move the hard-coded deficient values to some kind of JSON file or config.
/// </summary>
/// <returns></returns>
public List<MatRelevantAnswers> GetMaturityDeficiencies(int? modelId = null)
Expand Down
24 changes: 24 additions & 0 deletions CSETWebApi/CSETWeb_Api/CSETWebCore.DataLayer/Manual/CSETContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,30 @@ public virtual int FillEmptyMaturityQuestionsForAnalysis(Nullable<int> assessmen
}


/// <summary>
/// Insert empty questions for Maturity model questions for a specified model.
/// This is designed for use with SSG questions.
/// </summary>
/// <param name="assessment_Id"></param>
/// <returns></returns>
public virtual int FillEmptyMaturityQuestionsForModel(Nullable<int> assessmentId, int modelId)
{
if (!assessmentId.HasValue)
throw new ApplicationException("parameters may not be null");

int myrval = 0;
this.LoadStoredProc("FillEmptyMaturityQuestionsForModel")
.WithSqlParam("Assessment_Id", assessmentId)
.WithSqlParam("Model_Id", modelId)

.ExecuteStoredProc((handler) =>
{
myrval = handler.ReadToValue<int>() ?? 0;
});
return myrval;
}


/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ο»Ώ// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using Microsoft.EntityFrameworkCore;
using System;
using System.Data;
using System.Linq;
using CSETWebCore.DataLayer.Model;

namespace CSETWebCore.DataLayer.Model
{
public partial class CsetwebContext
{

[DbFunction("convert_sal", "dbo")]
public static string convert_sal(string SAL)
{
throw new NotSupportedException("This method can only be called from Entity Framework Core queries");
}

[DbFunction("convert_sal_short", "dbo")]
public static string convert_sal_short(string SAL)
{
throw new NotSupportedException("This method can only be called from Entity Framework Core queries");
}

[DbFunction("func_AM", "dbo")]
public IQueryable<func_AMResult> func_AM(int? assessmentId)
{
return FromExpression(() => func_AM(assessmentId));
}

[DbFunction("func_MQ", "dbo")]
public IQueryable<func_MQResult> func_MQ(int? assessmentId)
{
return FromExpression(() => func_MQ(assessmentId));
}



protected void OnModelCreatingGeneratedFunctions(ModelBuilder modelBuilder)
{
modelBuilder.Entity<func_AMResult>().HasNoKey();
modelBuilder.Entity<func_MQResult>().HasNoKey();
modelBuilder.Entity<SplitResult>().HasNoKey();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ public CsetwebContext(DbContextOptions<CsetwebContext> options)

public virtual DbSet<INSTALLATION> INSTALLATION { get; set; }

public virtual DbSet<INTERNATIONALIZATION_VALUES> INTERNATIONALIZATION_VALUES { get; set; }

public virtual DbSet<IRP> IRP { get; set; }

public virtual DbSet<IRP_HEADER> IRP_HEADER { get; set; }
Expand Down Expand Up @@ -2788,7 +2786,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
});
modelBuilder.HasSequence<int>("MaturityNodeSequence");

OnModelCreatingGeneratedProcedures(modelBuilder);
OnModelCreatingGeneratedFunctions(modelBuilder);
OnModelCreatingPartial(modelBuilder);
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace CSETWebCore.DataLayer.Model
{
public static class DbContextExtensions
{
public static async Task<List<T>> SqlQueryAsync<T>(this DbContext db, string sql, object[] parameters = null, CancellationToken cancellationToken = default) where T : class
public static async Task<List<T>> SqlQueryAsync<T>(this DbContext db, string sql, object[] parameters = null, CancellationToken cancellationToken = default)
where T : class
{
if (parameters is null)
{
Expand All @@ -22,7 +23,9 @@ public static async Task<List<T>> SqlQueryAsync<T>(this DbContext db, string sql

if (typeof(T).GetProperties().Any())
{
return await db.Set<T>().FromSqlRaw(sql, parameters).ToListAsync(cancellationToken);
return await db.Database
.SqlQueryRaw<T>(sql, parameters)
.ToListAsync(cancellationToken);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ο»Ώ// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace CSETWebCore.DataLayer.Model
{
public partial class GetAnswerCountsForGroupingsResult
{
public string Title { get; set; }
public int? Sequence { get; set; }
public int? Grouping_Id { get; set; }
public int? Parent_Id { get; set; }
public string Answer_Text { get; set; }
public int? AnsCount { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,70 @@ public partial class Get_Cie_Merge_ConflictsResult
public int? Assessment_id1 { get; set; }
public int? Question_Or_Requirement_Id1 { get; set; }
public string Answer_Text1 { get; set; }
public string Feedback1 { get; set; }
public string Comment1 { get; set; }
public string Free_Response_Answer1 { get; set; }
public string Assessment_Name2 { get; set; }
public int? Assessment_id2 { get; set; }
public int? Question_Or_Requirement_Id2 { get; set; }
public string Answer_Text2 { get; set; }
public string Feedback2 { get; set; }
public string Comment2 { get; set; }
public string Free_Response_Answer2 { get; set; }
public string Assessment_Name3 { get; set; }
public int? Assessment_id3 { get; set; }
public int? Question_Or_Requirement_Id3 { get; set; }
public string Answer_Text3 { get; set; }
public string Feedback3 { get; set; }
public string Comment3 { get; set; }
public string Free_Response_Answer3 { get; set; }
public string Assessment_Name4 { get; set; }
public int? Assessment_id4 { get; set; }
public int? Question_Or_Requirement_Id4 { get; set; }
public string Answer_Text4 { get; set; }
public string Feedback4 { get; set; }
public string Comment4 { get; set; }
public string Free_Response_Answer4 { get; set; }
public string Assessment_Name5 { get; set; }
public int? Assessment_id5 { get; set; }
public int? Question_Or_Requirement_Id5 { get; set; }
public string Answer_Text5 { get; set; }
public string Feedback5 { get; set; }
public string Comment5 { get; set; }
public string Free_Response_Answer5 { get; set; }
public string Assessment_Name6 { get; set; }
public int? Assessment_id6 { get; set; }
public int? Question_Or_Requirement_Id6 { get; set; }
public string Answer_Text6 { get; set; }
public string Feedback6 { get; set; }
public string Comment6 { get; set; }
public string Free_Response_Answer6 { get; set; }
public int? Assessment_id7 { get; set; }
public string Assessment_Name7 { get; set; }
public int? Question_Or_Requirement_Id7 { get; set; }
public string Answer_Text7 { get; set; }
public string Feedback7 { get; set; }
public string Comment7 { get; set; }
public string Free_Response_Answer7 { get; set; }
public string Assessment_Name8 { get; set; }
public int? Assessment_id8 { get; set; }
public int? Question_Or_Requirement_Id8 { get; set; }
public string Answer_Text8 { get; set; }
public string Feedback8 { get; set; }
public string Comment8 { get; set; }
public string Free_Response_Answer8 { get; set; }
public string Assessment_Name9 { get; set; }
public int? Assessment_id9 { get; set; }
public int? Question_Or_Requirement_Id9 { get; set; }
public string Answer_Text9 { get; set; }
public string Feedback9 { get; set; }
public string Comment9 { get; set; }
public string Free_Response_Answer9 { get; set; }
public string Assessment_Name10 { get; set; }
public int? Assessment_id10 { get; set; }
public int? Question_Or_Requirement_Id10 { get; set; }
public string Answer_Text10 { get; set; }
public string Feedback10 { get; set; }
public string Comment10 { get; set; }
public string Free_Response_Answer10 { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
ο»Ώ// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
Expand All @@ -16,102 +16,59 @@ public partial class Get_Merge_ConflictsResult
public string Answer_Text1 { get; set; }
public string Comment1 { get; set; }
public string Alt_Text1 { get; set; }

public string Feedback1 { get; set; }
public string Free_Response_Answer1 { get; set; }


public string Assessment_Name2 { get; set; }
public int? Assessment_id2 { get; set; }
public int? Question_Or_Requirement_Id2 { get; set; }
public string Answer_Text2 { get; set; }
public string Comment2 { get; set; }
public string Alt_Text2 { get; set; }

public string Feedback2 { get; set; }
public string Free_Response_Answer2 { get; set; }

public string Assessment_Name3 { get; set; }
public int? Assessment_id3 { get; set; }
public int? Question_Or_Requirement_Id3 { get; set; }
public string Answer_Text3 { get; set; }
public string Comment3 { get; set; }
public string Alt_Text3 { get; set; }

public string Feedback3 { get; set; }
public string Free_Response_Answer3 { get; set; }

public string Assessment_Name4 { get; set; }
public int? Assessment_id4 { get; set; }
public int? Question_Or_Requirement_Id4 { get; set; }
public string Answer_Text4 { get; set; }
public string Comment4 { get; set; }
public string Alt_Text4 { get; set; }

public string Feedback4 { get; set; }
public string Free_Response_Answer4 { get; set; }

public string Assessment_Name5 { get; set; }
public int? Assessment_id5 { get; set; }
public int? Question_Or_Requirement_Id5 { get; set; }
public string Answer_Text5 { get; set; }
public string Comment5 { get; set; }
public string Alt_Text5 { get; set; }

public string Feedback5 { get; set; }
public string Free_Response_Answer5 { get; set; }


public string Assessment_Name6 { get; set; }
public int? Assessment_id6 { get; set; }
public int? Question_Or_Requirement_Id6 { get; set; }
public string Answer_Text6 { get; set; }
public string Comment6 { get; set; }
public string Alt_Text6 { get; set; }

public string Feedback6 { get; set; }
public string Free_Response_Answer6 { get; set; }

public int? Assessment_id7 { get; set; }
public string Assessment_Name7 { get; set; }
public int? Question_Or_Requirement_Id7 { get; set; }
public string Answer_Text7 { get; set; }
public string Comment7 { get; set; }
public string Alt_Text7 { get; set; }

public string Feedback7 { get; set; }
public string Free_Response_Answer7 { get; set; }

public string Assessment_Name8 { get; set; }
public int? Assessment_id8 { get; set; }
public int? Question_Or_Requirement_Id8 { get; set; }
public string Answer_Text8 { get; set; }
public string Comment8 { get; set; }

public string Alt_Text8 { get; set; }

public string Feedback8 { get; set; }
public string Free_Response_Answer8 { get; set; }

public string Assessment_Name9 { get; set; }
public int? Assessment_id9 { get; set; }
public int? Question_Or_Requirement_Id9 { get; set; }
public string Answer_Text9 { get; set; }
public string Comment9 { get; set; }
public string Alt_Text9 { get; set; }

public string Feedback9 { get; set; }
public string Free_Response_Answer9 { get; set; }

public string Assessment_Name10 { get; set; }
public int? Assessment_id10 { get; set; }
public int? Question_Or_Requirement_Id10 { get; set; }
public string Answer_Text10 { get; set; }
public string Comment10 { get; set; }
public string Alt_Text10 { get; set; }

public string Feedback10 { get; set; }
public string Free_Response_Answer10 { get; set; }

}
}
Loading
Loading