Bug wrong count bulk upload dialog when runtime exception (#417)
* Fix for the bug by synchronizing the counts based on total target count Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Extended sync function with bulk progress bar set to 100% if runtime exception is thrown Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Changed method parameter to totalNumberOfLines Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com> * Changed parameter type to long Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
committed by
Kai Zimmermann
parent
8288904b1e
commit
59aba08666
@@ -193,11 +193,11 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
|
|
||||||
private void readFileStream(final InputStream tempStream) {
|
private void readFileStream(final InputStream tempStream) {
|
||||||
String line;
|
String line;
|
||||||
|
final long totalNumberOfLines = getTotalNumberOfLines();
|
||||||
try (final BufferedReader reader = new BufferedReader(
|
try (final BufferedReader reader = new BufferedReader(
|
||||||
new InputStreamReader(tempStream, Charset.defaultCharset()))) {
|
new InputStreamReader(tempStream, Charset.defaultCharset()))) {
|
||||||
LOG.info("Bulk file upload started");
|
LOG.info("Bulk file upload started");
|
||||||
long innerCounter = 0;
|
long innerCounter = 0;
|
||||||
final double totalFileSize = getTotalNumberOfLines();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Once control is in upload succeeded method automatically
|
* Once control is in upload succeeded method automatically
|
||||||
@@ -207,7 +207,7 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED));
|
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED));
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
innerCounter++;
|
innerCounter++;
|
||||||
readEachLine(line, innerCounter, totalFileSize);
|
readEachLine(line, innerCounter, totalNumberOfLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
@@ -217,7 +217,7 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
} finally {
|
} finally {
|
||||||
deleteFile();
|
deleteFile();
|
||||||
}
|
}
|
||||||
syncCountAfterUpload();
|
syncCountAfterUpload(totalNumberOfLines);
|
||||||
doAssignments();
|
doAssignments();
|
||||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_COMPLETED));
|
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_COMPLETED));
|
||||||
// Clearing after assignments are done
|
// Clearing after assignments are done
|
||||||
@@ -225,21 +225,21 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
resetCounts();
|
resetCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncCountAfterUpload() {
|
private void syncCountAfterUpload(final long totalNumberOfLines) {
|
||||||
if (managementUIState.getTargetTableFilters().getBulkUpload()
|
if ((successfullTargetCount + failedTargetCount) != totalNumberOfLines) {
|
||||||
.getSucessfulUploadCount() != successfullTargetCount) {
|
// something went wrong due to runtimeexception etc.
|
||||||
|
final long syncedFailedTargetCount = totalNumberOfLines - successfullTargetCount;
|
||||||
managementUIState.getTargetTableFilters().getBulkUpload()
|
managementUIState.getTargetTableFilters().getBulkUpload()
|
||||||
.setSucessfulUploadCount(successfullTargetCount);
|
.setSucessfulUploadCount(successfullTargetCount);
|
||||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
|
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
|
||||||
}
|
managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(syncedFailedTargetCount);
|
||||||
if (managementUIState.getTargetTableFilters().getBulkUpload().getFailedUploadCount() != failedTargetCount) {
|
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(1);
|
||||||
managementUIState.getTargetTableFilters().getBulkUpload().setSucessfulUploadCount(failedTargetCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getTotalNumberOfLines() {
|
private long getTotalNumberOfLines() {
|
||||||
|
|
||||||
double totalFileSize = 0;
|
long totalFileSize = 0;
|
||||||
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(tempFile),
|
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(tempFile),
|
||||||
Charset.defaultCharset())) {
|
Charset.defaultCharset())) {
|
||||||
try (BufferedReader readerForSize = new BufferedReader(inputStreamReader)) {
|
try (BufferedReader readerForSize = new BufferedReader(inputStreamReader)) {
|
||||||
@@ -269,7 +269,7 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
tempFile = null;
|
tempFile = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readEachLine(final String line, final double innerCounter, final double totalFileSize) {
|
private void readEachLine(final String line, final long innerCounter, final long totalNumberOfLines) {
|
||||||
final String csvDelimiter = ",";
|
final String csvDelimiter = ",";
|
||||||
final String[] targets = line.split(csvDelimiter);
|
final String[] targets = line.split(csvDelimiter);
|
||||||
if (targets.length == 2) {
|
if (targets.length == 2) {
|
||||||
@@ -281,7 +281,7 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
}
|
}
|
||||||
final float current = managementUIState.getTargetTableFilters().getBulkUpload()
|
final float current = managementUIState.getTargetTableFilters().getBulkUpload()
|
||||||
.getProgressBarCurrentValue();
|
.getProgressBarCurrentValue();
|
||||||
final float next = (float) (innerCounter / totalFileSize);
|
final float next = innerCounter / totalNumberOfLines;
|
||||||
if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05
|
if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05
|
||||||
|| Math.abs(next - 1) < 0.00001) {
|
|| Math.abs(next - 1) < 0.00001) {
|
||||||
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next);
|
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next);
|
||||||
|
|||||||
Reference in New Issue
Block a user