Skip to content

Commit

Permalink
feat: adopt the internal snapshot/aspect union and asset in resources. (
Browse files Browse the repository at this point in the history
#396)

* feat: adopt the internal snapshot/aspect union and asset in resources.

* create internal model mode.

* add experimental functions.

* create lix interface for experimental controllers.

* simplify the interface params and put link in java doc.

* include ingestAsset in experiment.

* integrate with ingestionParams

* remove the ingestAsset resource lix

* remove unused lix controllers.
  • Loading branch information
RealChrisL authored Aug 29, 2024
1 parent 47c0bd6 commit 62dda81
Show file tree
Hide file tree
Showing 23 changed files with 1,522 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,9 @@ public <ASPECT extends RecordTemplate> ASPECT add(@Nonnull URN urn, @Nonnull ASP
@Nonnull
public <ASPECT extends RecordTemplate> ASPECT add(@Nonnull URN urn, @Nonnull ASPECT newValue,
@Nonnull AuditStamp auditStamp, @Nullable IngestionTrackingContext trackingContext, @Nullable IngestionParams ingestionParams) {
final IngestionParams nonNullIngestionParams = ingestionParams == null ? new IngestionParams().setIngestionMode(IngestionMode.LIVE) : ingestionParams;
final IngestionParams nonNullIngestionParams =
ingestionParams == null ? new IngestionParams().setIngestionMode(IngestionMode.LIVE).setTestMode(false)
: ingestionParams;
return add(urn, (Class<ASPECT>) newValue.getClass(), ignored -> newValue, auditStamp, trackingContext, nonNullIngestionParams);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,4 +945,8 @@ public static <INTERNAL_SNAPSHOT extends RecordTemplate, VALUE extends RecordTem
throw new RuntimeException(e);
}
}

public static <URN extends Urn> String getEntityType(@Nullable URN urn) {
return urn == null ? null : urn.getEntityType();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -751,4 +751,14 @@ public void testDecorateValue() {
assertEquals(decoratedValue.getFoo(), entityFoo);
assertEquals(decoratedValue.getBar(), expectedBar);
}

@Test
public void testGetEntityType() {
Urn expectedUrn = makeUrn(1);

String entityType = ModelUtils.getEntityType(expectedUrn);

assertEquals(entityType, expectedUrn.getEntityType());
assertNull(ModelUtils.getEntityType(null));
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.linkedin.metadata.dao.utils.QueryUtils;
import com.linkedin.metadata.query.BrowseResult;
import com.linkedin.metadata.query.Filter;
import com.linkedin.metadata.restli.lix.ResourceLix;
import com.linkedin.parseq.Task;
import com.linkedin.restli.server.annotations.Action;
import com.linkedin.restli.server.annotations.ActionParam;
Expand All @@ -29,6 +30,9 @@
* @param <SNAPSHOT> must be a valid snapshot type defined in com.linkedin.metadata.snapshot
* @param <ASPECT_UNION> must be a valid aspect union type supported by the snapshot
* @param <DOCUMENT> must be a valid search document type defined in com.linkedin.metadata.search
* @param <INTERNAL_SNAPSHOT> must be a valid internal snapshot type defined in com.linkedin.metadata.snapshot
* @param <INTERNAL_ASPECT_UNION> must be a valid internal aspect union type supported by the internal snapshot
* @param <ASSET> must be a valid asset type defined in com.linkedin.metadata.asset
*/
public abstract class BaseBrowsableEntityResource<
// @formatter:off
Expand All @@ -37,18 +41,34 @@ public abstract class BaseBrowsableEntityResource<
URN extends Urn,
SNAPSHOT extends RecordTemplate,
ASPECT_UNION extends UnionTemplate,
DOCUMENT extends RecordTemplate>
DOCUMENT extends RecordTemplate,
INTERNAL_SNAPSHOT extends RecordTemplate,
INTERNAL_ASPECT_UNION extends UnionTemplate,
ASSET extends RecordTemplate>
// @formatter:on
extends BaseSearchableEntityResource<KEY, VALUE, URN, SNAPSHOT, ASPECT_UNION, DOCUMENT> {
extends
BaseSearchableEntityResource<KEY, VALUE, URN, SNAPSHOT, ASPECT_UNION, DOCUMENT, INTERNAL_SNAPSHOT, INTERNAL_ASPECT_UNION, ASSET> {

public BaseBrowsableEntityResource(@Nonnull Class<SNAPSHOT> snapshotClass,
@Nonnull Class<ASPECT_UNION> aspectUnionClass) {
super(snapshotClass, aspectUnionClass);
public BaseBrowsableEntityResource(@Nullable Class<SNAPSHOT> snapshotClass,
@Nullable Class<ASPECT_UNION> aspectUnionClass, @Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass) {
super(snapshotClass, aspectUnionClass, internalSnapshotClass, internalAspectUnionClass, assetClass);
}

public BaseBrowsableEntityResource(@Nonnull Class<SNAPSHOT> snapshotClass,
@Nonnull Class<ASPECT_UNION> aspectUnionClass, @Nonnull Class<URN> urnClass) {
super(snapshotClass, aspectUnionClass, urnClass);
public BaseBrowsableEntityResource(@Nullable Class<SNAPSHOT> snapshotClass,
@Nullable Class<ASPECT_UNION> aspectUnionClass, @Nonnull Class<URN> urnClass,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass) {
super(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass);
}

public BaseBrowsableEntityResource(@Nullable Class<SNAPSHOT> snapshotClass,
@Nullable Class<ASPECT_UNION> aspectUnionClass, @Nonnull Class<URN> urnClass,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass,
@Nonnull ResourceLix resourceLix) {
super(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass,
resourceLix);
}

/**
Expand Down
Loading

0 comments on commit 62dda81

Please sign in to comment.