Added support for creating a project by pointing to a data file URL.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@1139 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
f411dc9104
commit
3bda9d035d
@ -15,6 +15,9 @@ Features:
|
|||||||
- In CSV and TSV importers, added support for ignoring quotation marks
|
- In CSV and TSV importers, added support for ignoring quotation marks
|
||||||
- Regexp groups capturing GEL function
|
- Regexp groups capturing GEL function
|
||||||
- Text facet's choice count limit is now configurable through preference page
|
- Text facet's choice count limit is now configurable through preference page
|
||||||
|
- Select All and Unselect All buttons in History Extract dialog
|
||||||
|
- Schema skeleton: support for multiple cells per cell-as nodes, and for conditional links
|
||||||
|
- Added support for creating a project by pointing to a data file URL.
|
||||||
|
|
||||||
Fixes:
|
Fixes:
|
||||||
- TSV/CSV exporter bug: Gridworks crashed when there were empty cells.
|
- TSV/CSV exporter bug: Gridworks crashed when there were empty cells.
|
||||||
|
@ -173,7 +173,8 @@ public class CreateProjectCommand extends Command {
|
|||||||
) throws Exception {
|
) throws Exception {
|
||||||
|
|
||||||
ServletFileUpload upload = new ServletFileUpload();
|
ServletFileUpload upload = new ServletFileUpload();
|
||||||
String url = null;
|
String url = options.getProperty("url");
|
||||||
|
boolean imported = false;
|
||||||
|
|
||||||
FileItemIterator iter = upload.getItemIterator(request);
|
FileItemIterator iter = upload.getItemIterator(request);
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
@ -185,25 +186,29 @@ public class CreateProjectCommand extends Command {
|
|||||||
Reader reader = new InputStreamReader(stream,"UTF-8");
|
Reader reader = new InputStreamReader(stream,"UTF-8");
|
||||||
try {
|
try {
|
||||||
internalInvokeImporter(project, new TsvCsvImporter(), options, reader);
|
internalInvokeImporter(project, new TsvCsvImporter(), options, reader);
|
||||||
|
imported = true;
|
||||||
} finally {
|
} finally {
|
||||||
reader.close();
|
reader.close();
|
||||||
}
|
}
|
||||||
} else if (name.equals("url")) {
|
} else if (name.equals("project-url")) {
|
||||||
url = Streams.asString(stream);
|
url = Streams.asString(stream);
|
||||||
} else {
|
} else {
|
||||||
options.put(name, Streams.asString(stream));
|
options.put(name, Streams.asString(stream));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String fileName = item.getName().toLowerCase();
|
String fileName = item.getName().toLowerCase();
|
||||||
try {
|
if (fileName.length() > 0) {
|
||||||
internalImportFile(project, options, fileName, stream);
|
try {
|
||||||
} finally {
|
internalImportFile(project, options, fileName, stream);
|
||||||
stream.close();
|
imported = true;
|
||||||
|
} finally {
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url != null && url.length() > 0) {
|
if (!imported && url != null && url.length() > 0) {
|
||||||
internalImportURL(request, project, options, url);
|
internalImportURL(request, project, options, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,7 +235,7 @@ public class CreateProjectCommand extends Command {
|
|||||||
protected void internalImportFile(
|
protected void internalImportFile(
|
||||||
Project project,
|
Project project,
|
||||||
Properties options,
|
Properties options,
|
||||||
String fileName,
|
String fileName,
|
||||||
InputStream inputStream
|
InputStream inputStream
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
|
|
||||||
@ -413,7 +418,6 @@ public class CreateProjectCommand extends Command {
|
|||||||
Importer importer = guessUrlImporter(url);
|
Importer importer = guessUrlImporter(url);
|
||||||
if (importer instanceof UrlImporter) {
|
if (importer instanceof UrlImporter) {
|
||||||
((UrlImporter) importer).read(url, project, options);
|
((UrlImporter) importer).read(url, project, options);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
// If we couldn't find one, try opening URL and treating as a stream
|
// If we couldn't find one, try opening URL and treating as a stream
|
||||||
try {
|
try {
|
||||||
@ -432,10 +436,9 @@ public class CreateProjectCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
importer = guessImporter(connection.getContentType(),
|
importer = guessImporter(connection.getContentType(), url.getPath());
|
||||||
url.getPath());
|
|
||||||
internalInvokeImporter(project, importer, options, inputStream,
|
internalInvokeImporter(project, importer, options, inputStream, connection.getContentEncoding());
|
||||||
connection.getContentEncoding());
|
|
||||||
} finally {
|
} finally {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class ImporterUtilities {
|
|||||||
if (options.containsKey(name)) {
|
if (options.containsKey(name)) {
|
||||||
String s = options.getProperty(name);
|
String s = options.getProperty(name);
|
||||||
try {
|
try {
|
||||||
value = Boolean.parseBoolean(s);
|
value = s.equalsIgnoreCase("on") || s.equals("1") || Boolean.parseBoolean(s);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class TsvCsvImporter implements ReaderImporter,StreamImporter {
|
|||||||
@Override
|
@Override
|
||||||
public void read(Reader reader, Project project, Properties options) throws ImportException {
|
public void read(Reader reader, Project project, Properties options) throws ImportException {
|
||||||
boolean splitIntoColumns = ImporterUtilities.getBooleanOption("split-into-columns", options, true);
|
boolean splitIntoColumns = ImporterUtilities.getBooleanOption("split-into-columns", options, true);
|
||||||
|
|
||||||
String sep = options.getProperty("separator"); // auto-detect if not present
|
String sep = options.getProperty("separator"); // auto-detect if not present
|
||||||
int ignoreLines = ImporterUtilities.getIntegerOption("ignore", options, -1);
|
int ignoreLines = ImporterUtilities.getIntegerOption("ignore", options, -1);
|
||||||
int headerLines = ImporterUtilities.getIntegerOption("header-lines", options, 1);
|
int headerLines = ImporterUtilities.getIntegerOption("header-lines", options, 1);
|
||||||
|
@ -31,7 +31,6 @@ public class ParsingUtilities {
|
|||||||
if (query.startsWith("?")) {
|
if (query.startsWith("?")) {
|
||||||
query = query.substring(1);
|
query = query.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseParameters(options,query);
|
parseParameters(options,query);
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
|
@ -64,6 +64,9 @@
|
|||||||
<tr><td><span class="field-label">Data File</span>:</td>
|
<tr><td><span class="field-label">Data File</span>:</td>
|
||||||
<td><input type="file" id="project-file-input" name="project-file" /></td>
|
<td><input type="file" id="project-file-input" name="project-file" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr><td><span class="field-label">Or Data File URL</span>:</td>
|
||||||
|
<td><input id="project-url-input" name="project-url" size="50" /></td>
|
||||||
|
</tr>
|
||||||
<tr><td><span class="field-label">Project Name</span>:</td>
|
<tr><td><span class="field-label">Project Name</span>:</td>
|
||||||
<td><input type="text" size="30" id="project-name-input" name="project-name" /></td></tr>
|
<td><input type="text" size="30" id="project-name-input" name="project-name" /></td></tr>
|
||||||
<tr><td></td>
|
<tr><td></td>
|
||||||
@ -109,7 +112,7 @@
|
|||||||
|
|
||||||
<div class="field-group">
|
<div class="field-group">
|
||||||
<div><input id="ignore-quotes-input" name="ignore-quotes" type="checkbox" />Ignore Quotation Marks </div>
|
<div><input id="ignore-quotes-input" name="ignore-quotes" type="checkbox" />Ignore Quotation Marks </div>
|
||||||
<div class="field-hint">Ignore quotation marks, using all newlines and separators</div>
|
<div class="field-hint">Ignore quotation marks,<br/>using all newlines and separators</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
|
@ -1,22 +1,24 @@
|
|||||||
function onClickUploadFileButton(evt) {
|
function onClickUploadFileButton(evt) {
|
||||||
var projectName = $("#project-name-input")[0].value;
|
var projectName = $("#project-name-input")[0].value;
|
||||||
|
var dataURL = $.trim($("#project-url-input")[0].value);
|
||||||
if (! $.trim(projectName).length) {
|
if (! $.trim(projectName).length) {
|
||||||
window.alert("You must specify a project name.");
|
window.alert("You must specify a project name.");
|
||||||
|
|
||||||
} else if ($("#project-file-input")[0].files.length === 0) {
|
} else if ($("#project-file-input")[0].files.length === 0 && ! dataURL.length) {
|
||||||
window.alert("You must specify select a file to upload.");
|
window.alert("You must specify a data file to upload or a URL to retrieve.");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$("#file-upload-form").attr("action",
|
$("#file-upload-form").attr("action",
|
||||||
"/command/create-project-from-upload?" + [
|
"/command/create-project-from-upload?" + [
|
||||||
|
"url=" + escape(dataURL),
|
||||||
"split-into-columns=" + $("#split-into-columns-input")[0].checked,
|
"split-into-columns=" + $("#split-into-columns-input")[0].checked,
|
||||||
"separator=" + $("#separator-input")[0].value,
|
"separator=" + $("#separator-input")[0].value,
|
||||||
"ignore=" + $("#ignore-input")[0].value,
|
"ignore=" + $("#ignore-input")[0].value,
|
||||||
"header-lines=" + $("#header-lines-input")[0].value,
|
"header-lines=" + $("#header-lines-input")[0].value,
|
||||||
"skip=" + $("#skip-input")[0].value,
|
"skip=" + $("#skip-input")[0].value,
|
||||||
"limit=" + $("#limit-input")[0].value,
|
"limit=" + $("#limit-input")[0].value,
|
||||||
"guess-value-type=" + $("#guess-value-type-input")[0].checked,
|
"guess-value-type=" + $("#guess-value-type-input")[0].checked,
|
||||||
"ignore-quotes=" + $("#ignore-quotes-input")[0].checked
|
"ignore-quotes=" + $("#ignore-quotes-input")[0].checked
|
||||||
].join("&"));
|
].join("&"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user