- removed the 'thirdparty' directory (now the 'gridworks' script will download and install needed tools if they are not present in the system already)
- added 'findbugs' command that uses the findbugs static analyzer to look for problems in the code - fixed a bunch of issues that findbugs found (a few methods would go a little faster, and a few NPE will be avoided... nothing major but good to have) git-svn-id: http://google-refine.googlecode.com/svn/trunk@382 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
798b2a36ca
commit
2efbf0031f
20
build.xml
20
build.xml
@ -26,7 +26,6 @@
|
|||||||
<property name="graphics.dir" value="${basedir}/src/graphics" />
|
<property name="graphics.dir" value="${basedir}/src/graphics" />
|
||||||
<property name="conf.dir" value="${basedir}/src/conf" />
|
<property name="conf.dir" value="${basedir}/src/conf" />
|
||||||
<property name="lib.dir" value="${basedir}/lib" />
|
<property name="lib.dir" value="${basedir}/lib" />
|
||||||
<property name="tools.dir" value="${basedir}/thirdparty" />
|
|
||||||
<property name="tests.dir" value="${basedir}/tests" />
|
<property name="tests.dir" value="${basedir}/tests" />
|
||||||
|
|
||||||
<property name="server_classes.dir" value="${build.dir}/classes" />
|
<property name="server_classes.dir" value="${build.dir}/classes" />
|
||||||
@ -100,7 +99,7 @@
|
|||||||
<taskdef
|
<taskdef
|
||||||
name="jarbundler"
|
name="jarbundler"
|
||||||
classname="net.sourceforge.jarbundler.JarBundler"
|
classname="net.sourceforge.jarbundler.JarBundler"
|
||||||
classpath="${tools.dir}/jarbundler-2.1.0.jar"
|
classpath="${jarbundler.dir}/jarbundler-2.1.0.jar"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<mkdir dir="${mac.dir}"/>
|
<mkdir dir="${mac.dir}"/>
|
||||||
@ -138,7 +137,7 @@
|
|||||||
<taskdef
|
<taskdef
|
||||||
name="launch4j"
|
name="launch4j"
|
||||||
classname="net.sf.launch4j.ant.Launch4jTask"
|
classname="net.sf.launch4j.ant.Launch4jTask"
|
||||||
classpath="${tools.dir}/launch4j/launch4j.jar:${tools.dir}/launch4j/lib/xstream.jar"
|
classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar"
|
||||||
/>
|
/>
|
||||||
<launch4j>
|
<launch4j>
|
||||||
<config
|
<config
|
||||||
@ -224,8 +223,6 @@
|
|||||||
<copy file="${basedir}/README.txt" tofile="${linux.dir}/README.txt"/>
|
<copy file="${basedir}/README.txt" tofile="${linux.dir}/README.txt"/>
|
||||||
<copy file="${basedir}/gridworks" tofile="${linux.dir}/gridworks"/>
|
<copy file="${basedir}/gridworks" tofile="${linux.dir}/gridworks"/>
|
||||||
|
|
||||||
<echo file="${linux.dir}/.revision" append="false">${revision}</echo>
|
|
||||||
|
|
||||||
<tar longfile="gnu" compression="gzip" destfile="${dist.dir}/gridworks-${version}-${revision}.tar.gz">
|
<tar longfile="gnu" compression="gzip" destfile="${dist.dir}/gridworks-${version}-${revision}.tar.gz">
|
||||||
<tarfileset dir="${linux.dir}/.." filemode="755">
|
<tarfileset dir="${linux.dir}/.." filemode="755">
|
||||||
<include name="${linux.name}/gridworks"/>
|
<include name="${linux.name}/gridworks"/>
|
||||||
@ -237,6 +234,19 @@
|
|||||||
</tar>
|
</tar>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="findbugs" depends="build">
|
||||||
|
<taskdef
|
||||||
|
name="findbugs"
|
||||||
|
classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
|
||||||
|
classpath="${findbugs.dir}/lib/findbugs-ant.jar"
|
||||||
|
/>
|
||||||
|
<findbugs jvmargs="-Xmx1024m" home="${findbugs.dir}" output="html" outputFile="${build.dir}/gridworks-findbugs.html" >
|
||||||
|
<auxClasspath refid="class.path" />
|
||||||
|
<sourcePath path="${src.dir}" />
|
||||||
|
<class location="${webapp_classes.dir}" />
|
||||||
|
</findbugs>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="clean">
|
<target name="clean">
|
||||||
<delete file="${build.dir}/gridworks.jar" />
|
<delete file="${build.dir}/gridworks.jar" />
|
||||||
<delete dir="${server_classes.dir}" />
|
<delete dir="${server_classes.dir}" />
|
||||||
|
228
gridworks
228
gridworks
@ -4,7 +4,7 @@
|
|||||||
# Gridworks Control System #
|
# Gridworks Control System #
|
||||||
##########################################################
|
##########################################################
|
||||||
|
|
||||||
# -------------- functions ------------------------------------
|
# -------------- utility functions ----------------------
|
||||||
|
|
||||||
fail () {
|
fail () {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
@ -51,6 +51,7 @@ and <action> is one of
|
|||||||
run ....................... Run Gridworks
|
run ....................... Run Gridworks
|
||||||
|
|
||||||
test ...................... Test Gridworks
|
test ...................... Test Gridworks
|
||||||
|
findbugs .................. Run Findbugs against Gridworks
|
||||||
|
|
||||||
mac_dist <version> ........ Make MacOSX binary distribution
|
mac_dist <version> ........ Make MacOSX binary distribution
|
||||||
windows_dist <version> .... Make Windows binary distribution
|
windows_dist <version> .... Make Windows binary distribution
|
||||||
@ -81,45 +82,6 @@ check_macosx() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ant_prepare() {
|
|
||||||
if [ ! -d $GRIDWORKS_BUILD_DIR ] ; then
|
|
||||||
mkdir $GRIDWORKS_BUILD_DIR || exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ANT=`which ant`
|
|
||||||
if [ "$ANT" = "" ] ; then
|
|
||||||
cd thirdparty
|
|
||||||
ANT_TAR=`ls | grep apache-ant | grep tar.gz | grep -v svn`
|
|
||||||
ANT_DIR=`echo $ANT_TAR | sed 's/.tar.gz//'`
|
|
||||||
if [ ! -d $ANT_DIR ] ; then
|
|
||||||
tar xzf $ANT_TAR -C . || exit 1
|
|
||||||
fi
|
|
||||||
ANT="`pwd`/$ANT_DIR/bin/ant"
|
|
||||||
cd ..
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
ant() {
|
|
||||||
ant_prepare
|
|
||||||
$ANT -f build.xml -Dbuild.dir="$GRIDWORKS_BUILD_DIR" -Ddist.dir="$GRIDWORKS_DIST_DIR" -Dversion="$VERSION" -Dnum_version="$NUM_VERSION" -Drevision="$REVISION" $1 || exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
dist_prepare() {
|
|
||||||
if [ ! -d $GRIDWORKS_DIST_DIR ] ; then
|
|
||||||
mkdir $GRIDWORKS_DIST_DIR || exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
launch4j_prepare() {
|
|
||||||
cd thirdparty
|
|
||||||
LAUNCH4J_TAR=`ls | grep launch4j | grep tar.gz | grep -v svn`
|
|
||||||
LAUNCH4J_DIR="launch4j"
|
|
||||||
if [ ! -d "$LAUNCH4J_DIR" ] ; then
|
|
||||||
tar xzf $LAUNCH4J_TAR || exit 1
|
|
||||||
fi
|
|
||||||
cd ..
|
|
||||||
}
|
|
||||||
|
|
||||||
get_version() {
|
get_version() {
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
|
|
||||||
@ -135,8 +97,6 @@ get_revision() {
|
|||||||
INFO=`svn info`
|
INFO=`svn info`
|
||||||
elif [ -d ".git" ]; then
|
elif [ -d ".git" ]; then
|
||||||
INFO=`git svn info`
|
INFO=`git svn info`
|
||||||
elif [ -f ".revision" ]; then
|
|
||||||
REVISION=`cat .revision`
|
|
||||||
else
|
else
|
||||||
error "cannot obtain revision, exiting!"
|
error "cannot obtain revision, exiting!"
|
||||||
fi
|
fi
|
||||||
@ -144,6 +104,124 @@ get_revision() {
|
|||||||
REVISION=`echo $INFO | sed 's/.*Revision: /r/' | sed 's/ .*//'`
|
REVISION=`echo $INFO | sed 's/.*Revision: /r/' | sed 's/ .*//'`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_url_file() {
|
||||||
|
return `echo $1 | sed 's|.*/||'`
|
||||||
|
}
|
||||||
|
|
||||||
|
download() {
|
||||||
|
URL=$1
|
||||||
|
DEST=$2
|
||||||
|
|
||||||
|
if [ `which curl` == "" ] && [ `which wget` == "" ]; then
|
||||||
|
error "We need either 'curl' or 'wget' present in PATH to download external dependencies."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ `which curl` != "" ] ; then
|
||||||
|
curl -o $DEST $URL || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ `which wget` != "" ] ; then
|
||||||
|
wget -O $DEST $URL || exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
build_prepare() {
|
||||||
|
if [ ! -d $GRIDWORKS_BUILD_DIR ] ; then
|
||||||
|
mkdir $GRIDWORKS_BUILD_DIR || exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
dist_prepare() {
|
||||||
|
if [ ! -d $GRIDWORKS_DIST_DIR ] ; then
|
||||||
|
mkdir $GRIDWORKS_DIST_DIR || exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
tools_prepare() {
|
||||||
|
if [ ! -d $GRIDWORKS_TOOLS_DIR ] ; then
|
||||||
|
mkdir $GRIDWORKS_TOOLS_DIR || exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ant_prepare() {
|
||||||
|
ANT_URL="http://www.apache.org/dist/ant/binaries/apache-ant-1.8.0-bin.tar.gz"
|
||||||
|
ANT_FILE=`echo $ANT_URL | sed 's|.*/||'`
|
||||||
|
ANT_DIR="apache-ant-1.8.0"
|
||||||
|
|
||||||
|
ANT=`which ant`
|
||||||
|
if [ $ANT == "" ] ; then
|
||||||
|
if [ $ANT_HOME == "" ] ; then
|
||||||
|
cd $GRIDWORKS_TOOLS_DIR
|
||||||
|
if [ ! -f $ANT_FILE ] ; then
|
||||||
|
download $ANT_URL $ANT_FILE
|
||||||
|
fi
|
||||||
|
if [ ! -d $ANT_DIR ] ; then
|
||||||
|
tar xzf $ANT_FILE -C . || exit 1
|
||||||
|
fi
|
||||||
|
export ANT_HOME="`pwd`/$ANT_DIR"
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
ANT="$ANT_HOME/bin/ant"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
launch4j_prepare() {
|
||||||
|
LAUNCH4J_URL="http://downloads.sourceforge.net/project/launch4j/launch4j-3/3.0.1/launch4j-3.0.1-macosx.tgz"
|
||||||
|
LAUNCH4J_FILE=`echo $LAUNCH4J_URL | sed 's|.*/||'`
|
||||||
|
LAUNCH4J_DIR="launch4j"
|
||||||
|
|
||||||
|
cd $GRIDWORKS_TOOLS_DIR
|
||||||
|
if [ ! -f "$LAUNCH4J_FILE" ] ; then
|
||||||
|
download $LAUNCH4J_URL $LAUNCH4J_FILE
|
||||||
|
fi
|
||||||
|
if [ ! -d "$LAUNCH4J_DIR" ] ; then
|
||||||
|
tar xzf $LAUNCH4J_FILE || exit 1
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
|
||||||
|
jarbundler_prepare() {
|
||||||
|
JARBUNDLER_URL="http://www.informagen.com/JarBundler/dist/jarbundler.tar.gz"
|
||||||
|
JARBUNDLER_FILE=`echo $JARBUNDLER_URL | sed 's|.*/||'`
|
||||||
|
JARBUNDLER_DIR="jarbundler-2.1.0"
|
||||||
|
|
||||||
|
cd $GRIDWORKS_TOOLS_DIR
|
||||||
|
if [ ! -f "$JARBUNDLER_FILE" ] ; then
|
||||||
|
download $JARBUNDLER_URL $JARBUNDLER_FILE
|
||||||
|
fi
|
||||||
|
if [ ! -d "$JARBUNDLER_DIR" ] ; then
|
||||||
|
tar xzf $JARBUNDLER_FILE || exit 1
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
|
||||||
|
findbugs_prepare() {
|
||||||
|
FINDBUGS_URL="http://downloads.sourceforge.net/project/findbugs/findbugs/1.3.9/findbugs-1.3.9.tar.gz"
|
||||||
|
FINDBUGS_FILE=`echo $FINDBUGS_URL | sed 's|.*/||'`
|
||||||
|
FINDBUGS_DIR="findbugs-1.3.9"
|
||||||
|
|
||||||
|
cd $GRIDWORKS_TOOLS_DIR
|
||||||
|
if [ ! -f "$FINDBUGS_FILE" ] ; then
|
||||||
|
download $FINDBUGS_URL $FINDBUGS_FILE
|
||||||
|
fi
|
||||||
|
if [ ! -d "$FINDBUGS_DIR" ] ; then
|
||||||
|
tar xzf $FINDBUGS_FILE || exit 1
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ant() {
|
||||||
|
ant_prepare
|
||||||
|
#export ANT_OPTS="-Xmx1024M"
|
||||||
|
$ANT -f build.xml $ANT_PARAMS -Dbuild.dir="$GRIDWORKS_BUILD_DIR" -Ddist.dir="$GRIDWORKS_DIST_DIR" -Dversion="$VERSION" -Dnum_version="$NUM_VERSION" -Drevision="$REVISION" $1 || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
dist() {
|
dist() {
|
||||||
mac_dist $1
|
mac_dist $1
|
||||||
windows_dist $1
|
windows_dist $1
|
||||||
@ -172,6 +250,7 @@ windows_dist() {
|
|||||||
get_version $1
|
get_version $1
|
||||||
get_revision
|
get_revision
|
||||||
|
|
||||||
|
ANT_PARAMS="-Dlaunch4j.dir=${GRIDWORKS_TOOLS_DIR}/${LAUNCH4J_DIR}"
|
||||||
ant windows
|
ant windows
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,9 +265,11 @@ linux_dist() {
|
|||||||
mac_dist() {
|
mac_dist() {
|
||||||
check_macosx
|
check_macosx
|
||||||
dist_prepare
|
dist_prepare
|
||||||
|
jarbundler_prepare
|
||||||
get_version $1
|
get_version $1
|
||||||
get_revision
|
get_revision
|
||||||
|
|
||||||
|
ANT_PARAMS="-Djarbundler.dir=${GRIDWORKS_TOOLS_DIR}/${JARBUNDLER_DIR}"
|
||||||
ant mac
|
ant mac
|
||||||
|
|
||||||
mkdir -p "$GRIDWORKS_BUILD_DIR/mac/.background"
|
mkdir -p "$GRIDWORKS_BUILD_DIR/mac/.background"
|
||||||
@ -277,10 +358,6 @@ run() {
|
|||||||
add_option "-Dgridworks.data_dir=$GRIDWORKS_DATA_DIR"
|
add_option "-Dgridworks.data_dir=$GRIDWORKS_DATA_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_revision
|
|
||||||
|
|
||||||
add_option "-Dgridworks.version=$REVISION"
|
|
||||||
|
|
||||||
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes:$GRIDWORKS_LIB_DIR/*"
|
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes:$GRIDWORKS_LIB_DIR/*"
|
||||||
|
|
||||||
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.metaweb.gridworks.Gridworks"
|
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.metaweb.gridworks.Gridworks"
|
||||||
@ -309,6 +386,13 @@ execute() {
|
|||||||
exec $RUN_CMD $*
|
exec $RUN_CMD $*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findbugs() {
|
||||||
|
findbugs_prepare
|
||||||
|
|
||||||
|
ANT_PARAMS="-Dfindbugs.dir=${GRIDWORKS_TOOLS_DIR}/${FINDBUGS_DIR}"
|
||||||
|
ant findbugs
|
||||||
|
}
|
||||||
|
|
||||||
# -------------------------- script -----------------------------
|
# -------------------------- script -----------------------------
|
||||||
|
|
||||||
# ----- Normalize the current directory -------------------------
|
# ----- Normalize the current directory -------------------------
|
||||||
@ -336,7 +420,7 @@ if [ ! -z "$JAVA_HOME" ] ; then
|
|||||||
else
|
else
|
||||||
JAVA=`which java`
|
JAVA=`which java`
|
||||||
if [ -z "$JAVA" ] ; then
|
if [ -z "$JAVA" ] ; then
|
||||||
if [ "$SYSTEM" = 'Darwin' ] ; then
|
if [ "$SYSTEM" == 'Darwin' ] ; then
|
||||||
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
|
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
|
||||||
else
|
else
|
||||||
error "The 'java' command should be in your path or the 'JAVA_HOME' environment variable should be set"
|
error "The 'java' command should be in your path or the 'JAVA_HOME' environment variable should be set"
|
||||||
@ -411,6 +495,10 @@ if [ "$GRIDWORKS_LIB_DIR" == "" ] ; then
|
|||||||
GRIDWORKS_LIB_DIR="lib"
|
GRIDWORKS_LIB_DIR="lib"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$GRIDWORKS_TOOLS_DIR" == "" ] ; then
|
||||||
|
GRIDWORKS_TOOLS_DIR="tools"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$GRIDWORKS_DIST_DIR" == "" ] ; then
|
if [ "$GRIDWORKS_DIST_DIR" == "" ] ; then
|
||||||
GRIDWORKS_DIST_DIR="dist"
|
GRIDWORKS_DIST_DIR="dist"
|
||||||
fi
|
fi
|
||||||
@ -418,38 +506,16 @@ fi
|
|||||||
# ----- Respond to the action given --------------------------------------------
|
# ----- Respond to the action given --------------------------------------------
|
||||||
|
|
||||||
case "$ACTION" in
|
case "$ACTION" in
|
||||||
|
build) build_prepare; ant build;;
|
||||||
build)
|
clean) ant clean;;
|
||||||
ant build;;
|
distclean) ant distclean;;
|
||||||
|
test) test $1;;
|
||||||
clean)
|
findbugs) findbugs;;
|
||||||
ant clean;;
|
run) run;;
|
||||||
|
execute) execute $*;;
|
||||||
distclean)
|
mac_dist) mac_dist $1;;
|
||||||
ant distclean;;
|
windows_dist) windows_dist $1;;
|
||||||
|
linux_dist) linux_dist $1;;
|
||||||
test)
|
dist) dist $1;;
|
||||||
test $1;;
|
*) usage; ;;
|
||||||
|
|
||||||
run)
|
|
||||||
run;;
|
|
||||||
|
|
||||||
execute)
|
|
||||||
execute $*;;
|
|
||||||
|
|
||||||
mac_dist)
|
|
||||||
mac_dist $1;;
|
|
||||||
|
|
||||||
windows_dist)
|
|
||||||
windows_dist $1;;
|
|
||||||
|
|
||||||
linux_dist)
|
|
||||||
linux_dist $1;;
|
|
||||||
|
|
||||||
dist)
|
|
||||||
dist $1;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
usage; ;;
|
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
@ -59,7 +59,7 @@ public class GridworksServlet extends HttpServlet {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 2386057901503517403L;
|
private static final long serialVersionUID = 2386057901503517403L;
|
||||||
|
|
||||||
static protected Map<String, Command> _commands = new HashMap<String, Command>();
|
static final protected Map<String, Command> _commands = new HashMap<String, Command>();
|
||||||
|
|
||||||
// timer for periodically saving projects
|
// timer for periodically saving projects
|
||||||
static protected Timer _timer;
|
static protected Timer _timer;
|
||||||
|
@ -43,7 +43,7 @@ public class ProjectManager {
|
|||||||
|
|
||||||
static public ProjectManager singleton;
|
static public ProjectManager singleton;
|
||||||
|
|
||||||
static public void initialize() {
|
static public synchronized void initialize() {
|
||||||
if (singleton == null) {
|
if (singleton == null) {
|
||||||
File dir = getProjectLocation();
|
File dir = getProjectLocation();
|
||||||
Gridworks.log("Using workspace directory: " + dir.getAbsolutePath());
|
Gridworks.log("Using workspace directory: " + dir.getAbsolutePath());
|
||||||
@ -325,8 +325,6 @@ public class ProjectManager {
|
|||||||
List<SaveRecord> records = new ArrayList<SaveRecord>();
|
List<SaveRecord> records = new ArrayList<SaveRecord>();
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
|
||||||
boolean gc = false;
|
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (long id : _projectsMetadata.keySet()) {
|
for (long id : _projectsMetadata.keySet()) {
|
||||||
ProjectMetadata metadata = _projectsMetadata.get(id);
|
ProjectMetadata metadata = _projectsMetadata.get(id);
|
||||||
@ -347,8 +345,6 @@ public class ProjectManager {
|
|||||||
* modified. We can safely remove it from the cache to save some memory.
|
* modified. We can safely remove it from the cache to save some memory.
|
||||||
*/
|
*/
|
||||||
_projects.remove(id);
|
_projects.remove(id);
|
||||||
|
|
||||||
gc = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,10 +380,6 @@ public class ProjectManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gc) {
|
|
||||||
System.gc();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteProject(Project project) {
|
public void deleteProject(Project project) {
|
||||||
|
@ -87,10 +87,10 @@ public class NumericBinIndex {
|
|||||||
_min = (Math.floor(_min / _step) * _step);
|
_min = (Math.floor(_min / _step) * _step);
|
||||||
_max = (Math.ceil(_max / _step) * _step);
|
_max = (Math.ceil(_max / _step) * _step);
|
||||||
|
|
||||||
int binCount = (int) ((_max - _min) / _step);
|
double binCount = (_max - _min) / _step;
|
||||||
if (binCount > 100) {
|
if (binCount > 100) {
|
||||||
_step *= 2;
|
_step *= 2;
|
||||||
binCount = Math.round((1 + binCount) / 2);
|
binCount = (binCount + 1) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_max <= originalMax) {
|
if (_max <= originalMax) {
|
||||||
@ -98,7 +98,7 @@ public class NumericBinIndex {
|
|||||||
binCount++;
|
binCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
_bins = new int[binCount];
|
_bins = new int[(int) Math.round(binCount)];
|
||||||
for (double d : allValues) {
|
for (double d : allValues) {
|
||||||
int bin = (int) Math.floor((d - _min) / _step);
|
int bin = (int) Math.floor((d - _min) / _step);
|
||||||
_bins[bin]++;
|
_bins[bin]++;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.metaweb.gridworks.clustering.binning;
|
package com.metaweb.gridworks.clustering.binning;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -27,7 +28,7 @@ public class BinningClusterer extends Clusterer {
|
|||||||
|
|
||||||
private Keyer _keyer;
|
private Keyer _keyer;
|
||||||
|
|
||||||
static protected Map<String, Keyer> _keyers = new HashMap<String, Keyer>();
|
static final protected Map<String, Keyer> _keyers = new HashMap<String, Keyer>();
|
||||||
|
|
||||||
List<Map<String,Integer>> _clusters;
|
List<Map<String,Integer>> _clusters;
|
||||||
|
|
||||||
@ -65,19 +66,19 @@ public class BinningClusterer extends Clusterer {
|
|||||||
public boolean visit(Project project, int rowIndex, Row row, boolean includeContextual, boolean includeDependent) {
|
public boolean visit(Project project, int rowIndex, Row row, boolean includeContextual, boolean includeDependent) {
|
||||||
Cell cell = row.getCell(_colindex);
|
Cell cell = row.getCell(_colindex);
|
||||||
if (cell != null && cell.value != null) {
|
if (cell != null && cell.value != null) {
|
||||||
String v = cell.value.toString();
|
Object v = cell.value;
|
||||||
String s = (v instanceof String) ? ((String) v) : v.toString();
|
String s = (v instanceof String) ? ((String) v) : v.toString();
|
||||||
String key = _keyer.key(s,_params);
|
String key = _keyer.key(s,_params);
|
||||||
if (_map.containsKey(key)) {
|
if (_map.containsKey(key)) {
|
||||||
Map<String,Integer> m = _map.get(key);
|
Map<String,Integer> m = _map.get(key);
|
||||||
if (m.containsKey(v)) {
|
if (m.containsKey(s)) {
|
||||||
m.put(v, m.get(v) + 1);
|
m.put(s, m.get(s) + 1);
|
||||||
} else {
|
} else {
|
||||||
m.put(v,1);
|
m.put(s,1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Map<String,Integer> m = new TreeMap<String,Integer>();
|
Map<String,Integer> m = new TreeMap<String,Integer>();
|
||||||
m.put(v,1);
|
m.put(s,1);
|
||||||
_map.put(key, m);
|
_map.put(key, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +90,8 @@ public class BinningClusterer extends Clusterer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SizeComparator implements Comparator<Map<String,Integer>> {
|
public static class SizeComparator implements Comparator<Map<String,Integer>>, Serializable {
|
||||||
|
private static final long serialVersionUID = -1390696157208674054L;
|
||||||
public int compare(Map<String,Integer> o1, Map<String,Integer> o2) {
|
public int compare(Map<String,Integer> o1, Map<String,Integer> o2) {
|
||||||
int s1 = o1.size();
|
int s1 = o1.size();
|
||||||
int s2 = o2.size();
|
int s2 = o2.size();
|
||||||
@ -109,7 +111,8 @@ public class BinningClusterer extends Clusterer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EntriesComparator implements Comparator<Entry<String,Integer>> {
|
public static class EntriesComparator implements Comparator<Entry<String,Integer>>, Serializable {
|
||||||
|
private static final long serialVersionUID = 2763378036791777964L;
|
||||||
public int compare(Entry<String,Integer> o1, Entry<String,Integer> o2) {
|
public int compare(Entry<String,Integer> o1, Entry<String,Integer> o2) {
|
||||||
return o2.getValue() - o1.getValue();
|
return o2.getValue() - o1.getValue();
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class kNNClusterer extends Clusterer {
|
|||||||
|
|
||||||
private Distance _distance;
|
private Distance _distance;
|
||||||
|
|
||||||
static protected Map<String, Distance> _distances = new HashMap<String, Distance>();
|
static final protected Map<String, Distance> _distances = new HashMap<String, Distance>();
|
||||||
|
|
||||||
List<Set<Serializable>> _clusters;
|
List<Set<Serializable>> _clusters;
|
||||||
|
|
||||||
@ -148,7 +148,8 @@ public class kNNClusterer extends Clusterer {
|
|||||||
_clusters = visitor.getClusters();
|
_clusters = visitor.getClusters();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ValuesComparator implements Comparator<Entry<Serializable,Integer>> {
|
public static class ValuesComparator implements Comparator<Entry<Serializable,Integer>>, Serializable {
|
||||||
|
private static final long serialVersionUID = 204469656070583155L;
|
||||||
public int compare(Entry<Serializable,Integer> o1, Entry<Serializable,Integer> o2) {
|
public int compare(Entry<Serializable,Integer> o1, Entry<Serializable,Integer> o2) {
|
||||||
return o2.getValue() - o1.getValue();
|
return o2.getValue() - o1.getValue();
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class AnnotateOneRowCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class StarOneRowProcess extends QuickHistoryEntryProcess {
|
protected static class StarOneRowProcess extends QuickHistoryEntryProcess {
|
||||||
final int rowIndex;
|
final int rowIndex;
|
||||||
final boolean starred;
|
final boolean starred;
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
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.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -145,7 +146,7 @@ public class CreateProjectCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SafeInputStream extends FilterInputStream {
|
static class SafeInputStream extends FilterInputStream {
|
||||||
public SafeInputStream(InputStream stream) {
|
public SafeInputStream(InputStream stream) {
|
||||||
super(stream);
|
super(stream);
|
||||||
}
|
}
|
||||||
@ -191,6 +192,7 @@ public class CreateProjectCommand extends Command {
|
|||||||
// behave precisely the same, there is no polymorphic behavior so we have
|
// behave precisely the same, there is no polymorphic behavior so we have
|
||||||
// to treat each instance explicitly... one of those times you wish you had
|
// to treat each instance explicitly... one of those times you wish you had
|
||||||
// closures
|
// closures
|
||||||
|
try {
|
||||||
if (is instanceof TarInputStream) {
|
if (is instanceof TarInputStream) {
|
||||||
TarInputStream tis = (TarInputStream) is;
|
TarInputStream tis = (TarInputStream) is;
|
||||||
TarEntry te;
|
TarEntry te;
|
||||||
@ -208,7 +210,11 @@ public class CreateProjectCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
// sort extensions by how often they appear
|
// sort extensions by how often they appear
|
||||||
List<Entry<String,Integer>> values = new ArrayList<Entry<String,Integer>>(ext_map.entrySet());
|
List<Entry<String,Integer>> values = new ArrayList<Entry<String,Integer>>(ext_map.entrySet());
|
||||||
@ -239,6 +245,7 @@ public class CreateProjectCommand extends Command {
|
|||||||
// second pass, load the data for real
|
// second pass, load the data for real
|
||||||
is = getStream(fileName, new FileInputStream(file));
|
is = getStream(fileName, new FileInputStream(file));
|
||||||
SafeInputStream sis = new SafeInputStream(is);
|
SafeInputStream sis = new SafeInputStream(is);
|
||||||
|
try {
|
||||||
if (is instanceof TarInputStream) {
|
if (is instanceof TarInputStream) {
|
||||||
TarInputStream tis = (TarInputStream) is;
|
TarInputStream tis = (TarInputStream) is;
|
||||||
TarEntry te;
|
TarEntry te;
|
||||||
@ -264,7 +271,11 @@ public class CreateProjectCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
sis.reallyClose();
|
sis.reallyClose();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (fileName.endsWith(".gz")) {
|
} else if (fileName.endsWith(".gz")) {
|
||||||
internalImportFile(project, options, getExtension(fileName)[0], new GZIPInputStream(inputStream));
|
internalImportFile(project, options, getExtension(fileName)[0], new GZIPInputStream(inputStream));
|
||||||
@ -275,7 +286,9 @@ public class CreateProjectCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ValuesComparator implements Comparator<Entry<String,Integer>> {
|
public static class ValuesComparator implements Comparator<Entry<String,Integer>>, Serializable {
|
||||||
|
private static final long serialVersionUID = 8845863616149837657L;
|
||||||
|
|
||||||
public int compare(Entry<String,Integer> o1, Entry<String,Integer> o2) {
|
public int compare(Entry<String,Integer> o1, Entry<String,Integer> o2) {
|
||||||
return o2.getValue() - o1.getValue();
|
return o2.getValue() - o1.getValue();
|
||||||
}
|
}
|
||||||
@ -308,10 +321,8 @@ public class CreateProjectCommand extends Command {
|
|||||||
return new TarInputStream(new GZIPInputStream(is));
|
return new TarInputStream(new GZIPInputStream(is));
|
||||||
} else if (fileName.endsWith(".tar.bz2")) {
|
} else if (fileName.endsWith(".tar.bz2")) {
|
||||||
return new TarInputStream(new CBZip2InputStream(is));
|
return new TarInputStream(new CBZip2InputStream(is));
|
||||||
} else if (fileName.endsWith(".zip")) {
|
|
||||||
return new ZipInputStream(is);
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return new ZipInputStream(is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,12 +339,19 @@ public class CreateProjectCommand extends Command {
|
|||||||
byte[] buffer = new byte[4 * 1024];
|
byte[] buffer = new byte[4 * 1024];
|
||||||
long count = 0;
|
long count = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
try {
|
||||||
while (-1 != (n = input.read(buffer))) {
|
while (-1 != (n = input.read(buffer))) {
|
||||||
output.write(buffer, 0, n);
|
output.write(buffer, 0, n);
|
||||||
count += n;
|
count += n;
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
output.close();
|
output.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
try {
|
||||||
input.close();
|
input.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class EditOneCellCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class EditOneCellProcess extends QuickHistoryEntryProcess {
|
protected static class EditOneCellProcess extends QuickHistoryEntryProcess {
|
||||||
final int rowIndex;
|
final int rowIndex;
|
||||||
final int cellIndex;
|
final int cellIndex;
|
||||||
final Serializable value;
|
final Serializable value;
|
||||||
|
@ -20,7 +20,9 @@ import com.metaweb.gridworks.exporters.XlsExporter;
|
|||||||
import com.metaweb.gridworks.model.Project;
|
import com.metaweb.gridworks.model.Project;
|
||||||
|
|
||||||
public class ExportRowsCommand extends Command {
|
public class ExportRowsCommand extends Command {
|
||||||
static protected Map<String, Exporter> s_formatToExporter = new HashMap<String, Exporter>();
|
|
||||||
|
static final protected Map<String, Exporter> s_formatToExporter = new HashMap<String, Exporter>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
s_formatToExporter.put("tripleloader", new TripleloaderExporter());
|
s_formatToExporter.put("tripleloader", new TripleloaderExporter());
|
||||||
s_formatToExporter.put("html", new HtmlTableExporter());
|
s_formatToExporter.put("html", new HtmlTableExporter());
|
||||||
|
@ -3,6 +3,7 @@ package com.metaweb.gridworks.commands.info;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -32,9 +33,9 @@ public class GetAllProjectMetadataCommand extends Command {
|
|||||||
writer.key("projects");
|
writer.key("projects");
|
||||||
writer.object();
|
writer.object();
|
||||||
Map<Long, ProjectMetadata> m = ProjectManager.singleton.getAllProjectMetadata();
|
Map<Long, ProjectMetadata> m = ProjectManager.singleton.getAllProjectMetadata();
|
||||||
for (Long id : m.keySet()) {
|
for (Entry<Long,ProjectMetadata> e : m.entrySet()) {
|
||||||
writer.key(id.toString());
|
writer.key(e.getKey().toString());
|
||||||
m.get(id).write(writer, options);
|
e.getValue().write(writer, options);
|
||||||
}
|
}
|
||||||
writer.endObject();
|
writer.endObject();
|
||||||
|
|
||||||
|
@ -81,14 +81,14 @@ public class ReconJudgeOneCellCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class JudgeOneCellProcess extends QuickHistoryEntryProcess {
|
protected static class JudgeOneCellProcess extends QuickHistoryEntryProcess {
|
||||||
|
|
||||||
final int rowIndex;
|
final int rowIndex;
|
||||||
final int cellIndex;
|
final int cellIndex;
|
||||||
final Judgment judgment;
|
final Judgment judgment;
|
||||||
final ReconCandidate match;
|
final ReconCandidate match;
|
||||||
Cell newCell;
|
Cell newCell;
|
||||||
|
|
||||||
|
|
||||||
JudgeOneCellProcess(
|
JudgeOneCellProcess(
|
||||||
Project project,
|
Project project,
|
||||||
String briefDescription,
|
String briefDescription,
|
||||||
|
@ -16,7 +16,7 @@ public class Get implements Function {
|
|||||||
if (args.length > 1 && args.length <= 3) {
|
if (args.length > 1 && args.length <= 3) {
|
||||||
Object v = args[0];
|
Object v = args[0];
|
||||||
Object from = args[1];
|
Object from = args[1];
|
||||||
Object to = args.length == 3 ? args[2] : null;
|
Object to = (args.length == 3) ? args[2] : null;
|
||||||
|
|
||||||
if (v != null && from != null) {
|
if (v != null && from != null) {
|
||||||
if (v instanceof HasFields) {
|
if (v instanceof HasFields) {
|
||||||
@ -42,8 +42,7 @@ public class Get implements Function {
|
|||||||
((Object[]) v)[start] :
|
((Object[]) v)[start] :
|
||||||
ExpressionUtils.toObjectList(v).get(start));
|
ExpressionUtils.toObjectList(v).get(start));
|
||||||
} else {
|
} else {
|
||||||
int end = to != null && to instanceof Number ?
|
int end = (to != null && to instanceof Number) ? ((Number) to).intValue() : length;
|
||||||
((Number) to).intValue() : length;
|
|
||||||
|
|
||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
end = length + end;
|
end = length + end;
|
||||||
@ -63,7 +62,7 @@ public class Get implements Function {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String s = (v instanceof String ? (String) v : v.toString());
|
String s = (v instanceof String) ? (String) v : v.toString();
|
||||||
|
|
||||||
int start = ((Number) from).intValue();
|
int start = ((Number) from).intValue();
|
||||||
if (start < 0) {
|
if (start < 0) {
|
||||||
|
@ -15,7 +15,7 @@ public class Slice implements Function {
|
|||||||
if (args.length > 1 && args.length <= 3) {
|
if (args.length > 1 && args.length <= 3) {
|
||||||
Object v = args[0];
|
Object v = args[0];
|
||||||
Object from = args[1];
|
Object from = args[1];
|
||||||
Object to = args.length == 3 ? args[2] : null;
|
Object to = (args.length == 3) ? args[2] : null;
|
||||||
|
|
||||||
if (v != null && from != null && from instanceof Number && (to == null || to instanceof Number)) {
|
if (v != null && from != null && from instanceof Number && (to == null || to instanceof Number)) {
|
||||||
if (v.getClass().isArray() || v instanceof List<?>) {
|
if (v.getClass().isArray() || v instanceof List<?>) {
|
||||||
@ -24,8 +24,7 @@ public class Slice implements Function {
|
|||||||
ExpressionUtils.toObjectList(v).size();
|
ExpressionUtils.toObjectList(v).size();
|
||||||
|
|
||||||
int start = ((Number) from).intValue();
|
int start = ((Number) from).intValue();
|
||||||
int end = to != null && to instanceof Number ?
|
int end = (to != null && to instanceof Number) ? ((Number) to).intValue() : length;
|
||||||
((Number) to).intValue() : length;
|
|
||||||
|
|
||||||
if (start < 0) {
|
if (start < 0) {
|
||||||
start = length + start;
|
start = length + start;
|
||||||
@ -47,7 +46,7 @@ public class Slice implements Function {
|
|||||||
return ExpressionUtils.toObjectList(v).subList(start, end);
|
return ExpressionUtils.toObjectList(v).subList(start, end);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String s = (v instanceof String ? (String) v : v.toString());
|
String s = (v instanceof String) ? (String) v : v.toString();
|
||||||
|
|
||||||
int start = ((Number) from).intValue();
|
int start = ((Number) from).intValue();
|
||||||
if (start < 0) {
|
if (start < 0) {
|
||||||
|
@ -44,6 +44,7 @@ public class ChangeSequence implements Change {
|
|||||||
|
|
||||||
static public Change load(LineNumberReader reader) throws Exception {
|
static public Change load(LineNumberReader reader) throws Exception {
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
|
if (line == null) line = "";
|
||||||
int equal = line.indexOf('=');
|
int equal = line.indexOf('=');
|
||||||
|
|
||||||
assert "count".equals(line.substring(0, equal));
|
assert "count".equals(line.substring(0, equal));
|
||||||
|
@ -196,13 +196,15 @@ public class Project {
|
|||||||
int count = Integer.parseInt(value);
|
int count = Integer.parseInt(value);
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Row row = Row.load(reader.readLine());
|
line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
|
Row row = Row.load(line);
|
||||||
project.rows.add(row);
|
project.rows.add(row);
|
||||||
|
|
||||||
maxCellCount = Math.max(maxCellCount, row.cells.size());
|
maxCellCount = Math.max(maxCellCount, row.cells.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
project.columnModel.setMaxCellIndex(maxCellCount - 1);
|
project.columnModel.setMaxCellIndex(maxCellCount - 1);
|
||||||
project.recomputeRowContextDependencies();
|
project.recomputeRowContextDependencies();
|
||||||
|
@ -15,6 +15,7 @@ import com.metaweb.gridworks.Jsonizable;
|
|||||||
import com.metaweb.gridworks.expr.HasFields;
|
import com.metaweb.gridworks.expr.HasFields;
|
||||||
|
|
||||||
public class Recon implements HasFields, Jsonizable {
|
public class Recon implements HasFields, Jsonizable {
|
||||||
|
|
||||||
static public enum Judgment {
|
static public enum Judgment {
|
||||||
None,
|
None,
|
||||||
Matched,
|
Matched,
|
||||||
@ -41,16 +42,14 @@ public class Recon implements HasFields, Jsonizable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final public int Feature_typeMatch = 0;
|
||||||
|
static final public int Feature_nameMatch = 1;
|
||||||
|
static final public int Feature_nameLevenshtein = 2;
|
||||||
|
static final public int Feature_nameWordDistance = 3;
|
||||||
|
static final public int Feature_max = 4;
|
||||||
|
|
||||||
static public int Feature_typeMatch = 0;
|
static final protected Map<String, Integer> s_featureMap = new HashMap<String, Integer>();
|
||||||
static public int Feature_nameMatch = 1;
|
|
||||||
static public int Feature_nameLevenshtein = 2;
|
|
||||||
static public int Feature_nameWordDistance = 3;
|
|
||||||
static public int Feature_max = 4;
|
|
||||||
|
|
||||||
static protected Map<String, Integer> s_featureMap;
|
|
||||||
static {
|
static {
|
||||||
s_featureMap = new HashMap<String, Integer>();
|
|
||||||
s_featureMap.put("typeMatch", Feature_typeMatch);
|
s_featureMap.put("typeMatch", Feature_typeMatch);
|
||||||
s_featureMap.put("nameMatch", Feature_nameMatch);
|
s_featureMap.put("nameMatch", Feature_nameMatch);
|
||||||
s_featureMap.put("nameLevenshtein", Feature_nameLevenshtein);
|
s_featureMap.put("nameLevenshtein", Feature_nameLevenshtein);
|
||||||
|
@ -4,6 +4,7 @@ import java.io.Writer;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -134,9 +135,9 @@ public class Row implements HasFields, Jsonizable {
|
|||||||
if (options.containsKey("extra")) {
|
if (options.containsKey("extra")) {
|
||||||
Properties extra = (Properties) options.get("extra");
|
Properties extra = (Properties) options.get("extra");
|
||||||
if (extra != null) {
|
if (extra != null) {
|
||||||
for (Object key : extra.keySet()) {
|
for (Entry<Object,Object> e : extra.entrySet()) {
|
||||||
writer.key((String) key);
|
writer.key((String) e.getKey());
|
||||||
writer.value(extra.get(key));
|
writer.value(e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +195,7 @@ public class Row implements HasFields, Jsonizable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Record implements HasFields {
|
protected static class Record implements HasFields {
|
||||||
final int _recordRowIndex;
|
final int _recordRowIndex;
|
||||||
final int _currentRowIndex;
|
final int _currentRowIndex;
|
||||||
|
|
||||||
@ -211,7 +212,7 @@ public class Row implements HasFields, Jsonizable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class RecordCells implements HasFields {
|
protected static class RecordCells implements HasFields {
|
||||||
final int _recordRowIndex;
|
final int _recordRowIndex;
|
||||||
|
|
||||||
protected RecordCells(int recordRowIndex) {
|
protected RecordCells(int recordRowIndex) {
|
||||||
@ -247,7 +248,8 @@ public class Row implements HasFields, Jsonizable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class CellTuple extends ArrayList<Cell> implements HasFields {
|
protected static class CellTuple extends ArrayList<Cell> implements HasFields {
|
||||||
|
|
||||||
private static final long serialVersionUID = -651032866647686293L;
|
private static final long serialVersionUID = -651032866647686293L;
|
||||||
|
|
||||||
public Object getField(String name, Properties bindings) {
|
public Object getField(String name, Properties bindings) {
|
||||||
|
@ -94,7 +94,10 @@ public class ColumnAdditionChange extends ColumnChange {
|
|||||||
|
|
||||||
newCells = new ArrayList<CellAtRow>(newCellCount);
|
newCells = new ArrayList<CellAtRow>(newCellCount);
|
||||||
for (int i = 0; i < newCellCount; i++) {
|
for (int i = 0; i < newCellCount; i++) {
|
||||||
newCells.add(CellAtRow.load(line = reader.readLine()));
|
line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
|
newCells.add(CellAtRow.load(line));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,10 @@ public class ColumnRemovalChange extends ColumnChange {
|
|||||||
|
|
||||||
oldCells = new CellAtRow[oldCellCount];
|
oldCells = new CellAtRow[oldCellCount];
|
||||||
for (int i = 0; i < oldCellCount; i++) {
|
for (int i = 0; i < oldCellCount; i++) {
|
||||||
oldCells[i] = CellAtRow.load(line = reader.readLine());
|
line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
|
oldCells[i] = CellAtRow.load(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,16 +302,20 @@ public class DataExtensionChange implements Change {
|
|||||||
rowIndices = new ArrayList<Integer>(count);
|
rowIndices = new ArrayList<Integer>(count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
rowIndices.add(Integer.parseInt(line));
|
rowIndices.add(Integer.parseInt(line));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if ("columnNameCount".equals(field)) {
|
} else if ("columnNameCount".equals(field)) {
|
||||||
int count = Integer.parseInt(value);
|
int count = Integer.parseInt(value);
|
||||||
|
|
||||||
columnNames = new ArrayList<String>(count);
|
columnNames = new ArrayList<String>(count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
columnNames.add(line);
|
columnNames.add(line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if ("columnTypeCount".equals(field)) {
|
} else if ("columnTypeCount".equals(field)) {
|
||||||
int count = Integer.parseInt(value);
|
int count = Integer.parseInt(value);
|
||||||
|
|
||||||
@ -327,6 +331,8 @@ public class DataExtensionChange implements Change {
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
|
|
||||||
|
if (line == null) continue;
|
||||||
|
|
||||||
int rowCount = Integer.parseInt(line);
|
int rowCount = Integer.parseInt(line);
|
||||||
Object[][] data = new Object[rowCount][];
|
Object[][] data = new Object[rowCount][];
|
||||||
|
|
||||||
@ -358,17 +364,21 @@ public class DataExtensionChange implements Change {
|
|||||||
oldRows = new ArrayList<Row>(count);
|
oldRows = new ArrayList<Row>(count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
oldRows.add(Row.load(line));
|
oldRows.add(Row.load(line));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if ("newRowCount".equals(field)) {
|
} else if ("newRowCount".equals(field)) {
|
||||||
int count = Integer.parseInt(value);
|
int count = Integer.parseInt(value);
|
||||||
|
|
||||||
newRows = new ArrayList<Row>(count);
|
newRows = new ArrayList<Row>(count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
newRows.add(Row.load(line));
|
newRows.add(Row.load(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,18 +67,21 @@ public class MassRowChange implements Change {
|
|||||||
oldRows = new ArrayList<Row>(count);
|
oldRows = new ArrayList<Row>(count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
oldRows.add(Row.load(line));
|
oldRows.add(Row.load(line));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if ("newRowCount".equals(field)) {
|
} else if ("newRowCount".equals(field)) {
|
||||||
int count = Integer.parseInt(line.substring(equal + 1));
|
int count = Integer.parseInt(line.substring(equal + 1));
|
||||||
|
|
||||||
newRows = new ArrayList<Row>(count);
|
newRows = new ArrayList<Row>(count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
|
if (line != null) {
|
||||||
newRows.add(Row.load(line));
|
newRows.add(Row.load(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MassRowChange change = new MassRowChange(newRows);
|
MassRowChange change = new MassRowChange(newRows);
|
||||||
|
@ -265,8 +265,6 @@ public class HeuristicReconConfig extends ReconConfig {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.gc();
|
|
||||||
|
|
||||||
return recons;
|
return recons;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,8 +359,6 @@ public class HeuristicReconConfig extends ReconConfig {
|
|||||||
recons.add(recon);
|
recons.add(recon);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.gc();
|
|
||||||
|
|
||||||
return recons;
|
return recons;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,9 +437,8 @@ public class HeuristicReconConfig extends ReconConfig {
|
|||||||
return common / longWords.size();
|
return common / longWords.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected Set<String> s_stopWords;
|
static final protected Set<String> s_stopWords = new HashSet<String>();
|
||||||
static {
|
static {
|
||||||
s_stopWords = new HashSet<String>();
|
|
||||||
s_stopWords.add("the");
|
s_stopWords.add("the");
|
||||||
s_stopWords.add("a");
|
s_stopWords.add("a");
|
||||||
s_stopWords.add("and");
|
s_stopWords.add("and");
|
||||||
|
@ -64,7 +64,7 @@ public class MultiValuedCellJoinOperation extends AbstractOperation {
|
|||||||
int cellIndex = column.getCellIndex();
|
int cellIndex = column.getCellIndex();
|
||||||
|
|
||||||
Column keyColumn = project.columnModel.getColumnByName(_keyColumnName);
|
Column keyColumn = project.columnModel.getColumnByName(_keyColumnName);
|
||||||
if (column == null) {
|
if (keyColumn == null) {
|
||||||
throw new Exception("No key column named " + _keyColumnName);
|
throw new Exception("No key column named " + _keyColumnName);
|
||||||
}
|
}
|
||||||
int keyCellIndex = keyColumn.getCellIndex();
|
int keyCellIndex = keyColumn.getCellIndex();
|
||||||
|
@ -70,7 +70,7 @@ public class MultiValuedCellSplitOperation extends AbstractOperation {
|
|||||||
int cellIndex = column.getCellIndex();
|
int cellIndex = column.getCellIndex();
|
||||||
|
|
||||||
Column keyColumn = project.columnModel.getColumnByName(_keyColumnName);
|
Column keyColumn = project.columnModel.getColumnByName(_keyColumnName);
|
||||||
if (column == null) {
|
if (keyColumn == null) {
|
||||||
throw new Exception("No key column named " + _keyColumnName);
|
throw new Exception("No key column named " + _keyColumnName);
|
||||||
}
|
}
|
||||||
int keyCellIndex = keyColumn.getCellIndex();
|
int keyCellIndex = keyColumn.getCellIndex();
|
||||||
|
@ -10,8 +10,9 @@ import com.metaweb.gridworks.model.AbstractOperation;
|
|||||||
import com.metaweb.gridworks.model.Project;
|
import com.metaweb.gridworks.model.Project;
|
||||||
|
|
||||||
public abstract class OperationRegistry {
|
public abstract class OperationRegistry {
|
||||||
static public Map<String, Class<? extends AbstractOperation>> s_opNameToClass;
|
|
||||||
static public Map<Class<? extends AbstractOperation>, String> s_opClassToName;
|
static final public Map<String, Class<? extends AbstractOperation>> s_opNameToClass = new HashMap<String, Class<? extends AbstractOperation>>();
|
||||||
|
static final public Map<Class<? extends AbstractOperation>, String> s_opClassToName = new HashMap<Class<? extends AbstractOperation>, String>();
|
||||||
|
|
||||||
static protected void register(String name, Class<? extends AbstractOperation> klass) {
|
static protected void register(String name, Class<? extends AbstractOperation> klass) {
|
||||||
s_opNameToClass.put(name, klass);
|
s_opNameToClass.put(name, klass);
|
||||||
@ -19,9 +20,6 @@ public abstract class OperationRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
s_opNameToClass = new HashMap<String, Class<? extends AbstractOperation>>();
|
|
||||||
s_opClassToName = new HashMap<Class<? extends AbstractOperation>, String>();
|
|
||||||
|
|
||||||
register("recon", ReconOperation.class);
|
register("recon", ReconOperation.class);
|
||||||
register("recon-mark-new-topics", ReconMarkNewTopicsOperation.class);
|
register("recon-mark-new-topics", ReconMarkNewTopicsOperation.class);
|
||||||
register("recon-match-best-candidates", ReconMatchBestCandidatesOperation.class);
|
register("recon-match-best-candidates", ReconMatchBestCandidatesOperation.class);
|
||||||
|
@ -90,13 +90,8 @@ public class TripleLoaderTransposedNodeFactory implements TransposedNodeFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected class AnonymousTransposedNode extends TransposedNodeWithChildren {
|
protected class AnonymousTransposedNode extends TransposedNodeWithChildren {
|
||||||
AnonymousNode node;
|
|
||||||
|
|
||||||
protected AnonymousTransposedNode(
|
protected AnonymousTransposedNode(AnonymousNode node) { }
|
||||||
AnonymousNode node
|
|
||||||
) {
|
|
||||||
this.node = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String write(String subject, String predicate) {
|
public String write(String subject, String predicate) {
|
||||||
if (children.size() == 0 || subject == null) {
|
if (children.size() == 0 || subject == null) {
|
||||||
@ -116,7 +111,7 @@ public class TripleLoaderTransposedNodeFactory implements TransposedNodeFactory
|
|||||||
sb.append(", ");
|
sb.append(", ");
|
||||||
}
|
}
|
||||||
sb.append("\"" + properties.get(i).id + "\": ");
|
sb.append("\"" + properties.get(i).id + "\": ");
|
||||||
sb.append(s instanceof String ? JSONObject.quote(s) : s.toString());
|
sb.append(JSONObject.quote(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb.append(" }");
|
sb.append(" }");
|
||||||
|
@ -20,7 +20,8 @@ import org.json.JSONObject;
|
|||||||
import org.json.JSONTokener;
|
import org.json.JSONTokener;
|
||||||
|
|
||||||
public class ParsingUtilities {
|
public class ParsingUtilities {
|
||||||
static public SimpleDateFormat s_sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
|
||||||
|
static final public SimpleDateFormat s_sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
|
|
||||||
static public Properties parseUrlParameters(HttpServletRequest request) {
|
static public Properties parseUrlParameters(HttpServletRequest request) {
|
||||||
Properties options = new Properties();
|
Properties options = new Properties();
|
||||||
|
@ -8,7 +8,7 @@ public abstract class SignalHandler {
|
|||||||
try {
|
try {
|
||||||
_wrapper = new SignalHandlerWrapper(signalName, this);
|
_wrapper = new SignalHandlerWrapper(signalName, this);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
new java.lang.RuntimeException("Signal handling facilities are not available in this JVM.");
|
throw new java.lang.RuntimeException("Signal handling facilities are not available in this JVM.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
thirdparty/apache-ant-1.8.0.tar.gz
vendored
BIN
thirdparty/apache-ant-1.8.0.tar.gz
vendored
Binary file not shown.
BIN
thirdparty/jarbundler-2.1.0.jar
vendored
BIN
thirdparty/jarbundler-2.1.0.jar
vendored
Binary file not shown.
BIN
thirdparty/launch4j-3.0.1-macosx.tar.gz
vendored
BIN
thirdparty/launch4j-3.0.1-macosx.tar.gz
vendored
Binary file not shown.
Loading…
Reference in New Issue
Block a user