mirror of
https://github.com/datahub-project/datahub.git
synced 2025-06-27 05:03:31 +00:00
[Breaking] Update to GMA 0.2.0 and fix Urn definitions. (#1977)
Urn definitions needed to be updated since 0.2.0 changed the base Urn class. I also added some more urn coercers that were missing.
This commit is contained in:
parent
70ddb09d29
commit
60e43061d8
@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.pegasusVersion = '28.3.7'
|
ext.pegasusVersion = '28.3.7'
|
||||||
ext.gmaVersion = '0.1.0'
|
ext.gmaVersion = '0.2.0'
|
||||||
|
|
||||||
apply from: './repositories.gradle'
|
apply from: './repositories.gradle'
|
||||||
buildscript.repositories.addAll(project.repositories)
|
buildscript.repositories.addAll(project.repositories)
|
||||||
|
@ -43,7 +43,7 @@ public class OwnerViewDao {
|
|||||||
datasetOwnership.setDatasetUrn(datasetUrn);
|
datasetOwnership.setDatasetUrn(datasetUrn);
|
||||||
datasetOwnership.setFromUpstream(false);
|
datasetOwnership.setFromUpstream(false);
|
||||||
datasetOwnership.setOwners(fillDatasetOwner(ownership, owners));
|
datasetOwnership.setOwners(fillDatasetOwner(ownership, owners));
|
||||||
datasetOwnership.setActor(ownership.getLastModified().getActor().getContent());
|
datasetOwnership.setActor(ownership.getLastModified().getActor().getId());
|
||||||
datasetOwnership.setLastModified(ownership.getLastModified().getTime());
|
datasetOwnership.setLastModified(ownership.getLastModified().getTime());
|
||||||
return datasetOwnership;
|
return datasetOwnership;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class DatasetUtil {
|
|||||||
*/
|
*/
|
||||||
public static DatasetView toDatasetView(Dataset dataset) {
|
public static DatasetView toDatasetView(Dataset dataset) {
|
||||||
DatasetView view = new DatasetView();
|
DatasetView view = new DatasetView();
|
||||||
view.setPlatform(dataset.getPlatform().getContent());
|
view.setPlatform(dataset.getPlatform().getPlatformNameEntity());
|
||||||
view.setNativeName(dataset.getName());
|
view.setNativeName(dataset.getName());
|
||||||
view.setFabric(dataset.getOrigin().name());
|
view.setFabric(dataset.getOrigin().name());
|
||||||
view.setDescription(dataset.getDescription());
|
view.setDescription(dataset.getDescription());
|
||||||
|
@ -16,7 +16,7 @@ public class DataProcessesClient extends BaseClient {
|
|||||||
return new DataProcessKey()
|
return new DataProcessKey()
|
||||||
.setName(urn.getNameEntity())
|
.setName(urn.getNameEntity())
|
||||||
.setOrigin(urn.getOriginEntity())
|
.setOrigin(urn.getOriginEntity())
|
||||||
.setOrchestrator(urn.getOrchestrator());
|
.setOrchestrator(urn.getOrchestratorEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -95,7 +95,7 @@ public class DataProcesses extends BaseSearchableEntityResource<
|
|||||||
protected ComplexResourceKey<DataProcessKey, EmptyRecord> toKey(@Nonnull DataProcessUrn urn) {
|
protected ComplexResourceKey<DataProcessKey, EmptyRecord> toKey(@Nonnull DataProcessUrn urn) {
|
||||||
return new ComplexResourceKey<>(
|
return new ComplexResourceKey<>(
|
||||||
new DataProcessKey()
|
new DataProcessKey()
|
||||||
.setOrchestrator(urn.getOrchestrator())
|
.setOrchestrator(urn.getOrchestratorEntity())
|
||||||
.setName(urn.getNameEntity())
|
.setName(urn.getNameEntity())
|
||||||
.setOrigin(urn.getOriginEntity()),
|
.setOrigin(urn.getOriginEntity()),
|
||||||
new EmptyRecord());
|
new EmptyRecord());
|
||||||
@ -105,7 +105,7 @@ public class DataProcesses extends BaseSearchableEntityResource<
|
|||||||
@Override
|
@Override
|
||||||
protected DataProcess toValue(@Nonnull DataProcessSnapshot processSnapshot) {
|
protected DataProcess toValue(@Nonnull DataProcessSnapshot processSnapshot) {
|
||||||
final DataProcess value = new DataProcess()
|
final DataProcess value = new DataProcess()
|
||||||
.setOrchestrator(processSnapshot.getUrn().getOrchestrator())
|
.setOrchestrator(processSnapshot.getUrn().getOrchestratorEntity())
|
||||||
.setName(processSnapshot.getUrn().getNameEntity())
|
.setName(processSnapshot.getUrn().getNameEntity())
|
||||||
.setOrigin(processSnapshot.getUrn().getOriginEntity());
|
.setOrigin(processSnapshot.getUrn().getOriginEntity());
|
||||||
ModelUtils.getAspectsFromSnapshot(processSnapshot).forEach(aspect -> {
|
ModelUtils.getAspectsFromSnapshot(processSnapshot).forEach(aspect -> {
|
||||||
|
@ -10,37 +10,51 @@ public final class AzkabanFlowUrn extends Urn {
|
|||||||
|
|
||||||
public static final String ENTITY_TYPE = "azkabanFlow";
|
public static final String ENTITY_TYPE = "azkabanFlow";
|
||||||
|
|
||||||
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
|
private final String _cluster;
|
||||||
|
private final String _project;
|
||||||
private final String clusterEntity;
|
private final String _flowId;
|
||||||
|
|
||||||
private final String projectEntity;
|
|
||||||
|
|
||||||
private final String flowIdEntity;
|
|
||||||
|
|
||||||
public AzkabanFlowUrn(String cluster, String project, String flowId) {
|
public AzkabanFlowUrn(String cluster, String project, String flowId) {
|
||||||
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, cluster, project, flowId));
|
super(ENTITY_TYPE, TupleKey.create(cluster, project, flowId));
|
||||||
this.clusterEntity = cluster;
|
this._cluster = cluster;
|
||||||
this.projectEntity = project;
|
this._project = project;
|
||||||
this.flowIdEntity = flowId;
|
this._flowId = flowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClusterEntity() {
|
public String getClusterEntity() {
|
||||||
return clusterEntity;
|
return _cluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProjectEntity() {
|
public String getProjectEntity() {
|
||||||
return projectEntity;
|
return _project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlowIdEntity() {
|
public String getFlowIdEntity() {
|
||||||
return flowIdEntity;
|
return _flowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AzkabanFlowUrn createFromString(String rawUrn) throws URISyntaxException {
|
public static AzkabanFlowUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
String content = new Urn(rawUrn).getContent();
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
String[] parts = content.substring(1, content.length() - 1).split(",");
|
}
|
||||||
return new AzkabanFlowUrn(parts[0], parts[1], parts[2]);
|
|
||||||
|
public static AzkabanFlowUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'azkabanFlow'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 3) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new AzkabanFlowUrn((String) key.getAs(0, String.class), (String) key.getAs(1, String.class),
|
||||||
|
(String) key.getAs(2, String.class));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AzkabanFlowUrn deserialize(String rawUrn) throws URISyntaxException {
|
public static AzkabanFlowUrn deserialize(String rawUrn) throws URISyntaxException {
|
||||||
|
@ -10,31 +10,45 @@ public final class AzkabanJobUrn extends Urn {
|
|||||||
|
|
||||||
public static final String ENTITY_TYPE = "azkabanJob";
|
public static final String ENTITY_TYPE = "azkabanJob";
|
||||||
|
|
||||||
private static final String CONTENT_FORMAT = "(%s,%s)";
|
private final AzkabanFlowUrn _flow;
|
||||||
|
private final String _jobId;
|
||||||
private final AzkabanFlowUrn flowEntity;
|
|
||||||
|
|
||||||
private final String jobIdEntity;
|
|
||||||
|
|
||||||
public AzkabanJobUrn(AzkabanFlowUrn flow, String jobId) {
|
public AzkabanJobUrn(AzkabanFlowUrn flow, String jobId) {
|
||||||
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, flow.toString(), jobId));
|
super(ENTITY_TYPE, TupleKey.create(flow, jobId));
|
||||||
this.flowEntity = flow;
|
this._flow = flow;
|
||||||
this.jobIdEntity = jobId;
|
this._jobId = jobId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AzkabanFlowUrn getFlowEntity() {
|
public AzkabanFlowUrn getFlowEntity() {
|
||||||
return flowEntity;
|
return _flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJobIdEntity() {
|
public String getJobIdEntity() {
|
||||||
return jobIdEntity;
|
return _jobId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AzkabanJobUrn createFromString(String rawUrn) throws URISyntaxException {
|
public static AzkabanJobUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
String content = new Urn(rawUrn).getContent();
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
String flowParts = content.substring(1, content.lastIndexOf(",") + 1);
|
}
|
||||||
String[] parts = content.substring(1, content.length() - 1).split(",");
|
|
||||||
return new AzkabanJobUrn(AzkabanFlowUrn.createFromString(flowParts), parts[3]);
|
public static AzkabanJobUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'azkabanJob'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 2) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new AzkabanJobUrn((AzkabanFlowUrn) key.getAs(0, AzkabanFlowUrn.class),
|
||||||
|
(String) key.getAs(1, String.class));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AzkabanJobUrn deserialize(String rawUrn) throws URISyntaxException {
|
public static AzkabanJobUrn deserialize(String rawUrn) throws URISyntaxException {
|
||||||
@ -42,6 +56,7 @@ public final class AzkabanJobUrn extends Urn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
Custom.initializeCustomClass(AzkabanFlowUrn.class);
|
||||||
Custom.registerCoercer(new DirectCoercer<AzkabanJobUrn>() {
|
Custom.registerCoercer(new DirectCoercer<AzkabanJobUrn>() {
|
||||||
public Object coerceInput(AzkabanJobUrn object) throws ClassCastException {
|
public Object coerceInput(AzkabanJobUrn object) throws ClassCastException {
|
||||||
return object.toString();
|
return object.toString();
|
||||||
|
@ -10,31 +10,45 @@ public final class ChartUrn extends Urn {
|
|||||||
|
|
||||||
public static final String ENTITY_TYPE = "chart";
|
public static final String ENTITY_TYPE = "chart";
|
||||||
|
|
||||||
private static final String CONTENT_FORMAT = "(%s,%s)";
|
private final String _dashboardTool;
|
||||||
|
|
||||||
private final String dashboardToolEntity;
|
private final String _chartId;
|
||||||
|
|
||||||
private final String chartIdEntity;
|
|
||||||
|
|
||||||
public ChartUrn(String dashboardTool, String chartId) {
|
public ChartUrn(String dashboardTool, String chartId) {
|
||||||
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, dashboardTool, chartId));
|
super(ENTITY_TYPE, TupleKey.create(dashboardTool, chartId));
|
||||||
this.dashboardToolEntity = dashboardTool;
|
this._dashboardTool = dashboardTool;
|
||||||
this.chartIdEntity = chartId;
|
this._chartId = chartId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDashboardToolEntity() {
|
public String getDashboardToolEntity() {
|
||||||
return dashboardToolEntity;
|
return _dashboardTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChartIdEntity() {
|
public String getChartIdEntity() {
|
||||||
return chartIdEntity;
|
return _chartId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChartUrn createFromString(String rawUrn) throws URISyntaxException {
|
public static ChartUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
Urn urn = new Urn(rawUrn);
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
validateUrn(urn, ENTITY_TYPE);
|
}
|
||||||
String[] urnParts = urn.getContent().split(",");
|
|
||||||
return new ChartUrn(urnParts[0], urnParts[1]);
|
public static ChartUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'chart'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 2) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new ChartUrn((String)key.getAs(0, String.class), (String)key.getAs(1, String.class));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChartUrn deserialize(String rawUrn) throws URISyntaxException {
|
public static ChartUrn deserialize(String rawUrn) throws URISyntaxException {
|
||||||
|
@ -4,41 +4,52 @@ import com.linkedin.data.template.Custom;
|
|||||||
import com.linkedin.data.template.DirectCoercer;
|
import com.linkedin.data.template.DirectCoercer;
|
||||||
import com.linkedin.data.template.TemplateOutputCastException;
|
import com.linkedin.data.template.TemplateOutputCastException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public final class CorpGroupUrn extends Urn {
|
public final class CorpGroupUrn extends Urn {
|
||||||
|
|
||||||
public static final String ENTITY_TYPE = "corpGroup";
|
public static final String ENTITY_TYPE = "corpGroup";
|
||||||
|
|
||||||
private static final Pattern URN_PATTERN = Pattern.compile("^" + URN_PREFIX + ENTITY_TYPE + ":([\\-\\w]+)$");
|
private final String _groupName;
|
||||||
|
|
||||||
private final String groupNameEntity;
|
|
||||||
|
|
||||||
public CorpGroupUrn(String groupName) {
|
public CorpGroupUrn(String groupName) {
|
||||||
super(ENTITY_TYPE, groupName);
|
super(ENTITY_TYPE, TupleKey.createWithOneKeyPart(groupName));
|
||||||
this.groupNameEntity = groupName;
|
this._groupName = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CorpGroupUrn(TupleKey entityKey, String groupName) {
|
||||||
|
super("li", "corpGroup", entityKey);
|
||||||
|
this._groupName = groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupNameEntity() {
|
public String getGroupNameEntity() {
|
||||||
return groupNameEntity;
|
return _groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CorpGroupUrn createFromString(String rawUrn) throws URISyntaxException {
|
public static CorpGroupUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
String groupName = new Urn(rawUrn).getContent();
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
return new CorpGroupUrn(groupName);
|
}
|
||||||
|
|
||||||
|
private static CorpGroupUrn decodeUrn(String groupName) throws Exception {
|
||||||
|
return new CorpGroupUrn(TupleKey.create(new Object[]{groupName}), groupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CorpGroupUrn createFromUrn(Urn urn) throws URISyntaxException {
|
public static CorpGroupUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
throw new URISyntaxException(urn.toString(), "Can't cast URN to CorpGroupUrn, not same ENTITY");
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
}
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'corpGroup'.");
|
||||||
Matcher matcher = URN_PATTERN.matcher(urn.toString());
|
|
||||||
if (matcher.find()) {
|
|
||||||
return new CorpGroupUrn(matcher.group(1));
|
|
||||||
} else {
|
} else {
|
||||||
throw new URISyntaxException(urn.toString(), "CorpGroupUrn syntax error");
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 1) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return decodeUrn((String)key.getAs(0, String.class));
|
||||||
|
} catch (Exception var3) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + var3.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.linkedin.common.urn;
|
package com.linkedin.common.urn;
|
||||||
|
|
||||||
|
import com.linkedin.common.FabricType;
|
||||||
import com.linkedin.data.template.Custom;
|
import com.linkedin.data.template.Custom;
|
||||||
import com.linkedin.data.template.DirectCoercer;
|
import com.linkedin.data.template.DirectCoercer;
|
||||||
import com.linkedin.data.template.TemplateOutputCastException;
|
import com.linkedin.data.template.TemplateOutputCastException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
@ -12,34 +12,37 @@ public final class CorpuserUrn extends Urn {
|
|||||||
|
|
||||||
public static final String ENTITY_TYPE = "corpuser";
|
public static final String ENTITY_TYPE = "corpuser";
|
||||||
|
|
||||||
private static final Pattern URN_PATTERN = Pattern.compile("^" + URN_PREFIX + ENTITY_TYPE + ":([\\-\\w]+)$");
|
private final String _username;
|
||||||
|
|
||||||
private final String usernameEntity;
|
|
||||||
|
|
||||||
public CorpuserUrn(String username) {
|
public CorpuserUrn(String username) {
|
||||||
super(ENTITY_TYPE, username);
|
super(ENTITY_TYPE, TupleKey.create(username));
|
||||||
this.usernameEntity = username;
|
this._username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsernameEntity() {
|
public String getUsernameEntity() {
|
||||||
return usernameEntity;
|
return _username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CorpuserUrn createFromString(String rawUrn) throws URISyntaxException {
|
public static CorpuserUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
String username = new Urn(rawUrn).getContent();
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
return new CorpuserUrn(username);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CorpuserUrn createFromUrn(Urn urn) throws URISyntaxException {
|
public static CorpuserUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
throw new URISyntaxException(urn.toString(), "Can't cast URN to CorpuserUrn, not same ENTITY");
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
}
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'corpuser'.");
|
||||||
Matcher matcher = URN_PATTERN.matcher(urn.toString());
|
|
||||||
if (matcher.find()) {
|
|
||||||
return new CorpuserUrn(matcher.group(1));
|
|
||||||
} else {
|
} else {
|
||||||
throw new URISyntaxException(urn.toString(), "CorpuserUrn syntax error");
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 1) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new CorpuserUrn((String) key.getAs(0, String.class));
|
||||||
|
} catch (Exception var3) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + var3.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,31 +10,44 @@ public final class DashboardUrn extends Urn {
|
|||||||
|
|
||||||
public static final String ENTITY_TYPE = "dashboard";
|
public static final String ENTITY_TYPE = "dashboard";
|
||||||
|
|
||||||
private static final String CONTENT_FORMAT = "(%s,%s)";
|
private final String _dashboardTool;
|
||||||
|
private final String _dashboardId;
|
||||||
private final String dashboardToolEntity;
|
|
||||||
|
|
||||||
private final String dashboardIdEntity;
|
|
||||||
|
|
||||||
public DashboardUrn(String dashboardTool, String dashboardId) {
|
public DashboardUrn(String dashboardTool, String dashboardId) {
|
||||||
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, dashboardTool, dashboardId));
|
super(ENTITY_TYPE, TupleKey.create(dashboardId, dashboardId));
|
||||||
this.dashboardToolEntity = dashboardTool;
|
this._dashboardTool = dashboardTool;
|
||||||
this.dashboardIdEntity = dashboardId;
|
this._dashboardId = dashboardId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDashboardToolEntity() {
|
public String getDashboardToolEntity() {
|
||||||
return dashboardToolEntity;
|
return _dashboardTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDashboardIdEntity() {
|
public String getDashboardIdEntity() {
|
||||||
return dashboardIdEntity;
|
return _dashboardId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DashboardUrn createFromString(String rawUrn) throws URISyntaxException {
|
public static DashboardUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
Urn urn = new Urn(rawUrn);
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
validateUrn(urn, ENTITY_TYPE);
|
}
|
||||||
String[] urnParts = urn.getContent().split(",");
|
|
||||||
return new DashboardUrn(urnParts[0], urnParts[1]);
|
public static DashboardUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'dashboard'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 2) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new DashboardUrn((String) key.getAs(0, String.class), (String) key.getAs(1, String.class));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DashboardUrn deserialize(String rawUrn) throws URISyntaxException {
|
public static DashboardUrn deserialize(String rawUrn) throws URISyntaxException {
|
||||||
|
@ -11,20 +11,38 @@ public final class DataPlatformUrn extends Urn {
|
|||||||
|
|
||||||
public static final String ENTITY_TYPE = "dataPlatform";
|
public static final String ENTITY_TYPE = "dataPlatform";
|
||||||
|
|
||||||
private final String platformNameEntity;
|
private final String _platformName;
|
||||||
|
|
||||||
public DataPlatformUrn(String platformName) {
|
public DataPlatformUrn(String platformName) {
|
||||||
super(ENTITY_TYPE, platformName);
|
super(ENTITY_TYPE, TupleKey.create(platformName));
|
||||||
this.platformNameEntity = platformName;
|
this._platformName = platformName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlatformNameEntity() {
|
public String getPlatformNameEntity() {
|
||||||
return platformNameEntity;
|
return _platformName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataPlatformUrn createFromString(String rawUrn) throws URISyntaxException {
|
public static DataPlatformUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
String platformName = new Urn(rawUrn).getContent();
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
return new DataPlatformUrn(platformName);
|
}
|
||||||
|
|
||||||
|
public static DataPlatformUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'dataPlatform'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 1) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new DataPlatformUrn((String) key.getAs(0, String.class));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataPlatformUrn deserialize(String rawUrn) throws URISyntaxException {
|
public static DataPlatformUrn deserialize(String rawUrn) throws URISyntaxException {
|
||||||
|
@ -9,59 +9,76 @@ import java.net.URISyntaxException;
|
|||||||
|
|
||||||
import static com.linkedin.common.urn.UrnUtils.toFabricType;
|
import static com.linkedin.common.urn.UrnUtils.toFabricType;
|
||||||
|
|
||||||
|
|
||||||
public class DataProcessUrn extends Urn {
|
public class DataProcessUrn extends Urn {
|
||||||
public static final String ENTITY_TYPE = "dataProcess";
|
public static final String ENTITY_TYPE = "dataProcess";
|
||||||
|
|
||||||
private final String nameEntity;
|
private final String _name;
|
||||||
|
private final String _orchestrator;
|
||||||
|
private final FabricType _origin;
|
||||||
|
|
||||||
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
|
public DataProcessUrn(String orchestrator, String name, FabricType origin) {
|
||||||
|
super(ENTITY_TYPE, TupleKey.create(orchestrator, name, origin));
|
||||||
|
this._orchestrator = orchestrator;
|
||||||
|
this._name = name;
|
||||||
|
this._origin = origin;
|
||||||
|
}
|
||||||
|
|
||||||
private final String orchestrator;
|
public String getNameEntity() {
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
private final FabricType originEntity;
|
public String getOrchestratorEntity() {
|
||||||
|
return _orchestrator;
|
||||||
|
}
|
||||||
|
|
||||||
public DataProcessUrn(String orchestrator, String name, FabricType origin) {
|
public FabricType getOriginEntity() {
|
||||||
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, orchestrator, name, origin.name()));
|
return _origin;
|
||||||
this.orchestrator = orchestrator;
|
}
|
||||||
this.nameEntity = name;
|
|
||||||
this.originEntity = origin;
|
public static DataProcessUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataProcessUrn deserialize(String rawUrn) throws URISyntaxException {
|
||||||
|
return createFromString(rawUrn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataProcessUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'dataProcess'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 3) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new DataProcessUrn((String) key.getAs(0, String.class), (String) key.getAs(1, String.class),
|
||||||
|
(FabricType) key.getAs(2, FabricType.class));
|
||||||
|
} catch (Exception var3) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + var3.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNameEntity() {
|
static {
|
||||||
return nameEntity;
|
Custom.initializeCustomClass(DataProcessUrn.class);
|
||||||
}
|
Custom.initializeCustomClass(FabricType.class);
|
||||||
|
Custom.registerCoercer(new DirectCoercer<DataProcessUrn>() {
|
||||||
|
public Object coerceInput(DataProcessUrn object) throws ClassCastException {
|
||||||
|
return object.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public String getOrchestrator() {
|
public DataProcessUrn coerceOutput(Object object) throws TemplateOutputCastException {
|
||||||
return orchestrator;
|
try {
|
||||||
}
|
return DataProcessUrn.createFromString((String) object);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
public FabricType getOriginEntity() {
|
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
|
||||||
return originEntity;
|
}
|
||||||
}
|
}
|
||||||
|
}, DataProcessUrn.class);
|
||||||
public static DataProcessUrn createFromString(String rawUrn) throws URISyntaxException {
|
}
|
||||||
String content = new Urn(rawUrn).getContent();
|
|
||||||
String[] parts = content.substring(1, content.length() - 1).split(",");
|
|
||||||
return new DataProcessUrn(parts[0], parts[1], toFabricType(parts[2]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DataProcessUrn deserialize(String rawUrn) throws URISyntaxException {
|
|
||||||
return createFromString(rawUrn);
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
Custom.registerCoercer(new DirectCoercer<DataProcessUrn>() {
|
|
||||||
public Object coerceInput(DataProcessUrn object) throws ClassCastException {
|
|
||||||
return object.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataProcessUrn coerceOutput(Object object) throws TemplateOutputCastException {
|
|
||||||
try {
|
|
||||||
return DataProcessUrn.createFromString((String) object);
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, DataProcessUrn.class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,44 +6,56 @@ import com.linkedin.data.template.DirectCoercer;
|
|||||||
import com.linkedin.data.template.TemplateOutputCastException;
|
import com.linkedin.data.template.TemplateOutputCastException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import static com.linkedin.common.urn.UrnUtils.*;
|
|
||||||
|
|
||||||
|
|
||||||
public final class DatasetUrn extends Urn {
|
public final class DatasetUrn extends Urn {
|
||||||
|
|
||||||
public static final String ENTITY_TYPE = "dataset";
|
public static final String ENTITY_TYPE = "dataset";
|
||||||
|
|
||||||
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
|
private final DataPlatformUrn _platform;
|
||||||
|
private final String _datasetName;
|
||||||
private final DataPlatformUrn platformEntity;
|
private final FabricType _origin;
|
||||||
|
|
||||||
private final String datasetNameEntity;
|
|
||||||
|
|
||||||
private final FabricType originEntity;
|
|
||||||
|
|
||||||
public DatasetUrn(DataPlatformUrn platform, String name, FabricType origin) {
|
public DatasetUrn(DataPlatformUrn platform, String name, FabricType origin) {
|
||||||
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, platform.toString(), name, origin.name()));
|
super(ENTITY_TYPE, TupleKey.create(platform, name, origin));
|
||||||
this.platformEntity = platform;
|
this._platform = platform;
|
||||||
this.datasetNameEntity = name;
|
this._datasetName = name;
|
||||||
this.originEntity = origin;
|
this._origin = origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataPlatformUrn getPlatformEntity() {
|
public DataPlatformUrn getPlatformEntity() {
|
||||||
return platformEntity;
|
return _platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDatasetNameEntity() {
|
public String getDatasetNameEntity() {
|
||||||
return datasetNameEntity;
|
return _datasetName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FabricType getOriginEntity() {
|
public FabricType getOriginEntity() {
|
||||||
return originEntity;
|
return _origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DatasetUrn createFromString(String rawUrn) throws URISyntaxException {
|
public static DatasetUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
String content = new Urn(rawUrn).getContent();
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
String[] parts = content.substring(1, content.length() - 1).split(",");
|
}
|
||||||
return new DatasetUrn(DataPlatformUrn.createFromString(parts[0]), parts[1], toFabricType(parts[2]));
|
|
||||||
|
public static DatasetUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'dataset'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 3) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new DatasetUrn((DataPlatformUrn) key.getAs(0, DataPlatformUrn.class),
|
||||||
|
(String) key.getAs(1, String.class), (FabricType) key.getAs(2, FabricType.class));
|
||||||
|
} catch (Exception var3) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + var3.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DatasetUrn deserialize(String rawUrn) throws URISyntaxException {
|
public static DatasetUrn deserialize(String rawUrn) throws URISyntaxException {
|
||||||
@ -51,6 +63,9 @@ public final class DatasetUrn extends Urn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
Custom.initializeCustomClass(DataPlatformUrn.class);
|
||||||
|
Custom.initializeCustomClass(DatasetUrn.class);
|
||||||
|
Custom.initializeCustomClass(FabricType.class);
|
||||||
Custom.registerCoercer(new DirectCoercer<DatasetUrn>() {
|
Custom.registerCoercer(new DirectCoercer<DatasetUrn>() {
|
||||||
public Object coerceInput(DatasetUrn object) throws ClassCastException {
|
public Object coerceInput(DatasetUrn object) throws ClassCastException {
|
||||||
return object.toString();
|
return object.toString();
|
||||||
|
@ -1,17 +1,62 @@
|
|||||||
package com.linkedin.common.urn;
|
package com.linkedin.common.urn;
|
||||||
|
|
||||||
|
import com.linkedin.data.template.Custom;
|
||||||
|
import com.linkedin.data.template.DirectCoercer;
|
||||||
|
import com.linkedin.data.template.TemplateOutputCastException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
|
||||||
public final class FabricUrn extends Urn {
|
public final class FabricUrn extends Urn {
|
||||||
|
|
||||||
public static final String ENTITY_TYPE = "fabric";
|
public static final String ENTITY_TYPE = "fabric";
|
||||||
|
|
||||||
private final String nameEntity;
|
private final String _name;
|
||||||
|
|
||||||
public FabricUrn(String name) {
|
public FabricUrn(String name) {
|
||||||
super(ENTITY_TYPE, name);
|
super(ENTITY_TYPE, TupleKey.create(name));
|
||||||
this.nameEntity = name;
|
this._name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNameEntity() {
|
public String getNameEntity() {
|
||||||
return nameEntity;
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FabricUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FabricUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'fabric'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 1) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new FabricUrn((String) key.getAs(0, String.class));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
Custom.registerCoercer(new DirectCoercer<FabricUrn>() {
|
||||||
|
public Object coerceInput(FabricUrn object) throws ClassCastException {
|
||||||
|
return object.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FabricUrn coerceOutput(Object object) throws TemplateOutputCastException {
|
||||||
|
try {
|
||||||
|
return FabricUrn.createFromString((String) object);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, FabricUrn.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,69 @@
|
|||||||
package com.linkedin.common.urn;
|
package com.linkedin.common.urn;
|
||||||
|
|
||||||
|
import com.linkedin.data.template.Custom;
|
||||||
|
import com.linkedin.data.template.DirectCoercer;
|
||||||
|
import com.linkedin.data.template.TemplateOutputCastException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
|
||||||
public final class MLFeatureUrn extends Urn {
|
public final class MLFeatureUrn extends Urn {
|
||||||
|
|
||||||
public static final String ENTITY_TYPE = "mlFeature";
|
public static final String ENTITY_TYPE = "mlFeature";
|
||||||
|
|
||||||
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
|
private final String _mlFeatureNamespace;
|
||||||
|
|
||||||
private final String mlFeatureNamespace;
|
private final String _mlFeatureName;
|
||||||
|
|
||||||
private final String mlFeatureName;
|
|
||||||
|
|
||||||
public MLFeatureUrn(String mlFeatureNamespace, String mlFeatureName) {
|
public MLFeatureUrn(String mlFeatureNamespace, String mlFeatureName) {
|
||||||
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, mlFeatureNamespace, mlFeatureName));
|
super(ENTITY_TYPE, TupleKey.create(mlFeatureNamespace, mlFeatureName));
|
||||||
this.mlFeatureNamespace = mlFeatureNamespace;
|
this._mlFeatureNamespace = mlFeatureNamespace;
|
||||||
this.mlFeatureName = mlFeatureName;
|
this._mlFeatureName = mlFeatureName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMlFeatureName() {
|
public String getMlFeatureNameEntity() {
|
||||||
return mlFeatureName;
|
return _mlFeatureName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMlFeatureNamespace() {
|
public String getMlFeatureNamespaceEntity() {
|
||||||
return mlFeatureNamespace;
|
return _mlFeatureNamespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MLFeatureUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MLFeatureUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'mlFeature'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 2) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new MLFeatureUrn((String) key.getAs(0, String.class), (String) key.getAs(1, String.class));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
Custom.registerCoercer(new DirectCoercer<MLFeatureUrn>() {
|
||||||
|
public Object coerceInput(MLFeatureUrn object) throws ClassCastException {
|
||||||
|
return object.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MLFeatureUrn coerceOutput(Object object) throws TemplateOutputCastException {
|
||||||
|
try {
|
||||||
|
return MLFeatureUrn.createFromString((String) object);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, MLFeatureUrn.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package com.linkedin.common.urn;
|
package com.linkedin.common.urn;
|
||||||
|
|
||||||
|
import com.linkedin.data.template.Custom;
|
||||||
|
import com.linkedin.data.template.DirectCoercer;
|
||||||
|
import com.linkedin.data.template.TemplateOutputCastException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import com.linkedin.common.FabricType;
|
import com.linkedin.common.FabricType;
|
||||||
@ -11,40 +14,72 @@ public final class MLModelUrn extends Urn {
|
|||||||
|
|
||||||
public static final String ENTITY_TYPE = "mlModel";
|
public static final String ENTITY_TYPE = "mlModel";
|
||||||
|
|
||||||
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
|
private final DataPlatformUrn _platform;
|
||||||
|
private final String _mlModelName;
|
||||||
private final DataPlatformUrn platformEntity;
|
private final FabricType _origin;
|
||||||
|
|
||||||
private final String mlModelNameEntity;
|
|
||||||
|
|
||||||
private final FabricType originEntity;
|
|
||||||
|
|
||||||
public MLModelUrn(DataPlatformUrn platform, String mlModelName, FabricType origin) {
|
public MLModelUrn(DataPlatformUrn platform, String mlModelName, FabricType origin) {
|
||||||
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, platform.toString(), mlModelName, origin.name()));
|
super(ENTITY_TYPE, TupleKey.create(platform, mlModelName, origin));
|
||||||
this.platformEntity = platform;
|
this._platform = platform;
|
||||||
this.mlModelNameEntity = mlModelName;
|
this._mlModelName = mlModelName;
|
||||||
this.originEntity = origin;
|
this._origin = origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataPlatformUrn getPlatformEntity() {
|
public DataPlatformUrn getPlatformEntity() {
|
||||||
return platformEntity;
|
return _platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMlModelNameEntity() {
|
public String getMlModelNameEntity() {
|
||||||
return mlModelNameEntity;
|
return _mlModelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FabricType getOriginEntity() {
|
public FabricType getOriginEntity() {
|
||||||
return originEntity;
|
return _origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MLModelUrn createFromString(String rawUrn) throws URISyntaxException {
|
public static MLModelUrn createFromString(String rawUrn) throws URISyntaxException {
|
||||||
String content = new Urn(rawUrn).getContent();
|
return createFromUrn(Urn.createFromString(rawUrn));
|
||||||
String[] parts = content.substring(1, content.length() - 1).split(",");
|
}
|
||||||
return new MLModelUrn(DataPlatformUrn.createFromString(parts[0]), parts[1], toFabricType(parts[2]));
|
|
||||||
|
public static MLModelUrn createFromUrn(Urn urn) throws URISyntaxException {
|
||||||
|
if (!"li".equals(urn.getNamespace())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
|
||||||
|
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'mlFeature'.");
|
||||||
|
} else {
|
||||||
|
TupleKey key = urn.getEntityKey();
|
||||||
|
if (key.size() != 3) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new MLModelUrn((DataPlatformUrn) key.getAs(0, DataPlatformUrn.class),
|
||||||
|
(String) key.getAs(1, String.class), (FabricType) key.getAs(2, FabricType.class));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MLModelUrn deserialize(String rawUrn) throws URISyntaxException {
|
public static MLModelUrn deserialize(String rawUrn) throws URISyntaxException {
|
||||||
return createFromString(rawUrn);
|
return createFromString(rawUrn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
Custom.initializeCustomClass(DataPlatformUrn.class);
|
||||||
|
Custom.initializeCustomClass(FabricType.class);
|
||||||
|
Custom.registerCoercer(new DirectCoercer<MLModelUrn>() {
|
||||||
|
public Object coerceInput(MLModelUrn object) throws ClassCastException {
|
||||||
|
return object.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MLModelUrn coerceOutput(Object object) throws TemplateOutputCastException {
|
||||||
|
try {
|
||||||
|
return MLModelUrn.createFromString((String) object);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, MLModelUrn.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package com.linkedin.common.urn;
|
|
||||||
|
|
||||||
public final class MultiProductUrn extends Urn {
|
|
||||||
|
|
||||||
public static final String ENTITY_TYPE = "multiProduct";
|
|
||||||
|
|
||||||
private final String productNameEntity;
|
|
||||||
|
|
||||||
public MultiProductUrn(String productName) {
|
|
||||||
super(ENTITY_TYPE, productName);
|
|
||||||
this.productNameEntity = productName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProductNameEntity() {
|
|
||||||
return productNameEntity;
|
|
||||||
}
|
|
||||||
}
|
|
@ -32,7 +32,7 @@ public class DataProcessGraphBuilder extends BaseGraphBuilder<DataProcessSnapsho
|
|||||||
final DataProcessUrn urn = snapshot.getUrn();
|
final DataProcessUrn urn = snapshot.getUrn();
|
||||||
final DataProcessEntity entity = new DataProcessEntity().setUrn(urn)
|
final DataProcessEntity entity = new DataProcessEntity().setUrn(urn)
|
||||||
.setName(urn.getNameEntity())
|
.setName(urn.getNameEntity())
|
||||||
.setOrchestrator(urn.getOrchestrator())
|
.setOrchestrator(urn.getOrchestratorEntity())
|
||||||
.setOrigin(urn.getOriginEntity());
|
.setOrigin(urn.getOriginEntity());
|
||||||
|
|
||||||
return Collections.singletonList(entity);
|
return Collections.singletonList(entity);
|
||||||
|
@ -25,7 +25,7 @@ public class DataProcessIndexBuilder extends BaseIndexBuilder<DataProcessDocumen
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static String buildBrowsePath(@Nonnull DataProcessUrn urn) {
|
private static String buildBrowsePath(@Nonnull DataProcessUrn urn) {
|
||||||
return ("/" + urn.getOriginEntity() + "/" + urn.getOrchestrator() + "/" + urn.getNameEntity())
|
return ("/" + urn.getOriginEntity() + "/" + urn.getOrchestratorEntity() + "/" + urn.getNameEntity())
|
||||||
.replace('.', '/').toLowerCase();
|
.replace('.', '/').toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public class DataProcessIndexBuilder extends BaseIndexBuilder<DataProcessDocumen
|
|||||||
private static DataProcessDocument setUrnDerivedFields(@Nonnull DataProcessUrn urn) {
|
private static DataProcessDocument setUrnDerivedFields(@Nonnull DataProcessUrn urn) {
|
||||||
return new DataProcessDocument()
|
return new DataProcessDocument()
|
||||||
.setName(urn.getNameEntity())
|
.setName(urn.getNameEntity())
|
||||||
.setOrchestrator(urn.getOrchestrator())
|
.setOrchestrator(urn.getOrchestratorEntity())
|
||||||
.setUrn(urn)
|
.setUrn(urn)
|
||||||
.setBrowsePaths(new StringArray(Collections.singletonList(buildBrowsePath(urn))));
|
.setBrowsePaths(new StringArray(Collections.singletonList(buildBrowsePath(urn))));
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class DataProcessGraphBuilderTest {
|
|||||||
DataProcessSnapshot snapshot = new DataProcessSnapshot().setUrn(urn).setAspects(new DataProcessAspectArray());
|
DataProcessSnapshot snapshot = new DataProcessSnapshot().setUrn(urn).setAspects(new DataProcessAspectArray());
|
||||||
DataProcessEntity expected = new DataProcessEntity().setUrn(urn)
|
DataProcessEntity expected = new DataProcessEntity().setUrn(urn)
|
||||||
.setName(urn.getNameEntity())
|
.setName(urn.getNameEntity())
|
||||||
.setOrchestrator(urn.getOrchestrator())
|
.setOrchestrator(urn.getOrchestratorEntity())
|
||||||
.setOrigin(urn.getOriginEntity());
|
.setOrigin(urn.getOriginEntity());
|
||||||
|
|
||||||
List<? extends RecordTemplate> dataProcessEntities = new DataProcessGraphBuilder().buildEntities(snapshot);
|
List<? extends RecordTemplate> dataProcessEntities = new DataProcessGraphBuilder().buildEntities(snapshot);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user