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

3410 bug missing concepts and datatype in dataset enrichment #3422

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,25 @@ function onCellEditComplete() {
}

function formatData(data: DatasetColumn[]) {
return data.map((col) => ({
id: col.name,
name: formatName(col.name),
description: col.description,
concept: col.metadata?.groundings?.identifiers,
unit: col.metadata?.unit,
dataType: col.metadata?.column_stats?.type,
stats: col.metadata?.column_stats,
column: col
}));
return data.map((col) => {
let concept: object | undefined;
if (col.metadata?.groundings?.identifiers) {
concept = col.metadata.groundings.identifiers;
} else if (col.grounding?.identifiers[0]) {
concept = parseCurie(String(col.grounding.identifiers[0].curie));
}

return {
id: col.name,
name: formatName(col.name),
description: col.description,
concept,
unit: col.metadata?.unit,
dataType: col.metadata?.column_stats?.type,
stats: col.metadata?.column_stats,
column: col
};
});
}
</script>

Expand Down
7 changes: 6 additions & 1 deletion packages/client/hmi-client/src/types/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ export interface CsvColumnStats {
}

export interface Grounding {
identifiers: { [index: string]: string };
identifiers: Identifier[];
context?: { [index: string]: any };
}

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

export interface PresignedURL {
url: string;
method: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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 Down Expand Up @@ -584,9 +585,11 @@ public ResponseEntity<Dataset> postProfileDataset(
continue;
}
if (groundings.getIdentifiers() == null) {
groundings.setIdentifiers(new HashMap<>());
groundings.setIdentifiers(new ArrayList<>());
}
groundings.getIdentifiers().put(g.get(0).asText(), g.get(1).asText());
groundings
.getIdentifiers()
.add(new Identifier(g.get(0).asText(), g.get(1).asText()));
}

// remove groundings from annotation object
Expand All @@ -596,10 +599,11 @@ public ResponseEntity<Dataset> postProfileDataset(
newCol.setName(col.getName());
newCol.setDataType(col.getDataType());
newCol.setFormatStr(col.getFormatStr());
newCol.setGrounding(col.getGrounding());
newCol.setGrounding(groundings);
newCol.setAnnotations(col.getAnnotations());
newCol.setDescription(annotation.get("description").asText());
newCol.setMetadata(mapper.convertValue(annotation, Map.class));
newCol.setMetadata(col.getMetadata());
newCol.updateMetadata(mapper.convertValue(annotation, Map.class));
columns.add(newCol);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.experimental.Accessors;
Expand All @@ -18,7 +19,7 @@ public class Grounding implements Serializable {
private static final long serialVersionUID = 302308407252037615L;

/** Ontological identifier per DKG */
private Map<String, String> identifiers;
private List<Identifier> identifiers;

/** (Optional) Additional context that informs the grounding */
@TSOptional
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package software.uncharted.terarium.hmiserver.models.dataservice;

import java.io.Serializable;
import software.uncharted.terarium.hmiserver.annotations.TSModel;

@TSModel
public record Identifier(String curie, String name) implements Serializable {
private static final long serialVersionUID = 302308407252037615L;
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,12 @@ enum ColumnType {
@JsonAlias("time")
TIME
}

public void updateMetadata(final Map<String, Object> metadata) {
if (this.metadata == null) {
this.metadata = metadata;
} else {
this.metadata.putAll(metadata);
}
}
}
Loading