Skip to content

Commit

Permalink
FAIRSPC-102: fixed view update on triple deletion (property deletion)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreenwood committed Jun 19, 2024
1 parent 6130b32 commit fd1c61f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,13 @@ public void addLabel(String id, String type, String label) throws SQLException {
public int updateRows(String view, List<Map<String, Object>> rows, boolean bulkInsert) throws SQLException {
var viewTable = configuration.viewTables.get(view);
var config = configuration.viewConfig.get(view);
// Find the columns for which there are values in the rows
// Find the columns in the rows of type different from Set
var columnNames = rows.stream()
.flatMap(row -> row.entrySet().stream()
.filter(entry -> entry.getValue() != null)
.map(Map.Entry::getKey))
.flatMap(row -> row.keySet().stream())
.distinct()
.filter(columnName -> config.columns.stream()
.noneMatch(column ->
// Skip value set columns
column.name.equalsIgnoreCase(columnName) && column.type.isSet()))
.collect(Collectors.toList());
.noneMatch(column -> column.name.equalsIgnoreCase(columnName) && column.type.isSet()))
.toList();
if (columnNames.isEmpty()) {
return 0;
}
Expand All @@ -228,7 +224,7 @@ public int updateRows(String view, List<Map<String, Object>> rows, boolean bulkI
for (var row : rows) {
var values = columnNames.stream()
.map(columnName -> row.getOrDefault(columnName, null))
.collect(Collectors.toList());
.toList();
var id = (String) row.get("id");
var exists = (!bulkInsert) && rowExists(viewTable.name, id);
if (exists) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,7 @@ public void updateSubject(Node subject) {
try {
for (var column : view.columns) {
var objects = retrieveValues(graph, subject, column.source);
if (objects.isEmpty()) {
continue;
}
row.put(column.name, getValue(column, objects.get(0)));
row.put(column.name, objects.isEmpty() ? null : getValue(column, objects.getFirst()));
}
viewStoreClient.updateRows(view.name, List.of(row), false);
} catch (SQLException e) {
Expand Down

0 comments on commit fd1c61f

Please sign in to comment.