use of org.neo4j.server.http.cypher.TransactionStateChecker in project neo4j by neo4j.
the class ExecutionResultSerializer method writeRecord.
void writeRecord(RecordEvent recordEvent) {
try {
TransactionStateChecker txStateChecker = TransactionStateChecker.create(transactionHandle.getContext());
jsonGenerator.writeStartObject();
try {
writer.write(jsonGenerator, recordEvent, txStateChecker);
} finally {
jsonGenerator.writeEndObject();
}
flush();
} catch (JsonGenerationException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new ConnectionException("Failed to write to the connection", e);
}
}
use of org.neo4j.server.http.cypher.TransactionStateChecker in project neo4j by neo4j.
the class Neo4jJsonCodec method writeMeta.
public void writeMeta(JsonGenerator out, Object value) throws IOException {
if (value instanceof Node) {
Node node = (Node) value;
TransactionStateChecker stateChecker = TransactionStateChecker.create(transactionHandle.getContext());
writeNodeOrRelationshipMeta(out, node.getId(), Neo4jJsonMetaType.NODE, stateChecker.isNodeDeletedInCurrentTx(node.getId()));
} else if (value instanceof Relationship) {
Relationship relationship = (Relationship) value;
TransactionStateChecker transactionStateChecker = TransactionStateChecker.create(transactionHandle.getContext());
writeNodeOrRelationshipMeta(out, relationship.getId(), Neo4jJsonMetaType.RELATIONSHIP, transactionStateChecker.isRelationshipDeletedInCurrentTx(relationship.getId()));
} else if (value instanceof Path) {
writeMetaPath(out, (Path) value);
} else if (value instanceof Iterable) {
for (Object v : (Iterable) value) {
writeMeta(out, v);
}
} else if (value instanceof Map) {
Map map = (Map) value;
for (var mapValue : map.values()) {
writeMeta(out, mapValue);
}
} else if (value instanceof Geometry) {
writeObjectMeta(out, parseGeometryType((Geometry) value));
} else if (value instanceof Temporal) {
writeObjectMeta(out, parseTemporalType((Temporal) value));
} else if (value instanceof TemporalAmount) {
writeObjectMeta(out, Neo4jJsonMetaType.DURATION);
} else {
out.writeNull();
}
}
use of org.neo4j.server.http.cypher.TransactionStateChecker in project neo4j by neo4j.
the class LineDelimitedEventSourceJoltSerializer method writeRecord.
protected void writeRecord(RecordEvent recordEvent) {
try {
TransactionStateChecker txStateChecker = TransactionStateChecker.create(transactionHandle.getContext());
jsonGenerator.writeStartObject();
jsonGenerator.writeFieldName("data");
try {
writer.write(jsonGenerator, recordEvent, txStateChecker);
} finally {
jsonGenerator.writeEndObject();
flush();
}
} catch (JsonGenerationException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new ConnectionException("Failed to write to the connection", e);
}
}
use of org.neo4j.server.http.cypher.TransactionStateChecker in project neo4j by neo4j.
the class Neo4jJsonCodec method writeValue.
@Override
public void writeValue(JsonGenerator out, Object value) throws IOException {
if (value instanceof Entity) {
var context = transactionHandle.getContext();
TransactionStateChecker txStateChecker = TransactionStateChecker.create(context);
writeEntity(out, (Entity) value, txStateChecker, context);
} else if (value instanceof Path) {
var context = transactionHandle.getContext();
TransactionStateChecker txStateChecker = TransactionStateChecker.create(context);
writePath(out, ((Path) value).iterator(), txStateChecker, context);
} else if (value instanceof Iterable) {
writeIterator(out, ((Iterable) value).iterator());
} else if (value instanceof byte[]) {
writeByteArray(out, (byte[]) value);
} else if (value instanceof Map) {
writeMap(out, (Map) value);
} else if (value instanceof Geometry) {
Geometry geom = (Geometry) value;
Object coordinates = (geom instanceof Point) ? ((Point) geom).getCoordinate() : geom.getCoordinates();
writeMap(out, genericMap(new LinkedHashMap<>(), "type", geom.getGeometryType(), "coordinates", coordinates, "crs", geom.getCRS()));
} else if (value instanceof Coordinate) {
Coordinate coordinate = (Coordinate) value;
writeIterator(out, coordinate.getCoordinate().iterator());
} else if (value instanceof CRS) {
CRS crs = (CRS) value;
writeMap(out, genericMap(new LinkedHashMap<>(), "srid", crs.getCode(), "name", crs.getType(), "type", "link", "properties", genericMap(new LinkedHashMap<>(), "href", crs.getHref() + "ogcwkt/", "type", "ogcwkt")));
} else if (value instanceof Temporal || value instanceof TemporalAmount) {
super.writeValue(out, value.toString());
} else if (value != null && value.getClass().isArray() && supportedArrayType(value.getClass().getComponentType())) {
writeReflectiveArray(out, value);
} else {
super.writeValue(out, value);
}
}
Aggregations