Skip to content

Commit

Permalink
fix: studio serializer not doesn't break if a record is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed Jun 8, 2024
1 parent 6ff2d86 commit d272bc4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import com.arcadedb.database.Document;
import com.arcadedb.database.Identifiable;
import com.arcadedb.database.RID;
import com.arcadedb.exception.RecordNotFoundException;
import com.arcadedb.graph.Edge;
import com.arcadedb.graph.Vertex;
import com.arcadedb.log.LogManager;
import com.arcadedb.query.sql.executor.Result;
import com.arcadedb.query.sql.executor.ResultSet;
import com.arcadedb.schema.DocumentType;
Expand All @@ -36,6 +38,7 @@
import com.arcadedb.server.http.HttpServer;

import java.util.*;
import java.util.logging.*;
import java.util.stream.*;

public abstract class AbstractQueryHandler extends DatabaseAbstractHandler {
Expand Down Expand Up @@ -116,15 +119,17 @@ protected void serializeResultSet(final Database database, final String serializ
final Edge e = row.getEdge().get();
if (recordIncluded)
edges.put(serializerImpl.serializeGraphElement(e));
if (includedVertices.add(e.getIn())) {
includedRecords.add(e.getIn());

vertices.put(serializerImpl.serializeGraphElement(e.getInVertex()));
}
if (includedVertices.add(e.getOut())) {
includedRecords.add(e.getOut());

vertices.put(serializerImpl.serializeGraphElement(e.getOutVertex()));
try {
if (includedVertices.add(e.getIn())) {
includedRecords.add(e.getIn());
vertices.put(serializerImpl.serializeGraphElement(e.getInVertex()));
}
if (includedVertices.add(e.getOut())) {
includedRecords.add(e.getOut());
vertices.put(serializerImpl.serializeGraphElement(e.getOutVertex()));
}
} catch (RecordNotFoundException ex) {
LogManager.instance().log(this, Level.SEVERE, "Record %s not found during serialization", ex.getRID());
}
} else {
analyzeResultContent(database, serializerImpl, includedVertices, vertices, edges, row);
Expand All @@ -137,18 +142,22 @@ protected void serializeResultSet(final Database database, final String serializ

// FILTER OUT NOT CONNECTED EDGES
for (final Identifiable entry : includedVertices) {
final Vertex vertex = entry.asVertex(true);
try {
final Vertex vertex = entry.asVertex(true);

final Iterable<Edge> vEdgesOut = vertex.getEdges(Vertex.DIRECTION.OUT);
for (final Edge e : vEdgesOut) {
if (includedVertices.contains(e.getIn()) && !includedRecords.contains(e.getIdentity()))
edges.put(serializerImpl.serializeGraphElement(e));
}
final Iterable<Edge> vEdgesOut = vertex.getEdges(Vertex.DIRECTION.OUT);
for (final Edge e : vEdgesOut) {
if (includedVertices.contains(e.getIn()) && !includedRecords.contains(e.getIdentity()))
edges.put(serializerImpl.serializeGraphElement(e));
}

final Iterable<Edge> vEdgesIn = vertex.getEdges(Vertex.DIRECTION.IN);
for (final Edge e : vEdgesIn) {
if (includedVertices.contains(e.getOut()) && !includedRecords.contains(e.getIdentity()))
edges.put(serializerImpl.serializeGraphElement(e));
final Iterable<Edge> vEdgesIn = vertex.getEdges(Vertex.DIRECTION.IN);
for (final Edge e : vEdgesIn) {
if (includedVertices.contains(e.getOut()) && !includedRecords.contains(e.getIdentity()))
edges.put(serializerImpl.serializeGraphElement(e));
}
} catch (RecordNotFoundException e) {
LogManager.instance().log(this, Level.SEVERE, "Vertex %s not found during serialization", e.getRID());
}
}

Expand Down Expand Up @@ -215,10 +224,20 @@ protected void analyzePropertyValue(final Database database, final JsonGraphSeri

edges.put(serializerImpl.serializeGraphElement(edge));

if (includedVertices.add(edge.getIn()))
vertices.put(serializerImpl.serializeGraphElement(edge.getInVertex()));
if (includedVertices.add(edge.getOut()))
vertices.put(serializerImpl.serializeGraphElement(edge.getOutVertex()));
try {
if (includedVertices.add(edge.getIn())) {
final Vertex inV = edge.getInVertex();
vertices.put(serializerImpl.serializeGraphElement(inV));
}
if (includedVertices.add(edge.getOut())) {
final Vertex outV = edge.getOutVertex();
vertices.put(serializerImpl.serializeGraphElement(outV));
}
} catch (RecordNotFoundException e) {
LogManager.instance()
.log(this, Level.SEVERE, "Error on loading connecting vertices for edge %s: vertex %s not found", edge.getIdentity(),
e.getRID());
}
}
} else if (value instanceof Result) {
analyzeResultContent(database, serializerImpl, includedVertices, vertices, edges, (Result) value);
Expand Down
4 changes: 2 additions & 2 deletions studio/src/main/resources/static/js/studio-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ function renderTable() {
" </a>" +
" <ul class='dropdown-menu dropdown-menu-right' aria-labelledby='navbarDropdown' style='width: 300px'>" +
" <li class='dropdown-item'>" +
" <div class='form-check'>" +
" <div class='form-check-input'>" +
" <input id='tableTruncateColumns' class='form-check-input' type='checkbox' " +
tableTruncateColumnsChecked +
' onclick=\'globalCheckboxAndSave("#tableTruncateColumns", "table.truncateColumns");renderTable()\'>' +
" <label for='tableTruncateColumns' class='form-label' onclick='globalToggleCheckboxAndSave(\"#tableTruncateColumns\", \"table.truncateColumns\");renderTable()'>Truncate long values</label>" +
" </div>" +
" </li>" +
" <li class='dropdown-item'>" +
" <div class='form-check'>" +
" <div class='form-check-input'>" +
" <input id='tableFitInPage' class='form-check-input' type='checkbox' " +
tableFitInPageChecked +
' onclick=\'globalCheckboxAndSave("#tableFitInPage", "table.fitInPage");renderTable()\'>' +
Expand Down
4 changes: 2 additions & 2 deletions studio/src/main/resources/static/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
class="dropdown-item"
onclick="globalToggleCheckbox('#cumulativeSelection');globalGraphSettings.cumulativeSelection = $('#cumulativeSelection').prop('checked')"
>
<div class="form-check">
<div class="form-check-input">
<input id="cumulativeSelection" class="form-check-input" type="checkbox" />
<label for="cumulativeSelection" class="form-label">Cumulative Selection</label>
<i
Expand Down Expand Up @@ -308,7 +308,7 @@
<nav class="navbar navbar-expand-lg navbar-light">
<ul class="navbar-nav">
<li class="nav-item">
<div class="form-check">
<div class="form-check-input">
<input id="profileCommand" class="form-check-input" type="checkbox" />
<label for="profileCommand" class="form-label">Profile Execution</label>
<i
Expand Down

0 comments on commit d272bc4

Please sign in to comment.