From 3afbeb2c743af5e8a92c3fb9b7a058e0a7628616 Mon Sep 17 00:00:00 2001 From: datomo Date: Sat, 18 Mar 2023 18:54:14 +0100 Subject: [PATCH 1/5] fixed graph naming error --- .../main/java/org/polypheny/db/adapter/neo4j/Neo4jPlugin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/Neo4jPlugin.java b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/Neo4jPlugin.java index df95fd314d..3c055a6120 100644 --- a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/Neo4jPlugin.java +++ b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/Neo4jPlugin.java @@ -468,8 +468,10 @@ public void createNewSchema( SchemaPlus rootSchema, String name ) { final Expression expression = Schemas.subSchemaExpression( rootSchema, name, NeoNamespace.class ); String namespaceName; String[] splits = name.split( "_" ); - if ( splits.length >= 3 ) { + if ( splits.length == 3 ) { namespaceName = splits[1]; + } else if ( splits.length > 3 ) { + namespaceName = String.join( "_", Arrays.asList( splits ).subList( 1, splits.length - 1 ) ); } else { throw new RuntimeException( "Error while generating new namespace" ); } From 36954cc7aa01923d9c2f9fa1972f6f540d2c5f3b Mon Sep 17 00:00:00 2001 From: datomo Date: Sun, 19 Mar 2023 11:30:59 +0100 Subject: [PATCH 2/5] moved commit for implicit creation of collections, fixes #437 --- .../java/org/polypheny/db/transaction/TransactionImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dbms/src/main/java/org/polypheny/db/transaction/TransactionImpl.java b/dbms/src/main/java/org/polypheny/db/transaction/TransactionImpl.java index 720526cb1e..45fad3c000 100644 --- a/dbms/src/main/java/org/polypheny/db/transaction/TransactionImpl.java +++ b/dbms/src/main/java/org/polypheny/db/transaction/TransactionImpl.java @@ -44,6 +44,7 @@ import org.polypheny.db.catalog.entity.CatalogSchema; import org.polypheny.db.catalog.entity.CatalogTable; import org.polypheny.db.catalog.entity.CatalogUser; +import org.polypheny.db.catalog.exceptions.NoTablePrimaryKeyException; import org.polypheny.db.config.RuntimeConfig; import org.polypheny.db.information.InformationManager; import org.polypheny.db.languages.QueryLanguage; @@ -216,6 +217,11 @@ public void commit() throws TransactionException { // Handover information about commit to Materialized Manager MaterializedViewManager.getInstance().updateCommittedXid( xid ); + try { + Catalog.getInstance().commit(); + } catch ( NoTablePrimaryKeyException e ) { + throw new RuntimeException( e ); + } } From 0cb5537db068c3e441538ba97ef2d8a8837e21e5 Mon Sep 17 00:00:00 2001 From: datomo Date: Fri, 31 Mar 2023 00:04:45 +0200 Subject: [PATCH 3/5] fixed deploy of adapters via UI, fixed ; in mongoQL --- plugins/mql-language/src/main/codegen/DocumentParser.jj | 2 +- .../polypheny/db/adapter/neo4j/util/NeoStatements.java | 2 +- webui/src/main/java/org/polypheny/db/webui/Crud.java | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/mql-language/src/main/codegen/DocumentParser.jj b/plugins/mql-language/src/main/codegen/DocumentParser.jj index 8e92e5eed8..8c33b52ac7 100644 --- a/plugins/mql-language/src/main/codegen/DocumentParser.jj +++ b/plugins/mql-language/src/main/codegen/DocumentParser.jj @@ -389,7 +389,7 @@ MqlNode Input() : } { /** only one statement for now **/ - n = Statement() + n = Statement() [";"] {return n;} } diff --git a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/util/NeoStatements.java b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/util/NeoStatements.java index 19e004273d..5198a23148 100644 --- a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/util/NeoStatements.java +++ b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/util/NeoStatements.java @@ -290,7 +290,7 @@ public String build() { if ( direction == EdgeDirection.LEFT_TO_RIGHT ) { statement = statement + ">"; } else if ( direction == EdgeDirection.RIGHT_TO_LEFT ) { - statement = statement + "<"; + statement = "<" + statement; } return statement; } 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 f6f7b5067c..dd43324659 100644 --- a/webui/src/main/java/org/polypheny/db/webui/Crud.java +++ b/webui/src/main/java/org/polypheny/db/webui/Crud.java @@ -17,6 +17,8 @@ package org.polypheny.db.webui; +import static org.polypheny.db.adapter.ConnectionMethod.LINK; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; @@ -83,6 +85,7 @@ import org.polypheny.db.adapter.Adapter.AbstractAdapterSettingDirectory; import org.polypheny.db.adapter.AdapterManager; import org.polypheny.db.adapter.AdapterManager.AdapterInformation; +import org.polypheny.db.adapter.ConnectionMethod; import org.polypheny.db.adapter.DataSource; import org.polypheny.db.adapter.DataSource.ExportedColumn; import org.polypheny.db.adapter.DataStore; @@ -2328,15 +2331,15 @@ void addAdapter( final Context ctx, Gson gson ) throws ServletException, IOExcep AdapterModel a = gson.fromJson( body, AdapterModel.class ); Map settings = new HashMap<>(); - String method = a.settings.get( "method" ).getValue(); + ConnectionMethod method = ConnectionMethod.UPLOAD; if ( a.settings.containsKey( "method" ) ) { - method = a.settings.get( "method" ).getValue(); + method = a.settings.get( "method" ).equals( "link" ) ? LINK : ConnectionMethod.UPLOAD; } for ( Entry entry : a.settings.entrySet() ) { if ( entry.getValue() instanceof AbstractAdapterSettingDirectory ) { AbstractAdapterSettingDirectory setting = ((AbstractAdapterSettingDirectory) entry.getValue()); - if ( method.equals( "link" ) ) { + if ( method == LINK ) { Exception e = handleLinkFiles( ctx, a, setting, a.settings ); if ( e != null ) { ctx.json( new Result( e ) ); From 31abd20b663257036126a5de9450cb53810bfc05 Mon Sep 17 00:00:00 2001 From: datomo Date: Sat, 1 Apr 2023 00:28:22 +0200 Subject: [PATCH 4/5] added gates for where clauses in Cypher --- .../db/cypher/expression/CypherGate.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/expression/CypherGate.java b/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/expression/CypherGate.java index 7c5ba6cc23..23b104ec0a 100644 --- a/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/expression/CypherGate.java +++ b/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/expression/CypherGate.java @@ -18,7 +18,14 @@ import java.util.List; import lombok.Getter; +import org.polypheny.db.algebra.operators.OperatorName; +import org.polypheny.db.cypher.cypher2alg.CypherToAlgConverter.CypherContext; +import org.polypheny.db.cypher.cypher2alg.CypherToAlgConverter.RexType; +import org.polypheny.db.languages.OperatorRegistry; import org.polypheny.db.languages.ParserPos; +import org.polypheny.db.rex.RexCall; +import org.polypheny.db.rex.RexNode; +import org.polypheny.db.util.Pair; @Getter public class CypherGate extends CypherExpression { @@ -44,6 +51,38 @@ public CypherGate( Gate gate, List expressions ) { } + @Override + public Pair getRex( CypherContext context, RexType type ) { + OperatorName operatorName = null; + switch ( gate ) { + case OR: + operatorName = OperatorName.OR; + break; + case AND: + operatorName = OperatorName.AND; + break; + case XOR: + throw new UnsupportedOperationException(); + case NOT: + return handleSingular( context, type, OperatorName.NOT ); + } + + return Pair.of( null, new RexCall( + context.booleanType, + OperatorRegistry.get( operatorName ), + List.of( left.getRex( context, type ).right, right.getRex( context, type ).right ) ) ); + + } + + + private Pair handleSingular( CypherContext context, RexType type, OperatorName operatorName ) { + return Pair.of( null, new RexCall( + context.booleanType, + OperatorRegistry.get( operatorName ), + List.of( left.getRex( context, type ).right ) ) ); + } + + public enum Gate { OR, AND, From 3f50d8e48943bbead342262100785c0058f9ff15 Mon Sep 17 00:00:00 2001 From: svamel00 Date: Fri, 21 Apr 2023 11:28:05 +0200 Subject: [PATCH 5/5] added (hardcoded) namespace structure in sidebar for cross-model querying --- .../java/org/polypheny/db/webui/Crud.java | 38 ++++++++++++++++++- .../models/requests/SchemaTreeRequest.java | 1 + 2 files changed, 37 insertions(+), 2 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 dd43324659..4b3336aa40 100644 --- a/webui/src/main/java/org/polypheny/db/webui/Crud.java +++ b/webui/src/main/java/org/polypheny/db/webui/Crud.java @@ -397,7 +397,21 @@ void getSchemaTree( final Context ctx ) { } SidebarElement tableElement = new SidebarElement( schema.name + "." + table.name, table.name, schema.namespaceType, request.routerLinkRoot, icon ); - if ( request.depth > 2 ) { + // manually adding document-relation + if ( schema.namespaceType == NamespaceType.DOCUMENT ) { + schemaTree.setRouterLink( request.routerLinkRoot + "/" + schema.name ); + if (request.depth == 3 && request.isCrossModel) { + String[] documentRelational = new String[]{"d"}; // should be _id and _data + String[] collectionRelational = new String[]{"shop"}; // should be an array of the collections of a schema + for (String collection : collectionRelational) { + for (String doc : documentRelational) { + tableElement.addChild(new SidebarElement(schema.name + "." + collection + "." + doc, doc, schema.namespaceType, request.routerLinkRoot, "fa fa-table").setCssClass("sidebarColumn")); + } + } + } + } + + if ( request.depth > 2 && schema.namespaceType != NamespaceType.DOCUMENT) { 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" ) ); @@ -423,10 +437,30 @@ void getSchemaTree( final Context ctx ) { schemaTree.addChildren( collectionTree ).setRouterLink( "" ); } } + + // new Code from Melanie - manually adding children for graphs + String[] graphLabels = new String[]{"Movie", "Character", "Person"}; // hardcoded, should be the labels of the graph + ArrayList collectionTree = new ArrayList<>(); if ( schema.namespaceType == NamespaceType.GRAPH ) { schemaTree.setRouterLink( request.routerLinkRoot + "/" + schema.name ); + if (request.depth == 2 && request.isCrossModel) { + for (String label : graphLabels) { + schemaTree.addChild(new SidebarElement(schema.name + "." + label, label, schema.namespaceType, request.routerLinkRoot, "fa fa-table")); + } + } + if (request.depth == 3 && request.isCrossModel) { + String[] graphRelational = new String[]{"id", "properties", "labels"}; // should always be these + for (String label : graphLabels) { + SidebarElement tableElement = new SidebarElement( schema.name + "." + label, label, schema.namespaceType, request.routerLinkRoot, "fa fa-table"); + for (String graphx : graphRelational) { + tableElement.addChild( new SidebarElement( schema.name + "." + label + "." + graphx, graphx, schema.namespaceType, request.routerLinkRoot, "fa fa-table").setCssClass( "sidebarColumn" ) ); + } + tableElement.setTableType( "VIEW" ); // is always views if .isCrossModel is true + collectionTree.add( tableElement ); + } + schemaTree.addChildren( collectionTree ).setRouterLink( "" ); + } } - result.add( schemaTree ); } diff --git a/webui/src/main/java/org/polypheny/db/webui/models/requests/SchemaTreeRequest.java b/webui/src/main/java/org/polypheny/db/webui/models/requests/SchemaTreeRequest.java index acd86320c6..02dae0eeaa 100644 --- a/webui/src/main/java/org/polypheny/db/webui/models/requests/SchemaTreeRequest.java +++ b/webui/src/main/java/org/polypheny/db/webui/models/requests/SchemaTreeRequest.java @@ -26,6 +26,7 @@ public class SchemaTreeRequest extends UIRequest { public boolean views; public int depth; public boolean showTable; + public boolean isCrossModel; public List dataModels;