John Plaisted 25b663cc18
refactor: move code to linkedin/datahub-gma. (#1955)
Move code to linkedin/datahub-gma.

"GMA" (Generalized Metadata Architecture) is the backend of DataHub, and has been moved to its own repository.

This deletes the code that was moved and uses jars that GMA publishes to bintray to load it.

Note that not all of GMA was moved, but most of it. We may still move more things to the other repository in the future.
2020-10-23 15:14:57 -07:00

68 lines
2.2 KiB
Java

package com.linkedin.common.urn;
import com.linkedin.common.FabricType;
import com.linkedin.data.template.Custom;
import com.linkedin.data.template.DirectCoercer;
import com.linkedin.data.template.TemplateOutputCastException;
import java.net.URISyntaxException;
import static com.linkedin.common.urn.UrnUtils.toFabricType;
public class DataProcessUrn extends Urn {
public static final String ENTITY_TYPE = "dataProcess";
private final String nameEntity;
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
private final String orchestrator;
private final FabricType originEntity;
public DataProcessUrn(String orchestrator, String name, FabricType origin) {
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, orchestrator, name, origin.name()));
this.orchestrator = orchestrator;
this.nameEntity = name;
this.originEntity = origin;
}
public String getNameEntity() {
return nameEntity;
}
public String getOrchestrator() {
return orchestrator;
}
public FabricType getOriginEntity() {
return originEntity;
}
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);
}
}