Don't die if we get passed no candidates
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2210 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
9025a64dd0
commit
9d7b8a5279
@ -79,6 +79,7 @@ public class ExcelImporter extends TabularImportingParserBase {
|
|||||||
JSONArray sheetRecords = new JSONArray();
|
JSONArray sheetRecords = new JSONArray();
|
||||||
JSONUtilities.safePut(options, "sheetRecords", sheetRecords);
|
JSONUtilities.safePut(options, "sheetRecords", sheetRecords);
|
||||||
try {
|
try {
|
||||||
|
if (fileRecords.size() > 0) {
|
||||||
JSONObject firstFileRecord = fileRecords.get(0);
|
JSONObject firstFileRecord = fileRecords.get(0);
|
||||||
File file = ImportingUtilities.getFile(job, firstFileRecord);
|
File file = ImportingUtilities.getFile(job, firstFileRecord);
|
||||||
InputStream is = new FileInputStream(file);
|
InputStream is = new FileInputStream(file);
|
||||||
@ -107,6 +108,7 @@ public class ExcelImporter extends TabularImportingParserBase {
|
|||||||
} finally {
|
} finally {
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class FixedWidthImporter extends TabularImportingParserBase {
|
|||||||
ImportingJob job, List<JSONObject> fileRecords, String format) {
|
ImportingJob job, List<JSONObject> fileRecords, String format) {
|
||||||
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
||||||
JSONArray columnWidths = new JSONArray();
|
JSONArray columnWidths = new JSONArray();
|
||||||
|
if (fileRecords.size() > 0) {
|
||||||
JSONObject firstFileRecord = fileRecords.get(0);
|
JSONObject firstFileRecord = fileRecords.get(0);
|
||||||
String encoding = ImportingUtilities.getEncoding(firstFileRecord);
|
String encoding = ImportingUtilities.getEncoding(firstFileRecord);
|
||||||
String location = JSONUtilities.getString(firstFileRecord, "location", null);
|
String location = JSONUtilities.getString(firstFileRecord, "location", null);
|
||||||
@ -48,7 +48,7 @@ public class FixedWidthImporter extends TabularImportingParserBase {
|
|||||||
JSONUtilities.safePut(options, "headerLines", 0);
|
JSONUtilities.safePut(options, "headerLines", 0);
|
||||||
JSONUtilities.safePut(options, "columnWidths", columnWidths);
|
JSONUtilities.safePut(options, "columnWidths", columnWidths);
|
||||||
JSONUtilities.safePut(options, "guessCellValueTypes", true);
|
JSONUtilities.safePut(options, "guessCellValueTypes", true);
|
||||||
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ public class JsonImporter extends TreeImportingParserBase {
|
|||||||
public JSONObject createParserUIInitializationData(
|
public JSONObject createParserUIInitializationData(
|
||||||
ImportingJob job, List<JSONObject> fileRecords, String format) {
|
ImportingJob job, List<JSONObject> fileRecords, String format) {
|
||||||
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
||||||
|
if (fileRecords.size() > 0) {
|
||||||
try {
|
try {
|
||||||
JSONObject firstFileRecord = fileRecords.get(0);
|
JSONObject firstFileRecord = fileRecords.get(0);
|
||||||
File file = ImportingUtilities.getFile(job, firstFileRecord);
|
File file = ImportingUtilities.getFile(job, firstFileRecord);
|
||||||
@ -94,6 +95,7 @@ public class JsonImporter extends TreeImportingParserBase {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ public class XmlImporter extends TreeImportingParserBase {
|
|||||||
ImportingJob job, List<JSONObject> fileRecords, String format) {
|
ImportingJob job, List<JSONObject> fileRecords, String format) {
|
||||||
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
||||||
try {
|
try {
|
||||||
|
if (fileRecords.size() > 0) {
|
||||||
JSONObject firstFileRecord = fileRecords.get(0);
|
JSONObject firstFileRecord = fileRecords.get(0);
|
||||||
File file = ImportingUtilities.getFile(job, firstFileRecord);
|
File file = ImportingUtilities.getFile(job, firstFileRecord);
|
||||||
InputStream is = new FileInputStream(file);
|
InputStream is = new FileInputStream(file);
|
||||||
@ -96,6 +97,7 @@ public class XmlImporter extends TreeImportingParserBase {
|
|||||||
} finally {
|
} finally {
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (XMLStreamException e) {
|
} catch (XMLStreamException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user