2020-05-20 15:45:59 -05:00
|
|
|
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";
|
|
|
|
|
2020-06-09 17:42:08 -05:00
|
|
|
private final String nameEntity;
|
2020-05-20 15:45:59 -05:00
|
|
|
|
|
|
|
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
|
|
|
|
|
2020-06-09 17:42:08 -05:00
|
|
|
private final String orchestrator;
|
2020-05-20 15:45:59 -05:00
|
|
|
|
|
|
|
private final FabricType originEntity;
|
|
|
|
|
|
|
|
public DataProcessUrn(String orchestrator, String name, FabricType origin) {
|
|
|
|
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, orchestrator, name, origin.name()));
|
2020-06-09 17:42:08 -05:00
|
|
|
this.orchestrator = orchestrator;
|
|
|
|
this.nameEntity = name;
|
2020-05-20 15:45:59 -05:00
|
|
|
this.originEntity = origin;
|
|
|
|
}
|
|
|
|
|
2020-06-09 17:42:08 -05:00
|
|
|
public String getNameEntity() {
|
|
|
|
return nameEntity;
|
2020-05-20 15:45:59 -05:00
|
|
|
}
|
|
|
|
|
2020-06-09 17:42:08 -05:00
|
|
|
public String getOrchestrator() {
|
|
|
|
return orchestrator;
|
2020-05-20 15:45:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|