From cb3d746f4bc7fc1d26cee635737136187a9eaafa Mon Sep 17 00:00:00 2001 From: datomo Date: Mon, 11 Sep 2023 16:49:37 +0200 Subject: [PATCH] let there be documents --- .../org/polypheny/db/webui/crud/LanguageCrud.java | 12 ++++++++---- .../db/webui/models/results/RelationalResult.java | 5 +++-- .../polypheny/db/webui/models/results/Result.java | 7 ++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/webui/src/main/java/org/polypheny/db/webui/crud/LanguageCrud.java b/webui/src/main/java/org/polypheny/db/webui/crud/LanguageCrud.java index e296e79c10..920f71cdaf 100644 --- a/webui/src/main/java/org/polypheny/db/webui/crud/LanguageCrud.java +++ b/webui/src/main/java/org/polypheny/db/webui/crud/LanguageCrud.java @@ -194,9 +194,9 @@ public static void attachError( Transaction transaction, List> resu Catalog catalog = Catalog.getInstance(); if ( language == QueryLanguage.from( "mongo" ) ) { - return getDocResult( statement, request, query, implementation, transaction, noLimit ); + return getDocResult( statement, language, request, query, implementation, transaction, noLimit ); } else if ( language == QueryLanguage.from( "cypher" ) ) { - return getGraphResult( statement, request, query, implementation, transaction, noLimit ); + return getGraphResult( statement, language, request, query, implementation, transaction, noLimit ); } ResultIterator iterator = implementation.execute( statement, noLimit ? -1 : language == QueryLanguage.from( "cypher" ) ? RuntimeConfig.UI_NODE_AMOUNT.getInteger() : RuntimeConfig.UI_PAGE_SIZE.getInteger() ); @@ -259,7 +259,7 @@ public static void attachError( Transaction transaction, List> resu } - private static GraphResult getGraphResult( Statement statement, QueryRequest request, String query, PolyImplementation implementation, Transaction transaction, boolean noLimit ) { + private static GraphResult getGraphResult( Statement statement, QueryLanguage language, QueryRequest request, String query, PolyImplementation implementation, Transaction transaction, boolean noLimit ) { ResultIterator iterator = implementation.execute( statement, noLimit ? -1 : RuntimeConfig.UI_PAGE_SIZE.getInteger() ); List data = iterator.getArrayRows(); @@ -273,13 +273,15 @@ private static GraphResult getGraphResult( Statement statement, QueryRequest req .data( data.stream().map( r -> Arrays.stream( r ).map( LanguageCrud::toJson ).toArray( String[]::new ) ).toArray( String[][]::new ) ) .header( implementation.rowType.getFieldList().stream().map( FieldDefinition::of ).toArray( FieldDefinition[]::new ) ) .query( query ) + .language( language ) + .namespaceType( implementation.getNamespaceType() ) .xid( transaction.getXid().toString() ) .namespaceName( Catalog.snapshot().getNamespace( request.namespaceId ).orElseThrow().name ) .build(); } - private static DocResult getDocResult( Statement statement, QueryRequest request, String query, PolyImplementation implementation, Transaction transaction, boolean noLimit ) { + private static DocResult getDocResult( Statement statement, QueryLanguage language, QueryRequest request, String query, PolyImplementation implementation, Transaction transaction, boolean noLimit ) { ResultIterator iterator = implementation.execute( statement, noLimit ? -1 : RuntimeConfig.UI_PAGE_SIZE.getInteger() ); List data = iterator.getSingleRows(); @@ -293,7 +295,9 @@ private static DocResult getDocResult( Statement statement, QueryRequest request .header( implementation.rowType.getFieldList().stream().map( FieldDefinition::of ).toArray( FieldDefinition[]::new ) ) .data( data.stream().map( LanguageCrud::toJson ).toArray( String[]::new ) ) .query( query ) + .language( language ) .xid( transaction.getXid().toString() ) + .namespaceType( implementation.getNamespaceType() ) .namespaceName( Catalog.snapshot().getNamespace( request.namespaceId ).orElseThrow().name ) .build(); } diff --git a/webui/src/main/java/org/polypheny/db/webui/models/results/RelationalResult.java b/webui/src/main/java/org/polypheny/db/webui/models/results/RelationalResult.java index ee1ea34379..841c0a645c 100644 --- a/webui/src/main/java/org/polypheny/db/webui/models/results/RelationalResult.java +++ b/webui/src/main/java/org/polypheny/db/webui/models/results/RelationalResult.java @@ -79,8 +79,9 @@ public RelationalResult( @JsonProperty("UIRequest") UIRequest request, @JsonProperty("int") int affectedRows, @JsonProperty("ResultType") ResultType type, - @JsonProperty("hasMoreRows") boolean hasMore ) { - super( namespaceType, namespaceName, data, header, exception, query, xid, error, currentPage, highestPage, hasMore ); + @JsonProperty("hasMoreRows") boolean hasMore, + @JsonProperty("language") QueryLanguage language ) { + super( namespaceType, namespaceName, data, header, exception, query, xid, error, currentPage, highestPage, hasMore, language ); this.table = table; this.tables = tables; this.request = request; diff --git a/webui/src/main/java/org/polypheny/db/webui/models/results/Result.java b/webui/src/main/java/org/polypheny/db/webui/models/results/Result.java index 8f7df79337..2e50c761fb 100644 --- a/webui/src/main/java/org/polypheny/db/webui/models/results/Result.java +++ b/webui/src/main/java/org/polypheny/db/webui/models/results/Result.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Value; import lombok.experimental.NonFinal; import lombok.experimental.SuperBuilder; @@ -53,7 +54,6 @@ public abstract class Result { public String query; - /** * Transaction id, for the websocket. It will not be serialized to gson. */ @@ -79,6 +79,7 @@ public abstract class Result { * language type of result MQL/SQL/CQL */ @JsonSerialize(using = LanguageSerializer.class) + @Builder.Default public QueryLanguage language = QueryLanguage.from( "sql" ); @@ -87,6 +88,9 @@ public abstract class Result { */ public static abstract class ResultBuilder, B extends ResultBuilder> { + /** + * Only necessary due to lombok builder downside + */ protected B $fillValuesFrom( C instance ) { this.data = instance.data; this.namespaceType = instance.namespaceType; @@ -95,6 +99,7 @@ public static abstract class ResultBuilder, B exten this.namespaceName = instance.namespaceName; this.query = instance.query; this.exception = instance.exception; + this.language$value = instance.language; return self(); }