Skip to content

Commit

Permalink
[q3KTZ83O] Remove strange clean up method (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
gem-neo4j authored Oct 27, 2023
1 parent 3e809d9 commit 388d5cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
11 changes: 2 additions & 9 deletions core/src/main/java/apoc/export/csv/CsvFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private void writeNodesBulkImport(Reporter reporter, ExportConfig config, Export
return joinLabels(entrySet.getKey(), config.getArrayDelim());
}
String prop = s.split(":")[0];
return "".equals(prop) ? String.valueOf(getNodeId(tx, n.getElementId())) : cleanPoint(FormatUtils.toString(n.getProperty(prop, "")));
return prop.isEmpty() ? String.valueOf(getNodeId(tx, n.getElementId())) : FormatUtils.toString(n.getProperty(prop, ""));
}).collect(Collectors.toList());
})
.collect(Collectors.toList());
Expand Down Expand Up @@ -224,7 +224,7 @@ private void writeRelsBulkImport(Reporter reporter, ExportConfig config, ExportF
return entrySet.getKey().name();
default:
String prop = s.split(":")[0];
return "".equals(prop) ? String.valueOf(getRelationshipId(tx, r.getElementId())) : cleanPoint(FormatUtils.toString(r.getProperty(prop, "")));
return prop.isEmpty() ? String.valueOf(getRelationshipId(tx, r.getElementId())) : FormatUtils.toString(r.getProperty(prop, ""));
}
}).collect(Collectors.toList());
})
Expand All @@ -233,13 +233,6 @@ private void writeRelsBulkImport(Reporter reporter, ExportConfig config, ExportF
});
}

private String cleanPoint(String point) {
point = point.replace(",\"z\":null", "");
point = point.replace(",\"heigth\":null", "");
point = point.replace("\"", "");
return point;
}

private Set<String> generateHeaderNodeBulkImport(Map.Entry<Iterable<Label>, List<Node>> entrySet) {
Set<String> headerNode = new LinkedHashSet<>();
headerNode.add(":ID");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class ExportCsvNeo4jAdminTest {
.format(":ID;born_2D:point;born_3D:point;localtime:localtime;time:time;dateTime:datetime;localDateTime:localdatetime;date:date;duration:duration;:LABEL%n");

private static final String EXPECTED_NEO4J_ADMIN_IMPORT_TYPES_NODE = String
.format("6;{crs:cartesian,x:2.3,y:4.5};{crs:wgs-84-3d,latitude:12.78,longitude:56.7,height:100.0};12:50:35.556;12:50:35.556+01:00;2018-10-30T12:50:35.556+01:00;2018-10-30T19:32:24;2018-10-30;P5M1DT12H;Types%n");
.format("6;\"{\"\"crs\"\":\"\"cartesian\"\",\"\"x\"\":2.3,\"\"y\"\":4.5,\"\"z\"\":null}\";\"{\"\"crs\"\":\"\"wgs-84-3d\"\",\"\"latitude\"\":12.78,\"\"longitude\"\":56.7,\"\"height\"\":100.0}\";12:50:35.556;12:50:35.556+01:00;2018-10-30T12:50:35.556+01:00;2018-10-30T19:32:24;2018-10-30;P5M1DT12H;Types%n");

private static final String EXPECTED_NEO4J_ADMIN_IMPORT_HEADER_NODE_ADDRESS = String
.format(":ID;name;street;:LABEL%n");
Expand Down Expand Up @@ -87,7 +87,7 @@ public class ExportCsvNeo4jAdminTest {
"2;;12;User%n");

private static final String EXPECTED_NEO4J_ADMIN_IMPORT_NODE_USER1 = String
.format("0;foo;42;true;[a,b,c];\"User1;User\"%n");
.format("0;\"foo \"\"the\"\" bar\";42;true;\"[\"\"a\"\",\"\"b\"\",\"\"c\"\"]\";\"User1;User\"%n");

private static final String EXPECTED_NEO4J_ADMIN_IMPORT_RELATIONSHIP_KNOWS = String
.format("0;1;KNOWS%n");
Expand All @@ -111,7 +111,7 @@ public class ExportCsvNeo4jAdminTest {
public void before() {
apocConfig().setProperty(APOC_EXPORT_FILE_ENABLED, true);
TestUtil.registerProcedure(db, ExportCSV.class, Graphs.class);
db.executeTransactionally("CREATE (f:User1:User {name:'foo',age:42,male:true,kids:['a','b','c']})-[:KNOWS]->(b:User {name:'bar',age:42}),(c:User {age:12})");
db.executeTransactionally("CREATE (f:User1:User {name:'foo \"the\" bar',age:42,male:true,kids:['a','b','c']})-[:KNOWS]->(b:User {name:'bar',age:42}),(c:User {age:12})");
db.executeTransactionally("CREATE (f:Address1:Address {name:'Andrea', city: 'Milano', street:'Via Garibaldi, 7'})-[:NEXT_DELIVERY]->(a:Address {name: 'Bar Sport'}), (b:Address {street: 'via Benni'})");
db.executeTransactionally("CREATE (a:Types {date: date('2018-10-30'), localDateTime: localdatetime('20181030T19:32:24'), dateTime: datetime('2018-10-30T12:50:35.556+0100'), localtime: localtime('12:50:35.556'), duration: duration('P5M1DT12H'), time: time('125035.556+0100'), born_2D: point({ x: 2.3, y: 4.5 }), born_3D:point({ longitude: 56.7, latitude: 12.78, height: 100 })})");
}
Expand Down

0 comments on commit 388d5cf

Please sign in to comment.