Skip to content
Snippets Groups Projects
Commit 1704171d authored by tpylak's avatar tpylak
Browse files

flexible library import: send error in the email, make sheet names...

flexible library import: send error in the email, make sheet names case-insensitive, minor improvements

SVN: 22956
parent 72a1a335
No related branches found
No related tags found
No related merge requests found
...@@ -112,7 +112,7 @@ public class ExcelFileSection ...@@ -112,7 +112,7 @@ public class ExcelFileSection
List<ExcelFileSection> defaultSheetSections = null; List<ExcelFileSection> defaultSheetSections = null;
Sheet sheet = null; Sheet sheet = null;
String prefix = excelSheetName + "-"; String prefix = excelSheetName;
for (int i = 0; i < wb.getNumberOfSheets(); i++) for (int i = 0; i < wb.getNumberOfSheets(); i++)
{ {
String sheetName = wb.getSheetName(i); String sheetName = wb.getSheetName(i);
...@@ -120,9 +120,9 @@ public class ExcelFileSection ...@@ -120,9 +120,9 @@ public class ExcelFileSection
{ {
sheet = wb.getSheetAt(i); sheet = wb.getSheetAt(i);
defaultSheetSections = extractSectionsFromDefaultSheet(sheet); defaultSheetSections = extractSectionsFromDefaultSheet(sheet);
} else if (sheetName.startsWith(prefix)) } else if (sheetName.toUpperCase().startsWith(prefix.toUpperCase()))
{ {
String sectionName = sheetName.substring(prefix.length()); String sectionName = sheetName.substring(prefix.length() + 1);
sheet = wb.getSheetAt(i); sheet = wb.getSheetAt(i);
if (SECTION_FILE_DEFAULT.equalsIgnoreCase(sectionName)) if (SECTION_FILE_DEFAULT.equalsIgnoreCase(sectionName))
{ {
......
...@@ -111,6 +111,7 @@ public class MaterialUploadSectionsParser ...@@ -111,6 +111,7 @@ public class MaterialUploadSectionsParser
{ {
final String fileName = multipartFile.getOriginalFilename(); final String fileName = multipartFile.getOriginalFilename();
final String loweredFileName = fileName.toLowerCase(); final String loweredFileName = fileName.toLowerCase();
String registrationMessage = "Registration/update of %d material(s) is complete.";
if (loweredFileName.endsWith("xls") || loweredFileName.endsWith("xlsx")) if (loweredFileName.endsWith("xls") || loweredFileName.endsWith("xlsx"))
{ {
List<ExcelFileSection> materialSections = new ArrayList<ExcelFileSection>(); List<ExcelFileSection> materialSections = new ArrayList<ExcelFileSection>();
...@@ -164,7 +165,7 @@ public class MaterialUploadSectionsParser ...@@ -164,7 +165,7 @@ public class MaterialUploadSectionsParser
} }
} }
results.add(new BatchRegistrationResult(fileName, String.format( results.add(new BatchRegistrationResult(fileName, String.format(
"Registration of %d material(s) is complete.", materialCounter))); registrationMessage, materialCounter)));
} else } else
{ {
...@@ -217,7 +218,7 @@ public class MaterialUploadSectionsParser ...@@ -217,7 +218,7 @@ public class MaterialUploadSectionsParser
} }
} }
results.add(new BatchRegistrationResult(fileName, String.format( results.add(new BatchRegistrationResult(fileName, String.format(
"Registration of %d material(s) is complete.", materialCounter))); registrationMessage, materialCounter)));
} }
} }
return results; return results;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package ch.systemsx.cisd.openbis.plugin.generic.server; package ch.systemsx.cisd.openbis.plugin.generic.server;
import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
...@@ -799,13 +800,31 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen ...@@ -799,13 +800,31 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen
{ {
public String getName() public String getName()
{ {
return "General Import"; return "General Batch Import";
} }
public boolean doAction(Writer messageWriter) public boolean doAction(Writer messageWriter)
{ {
genericServer.registerOrUpdateSamplesAndMaterials(sessionToken, try
newSamplesWithType, newMaterialsWithType); {
genericServer.registerOrUpdateSamplesAndMaterials(sessionToken,
newSamplesWithType, newMaterialsWithType);
} catch (RuntimeException ex)
{
try
{
messageWriter.write(getName()
+ " has failed with a following exception: ");
messageWriter.write(ex.getMessage());
messageWriter
.write("\n\nPlease correct the error or contact your administrator.");
} catch (IOException writingEx)
{
throw new UserFailureException(writingEx.getMessage()
+ " when trying to throw exception: " + ex.getMessage(), ex);
}
throw ex;
}
return true; return true;
} }
}); });
......
...@@ -454,7 +454,7 @@ var common = { ...@@ -454,7 +454,7 @@ var common = {
ARCHIVING_MENU_LOCK: "Disable", ARCHIVING_MENU_LOCK: "Disable",
ARCHIVING_MENU_UNLOCK: "Enable", ARCHIVING_MENU_UNLOCK: "Enable",
GENERAL_IMPORT_MENU: "General Import", GENERAL_IMPORT_MENU: "General Batch Import",
menu_modules: "Utilities", menu_modules: "Utilities",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment