-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ODS-6502] Update security metadata for StudentContactAssociation (#1157
- Loading branch information
1 parent
dd998d2
commit 8bc4237
Showing
12 changed files
with
210 additions
and
778 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...rd/4.0.0/Artifacts/MsSql/Data/Security/2190-StudentParentAssociation-ClaimName-Update.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
BEGIN | ||
DECLARE | ||
@claimId AS INT, | ||
@claimName AS nvarchar(max), | ||
@parentResourceClaimId AS INT, | ||
@existingParentResourceClaimId AS INT | ||
|
||
BEGIN TRANSACTION | ||
|
||
|
||
---------------------------------------------------------------------------------------------------------------------------- | ||
-- Resource Claim: 'http://ed-fi.org/ods/identity/claims/domains/primaryRelationships' | ||
---------------------------------------------------------------------------------------------------------------------------- | ||
SET @claimName = 'http://ed-fi.org/ods/identity/claims/domains/primaryRelationships' | ||
|
||
SELECT @parentResourceClaimId = ResourceClaimId | ||
FROM dbo.ResourceClaims | ||
WHERE ClaimName = @claimName | ||
|
||
-- Processing children of http://ed-fi.org/ods/identity/claims/domains/primaryRelationships | ||
---------------------------------------------------------------------------------------------------------------------------- | ||
-- Resource Claim: 'http://ed-fi.org/ods/identity/claims/studentParentAssociation' | ||
---------------------------------------------------------------------------------------------------------------------------- | ||
SET @claimName = 'http://ed-fi.org/ods/identity/claims/studentParentAssociation' | ||
SET @claimId = NULL | ||
|
||
SELECT @claimId = ResourceClaimId, @existingParentResourceClaimId = ParentResourceClaimId | ||
FROM dbo.ResourceClaims | ||
WHERE ClaimName = @claimName | ||
|
||
IF @parentResourceClaimId IS NOT NULL | ||
BEGIN | ||
IF @parentResourceClaimId != @existingParentResourceClaimId | ||
BEGIN | ||
PRINT 'Repointing claim ''' + @claimName + ''' (ResourceClaimId=' + CONVERT(nvarchar, @claimId) + ') to new parent (ResourceClaimId=' + CONVERT(nvarchar, @parentResourceClaimId) + ')' | ||
PRINT 'Updating parent resource claim to primaryRelationships' | ||
UPDATE dbo.ResourceClaims | ||
SET ParentResourceClaimId = @parentResourceClaimId | ||
WHERE ResourceClaimId = @claimId | ||
END | ||
END | ||
|
||
COMMIT TRANSACTION | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...rd/4.0.0/Artifacts/PgSql/Data/Security/2190-StudentParentAssociation-ClaimName-Update.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
DO | ||
$$ | ||
DECLARE | ||
claim_id INT; | ||
claim_name VARCHAR(2048); | ||
parent_resource_claim_id INT; | ||
existing_parent_resource_claim_id INT; | ||
BEGIN | ||
-- Begin transaction | ||
BEGIN | ||
|
||
---------------------------------------------------------------------------------------------------------------------------- | ||
-- Resource Claim: 'http://ed-fi.org/ods/identity/claims/domains/primaryRelationships' | ||
---------------------------------------------------------------------------------------------------------------------------- | ||
claim_name := 'http://ed-fi.org/ods/identity/claims/domains/primaryRelationships'; | ||
|
||
SELECT resourceclaimid INTO parent_resource_claim_id | ||
FROM dbo.resourceclaims | ||
WHERE claimname = claim_name; | ||
|
||
-- Processing children of 'http://ed-fi.org/ods/identity/claims/domains/primaryRelationships' | ||
---------------------------------------------------------------------------------------------------------------------------- | ||
-- Resource Claim: 'http://ed-fi.org/ods/identity/claims/studentParentAssociation' | ||
---------------------------------------------------------------------------------------------------------------------------- | ||
claim_name := 'http://ed-fi.org/ods/identity/claims/studentParentAssociation'; | ||
claim_id := NULL; | ||
|
||
SELECT resourceclaimid, parentresourceclaimid INTO claim_id, existing_parent_resource_claim_id | ||
FROM dbo.resourceclaims | ||
WHERE claimname = claim_name; | ||
|
||
IF parent_resource_claim_id IS NOT NULL THEN | ||
IF parent_resource_claim_id != existing_parent_resource_claim_id THEN | ||
RAISE NOTICE 'Repointing claim % (ResourceClaimId=%) to new parent (ResourceClaimId=%)', | ||
claim_name, claim_id, parent_resource_claim_id; | ||
|
||
RAISE NOTICE 'Updating parent resource claim to primaryRelationships'; | ||
|
||
UPDATE dbo.resourceclaims | ||
SET parentresourceclaimid = parent_resource_claim_id | ||
WHERE resourceclaimid = claim_id; | ||
END IF; | ||
END IF; | ||
|
||
-- Commit transaction | ||
COMMIT; | ||
|
||
END; | ||
END | ||
$$; |
Oops, something went wrong.