Skip to content

Commit

Permalink
Split okapi.schema in db.schema.nodeProperties & relationshipProperties
Browse files Browse the repository at this point in the history
Also changed the result structure of the procedures.
Most importantly `nullable` is now `mandatory` (which is basically the inverse) and labels are now output as a string with ":" between them
  • Loading branch information
SaschaPeukert committed Oct 15, 2018
1 parent d579162 commit 8f49bd9
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 207 deletions.

Large diffs are not rendered by default.

Expand Up @@ -149,10 +149,14 @@ public void listProcedures() throws Throwable
"Show the schema of the data.", "READ" ),
proc( "db.schema.visualization","() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)",
"Visualize the schema of the data. Replaces db.schema.", "READ" ),
proc( "okapi.schema", "() :: (type :: STRING?, nodeLabelsOrRelType :: LIST? OF STRING?, property :: STRING?, " +
"cypherTypes :: LIST? OF STRING?, nullable :: BOOLEAN?)", "Show the derived property schema of the data in tabular form.",
proc( "db.schema.nodeProperties", "() :: (nodeType :: STRING?, propertyName :: STRING?, " +
"propertyTypes :: LIST? OF STRING?, mandatory :: BOOLEAN?)", "Show the derived property schema of the nodes in tabular form.",
"READ" ),
proc( "db.relationshipTypes", "() :: (relationshipType :: " + "STRING?)", "List all relationship types in the database.", "READ" ),
proc( "db.schema.edgeProperties", "() :: (relationshipType :: STRING?, propertyName :: STRING?, " +
"propertyTypes :: LIST? OF STRING?, mandatory :: BOOLEAN?)",
"Show the derived property schema of the relationships in tabular form.", "READ" ),
proc( "db.relationshipTypes", "() :: (relationshipType :: " + "STRING?)",
"List all relationship types in the database.", "READ" ),
proc( "dbms.procedures", "() :: (name :: STRING?, signature :: " + "STRING?, description :: STRING?, mode :: STRING?)",
"List all procedures in the DBMS.", "DBMS" ),
proc( "dbms.functions", "() :: (name :: STRING?, signature :: " + "STRING?, description :: STRING?)",
Expand Down
Expand Up @@ -215,11 +215,18 @@ public void resampleOutdatedIndexes()
}
}

@Procedure( name = "okapi.schema", mode = Mode.READ )
@Description( "Show the derived property schema of the data in tabular form." )
public Stream<SchemaInfoResult> propertySchema()
@Procedure( name = "db.schema.nodeProperties", mode = Mode.READ )
@Description( "Show the derived property schema of the nodes in tabular form." )
public Stream<NodePropertySchemaInfoResult> nodePropertySchema()
{
return new SchemaCalculator( tx ).calculateTabularResultStream();
return new SchemaCalculator( tx ).calculateTabularResultStreamForNodes();
}

@Procedure( name = "db.schema.edgeProperties", mode = Mode.READ )
@Description( "Show the derived property schema of the relationships in tabular form." )
public Stream<RelationshipPropertySchemaInfoResult> relationshipPropertySchema()
{
return new SchemaCalculator( tx ).calculateTabularResultStreamForRels();
}

@Deprecated
Expand Down
Expand Up @@ -21,39 +21,33 @@

import java.util.List;

public class SchemaInfoResult
public class NodePropertySchemaInfoResult
{
/**
* Indicates whether the entry is a node or a relationship
* A combination of labels interleaved by ":"
*/
public final String type;
public final String nodeType;

/**
* A combination of labels or a relationship
* A property name that occurs on the given label combination or null
*/
public final List<String> nodeLabelsOrRelType;
public final String propertyName;

/**
* A property that occurs on the given label combination / relationship type or null
* A List containing all types of the given property on the given label combination or null
*/
public final String property;
public final List<String> propertyTypes;

/**
* A List containing all CypherTypes of the given property on the given label combination / relationship type or null
* Indicates whether the property is present on all similar nodes (= true) or not (= false)
*/
public final List<String> cypherTypes;
public final boolean mandatory;

/**
* Indicates whether the property is present on all similar nodes / relationships (= false) or not (= true)
*/
public final boolean nullable;

public SchemaInfoResult( String type, List<String> nodeLabelsOrRelType, String property, List<String> cypherTypes, boolean nullable )
public NodePropertySchemaInfoResult( String nodeLabels, String propertyName, List<String> cypherTypes, boolean mandatory )
{
this.type = type;
this.nodeLabelsOrRelType = nodeLabelsOrRelType;
this.property = property;
this.cypherTypes = cypherTypes;
this.nullable = nullable;
this.nodeType = nodeLabels;
this.propertyName = propertyName;
this.propertyTypes = cypherTypes;
this.mandatory = mandatory;
}
}
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.kernel.builtinprocs;

import java.util.List;

public class RelationshipPropertySchemaInfoResult
{
/**
* A relationship type
*/
public final String relationshipType;

/**
* A property name that occurs on the given relationship type or null
*/
public final String propertyName;

/**
* A List containing all types of the given property on the given relationship type or null
*/
public final List<String> propertyTypes;

/**
* Indicates whether the property is present on all similar relationships (= true) or not (= false)
*/
public final boolean mandatory;

public RelationshipPropertySchemaInfoResult( String relType, String propertyName, List<String> cypherTypes, boolean mandatory )
{
this.relationshipType = relType;
this.propertyName = propertyName;
this.propertyTypes = cypherTypes;
this.mandatory = mandatory;
}
}

0 comments on commit 8f49bd9

Please sign in to comment.