Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework Model, Dataset and Document models to use the same underlying dkg #5469

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions packages/client/hmi-client/src/types/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,10 @@ export interface CsvColumnStats {
}

export interface Grounding extends TerariumEntity {
identifiers: Identifier[];
identifiers: DKG[];
context?: any;
}

export interface Identifier {
curie: string;
name: string;
}

export interface PresignedURL {
url: string;
method: string;
Expand Down Expand Up @@ -799,10 +794,10 @@ export interface ModelUnit {
}

export interface GroundedSemantic {
grounding?: ModelGrounding;
id: string;
name?: string;
description?: string;
grounding?: ModelGrounding;
}

export interface Properties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ResponseStatusException;
import software.uncharted.terarium.hmiserver.models.dataservice.Grounding;
import software.uncharted.terarium.hmiserver.models.dataservice.Identifier;
import software.uncharted.terarium.hmiserver.models.dataservice.code.Code;
import software.uncharted.terarium.hmiserver.models.dataservice.code.CodeFile;
import software.uncharted.terarium.hmiserver.models.dataservice.dataset.Dataset;
Expand All @@ -59,6 +58,7 @@
import software.uncharted.terarium.hmiserver.models.dataservice.provenance.ProvenanceRelationType;
import software.uncharted.terarium.hmiserver.models.dataservice.provenance.ProvenanceType;
import software.uncharted.terarium.hmiserver.models.extractionservice.ExtractionResponse;
import software.uncharted.terarium.hmiserver.models.mira.DKG;
import software.uncharted.terarium.hmiserver.models.task.TaskRequest;
import software.uncharted.terarium.hmiserver.models.task.TaskRequest.TaskType;
import software.uncharted.terarium.hmiserver.models.task.TaskResponse;
Expand Down Expand Up @@ -679,7 +679,7 @@ public ResponseEntity<Dataset> postProfileDataset(
if (groundings.getIdentifiers() == null) {
groundings.setIdentifiers(new ArrayList<>());
}
groundings.getIdentifiers().add(new Identifier(g.get(0).asText(), g.get(1).asText()));
groundings.getIdentifiers().add(new DKG(g.get(0).asText(), g.get(1).asText(), null));
}

// remove groundings from annotation object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import software.uncharted.terarium.hmiserver.annotations.TSModel;
import software.uncharted.terarium.hmiserver.annotations.TSOptional;
import software.uncharted.terarium.hmiserver.models.TerariumEntity;
import software.uncharted.terarium.hmiserver.models.mira.DKG;

/** Represents a grounding document from TDS */
@Data
Expand All @@ -29,7 +30,7 @@ public class Grounding extends TerariumEntity {
/** Ontological identifier per DKG */
@Type(JsonType.class)
@Column(columnDefinition = "json")
private List<Identifier> identifiers;
private List<DKG> identifiers;

/** (Optional) Additional context that informs the grounding */
@TSOptional
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;
import software.uncharted.terarium.hmiserver.annotations.TSModel;

@Data
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@TSModel
@AllArgsConstructor
public class DKG {

public static final String ID = "id:ID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import software.uncharted.terarium.hmiserver.TerariumApplicationTests;
import software.uncharted.terarium.hmiserver.configuration.MockUser;
import software.uncharted.terarium.hmiserver.models.dataservice.Grounding;
import software.uncharted.terarium.hmiserver.models.dataservice.Identifier;
import software.uncharted.terarium.hmiserver.models.dataservice.dataset.Dataset;
import software.uncharted.terarium.hmiserver.models.dataservice.dataset.DatasetColumn;
import software.uncharted.terarium.hmiserver.models.dataservice.project.Project;
import software.uncharted.terarium.hmiserver.models.mira.DKG;

@Slf4j
public class DatasetServiceTests extends TerariumApplicationTests {
Expand Down Expand Up @@ -60,7 +60,7 @@ static Grounding createGrounding(final String key) {
final Grounding grounding = new Grounding();
grounding.setContext(mapper.createObjectNode().put("hello", "world-" + key).put("foo", "bar-" + key));
grounding.setIdentifiers(new ArrayList<>());
grounding.getIdentifiers().add(new Identifier("curie", "maria"));
grounding.getIdentifiers().add(new DKG("curie", "maria", null));
return grounding;
}

Expand Down Expand Up @@ -116,8 +116,8 @@ public void testItCanCreateDataset() throws Exception {
Assertions.assertNotNull(col.getGrounding().getCreatedOn());
Assertions.assertNotNull(col.getGrounding().getIdentifiers());
Assertions.assertEquals(col.getGrounding().getIdentifiers().size(), 1);
Assertions.assertNotNull(col.getGrounding().getIdentifiers().get(0).curie());
Assertions.assertNotNull(col.getGrounding().getIdentifiers().get(0).name());
Assertions.assertNotNull(col.getGrounding().getIdentifiers().get(0).getCurie());
Assertions.assertNotNull(col.getGrounding().getIdentifiers().get(0).getName());
Assertions.assertNotNull(col.getGrounding().getContext());
Assertions.assertEquals(col.getGrounding().getContext().size(), 2);
}
Expand All @@ -126,8 +126,8 @@ public void testItCanCreateDataset() throws Exception {
Assertions.assertNotNull(after.getGrounding().getId());
Assertions.assertNotNull(after.getGrounding().getCreatedOn());
Assertions.assertNotNull(after.getGrounding().getIdentifiers());
Assertions.assertNotNull(after.getGrounding().getIdentifiers().get(0).curie());
Assertions.assertNotNull(after.getGrounding().getIdentifiers().get(0).name());
Assertions.assertNotNull(after.getGrounding().getIdentifiers().get(0).getCurie());
Assertions.assertNotNull(after.getGrounding().getIdentifiers().get(0).getName());
Assertions.assertNotNull(after.getGrounding().getContext());
Assertions.assertEquals(after.getGrounding().getContext().size(), 2);
}
Expand Down Expand Up @@ -169,8 +169,8 @@ public void testItCanCreateDatasetAndAddColumnsLater() throws Exception {
Assertions.assertNotNull(col.getGrounding().getCreatedOn());
Assertions.assertNotNull(col.getGrounding().getIdentifiers());
Assertions.assertEquals(col.getGrounding().getIdentifiers().size(), 1);
Assertions.assertNotNull(col.getGrounding().getIdentifiers().get(0).curie());
Assertions.assertNotNull(col.getGrounding().getIdentifiers().get(0).name());
Assertions.assertNotNull(col.getGrounding().getIdentifiers().get(0).getCurie());
Assertions.assertNotNull(col.getGrounding().getIdentifiers().get(0).getName());
Assertions.assertNotNull(col.getGrounding().getContext());
Assertions.assertEquals(col.getGrounding().getContext().size(), 2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import software.uncharted.terarium.hmiserver.TerariumApplicationTests;
import software.uncharted.terarium.hmiserver.configuration.MockUser;
import software.uncharted.terarium.hmiserver.models.dataservice.Grounding;
import software.uncharted.terarium.hmiserver.models.dataservice.Identifier;
import software.uncharted.terarium.hmiserver.models.dataservice.document.DocumentAsset;
import software.uncharted.terarium.hmiserver.models.dataservice.document.DocumentExtraction;
import software.uncharted.terarium.hmiserver.models.dataservice.document.ExtractionAssetType;
import software.uncharted.terarium.hmiserver.models.dataservice.project.Project;
import software.uncharted.terarium.hmiserver.models.mira.DKG;

@Slf4j
public class DocumentServiceTests extends TerariumApplicationTests {
Expand Down Expand Up @@ -63,7 +63,7 @@ static Grounding createGrounding(final String key) {
final Grounding grounding = new Grounding();
grounding.setContext(mapper.createObjectNode().put("hello", "world-" + key).put("foo", "bar-" + key));
grounding.setIdentifiers(new ArrayList<>());
grounding.getIdentifiers().add(new Identifier("curie", "maria"));
grounding.getIdentifiers().add(new DKG("curie", "maria", null));
return grounding;
}

Expand Down Expand Up @@ -106,8 +106,8 @@ public void testItCanCreateDocument() throws Exception {
Assertions.assertNotNull(after.getGrounding().getId());
Assertions.assertNotNull(after.getGrounding().getCreatedOn());
Assertions.assertNotNull(after.getGrounding().getIdentifiers());
Assertions.assertNotNull(after.getGrounding().getIdentifiers().get(0).curie());
Assertions.assertNotNull(after.getGrounding().getIdentifiers().get(0).name());
Assertions.assertNotNull(after.getGrounding().getIdentifiers().get(0).getCurie());
Assertions.assertNotNull(after.getGrounding().getIdentifiers().get(0).getName());
Assertions.assertNotNull(after.getGrounding().getContext());
Assertions.assertEquals(after.getGrounding().getContext().size(), 2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import software.uncharted.terarium.hmiserver.models.TerariumAsset;
import software.uncharted.terarium.hmiserver.models.dataservice.AssetType;
import software.uncharted.terarium.hmiserver.models.dataservice.Grounding;
import software.uncharted.terarium.hmiserver.models.dataservice.Identifier;
import software.uncharted.terarium.hmiserver.models.dataservice.document.DocumentAsset;
import software.uncharted.terarium.hmiserver.models.dataservice.document.DocumentExtraction;
import software.uncharted.terarium.hmiserver.models.dataservice.document.ExtractionAssetType;
Expand All @@ -29,6 +28,7 @@
import software.uncharted.terarium.hmiserver.models.dataservice.workflow.Workflow;
import software.uncharted.terarium.hmiserver.models.dataservice.workflow.WorkflowEdge;
import software.uncharted.terarium.hmiserver.models.dataservice.workflow.WorkflowNode;
import software.uncharted.terarium.hmiserver.models.mira.DKG;
import software.uncharted.terarium.hmiserver.service.TerariumAssetCloneService;

public class TerariumAssetCloneServiceTests extends TerariumApplicationTests {
Expand Down Expand Up @@ -74,7 +74,7 @@ static Grounding createGrounding(final String key) {
final Grounding grounding = new Grounding();
grounding.setContext(objectMapper.createObjectNode().put("hello", "world-" + key).put("foo", "bar-" + key));
grounding.setIdentifiers(new ArrayList<>());
grounding.getIdentifiers().add(new Identifier("curie", "maria"));
grounding.getIdentifiers().add(new DKG("curie", "maria", null));
return grounding;
}

Expand Down