Skip to content

Commit

Permalink
force observable field to exist (#4616)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwdchang authored Aug 29, 2024
1 parent 9d3db66 commit ee859da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ ResponseEntity<Model> getModel(
log.debug("Unable to get the, or empty, provenance search models_from_document for model " + id);
}

// Force observable to empty-list if null or not specified
if (model.get().getSemantics() != null) {
if (model.get().getSemantics().getOde().getObservables() == null) {
model.get().getSemantics().getOde().setObservables(new ArrayList());
}
}

// Return the model
return ResponseEntity.ok(model.get());
} catch (final Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.micrometer.observation.annotation.Observed;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -159,6 +160,13 @@ public Model createAsset(final Model asset, final UUID projectId, final Schema.P
});
}

// Force observable to empty-list if null or not specified
if (asset.getSemantics() != null) {
if (asset.getSemantics().getOde().getObservables() == null) {
asset.getSemantics().getOde().setObservables(new ArrayList());
}
}

if (asset.getHeader() != null && asset.getHeader().getName() != null) {
asset.setName(asset.getHeader().getName());
}
Expand Down Expand Up @@ -197,6 +205,14 @@ public Optional<Model> updateAsset(
if (asset.getHeader() != null && asset.getHeader().getName() != null) {
asset.setName(asset.getHeader().getName());
}

// Force observable to empty-list if null or not specified
if (asset.getSemantics() != null) {
if (asset.getSemantics().getOde().getObservables() == null) {
asset.getSemantics().getOde().setObservables(new ArrayList());
}
}

final Optional<Model> updatedOptional = super.updateAsset(asset, projectId, hasWritePermission);
if (updatedOptional.isEmpty()) {
return Optional.empty();
Expand Down

0 comments on commit ee859da

Please sign in to comment.