- replace the 'cos' library with the apache 'commons-fileupload' for licensing reason (the cos library had a weird arm-twisting license that forced you to buy an o'reilly book on servlets for each developer in your company... good thing I read it all)

- some tweaks on imgareaselect's look


git-svn-id: http://google-refine.googlecode.com/svn/trunk@483 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-04-15 18:42:41 +00:00
parent 93a8f78192
commit 397861b612
14 changed files with 121 additions and 114 deletions

View File

@ -10,9 +10,9 @@
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar" sourcepath="lib-src/log4j-1.2.15-sources.jar"/> <classpathentry kind="lib" path="lib/log4j-1.2.15.jar" sourcepath="lib-src/log4j-1.2.15-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar" sourcepath="lib-src/commons-codec-1.3-sources.jar"/> <classpathentry kind="lib" path="lib/commons-codec-1.3.jar" sourcepath="lib-src/commons-codec-1.3-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-2.5.jar" sourcepath="lib-src/commons-lang-2.5-sources.jar"/> <classpathentry kind="lib" path="lib/commons-lang-2.5.jar" sourcepath="lib-src/commons-lang-2.5-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-fileupload-1.2.1.jar" sourcepath="lib-src/commons-fileupload-1.2.1-sources.jar"/>
<classpathentry kind="lib" path="lib/json-20100208.jar" sourcepath="lib-src/json-20100208-sources.jar"/> <classpathentry kind="lib" path="lib/json-20100208.jar" sourcepath="lib-src/json-20100208-sources.jar"/>
<classpathentry kind="lib" path="lib/icu4j-4.2.1.jar" sourcepath="lib-src/icu4j-4.2.1-sources.jar"/> <classpathentry kind="lib" path="lib/icu4j-4.2.1.jar" sourcepath="lib-src/icu4j-4.2.1-sources.jar"/>
<classpathentry kind="lib" path="lib/cos-20081226.jar" sourcepath="lib-src/cos-20081226-sources.jar"/>
<classpathentry kind="lib" path="lib/arithcode-1.1.jar" sourcepath="lib-src/arithcode-1.1-sources.jar"/> <classpathentry kind="lib" path="lib/arithcode-1.1.jar" sourcepath="lib-src/arithcode-1.1-sources.jar"/>
<classpathentry kind="lib" path="lib/jdatapath-alpha2.jar" sourcepath="lib-src/jdatapath-alpha2-sources.jar"/> <classpathentry kind="lib" path="lib/jdatapath-alpha2.jar" sourcepath="lib-src/jdatapath-alpha2-sources.jar"/>
<classpathentry kind="lib" path="lib/secondstring-20100303.jar" sourcepath="lib-src/secondstring-20100303-sources.jar"/> <classpathentry kind="lib" path="lib/secondstring-20100303.jar" sourcepath="lib-src/secondstring-20100303-sources.jar"/>

View File

@ -35,11 +35,15 @@
See the 'licenses' directory for a list of the licenses for the libraries we depend on, See the 'licenses' directory for a list of the licenses for the libraries we depend on,
ordered here by license: ordered here by license:
Apache License 2.0
------------------
licenses/apache2.0.LICENSE.txt licenses/apache2.0.LICENSE.txt
calendar-parser (package com.metaweb.gridworks.expr.util) calendar-parser (package com.metaweb.gridworks.expr.util)
ant-tools ant-tools
commons-lang commons-lang
commons-codec commons-codec
commons-fileupload
jackson jackson
jdatapath jdatapath
jetty jetty
@ -50,44 +54,47 @@ licenses/apache2.0.LICENSE.txt
poi-ooxml-schemas poi-ooxml-schemas
servlet-api servlet-api
xmlbeans xmlbeans
BSD
---
licenses/secondstring.LICENSE.txt (BSD family) licenses/secondstring.LICENSE.txt
secondstring secondstring
licenses/dom4j.LICENSE.txt (BSD family) licenses/dom4j.LICENSE.txt
dom4j dom4j
licenses/simile.LICENSE.txt (BSD family) licenses/simile.LICENSE.txt
vicino simile vicino
licenses/arithcode.LICENSE.txt (BSD family) licenses/arithcode.LICENSE.txt
arithcode arithcode
licenses/freebase_suggest.LICENSE.txt (BSD family) licenses/freebase_suggest.LICENSE.txt
freebase_suggest freebase_suggest
licenses/jquery.LICENSE.txt (MIT) MIT
---
licenses/jquery.LICENSE.txt
jquery jquery
licenses/jquery_ui.LICENSE.txt (MIT) licenses/jquery_ui.LICENSE.txt
jquery_ui jquery_ui
licenses/datejs.LICENSE.txt (MIT) licenses/datejs.LICENSE.txt
datejs datejs
licenses/imgareaselect.LICENSE.txt (MIT) licenses/imgareaselect.LICENSE.txt
imgareaselect imgareaselect
licenses/slf4j.LICENSE.txt (MIT) licenses/slf4j.LICENSE.txt
slf4j-api slf4j-api
slf4j-log4j12 slf4j-log4j12
jcl-over-slf4j jcl-over-slf4j
licenses/icu4j.LICENSE.txt (MIT family) licenses/icu4j.LICENSE.txt
icu4j icu4j
licenses/json.LICENSE.txt (MIT family) licenses/json.LICENSE.txt
json json
licenses/cos.LICENSE.txt
cos

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -10,7 +10,6 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.io.Serializable; import java.io.Serializable;
import java.io.StringReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
@ -31,6 +30,10 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.apache.tools.bzip2.CBZip2InputStream; import org.apache.tools.bzip2.CBZip2InputStream;
import org.apache.tools.tar.TarEntry; import org.apache.tools.tar.TarEntry;
import org.apache.tools.tar.TarInputStream; import org.apache.tools.tar.TarInputStream;
@ -47,10 +50,6 @@ import com.metaweb.gridworks.importers.TsvCsvImporter;
import com.metaweb.gridworks.importers.XmlImporter; import com.metaweb.gridworks.importers.XmlImporter;
import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.util.ParsingUtilities; import com.metaweb.gridworks.util.ParsingUtilities;
import com.oreilly.servlet.multipart.FilePart;
import com.oreilly.servlet.multipart.MultipartParser;
import com.oreilly.servlet.multipart.ParamPart;
import com.oreilly.servlet.multipart.Part;
public class CreateProjectCommand extends Command { public class CreateProjectCommand extends Command {
@ -66,7 +65,6 @@ public class CreateProjectCommand extends Command {
* This is why we have to parse the URL for parameters ourselves. * This is why we have to parse the URL for parameters ourselves.
* Don't call request.getParameter() before calling internalImport(). * Don't call request.getParameter() before calling internalImport().
*/ */
Properties options = ParsingUtilities.parseUrlParameters(request); Properties options = ParsingUtilities.parseUrlParameters(request);
Project project = new Project(); Project project = new Project();
@ -102,47 +100,40 @@ public class CreateProjectCommand extends Command {
Project project, Project project,
Properties options Properties options
) throws Exception { ) throws Exception {
MultipartParser parser = new MultipartParser(request, 1024 * 1024 * 1024);
ServletFileUpload upload = new ServletFileUpload();
String url = null;
if (parser != null) { FileItemIterator iter = upload.getItemIterator(request);
Part part = null; while (iter.hasNext()) {
String url = null; FileItemStream item = iter.next();
String name = item.getFieldName().toLowerCase();
while ((part = parser.readNextPart()) != null) { InputStream stream = item.openStream();
if (item.isFormField()) {
if (part.isFile()) { if (name.equals("raw-text")) {
Reader reader = new InputStreamReader(stream,"UTF-8");
FilePart filePart = (FilePart) part;
InputStream stream = filePart.getInputStream();
String name = filePart.getFileName().toLowerCase();
try { try {
internalImportFile(project, options, name, stream); internalInvokeImporter(project, new TsvCsvImporter(), options, reader);
} finally { } finally {
stream.close(); reader.close();
}
} else if (part.isParam()) {
ParamPart paramPart = (ParamPart) part;
String paramName = paramPart.getName();
if (paramName.equals("raw-text")) {
StringReader reader = new StringReader(paramPart.getStringValue());
try {
internalInvokeImporter(project, new TsvCsvImporter(), options, reader);
} finally {
reader.close();
}
} else if (paramName.equals("url")) {
url = paramPart.getStringValue();
} else {
options.put(paramName, paramPart.getStringValue());
} }
} else if (name.equals("url")) {
url = Streams.asString(stream);
} else {
options.put(name, Streams.asString(stream));
}
} else {
String fileName = item.getName().toLowerCase();
try {
internalImportFile(project, options, fileName, stream);
} finally {
stream.close();
} }
} }
}
if (url != null && url.length() > 0) {
internalImportURL(request, project, options, url); if (url != null && url.length() > 0) {
} internalImportURL(request, project, options, url);
} }
} }

View File

@ -13,6 +13,10 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.apache.tools.tar.TarEntry; import org.apache.tools.tar.TarEntry;
import org.apache.tools.tar.TarInputStream; import org.apache.tools.tar.TarInputStream;
@ -22,10 +26,6 @@ import com.metaweb.gridworks.ProjectMetadata;
import com.metaweb.gridworks.commands.Command; import com.metaweb.gridworks.commands.Command;
import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.util.ParsingUtilities; import com.metaweb.gridworks.util.ParsingUtilities;
import com.oreilly.servlet.multipart.FilePart;
import com.oreilly.servlet.multipart.MultipartParser;
import com.oreilly.servlet.multipart.ParamPart;
import com.oreilly.servlet.multipart.Part;
public class ImportProjectCommand extends Command { public class ImportProjectCommand extends Command {
@ -68,44 +68,34 @@ public class ImportProjectCommand extends Command {
Properties options, Properties options,
long projectID long projectID
) throws Exception { ) throws Exception {
MultipartParser parser = null;
try {
parser = new MultipartParser(request, 1024 * 1024 * 1024);
} catch (Exception e) {
// silent
}
if (parser != null) { String url = null;
Part part = null;
String url = null; ServletFileUpload upload = new ServletFileUpload();
while ((part = parser.readNextPart()) != null) { FileItemIterator iter = upload.getItemIterator(request);
if (part.isFile()) { while (iter.hasNext()) {
FilePart filePart = (FilePart) part; FileItemStream item = iter.next();
InputStream inputStream = filePart.getInputStream(); String name = item.getFieldName().toLowerCase();
try { InputStream stream = item.openStream();
internalImportInputStream( if (item.isFormField()) {
projectID, if (name.equals("url")) {
inputStream, url = Streams.asString(stream);
!filePart.getFileName().endsWith(".tar") } else {
); options.put(name, Streams.asString(stream));
} finally { }
inputStream.close(); } else {
} String fileName = item.getName().toLowerCase();
} else if (part.isParam()) { try {
ParamPart paramPart = (ParamPart) part; internalImportInputStream(projectID, stream, !fileName.endsWith(".tar"));
String paramName = paramPart.getName(); } finally {
if (paramName.equals("url")) { stream.close();
url = paramPart.getStringValue();
} else {
options.put(paramName, paramPart.getStringValue());
}
} }
} }
}
if (url != null && url.length() > 0) {
internalImportURL(request, options, projectID, url); if (url != null && url.length() > 0) {
} internalImportURL(request, options, projectID, url);
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 B

View File

@ -3,38 +3,38 @@
*/ */
.imgareaselect-border1 { .imgareaselect-border1 {
background: url(border-v.gif) repeat-y left top; border: 1px solid red;
} }
.imgareaselect-border2 { .imgareaselect-border2 {
background: url(border-h.gif) repeat-x left top; border: 1px solid red;
} }
.imgareaselect-border3 { .imgareaselect-border3 {
background: url(border-v.gif) repeat-y right top; border: 1px solid red;
} }
.imgareaselect-border4 { .imgareaselect-border4 {
background: url(border-h.gif) repeat-x left bottom; border: 1px solid red;
} }
.imgareaselect-border1, .imgareaselect-border2, .imgareaselect-border1, .imgareaselect-border2,
.imgareaselect-border3, .imgareaselect-border4 { .imgareaselect-border3, .imgareaselect-border4 {
opacity: 0.5; opacity: 0.2;
filter: alpha(opacity=50); filter: alpha(opacity=20);
} }
.imgareaselect-handle { .imgareaselect-handle {
background-color: #fff; background-color: #fff;
border: solid 1px #000; border: solid 1px #000;
opacity: 0.5; opacity: 0.2;
filter: alpha(opacity=50); filter: alpha(opacity=20);
} }
.imgareaselect-outer { .imgareaselect-outer {
background-color: #000; background-color: #000;
opacity: 0.5; opacity: 0.2;
filter: alpha(opacity=50); filter: alpha(opacity=20);
} }
.imgareaselect-selection { .imgareaselect-selection {

View File

@ -73,7 +73,7 @@ ScatterplotFacet.prototype._initializeUI = function() {
this._messageDiv = $('<div>').text("Loading...").addClass("facet-scatterplot-message").appendTo(bodyDiv); this._messageDiv = $('<div>').text("Loading...").addClass("facet-scatterplot-message").appendTo(bodyDiv);
this._plotDiv = $('<div>').addClass("facet-scatterplot-plot").appendTo(bodyDiv); this._plotDiv = $('<div>').addClass("facet-scatterplot-plot").appendTo(bodyDiv);
this._statusDiv = $('<div>').addClass("facet-scatterplot-status").appendTo(bodyDiv); this._statusDiv = $('<div>').addClass("facet-scatterplot-status").appendTo(bodyDiv);
this._plot = new ScatterplotWidget(this._plotDiv, this._config); this._plot = new ScatterplotWidget(this._plotDiv, this._config);
}; };

View File

@ -55,6 +55,8 @@ ScatterplotWidget.prototype._update = function() {
}; };
ScatterplotWidget.prototype._initializeUI = function() { ScatterplotWidget.prototype._initializeUI = function() {
self = this;
this._elmt this._elmt
.empty() .empty()
.hide() .hide()
@ -62,6 +64,18 @@ ScatterplotWidget.prototype._initializeUI = function() {
.html('<canvas bind="canvas"></canvas>'); .html('<canvas bind="canvas"></canvas>');
this._elmts = DOM.bind(this._elmt); this._elmts = DOM.bind(this._elmt);
this._elmts.canvas.imgAreaSelect({
handles: false,
fadeSpeed: 70,
onSelectEnd: function(elmt, selection) {
self.highlight(
selection.x1,
selection.x2,
self._plotter.h - selection.y2,
self._plotter.h - selection.y1
);
}
});
}; };
ScatterplotWidget.prototype._resize = function() { ScatterplotWidget.prototype._resize = function() {
@ -89,19 +103,15 @@ ScatterplotWidget.prototype._render = function() {
var img2 = new Image(); var img2 = new Image();
img2.onload = function(){ img2.onload = function(){
ctx.drawImage(img2,0,0); ctx.drawImage(img2,0,0);
ctx.translate(0, canvas.height);
ctx.scale(1, -1);
// draw something else
ctx.restore(); ctx.restore();
} }
self._plotter.color = "000088"; self._plotter.color = "000088";
console.log(self._plotter);
img2.src = self._get_image_url(self._plotter); img2.src = self._get_image_url(self._plotter);
} }
} }
self._plotter.color = "000000"; self._plotter.color = "000000";
console.log(self._plotter);
img.src = self._get_image_url(self._plotter); img.src = self._get_image_url(self._plotter);
}; };

View File

@ -40,6 +40,7 @@ public class Gridworks {
static private final String VERSION = "1.0a"; static private final String VERSION = "1.0a";
static private final String DEFAULT_HOST = "127.0.0.1"; static private final String DEFAULT_HOST = "127.0.0.1";
static private final int DEFAULT_PORT = 3333; static private final int DEFAULT_PORT = 3333;
static private final int MAX_UPLOAD_SIZE = 1024 * 1024 * 1024;
static private File tempDir; static private File tempDir;
@ -73,7 +74,15 @@ public class Gridworks {
public static File getTempFile(String name) { public static File getTempFile(String name) {
return new File(tempDir, name); return new File(tempDir, name);
} }
public static File getTempDir() {
return tempDir;
}
public static int getMaxUploadSize() {
return Configurations.getInteger("gridworks.max_upload_size",MAX_UPLOAD_SIZE);
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// tell jetty to use SLF4J for logging instead of its own stuff // tell jetty to use SLF4J for logging instead of its own stuff