Skip to content

Commit

Permalink
Use previous values for missing restrict option
Browse files Browse the repository at this point in the history
If a restrict via lineage or restrict via hierarchy option is
missing while updating the set classification, this will use
the previously saved value. This is done to avoid bypassing
the validation if setting the options one by one.
  • Loading branch information
krsoninikhil committed Jul 10, 2024
1 parent bc5e933 commit f6bcdea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3712,6 +3712,21 @@ public void updateClassifications(EntityMutationContext context, String guid, Li
Boolean updatedRestrictPropagationThroughLineage = classification.getRestrictPropagationThroughLineage();
Boolean currentRestrictPropagationThroughHierarchy = currentClassification.getRestrictPropagationThroughHierarchy();
Boolean updatedRestrictPropagationThroughHierarchy = classification.getRestrictPropagationThroughHierarchy();
if (updatedRestrictPropagationThroughLineage == null) {
updatedRestrictPropagationThroughLineage = currentRestrictPropagationThroughLineage;
classification.setRestrictPropagationThroughLineage(updatedRestrictPropagationThroughLineage);
}
if (updatedRestrictPropagationThroughHierarchy == null) {
updatedRestrictPropagationThroughHierarchy = currentRestrictPropagationThroughHierarchy;
classification.setRestrictPropagationThroughHierarchy(updatedRestrictPropagationThroughHierarchy);
}

String propagationMode = CLASSIFICATION_PROPAGATION_MODE_DEFAULT;
if (updatedTagPropagation) {
// determinePropagationMode also validates the propagation restriction option values
propagationMode = entityRetriever.determinePropagationMode(updatedRestrictPropagationThroughLineage, updatedRestrictPropagationThroughHierarchy);
}

if ((!Objects.equals(updatedRemovePropagations, currentRemovePropagations) ||
!Objects.equals(currentTagPropagation, updatedTagPropagation) ||
!Objects.equals(currentRestrictPropagationThroughLineage, updatedRestrictPropagationThroughLineage)) &&
Expand All @@ -3731,10 +3746,8 @@ public void updateClassifications(EntityMutationContext context, String guid, Li
// compute propagatedEntityVertices once and use it for subsequent iterations and notifications
if (updatedTagPropagation != null && (currentTagPropagation != updatedTagPropagation || currentRestrictPropagationThroughLineage != updatedRestrictPropagationThroughLineage || currentRestrictPropagationThroughHierarchy != updatedRestrictPropagationThroughHierarchy)) {
if (updatedTagPropagation) {
String propagationMode = entityRetriever.determinePropagationMode(updatedRestrictPropagationThroughLineage, updatedRestrictPropagationThroughHierarchy);
if (updatedRestrictPropagationThroughLineage != null && !currentRestrictPropagationThroughLineage && updatedRestrictPropagationThroughLineage) {
deleteDelegate.getHandler().removeTagPropagation(classificationVertex);

}
if (updatedRestrictPropagationThroughHierarchy != null && !currentRestrictPropagationThroughHierarchy && updatedRestrictPropagationThroughHierarchy) {
deleteDelegate.getHandler().removeTagPropagation(classificationVertex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,18 @@ private void sendNotifications(OperationType operationType, List<EntityNotificat
}

private void sendNotifications(OperationType operationType, List<EntityNotificationV2> messages, boolean forceInline) throws AtlasBaseException {
if (!messages.isEmpty()) {
try {
if (forceInline) {
inlineNotificationSender.send(operationType, messages);
}
else {
notificationSender.send(operationType, messages);
}
} catch (NotificationException e) {
throw new AtlasBaseException(AtlasErrorCode.ENTITY_NOTIFICATION_FAILED, e, operationType.name());
}
}
// if (!messages.isEmpty()) {
// try {
// if (forceInline) {
// inlineNotificationSender.send(operationType, messages);
// }
// else {
// notificationSender.send(operationType, messages);
// }
// } catch (NotificationException e) {
// throw new AtlasBaseException(AtlasErrorCode.ENTITY_NOTIFICATION_FAILED, e, operationType.name());
// }
// }
}

private AtlasEntityHeaderWithRelations toNotificationHeader(AtlasEntity entity) {
Expand Down

0 comments on commit f6bcdea

Please sign in to comment.