-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(change-events): refactor AspectDiffers to EntityChangeEventG…
…enerators (#6320) * refactor(change-events): refactor AspectDiffers to EntityChangeEventGenerators * feat(change-event): add change events for AssertionRunEvent * feat(change-event): add change events for DataProcessInstanceRunEvent
- Loading branch information
1 parent
4b31204
commit 873b100
Showing
33 changed files
with
934 additions
and
678 deletions.
There are no files selected for viewing
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
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
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
36 changes: 0 additions & 36 deletions
36
metadata-io/src/main/java/com/linkedin/metadata/timeline/differ/AspectDiffer.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
metadata-io/src/main/java/com/linkedin/metadata/timeline/differ/AspectDifferFactory.java
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
metadata-io/src/main/java/com/linkedin/metadata/timeline/differ/AspectDifferRegistry.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...edin/metadata/timeline/differ/Aspect.java → ...adata/timeline/eventgenerator/Aspect.java
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
74 changes: 74 additions & 0 deletions
74
.../com/linkedin/metadata/timeline/eventgenerator/AssertionRunEventChangeEventGenerator.java
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,74 @@ | ||
package com.linkedin.metadata.timeline.eventgenerator; | ||
|
||
import com.google.common.collect.ImmutableSortedMap; | ||
import com.linkedin.assertion.AssertionResult; | ||
import com.linkedin.assertion.AssertionRunEvent; | ||
import com.linkedin.common.AuditStamp; | ||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.metadata.timeline.data.ChangeCategory; | ||
import com.linkedin.metadata.timeline.data.ChangeEvent; | ||
import com.linkedin.metadata.timeline.data.ChangeOperation; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import javax.annotation.Nonnull; | ||
|
||
import static com.linkedin.metadata.Constants.*; | ||
|
||
|
||
public class AssertionRunEventChangeEventGenerator extends EntityChangeEventGenerator<AssertionRunEvent> { | ||
@Override | ||
public List<ChangeEvent> getChangeEvents( | ||
@Nonnull Urn urn, | ||
@Nonnull String entity, | ||
@Nonnull String aspect, | ||
@Nonnull Aspect<AssertionRunEvent> from, | ||
@Nonnull Aspect<AssertionRunEvent> to, | ||
@Nonnull AuditStamp auditStamp) { | ||
return computeDiffs(from.getValue(), to.getValue(), urn.toString(), auditStamp); | ||
} | ||
|
||
private List<ChangeEvent> computeDiffs( | ||
@Nonnull final AssertionRunEvent previousAspect, | ||
@Nonnull final AssertionRunEvent newAspect, | ||
@Nonnull final String entityUrn, | ||
@Nonnull final AuditStamp auditStamp) { | ||
|
||
boolean isPreviousCompleted = isCompleted(previousAspect); | ||
boolean isNewCompleted = isCompleted(newAspect); | ||
|
||
if (isNewCompleted && !isPreviousCompleted) { | ||
return Collections.singletonList(ChangeEvent.builder() | ||
.category(ChangeCategory.RUN) | ||
.operation(ChangeOperation.COMPLETED) | ||
.auditStamp(auditStamp) | ||
.entityUrn(entityUrn) | ||
.parameters(buildParameters(newAspect)) | ||
.build()); | ||
} | ||
|
||
return Collections.emptyList(); | ||
} | ||
|
||
private boolean isCompleted(final AssertionRunEvent assertionRunEvent) { | ||
return assertionRunEvent != null && assertionRunEvent.getStatus() | ||
.toString() | ||
.equals(ASSERTION_RUN_EVENT_STATUS_COMPLETE); | ||
} | ||
|
||
@Nonnull | ||
private Map<String, Object> buildParameters(@Nonnull final AssertionRunEvent assertionRunEvent) { | ||
final Map<String, Object> parameters = new HashMap<>(); | ||
parameters.put(RUN_RESULT_KEY, assertionRunEvent.getStatus().toString()); | ||
parameters.put(RUN_ID_KEY, assertionRunEvent.getRunId()); | ||
parameters.put(ASSERTEE_URN_KEY, assertionRunEvent.getAsserteeUrn().toString()); | ||
|
||
if (assertionRunEvent.hasResult()) { | ||
final AssertionResult assertionResult = assertionRunEvent.getResult(); | ||
parameters.put(ASSERTION_RESULT_KEY, assertionResult.getType().toString()); | ||
} | ||
|
||
return ImmutableSortedMap.copyOf(parameters); | ||
} | ||
} |
Oops, something went wrong.