Skip to content

Commit

Permalink
[NOREF] Add CEDAR System UUID (#2599)
Browse files Browse the repository at this point in the history
* Add CEDAR System UUID

* Make uuid nullable

* Added log for failed UUID parse

* Set uuid to nil if failed to parse
  • Loading branch information
ClayBenson94 committed May 23, 2024
1 parent d511928 commit d4e73c9
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/cedar/core/system_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand All @@ -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)
}
Expand Down
64 changes: 64 additions & 0 deletions pkg/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/graph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ type CedarSystem {
isBookmarked: Boolean!
linkedTrbRequests: [TRBRequest!]!
linkedSystemIntakes: [SystemIntake!]!
uuid: String
}

"""
Expand Down
5 changes: 5 additions & 0 deletions pkg/local/cedarcoremock/system_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
Expand All @@ -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}"),
Expand All @@ -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}"),
Expand All @@ -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}"),
Expand All @@ -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"),
},
}

Expand Down
1 change: 1 addition & 0 deletions pkg/models/cedar_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/data/mock/systemProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
1 change: 1 addition & 0 deletions src/queries/GetSystemProfileQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default gql`
businessOwnerOrgComp
systemMaintainerOrg
systemMaintainerOrgComp
uuid
}
deployments {
id
Expand Down
1 change: 1 addition & 0 deletions src/queries/types/GetSystemProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d4e73c9

Please sign in to comment.