forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataProcessUrn.java
84 lines (69 loc) · 2.76 KB
/
DataProcessUrn.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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 _name;
private final String _orchestrator;
private final FabricType _origin;
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;
}
public String getNameEntity() {
return _name;
}
public String getOrchestratorEntity() {
return _orchestrator;
}
public FabricType getOriginEntity() {
return _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());
}
}
}
}
static {
Custom.initializeCustomClass(DataProcessUrn.class);
Custom.initializeCustomClass(FabricType.class);
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);
}
}