forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'datahub-project:master' into master
- Loading branch information
Showing
37 changed files
with
2,035 additions
and
223 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
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
18 changes: 12 additions & 6 deletions
18
...gistry/src/main/java/com/linkedin/metadata/aspect/patch/template/CompoundKeyTemplate.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 |
---|---|---|
@@ -1,23 +1,29 @@ | ||
package com.linkedin.metadata.aspect.patch.template; | ||
|
||
import static com.linkedin.metadata.aspect.patch.template.TemplateUtil.OBJECT_MAPPER; | ||
import static com.linkedin.metadata.aspect.patch.template.TemplateUtil.populateTopLevelKeys; | ||
|
||
import com.datahub.util.RecordUtils; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.github.fge.jsonpatch.JsonPatchException; | ||
import com.github.fge.jsonpatch.Patch; | ||
import com.linkedin.data.template.RecordTemplate; | ||
import jakarta.json.Json; | ||
import jakarta.json.JsonObject; | ||
import jakarta.json.JsonPatch; | ||
import java.io.StringReader; | ||
|
||
public abstract class CompoundKeyTemplate<T extends RecordTemplate> | ||
implements ArrayMergingTemplate<T> { | ||
|
||
@Override | ||
public T applyPatch(RecordTemplate recordTemplate, Patch jsonPatch) | ||
throws JsonProcessingException, JsonPatchException { | ||
public T applyPatch(RecordTemplate recordTemplate, JsonPatch jsonPatch) | ||
throws JsonProcessingException { | ||
JsonNode transformed = populateTopLevelKeys(preprocessTemplate(recordTemplate), jsonPatch); | ||
JsonNode patched = jsonPatch.apply(transformed); | ||
JsonNode postProcessed = rebaseFields(patched); | ||
JsonObject patched = | ||
jsonPatch.apply( | ||
Json.createReader(new StringReader(OBJECT_MAPPER.writeValueAsString(transformed))) | ||
.readObject()); | ||
JsonNode postProcessed = rebaseFields(OBJECT_MAPPER.readTree(patched.toString())); | ||
return RecordUtils.toRecordTemplate(getTemplateType(), postProcessed.toString()); | ||
} | ||
} |
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
Oops, something went wrong.