Skip to content

Commit 8795274

Browse files
DataHub Docker & Helm Chart
1 parent 472ae12 commit 8795274

File tree

18 files changed

+755
-28
lines changed

18 files changed

+755
-28
lines changed

datahub/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@
6060
<artifactId>api-nexus-security</artifactId>
6161
<version>1.0-SNAPSHOT</version>
6262
</dependency>
63-
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-starter-test</artifactId>
66+
<scope>test</scope>
67+
</dependency>
6468
<dependency>
6569
<groupId>org.pantherslabs.chimera</groupId>
6670
<artifactId>api-nexus-db</artifactId>

datahub/src/main/java/org/pantherslabs/chimera/sentinel/datahub/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public class Constants {
6060
// been processed and
6161
// should not be reprocessed
6262
public static final String APP_SOURCE = "appSource";
63+
public static final String APP_URN_PREFIX = "urn:li:application:";
64+
public static final String APPLICATION_ENTITY_NAME = "application";
6365

6466
// App sources
6567
public static final String UI_SOURCE = "ui";

datahub/src/main/java/org/pantherslabs/chimera/sentinel/datahub/api/DataHub.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
@SpringBootApplication
99
@ComponentScan(basePackages = "org.pantherslabs.chimera.sentinel.datahub.api")
10-
@MapperScan("org.pantherslabs.chimera.sentinel.datahub.api.mapper.generated")
11-
@MapperScan("org.pantherslabs.chimera.unisca.api_nexus.api_nexus_client.dynamic_query.mapper")
10+
@MapperScan({
11+
"org.pantherslabs.chimera.sentinel.datahub.api.mapper.generated",
12+
"org.pantherslabs.chimera.unisca.api_nexus.api_nexus_client.dynamic_query.mapper"
13+
})
1214
public class DataHub {
1315
public static void main(String[] args) {
1416
SpringApplication.run(DataHub.class, args);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package org.pantherslabs.chimera.sentinel.datahub.api.controller;
2+
3+
import org.pantherslabs.chimera.sentinel.datahub.api.service.ManageDatasets;
4+
import org.pantherslabs.chimera.sentinel.datahub.modal.EmitResult;
5+
import org.pantherslabs.chimera.unisca.api_nexus.api_nexus_client.response.SuccessResponse;
6+
import org.pantherslabs.chimera.unisca.exception.ChimeraException;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.http.HttpStatus;
9+
import org.springframework.http.ResponseEntity;
10+
import org.springframework.web.bind.annotation.*;
11+
import org.springframework.http.ResponseEntity;
12+
import java.util.List;
13+
import java.util.Map;
14+
import java.util.stream.Collectors;
15+
16+
@RestController
17+
@RequestMapping("/api/dataset")
18+
public class DatasetController {
19+
20+
@Autowired
21+
ManageDatasets manageDatasets;
22+
/**
23+
* Accepts a dataset definition as JSON string (raw body) and a createdBy query parameter.
24+
*/
25+
26+
@PostMapping("/create")
27+
public ResponseEntity<?> createDataset(
28+
@RequestBody String datasetDefinitionJson,
29+
@RequestParam(name = "inFormat", required = false, defaultValue = "json") String inFormat) {
30+
EmitResult result = null;
31+
try {
32+
result = manageDatasets.createDataset(datasetDefinitionJson, inFormat, "UPSERT");
33+
List<SuccessResponse> summaries = result.getSucceeded().stream()
34+
.map(p -> new SuccessResponse(
35+
p.getEntityUrn().toString() + " " + p.getAspectName() + " created successfully..", "200"))
36+
.collect(Collectors.toList());
37+
return ResponseEntity.ok(summaries);
38+
} catch (Exception e) {
39+
assert result != null;
40+
throw new ChimeraException(
41+
"APIException." + result.getErrorDetails().getStatus(),
42+
Map.of("exception", result.getErrorDetails().getMessage()),
43+
null,
44+
HttpStatus.valueOf(result.getErrorDetails().getStatus())
45+
);
46+
}
47+
}
48+
49+
}

datahub/src/main/java/org/pantherslabs/chimera/sentinel/datahub/api/controller/OwnershipController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public ResponseEntity<?> addOwners(@RequestBody OwnerRequest request) {
4242
EmitResult result = null;
4343
try {
4444
Urn urn = Urn.createFromString(request.getEntityUrn());
45-
result = manageOwnership.createOwners(
45+
result = ManageOwnership.createOwners(
4646
urn,
4747
request.getEntityType(),
4848
request.getOwnersInfo(),
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package org.pantherslabs.chimera.sentinel.datahub.api.dto;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
import javax.validation.constraints.NotNull;
7+
import java.util.List;
8+
9+
@Getter
10+
@Setter
11+
public class Dataset {
12+
13+
// Required fields
14+
@NotNull
15+
private String dataProductName;
16+
17+
@NotNull
18+
private String name;
19+
20+
@NotNull
21+
private String fabricType;
22+
23+
@NotNull
24+
private String datasetPlatformName;
25+
26+
// Optional fields
27+
private String displayName;
28+
private String description;
29+
private String qualifiedName;
30+
private String uri;
31+
private String domain;
32+
33+
private List<Tag> tags;
34+
private List<Property> properties;
35+
private List<Owners> owners;
36+
private List<GlossaryTerm> glossaryTerm;
37+
private List<Field> fields;
38+
39+
// Constructors
40+
public Dataset() {}
41+
42+
public Dataset(@NotNull String dataProductName, @NotNull String name, @NotNull String fabricType,
43+
@NotNull String datasetPlatformName) {
44+
this.dataProductName = dataProductName;
45+
this.name = name;
46+
this.fabricType = fabricType;
47+
this.datasetPlatformName = datasetPlatformName;
48+
}
49+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.pantherslabs.chimera.sentinel.datahub.api.dto;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
import org.pantherslabs.chimera.sentinel.datahub.modal.ForeignKey;
7+
import org.pantherslabs.chimera.sentinel.datahub.modal.GlossaryTerm;
8+
import org.pantherslabs.chimera.sentinel.datahub.modal.Tag;
9+
10+
import java.util.List;
11+
12+
@Getter
13+
@Setter
14+
//@JsonIgnoreProperties(ignoreUnknown = true)
15+
16+
public class Field {
17+
18+
public Field(){}
19+
20+
public Field(String name, String type, String displayName, String description, String fieldCanonicalName,
21+
int maxLength, boolean isPartitionKey, boolean isPrimaryKey, boolean isSampleTime, boolean isNullable,
22+
List<ForeignKey> foreignKey, List<org.pantherslabs.chimera.sentinel.datahub.modal.Tag> tags, List<org.pantherslabs.chimera.sentinel.datahub.modal.GlossaryTerm> glossaryTerm) {
23+
this.name = name;
24+
this.type = type;
25+
this.displayName = displayName;
26+
this.description = description;
27+
this.fieldCanonicalName = fieldCanonicalName;
28+
this.maxLength = maxLength;
29+
this.isPartitionKey = isPartitionKey;
30+
this.isPrimaryKey = isPrimaryKey;
31+
this.isSampleTime = isSampleTime;
32+
this.isNullable = isNullable;
33+
this.foreignKey = foreignKey;
34+
this.tags = tags;
35+
this.glossaryTerm = glossaryTerm;
36+
}
37+
38+
@JsonProperty("name")
39+
private String name;
40+
@JsonProperty("type")
41+
private String type;
42+
@JsonProperty("displayName")
43+
private String displayName;
44+
@JsonProperty("description")
45+
private String description;
46+
@JsonProperty("fieldCanonicalName")
47+
private String fieldCanonicalName;
48+
@JsonProperty("maxLength")
49+
private int maxLength;
50+
@JsonProperty("isPartitionKey")
51+
private boolean isPartitionKey;
52+
@JsonProperty("isPrimaryKey")
53+
private boolean isPrimaryKey;
54+
@JsonProperty("isSampleTime")
55+
private boolean isSampleTime;
56+
@JsonProperty("isNullable")
57+
private boolean isNullable;
58+
@JsonProperty("foreignKey")
59+
private List<ForeignKey> foreignKey;
60+
@JsonProperty("tags")
61+
private List<Tag> tags;
62+
@JsonProperty("glossaryTerm")
63+
private List<GlossaryTerm> glossaryTerm;
64+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.pantherslabs.chimera.sentinel.datahub.api.dto;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
import org.pantherslabs.chimera.sentinel.datahub.modal.GlossaryNodeGroup;
6+
import org.pantherslabs.chimera.sentinel.datahub.modal.GlossaryRelatedTerm;
7+
8+
import java.util.List;
9+
import java.util.Map;
10+
11+
@Getter
12+
@Setter
13+
public class GlossaryTerm {
14+
15+
public GlossaryTerm(){}
16+
17+
public GlossaryTerm(String glossaryTermName, String documentations, String parentTermName, String sourceRef,
18+
String sourceURL, GlossaryNodeGroup glossaryNodeRecord, List<GlossaryRelatedTerm>
19+
glossaryRelatedTermsRecord, Map<String, String> customProperties) {
20+
this.glossaryTermName = glossaryTermName;
21+
this.documentations = documentations;
22+
this.parentTermName = parentTermName;
23+
this.sourceRef = sourceRef;
24+
this.sourceURL = sourceURL;
25+
this.glossaryNodeRecord = glossaryNodeRecord;
26+
this.glossaryRelatedTermsRecord = glossaryRelatedTermsRecord;
27+
this.customProperties = customProperties;
28+
}
29+
30+
private String glossaryTermName;
31+
private String documentations;
32+
private String parentTermName;
33+
private String sourceRef;
34+
private String sourceURL;
35+
private GlossaryNodeGroup glossaryNodeRecord;
36+
private List<GlossaryRelatedTerm> glossaryRelatedTermsRecord;
37+
private Map<String, String> customProperties;
38+
39+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.pantherslabs.chimera.sentinel.datahub.api.dto;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
import javax.validation.constraints.NotNull;
7+
import java.util.Locale;
8+
import java.util.Set;
9+
10+
@Getter
11+
@Setter
12+
public class Owners {
13+
14+
// Valid owners set as a constant
15+
private static final Set<String> VALID_OWNERS = Set.of(
16+
"CUSTOM", "TECHNICAL_OWNER", "BUSINESS_OWNER", "DATA_STEWARD",
17+
"NONE", "DEVELOPER", "DATAOWNER", "PRODUCER",
18+
"DELEGATE", "CONSUMER", "STAKEHOLDER", "$UNKNOWN"
19+
);
20+
21+
// Get the name of the owner
22+
@Getter
23+
@NotNull
24+
private String name;
25+
26+
public Owners(){}
27+
28+
public Owners(String name, String type) {
29+
this.name = name;
30+
this.type = type;
31+
}
32+
33+
@NotNull
34+
private String type;
35+
36+
// Get the type of the owner, with validation logic
37+
public String getType() {
38+
// Check if type is null or empty before proceeding
39+
if (type == null || type.trim().isEmpty()) {
40+
return "urn:li:ownershipType:__system__none";
41+
}
42+
43+
return VALID_OWNERS.contains(type.toUpperCase(Locale.ROOT)) ?
44+
"urn:li:ownershipType:__system__" + type.toLowerCase(Locale.ROOT) :
45+
"urn:li:ownershipType:__system__none";
46+
47+
}
48+
}
49+
50+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.pantherslabs.chimera.sentinel.datahub.api.dto;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
import javax.validation.constraints.NotNull;
7+
8+
@Setter
9+
@Getter
10+
public class Property {
11+
12+
// Getters and Setters
13+
@NotNull
14+
private String name;
15+
16+
@NotNull
17+
private String value;
18+
19+
public Property(){}
20+
// Constructor
21+
public Property(String name, String value) {
22+
this.name = name;
23+
this.value = value;
24+
}
25+
26+
}

0 commit comments

Comments
 (0)