Skip to content

Commit 2a012ae

Browse files
committed
[NOID] changes after rebase
1 parent 719f1b3 commit 2a012ae

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

common/src/main/java/apoc/export/util/BatchTransaction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public void increment() {
3232
public void rollback() {
3333
tx.rollback();
3434
}
35-
36-
private void doCommit() {
35+
36+
public void doCommit() {
3737
tx.commit();
3838
tx.close();
3939
if (reporter!=null) reporter.progress("commit after " + count + " row(s) ");

core/src/main/java/apoc/export/csv/CsvEntityLoader.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void loadNodes(final Object fileName, final List<String> labels, final Gr
141141
btx.increment();
142142
reporter.update(1, 0, props++);
143143
});
144-
btx.commit();
144+
btx.doCommit();
145145
} catch (RuntimeException e) {
146146
btx.rollback();
147147
throw e;
@@ -192,11 +192,11 @@ public void loadRelationships(
192192
try (final var csv = new CSVReaderBuilder(reader).withCSVParser(parser).build()) {
193193
final String[] loadCsvCompatibleHeader = fields.stream().map(f -> f.getName()).toArray(String[]::new);
194194

195-
AtomicInteger lineNo = new AtomicInteger();
196-
BatchTransaction btx = new BatchTransaction(db, clc.getBatchSize(), reporter);
197-
try {
198-
csv.forEach(line -> {
199-
lineNo.getAndIncrement();
195+
AtomicInteger lineNo = new AtomicInteger();
196+
BatchTransaction btx = new BatchTransaction(db, clc.getBatchSize(), reporter);
197+
try {
198+
csv.forEach(line -> {
199+
lineNo.getAndIncrement();
200200

201201
final EnumSet<Results> results = EnumSet.of(Results.map);
202202
final CSVResult result = new CSVResult(
@@ -226,23 +226,24 @@ public void loadRelationships(
226226
}
227227
final Relationship rel = source.createRelationshipTo(target, RelationshipType.withName(currentType));
228228

229-
// add properties
230-
int props = 0;
231-
for (CsvHeaderField field : edgePropertiesFields) {
232-
final String name = field.getName();
233-
Object value = result.map.get(name);
234-
boolean propertyAdded = CsvPropertyConverter.addPropertyToGraphEntity(rel, field, value, clc);
235-
props += propertyAdded ? 1 : 0;
236-
}
237-
btx.increment();
238-
reporter.update(0, 1, props);
239-
});
240-
btx.commit();
241-
} catch (RuntimeException e) {
242-
btx.rollback();
243-
throw e;
244-
} finally {
245-
btx.close();
229+
// add properties
230+
int props = 0;
231+
for (CsvHeaderField field : edgePropertiesFields) {
232+
final String name = field.getName();
233+
Object value = result.map.get(name);
234+
boolean propertyAdded = CsvPropertyConverter.addPropertyToGraphEntity(rel, field, value, clc);
235+
props += propertyAdded ? 1 : 0;
236+
}
237+
btx.increment();
238+
reporter.update(0, 1, props);
239+
});
240+
btx.doCommit();
241+
} catch (RuntimeException e) {
242+
btx.rollback();
243+
throw e;
244+
} finally {
245+
btx.close();
246+
}
246247
}
247248
}
248249
}

core/src/main/java/apoc/export/graphml/XmlGraphMLReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public long parseXML(Reader input) throws XMLStreamException {
291291
}
292292
}
293293
}
294-
tx.commit();
294+
tx.doCommit();
295295
} catch (Exception e) {
296296
tx.rollback();
297297
throw e;

core/src/test/java/apoc/export/csv/ImportCsvTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public void issue2826WithImportCsv() {
245245
(r) -> fail());
246246
} catch (RuntimeException e) {
247247
String expected = "Failed to invoke procedure `apoc.import.csv`: " +
248-
"Caused by: IndexEntryConflictException{propertyValues=( String(\"John\") ), addedNodeId=-1, existingNodeId=0}";
248+
"Caused by: IndexEntryConflictException{propertyValues=( String(\"John\") ), addedEntityId=-1, existingEntityId=0}";
249249
assertEquals(expected, e.getMessage());
250250
}
251251

0 commit comments

Comments
 (0)