Skip to content

Commit

Permalink
Merge branch 'master' into code-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
chakru-r authored Dec 2, 2024
2 parents 137daf8 + 02198f7 commit e1f1fcc
Show file tree
Hide file tree
Showing 13 changed files with 567 additions and 65 deletions.
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

0 comments on commit e1f1fcc

Please sign in to comment.