From d4e73c925464d5849d9689027c958901025212a6 Mon Sep 17 00:00:00 2001 From: Clay Benson Date: Thu, 23 May 2024 11:53:16 -0400 Subject: [PATCH] [NOREF] Add CEDAR System UUID (#2599) * Add CEDAR System UUID * Make uuid nullable * Added log for failed UUID parse * Set uuid to nil if failed to parse --- pkg/cedar/core/system_summary.go | 11 ++++ pkg/graph/generated/generated.go | 64 +++++++++++++++++++++++ pkg/graph/schema.graphql | 1 + pkg/local/cedarcoremock/system_summary.go | 5 ++ pkg/models/cedar_system.go | 1 + src/data/mock/systemProfile.ts | 1 + src/queries/GetSystemProfileQuery.ts | 1 + src/queries/types/GetSystemProfile.ts | 1 + 8 files changed, 85 insertions(+) diff --git a/pkg/cedar/core/system_summary.go b/pkg/cedar/core/system_summary.go index e6e3abada2..560b5d9e6e 100644 --- a/pkg/cedar/core/system_summary.go +++ b/pkg/cedar/core/system_summary.go @@ -4,7 +4,9 @@ import ( "context" "fmt" + "github.com/google/uuid" "github.com/guregu/null/zero" + "go.uber.org/zap" "github.com/cmsgov/easi-app/pkg/appcontext" "github.com/cmsgov/easi-app/pkg/apperrors" @@ -67,6 +69,14 @@ func (c *Client) GetSystemSummary(ctx context.Context, opts ...systemSummaryPara // Populate the SystemSummary field by converting each item in resp.Payload.SystemSummary for _, sys := range resp.Payload.SystemSummary { if sys.IctObjectID != nil { + uuid, uErr := uuid.Parse(sys.UUID) + uuidString := zero.StringFrom(uuid.String()) + // errors in parsing shouldn't stop the process, but we should log when it happens + if uErr != nil { + appcontext.ZLogger(ctx).Warn("failed to parse System UUID", zap.String("cedarUUID", sys.UUID)) + uuidString = zero.StringFromPtr(nil) + } + cedarSys := &models.CedarSystem{ VersionID: zero.StringFromPtr(sys.ID), Name: zero.StringFromPtr(sys.Name), @@ -78,6 +88,7 @@ func (c *Client) GetSystemSummary(ctx context.Context, opts ...systemSummaryPara SystemMaintainerOrg: zero.StringFrom(sys.SystemMaintainerOrg), SystemMaintainerOrgComp: zero.StringFrom(sys.SystemMaintainerOrgComp), ID: zero.StringFromPtr(sys.IctObjectID), + UUID: uuidString, } retVal = append(retVal, cedarSys) } diff --git a/pkg/graph/generated/generated.go b/pkg/graph/generated/generated.go index 0381701825..6c2735dc2b 100644 --- a/pkg/graph/generated/generated.go +++ b/pkg/graph/generated/generated.go @@ -355,6 +355,7 @@ type ComplexityRoot struct { Status func(childComplexity int) int SystemMaintainerOrg func(childComplexity int) int SystemMaintainerOrgComp func(childComplexity int) int + UUID func(childComplexity int) int VersionID func(childComplexity int) int } @@ -2971,6 +2972,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CedarSystem.SystemMaintainerOrgComp(childComplexity), true + case "CedarSystem.uuid": + if e.complexity.CedarSystem.UUID == nil { + break + } + + return e.complexity.CedarSystem.UUID(childComplexity), true + case "CedarSystem.versionId": if e.complexity.CedarSystem.VersionID == nil { break @@ -7566,6 +7574,7 @@ type CedarSystem { isBookmarked: Boolean! linkedTrbRequests: [TRBRequest!]! linkedSystemIntakes: [SystemIntake!]! + uuid: String } """ @@ -21855,6 +21864,47 @@ func (ec *executionContext) fieldContext_CedarSystem_linkedSystemIntakes(_ conte return fc, nil } +func (ec *executionContext) _CedarSystem_uuid(ctx context.Context, field graphql.CollectedField, obj *models.CedarSystem) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CedarSystem_uuid(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.UUID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(zero.String) + fc.Result = res + return ec.marshalOString2githubᚗcomᚋgureguᚋnullᚋzeroᚐString(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CedarSystem_uuid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CedarSystem", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _CedarSystemBookmark_euaUserId(ctx context.Context, field graphql.CollectedField, obj *models.CedarSystemBookmark) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CedarSystemBookmark_euaUserId(ctx, field) if err != nil { @@ -22010,6 +22060,8 @@ func (ec *executionContext) fieldContext_CedarSystemDetails_cedarSystem(_ contex return ec.fieldContext_CedarSystem_linkedTrbRequests(ctx, field) case "linkedSystemIntakes": return ec.fieldContext_CedarSystem_linkedSystemIntakes(ctx, field) + case "uuid": + return ec.fieldContext_CedarSystem_uuid(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CedarSystem", field.Name) }, @@ -33853,6 +33905,8 @@ func (ec *executionContext) fieldContext_Query_cedarSystem(ctx context.Context, return ec.fieldContext_CedarSystem_linkedTrbRequests(ctx, field) case "linkedSystemIntakes": return ec.fieldContext_CedarSystem_linkedSystemIntakes(ctx, field) + case "uuid": + return ec.fieldContext_CedarSystem_uuid(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CedarSystem", field.Name) }, @@ -33938,6 +33992,8 @@ func (ec *executionContext) fieldContext_Query_cedarSystems(_ context.Context, f return ec.fieldContext_CedarSystem_linkedTrbRequests(ctx, field) case "linkedSystemIntakes": return ec.fieldContext_CedarSystem_linkedSystemIntakes(ctx, field) + case "uuid": + return ec.fieldContext_CedarSystem_uuid(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CedarSystem", field.Name) }, @@ -34152,6 +34208,8 @@ func (ec *executionContext) fieldContext_Query_myCedarSystems(_ context.Context, return ec.fieldContext_CedarSystem_linkedTrbRequests(ctx, field) case "linkedSystemIntakes": return ec.fieldContext_CedarSystem_linkedSystemIntakes(ctx, field) + case "uuid": + return ec.fieldContext_CedarSystem_uuid(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CedarSystem", field.Name) }, @@ -39122,6 +39180,8 @@ func (ec *executionContext) fieldContext_SystemIntake_systems(_ context.Context, return ec.fieldContext_CedarSystem_linkedTrbRequests(ctx, field) case "linkedSystemIntakes": return ec.fieldContext_CedarSystem_linkedSystemIntakes(ctx, field) + case "uuid": + return ec.fieldContext_CedarSystem_uuid(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CedarSystem", field.Name) }, @@ -46693,6 +46753,8 @@ func (ec *executionContext) fieldContext_TRBRequest_systems(_ context.Context, f return ec.fieldContext_CedarSystem_linkedTrbRequests(ctx, field) case "linkedSystemIntakes": return ec.fieldContext_CedarSystem_linkedSystemIntakes(ctx, field) + case "uuid": + return ec.fieldContext_CedarSystem_uuid(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CedarSystem", field.Name) }, @@ -57821,6 +57883,8 @@ func (ec *executionContext) _CedarSystem(ctx context.Context, sel ast.SelectionS } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "uuid": + out.Values[i] = ec._CedarSystem_uuid(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } diff --git a/pkg/graph/schema.graphql b/pkg/graph/schema.graphql index 40fed9006d..e8266e6a21 100644 --- a/pkg/graph/schema.graphql +++ b/pkg/graph/schema.graphql @@ -182,6 +182,7 @@ type CedarSystem { isBookmarked: Boolean! linkedTrbRequests: [TRBRequest!]! linkedSystemIntakes: [SystemIntake!]! + uuid: String } """ diff --git a/pkg/local/cedarcoremock/system_summary.go b/pkg/local/cedarcoremock/system_summary.go index 42d2c577ce..846e088f7b 100644 --- a/pkg/local/cedarcoremock/system_summary.go +++ b/pkg/local/cedarcoremock/system_summary.go @@ -22,6 +22,7 @@ var mockSystems = map[string]*models.CedarSystem{ BusinessOwnerOrgComp: zero.StringFrom("IST"), SystemMaintainerOrg: zero.StringFrom("Division of Quality Assurance"), SystemMaintainerOrgComp: zero.StringFrom("DQA"), + UUID: zero.StringFrom("f5172597-1f9d-4930-9db1-a565a2994c61"), }, "{11AB1A00-1234-5678-ABC1-1A001B00CC1B}": { ID: zero.StringFrom("{11AB1A00-1234-5678-ABC1-1A001B00CC1B}"), @@ -34,6 +35,7 @@ var mockSystems = map[string]*models.CedarSystem{ BusinessOwnerOrgComp: zero.StringFrom("IST"), SystemMaintainerOrg: zero.StringFrom("Division of Quality Assurance"), SystemMaintainerOrgComp: zero.StringFrom("DQA"), + UUID: zero.StringFrom("44feed75-a837-4fe6-94f2-f9d24e56697b"), }, "{11AB1A00-1234-5678-ABC1-1A001B00CC2C}": { ID: zero.StringFrom("{11AB1A00-1234-5678-ABC1-1A001B00CC2C}"), @@ -46,6 +48,7 @@ var mockSystems = map[string]*models.CedarSystem{ BusinessOwnerOrgComp: zero.StringFrom("IST"), SystemMaintainerOrg: zero.StringFrom("Division of Quality Assurance"), SystemMaintainerOrgComp: zero.StringFrom("DQA"), + UUID: zero.StringFrom("81b4638f-fbb3-4bb0-a0a4-d16f03eb8cc0"), }, "{11AB1A00-1234-5678-ABC1-1A001B00CC3D}": { ID: zero.StringFrom("{11AB1A00-1234-5678-ABC1-1A001B00CC3D}"), @@ -58,6 +61,7 @@ var mockSystems = map[string]*models.CedarSystem{ BusinessOwnerOrgComp: zero.StringFrom("MMM"), SystemMaintainerOrg: zero.StringFrom("Division of Divisive Divergence"), SystemMaintainerOrgComp: zero.StringFrom("DODD"), + UUID: zero.StringFrom("3d167844-8f36-49f4-a5d7-8c55c9d7621c"), }, "{11AB1A00-1234-5678-ABC1-1A001B00CC4E}": { ID: zero.StringFrom("{11AB1A00-1234-5678-ABC1-1A001B00CC4E}"), @@ -70,6 +74,7 @@ var mockSystems = map[string]*models.CedarSystem{ BusinessOwnerOrgComp: zero.StringFrom("MMM"), SystemMaintainerOrg: zero.StringFrom("Division of Divisive Divergence"), SystemMaintainerOrgComp: zero.StringFrom("DODD"), + UUID: zero.StringFrom("46434d7c-5193-4a9d-82b1-0c4d3ceb4237"), }, } diff --git a/pkg/models/cedar_system.go b/pkg/models/cedar_system.go index 34837f86e3..d95021e92e 100644 --- a/pkg/models/cedar_system.go +++ b/pkg/models/cedar_system.go @@ -16,6 +16,7 @@ type CedarSystem struct { SystemMaintainerOrg zero.String `json:"systemMaintainerOrg"` SystemMaintainerOrgComp zero.String `json:"systemMaintainerOrgComp"` VersionID zero.String `json:"versionId"` + UUID zero.String `json:"uuid"` } // CedarSubSystem is the model for a sub system that comes back from the CEDAR Core API diff --git a/src/data/mock/systemProfile.ts b/src/data/mock/systemProfile.ts index 9eabbb57e0..f134e4f10e 100644 --- a/src/data/mock/systemProfile.ts +++ b/src/data/mock/systemProfile.ts @@ -690,6 +690,7 @@ export const result: { data: GetSystemProfile } = { businessOwnerOrgComp: 'OC', systemMaintainerOrg: 'Web and Emerging Technologies Group', systemMaintainerOrgComp: 'OC', + uuid: '0ab8fafa-6857-497b-87c1-e054d732bd5d', __typename: 'CedarSystem' }, deployments: [ diff --git a/src/queries/GetSystemProfileQuery.ts b/src/queries/GetSystemProfileQuery.ts index 9a04c12678..9c92d2c947 100644 --- a/src/queries/GetSystemProfileQuery.ts +++ b/src/queries/GetSystemProfileQuery.ts @@ -120,6 +120,7 @@ export default gql` businessOwnerOrgComp systemMaintainerOrg systemMaintainerOrgComp + uuid } deployments { id diff --git a/src/queries/types/GetSystemProfile.ts b/src/queries/types/GetSystemProfile.ts index 1d9f732f05..a65ff43759 100644 --- a/src/queries/types/GetSystemProfile.ts +++ b/src/queries/types/GetSystemProfile.ts @@ -131,6 +131,7 @@ export interface GetSystemProfile_cedarSystemDetails_cedarSystem { businessOwnerOrgComp: string | null; systemMaintainerOrg: string | null; systemMaintainerOrgComp: string | null; + uuid: string | null; } export interface GetSystemProfile_cedarSystemDetails_deployments_dataCenter {