From d97fa0be043857a575c32e397b74ee5ddf095d0b Mon Sep 17 00:00:00 2001 From: alyaa999 Date: Sat, 9 Mar 2024 05:30:56 +0200 Subject: [PATCH 1/2] Enhanced the auto-Completion modified the response of the getSchemaTree endpoint to include constraints and indexes for improved the auto-completion provided in the sql query console of the Polypheny-UI --- .../src/main/java/org/polypheny/db/webui/Crud.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/webui/src/main/java/org/polypheny/db/webui/Crud.java b/webui/src/main/java/org/polypheny/db/webui/Crud.java index 67546f3189..26bada2ea3 100644 --- a/webui/src/main/java/org/polypheny/db/webui/Crud.java +++ b/webui/src/main/java/org/polypheny/db/webui/Crud.java @@ -409,7 +409,19 @@ void getSchemaTree( final Context ctx ) { if ( request.depth > 2 ) { List columns = catalog.getColumns( table.id ); for ( CatalogColumn column : columns ) { - tableElement.addChild( new SidebarElement( schema.name + "." + table.name + "." + column.name, column.name, schema.namespaceType, request.routerLinkRoot, icon ).setCssClass( "sidebarColumn" ) ); + tableElement.addChild(new SidebarElement(schema.name + "." + table.name + "." + column.name, column.name, schema.namespaceType, request.routerLinkRoot, icon).setCssClass("sidebarColumn")); + List constraints = catalog.getConstraints(table.id); + List Indexes = catalog.getIndexes(table.id,false); + + for (CatalogConstraint constraint : constraints) + { + tableElement.addChild(new SidebarElement(schema.name + "." + table.name +"." +constraint.name , constraint.name , schema.namespaceType , request.routerLinkRoot , icon)).setCssClass("sidebarConstrain"); + } + for(CatalogIndex index : Indexes) + { + tableElement.addChild(new SidebarElement(schema.name + "." + table.name +"." +index.name , index.name , schema.namespaceType , request.routerLinkRoot , icon)).setCssClass("sidebarIndexes"); + } + } } From cee2b888fcba2f0288e7673da1a7b3894f974497 Mon Sep 17 00:00:00 2001 From: alyaa999 Date: Sun, 10 Mar 2024 22:31:31 +0200 Subject: [PATCH 2/2] add method to get all adapter names add methid to gell all query interface names --- .../java/org/polypheny/db/webui/Crud.java | 39 ++++++++++++------- .../org/polypheny/db/webui/HttpServer.java | 4 ++ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/webui/src/main/java/org/polypheny/db/webui/Crud.java b/webui/src/main/java/org/polypheny/db/webui/Crud.java index 26bada2ea3..227d6e1ae1 100644 --- a/webui/src/main/java/org/polypheny/db/webui/Crud.java +++ b/webui/src/main/java/org/polypheny/db/webui/Crud.java @@ -50,9 +50,7 @@ import java.sql.SQLException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; +import java.util.*; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -80,6 +78,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.ArrayUtils; import org.eclipse.jetty.websocket.api.Session; +import org.jetbrains.annotations.NotNull; import org.polypheny.db.PolyImplementation; import org.polypheny.db.adapter.Adapter; import org.polypheny.db.adapter.Adapter.AbstractAdapterSetting; @@ -108,18 +107,8 @@ import org.polypheny.db.catalog.Catalog.PartitionType; import org.polypheny.db.catalog.Catalog.PlacementType; import org.polypheny.db.catalog.NameGenerator; +import org.polypheny.db.catalog.entity.*; import org.polypheny.db.catalog.entity.CatalogAdapter.AdapterType; -import org.polypheny.db.catalog.entity.CatalogColumn; -import org.polypheny.db.catalog.entity.CatalogColumnPlacement; -import org.polypheny.db.catalog.entity.CatalogConstraint; -import org.polypheny.db.catalog.entity.CatalogForeignKey; -import org.polypheny.db.catalog.entity.CatalogIndex; -import org.polypheny.db.catalog.entity.CatalogMaterializedView; -import org.polypheny.db.catalog.entity.CatalogPrimaryKey; -import org.polypheny.db.catalog.entity.CatalogSchema; -import org.polypheny.db.catalog.entity.CatalogTable; -import org.polypheny.db.catalog.entity.CatalogView; -import org.polypheny.db.catalog.entity.MaterializedCriteria; import org.polypheny.db.catalog.entity.MaterializedCriteria.CriteriaType; import org.polypheny.db.catalog.exceptions.ColumnAlreadyExistsException; import org.polypheny.db.catalog.exceptions.EntityAlreadyExistsException; @@ -373,6 +362,28 @@ Result getTable( final UIRequest request ) { return result; } + void getAdapterNames(final Context ctx) + { + List adapters = catalog.getAdapters(); + ArrayList result = new ArrayList<>(); + for(CatalogAdapter adapter : adapters) + { + result.add(adapter.adapterName); + + } + ctx.json(result); + } + void getQueryInterfaceNames(final Context ctx) + { + List queryInterfaces = catalog.getQueryInterfaces(); + ArrayList result = new ArrayList<>(); + for(CatalogQueryInterface queryInterface : queryInterfaces) + { + result.add(queryInterface.name); + + } + ctx.json(result); + } void getSchemaTree( final Context ctx ) { SchemaTreeRequest request = ctx.bodyAsClass( SchemaTreeRequest.class ); diff --git a/webui/src/main/java/org/polypheny/db/webui/HttpServer.java b/webui/src/main/java/org/polypheny/db/webui/HttpServer.java index 24216d806f..358ff687b8 100644 --- a/webui/src/main/java/org/polypheny/db/webui/HttpServer.java +++ b/webui/src/main/java/org/polypheny/db/webui/HttpServer.java @@ -225,6 +225,10 @@ private void defaultException( Class exceptionClass, Javali private void crudRoutes( Javalin webuiServer, Crud crud ) { webuiServer.post( "/getSchemaTree", crud::getSchemaTree ); + webuiServer.get("/getAdpaterNames", crud ::getAdapterNames); + + webuiServer.get("/getQueryInterfaceNames", crud :: getQueryInterfaceNames); + webuiServer.get( "/getTypeSchemas", crud::getTypeSchemas ); webuiServer.post( "/insertRow", crud::insertRow );