Skip to content

Commit

Permalink
Make sure these equations match the format of the existing ones. (#5111)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbirk authored Oct 9, 2024
1 parent 32f62ac commit 8ada802
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import software.uncharted.terarium.hmiserver.models.dataservice.document.DocumentAsset;
import software.uncharted.terarium.hmiserver.models.dataservice.document.ExtractedDocumentPage;
import software.uncharted.terarium.hmiserver.models.dataservice.provenance.Provenance;
import software.uncharted.terarium.hmiserver.models.dataservice.provenance.ProvenanceRelationType;
import software.uncharted.terarium.hmiserver.models.dataservice.provenance.ProvenanceType;
Expand Down Expand Up @@ -86,12 +88,19 @@ public TaskResponse onSuccess(final TaskResponse resp) {

// get the existing equations and add the new ones
final ArrayNode existingEquations = (ArrayNode) document.getMetadata().get("equations");
for (final JsonNode equation : equations.response.get("equations")) {
existingEquations.add(equation);
}

existingEquations.add(equations.response.get("equations"));
document.getMetadata().put("equations", existingEquations);

// add to the extractions field
final List<JsonNode> newEquations = new ArrayList<>();
for (final JsonNode node : equations.response.get("equations")) {
newEquations.add(node);
}
final ExtractedDocumentPage newPage = new ExtractedDocumentPage()
.setPageNumber(document.getExtractions().size() + 1)
.setEquations(newEquations);
document.getExtractions().add(newPage);

documentService.updateAsset(document, props.projectId, ASSUME_WRITE_PERMISSION_ON_BEHALF_OF_USER).orElseThrow();

// add provenance
Expand Down

0 comments on commit 8ada802

Please sign in to comment.