feat(backoffice): migrate masking rules to Smilegate tables
This commit is contained in:
@@ -4,41 +4,41 @@
|
||||
<mapper namespace="com.cloudhandson.vpdbackoffice.mapper.MaskingRuleMapper">
|
||||
<select id="findAllRules" resultType="com.cloudhandson.vpdbackoffice.domain.masking.MaskingRule">
|
||||
SELECT rule_id, rule_code, rule_name, template_code, description, enabled_yn
|
||||
FROM cb_masking_rule
|
||||
FROM sg_masking_rule
|
||||
ORDER BY enabled_yn DESC, rule_name, rule_id
|
||||
</select>
|
||||
|
||||
<select id="findEnabledRules" resultType="com.cloudhandson.vpdbackoffice.domain.masking.MaskingRule">
|
||||
SELECT rule_id, rule_code, rule_name, template_code, description, enabled_yn
|
||||
FROM cb_masking_rule
|
||||
FROM sg_masking_rule
|
||||
WHERE enabled_yn = 'Y'
|
||||
ORDER BY rule_name, rule_id
|
||||
</select>
|
||||
|
||||
<select id="findRuleById" resultType="com.cloudhandson.vpdbackoffice.domain.masking.MaskingRule">
|
||||
SELECT rule_id, rule_code, rule_name, template_code, description, enabled_yn
|
||||
FROM cb_masking_rule
|
||||
FROM sg_masking_rule
|
||||
WHERE rule_id = #{ruleId}
|
||||
</select>
|
||||
|
||||
<select id="findRuleByCode" resultType="com.cloudhandson.vpdbackoffice.domain.masking.MaskingRule">
|
||||
SELECT rule_id, rule_code, rule_name, template_code, description, enabled_yn
|
||||
FROM cb_masking_rule
|
||||
FROM sg_masking_rule
|
||||
WHERE rule_code = #{ruleCode}
|
||||
</select>
|
||||
|
||||
<select id="nextRuleId" resultType="long">
|
||||
SELECT NVL(MAX(rule_id), 0) + 1 FROM cb_masking_rule
|
||||
SELECT NVL(MAX(rule_id), 0) + 1 FROM sg_masking_rule
|
||||
</select>
|
||||
|
||||
<insert id="insertRule">
|
||||
INSERT INTO cb_masking_rule (rule_id, rule_code, rule_name, template_code, description, enabled_yn)
|
||||
INSERT INTO sg_masking_rule (rule_id, rule_code, rule_name, template_code, description, enabled_yn)
|
||||
VALUES (#{ruleId}, #{command.ruleCode}, #{command.ruleName}, #{command.templateCode},
|
||||
#{command.description}, 'Y')
|
||||
</insert>
|
||||
|
||||
<update id="updateRuleActive">
|
||||
UPDATE cb_masking_rule
|
||||
UPDATE sg_masking_rule
|
||||
SET enabled_yn = #{enabledYn}
|
||||
WHERE rule_id = #{ruleId}
|
||||
</update>
|
||||
@@ -54,10 +54,10 @@
|
||||
r.rule_name,
|
||||
r.template_code,
|
||||
r.enabled_yn AS rule_enabled_yn
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_protected_column c ON c.column_id = link.column_id
|
||||
JOIN cb_protected_object o ON o.object_id = c.object_id
|
||||
JOIN cb_masking_rule r ON r.rule_id = link.rule_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_protected_column c ON c.column_id = link.column_id
|
||||
JOIN sg_protected_object o ON o.object_id = c.object_id
|
||||
JOIN sg_masking_rule r ON r.rule_id = link.rule_id
|
||||
ORDER BY o.owner, o.object_name, c.column_name
|
||||
</select>
|
||||
|
||||
@@ -76,10 +76,10 @@
|
||||
configured AS (
|
||||
SELECT protected_object.object_name,
|
||||
COUNT(*) AS configured_column_count
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN cb_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN cb_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN sg_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN sg_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
WHERE protected_object.owner = 'POC_2'
|
||||
AND rule.enabled_yn = 'Y'
|
||||
GROUP BY protected_object.object_name
|
||||
@@ -102,10 +102,10 @@
|
||||
missing_columns AS (
|
||||
SELECT protected_object.object_name,
|
||||
COUNT(*) AS missing_column_count
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN cb_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN cb_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN sg_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN sg_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
LEFT JOIN redaction_columns policy_column
|
||||
ON policy_column.object_owner = protected_object.owner
|
||||
AND policy_column.object_name = protected_object.object_name
|
||||
@@ -123,10 +123,10 @@
|
||||
WHERE policy_column.object_owner = 'POC_2'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN cb_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN cb_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_masking_rule rule ON rule.rule_id = link.rule_id
|
||||
JOIN sg_protected_column protected_column ON protected_column.column_id = link.column_id
|
||||
JOIN sg_protected_object protected_object ON protected_object.object_id = protected_column.object_id
|
||||
WHERE protected_object.owner = 'POC_2'
|
||||
AND protected_object.object_name = policy_column.object_name
|
||||
AND protected_column.column_name = policy_column.column_name
|
||||
@@ -180,15 +180,15 @@
|
||||
r.rule_name,
|
||||
r.template_code,
|
||||
r.enabled_yn AS rule_enabled_yn
|
||||
FROM cb_column_masking_rule link
|
||||
JOIN cb_protected_column c ON c.column_id = link.column_id
|
||||
JOIN cb_protected_object o ON o.object_id = c.object_id
|
||||
JOIN cb_masking_rule r ON r.rule_id = link.rule_id
|
||||
FROM sg_column_masking_rule link
|
||||
JOIN sg_protected_column c ON c.column_id = link.column_id
|
||||
JOIN sg_protected_object o ON o.object_id = c.object_id
|
||||
JOIN sg_masking_rule r ON r.rule_id = link.rule_id
|
||||
WHERE c.column_id = #{columnId}
|
||||
</select>
|
||||
|
||||
<insert id="upsertColumnRule">
|
||||
MERGE INTO cb_column_masking_rule dst
|
||||
MERGE INTO sg_column_masking_rule dst
|
||||
USING (SELECT #{columnId} column_id, #{ruleId} rule_id FROM dual) src
|
||||
ON (dst.column_id = src.column_id)
|
||||
WHEN MATCHED THEN UPDATE SET dst.rule_id = src.rule_id, dst.updated_at = SYSTIMESTAMP
|
||||
@@ -197,12 +197,12 @@
|
||||
</insert>
|
||||
|
||||
<delete id="deleteColumnRule">
|
||||
DELETE FROM cb_column_masking_rule
|
||||
DELETE FROM sg_column_masking_rule
|
||||
WHERE column_id = #{columnId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteUserRulesForColumn">
|
||||
DELETE FROM cb_user_masking_rule
|
||||
DELETE FROM sg_user_masking_rule
|
||||
WHERE column_id = #{columnId}
|
||||
</delete>
|
||||
|
||||
@@ -217,12 +217,12 @@
|
||||
r.template_code,
|
||||
assignment.decision,
|
||||
assignment.active_yn
|
||||
FROM cb_user_masking_rule assignment
|
||||
JOIN cb_app_user u ON u.user_id = assignment.user_id
|
||||
JOIN cb_protected_column c ON c.column_id = assignment.column_id
|
||||
JOIN cb_protected_object o ON o.object_id = c.object_id
|
||||
JOIN cb_column_masking_rule link ON link.column_id = c.column_id
|
||||
JOIN cb_masking_rule r ON r.rule_id = link.rule_id
|
||||
FROM sg_user_masking_rule assignment
|
||||
JOIN sg_app_user u ON u.user_id = assignment.user_id
|
||||
JOIN sg_protected_column c ON c.column_id = assignment.column_id
|
||||
JOIN sg_protected_object o ON o.object_id = c.object_id
|
||||
JOIN sg_column_masking_rule link ON link.column_id = c.column_id
|
||||
JOIN sg_masking_rule r ON r.rule_id = link.rule_id
|
||||
ORDER BY u.user_name, o.owner, o.object_name, c.column_name
|
||||
</select>
|
||||
|
||||
@@ -237,18 +237,18 @@
|
||||
r.template_code,
|
||||
assignment.decision,
|
||||
assignment.active_yn
|
||||
FROM cb_user_masking_rule assignment
|
||||
JOIN cb_app_user u ON u.user_id = assignment.user_id
|
||||
JOIN cb_protected_column c ON c.column_id = assignment.column_id
|
||||
JOIN cb_protected_object o ON o.object_id = c.object_id
|
||||
JOIN cb_column_masking_rule link ON link.column_id = c.column_id
|
||||
JOIN cb_masking_rule r ON r.rule_id = link.rule_id
|
||||
FROM sg_user_masking_rule assignment
|
||||
JOIN sg_app_user u ON u.user_id = assignment.user_id
|
||||
JOIN sg_protected_column c ON c.column_id = assignment.column_id
|
||||
JOIN sg_protected_object o ON o.object_id = c.object_id
|
||||
JOIN sg_column_masking_rule link ON link.column_id = c.column_id
|
||||
JOIN sg_masking_rule r ON r.rule_id = link.rule_id
|
||||
WHERE assignment.user_id = #{userId}
|
||||
AND assignment.column_id = #{columnId}
|
||||
</select>
|
||||
|
||||
<insert id="upsertUserRule">
|
||||
MERGE INTO cb_user_masking_rule dst
|
||||
MERGE INTO sg_user_masking_rule dst
|
||||
USING (SELECT #{userId} user_id, #{columnId} column_id, #{decision} decision FROM dual) src
|
||||
ON (dst.user_id = src.user_id AND dst.column_id = src.column_id)
|
||||
WHEN MATCHED THEN UPDATE SET dst.decision = src.decision, dst.active_yn = 'Y', dst.updated_at = SYSTIMESTAMP
|
||||
@@ -257,7 +257,7 @@
|
||||
</insert>
|
||||
|
||||
<delete id="deleteUserRule">
|
||||
DELETE FROM cb_user_masking_rule
|
||||
DELETE FROM sg_user_masking_rule
|
||||
WHERE user_id = #{userId}
|
||||
AND column_id = #{columnId}
|
||||
</delete>
|
||||
|
||||
Reference in New Issue
Block a user