├── .gitignore ├── .mvn └── extensions.xml ├── CONTRIBUTING.md ├── FETCH_HEAD ├── README.asciidoc ├── build ├── AGPL-3-header.txt ├── ApacheLicense-2.0-header.txt ├── GPL-3-header.txt └── checkstyle.xml ├── config-docs ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── neo4j │ └── doc │ ├── ConfigDocsGenerator.java │ ├── ConfigDocsTool.java │ └── DocsConfigValue.java ├── cypher ├── cypher-docs │ ├── pom.xml │ └── src │ │ ├── docs │ │ ├── dev │ │ │ ├── advanced-query-tuning-example.asciidoc │ │ │ ├── basic-query-tuning-example.asciidoc │ │ │ ├── clause.asciidoc │ │ │ ├── deprecations-additions-and-compatibility.asciidoc │ │ │ ├── execution-plan-groups │ │ │ │ └── operators.asciidoc │ │ │ ├── execution-plans-db-hits.asciidoc │ │ │ ├── execution-plans-operator-summary.asciidoc │ │ │ ├── execution-plans.asciidoc │ │ │ ├── general │ │ │ │ ├── cypher-introduction.asciidoc │ │ │ │ ├── cypher-path-matching.asciidoc │ │ │ │ ├── databases-and-graphs.asciidoc │ │ │ │ ├── index.asciidoc │ │ │ │ ├── query-transactions.asciidoc │ │ │ │ └── querying-updating-administering.asciidoc │ │ │ ├── glossary.asciidoc │ │ │ ├── images │ │ │ │ ├── basic-filtering.png │ │ │ │ ├── friends-of-friends.png │ │ │ │ └── friends-of-friends2.psd │ │ │ ├── ql │ │ │ │ ├── administration │ │ │ │ │ ├── alias │ │ │ │ │ │ ├── alias-command-syntax.asciidoc │ │ │ │ │ │ ├── alias-driver-settings-table.asciidoc │ │ │ │ │ │ ├── alias-management-syntax-alter-alias.asciidoc │ │ │ │ │ │ ├── alias-management-syntax-create-alias.asciidoc │ │ │ │ │ │ └── show-database-alias-columns.asciidoc │ │ │ │ │ ├── databases-command-syntax.asciidoc │ │ │ │ │ ├── indexes-for-full-text-search │ │ │ │ │ │ ├── create-fulltext-syntax.asciidoc │ │ │ │ │ │ └── index.asciidoc │ │ │ │ │ ├── indexes-for-search-performance │ │ │ │ │ │ └── index.asciidoc │ │ │ │ │ └── show-databases-columns.asciidoc │ │ │ │ ├── constraints │ │ │ │ │ ├── examples.adoc │ │ │ │ │ ├── index.adoc │ │ │ │ │ └── syntax.adoc │ │ │ │ ├── functions │ │ │ │ │ ├── index.asciidoc │ │ │ │ │ ├── query-functions-graph.adoc │ │ │ │ │ └── user-defined-functions.adoc │ │ │ │ └── load-csv │ │ │ │ │ └── index.asciidoc │ │ │ ├── query-tuning-indexes.adoc │ │ │ ├── query-tuning.asciidoc │ │ │ ├── query-use.adoc │ │ │ └── syntax │ │ │ │ ├── boolean-operator-table.asciidoc │ │ │ │ ├── comments.asciidoc │ │ │ │ ├── comparison.asciidoc │ │ │ │ ├── expressions.asciidoc │ │ │ │ ├── index.asciidoc │ │ │ │ ├── naming.asciidoc │ │ │ │ ├── parameters.asciidoc │ │ │ │ ├── reserved.asciidoc │ │ │ │ ├── values.asciidoc │ │ │ │ ├── variables.asciidoc │ │ │ │ └── working-with-null.asciidoc │ │ └── graphgists │ │ │ ├── import │ │ │ ├── import-csv-with-cypher.asciidoc │ │ │ ├── movies.csv │ │ │ ├── persons.csv │ │ │ └── roles.csv │ │ │ ├── intro │ │ │ ├── compose-statements.adoc │ │ │ ├── data-structures.adoc │ │ │ ├── getting-the-results-you-want.adoc │ │ │ ├── labels.adoc │ │ │ ├── loading-data.adoc │ │ │ ├── movie_actor_roles.csv │ │ │ ├── movies.csv │ │ │ ├── patterns-in-practice.adoc │ │ │ ├── persons.csv │ │ │ └── roles.csv │ │ │ └── sql │ │ │ └── cypher-vs-sql.asciidoc │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── neo4j │ │ │ ├── cypher │ │ │ └── example │ │ │ │ └── JavaQuery.java │ │ │ └── function │ │ │ └── example │ │ │ ├── JoinFunction.java │ │ │ └── LongestString.java │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── cypher │ │ │ ├── TestEnterpriseDatabaseManagementServiceBuilder.java │ │ │ ├── example │ │ │ ├── IntroDocTest.java │ │ │ ├── JavaExecutionEngineDocTest.java │ │ │ └── JavaQueryDocTest.java │ │ │ ├── export │ │ │ ├── DatabaseSubGraph.java │ │ │ ├── SubGraph.java │ │ │ └── SubGraphExporter.java │ │ │ └── internal │ │ │ └── javacompat │ │ │ └── GraphImpl.java │ │ ├── resources │ │ └── keystore_11_0_5.pkcs12 │ │ └── scala │ │ └── org │ │ └── neo4j │ │ └── cypher │ │ ├── docgen │ │ ├── AggregatingFunctionsTest.scala │ │ ├── AliasesTest.scala │ │ ├── CallSubqueryTest.scala │ │ ├── CallTest.scala │ │ ├── CaseExpressionsTest.scala │ │ ├── ConstraintsTest.scala │ │ ├── CreateTest.scala │ │ ├── CsvFile.scala │ │ ├── DatabasesTest.scala │ │ ├── DeleteTest.scala │ │ ├── DocumentationTestBaseTest.scala │ │ ├── DocumentingTestBase.scala │ │ ├── ExecutionEngineFactory.scala │ │ ├── ForeachTest.scala │ │ ├── FulltextIndexTest.scala │ │ ├── LabelExpressionsTest.scala │ │ ├── LimitTest.scala │ │ ├── ListFunctionsTest.scala │ │ ├── ListsTest.scala │ │ ├── LoadCSVFunctionsTest.scala │ │ ├── LoadCSVTest.scala │ │ ├── MapsTest.scala │ │ ├── MatchTest.scala │ │ ├── MathematicalLogarithmicFunctionsTest.scala │ │ ├── MathematicalNumericFunctionsTest.scala │ │ ├── MathematicalTrigonometricFunctionsTest.scala │ │ ├── MergeTest.scala │ │ ├── OperatorsTest.scala │ │ ├── OptionalMatchTest.scala │ │ ├── OrderByTest.scala │ │ ├── PatternTest.scala │ │ ├── PredicateFunctionsTest.scala │ │ ├── PrivilegesTestBase.scala │ │ ├── QueryPlanTest.scala │ │ ├── RemoveTest.scala │ │ ├── ReturnTest.scala │ │ ├── ScalarFunctionsTest.scala │ │ ├── SchemaIndexTest.scala │ │ ├── SetTest.scala │ │ ├── ShortestPathPlanningTest.scala │ │ ├── ShowFunctionsTest.scala │ │ ├── ShowProceduresTest.scala │ │ ├── SkipTest.scala │ │ ├── SpatialFunctionsTest.scala │ │ ├── SpatialTest.scala │ │ ├── StringFunctionsTest.scala │ │ ├── SubqueryExpressionsTest.scala │ │ ├── TemporalDurationFunctionsTest.scala │ │ ├── TemporalFunctionsTest.scala │ │ ├── TemporalTest.scala │ │ ├── TransactionsCommandTest.scala │ │ ├── UnionTest.scala │ │ ├── UnwindTest.scala │ │ ├── UserDefinedAggregationFunctionTest.scala │ │ ├── UserDefinedFunctionTest.scala │ │ ├── UsingTest.scala │ │ ├── WhereTest.scala │ │ ├── WithTest.scala │ │ ├── relationshipTypeExpressionsTest.scala │ │ └── tooling │ │ │ ├── DocBuilder.scala │ │ │ ├── DocsExecutionResult.scala │ │ │ ├── Document.scala │ │ │ ├── DocumentingTest.scala │ │ │ ├── QueryResultContentBuilder.scala │ │ │ ├── QueryRunner.scala │ │ │ ├── QueryStatisticsTestSupport.scala │ │ │ ├── RestartableDatabase.scala │ │ │ ├── captureStateAsGraphViz.scala │ │ │ ├── contentAndResultMerger.scala │ │ │ └── tests │ │ │ ├── ContentAndResultMergerTest.scala │ │ │ ├── DocumentTest.scala │ │ │ ├── QueryResultContentBuilderTest.scala │ │ │ ├── QueryRunnerTest.scala │ │ │ └── RunnableContentTest.scala │ │ └── internal │ │ ├── CypherSerializer.scala │ │ └── javacompat │ │ └── ExecutionEngineGetter.scala ├── cypher-prettifier │ ├── pom.xml │ └── src │ │ └── main │ │ └── scala │ │ └── org │ │ └── neo4j │ │ └── cypher │ │ └── docgen │ │ └── tooling │ │ └── CypherPrettifier.scala ├── pom.xml └── refcard-tests │ ├── .gitignore │ ├── pom.xml │ └── src │ └── test │ ├── resources │ └── keystore_11_0_5.pkcs12 │ └── scala │ └── org │ └── neo4j │ └── cypher │ └── docgen │ ├── RefcardTest.scala │ └── refcard │ ├── AdministrationCommandTestBase.scala │ ├── AggregationTest.scala │ ├── AliasManagementPrivilegeTest.scala │ ├── AliasManagementTest.scala │ ├── CallSubqueryTest.scala │ ├── CallTest.scala │ ├── CaseTest.scala │ ├── ConstraintTest.scala │ ├── CreateTest.scala │ ├── DatabaseManagementPrivilegeTest.scala │ ├── DatabaseManagementTest.scala │ ├── DatabasePrivilegeTest.scala │ ├── DbmsPrivilegeTest.scala │ ├── DeleteTest.scala │ ├── DurationFunctionsTest.scala │ ├── ExampleTest.scala │ ├── ForeachTest.scala │ ├── FunctionsTest.scala │ ├── GraphReadPrivilegeTest.scala │ ├── GraphWritePrivilegeTest.scala │ ├── ImmutablePrivilegeTest.scala │ ├── ImportTest.scala │ ├── IndexTest.scala │ ├── LabelsTest.scala │ ├── ListExpressionsTest.scala │ ├── ListPredicatesTest.scala │ ├── ListPrivilegeTest.scala │ ├── ListsTest.scala │ ├── MapsTest.scala │ ├── MatchTest.scala │ ├── MathematicalFunctionsTest.scala │ ├── MergeTest.scala │ ├── PathFunctionsTest.scala │ ├── PatternsTest.scala │ ├── PredicatesTest.scala │ ├── PrivilegeManagementPrivilegeTest.scala │ ├── RelationshipFunctionsTest.scala │ ├── RemoveTest.scala │ ├── ReturnTest.scala │ ├── RoleManagementPrivilegeTest.scala │ ├── RoleManagementTest.scala │ ├── ServerManagementPrivilegeTest.scala │ ├── ServerManagementTest.scala │ ├── SetTest.scala │ ├── ShowProcFuncTest.scala │ ├── SpatialFunctionsTest.scala │ ├── StringFunctionsTest.scala │ ├── SubqueryExpressionsTest.scala │ ├── TemporalFunctionsTest.scala │ ├── TransactionCommandsTest.scala │ ├── UnionTest.scala │ ├── UseTest.scala │ ├── UserManagementPrivilegeTest.scala │ ├── UserManagementTest.scala │ ├── WhereTest.scala │ └── WithTest.scala ├── doctools ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── neo4j │ │ └── doc │ │ ├── AsciiDocListGenerator.java │ │ ├── GenerateConfigDocumentation.java │ │ ├── SettingDescription.java │ │ ├── SettingDescriptionImpl.java │ │ ├── SettingsDescription.java │ │ ├── SettingsDocumenter.java │ │ ├── jmx │ │ └── JmxBeanDocumenter.java │ │ ├── tools │ │ ├── AsciiDocGenerator.java │ │ ├── JavaDocsGenerator.java │ │ └── JavaTestDocsGenerator.java │ │ └── util │ │ └── FileUtil.java │ └── test │ └── java │ └── org │ └── neo4j │ └── doc │ ├── SettingsDocumenterTest.java │ └── metatest │ └── AsciiDocGeneratorTest.java ├── embedded-examples ├── README.txt ├── pom.xml └── src │ ├── docs │ └── dev │ │ ├── data-modeling-examples.asciidoc │ │ ├── examples │ │ ├── ACL-graph.asciidoc │ │ └── images │ │ │ ├── RDBMSvsGraph.svg │ │ │ └── RDBMSvsGraph.svg.png │ │ └── images │ │ ├── ACL.png │ │ ├── examples-matrix.png │ │ ├── graphalgo-astar.png │ │ ├── hello-world.png │ │ ├── roles.png │ │ ├── social_status.png │ │ ├── socnet-model.png │ │ └── socnet-model.svg │ ├── main │ ├── assembly │ │ └── download-assembly.xml │ └── java │ │ └── org │ │ └── neo4j │ │ └── examples │ │ ├── AnalyzerProviderExample.java │ │ ├── CalculateShortestPath.java │ │ ├── EmbeddedNeo4j.java │ │ ├── EmbeddedNeo4jClusterUsingBuilder.java │ │ ├── EmbeddedNeo4jClusterUsingNeo4jConf.java │ │ ├── EmbeddedNeo4jWithBolt.java │ │ ├── EmbeddedNeo4jWithCustomLogging.java │ │ ├── EmbeddedNeo4jWithIndexing.java │ │ ├── NewMatrix.java │ │ ├── ProcedureExample.java │ │ ├── TerminateTransactions.java │ │ ├── TransactionEventListenerExample.java │ │ ├── TraversalExample.java │ │ ├── orderedpath │ │ └── OrderedPath.java │ │ └── socnet │ │ ├── FriendsStatusUpdateIterator.java │ │ ├── Person.java │ │ ├── PersonRepository.java │ │ ├── PositionedIterator.java │ │ ├── RelTypes.java │ │ └── StatusUpdate.java │ └── test │ ├── java │ └── org │ │ └── neo4j │ │ ├── doc │ │ ├── kernel │ │ │ └── impl │ │ │ │ └── proc │ │ │ │ └── JarBuilder.java │ │ └── metatest │ │ │ └── TestJavaTestDocsGenerator.java │ │ └── examples │ │ ├── AbstractJavaDocTestBase.java │ │ ├── AclExampleDocTest.java │ │ ├── CalculateShortestPathTest.java │ │ ├── CustomAnalyzerProviderTest.java │ │ ├── DocumentationDocTest.java │ │ ├── EmbeddedNeo4JWithIndexingDocTest.java │ │ ├── EmbeddedNeo4jDocTest.java │ │ ├── EmbeddedNeo4jWithBoltIT.java │ │ ├── GetOrCreateDocIT.java │ │ ├── MatrixDocTest.java │ │ ├── Neo4jBasicDocTest.java │ │ ├── PathFindingDocTest.java │ │ ├── ProcedureExampleDocTest.java │ │ ├── ReadOnlyDocTest.java │ │ ├── RolesDocTest.java │ │ ├── StartWithConfigurationDocTest.java │ │ ├── TerminateTransactionsDocTest.java │ │ ├── UniquenessOfPathsDocTest.java │ │ ├── orderedpath │ │ └── OrderedPathDocTest.java │ │ └── socnet │ │ └── SocnetTest.java │ └── resources │ ├── neo4j.conf │ └── stopwords.txt ├── functions ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── neo4j │ └── doc │ ├── FunctionDescriptionsGenerator.java │ ├── GenerateFunctionDescriptions.java │ └── Neo4jInstance.java ├── graphviz ├── .gitignore ├── README.rst ├── graphviz ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── neo4j │ │ ├── visualization │ │ ├── GraphRenderer.java │ │ ├── PropertyRenderer.java │ │ ├── PropertyType.java │ │ ├── SubgraphMapper.java │ │ ├── ValueFormatter.java │ │ ├── Visualizer.java │ │ ├── asciidoc │ │ │ └── AsciidocHelper.java │ │ └── graphviz │ │ │ ├── AsciiDocSimpleStyle.java │ │ │ ├── AsciiDocStyle.java │ │ │ ├── ConfigurationParser.java │ │ │ ├── DefaultNodeStyle.java │ │ │ ├── DefaultRelationshipStyle.java │ │ │ ├── DefaultStyleConfiguration.java │ │ │ ├── GraphStyle.java │ │ │ ├── GraphvizRenderer.java │ │ │ ├── GraphvizWriter.java │ │ │ ├── NodeStyle.java │ │ │ ├── ParameterGetter.java │ │ │ ├── PropertyContainerStyle.java │ │ │ ├── PropertyFilter.java │ │ │ ├── PropertyFormatter.java │ │ │ ├── RelationshipStyle.java │ │ │ ├── Script.java │ │ │ ├── SimpleNodeStyle.java │ │ │ ├── StyleConfiguration.java │ │ │ ├── StyleParameter.java │ │ │ ├── TitleGetter.java │ │ │ └── color │ │ │ ├── AutoNodeColor.java │ │ │ ├── AutoRelationshipTypeColor.java │ │ │ ├── Color.java │ │ │ ├── ColorMapper.java │ │ │ ├── DefaultColorMapping.java │ │ │ ├── SimpleNodeColorMapper.java │ │ │ └── SimpleRelationshipTypeColorMapper.java │ │ └── walk │ │ ├── Visitor.java │ │ └── Walker.java │ └── test │ └── java │ └── org │ └── neo4j │ └── visualization │ └── graphviz │ ├── AsciidocHelperTest.java │ ├── TestGraphvizSubgraphOutput.java │ └── TestNewGraphvizWriter.java ├── jmx ├── pom.xml └── src │ └── docs │ └── jmx.adoc ├── kernel ├── pom.xml └── src │ ├── docs │ └── ops │ │ ├── introduction.asciidoc │ │ ├── io-examples.asciidoc │ │ ├── logical-logs.asciidoc │ │ ├── performance-guide.asciidoc │ │ └── property-compression.asciidoc │ └── test │ └── java │ └── examples │ └── DeadlockDocTest.java ├── metrics-docs ├── pom.xml └── src │ ├── docs │ └── ops │ │ └── metrics.asciidoc │ └── main │ └── java │ └── org │ └── neo4j │ └── metrics │ └── docs │ ├── GenerateMetricsDocumentation.java │ └── MetricsAsciiDocGenerator.java ├── neo4j-harness-enterprise-test ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── neo4j │ │ └── harness │ │ └── enterprise │ │ └── extensionpackage │ │ └── MyUnmanagedExtension.java │ └── test │ └── java │ └── org │ └── neo4j │ └── harness │ └── enterprise │ └── doc │ ├── ExtensionTestingDocIT.java │ └── JUnitDocIT.java ├── neo4j-harness-test ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── neo4j │ │ └── harness │ │ └── extensionpackage │ │ └── MyUnmanagedExtension.java │ └── test │ └── java │ └── org │ └── neo4j │ └── harness │ └── doc │ ├── ExtensionTestingDocIT.java │ └── JUnitDocIT.java ├── pom.xml ├── procedures ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── neo4j │ └── doc │ ├── GenerateProcedureReference.java │ ├── Neo4jInstance.java │ └── ProcedureReferenceGenerator.java ├── server-docs ├── pom.xml └── src │ └── test │ └── java │ └── org │ ├── dummy │ └── doc │ │ └── web │ │ └── service │ │ └── DummyThirdPartyWebService.java │ └── neo4j │ └── doc │ └── server │ ├── ExclusiveWebContainerTestBase.java │ ├── NeoServerJAXRSDocIT.java │ ├── TransactionTimeoutDocIT.java │ ├── rest │ ├── security │ │ ├── AuthenticationDocIT.java │ │ └── CommunityServerTestBase.java │ └── transactional │ │ ├── TransactionDocIT.java │ │ └── error │ │ ├── ErrorDocumentationGenerator.java │ │ └── ErrorDocumentationGeneratorTest.java │ └── web │ └── HelloWorldWebResource.java ├── server-examples ├── .gitignore ├── README.txt ├── pom.xml └── src │ ├── main │ ├── assembly │ │ └── download-assembly.xml │ └── java │ │ └── org │ │ └── neo4j │ │ └── examples │ │ └── server │ │ ├── CreateSimpleGraph.java │ │ ├── Relation.java │ │ ├── TraversalDefinition.java │ │ └── unmanaged │ │ ├── ColleaguesCypherExecutionResource.java │ │ ├── ColleaguesResource.java │ │ └── HelloWorldResource.java │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── server │ └── unmanaged │ └── UnmanagedExtensionsDocIT.java ├── server-test-utils ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── neo4j │ └── doc │ └── server │ ├── HTTP.java │ ├── SharedWebContainerTestBase.java │ ├── WebContainerHolder.java │ ├── WebContainerTestUtils.java │ ├── helpers │ ├── CommunityWebContainerBuilder.java │ ├── FunctionalTestHelper.java │ ├── TestWebContainer.java │ ├── Transactor.java │ ├── UnitOfWork.java │ └── WebContainerHelper.java │ └── rest │ ├── AbstractRestFunctionalTestBase.java │ ├── DocumentationData.java │ ├── JSONPrettifier.java │ ├── JaxRsResponse.java │ ├── RESTDocsGenerator.java │ └── RestRequest.java └── test-framework ├── pom.xml └── src └── main └── java └── org └── neo4j └── doc └── test ├── GraphDatabaseServiceCleaner.java ├── GraphDefinition.java ├── GraphDescription.java ├── GraphHolder.java └── TestData.java /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | \#* 3 | target 4 | out 5 | .project 6 | .classpath 7 | .settings 8 | .externalToolBuilders/ 9 | .scala_dependencies 10 | .factorypath 11 | .cache 12 | .cache-main 13 | .cache-tests 14 | *.iws 15 | *.ipr 16 | *.iml 17 | .idea 18 | .vscode 19 | .DS_Store 20 | .shell_history 21 | .mailmap 22 | .java-version 23 | .cache-main 24 | .cache-tests 25 | Thumbs.db 26 | .cache-main 27 | .cache-tests 28 | /cypher-shell.zip 29 | packaging/standalone/src/main/distribution/cypher-shell 30 | /.profiler/ 31 | -------------------------------------------------------------------------------- /.mvn/extensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | fr.jcgay.maven 5 | maven-profiler 6 | 2.4 7 | 8 | 9 | -------------------------------------------------------------------------------- /FETCH_HEAD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/FETCH_HEAD -------------------------------------------------------------------------------- /README.asciidoc: -------------------------------------------------------------------------------- 1 | = About Neo4j documentation 2 | 3 | This repository contains tools and tests for proving and generating documentation for https://github.com/neo4j/neo4j/[Neo4j]. 4 | 5 | All docs sources are maintained in AsciiDoc format. 6 | The primary output of building the projects kept here are artifacts (JARs) containing docs sources, code examples, and some scripts and images. 7 | These are processed downstream with custom tools, Asciidoctor and XSLT to produce the library of documentation available at https://neo4j.com/docs/. 8 | -------------------------------------------------------------------------------- /build/AGPL-3-header.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) ${project.inceptionYear}-${currentYear} "Neo4j," 2 | Neo4j Sweden AB [http://neo4j.com] 3 | 4 | This file is part of Neo4j Enterprise Edition. The included source 5 | code can be redistributed and/or modified under the terms of the 6 | GNU AFFERO GENERAL PUBLIC LICENSE Version 3 7 | (http://www.fsf.org/licensing/licenses/agpl-3.0.html) with the 8 | Commons Clause, as found in the associated LICENSE.txt file. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Affero General Public License for more details. 14 | 15 | Neo4j object code can be licensed independently from the source 16 | under separate terms from the AGPL. Inquiries can be directed to: 17 | licensing@neo4j.com 18 | 19 | More information is also available at: 20 | https://neo4j.com/licensing/ 21 | 22 | -------------------------------------------------------------------------------- /build/ApacheLicense-2.0-header.txt: -------------------------------------------------------------------------------- 1 | Licensed to Neo4j under one or more contributor 2 | license agreements. See the NOTICE file distributed with 3 | this work for additional information regarding copyright 4 | ownership. Neo4j licenses this file to you under 5 | the Apache License, Version 2.0 (the "License"); you may 6 | not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, 12 | software distributed under the License is distributed on an 13 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | KIND, either express or implied. See the License for the 15 | specific language governing permissions and limitations 16 | under the License. 17 | -------------------------------------------------------------------------------- /build/GPL-3-header.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) ${project.inceptionYear}-${currentYear} "Neo4j," 2 | Neo4j Sweden AB [http://neo4j.com] 3 | 4 | This file is part of Neo4j. 5 | 6 | Neo4j is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | 19 | -------------------------------------------------------------------------------- /config-docs/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | \#* 3 | */target/ 4 | /target/ 5 | *.swp 6 | .project 7 | .classpath 8 | .settings 9 | *.iws 10 | *.ipr 11 | *.iml 12 | .idea/ 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/execution-plans-db-hits.asciidoc: -------------------------------------------------------------------------------- 1 | [[execution-plans-dbhits]] 2 | = Database hits (DbHits) 3 | 4 | [abstract] 5 | -- 6 | This section contains an overview of actions that triggers database hits. 7 | -- 8 | 9 | Each operator will send a request to the storage engine to do work such as retrieving or updating data. 10 | A _database hit_ is an abstract unit of this storage engine work. 11 | 12 | We list below all the actions that trigger one or more database hits: 13 | 14 | * Create actions 15 | ** Create a node 16 | ** Create a relationship 17 | ** Create a new node label 18 | ** Create a new relationship type 19 | ** Create a new ID for property keys with the same name 20 | 21 | * Delete actions 22 | ** Delete a node 23 | ** Delete a relationship 24 | 25 | * Update actions 26 | ** Set one or more labels on a node 27 | ** Remove one or more labels from a node 28 | 29 | * Node-specific actions 30 | ** Get a node by its ID 31 | ** Get the degree of a node 32 | ** Determine whether a node is dense 33 | ** Determine whether a label is set on a node 34 | ** Get the labels of a node 35 | ** Get a property of a node 36 | ** Get an existing node label 37 | ** Get the name of a label by its ID, or its ID by its name 38 | 39 | * Relationship-specific actions 40 | ** Get a relationship by its ID 41 | ** Get a property of a relationship 42 | ** Get an existing relationship type 43 | ** Get a relationship type name by its ID, or its ID by its name 44 | 45 | 46 | * General actions 47 | ** Get the name of a property key by its ID, or its ID by the key name 48 | ** Find a node or relationship through an index seek or index scan 49 | ** Find a path in a variable-length expand 50 | ** Find a shortest path 51 | ** Ask the count store for a value 52 | 53 | 54 | * Schema actions 55 | ** Add an index 56 | ** Drop an index 57 | ** Get the reference of an index 58 | ** Create a constraint 59 | ** Drop a constraint 60 | 61 | * Call a procedure 62 | * Call a user-defined function 63 | 64 | [NOTE] 65 | -- 66 | The presented value can vary slightly depending on the <> that was used to execute the query. 67 | In the pipelined runtime the number of _database hits_ will typically be higher since it uses a more accurate way of measuring. 68 | -- 69 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/general/cypher-introduction.asciidoc: -------------------------------------------------------------------------------- 1 | [[cypher-introduction]] 2 | = What is Cypher? 3 | 4 | Cypher is a declarative graph query language that allows for expressive and efficient <> of the graph. 5 | It is designed to be suitable for both developers and operations professionals. 6 | Cypher is designed to be simple, yet powerful; highly complicated database queries can be easily expressed, enabling you to focus on your domain, instead of getting lost in database access. 7 | 8 | Cypher is inspired by a number of different approaches and builds on established practices for expressive querying. 9 | Many of the keywords, such as `WHERE` and `ORDER BY`, are inspired by http://en.wikipedia.org/wiki/SQL[SQL]. 10 | Pattern matching borrows expression approaches from http://en.wikipedia.org/wiki/SPARQL[SPARQL]. 11 | Some of the list semantics are borrowed from languages such as Haskell and Python. 12 | Cypher's constructs, based on English prose and neat iconography, make queries easy, both to write and to read. 13 | 14 | **Structure** 15 | 16 | Cypher borrows its structure from SQL -- queries are built up using various clauses. 17 | 18 | Clauses are chained together, and they feed intermediate result sets between each other. 19 | For example, the matching variables from one `MATCH` clause will be the context that the next clause exists in. 20 | 21 | The query language is comprised of several distinct clauses. 22 | These are discussed in more detail in the chapter on <>. 23 | 24 | The following are a few examples of clauses used to read from the graph: 25 | 26 | * `MATCH`: The graph pattern to match. 27 | This is the most common way to get data from the graph. 28 | 29 | * `WHERE`: Not a clause in its own right, but rather part of `MATCH`, `OPTIONAL MATCH` and `WITH`. 30 | Adds constraints to a pattern, or filters the intermediate result passing through `WITH`. 31 | 32 | * `RETURN`: What to return. 33 | 34 | Let's see `MATCH` and `RETURN` in action. 35 | 36 | include::intro-examples.asciidoc[] 37 | 38 | And these are examples of clauses that are used to update the graph: 39 | 40 | * `CREATE` (and `DELETE`): Create (and delete) nodes and relationships. 41 | 42 | * `SET` (and `REMOVE`): Set values to properties and add labels on nodes using `SET` and use `REMOVE` to remove them. 43 | 44 | * `MERGE`: Match existing or create new nodes and patterns. This is especially useful together with unique constraints. 45 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/general/index.asciidoc: -------------------------------------------------------------------------------- 1 | [[cypher-intro]] 2 | = Introduction 3 | 4 | [abstract] 5 | -- 6 | This section provides an introduction to the Cypher query language. 7 | -- 8 | 9 | include::cypher-introduction.asciidoc[leveloffset=+1] 10 | 11 | include::databases-and-graphs.asciidoc[leveloffset=+1] 12 | 13 | include::querying-updating-administering.asciidoc[leveloffset=+1] 14 | 15 | include::query-transactions.asciidoc[leveloffset=+1] 16 | 17 | include::cypher-path-matching.asciidoc[leveloffset=+1] 18 | 19 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/images/basic-filtering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/cypher/cypher-docs/src/docs/dev/images/basic-filtering.png -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/images/friends-of-friends.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/cypher/cypher-docs/src/docs/dev/images/friends-of-friends.png -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/images/friends-of-friends2.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/cypher/cypher-docs/src/docs/dev/images/friends-of-friends2.psd -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/ql/administration/alias/alias-command-syntax.asciidoc: -------------------------------------------------------------------------------- 1 | The syntax of the alias management commands is as follows: 2 | 3 | .Alias management command syntax 4 | [options="header", width="100%", cols="1,5a"] 5 | |=== 6 | | Command | Syntax 7 | | Show Database Alias 8 | | 9 | [source] 10 | ----- 11 | SHOW ALIAS[ES] [name] FOR DATABASE[S] 12 | [WHERE expression] 13 | ----- 14 | [source] 15 | ----- 16 | SHOW ALIAS[ES] [name] FOR DATABASE[S] 17 | YIELD { * \| field[, ...] } [ORDER BY field[, ...]] [SKIP n] [LIMIT n] 18 | [WHERE expression] 19 | [RETURN field[, ...] [ORDER BY field[, ...]] [SKIP n] [LIMIT n]] 20 | ----- 21 | Lists both local and remote database aliases, optionally filtered on the alias name. 22 | 23 | | Create Local Alias 24 | | 25 | [source] 26 | ----- 27 | CREATE ALIAS name [IF NOT EXISTS] FOR DATABASE targetName 28 | [PROPERTIES "{" key: value[, ...] "}"] 29 | ----- 30 | [source] 31 | ----- 32 | CREATE OR REPLACE ALIAS name FOR DATABASE targetName 33 | [PROPERTIES "{" key: value[, ...] "}"] 34 | ----- 35 | 36 | | Create Remote Alias 37 | | 38 | [source] 39 | ----- 40 | CREATE ALIAS name [IF NOT EXISTS] FOR DATABASE targetName 41 | AT 'url' USER username PASSSWORD 'password' 42 | [DRIVER "{" setting: value[, ...] "}"] 43 | [PROPERTIES "{" key: value[, ...] "}"] 44 | ----- 45 | [source] 46 | ----- 47 | CREATE OR REPLACE ALIAS name FOR DATABASE targetName 48 | AT 'url' USER username PASSSWORD 'password' 49 | [DRIVER "{" setting: value[, ...] "}"] 50 | [PROPERTIES "{" key: value[, ...] "}"] 51 | ----- 52 | 53 | | Alter Local Alias 54 | | 55 | [source] 56 | ----- 57 | ALTER ALIAS name [IF EXISTS] SET DATABASE 58 | [TARGET targetName] 59 | [PROPERTIES "{" key: value[, ...] "}"] 60 | ----- 61 | 62 | | Alter Remote Alias 63 | | 64 | [source] 65 | ----- 66 | ALTER ALIAS name [IF EXISTS] SET DATABASE 67 | [TARGET targetName AT 'url'] 68 | [USER username] 69 | [PASSWORD 'password'] 70 | [DRIVER "{" setting: value[, ...] "}"] 71 | [PROPERTIES "{" key: value[, ...] "}"] 72 | ----- 73 | 74 | | Drop Alias 75 | | 76 | [source] 77 | ----- 78 | DROP ALIAS name [IF EXISTS] FOR DATABASE 79 | ----- 80 | Drop either a local or remote database alias. 81 | 82 | |=== -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/ql/administration/alias/alias-management-syntax-alter-alias.asciidoc: -------------------------------------------------------------------------------- 1 | .Alter alias command syntax 2 | [options="header", width="100%", cols="5a,2"] 3 | |=== 4 | | Syntax | Comment 5 | | 6 | [source, cypher, role=noplay] 7 | ----- 8 | ALTER ALIAS [compositeDatabaseName.]aliasName [IF EXISTS] SET DATABASE 9 | [TARGET targetName] 10 | [PROPERTIES "{" key: value[, ...] "}"] 11 | ----- 12 | | Modify database target of a local alias. 13 | 14 | The clauses can be applied in any order, while at least one clause needs to be set. 15 | 16 | | 17 | [source, cypher, role=noplay] 18 | ----- 19 | ALTER ALIAS [compositeDatabaseName.]aliasName [IF EXISTS] SET DATABASE 20 | [TARGET targetName AT 'url'] 21 | [USER username] 22 | [PASSSWORD 'password'] 23 | [DRIVER "{" setting: value[, ...] "}"] 24 | [PROPERTIES "{" key: value[, ...] "}"] 25 | ----- 26 | | Modify a remote alias. 27 | 28 | The clauses can be applied in any order, while at least one clause needs to be set. 29 | 30 | |=== -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/ql/administration/alias/alias-management-syntax-create-alias.asciidoc: -------------------------------------------------------------------------------- 1 | .Create alias command syntax 2 | [options="header", width="100%", cols="5a,2"] 3 | |=== 4 | | Syntax | Comment 5 | | 6 | [source, cypher, role=noplay] 7 | ----- 8 | CREATE [OR REPLACE] ALIAS [compositeDatabaseName.]aliasName [IF NOT EXISTS] FOR DATABASE targetName 9 | [PROPERTIES "{" key: value[, ...] "}"] 10 | ----- 11 | | Create a local alias. 12 | 13 | | 14 | [source, cypher, role=noplay] 15 | ----- 16 | CREATE [OR REPLACE] ALIAS [compositeDatabaseName.]aliasName [IF NOT EXISTS] FOR DATABASE targetName 17 | AT 'url' USER username PASSSWORD 'password' 18 | [DRIVER "{" setting: value[, ...] "}"] 19 | [PROPERTIES "{" key: value[, ...] "}"] 20 | ----- 21 | | Create a remote alias. 22 | 23 | |=== -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/ql/administration/alias/show-database-alias-columns.asciidoc: -------------------------------------------------------------------------------- 1 | [options="header" cols="2l,4,1,1,2"] 2 | |=== 3 | |Column |Description|Default Output|Full Output| Notes 4 | |name|The fully qualified name of the database alias.|{check-mark}|{check-mark}| 5 | |database|The name of the target database.|{check-mark}|{check-mark}| 6 | |location| The location of the database, either `local` or `remote`.|{check-mark}|{check-mark}| 7 | |url| Target location or `null` if the target is local.|{check-mark}|{check-mark}| 8 | |user| User connecting to the remote database or `null` if the target database is local.|{check-mark}|{check-mark}| 9 | |driver| The driver options for connection to the remote database or `null` if the target database is local or if no driver settings are added. ||{check-mark} 10 | | List of <> allowed for remote database aliases. 11 | |properties| Any properties set on the alias.||{check-mark}| 12 | |=== 13 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/ql/administration/databases-command-syntax.asciidoc: -------------------------------------------------------------------------------- 1 | The syntax of the database management commands is as follows: 2 | 3 | .Database management command syntax 4 | [options="header", width="100%", cols="1,5a"] 5 | |=== 6 | | Command | Syntax 7 | | Show Database 8 | | [source] 9 | SHOW { DATABASE name \| DATABASES \| DEFAULT DATABASE \| HOME DATABASE } 10 | [WHERE expression] 11 | 12 | [source] 13 | SHOW { DATABASE name \| DATABASES \| DEFAULT DATABASE \| HOME DATABASE } 14 | YIELD { * \| field[, ...] } [ORDER BY field[, ...]] [SKIP n] [LIMIT n] 15 | [WHERE expression] 16 | [RETURN field[, ...] [ORDER BY field[, ...]] [SKIP n] [LIMIT n]] 17 | | Create Database 18 | | [source] 19 | CREATE DATABASE name [IF NOT EXISTS] 20 | [TOPOLOGY n PRIMAR{Y\|IES} [m SECONDAR{Y\|IES}]] 21 | [OPTIONS "{" option: value[, ...] "}"] 22 | [WAIT [n [SEC[OND[S]]]]\|NOWAIT] 23 | 24 | [source] 25 | CREATE OR REPLACE DATABASE name 26 | [TOPOLOGY n PRIMAR{Y\|IES} [m SECONDAR{Y\|IES}]] 27 | [OPTIONS "{" option: value[, ...] "}"] 28 | [WAIT [n [SEC[OND[S]]]]\|NOWAIT] 29 | | Create Composite Database 30 | | [source] 31 | CREATE COMPOSITE DATABASE name [IF NOT EXISTS] 32 | [WAIT [n [SEC[OND[S]]]]\|NOWAIT] 33 | 34 | [source] 35 | CREATE OR REPLACE COMPOSITE DATABASE name 36 | [WAIT [n [SEC[OND[S]]]]\|NOWAIT] 37 | |Alter Database 38 | | [source] 39 | ALTER DATABASE name [IF EXISTS] 40 | { 41 | SET ACCESS {READ ONLY \| READ WRITE} \| 42 | SET TOPOLOGY n PRIMAR{Y\|IES} [m SECONDAR{Y\|IES}] 43 | } 44 | |Stop Database 45 | | [source] 46 | STOP DATABASE name [WAIT [n [SEC[OND[S]]]]\|NOWAIT] 47 | |Start Database 48 | | [source] 49 | START DATABASE name [WAIT [n [SEC[OND[S]]]]\|NOWAIT] 50 | |Drop Database 51 | | [source] 52 | DROP [COMPOSITE] DATABASE name [IF EXISTS] [{DUMP\|DESTROY} [DATA]] [WAIT [n [SEC[OND[S]]]]\|NOWAIT] 53 | |=== 54 | 55 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/ql/administration/indexes-for-full-text-search/create-fulltext-syntax.asciidoc: -------------------------------------------------------------------------------- 1 | .Syntax for creating fulltext indexes 2 | [options="header", width="100%", cols="5a,3, 3a"] 3 | |=== 4 | | Command | Description | Comment 5 | 6 | | [source, cypher, role=noplay] 7 | ---- 8 | CREATE FULLTEXT INDEX [index_name] [IF NOT EXISTS] 9 | FOR (n:LabelName["\|" ...]) 10 | ON EACH "[" n.propertyName[, ...] "]" 11 | [OPTIONS "{" option: value[, ...] "}"] 12 | ---- 13 | | Create a fulltext index on nodes. 14 | .2+.^| Best practice is to give the index a name when it is created. This name is needed for both dropping and querying the index. 15 | If the index is not explicitly named, it will get an auto-generated name. 16 | 17 | The index name must be unique among all indexes and constraints. 18 | 19 | Index provider and configuration can be specified using the `OPTIONS` clause. 20 | 21 | The command is optionally idempotent, with the default behavior to throw an error if you attempt to create the same index twice. 22 | With `IF NOT EXISTS`, no error is thrown and nothing happens should an index with the same name, schema or both already exist. 23 | It may still throw an error should a constraint with the same name exist. 24 | 25 | | [source, cypher, role=noplay] 26 | ---- 27 | CREATE FULLTEXT INDEX [index_name] [IF NOT EXISTS] 28 | FOR ()-"["r:TYPE_NAME["\|" ...]"]"-() 29 | ON EACH "[" r.propertyName[, ...] "]" 30 | [OPTIONS "{" option: value[, ...] "}"] 31 | ---- 32 | | Create a fulltext index on relationships. 33 | |=== -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/ql/administration/indexes-for-full-text-search/index.asciidoc: -------------------------------------------------------------------------------- 1 | include::../indexes/administration-indexes-fulltext-search.adoc[leveloffset=2] 2 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/ql/functions/query-functions-graph.adoc: -------------------------------------------------------------------------------- 1 | [[query-functions-graph]] 2 | = Graph functions 3 | 4 | [abstract] 5 | -- 6 | Graph functions provide information about the constituent graphs in <>. 7 | -- 8 | 9 | .Graph functions 10 | [options="header", width="100%", cols="2,2a,2a,2"] 11 | |=== 12 | | Syntax | Query | Result | Description 13 | 14 | | `graph.names()` 15 | | [source, cypher, role=noplay] 16 | ---- 17 | RETURN graph.names() 18 | ---- 19 | | 20 | [role="queryresult",options="header,footer",cols="1*>. 28 | | `USE graph.byName(graphName)` 29 | | [source, cypher, role=noplay] 30 | ---- 31 | UNWIND graph.names() AS graphName 32 | CALL { 33 | USE graph.byName(graphName) 34 | MATCH (n) 35 | RETURN n 36 | } 37 | RETURN n 38 | ---- 39 | | Returns all nodes from all graphs on the current composite database. 40 | | Resolves a constituent graph by name. 41 | It is only supported in the <>, on <>. 42 | 43 | |=== -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/ql/functions/user-defined-functions.adoc: -------------------------------------------------------------------------------- 1 | [[query-functions-user-defined]] 2 | = User-defined functions 3 | 4 | [abstract] 5 | -- 6 | User-defined functions are written in Java, deployed into the database and are called in the same way as any other Cypher function. 7 | -- 8 | 9 | There are two main types of functions that can be developed and used: 10 | 11 | [options="header"] 12 | |=== 13 | |Type | Description | Usage | Developing 14 | |Scalar | For each row the function takes parameters and returns a result | <> | <> 15 | |Aggregating | Consumes many rows and produces an aggregated result | <> | <> 16 | |=== 17 | 18 | // User-defined functions 19 | 20 | include::query-functions-udf.adoc[leveloffset=+1] 21 | 22 | // User-defined aggregating functions 23 | 24 | include::query-functions-user-defined-aggregation.adoc[leveloffset=+1] 25 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/syntax/boolean-operator-table.asciidoc: -------------------------------------------------------------------------------- 1 | Here is the truth table for `AND`, `OR`, `XOR` and `NOT`. 2 | 3 | [options="header", cols="^,^,^,^,^,^", width="85%"] 4 | |==== 5 | |a | b | a `AND` b | a `OR` b | a `XOR` b | `NOT` a 6 | |`false` | `false` | `false` | `false` | `false` | `true` 7 | |`false` | `null` | `false` | `null` | `null` | `true` 8 | |`false` | `true` | `false` | `true` | `true` | `true` 9 | |`true` | `false` | `false` | `true` | `true` | `false` 10 | |`true` | `null` | `null` | `true` | `null` | `false` 11 | |`true` | `true` | `true` | `true` | `false` | `false` 12 | |`null` | `false` | `false` | `null` | `null` | `null` 13 | |`null` | `null` | `null` | `null` | `null` | `null` 14 | |`null` | `true` | `null` | `true` | `null` | `null` 15 | |==== -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/syntax/comments.asciidoc: -------------------------------------------------------------------------------- 1 | [[cypher-comments]] 2 | = Comments 3 | 4 | [abstract] 5 | -- 6 | This section describes how how to use comments in Cypher. 7 | -- 8 | 9 | A comment begin with double slash (`//`) and continue to the end of the line. 10 | Comments do not execute, they are for humans to read. 11 | 12 | Examples: 13 | 14 | [source, cypher] 15 | ---- 16 | MATCH (n) RETURN n //This is an end of line comment 17 | ---- 18 | 19 | [source, cypher] 20 | ---- 21 | MATCH (n) 22 | //This is a whole line comment 23 | RETURN n 24 | ---- 25 | 26 | [source, cypher] 27 | ---- 28 | MATCH (n) WHERE n.property = '//This is NOT a comment' RETURN n 29 | ---- 30 | 31 | 32 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/syntax/naming.asciidoc: -------------------------------------------------------------------------------- 1 | [[cypher-naming]] 2 | = Naming rules and recommendations 3 | 4 | [abstract] 5 | -- 6 | This section describes rules and recommendations for the naming of node labels, relationship types, property names, variables, indexes, and constraints. 7 | -- 8 | 9 | == Naming rules 10 | 11 | * Alphabetic characters: 12 | ** Names should begin with an alphabetic character. 13 | ** This includes "non-English" characters, such as `å`, `ä`, `ö`, `ü` etc. 14 | * Numbers: 15 | ** Names should not begin with a number. 16 | ** To illustrate, `1first` is not allowed, whereas `first1` is allowed. 17 | * Symbols: 18 | ** Names should not contain symbols, except for underscore, as in `my_variable`, or `$` as the first character to denote a <>, as given by `$myParam`. 19 | * Length: 20 | ** Can be very long, up to `65535` (`2^16 - 1`) or `65534` characters, depending on the version of Neo4j. 21 | * Case-sensitive: 22 | ** Names are case-sensitive and thus, `:PERSON`, `:Person` and `:person` are three different labels, and `n` and `N` are two different variables. 23 | * Whitespace characters: 24 | ** Leading and trailing whitespace characters will be removed automatically. 25 | For example, `MATCH ( a ) RETURN a` is equivalent to `MATCH (a) RETURN a`. 26 | 27 | [NOTE] 28 | ==== 29 | Non-alphabetic characters, including numbers, symbols and whitespace characters, *can* be used in names, but *must* be escaped using backticks. 30 | For example: `++`^n`++`, `++`1first`++`, `++`$$n`++`, and `++`my variable has spaces`++`. 31 | Database names are an exception and may include dots without the need for escaping. 32 | For example: naming a database `foo.bar.baz` is perfectly valid. 33 | ==== 34 | 35 | == Scoping and namespace rules 36 | 37 | * Node labels, relationship types and property names may re-use names. 38 | ** The following query -- with `a` for the label, type and property name -- is valid: `+CREATE (a:a {a: 'a'})-[r:a]->(b:a {a: 'a'})+`. 39 | * Variables for nodes and relationships must not re-use names within the same query scope. 40 | ** The following query is not valid as the node and relationship both have the name `a`: `+CREATE (a)-[a]->(b)+`. 41 | 42 | 43 | == Recommendations 44 | 45 | Here are the recommended naming conventions: 46 | 47 | |=== 48 | | Node labels | Camel-case, beginning with an upper-case character | `:VehicleOwner` rather than `:vehicle_owner` etc. 49 | | Relationship types | Upper-case, using underscore to separate words | `:OWNS_VEHICLE` rather than `:ownsVehicle` etc. 50 | |=== 51 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/syntax/reserved.asciidoc: -------------------------------------------------------------------------------- 1 | [[cypher-reserved]] 2 | = Reserved keywords 3 | 4 | [abstract] 5 | -- 6 | This section contains a list of reserved keywords in Cypher. 7 | -- 8 | 9 | Reserved keywords are words that have a special meaning in Cypher. 10 | The listing of the reserved keywords are grouped by the categories from which they are drawn. 11 | In addition to this, there are a number of keywords that are reserved for future use. 12 | 13 | The reserved keywords are not permitted to be used as identifiers in the following contexts: 14 | 15 | * Variables 16 | * Function names 17 | * Parameters 18 | 19 | If any reserved keyword is escaped -- i.e. is encapsulated by backticks ```, such as `++`AND`++` -- it would become a valid identifier in the above contexts. 20 | 21 | == Clauses 22 | 23 | * `CALL` 24 | * `CREATE` 25 | * `DELETE` 26 | * `DETACH` 27 | * `FOREACH` 28 | * `LOAD` 29 | * `MATCH` 30 | * `MERGE` 31 | * `OPTIONAL` 32 | * `REMOVE` 33 | * `RETURN` 34 | * `SET` 35 | * `START` 36 | * `UNION` 37 | * `UNWIND` 38 | * `WITH` 39 | 40 | == Subclauses 41 | 42 | * `LIMIT` 43 | * `ORDER` 44 | * `SKIP` 45 | * `WHERE` 46 | * `YIELD` 47 | 48 | == Modifiers 49 | 50 | * `ASC` 51 | * `ASCENDING` 52 | * `ASSERT` 53 | * `BY` 54 | * `CSV` 55 | * `DESC` 56 | * `DESCENDING` 57 | * `ON` 58 | 59 | == Expressions 60 | 61 | * `ALL` 62 | * `CASE` 63 | * `COUNT` 64 | * `ELSE` 65 | * `END` 66 | * `EXISTS` 67 | * `THEN` 68 | * `WHEN` 69 | 70 | == Operators 71 | 72 | * `AND` 73 | * `AS` 74 | * `CONTAINS` 75 | * `DISTINCT` 76 | * `ENDS` 77 | * `IN` 78 | * `IS` 79 | * `NOT` 80 | * `OR` 81 | * `STARTS` 82 | * `XOR` 83 | 84 | == Schema 85 | 86 | * `CONSTRAINT` 87 | * `CREATE` 88 | * `DROP` 89 | * `EXISTS` 90 | * `INDEX` 91 | * `NODE` 92 | * `KEY` 93 | * `UNIQUE` 94 | 95 | == Hints 96 | 97 | * `INDEX` 98 | * `JOIN` 99 | * `SCAN` 100 | * `USING` 101 | 102 | == Literals 103 | 104 | * `false` 105 | * `null` 106 | * `true` 107 | 108 | == Reserved for future use 109 | 110 | * `ADD` 111 | * `DO` 112 | * `FOR` 113 | * `MANDATORY` 114 | * `OF` 115 | * `REQUIRE` 116 | * `SCALAR` 117 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/dev/syntax/variables.asciidoc: -------------------------------------------------------------------------------- 1 | [[cypher-variables]] 2 | = Variables 3 | 4 | [abstract] 5 | -- 6 | This section provides an overview of variables in Cypher. 7 | -- 8 | 9 | When you reference parts of a pattern or a query, you do so by naming them. 10 | The names you give the different parts are called variables. 11 | 12 | In this example: 13 | 14 | [source, cypher] 15 | ---- 16 | MATCH (n)-->(b) 17 | RETURN b 18 | ---- 19 | 20 | The variables are `n` and `b`. 21 | 22 | Information regarding the naming of variables may be found <>. 23 | 24 | [IMPORTANT] 25 | .Variables are only visible in the same query part 26 | ==== 27 | Variables are not carried over to subsequent queries. 28 | If multiple query parts are chained together using `WITH`, variables have to be listed in the `WITH` clause to be carried over to the next part. 29 | For more information see <>. 30 | ==== 31 | 32 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/graphgists/import/movies.csv: -------------------------------------------------------------------------------- 1 | id,title,country,year 2 | 1,Wall Street,USA,1987 3 | 2,The American President,USA,1995 4 | 3,The Shawshank Redemption,USA,1994 5 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/graphgists/import/persons.csv: -------------------------------------------------------------------------------- 1 | id,name 2 | 1,Charlie Sheen 3 | 2,Oliver Stone 4 | 3,Michael Douglas 5 | 4,Martin Sheen 6 | 5,Morgan Freeman 7 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/graphgists/import/roles.csv: -------------------------------------------------------------------------------- 1 | personId,movieId,role 2 | 1,1,Bud Fox 3 | 4,1,Carl Fox 4 | 3,1,Gordon Gekko 5 | 4,2,A.J. MacInerney 6 | 3,2,President Andrew Shepherd 7 | 5,3,Ellis Boyd 'Red' Redding 8 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/graphgists/intro/movie_actor_roles.csv: -------------------------------------------------------------------------------- 1 | title;released;actor;born;characters 2 | Back to the Future;1985;Michael J. Fox;1961;Marty McFly 3 | Back to the Future;1985;Christopher Lloyd;1938;Dr. Emmet Brown 4 | 5 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/graphgists/intro/movies.csv: -------------------------------------------------------------------------------- 1 | id,title,country,year 2 | 1,Wall Street,USA,1987 3 | 2,The American President,USA,1995 4 | 3,The Shawshank Redemption,USA,1994 5 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/graphgists/intro/persons.csv: -------------------------------------------------------------------------------- 1 | id,name 2 | 1,Charlie Sheen 3 | 2,Oliver Stone 4 | 3,Michael Douglas 5 | 4,Martin Sheen 6 | 5,Morgan Freeman 7 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/docs/graphgists/intro/roles.csv: -------------------------------------------------------------------------------- 1 | personId,movieId,role 2 | 1,1,Bud Fox 3 | 4,1,Carl Fox 4 | 3,1,Gordon Gekko 5 | 4,2,A.J. MacInerney 6 | 3,2,President Andrew Shepherd 7 | 5,3,Ellis Boyd 'Red' Redding 8 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/main/java/org/neo4j/function/example/JoinFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.function.example; 21 | 22 | import java.util.List; 23 | import org.neo4j.procedure.Description; 24 | import org.neo4j.procedure.Name; 25 | import org.neo4j.procedure.UserFunction; 26 | 27 | // tag::joinFunction[] 28 | public class JoinFunction { 29 | 30 | /** 31 | * Joins a list of strings together using the provided delimiter 32 | * 33 | * @param strings the strings to join 34 | * @param delimiter the delimiter to join with (optional) 35 | * @return A string composed of the strings joined using the delimiter 36 | */ 37 | @UserFunction 38 | @Description("org.neo4j.function.example.join(['s1','s2',...], delimiter) - join the given strings with the " + 39 | "given delimiter.") 40 | public String join( 41 | @Name("strings") List strings, 42 | @Name(value = "delimiter", defaultValue = ",") String delimiter) { 43 | if (strings == null || delimiter == null) { 44 | return null; 45 | } 46 | return String.join(delimiter, strings); 47 | } 48 | } 49 | // end::joinFunction[] 50 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/main/java/org/neo4j/function/example/LongestString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.function.example; 21 | 22 | import org.neo4j.procedure.Description; 23 | import org.neo4j.procedure.Name; 24 | import org.neo4j.procedure.UserAggregationFunction; 25 | import org.neo4j.procedure.UserAggregationResult; 26 | import org.neo4j.procedure.UserAggregationUpdate; 27 | 28 | // tag::longestString[] 29 | public class LongestString { 30 | @UserAggregationFunction 31 | @Description("org.neo4j.function.example.longestString(string) - aggregates the longest string found") 32 | public LongStringAggregator longestString() { 33 | return new LongStringAggregator(); 34 | } 35 | 36 | public static class LongStringAggregator { 37 | private int longest; 38 | private String longestString; 39 | 40 | @UserAggregationUpdate 41 | public void findLongest( 42 | @Name("string") String string) { 43 | if (string != null && string.length() > longest) { 44 | longest = string.length(); 45 | longestString = string; 46 | } 47 | } 48 | 49 | @UserAggregationResult 50 | public String result() { 51 | return longestString; 52 | } 53 | } 54 | } 55 | // end::longestString[] 56 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/java/org/neo4j/cypher/example/JavaQueryDocTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.example; 21 | 22 | import static org.junit.jupiter.api.Assertions.assertTrue; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.neo4j.doc.tools.JavaDocsGenerator; 26 | import org.neo4j.visualization.asciidoc.AsciidocHelper; 27 | 28 | class JavaQueryDocTest { 29 | @Test 30 | void test() { 31 | JavaDocsGenerator gen = new JavaDocsGenerator("java-cypher-queries", "dev/java"); 32 | 33 | JavaQuery jq = new JavaQuery(); 34 | jq.run(); 35 | assertTrue(jq.columnsString.contains("n,")); 36 | assertTrue(jq.columnsString.contains("n.name")); 37 | assertTrue(jq.resultString.contains("Node[")); 38 | assertTrue(jq.resultString.contains("name")); 39 | assertTrue(jq.resultString.contains("my")); 40 | assertTrue(jq.resultString.contains("1 row")); 41 | assertTrue(jq.nodeResult.contains("Node[")); 42 | assertTrue(jq.nodeResult.contains("my")); 43 | assertTrue(jq.rows.contains("n.name: my node; ")); 44 | assertTrue(jq.rows.contains("Node[")); 45 | assertTrue(jq.rows.contains("];")); 46 | 47 | gen.saveToFile("result", AsciidocHelper.createOutputSnippet(jq.resultString)); 48 | gen.saveToFile("columns", AsciidocHelper.createOutputSnippet(jq.columnsString)); 49 | gen.saveToFile("node", AsciidocHelper.createOutputSnippet(jq.nodeResult)); 50 | gen.saveToFile("rows", AsciidocHelper.createOutputSnippet(jq.rows)); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/java/org/neo4j/cypher/export/DatabaseSubGraph.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.export; 21 | 22 | import org.neo4j.graphdb.Node; 23 | import org.neo4j.graphdb.Relationship; 24 | import org.neo4j.graphdb.Transaction; 25 | import org.neo4j.graphdb.schema.ConstraintDefinition; 26 | import org.neo4j.graphdb.schema.IndexDefinition; 27 | 28 | public class DatabaseSubGraph implements SubGraph { 29 | private final Transaction transaction; 30 | 31 | private DatabaseSubGraph(Transaction transaction) { 32 | this.transaction = transaction; 33 | } 34 | 35 | public static SubGraph from(Transaction transaction) { 36 | return new DatabaseSubGraph(transaction); 37 | } 38 | 39 | @Override 40 | public Iterable getNodes() { 41 | return transaction.getAllNodes(); 42 | } 43 | 44 | @Override 45 | public Iterable getRelationships() { 46 | return transaction.getAllRelationships(); 47 | } 48 | 49 | @Override 50 | public boolean contains(Relationship relationship) { 51 | return transaction.getRelationshipById(relationship.getId()) != null; 52 | } 53 | 54 | @Override 55 | public Iterable getIndexes() { 56 | return transaction.schema().getIndexes(); 57 | } 58 | 59 | @Override 60 | public Iterable getConstraints() { 61 | return transaction.schema().getConstraints(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/java/org/neo4j/cypher/export/SubGraph.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.export; 21 | 22 | import org.neo4j.graphdb.Node; 23 | import org.neo4j.graphdb.Relationship; 24 | import org.neo4j.graphdb.schema.ConstraintDefinition; 25 | import org.neo4j.graphdb.schema.IndexDefinition; 26 | 27 | public interface SubGraph { 28 | Iterable getNodes(); 29 | 30 | Iterable getRelationships(); 31 | 32 | boolean contains(Relationship relationship); 33 | 34 | Iterable getIndexes(); 35 | 36 | Iterable getConstraints(); 37 | } 38 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/java/org/neo4j/cypher/internal/javacompat/GraphImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.internal.javacompat; 21 | 22 | import java.lang.annotation.Annotation; 23 | import org.neo4j.doc.test.GraphDescription.Graph; 24 | import org.neo4j.doc.test.GraphDescription.NODE; 25 | import org.neo4j.doc.test.GraphDescription.REL; 26 | 27 | public class GraphImpl implements Graph { 28 | 29 | private final String[] value; 30 | 31 | public GraphImpl(String[] value) { 32 | this.value = value; 33 | } 34 | 35 | @Override 36 | public Class annotationType() { 37 | return null; 38 | } 39 | 40 | @Override 41 | public String[] value() { 42 | return value; 43 | } 44 | 45 | @Override 46 | public NODE[] nodes() { 47 | return new NODE[]{}; 48 | } 49 | 50 | @Override 51 | public REL[] relationships() { 52 | return new REL[]{}; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/resources/keystore_11_0_5.pkcs12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/cypher/cypher-docs/src/test/resources/keystore_11_0_5.pkcs12 -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/CsvFile.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen 21 | 22 | import java.io.File 23 | import java.io.PrintWriter 24 | import java.nio.charset.StandardCharsets 25 | 26 | object CsvFile { 27 | 28 | def urify(file: File): String = 29 | file.toURI.toURL.toString.replace("\\", "\\\\") 30 | } 31 | 32 | class CsvFile(fileName: String, delimiter: Char = ',')(implicit csvFilesDir: File) { 33 | 34 | import org.neo4j.cypher.docgen.CsvFile._ 35 | 36 | def withContents(lines: Seq[String]*): String = { 37 | val csvFile = withContentsF(false, lines: _*) 38 | urify(csvFile) 39 | } 40 | 41 | def withContentsF(lines: Seq[String]*): File = { 42 | withContentsF(false, lines: _*) 43 | } 44 | 45 | def withContentsF(quoted: Boolean, lines: Seq[String]*): File = { 46 | val csvFile = new File(csvFilesDir, fileName) 47 | val writer = new PrintWriter(csvFile, StandardCharsets.UTF_8.name()) 48 | lines.foreach(line => { 49 | writer.println(line.map(s => if (quoted) '"' + s + '"' else s).mkString(delimiter.toString)) 50 | }) 51 | writer.flush() 52 | writer.close() 53 | csvFile 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/ExecutionEngineFactory.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen 21 | 22 | import org.neo4j.cypher.internal._ 23 | import org.neo4j.cypher.internal.javacompat.ExecutionEngineGetter 24 | import org.neo4j.dbms.api.DatabaseManagementService 25 | import org.neo4j.graphdb.GraphDatabaseService 26 | import org.neo4j.io.fs.EphemeralFileSystemAbstraction 27 | import org.neo4j.kernel.internal.GraphDatabaseAPI 28 | import org.neo4j.test.TestDatabaseManagementServiceBuilder 29 | import org.neo4j.test.utils.TestDirectory 30 | 31 | object ExecutionEngineFactory { 32 | 33 | def createCommunityDbms(): DatabaseManagementService = { 34 | val fs = new EphemeralFileSystemAbstraction() 35 | val td = TestDirectory.testDirectory(this.getClass, fs) 36 | val dbFolder = td.prepareDirectoryForTest("target/example-db" + System.nanoTime()).toFile 37 | new TestDatabaseManagementServiceBuilder(dbFolder.toPath).setFileSystem(fs).build() 38 | } 39 | 40 | def getExecutionEngine(graph: GraphDatabaseService): ExecutionEngine = { 41 | val resolver = graph.asInstanceOf[GraphDatabaseAPI].getDependencyResolver 42 | val ee = resolver.resolveDependency(classOf[org.neo4j.cypher.internal.javacompat.ExecutionEngine]) 43 | ExecutionEngineGetter.getCypherExecutionEngine(ee) 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/LoadCSVFunctionsTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen 21 | 22 | import org.neo4j.cypher.docgen.tooling._ 23 | 24 | class LoadCSVFunctionsTest extends DocumentingTest { 25 | 26 | override def outputPath = "target/docs/dev/ql/functions" 27 | 28 | override def doc = new DocBuilder { 29 | doc("LOAD CSV functions", "query-functions-load-csv") 30 | synopsis("LOAD CSV functions can be used to get information about the file that is processed by `LOAD CSV`.") 31 | 32 | important { 33 | p("""The functions described on this page are only useful when run on a query that uses `LOAD CSV`. 34 | #In all other contexts they will always return `null`.""".stripMargin('#')) 35 | } 36 | 37 | p("""Functions: 38 | # 39 | #* <> 40 | #* <>""".stripMargin('#')) 41 | 42 | section("linenumber()", "functions-linenumber") { 43 | p("`linenumber()` returns the line number that `LOAD CSV` is currently using.") 44 | function("linenumber()", "An Integer.") 45 | considerations( 46 | "`null` will be returned if this function is called without a `LOAD CSV` context.", 47 | "If the CSV file contains headers, the headers will be `linenumber` 1 and the 1st row of data will have a `linenumber` of 2." 48 | ) 49 | } 50 | 51 | section("file()", "functions-file") { 52 | p("`file()` returns the absolute path of the file that `LOAD CSV` is using.") 53 | function("file()", "A String.") 54 | considerations("`null` will be returned if this function is called without a `LOAD CSV` context.") 55 | } 56 | }.build() 57 | } 58 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/PrivilegesTestBase.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen 21 | 22 | import org.neo4j.cypher.docgen.tooling.ResultAssertions 23 | import org.scalatest.matchers.should.Matchers._ 24 | 25 | trait PrivilegesTestBase { 26 | 27 | def assertPrivilegeShown(expected: Seq[Map[String, AnyRef]]): ResultAssertions = ResultAssertions(p => { 28 | // Quite lenient method: 29 | // - Only checks specified rows, result can include more privileges that are not checked against 30 | // - Only checks specified fields, result can include more fields that are not checked against 31 | // - Only checks that the number of found matching rows are the same as number of expected rows 32 | 33 | // This can however lead to errors: 34 | // - If you specify too few fields you might match more than one privilege and the sizes will differ (ex. not specifying `segment` and finding both `NODE` and `RELATIONSHIP`) 35 | // - Will not fail when expecting ['existing matching 2 privileges', 'non-existing'], since we will find 2 privileges matching the first and none matching the second (so the sizes will be the same) 36 | val found = p.toList.filter { row => 37 | val m = expected.filter { expectedRow => 38 | expectedRow.forall { 39 | case (k, v) => row.contains(k) && row(k) == v 40 | } 41 | } 42 | m.nonEmpty 43 | } 44 | found.nonEmpty should be(true) 45 | found.size should equal(expected.size) 46 | }) 47 | } 48 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/UserDefinedAggregationFunctionTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen 21 | 22 | import org.neo4j.cypher.docgen.tooling.DocBuilder 23 | import org.neo4j.cypher.docgen.tooling.DocumentingTest 24 | import org.neo4j.cypher.docgen.tooling.ResultAssertions 25 | 26 | class UserDefinedAggregationFunctionTest extends DocumentingTest { 27 | 28 | override def outputPath = "target/docs/dev/ql/functions" 29 | 30 | override def doc = new DocBuilder { 31 | doc("User-defined aggregation functions", "query-functions-user-defined-aggregation") 32 | registerUserDefinedAggregationFunctions(classOf[org.neo4j.function.example.LongestString]) 33 | 34 | initQueries( 35 | """UNWIND ['John', 'Paul', 'George', 'Ringe'] AS beatle 36 | |CREATE (:Member {name: beatle})""".stripMargin 37 | ) 38 | p("Aggregating functions consume many rows and produces a single aggregated result.") 39 | p("This example shows how you invoke a user-defined aggregation function called `longestString` from Cypher.") 40 | 41 | section("Call a user-defined aggregation function", "functions-call-a-user-defined-aggregation-function") { 42 | p("This calls the user-defined function `org.neo4j.function.example.longestString()`.") 43 | query( 44 | """MATCH (n:Member) 45 | |RETURN org.neo4j.function.example.longestString(n.name) AS member""".stripMargin, 46 | ResultAssertions((r) => { 47 | assert(r.toList === List(Map("member" -> "George"))) 48 | }) 49 | ) { 50 | resultTable() 51 | } 52 | } 53 | }.build() 54 | 55 | } 56 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/UserDefinedFunctionTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen 21 | 22 | import org.neo4j.cypher.docgen.tooling.DocBuilder 23 | import org.neo4j.cypher.docgen.tooling.DocumentingTest 24 | import org.neo4j.cypher.docgen.tooling.ResultAssertions 25 | 26 | class UserDefinedFunctionTest extends DocumentingTest { 27 | 28 | override def outputPath = "target/docs/dev/ql/functions" 29 | 30 | override def doc = new DocBuilder { 31 | doc("User-defined scalar functions", "query-functions-udf") 32 | 33 | registerUserDefinedFunctions(classOf[org.neo4j.function.example.JoinFunction]) 34 | 35 | initQueries( 36 | """UNWIND ["John", "Paul", "George", "Ringo"] as name CREATE (:Member {name: name})""" 37 | ) 38 | 39 | p(""" 40 | |For each incoming row the function takes parameters and returns a single result.""") 41 | 42 | p(""" 43 | |This example shows how you invoke a user-defined function called `join` from Cypher.""") 44 | 45 | section("Call a user-defined function") { 46 | p("This calls the user-defined function `org.neo4j.procedure.example.join()`.") 47 | 48 | query( 49 | "MATCH (n:Member) RETURN org.neo4j.function.example.join(collect(n.name)) AS members", 50 | ResultAssertions((r) => 51 | assert(r.toList === List(Map("members" -> "John,Paul,George,Ringo"))) 52 | ) 53 | ) { 54 | resultTable() 55 | } 56 | } 57 | 58 | p( 59 | """ 60 | |For developing and deploying user-defined functions in Neo4j, see < User-defined functions>>.""" 61 | ) 62 | 63 | }.build() 64 | } 65 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/tooling/captureStateAsGraphViz.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.tooling 21 | 22 | import org.neo4j.cypher.GraphIcing 23 | import org.neo4j.cypher.internal.javacompat.GraphDatabaseCypherService 24 | import org.neo4j.cypher.internal.util._ 25 | import org.neo4j.visualization.graphviz.AsciiDocSimpleStyle 26 | import org.neo4j.visualization.graphviz.GraphvizWriter 27 | import org.neo4j.walk.Walker 28 | 29 | import java.io.ByteArrayOutputStream 30 | 31 | /** 32 | * Run this method to capture the graph state. The Content object sent in will be rewritten 33 | * away and replaced with a Content object containing the GraphViz 34 | */ 35 | object captureStateAsGraphViz extends GraphIcing { 36 | 37 | def apply(db: GraphDatabaseCypherService, name: String, count: Int, options: String): GraphViz = 38 | GraphViz(emitGraphviz(s"$name-$count", options, db)) 39 | 40 | private def emitGraphviz(testid: String, graphVizOptions: String, db: GraphDatabaseCypherService): String = { 41 | val out = new ByteArrayOutputStream() 42 | val writer = new GraphvizWriter(AsciiDocSimpleStyle.withAutomaticRelationshipTypeColors()) 43 | 44 | db.withTx(tx => { 45 | writer.emit(out, Walker.fullGraph(tx)) 46 | }) 47 | 48 | """.Graph 49 | |["dot", "%s.svg", "neoviz", "%s"] 50 | |---- 51 | |%s 52 | |---- 53 | | """.stripMargin.format(testid, graphVizOptions, out) 54 | } 55 | 56 | } 57 | 58 | case class replaceSingleObject(from: Content, to: Content) extends Rewriter { 59 | override def apply(input: AnyRef) = instance.apply(input) 60 | 61 | private val instance: Rewriter = bottomUp(Rewriter.lift { 62 | case x if x == from => to 63 | }) 64 | } 65 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/tooling/contentAndResultMerger.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.tooling 21 | 22 | import org.neo4j.cypher.internal.util.Rewritable._ 23 | import org.neo4j.cypher.internal.util.Rewriter 24 | import org.neo4j.cypher.internal.util.bottomUp 25 | 26 | /** 27 | * Takes the document tree and the execution results and rewrites the 28 | * tree to include the result content 29 | */ 30 | object contentAndResultMerger { 31 | 32 | def apply(originalContent: Document, result: TestRunResult): Document = { 33 | val rewritesToDo = for { 34 | runResult <- result.queryResults 35 | newContent <- runResult.newContent 36 | original = runResult.original 37 | } yield original -> newContent 38 | 39 | val replacer = new ContentReplacer(rewritesToDo.toMap) 40 | originalContent.endoRewrite(replacer) 41 | } 42 | /* 43 | 44 | A(B(Query("", Section(table(), graphVizResult()))) 45 | 46 | GraphVizPlaceHolder -> GraphVizResult 47 | Query(_,_, originalContent) -> Query(_, _, newContent) 48 | Query(_,_, originalContent) -> newContent 49 | */ 50 | 51 | private class ContentReplacer(rewrites: Map[QueryResultPlaceHolder, Content]) extends Rewriter { 52 | override def apply(value: AnyRef): AnyRef = instance(value) 53 | 54 | private val instance: Rewriter = bottomUp(Rewriter.lift { 55 | case q: QueryResultPlaceHolder => rewrites(q) 56 | }) 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /cypher/cypher-docs/src/test/scala/org/neo4j/cypher/internal/javacompat/ExecutionEngineGetter.scala: -------------------------------------------------------------------------------- 1 | package org.neo4j.cypher.internal.javacompat 2 | 3 | object ExecutionEngineGetter { 4 | 5 | // Hacking around `protected` 6 | // (better to depend on this single thing than on lots of internal things like we did before) 7 | def getCypherExecutionEngine(engine: org.neo4j.cypher.internal.javacompat.ExecutionEngine) 8 | : org.neo4j.cypher.internal.ExecutionEngine = 9 | engine.cypherExecutionEngine 10 | } 11 | -------------------------------------------------------------------------------- /cypher/cypher-prettifier/src/main/scala/org/neo4j/cypher/docgen/tooling/CypherPrettifier.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.tooling 21 | 22 | import org.neo4j.cypher.internal.ast.Statement 23 | import org.neo4j.cypher.internal.ast.factory.neo4j.JavaCCParser 24 | import org.neo4j.cypher.internal.ast.prettifier.ExpressionStringifier 25 | import org.neo4j.cypher.internal.ast.prettifier.Prettifier 26 | import org.neo4j.cypher.internal.util.OpenCypherExceptionFactory 27 | 28 | trait Prettifying { 29 | 30 | /** 31 | * @param input the input to prettify 32 | */ 33 | def apply(input: String): String 34 | } 35 | 36 | case object CypherPrettifier extends Prettifying { 37 | 38 | override def apply(input: String): String = { 39 | val prettifier: Prettifier = Prettifier(ExpressionStringifier()) 40 | 41 | val parsingResults: Statement = JavaCCParser.parse(input, OpenCypherExceptionFactory(None)) 42 | prettifier.asString(parsingResults) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /cypher/refcard-tests/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | \#* 3 | target 4 | *.swp 5 | .project 6 | .classpath 7 | .settings 8 | .pydevproject 9 | *.iws 10 | *.ipr 11 | *.iml 12 | .idea 13 | .DS_Store 14 | .cache 15 | .scala_dependencies 16 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/resources/keystore_11_0_5.pkcs12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/cypher/refcard-tests/src/test/resources/keystore_11_0_5.pkcs12 -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/AliasManagementPrivilegeTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | class AliasManagementPrivilegeTest extends AdministrationCommandTestBase { 23 | val title = "(★) Alias management privileges" 24 | override val linkId = "administration/security/administration/#access-control-dbms-administration-alias-management" 25 | 26 | private def setup() = graph.withTx { tx => 27 | tx.execute("CREATE ROLE my_role") 28 | tx.execute("DENY DROP ALIAS ON DBMS TO my_role") 29 | tx.execute("GRANT ALTER ALIAS ON DBMS TO my_role") 30 | } 31 | 32 | def text: String = { 33 | setup() 34 | """ 35 | ###assertion=update-one 36 | // 37 | 38 | GRANT CREATE ALIAS ON DBMS TO my_role 39 | ### 40 | 41 | Grant the privilege to create aliases to a role. 42 | 43 | ###assertion=update-one 44 | // 45 | 46 | REVOKE DENY DROP ALIAS ON DBMS FROM my_role 47 | ### 48 | 49 | Revoke the denied privilege to delete aliases from a role. 50 | 51 | ###assertion=update-one 52 | // 53 | 54 | REVOKE GRANT ALTER ALIAS ON DBMS FROM my_role 55 | ### 56 | 57 | Revoke the granted privilege to alter aliases from a role. 58 | 59 | ###assertion=update-one 60 | // 61 | 62 | GRANT SHOW ALIAS ON DBMS TO my_role 63 | ### 64 | 65 | Granted privilege to list aliases to a role. 66 | 67 | ###assertion=update-one 68 | // 69 | 70 | DENY ALIAS MANAGEMENT ON DBMS TO my_role 71 | ### 72 | 73 | Deny all privileges to manage aliases to a role. 74 | 75 | """ 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/CallSubqueryTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class CallSubqueryTest extends RefcardTest with QueryStatisticsTestSupport { 28 | 29 | val graphDescription = List("A:Person:Child FRIEND_OF B:Person", "A CHILD_OF C:Person:Parent") 30 | val title = "CALL subquery" 31 | override val linkId = "clauses/call-subquery" 32 | 33 | override val properties: Map[String, Map[String, Any]] = Map( 34 | "A" -> Map("name" -> "Alice"), 35 | "B" -> Map("name" -> "Bob"), 36 | "C" -> Map("name" -> "Chuck") 37 | ) 38 | 39 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = { 40 | name match { 41 | case "itWorks" => 42 | assert(result.toList === Seq(Map("p.name" -> "Alice", "count(other)" -> 2))) 43 | } 44 | } 45 | 46 | override def parameters(name: String): Map[String, Any] = 47 | name match { 48 | case "parameters=arg" => Map("input" -> "foo") 49 | case "" => Map.empty 50 | } 51 | 52 | def text = """ 53 | ### assertion=itWorks 54 | // 55 | 56 | CALL { 57 | MATCH (p:Person)-[:FRIEND_OF]->(other:Person) RETURN p, other 58 | UNION 59 | MATCH (p:Child)-[:CHILD_OF]->(other:Parent) RETURN p, other 60 | } 61 | 62 | RETURN DISTINCT p.name, count(other) 63 | ### 64 | 65 | This calls a subquery with two union parts. 66 | The result of the subquery can afterwards be post-processed. 67 | """ 68 | } 69 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/CaseTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class CaseTest extends RefcardTest with QueryStatisticsTestSupport { 28 | 29 | def graphDescription = List( 30 | "A KNOWS B" 31 | ) 32 | val title = "CASE" 33 | override val linkId = "syntax/expressions" 34 | 35 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = { 36 | name match { 37 | case "simple" => 38 | assertStats(result, nodesCreated = 0) 39 | assert(result.head("result") != 3) 40 | case "generic" => 41 | assertStats(result, nodesCreated = 0) 42 | assert(result.head("result") != 3) 43 | } 44 | } 45 | 46 | override val properties = Map( 47 | "A" -> Map[String, Any]("name" -> "Alice", "age" -> 38, "eyes" -> "brown"), 48 | "B" -> Map[String, Any]("name" -> "Beth", "age" -> 38, "eyes" -> "blue") 49 | ) 50 | 51 | def text = """ 52 | ###assertion=simple 53 | MATCH (n) 54 | RETURN 55 | 56 | CASE n.eyes 57 | WHEN 'blue' THEN 1 58 | WHEN 'brown' THEN 2 59 | ELSE 3 60 | END 61 | 62 | AS result 63 | ### 64 | 65 | Return `THEN` value from the matching `WHEN` value. 66 | The `ELSE` value is optional, and substituted for `null` if missing. 67 | 68 | ###assertion=generic 69 | MATCH (n) 70 | RETURN 71 | 72 | CASE 73 | WHEN n.eyes = 'blue' THEN 1 74 | WHEN n.age < 40 THEN 2 75 | ELSE 3 76 | END 77 | 78 | AS result 79 | ### 80 | 81 | Return `THEN` value from the first `WHEN` predicate evaluating to `true`. 82 | Predicates are evaluated in order. 83 | 84 | """ 85 | } 86 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/DbmsPrivilegeTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | class DbmsPrivilegeTest extends AdministrationCommandTestBase { 23 | val title = "(★) DBMS privileges" 24 | override val linkId = "administration/security/administration/#access-control-dbms-administration-all" 25 | 26 | private def setup() = graph.withTx { tx => 27 | tx.execute("CREATE ROLE my_role") 28 | } 29 | 30 | def text: String = { 31 | setup() 32 | """ 33 | ###assertion=update-one 34 | // 35 | 36 | GRANT ALL ON DBMS TO my_role 37 | ### 38 | 39 | Grant privilege to perform all role, user, database, alias, privilege, procedure, function, and impersonation management to a role. 40 | 41 | ###assertion=update-one 42 | // 43 | 44 | DENY IMPERSONATE (alice) ON DBMS TO my_role 45 | ### 46 | 47 | Deny privilege to impersonate the specified user to a role. 48 | 49 | """ 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/ForeachTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class ForeachTest extends RefcardTest with QueryStatisticsTestSupport { 28 | val graphDescription = List("ROOT KNOWS A", "A:Person KNOWS B:Person", "B KNOWS C:Person", "C KNOWS ROOT") 29 | val title = "FOREACH" 30 | override val linkId = "clauses/foreach" 31 | 32 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = { 33 | name match { 34 | case "foreach" => 35 | assertStats(result, nodesCreated = 3, labelsAdded = 3, propertiesWritten = 3) 36 | assert(result.toList.size === 0) 37 | case "friends" => 38 | assertStats(result, nodesCreated = 0, propertiesWritten = 1) 39 | assert(result.toList.size === 0) 40 | } 41 | } 42 | 43 | override def parameters(name: String): Map[String, Any] = 44 | name match { 45 | case "" => 46 | Map() 47 | } 48 | 49 | override val properties: Map[String, Map[String, Any]] = Map( 50 | "A" -> Map("prop" -> "Andy"), 51 | "B" -> Map("prop" -> "Timothy"), 52 | "C" -> Map("prop" -> "Chris") 53 | ) 54 | 55 | def text = """ 56 | ###assertion=friends 57 | MATCH path = (begin)-[*]->(end) 58 | WHERE id(begin) = %A% AND id(end) = %B% 59 | 60 | FOREACH (r IN relationships(path) | 61 | SET r.marked = true) 62 | ### 63 | Execute a mutating operation for each relationship in a path. 64 | 65 | ###assertion=foreach 66 | WITH ['Alice', 'Bob', 'Charlie'] AS coll 67 | 68 | FOREACH (value IN coll | 69 | CREATE (:Person {name: value})) 70 | ### 71 | Execute a mutating operation for each element in a list. 72 | """ 73 | } 74 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/GraphReadPrivilegeTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | class GraphReadPrivilegeTest extends AdministrationCommandTestBase { 23 | val title = "(★) Graph read privileges" 24 | override val linkId = "administration/security/reads" 25 | 26 | private def setup() = graph.withTx { tx => 27 | tx.execute("CREATE ROLE my_role") 28 | tx.execute("CREATE DATABASE foo") 29 | } 30 | 31 | def text: String = { 32 | setup() 33 | """ 34 | ###assertion=update-one 35 | // 36 | 37 | GRANT TRAVERSE ON GRAPH * NODES * TO my_role 38 | ### 39 | 40 | Grant `traverse` privilege on all nodes and all graphs to a role. 41 | 42 | ###assertion=update-one 43 | // 44 | 45 | DENY READ {prop} ON GRAPH foo RELATIONSHIP Type TO my_role 46 | ### 47 | 48 | Deny `read` privilege on a specified property, on all relationships with a specified type in a specified graph, to a role. 49 | 50 | ###assertion=update-two 51 | // 52 | 53 | GRANT MATCH {*} ON HOME GRAPH ELEMENTS Label TO my_role 54 | ### 55 | 56 | Grant `read` privilege on all properties and `traverse` privilege in the home graph, to a role. 57 | Here, both privileges apply to all nodes and relationships with a specified label/type in the graph. 58 | 59 | """ 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/ImmutablePrivilegeTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | class ImmutablePrivilegeTest extends AdministrationCommandTestBase { 23 | val title = "(★) Immutable privileges" 24 | 25 | override val linkId = 26 | "administration/security/administration/#access-control-privileges-immutable" 27 | 28 | private def setup() = graph.withTx { tx => 29 | tx.execute("CREATE ROLE my_role") 30 | tx.execute("GRANT IMMUTABLE DATABASE MANAGEMENT ON DBMS TO my_role") 31 | } 32 | 33 | def text: String = { 34 | setup() 35 | """ 36 | ###assertion=update-one 37 | // 38 | 39 | DENY IMMUTABLE DATABASE MANAGEMENT ON DBMS TO `my_role` 40 | ### 41 | 42 | Immutably deny the database management privilege to a role. 43 | 44 | ###assertion=update-two 45 | // 46 | 47 | REVOKE IMMUTABLE DATABASE MANAGEMENT ON DBMS FROM `my_role` 48 | ### 49 | 50 | Remove only immutable database management privileges. 51 | 52 | """ 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/PrivilegeManagementPrivilegeTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | class PrivilegeManagementPrivilegeTest extends AdministrationCommandTestBase { 23 | val title = "(★) Privilege management privileges" 24 | 25 | override val linkId = 26 | "administration/security/administration/#access-control-dbms-administration-privilege-management" 27 | 28 | private def setup() = graph.withTx { tx => 29 | tx.execute("CREATE ROLE my_role") 30 | tx.execute("GRANT REMOVE PRIVILEGE ON DBMS TO my_role") 31 | tx.execute("GRANT PRIVILEGE MANAGEMENT ON DBMS TO my_role") 32 | tx.execute("DENY PRIVILEGE MANAGEMENT ON DBMS TO my_role") 33 | } 34 | 35 | def text: String = { 36 | setup() 37 | """ 38 | ###assertion=update-one 39 | // 40 | 41 | GRANT SHOW PRIVILEGE ON DBMS TO my_role 42 | ### 43 | 44 | Grant the privilege to show privileges to a role. 45 | 46 | ###assertion=update-one 47 | // 48 | 49 | DENY ASSIGN PRIVILEGE ON DBMS TO my_role 50 | ### 51 | 52 | Deny the privilege to assign privileges to roles to a role. 53 | 54 | ###assertion=update-one 55 | // 56 | 57 | REVOKE GRANT REMOVE PRIVILEGE ON DBMS FROM my_role 58 | ### 59 | 60 | Revoke the granted privilege to remove privileges from roles from a role. 61 | 62 | ###assertion=update-two 63 | // 64 | 65 | REVOKE PRIVILEGE MANAGEMENT ON DBMS FROM my_role 66 | ### 67 | 68 | Revoke all granted and denied privileges for manage privileges from a role. 69 | 70 | """ 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/RemoveTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class RemoveTest extends RefcardTest with QueryStatisticsTestSupport { 28 | val graphDescription = List("ROOT LINK A:Person", "A LINK B", "B LINK C", "C LINK ROOT") 29 | val title = "REMOVE" 30 | override val linkId = "clauses/remove" 31 | 32 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = { 33 | name match { 34 | case "remove-label" => 35 | assertStats(result, labelsRemoved = 1) 36 | assert(result.toList.size === 0) 37 | case "remove-prop" => 38 | assertStats(result, nodesCreated = 1, propertiesWritten = 2) 39 | assert(result.toList.size === 0) 40 | } 41 | } 42 | 43 | override def parameters(name: String): Map[String, Any] = 44 | name match { 45 | case "parameters=set" => 46 | Map("value" -> "a value") 47 | case "parameters=map" => 48 | Map("map" -> Map("property" -> "a value")) 49 | case "" => 50 | Map() 51 | } 52 | 53 | override val properties: Map[String, Map[String, Any]] = Map( 54 | "A" -> Map("value" -> 10), 55 | "B" -> Map("value" -> 20), 56 | "C" -> Map("value" -> 30) 57 | ) 58 | 59 | def text = """ 60 | ###assertion=remove-label 61 | MATCH (n:Person) 62 | 63 | REMOVE n:Person 64 | ### 65 | 66 | Remove a label from `n`. 67 | 68 | ###assertion=remove-prop 69 | CREATE (n {property: 'value'}) 70 | 71 | REMOVE n.property 72 | ### 73 | 74 | Remove a property. 75 | """ 76 | } 77 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/RoleManagementPrivilegeTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | class RoleManagementPrivilegeTest extends AdministrationCommandTestBase { 23 | val title = "(★) Role management privileges" 24 | override val linkId = "administration/security/administration/#access-control-dbms-administration-role-management" 25 | 26 | private def setup() = graph.withTx { tx => 27 | tx.execute("CREATE ROLE my_role") 28 | tx.execute("DENY SHOW ROLE ON DBMS TO my_role") 29 | } 30 | 31 | def text: String = { 32 | setup() 33 | """ 34 | ###assertion=update-one 35 | // 36 | 37 | GRANT CREATE ROLE ON DBMS TO my_role 38 | ### 39 | 40 | Grant the privilege to create roles to a role. 41 | 42 | ###assertion=update-one 43 | // 44 | 45 | GRANT RENAME ROLE ON DBMS TO my_role 46 | ### 47 | 48 | Grant the privilege to rename roles to a role. 49 | 50 | ###assertion=update-one 51 | // 52 | 53 | GRANT DROP ROLE ON DBMS TO my_role 54 | ### 55 | 56 | Grant the privilege to delete roles to a role. 57 | 58 | ###assertion=update-one 59 | // 60 | 61 | DENY ASSIGN ROLE ON DBMS TO my_role 62 | ### 63 | 64 | Deny the privilege to assign roles to users to a role. 65 | 66 | ###assertion=update-one 67 | // 68 | 69 | DENY REMOVE ROLE ON DBMS TO my_role 70 | ### 71 | 72 | Deny the privilege to remove roles from users to a role. 73 | 74 | ###assertion=update-one 75 | // 76 | 77 | REVOKE DENY SHOW ROLE ON DBMS FROM my_role 78 | ### 79 | 80 | Revoke the denied privilege to show roles from a role. 81 | 82 | ###assertion=update-one 83 | // 84 | 85 | GRANT ROLE MANAGEMENT ON DBMS TO my_role 86 | ### 87 | 88 | Grant all privileges to manage roles to a role. 89 | 90 | """ 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/ServerManagementPrivilegeTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | class ServerManagementPrivilegeTest extends AdministrationCommandTestBase { 23 | val title = "(★) Server management privileges" 24 | override val linkId = "administration/security/administration/#access-control-dbms-administration-server-management" 25 | 26 | private def setup() = graph.withTx { tx => 27 | tx.execute("CREATE ROLE my_role") 28 | } 29 | 30 | def text: String = { 31 | setup() 32 | """ 33 | ###assertion=update-one 34 | // 35 | 36 | GRANT SERVER MANAGEMENT ON DBMS TO my_role 37 | ### 38 | 39 | Grant the privilege to manage servers. 40 | 41 | ###assertion=update-one 42 | // 43 | 44 | DENY SHOW SERVERS ON DBMS TO my_role 45 | ### 46 | 47 | Deny the privilege to show information about the servers. 48 | 49 | """ 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/ShowProcFuncTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class ShowProcFuncTest extends RefcardTest with QueryStatisticsTestSupport { 28 | val graphDescription = List() 29 | val title = "SHOW FUNCTIONS and PROCEDURES" 30 | override val linkId = "clauses/#header-listing-procs-functions" 31 | 32 | // just make sure we get results 33 | // but not the exact number to avoid it breaking 34 | // when new functions or procedures gets added to Neo4j 35 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = assert(result.toList.nonEmpty) 36 | 37 | def text = """ 38 | ###assertion=result 39 | // 40 | 41 | SHOW FUNCTIONS 42 | ### 43 | 44 | Listing all available functions. 45 | 46 | ###assertion=result 47 | // 48 | 49 | SHOW PROCEDURES EXECUTABLE YIELD name 50 | ### 51 | 52 | List all procedures that can be executed by the current user and return only the name of the procedures. 53 | 54 | """ 55 | } 56 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/SubqueryExpressionsTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class SubqueryExpressionsTest extends RefcardTest with QueryStatisticsTestSupport { 28 | 29 | def graphDescription = List( 30 | "A KNOWS B" 31 | ) 32 | val title = "Subquery Expressions" 33 | override val linkId = "syntax/expressions" 34 | 35 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = { 36 | name match { 37 | case "returns-one" => 38 | assertStats(result) 39 | assert(result.toList.size === 1) 40 | } 41 | } 42 | 43 | override val properties: Map[String, Map[String, Any]] = Map( 44 | "A" -> Map("property" -> "Andy", "age" -> 39), 45 | "B" -> Map("property" -> "Timothy", "age" -> 39) 46 | ) 47 | 48 | def text = """ 49 | ###assertion=returns-one 50 | MATCH (n) WHERE 51 | 52 | EXISTS { 53 | MATCH (n)-->(m) WHERE n.age = m.age 54 | } 55 | 56 | RETURN n### 57 | 58 | Use an `EXISTS` subquery expression to test for the existence of a subquery. 59 | 60 | ###assertion=returns-one 61 | MATCH (n) WHERE 62 | 63 | COUNT { 64 | MATCH (n)-[:KNOWS]->(m) WHERE n.age = m.age 65 | } 66 | 67 | = 1 68 | RETURN n### 69 | 70 | Use a `COUNT` subquery expression to count the number of results of a subquery. 71 | """ 72 | } 73 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/TransactionCommandsTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class TransactionCommandsTest extends RefcardTest with QueryStatisticsTestSupport { 28 | val graphDescription = List() 29 | val title = "SHOW and TERMINATE TRANSACTIONS" 30 | override val linkId = "clauses/transaction-clauses" 31 | 32 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = { 33 | name match { 34 | case "show" => 35 | assert(result.toList.size === 1) 36 | case "empty" => 37 | assert(result.toList.size === 0) 38 | } 39 | } 40 | 41 | def text = """ 42 | ###assertion=show 43 | // 44 | 45 | SHOW TRANSACTIONS 46 | ### 47 | 48 | Listing all available transactions. 49 | 50 | ###dontrun 51 | // 52 | 53 | TERMINATE TRANSACTIONS 'neo4j-transaction-42' 54 | ### 55 | 56 | Terminate the transaction with ID `neo4j-transaction-42`. 57 | 58 | ###empty 59 | // 60 | 61 | SHOW TRANSACTIONS 62 | YIELD username, transactionId AS txId 63 | WHERE username = 'MyUser' 64 | TERMINATE TRANSACTIONS txId 65 | YIELD message 66 | RETURN message, txId 67 | ### 68 | 69 | Terminate all transactions by MyUser. 70 | 71 | """ 72 | } 73 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/UnionTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class UnionTest extends RefcardTest with QueryStatisticsTestSupport { 28 | 29 | def graphDescription = List( 30 | "A KNOWS B", 31 | "A LOVES B" 32 | ) 33 | val title = "UNION" 34 | override val linkId = "clauses/union" 35 | 36 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = { 37 | name match { 38 | case "one" => 39 | assertStats(result) 40 | val list = result.toList 41 | assert(list === List(Map("b.name" -> "Beth"))) 42 | assert(list.size === 1) 43 | case "two" => 44 | assertStats(result) 45 | val list = result.toList 46 | assert(list.size === 2) 47 | assert(list === List(Map("b.name" -> "Beth"), Map("b.name" -> "Beth"))) 48 | } 49 | } 50 | 51 | override val properties = Map( 52 | "A" -> Map("name" -> "Alice"), 53 | "B" -> Map("name" -> "Beth") 54 | ) 55 | 56 | def text = """ 57 | ###assertion=one 58 | // 59 | 60 | MATCH (a)-[:KNOWS]->(b) 61 | RETURN b.name 62 | UNION 63 | MATCH (a)-[:LOVES]->(b) 64 | RETURN b.name 65 | 66 | ### 67 | 68 | Returns the distinct union of all query results. 69 | Result column types and names have to match. 70 | 71 | ###assertion=two 72 | // 73 | 74 | MATCH (a)-[:KNOWS]->(b) 75 | RETURN b.name 76 | UNION ALL 77 | MATCH (a)-[:LOVES]->(b) 78 | RETURN b.name 79 | 80 | ### 81 | 82 | Returns the union of all query results, including duplicated rows. 83 | """ 84 | } 85 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/UseTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class UseTest extends RefcardTest with QueryStatisticsTestSupport { 28 | val graphDescription = List() 29 | val title = "USE" 30 | override val linkId = "clauses/use" 31 | 32 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = {} 33 | 34 | def text = """ 35 | ###dontrun 36 | // Can't be run since the USE clause is not available in embedded or http sessions. 37 | 38 | USE myDatabase 39 | ### 40 | 41 | Select `myDatabase` to execute query, or query part, against. 42 | 43 | ###dontrun 44 | // Can't be run since the USE clause is not available in embedded or http sessions. 45 | 46 | USE neo4j 47 | MATCH (n:Person)-[:KNOWS]->(m:Person) 48 | WHERE n.name = 'Alice' 49 | 50 | RETURN n, m### 51 | 52 | `MATCH` query executed against `neo4j` database. 53 | 54 | """ 55 | } 56 | -------------------------------------------------------------------------------- /cypher/refcard-tests/src/test/scala/org/neo4j/cypher/docgen/refcard/WhereTest.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.cypher.docgen.refcard 21 | 22 | import org.neo4j.cypher.docgen.RefcardTest 23 | import org.neo4j.cypher.docgen.tooling.DocsExecutionResult 24 | import org.neo4j.cypher.docgen.tooling.QueryStatisticsTestSupport 25 | import org.neo4j.graphdb.Transaction 26 | 27 | class WhereTest extends RefcardTest with QueryStatisticsTestSupport { 28 | val graphDescription = List("ROOT FRIEND A", "A FRIEND B", "B FRIEND C", "C FRIEND ROOT") 29 | val title = "WHERE" 30 | override val linkId = "clauses/where" 31 | 32 | override def assert(tx: Transaction, name: String, result: DocsExecutionResult): Unit = { 33 | name match { 34 | case "returns-one" => 35 | assertStats(result) 36 | assert(result.toList.size === 1) 37 | } 38 | } 39 | 40 | override def parameters(name: String): Map[String, Any] = 41 | name match { 42 | case "parameters=aname" => 43 | Map("value" -> "Bob") 44 | case _ => Map.empty 45 | } 46 | 47 | override val properties: Map[String, Map[String, Any]] = Map( 48 | "A" -> Map("property" -> "Andy", "age" -> 39), 49 | "B" -> Map("property" -> "Timothy", "age" -> 39), 50 | "C" -> Map("property" -> "Chris", "age" -> 22) 51 | ) 52 | 53 | def text = """ 54 | ###assertion=returns-one parameters=aname 55 | MATCH (n)-->(m) 56 | 57 | WHERE n.property <> $value 58 | 59 | AND id(n) = %A% AND id(m) = %B% 60 | RETURN n, m### 61 | 62 | Use a predicate to filter. 63 | Note that `WHERE` is always part of a `MATCH`, `OPTIONAL MATCH` or `WITH` clause. 64 | Putting it after a different clause in a query will alter what it does. 65 | """ 66 | } 67 | -------------------------------------------------------------------------------- /doctools/src/main/java/org/neo4j/doc/GenerateConfigDocumentation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.doc; 21 | 22 | import java.nio.file.Path; 23 | import java.util.List; 24 | import java.util.function.Function; 25 | import org.neo4j.internal.helpers.Args; 26 | import org.neo4j.io.fs.FileUtils; 27 | 28 | /** 29 | * Generates Asciidoc for the GraphDatabaseSettings class. 30 | */ 31 | public class GenerateConfigDocumentation { 32 | public static void main(String[] argv) throws Exception { 33 | Args arguments = Args.parse(argv); 34 | 35 | Path output = arguments.has("o") ? Path.of(arguments.get("o")) : null; 36 | List settingsClasses = arguments.orphans(); 37 | if (settingsClasses.size() == 0) { 38 | System.out.println("Usage: GenerateConfigDocumentation [-o output file] SETTINGS_CLASS.."); 39 | System.exit(0); 40 | } 41 | 42 | String doc = new SettingsDocumenter() 43 | .document(settingsClasses.stream().map(classFromString)); 44 | 45 | if (output != null) { 46 | System.out.println("Saving docs in '" + output.toAbsolutePath() + "'."); 47 | FileUtils.writeToFile(output, doc, false); 48 | } 49 | else { 50 | System.out.println(doc); 51 | } 52 | } 53 | 54 | private static final Function> classFromString = (className) -> { 55 | try { 56 | return Class.forName(className); 57 | } 58 | catch (ClassNotFoundException e) { 59 | throw new RuntimeException(e); 60 | } 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /doctools/src/main/java/org/neo4j/doc/SettingDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.doc; 21 | 22 | import java.util.Optional; 23 | import java.util.function.Function; 24 | 25 | public interface SettingDescription { 26 | String id(); 27 | 28 | String name(); 29 | 30 | Optional description(); 31 | 32 | boolean isDeprecated(); 33 | 34 | boolean hasDefault(); 35 | 36 | boolean isInternal(); 37 | 38 | boolean hasReplacement(); 39 | 40 | boolean isDynamic(); 41 | 42 | boolean isEnterprise(); 43 | 44 | String replacedBy(); 45 | 46 | String defaultValue(); 47 | 48 | String deprecationMessage(); 49 | 50 | String validationMessage(); 51 | 52 | SettingDescription formatted(Function format); 53 | } 54 | -------------------------------------------------------------------------------- /doctools/src/main/java/org/neo4j/doc/tools/JavaDocsGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.doc.tools; 21 | 22 | import java.io.File; 23 | import java.io.IOException; 24 | import java.io.Writer; 25 | 26 | public class JavaDocsGenerator extends AsciiDocGenerator { 27 | private static final String DIRECTORY = "target" + File.separator + "docs"; 28 | 29 | public JavaDocsGenerator(String title, String section) { 30 | super(title, section); 31 | } 32 | 33 | public void saveToFile(String identifier, String text) { 34 | Writer fw = getFW(DIRECTORY + File.separator + this.section, 35 | getTitle() + "-" + identifier); 36 | try { 37 | line(fw, text); 38 | fw.flush(); 39 | fw.close(); 40 | } 41 | catch (IOException e) { 42 | e.printStackTrace(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /embedded-examples/README.txt: -------------------------------------------------------------------------------- 1 | Embedded Neo4j on the JVM 2 | ========================= 3 | 4 | You'll find some source code in the examples/ directory. These examples 5 | progress from setting up a graph, to indexing, to using algorithms. 6 | Scripts in the bin/ directory run the source code against pre-compiled 7 | classes in the lib/ directory. 8 | 9 | The scripts and related source code are: 10 | 11 | * embedded-neo4j org.neo4j.examples.EmbeddedNeo4j 12 | * embedded-neo4j-with-indexing org.neo4j.examples.EmbeddedNeo4jWithIndexing 13 | * calculate-shortest-path org.neo4j.examples.CalculateShortestPath 14 | * using-integrated-index org.neo4j.examples.UsingIntegratedIndex 15 | 16 | References 17 | ---------- 18 | 19 | * http://neo4j.com/docs/ documentation 20 | 21 | License(s) 22 | ---------- 23 | Various licenses apply. Please refer to the LICENSE and NOTICE files for more 24 | detailed information. A full report regarding the licenses of all included 25 | dependencies is found in site/dependencies.html. 26 | 27 | 28 | -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/data-modeling-examples.asciidoc: -------------------------------------------------------------------------------- 1 | [[data-modeling-examples]] 2 | Data Modeling Examples 3 | ====================== 4 | 5 | The following chapters contain simplified examples of how different domains can be modeled using Neo4j. 6 | The aim is not to give full examples, but to suggest possible ways to think using nodes, relationships, graph patterns and data locality in traversals. 7 | 8 | The examples use Cypher queries a lot, read <> for more information. 9 | 10 | :leveloffset: 2 11 | 12 | include::examples/acl-structures-in-graphs.asciidoc[] 13 | 14 | :leveloffset: 1 15 | 16 | include::{import-neo4j-cypher-docs-sources}/dev/ql/cookbook/index.asciidoc[] 17 | 18 | :leveloffset: 2 19 | 20 | include::examples/user-roles-in-graphs.asciidoc[] 21 | 22 | -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/examples/ACL-graph.asciidoc: -------------------------------------------------------------------------------- 1 | ["dot", "The-Domain-Structure-ACL-structures-in-graphs.svg", "neoviz"] 2 | ---- 3 | subgraph clusterFiles{ 4 | style=invis 5 | node [fontsize=16] 6 | edge [arrowsize=1, color=red]; 7 | N20 -> N17 [ 8 | label = "leaf\n" 9 | ] 10 | 11 | N23 [ 12 | label = "{Node\[23\]|'name' = 'Desktop'}" 13 | ] 14 | N23 -> N16 [ 15 | label = "leaf\n" 16 | ] 17 | N20 [ 18 | label = "{Node\[20\]|'name' = 'HomeU1'}" 19 | ] 20 | N10 [ 21 | label = "{Node\[10\]|'name' = 'Home'}" 22 | ] 23 | N10 -> N20 [ 24 | label = "contains\n" 25 | ] 26 | N10 -> N15 [ 27 | label = "contains\n" 28 | ] 29 | N11 [ 30 | label = "{Node\[11\]|'name' = 'init.d'}" 31 | ] 32 | N12 [ 33 | label = "{Node\[12\]|'name' = 'etc'}" 34 | ] 35 | N12 -> N11 [ 36 | label = "contains\n" 37 | ] 38 | N15 [ 39 | label = "{Node\[15\]|'name' = 'HomeU2'}" 40 | ] 41 | N15 -> N23 [ 42 | label = "contains\n" 43 | ] 44 | N16 [ 45 | label = "{Node\[16\]|'name' = 'File2'}" 46 | ] 47 | N17 [ 48 | label = "{Node\[17\]|'name' = 'File1'}" 49 | ] 50 | N18 [ 51 | label = "{Node\[18\]|'name' = 'FileRoot'}" 52 | ] 53 | N18 -> N10 [ 54 | label = "contains\n" 55 | ] 56 | N18 -> N12 [ 57 | label = "contains\n" 58 | ] 59 | 60 | 61 | } 62 | subgraph clusterUsers { 63 | style=invis 64 | node [fontsize=16] 65 | bgcolor=white; 66 | N7 [ 67 | label = "{Node\[7\]|'name' = 'User'}" 68 | ] 69 | N7 -> N14 [ 70 | label = "member\n" 71 | ] 72 | N7 -> N13 [ 73 | label = "member\n" 74 | ] 75 | N8 [ 76 | label = "{Node\[8\]|'name' = 'Admin2'}" 77 | ] 78 | N9 [ 79 | label = "{Node\[9\]|'name' = 'Admin1'}" 80 | ] 81 | N13 [ 82 | label = "{Node\[13\]|'name' = 'User2'}" 83 | ] 84 | N13 -> N16 [ 85 | label = "owns\n" 86 | ] 87 | N14 [ 88 | label = "{Node\[14\]|'name' = 'User1'}" 89 | ] 90 | N14 -> N17 [ 91 | label = "owns\n" 92 | ] 93 | N21 [ 94 | label = "{Node\[21\]|'name' = 'Role'}" 95 | ] 96 | N21 -> N22 [ 97 | label = "subRole\n" 98 | ] 99 | N21 -> N7 [ 100 | label = "subRole\n" 101 | ] 102 | N22 [ 103 | label = "{Node\[22\]|'name' = 'SUDOers'}" 104 | ] 105 | N22 -> N9 [ 106 | label = "member\n" 107 | ] 108 | N22 -> N8 [ 109 | label = "member\n" 110 | ] 111 | N22 -> N18 [ 112 | label = "canRead\n" 113 | ] 114 | 115 | } 116 | N19 [ 117 | label = "{Node\[19\]|'name' = 'Root'}" 118 | ] 119 | 120 | N19 -> N21 [ 121 | label = "has\n" 122 | ] 123 | N19 -> N18 [ 124 | label = "has\n" 125 | ] 126 | ---- -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/examples/images/RDBMSvsGraph.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/embedded-examples/src/docs/dev/examples/images/RDBMSvsGraph.svg.png -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/images/ACL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/embedded-examples/src/docs/dev/images/ACL.png -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/images/examples-matrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/embedded-examples/src/docs/dev/images/examples-matrix.png -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/images/graphalgo-astar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/embedded-examples/src/docs/dev/images/graphalgo-astar.png -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/images/hello-world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/embedded-examples/src/docs/dev/images/hello-world.png -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/images/roles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/embedded-examples/src/docs/dev/images/roles.png -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/images/social_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/embedded-examples/src/docs/dev/images/social_status.png -------------------------------------------------------------------------------- /embedded-examples/src/docs/dev/images/socnet-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j/neo4j-documentation/cffa2579a2035679dec419009d5218843e3c7503/embedded-examples/src/docs/dev/images/socnet-model.png -------------------------------------------------------------------------------- /embedded-examples/src/main/java/org/neo4j/examples/AnalyzerProviderExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import java.io.IOException; 22 | import java.io.UncheckedIOException; 23 | import org.apache.lucene.analysis.Analyzer; 24 | import org.apache.lucene.analysis.core.LowerCaseFilterFactory; 25 | import org.apache.lucene.analysis.core.StopFilterFactory; 26 | import org.apache.lucene.analysis.custom.CustomAnalyzer; 27 | import org.apache.lucene.analysis.standard.StandardTokenizerFactory; 28 | import org.neo4j.graphdb.schema.AnalyzerProvider; 29 | 30 | public class AnalyzerProviderExample { 31 | // tag::customAnalyzerProvider[] 32 | public class CustomAnalyzerProvider extends AnalyzerProvider // <1> 33 | { 34 | public CustomAnalyzerProvider() // <2> 35 | { 36 | super("custom-analyzer"); // <3> 37 | } 38 | 39 | @Override 40 | public Analyzer createAnalyzer() // <4> 41 | { 42 | try { 43 | return CustomAnalyzer.builder() // <5> 44 | .withTokenizer(StandardTokenizerFactory.class) 45 | .addTokenFilter(LowerCaseFilterFactory.class) 46 | .addTokenFilter(StopFilterFactory.class, "ignoreCase", "false", "words", "stopwords.txt", "format", "wordset") 47 | .build(); 48 | } 49 | catch (IOException e) { 50 | throw new UncheckedIOException(e); 51 | } 52 | } 53 | } 54 | // end::customAnalyzerProvider[] 55 | } 56 | -------------------------------------------------------------------------------- /embedded-examples/src/main/java/org/neo4j/examples/EmbeddedNeo4jClusterUsingNeo4jConf.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import com.neo4j.dbms.api.EnterpriseDatabaseManagementServiceBuilder; 22 | import java.io.IOException; 23 | import java.nio.file.Path; 24 | import org.neo4j.io.fs.FileUtils; 25 | 26 | public class EmbeddedNeo4jClusterUsingNeo4jConf { 27 | private static final Path homeDirectory = Path.of("target/neo4j-home"); 28 | 29 | public static void main(final String[] args) throws IOException { 30 | System.out.println("Starting database ..."); 31 | FileUtils.deleteDirectory(homeDirectory); 32 | 33 | // tag::startCore[] 34 | var managementService = new EnterpriseDatabaseManagementServiceBuilder(homeDirectory) 35 | .loadPropertiesFromFile(Path.of("/path/to/neo4j.conf")) 36 | .build(); 37 | // end::startCore[] 38 | 39 | managementService.shutdown(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /embedded-examples/src/main/java/org/neo4j/examples/EmbeddedNeo4jWithBolt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import java.io.IOException; 22 | import java.nio.file.Path; 23 | import org.neo4j.configuration.connectors.BoltConnector; 24 | import org.neo4j.configuration.helpers.SocketAddress; 25 | import org.neo4j.dbms.api.DatabaseManagementService; 26 | import org.neo4j.dbms.api.DatabaseManagementServiceBuilder; 27 | import org.neo4j.io.fs.FileUtils; 28 | 29 | public class EmbeddedNeo4jWithBolt { 30 | private static final Path DB_PATH = Path.of("target/neo4j-store-with-bolt"); 31 | 32 | public static void main(final String[] args) throws IOException { 33 | System.out.println("Starting database ..."); 34 | FileUtils.deleteDirectory(DB_PATH); 35 | 36 | // tag::startDb[] 37 | DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(DB_PATH) 38 | .setConfig(BoltConnector.enabled, true) 39 | .setConfig(BoltConnector.listen_address, new SocketAddress("localhost", 7687)) 40 | .build(); 41 | // end::startDb[] 42 | 43 | managementService.shutdown(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /embedded-examples/src/main/java/org/neo4j/examples/ProcedureExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import java.util.stream.Stream; 22 | import org.neo4j.graphdb.Node; 23 | import org.neo4j.graphdb.Transaction; 24 | import org.neo4j.procedure.Context; 25 | import org.neo4j.procedure.Name; 26 | import org.neo4j.procedure.Procedure; 27 | 28 | public class ProcedureExample { 29 | // tag::procedureExample[] 30 | @Context 31 | public Transaction transaction; 32 | 33 | /** 34 | * Finds all nodes in the database with more relationships than the specified threshold. 35 | * 36 | * @param threshold only include nodes with at least this many relationships 37 | * @return a stream of records describing dense nodes in this database 38 | */ 39 | @Procedure 40 | public Stream findDenseNodes(@Name("threshold") long threshold) { 41 | return transaction.getAllNodes().stream().filter((node) -> node.getDegree() > threshold).map(DenseNode::new); 42 | } 43 | // end::procedureExample[] 44 | 45 | // tag::outputRecordExample[] 46 | 47 | /** 48 | * Output record for {@link #findDenseNodes(long)}. 49 | */ 50 | public static class DenseNode { 51 | public long nodeId; 52 | public long degree; 53 | 54 | public DenseNode(Node node) { 55 | this.nodeId = node.getId(); 56 | this.degree = node.getDegree(); 57 | } 58 | } 59 | // end::outputRecordExample[] 60 | } 61 | -------------------------------------------------------------------------------- /embedded-examples/src/main/java/org/neo4j/examples/socnet/PositionedIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples.socnet; 20 | 21 | import java.util.Iterator; 22 | 23 | /** 24 | * Decorator class that wraps any iterator and remembers the current node. 25 | */ 26 | 27 | public class PositionedIterator implements Iterator { 28 | private Iterator inner; 29 | private T current; 30 | private Boolean initiated = false; 31 | 32 | /** 33 | * Creates an instance of the class, wrapping iterator 34 | * 35 | * @param iterator The iterator to wrap 36 | */ 37 | public PositionedIterator(Iterator iterator) { 38 | inner = iterator; 39 | } 40 | 41 | @Override 42 | public boolean hasNext() { 43 | return inner.hasNext(); 44 | } 45 | 46 | @Override 47 | public T next() { 48 | initiated = true; 49 | current = inner.next(); 50 | return current; 51 | } 52 | 53 | @Override 54 | public void remove() { 55 | inner.remove(); 56 | } 57 | 58 | /** 59 | * Returns the current node. Any subsequent calls to current will return the same object, unless the next() method has been called. 60 | * 61 | * @return The current node. 62 | */ 63 | public T current() { 64 | if (!initiated) { 65 | return next(); 66 | } 67 | 68 | return current; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /embedded-examples/src/main/java/org/neo4j/examples/socnet/RelTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples.socnet; 20 | 21 | import org.neo4j.graphdb.RelationshipType; 22 | 23 | public enum RelTypes implements RelationshipType { 24 | REF_PERSONS, 25 | A_PERSON, 26 | STATUS, 27 | NEXT, 28 | FRIEND 29 | } 30 | -------------------------------------------------------------------------------- /embedded-examples/src/test/java/org/neo4j/doc/kernel/impl/proc/JarBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.doc.kernel.impl.proc; 20 | 21 | import java.io.ByteArrayOutputStream; 22 | import java.io.File; 23 | import java.io.FileOutputStream; 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.net.URL; 27 | import java.util.jar.JarOutputStream; 28 | import java.util.zip.ZipEntry; 29 | 30 | /** 31 | * Utility to create jar files containing classes from the current classpath. 32 | */ 33 | public class JarBuilder { 34 | public URL createJarFor(File f, Class... classesToInclude) throws IOException { 35 | try (FileOutputStream fout = new FileOutputStream(f); 36 | JarOutputStream jarOut = new JarOutputStream(fout)) { 37 | for (Class target : classesToInclude) { 38 | String fileName = target.getName().replace(".", "/") + ".class"; 39 | jarOut.putNextEntry(new ZipEntry(fileName)); 40 | jarOut.write(classCompiledBytes(fileName)); 41 | jarOut.closeEntry(); 42 | } 43 | } 44 | return f.toURI().toURL(); 45 | } 46 | 47 | private byte[] classCompiledBytes(String fileName) throws IOException { 48 | try (InputStream in = getClass().getClassLoader().getResourceAsStream(fileName)) { 49 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 50 | while (in.available() > 0) { 51 | out.write(in.read()); 52 | } 53 | 54 | return out.toByteArray(); 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /embedded-examples/src/test/java/org/neo4j/examples/AbstractJavaDocTestBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import static org.neo4j.doc.test.GraphDatabaseServiceCleaner.cleanDatabaseContent; 22 | 23 | import java.util.Map; 24 | import org.junit.jupiter.api.AfterEach; 25 | import org.junit.jupiter.api.BeforeEach; 26 | import org.junit.jupiter.api.extension.ExtendWith; 27 | import org.junit.jupiter.api.extension.RegisterExtension; 28 | import org.neo4j.cypher.docgen.tooling.CypherPrettifier; 29 | import org.neo4j.doc.test.GraphDescription; 30 | import org.neo4j.doc.test.TestData; 31 | import org.neo4j.doc.tools.JavaTestDocsGenerator; 32 | import org.neo4j.graphdb.GraphDatabaseService; 33 | import org.neo4j.graphdb.Node; 34 | import org.neo4j.harness.junit.extension.Neo4jExtension; 35 | import org.neo4j.visualization.asciidoc.AsciidocHelper; 36 | 37 | @ExtendWith(Neo4jExtension.class) 38 | public abstract class AbstractJavaDocTestBase { 39 | @RegisterExtension 40 | final TestData gen = TestData.producedThrough(JavaTestDocsGenerator.PRODUCER); 41 | @RegisterExtension 42 | final TestData> data = TestData.producedThrough(GraphDescription.createGraphFor()); 43 | 44 | protected String createCypherSnippet(String cypherQuery) { 45 | String snippet = CypherPrettifier.apply(cypherQuery); 46 | return AsciidocHelper.createAsciiDocSnippet("cypher", snippet); 47 | } 48 | 49 | @BeforeEach 50 | public void setUp(GraphDatabaseService graphDb) { 51 | cleanDatabaseContent(graphDb); 52 | gen.setGraphDatabaseService(graphDb); 53 | data.setGraphDatabaseService(graphDb); 54 | 55 | gen.get().setGraph(graphDb); 56 | } 57 | 58 | @AfterEach 59 | public void doc() { 60 | gen.get().document("target/docs/dev", "examples"); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /embedded-examples/src/test/java/org/neo4j/examples/CalculateShortestPathTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import java.io.IOException; 22 | import org.junit.jupiter.api.Test; 23 | 24 | class CalculateShortestPathTest { 25 | @Test 26 | void testMain() throws IOException { 27 | CalculateShortestPath.main(null); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /embedded-examples/src/test/java/org/neo4j/examples/CustomAnalyzerProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import static org.junit.jupiter.api.Assertions.assertNotNull; 22 | 23 | import org.junit.jupiter.api.Test; 24 | 25 | class CustomAnalyzerProviderTest { 26 | @Test 27 | void creatingCustomAnalyzer() { 28 | AnalyzerProviderExample example = new AnalyzerProviderExample(); 29 | AnalyzerProviderExample.CustomAnalyzerProvider provider = example.new CustomAnalyzerProvider(); 30 | assertNotNull(provider.createAnalyzer()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /embedded-examples/src/test/java/org/neo4j/examples/EmbeddedNeo4JWithIndexingDocTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import java.io.IOException; 22 | import org.junit.jupiter.api.Test; 23 | 24 | class EmbeddedNeo4JWithIndexingDocTest { 25 | @Test 26 | void justExecuteIt() throws IOException { 27 | EmbeddedNeo4jWithIndexing.main(null); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /embedded-examples/src/test/java/org/neo4j/examples/EmbeddedNeo4jDocTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import static org.junit.jupiter.api.Assertions.assertFalse; 22 | 23 | import java.io.IOException; 24 | import org.junit.jupiter.api.BeforeAll; 25 | import org.junit.jupiter.api.Test; 26 | import org.neo4j.doc.tools.JavaDocsGenerator; 27 | import org.neo4j.visualization.asciidoc.AsciidocHelper; 28 | 29 | public class EmbeddedNeo4jDocTest { 30 | private static EmbeddedNeo4j hello; 31 | private static JavaDocsGenerator gen; 32 | 33 | @BeforeAll 34 | public static void setUpBeforeClass() throws Exception { 35 | hello = new EmbeddedNeo4j(); 36 | gen = new JavaDocsGenerator("hello-world-java", "dev"); 37 | } 38 | 39 | @Test 40 | public void test() throws IOException { 41 | hello.createDb(); 42 | String graph = AsciidocHelper.createGraphVizDeletingReferenceNode( 43 | "Hello World Graph", 44 | hello.graphDb, "java"); 45 | assertFalse(graph.isEmpty()); 46 | gen.saveToFile("graph", graph); 47 | 48 | assertFalse(hello.greeting.isEmpty()); 49 | gen.saveToFile("output", hello.greeting + "\n\n"); 50 | 51 | hello.removeData(); 52 | hello.shutDown(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /embedded-examples/src/test/java/org/neo4j/examples/EmbeddedNeo4jWithBoltIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | class EmbeddedNeo4jWithBoltIT { 24 | @Test 25 | void justExecuteIt() throws Throwable { 26 | EmbeddedNeo4jWithBolt.main(null); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /embedded-examples/src/test/java/org/neo4j/examples/MatrixDocTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import static org.junit.jupiter.api.Assertions.assertTrue; 22 | import static org.neo4j.visualization.asciidoc.AsciidocHelper.createOutputSnippet; 23 | 24 | import org.junit.jupiter.api.BeforeAll; 25 | import org.junit.jupiter.api.Test; 26 | import org.neo4j.doc.tools.JavaDocsGenerator; 27 | 28 | public class MatrixDocTest { 29 | private static JavaDocsGenerator gen; 30 | 31 | @BeforeAll 32 | public static void setUpBeforeClass() { 33 | gen = new JavaDocsGenerator("matrix-traversal-java", "dev"); 34 | } 35 | 36 | @Test 37 | void newMatrix() throws Exception { 38 | NewMatrix newMatrix = new NewMatrix(); 39 | newMatrix.setUp(); 40 | String friends = newMatrix.printNeoFriends(); 41 | String hackers = newMatrix.printMatrixHackers(); 42 | newMatrix.shutdown(); 43 | check(friends, hackers); 44 | gen.saveToFile("new-friends", createOutputSnippet(friends)); 45 | gen.saveToFile("new-hackers", createOutputSnippet(hackers)); 46 | } 47 | 48 | private void check(String friends, String hackers) { 49 | assertTrue(friends.contains("friends found: 4")); 50 | assertTrue(friends.contains("Trinity")); 51 | assertTrue(friends.contains("Morpheus")); 52 | assertTrue(friends.contains("Cypher")); 53 | assertTrue(friends.contains("Agent Smith")); 54 | assertTrue(hackers.contains("hackers found: 1")); 55 | assertTrue(hackers.contains("The Architect")); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /embedded-examples/src/test/java/org/neo4j/examples/TerminateTransactionsDocTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Neo4j under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Neo4j licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.neo4j.examples; 20 | 21 | import static org.neo4j.visualization.asciidoc.AsciidocHelper.createOutputSnippet; 22 | 23 | import java.io.IOException; 24 | import org.junit.jupiter.api.BeforeAll; 25 | import org.junit.jupiter.api.Test; 26 | import org.neo4j.doc.tools.JavaDocsGenerator; 27 | 28 | public class TerminateTransactionsDocTest { 29 | private static TerminateTransactions terminateTransactions; 30 | private static final JavaDocsGenerator gen = new JavaDocsGenerator("terminate-tx-java", "dev"); 31 | 32 | @BeforeAll 33 | public static void setUpBeforeClass() { 34 | terminateTransactions = new TerminateTransactions(); 35 | } 36 | 37 | @Test 38 | void test() throws IOException { 39 | String result = terminateTransactions.run(); 40 | gen.saveToFile("result", createOutputSnippet(result)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /embedded-examples/src/test/resources/neo4j.conf: -------------------------------------------------------------------------------- 1 | 2 | # Enable this to be able to upgrade a store from an older version. 3 | #dbms.allow_format_migration=true 4 | 5 | # The amount of memory to use for mapping the store files, in bytes (or 6 | # kilobytes with the 'k' suffix, megabytes with 'm' and gigabytes with 'g'). 7 | # If Neo4j is running on a dedicated server, then it is generally recommended 8 | # to leave about 2-4 gigabytes for the operating system, give the JVM enough 9 | # heap to hold all your transaction state and query context, and then leave the 10 | # rest for the page cache. 11 | # The default page cache memory assumes the machine is dedicated to running 12 | # Neo4j, and is heuristically set to 50% of RAM minus the max Java heap size. 13 | #dbms.memory.pagecache.size=10g 14 | 15 | # Keep logical logs, helps debugging but uses more disk space, enabled for 16 | # legacy reasons To limit space needed to store historical logs use values such 17 | # as: "7 days" or "100M size" instead of "true". 18 | dbms.tx_log.rotation.retention_policy=true 19 | 20 | # Enable shell server so that remote clients can connect via Neo4j shell. 21 | #dbms.shell.enabled=true 22 | # The network interface IP the shell will listen on (use 0.0.0.0 for all interfaces). 23 | #dbms.shell.host=127.0.0.1 24 | # The port the shell will listen on, default is 1337. 25 | #dbms.shell.port=1337 26 | -------------------------------------------------------------------------------- /embedded-examples/src/test/resources/stopwords.txt: -------------------------------------------------------------------------------- 1 | this 2 | file 3 | is 4 | used 5 | in 6 | the 7 | CustomAnalyzerProviderTest 8 | -------------------------------------------------------------------------------- /functions/src/main/java/org/neo4j/doc/GenerateFunctionDescriptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j Enterprise Edition. The included source 6 | * code can be redistributed and/or modified under the terms of the 7 | * GNU AFFERO GENERAL PUBLIC LICENSE Version 3 8 | * (http://www.fsf.org/licensing/licenses/agpl-3.0.html) with the 9 | * Commons Clause, as found in the associated LICENSE.txt file. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * Neo4j object code can be licensed independently from the source 17 | * under separate terms from the AGPL. Inquiries can be directed to: 18 | * licensing@neo4j.com 19 | * 20 | * More information is also available at: 21 | * https://neo4j.com/licensing/ 22 | */ 23 | package org.neo4j.doc; 24 | 25 | import java.io.IOException; 26 | import java.nio.file.Files; 27 | import java.nio.file.NoSuchFileException; 28 | import java.nio.file.Path; 29 | import java.nio.file.Paths; 30 | import java.util.List; 31 | import java.util.NoSuchElementException; 32 | import org.neo4j.internal.helpers.Args; 33 | 34 | public class GenerateFunctionDescriptions { 35 | 36 | public static void main(String[] args) throws IOException { 37 | Args arguments = Args.parse(args); 38 | printUsage(); 39 | 40 | List orphans = arguments.orphans(); 41 | Path outFile = orphans.size() == 1 ? Paths.get(orphans.get(0)) : null; 42 | 43 | try { 44 | String doc = new FunctionDescriptionsGenerator().document(); 45 | if (null != outFile) { 46 | Path parentDir = outFile.getParent(); 47 | if (!Files.exists(parentDir)) { 48 | Files.createDirectories(parentDir); 49 | } 50 | System.out.println("Saving docs in '" + outFile.toFile().getAbsolutePath() + "'."); 51 | Files.write(outFile, doc.getBytes()); 52 | } 53 | else { 54 | System.out.println(doc); 55 | } 56 | } 57 | catch (NoSuchElementException | NoSuchFileException e) { 58 | e.printStackTrace(); 59 | throw e; 60 | } 61 | } 62 | 63 | private static void printUsage() { 64 | System.out.printf("Usage: FunctionReferenceTool %n"); 65 | System.out.printf(" If no is given prints to stdout.%n"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /graphviz/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ 3 | .project 4 | .classpath 5 | .settings 6 | -------------------------------------------------------------------------------- /graphviz/README.rst: -------------------------------------------------------------------------------- 1 | Neo4j graphviz visualization 2 | ============================ 3 | 4 | A library for visualizing a Neo4j graph database using graphviz. 5 | 6 | Also includes a tool for visualizing an entire graph database. 7 | 8 | 9 | ## Command-line interface 10 | 11 | Run `./graphviz --help` for information on use. 12 | -------------------------------------------------------------------------------- /graphviz/src/main/java/org/neo4j/visualization/GraphRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.visualization; 21 | 22 | import org.neo4j.graphdb.Node; 23 | import org.neo4j.graphdb.Relationship; 24 | 25 | /** 26 | * @param A base exception type that can be thrown by the methods of this renderer. 27 | */ 28 | public interface GraphRenderer { 29 | /** 30 | * Renders a node. 31 | * 32 | * @param node the node to render. 33 | * @return an object capable of rendering the properties of the node, or 34 | * null to not render properties externally. 35 | * @throws E if an error occurs when rendering the node. 36 | */ 37 | PropertyRenderer renderNode(Node node) throws E; 38 | 39 | /** 40 | * Renders a relationship. 41 | * 42 | * @param relationship the relationship to render. 43 | * @return an object capable of rendering the properties of the relationship, or null to not render properties externally. 44 | * @throws E if an error occurs when rendering the relationship. 45 | */ 46 | PropertyRenderer renderRelationship(Relationship relationship) 47 | throws E; 48 | 49 | /** 50 | * Invoked when the entire graph has been rendered. 51 | * 52 | * @throws E if an error occurs. 53 | */ 54 | void done() throws E; 55 | 56 | GraphRenderer renderSubgraph(String name) throws E; 57 | } 58 | -------------------------------------------------------------------------------- /graphviz/src/main/java/org/neo4j/visualization/PropertyRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.visualization; 21 | 22 | /** 23 | * The {@link PropertyRenderer} is responsible for rendering the properties of a node or relationship. 24 | * 25 | * @param A base exception type that can be thrown by the methods of this renderer. 26 | */ 27 | public interface PropertyRenderer { 28 | /** 29 | * Renders a property. 30 | * 31 | * @param propertyKey the key of the property. 32 | * @param propertyValue the value of the property. 33 | * @throws E if an error occurs when rendering the property. 34 | */ 35 | void renderProperty(String propertyKey, Object propertyValue) throws E; 36 | 37 | /** 38 | * Invoked when all properties have been rendered. 39 | * 40 | * @throws E if an error occurs. 41 | */ 42 | void done() throws E; 43 | } 44 | -------------------------------------------------------------------------------- /graphviz/src/main/java/org/neo4j/visualization/graphviz/AsciiDocStyle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.visualization.graphviz; 21 | 22 | import java.io.IOException; 23 | import org.neo4j.visualization.graphviz.StyleParameter.Simple; 24 | import org.neo4j.visualization.graphviz.color.AutoRelationshipTypeColor; 25 | 26 | public class AsciiDocStyle extends GraphStyle { 27 | static final Simple SIMPLE_PROPERTY_STYLE = StyleParameter.Simple.PROPERTY_AS_KEY_EQUALS_VALUE; 28 | static final DefaultStyleConfiguration PLAIN_STYLE = new DefaultStyleConfiguration( 29 | SIMPLE_PROPERTY_STYLE); 30 | 31 | public AsciiDocStyle() { 32 | super(); 33 | } 34 | 35 | AsciiDocStyle(StyleParameter... parameters) { 36 | super(parameters); 37 | } 38 | 39 | public AsciiDocStyle(NodeStyle nodeStyle, RelationshipStyle edgeStyle) { 40 | super(nodeStyle, edgeStyle); 41 | } 42 | 43 | @Override 44 | protected void emitGraphStart(Appendable stream) throws IOException { 45 | } 46 | 47 | @Override 48 | protected void emitGraphEnd(Appendable stream) throws IOException { 49 | } 50 | 51 | public static AsciiDocStyle withAutomaticRelationshipTypeColors() { 52 | return new AsciiDocStyle(new DefaultNodeStyle(PLAIN_STYLE), 53 | new DefaultRelationshipStyle(new DefaultStyleConfiguration( 54 | AsciiDocStyle.SIMPLE_PROPERTY_STYLE, 55 | new AutoRelationshipTypeColor()))); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /graphviz/src/main/java/org/neo4j/visualization/graphviz/DefaultNodeStyle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) "Neo4j" 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Neo4j is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package org.neo4j.visualization.graphviz; 21 | 22 | import java.io.IOException; 23 | import java.util.Iterator; 24 | import org.neo4j.graphdb.Label; 25 | import org.neo4j.graphdb.Node; 26 | import org.neo4j.visualization.PropertyType; 27 | 28 | class DefaultNodeStyle implements NodeStyle { 29 | protected final DefaultStyleConfiguration config; 30 | 31 | DefaultNodeStyle(DefaultStyleConfiguration configuration) { 32 | this.config = configuration; 33 | } 34 | 35 | @Override 36 | public void emitNodeStart(Appendable stream, Node node) 37 | throws IOException { 38 | stream.append(" N").append(String.valueOf(node.getId())).append(" [\n"); 39 | config.emit(node, stream); 40 | stream.append(" label = \"{").append(config.escapeLabel(config.getTitle(node))); 41 | Iterator