forked from neo4j-contrib/neo4j-apoc-procedures
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…4j-contrib#2374) * Fixes neo4j-contrib#2333: Add systemdb export metadata procedure * added System annotation - formatProperties
- Loading branch information
Showing
28 changed files
with
680 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ public enum SystemPropertyKeys { | |
params, | ||
paused, | ||
|
||
// dv | ||
data, | ||
|
||
// uuid handler | ||
label, | ||
addToSetLabel, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...oc/modules/ROOT/pages/overview/apoc.systemdb/apoc.systemdb.export.metadata.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//// | ||
This file is generated by DocsTest, so don't change it! | ||
//// | ||
|
||
= apoc.systemdb.export.metadata | ||
:description: This section contains reference documentation for the apoc.systemdb.export.metadata procedure. | ||
|
||
label:procedure[] label:apoc-core[] | ||
|
||
== Signature | ||
|
||
[source] | ||
---- | ||
apoc.systemdb.export.metadata(config = {} :: MAP?) :: (file :: STRING?, source :: STRING?, format :: STRING?, nodes :: INTEGER?, relationships :: INTEGER?, properties :: INTEGER?, time :: INTEGER?, rows :: INTEGER?, batchSize :: INTEGER?, batches :: INTEGER?, done :: BOOLEAN?, data :: STRING?) | ||
---- | ||
|
||
== Input parameters | ||
[.procedures, opts=header] | ||
|=== | ||
| Name | Type | Default | ||
|config|MAP?|{} | ||
|=== | ||
|
||
== Config parameters | ||
include::partial$usage/config/apoc.systemdb.export.metadata.adoc[] | ||
|
||
== Output parameters | ||
[.procedures, opts=header] | ||
|=== | ||
| Name | Type | ||
|file|STRING? | ||
|source|STRING? | ||
|format|STRING? | ||
|nodes|INTEGER? | ||
|relationships|INTEGER? | ||
|properties|INTEGER? | ||
|time|INTEGER? | ||
|rows|INTEGER? | ||
|batchSize|INTEGER? | ||
|batches|INTEGER? | ||
|done|BOOLEAN? | ||
|data|STRING? | ||
|=== | ||
|
||
[[usage-apoc.systemdb.export.metadata]] | ||
== Usage Examples | ||
include::partial$usage/apoc.systemdb.export.metadata.adoc[] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
docs/asciidoc/modules/ROOT/partials/usage/apoc.systemdb.export.metadata.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
To use this procedure, we have to enable it by setting the following property in `apoc.conf`: | ||
|
||
.apoc.conf | ||
[source,properties] | ||
---- | ||
apoc.export.file.enabled=true | ||
---- | ||
|
||
|
||
If we execute in a database `neo4j` the following queries: | ||
[source,cypher] | ||
---- | ||
CALL apoc.trigger.add('trig','RETURN $alpha', {phase: 'after'}, {params: {alpha: 1} }); | ||
CALL apoc.trigger.add('trigTwo','RETURN 1', null); | ||
CALL apoc.trigger.pause('trigTwo'); | ||
CALL apoc.custom.declareFunction('funNameOne(val = 2 :: INTEGER) :: NODE ', 'MATCH (t:Target {value : $val}) RETURN t'); | ||
CALL apoc.custom.declareProcedure('procNameOne(one = 2 ::INTEGER?, two = 3 :: INTEGER?) :: (sum :: INTEGER) ', 'RETURN $one + $two as sum'); | ||
CALL apoc.custom.asProcedure('procName','RETURN $input as answer','read',[['answer','number']],[['input','int','42']], 'Procedure that answer to the Ultimate Question of Life, the Universe, and Everything'); | ||
CALL apoc.custom.asFunction('funName','RETURN $input as answer','long', [['input','number']], false); | ||
CREATE CONSTRAINT person_cons ON (p:Person) ASSERT p.alpha IS UNIQUE; | ||
CALL apoc.uuid.install('Person', {addToSetLabels: true, uuidProperty: 'alpha'}); | ||
CALL apoc.dv.catalog.add("dvName", {type: 'CSV', url: 'file://myUrl', query: 'map.name = $name and map.age = $age', desc: "person's details", labels: ['Person']}); | ||
---- | ||
|
||
and in a database `another`: | ||
[source,cypher] | ||
---- | ||
CALL apoc.trigger.add('trigAnother','RETURN 1', null); | ||
---- | ||
|
||
|
||
If we execute: | ||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.systemdb.export.metadata() | ||
---- | ||
|
||
we obtain the following files: | ||
|
||
.metadata.customProcedures.neo4j.cypher | ||
[source,cypher] | ||
---- | ||
CALL apoc.custom.declareFunction('funNameOne(val = 2 :: INTEGER?) :: (NODE?)', 'MATCH (t:Target {value : $val}) RETURN t' , false, ''); | ||
CALL apoc.custom.declareProcedure('procNameOne(one = 2 :: INTEGER?, two = 3 :: INTEGER?) :: (sum :: INTEGER?)', 'RETURN $one + $two as sum' , 'READ', ''); | ||
CALL apoc.custom.declareProcedure('procName(input = 42 :: INTEGER?) :: (answer :: NUMBER?)', 'RETURN $input as answer' , 'READ', 'Procedure that answer to the Ultimate Question of Life, the Universe, and Everything'); | ||
CALL apoc.custom.declareFunction('funName(input :: NUMBER?) :: (INTEGER?)', 'RETURN $input as answer' , false, ''); | ||
---- | ||
|
||
.metadata.dvCatalogs.neo4j.cypher | ||
[source,cypher] | ||
---- | ||
CALL apoc.dv.catalog.add('dvName', {name:"dvName",url:"file://myUrl",desc:"person's details",labels:["Person"],query:"map.name = $name and map.age = $age",params:["$name","$age"],type:"CSV"}); | ||
---- | ||
|
||
.metadata.triggers.neo4j.cypher | ||
[source,cypher] | ||
---- | ||
CALL apoc.trigger.add('trig', 'RETURN $alpha', {phase:"after"},{params: {alpha:1}}); | ||
CALL apoc.trigger.add('trigTwo', 'RETURN 1', null,{params: {}}); | ||
CALL apoc.trigger.pause('trigTwo'); | ||
---- | ||
|
||
.metadata.uuids.neo4j.cypher | ||
[source,cypher] | ||
---- | ||
CALL apoc.uuid.install('Person', {uuidProperty:"alpha",addToSetLabels:true}) YIELD label RETURN label; | ||
CALL apoc.uuid.install('Person', {uuidProperty:"beta",addToSetLabels:null}) YIELD label RETURN label; | ||
---- | ||
|
||
.metadata.uuids.schema.neo4j.cypher | ||
[source,cypher] | ||
---- | ||
CREATE CONSTRAINT IF NOT EXISTS ON (n:Person) ASSERT n.alpha IS UNIQUE; | ||
CREATE CONSTRAINT IF NOT EXISTS ON (n:Person) ASSERT n.beta IS UNIQUE; | ||
---- | ||
|
||
|
||
So that we can import everything in another db, with the `apoc.cypher.run*` procedures: | ||
|
||
.metadata.uuids.schema.neo4j.cypher | ||
[source,cypher] | ||
---- | ||
CALL apoc.cypher.runSchemaFile("metadata.uuids.schema.neo4j.cypher"); | ||
CALL apoc.cypher.runFiles(["metadata.customProcedures.neo4j.cypher", "metadata.dvCatalogs.neo4j.cypher", "metadata.triggers.neo4j.cypher", "metadata.uuids.neo4j.cypher"]) | ||
---- | ||
|
||
|
||
We can choose what we want to export with config parameter `features` (this is a list of strings with possible values "customProcedures", "triggers", "uuids", "dvCatalogs"). | ||
For example with: | ||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.systemdb.export.metadata({features: ["triggers", "uuids"]}) | ||
---- | ||
|
||
will be exported only `metadata.triggers.neo4j.cypher` and `metadata.uuids.neo4j.cypher` files. | ||
|
||
Therefore, we can choose the file name prefix, for example if we want to export files with names `customName.triggers.neo4j.cypher`, etc..., we can do: | ||
|
||
[source,cypher] | ||
---- | ||
CALL apoc.systemdb.export.metadata({filename: "customName"}) | ||
---- |
9 changes: 9 additions & 0 deletions
9
.../asciidoc/modules/ROOT/partials/usage/config/apoc.systemdb.export.metadata.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The procedure support the following config parameters: | ||
|
||
.Config parameters | ||
[opts=header, cols="1,1,1,5"] | ||
|=== | ||
| name | type | default | description | ||
| filename | String | "metadata" | The filename prefix. For example, metadata.customProcedures.dbName.cypher | ||
| features | List<String> | ["CypherProcedure", "CypherFunction", "Uuid", "Trigger", "DataVirtualizationCatalog"] | A list indicating which functions are to be exported. Possible values are "CypherProcedure", "CypherFunction", "Uuid", "Trigger", "DataVirtualizationCatalog". | ||
|=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.