From 06bbe86132fdabd4c9dfef9add7ed00100e1493f Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Wed, 22 Dec 2010 17:23:31 +0000 Subject: [PATCH] LMS-1947 Keep the lines in the order they were provided. SVN: 19215 --- .../SampleAndDataSetControlFileProcessor.java | 12 ++++++++++-- .../SampleAndDatasetRegistrationHandlerTest.java | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDataSetControlFileProcessor.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDataSetControlFileProcessor.java index 5f43a13b669..48b3bae41ee 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDataSetControlFileProcessor.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDataSetControlFileProcessor.java @@ -52,12 +52,18 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce private final File controlFile; + // Keep the errors as a map and array list for fast access and correct ordering private final HashMap<SampleDataSetPair, IRegistrationStatus> errorMap = new HashMap<SampleDataSetPair, IRegistrationStatus>(); + private final ArrayList<SampleDataSetPair> errorPairs = new ArrayList<SampleDataSetPair>(); + + // Keep the successes as a map and array list for fast access and correct ordering private final HashMap<SampleDataSetPair, IRegistrationStatus> successMap = new HashMap<SampleDataSetPair, IRegistrationStatus>(); + private final ArrayList<SampleDataSetPair> successPairs = new ArrayList<SampleDataSetPair>(); + private final HashSet<File> processedDataSetFiles = new HashSet<File>(); // State that is filled out as a result of processing @@ -293,9 +299,11 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce if (result.isError()) { errorMap.put(sampleDataSet, result); + errorPairs.add(sampleDataSet); } else { successMap.put(sampleDataSet, result); + successPairs.add(sampleDataSet); } } @@ -348,7 +356,7 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce StringBuilder sb = new StringBuilder(); sb.append("Encountered errors in the following lines:\n"); - for (SampleDataSetPair pair : errorMap.keySet()) + for (SampleDataSetPair pair : errorPairs) { IRegistrationStatus error = errorMap.get(pair); sb.append("# "); @@ -410,7 +418,7 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce StringBuilder sb = new StringBuilder(); sb.append("The following lines were successfully registered:\n"); - for (SampleDataSetPair pair : successMap.keySet()) + for (SampleDataSetPair pair : successPairs) { sb.append("# "); String[] tokens = pair.getTokens(); diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDatasetRegistrationHandlerTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDatasetRegistrationHandlerTest.java index 305ce74230f..4cd4cf9f2e7 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDatasetRegistrationHandlerTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDatasetRegistrationHandlerTest.java @@ -127,8 +127,8 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT + "# Illegal empty identifier\n" + "\t/MYSPACE/MYPROJ/EXP2\tVAL11\tVAL21\tVAL31\tFILE_TYPE\tVAL41\tVAL51\tds2/\n\n" + "The following lines were successfully registered:\n" - + "# /MYSPACE/S3\t/MYSPACE/MYPROJ/EXP3\tVAL12\tVAL22\tVAL32\tFILE_TYPE\tVAL42\tVAL52\tds3/\n" - + "# /MYSPACE/S1\t/MYSPACE/MYPROJ/EXP1\tVAL10\tVAL20\tVAL30\tFILE_TYPE\tVAL40\tVAL50\tds1/\n"; + + "# /MYSPACE/S1\t/MYSPACE/MYPROJ/EXP1\tVAL10\tVAL20\tVAL30\tFILE_TYPE\tVAL40\tVAL50\tds1/\n" + + "# /MYSPACE/S3\t/MYSPACE/MYPROJ/EXP3\tVAL12\tVAL22\tVAL32\tFILE_TYPE\tVAL42\tVAL52\tds3/\n"; checkAppenderContent(logText, folderName); context.assertIsSatisfied(); -- GitLab