Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(java-sdk): custom properties patch client #11984

Merged
merged 2 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ public class CustomPropertiesPatchBuilder<T extends AbstractMultiFieldPatchBuild
public static final String CUSTOM_PROPERTIES_BASE_PATH = "/customProperties";

private final T parent;
private final List<ImmutableTriple<String, String, JsonNode>> operations = new ArrayList<>();
private final List<ImmutableTriple<String, String, JsonNode>> operations;

public CustomPropertiesPatchBuilder(T parentBuilder) {
this.parent = parentBuilder;
if (parentBuilder != null) {
// If a parent builder is provided, we use the same path operations list.
this.operations = parentBuilder.getPathValues();
} else {
this.operations = new ArrayList<>();
}
}

/**
Expand Down Expand Up @@ -72,9 +78,4 @@ public CustomPropertiesPatchBuilder<T> setProperties(Map<String, String> propert
public T getParent() {
return parent;
}

@Override
public List<ImmutableTriple<String, String, JsonNode>> getSubPaths() {
return operations;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import static com.linkedin.metadata.Constants.DATA_FLOW_ENTITY_NAME;
import static com.linkedin.metadata.Constants.DATA_FLOW_INFO_ASPECT_NAME;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.linkedin.common.TimeStamp;
import com.linkedin.metadata.aspect.patch.PatchOperationType;
import com.linkedin.metadata.aspect.patch.builder.subtypesupport.CustomPropertiesPatchBuilderSupport;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -87,28 +85,23 @@ public DataFlowInfoPatchBuilder setCreated(@Nullable TimeStamp created) {
}

public DataFlowInfoPatchBuilder setLastModified(@Nullable TimeStamp lastModified) {
ObjectNode lastModifiedNode = instance.objectNode();
if (lastModified == null) {
pathValues.add(
ImmutableTriple.of(
PatchOperationType.REMOVE.getValue(), BASE_PATH + LAST_MODIFIED_KEY, null));
} else {
lastModifiedNode.put(TIME_KEY, lastModified.getTime());
if (lastModified.getActor() != null) {
lastModifiedNode.put(ACTOR_KEY, lastModified.getActor().toString());
}
pathValues.add(
ImmutableTriple.of(
PatchOperationType.ADD.getValue(), BASE_PATH + LAST_MODIFIED_KEY, lastModifiedNode));
}
ObjectNode lastModifiedNode = instance.objectNode();
lastModifiedNode.put(TIME_KEY, lastModified.getTime());
if (lastModified.getActor() != null) {
lastModifiedNode.put(ACTOR_KEY, lastModified.getActor().toString());
}
pathValues.add(
ImmutableTriple.of(
PatchOperationType.ADD.getValue(), BASE_PATH + LAST_MODIFIED_KEY, lastModifiedNode));
return this;
}

@Override
protected List<ImmutableTriple<String, String, JsonNode>> getPathValues() {
pathValues.addAll(customPropertiesPatchBuilder.getSubPaths());
return pathValues;
}

@Override
protected String getAspectName() {
return DATA_FLOW_INFO_ASPECT_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import static com.linkedin.metadata.Constants.DATA_JOB_ENTITY_NAME;
import static com.linkedin.metadata.Constants.DATA_JOB_INFO_ASPECT_NAME;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.linkedin.common.TimeStamp;
import com.linkedin.common.urn.DataFlowUrn;
import com.linkedin.metadata.aspect.patch.PatchOperationType;
import com.linkedin.metadata.aspect.patch.builder.subtypesupport.CustomPropertiesPatchBuilderSupport;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -113,12 +111,6 @@ public DataJobInfoPatchBuilder setLastModified(@Nullable TimeStamp lastModified)
return this;
}

@Override
protected List<ImmutableTriple<String, String, JsonNode>> getPathValues() {
pathValues.addAll(customPropertiesPatchBuilder.getSubPaths());
return pathValues;
}

@Override
protected String getAspectName() {
return DATA_JOB_INFO_ASPECT_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import static com.linkedin.metadata.Constants.DATASET_ENTITY_NAME;
import static com.linkedin.metadata.Constants.DATASET_PROPERTIES_ASPECT_NAME;

import com.fasterxml.jackson.databind.JsonNode;
import com.linkedin.metadata.aspect.patch.PatchOperationType;
import com.linkedin.metadata.aspect.patch.builder.subtypesupport.CustomPropertiesPatchBuilderSupport;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -116,12 +114,6 @@ public DatasetPropertiesPatchBuilder setCustomProperties(Map<String, String> pro
return this;
}

@Override
protected List<ImmutableTriple<String, String, JsonNode>> getPathValues() {
pathValues.addAll(customPropertiesPatchBuilder.getSubPaths());
return pathValues;
}

@Override
protected String getAspectName() {
return DATASET_PROPERTIES_ASPECT_NAME;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.linkedin.metadata.aspect.patch.builder.subtypesupport;

import com.fasterxml.jackson.databind.JsonNode;
import com.linkedin.metadata.aspect.patch.builder.AbstractMultiFieldPatchBuilder;
import java.util.List;
import org.apache.commons.lang3.tuple.ImmutableTriple;

/**
* Used for supporting intermediate subtypes when constructing a patch for an aspect that includes
Expand All @@ -15,10 +12,4 @@ public interface IntermediatePatchBuilder<T extends AbstractMultiFieldPatchBuild

/** Convenience method to return parent patch builder in functional callstack */
T getParent();

/**
* Exposes subpath values to parent patch builder in Op, Path, Value triples. Should usually only
* be called by the parent patch builder class when constructing the path values.
*/
List<ImmutableTriple<String, String, JsonNode>> getSubPaths();
}
Loading
Loading