Skip to content

Commit

Permalink
Incorporate yaml deps into main jar (neo4j-contrib#4098) (neo4j-contr…
Browse files Browse the repository at this point in the history
…ib#4099)

* Incorporate yaml deps into main jar (neo4j-contrib#4098)

* Removed unused import
  • Loading branch information
vga91 authored and gmarcostam committed Jul 3, 2024
1 parent ac2446c commit 96ad6af
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 343 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ apoc.convert.fromYaml(value :: STRING, config = {} :: MAP) :: ANY
== Config parameters
include::partial$usage/config/apoc.convert.fromYaml.adoc[]

[[yaml-dependencies]]
=== Install dependencies
Note that to use this function, you have to install additional dependencies
which can be downloaded https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/{apoc-release}/apoc-yaml-dependencies-{apoc-release}-all.jar[from this link].


[[usage-apoc.convert.fromYaml]]
== Usage Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ apoc.convert.toYaml(value :: ANY, config = {} :: MAP) :: STRING
== Config parameters
include::partial$usage/config/apoc.convert.toYaml.adoc[]

[[yaml-dependencies]]
=== Install dependencies
Note that to use this function, you have to install additional dependencies
which can be downloaded https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/{apoc-release}/apoc-yaml-dependencies-{apoc-release}-all.jar[from this link].


[[usage-apoc.convert.toYaml]]
== Usage Examples
include::partial$usage/apoc.convert.toYaml.adoc[]
Expand Down
4 changes: 2 additions & 2 deletions extended/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies {
}

def withoutJacksons = {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
}
Expand All @@ -83,6 +84,7 @@ dependencies {
exclude group: 'org.apache.commons', module: 'commons-lang3'
}
implementation group: 'us.fatehi', name: 'schemacrawler', version: '16.20.8'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.17.0', withoutJacksons

// These will be dependencies not packaged with the .jar
// They need to be provided either through the database or in an extra .jar
Expand Down Expand Up @@ -113,11 +115,9 @@ dependencies {
// testImplementation analogous is not needed since is bundled via `test-utils` submodule
compileOnly group: 'org.apache.hadoop', name: 'hadoop-common', version: '3.4.0', withoutServers

compileOnly group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.17.0'
compileOnly group: 'org.apache.arrow', name: 'arrow-vector', version: '13.0.0'
compileOnly group: 'org.apache.arrow', name: 'arrow-memory-netty', version: '13.0.0'

testImplementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.17.0'
testImplementation group: 'org.apache.arrow', name: 'arrow-vector', version: '13.0.0'
testImplementation group: 'org.apache.arrow', name: 'arrow-memory-netty', version: '13.0.0'

Expand Down
18 changes: 3 additions & 15 deletions extended/src/main/java/apoc/convert/ConvertExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import apoc.Extended;
import apoc.meta.Types;
import apoc.util.MissingDependencyException;
import apoc.util.collection.Iterables;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Path;
Expand All @@ -25,20 +24,13 @@

@Extended
public class ConvertExtended {
private static final String YAML_MISSING_DEPS_ERROR = """
Cannot find the Yaml client jar.
Please put the apoc-yaml-dependencies-5.x.x-all.jar into plugin folder.
See the documentation: https://neo4j.com/labs/apoc/5/overview/apoc.convert/apoc.convert.toYaml/#yaml-dependencies""";


@UserFunction("apoc.convert.toYaml")
@Description("apoc.convert.toYaml(value, $config) - Serializes the given value to a YAML string")
public String toYaml(@Name("value") Object value, @Name(value = "config", defaultValue = "{}") Map<String, Object> config) {
Object result = writeYamlResult(value);
try {
return getYamlFactory(result, config);
} catch (NoClassDefFoundError e) {
throw new MissingDependencyException(YAML_MISSING_DEPS_ERROR);
} catch (IOException e) {
throw new RuntimeException("Can't convert " + "value" + " to yaml", e);
}
Expand All @@ -47,13 +39,9 @@ public String toYaml(@Name("value") Object value, @Name(value = "config", defaul
@UserFunction("apoc.convert.fromYaml")
@Description("apoc.convert.fromYaml(value, $config) - Deserializes the YAML string to Neo4j value")
public Object fromYaml(@Name("value") String value, @Name(value = "config", defaultValue = "{}") Map<String, Object> config) throws Exception {
try {
Object parse = parse(value, config);
var mappingConf = (Map<String, Object>) config.getOrDefault(MAPPING_KEY, Map.of());
return toValidYamlValue(parse, null, mappingConf, true);
} catch (NoClassDefFoundError e) {
throw new MissingDependencyException(YAML_MISSING_DEPS_ERROR);
}
Object parse = parse(value, config);
var mappingConf = (Map<String, Object>) config.getOrDefault(MAPPING_KEY, Map.of());
return toValidYamlValue(parse, null, mappingConf, true);
}

/**
Expand Down
1 change: 0 additions & 1 deletion extra-dependencies/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ include('selenium')
include('hadoop')
include('gcs')
include('aws')
include('yaml')
25 changes: 0 additions & 25 deletions extra-dependencies/yaml/build.gradle

This file was deleted.

Binary file not shown.

This file was deleted.

183 changes: 0 additions & 183 deletions extra-dependencies/yaml/gradlew

This file was deleted.

Loading

0 comments on commit 96ad6af

Please sign in to comment.