cleanups (no functional changes)
this makes pmd and javac on linux happier git-svn-id: http://google-refine.googlecode.com/svn/trunk@427 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
be084ff0da
commit
7526c4e582
@ -110,10 +110,8 @@ public class InterProjectModel {
|
||||
|
||||
for (Row fromRow : fromProject.rows) {
|
||||
Object value = fromRow.getCellValue(fromColumn.getCellIndex());
|
||||
if (ExpressionUtils.isNonBlankData(value)) {
|
||||
if (!join.valueToRowIndices.containsKey(value)) {
|
||||
join.valueToRowIndices.put(value, new ArrayList<Integer>());
|
||||
}
|
||||
if (ExpressionUtils.isNonBlankData(value) && !join.valueToRowIndices.containsKey(value)) {
|
||||
join.valueToRowIndices.put(value, new ArrayList<Integer>());
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,10 +120,8 @@ public class InterProjectModel {
|
||||
Row toRow = toProject.rows.get(r);
|
||||
|
||||
Object value = toRow.getCellValue(toColumn.getCellIndex());
|
||||
if (ExpressionUtils.isNonBlankData(value)) {
|
||||
if (join.valueToRowIndices.containsKey(value)) {
|
||||
join.valueToRowIndices.get(value).add(r);
|
||||
}
|
||||
if (ExpressionUtils.isNonBlankData(value) && join.valueToRowIndices.containsKey(value)) {
|
||||
join.valueToRowIndices.get(value).add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,16 +49,15 @@ public class ConjunctiveFilteredRows implements FilteredRows {
|
||||
// and this row is a dependent row since it's not a record row
|
||||
row.recordIndex < 0 &&
|
||||
row.contextRows != null &&
|
||||
row.contextRows.size() > 0
|
||||
row.contextRows.size() > 0 &&
|
||||
|
||||
row.contextRows.get(0) == lastRecordRowAcceptedRowIndex
|
||||
) {
|
||||
// this row depends on the last previously matched record row,
|
||||
// so we visit it as well as a dependent row
|
||||
|
||||
if (row.contextRows.get(0) == lastRecordRowAcceptedRowIndex) {
|
||||
// this row depends on the last previously matched record row,
|
||||
// so we visit it as well as a dependent row
|
||||
|
||||
visitor.visit(project, rowIndex, row, false, true);
|
||||
lastVisitedRowRowIndex = rowIndex;
|
||||
}
|
||||
visitor.visit(project, rowIndex, row, false, true);
|
||||
lastVisitedRowRowIndex = rowIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,6 @@ import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.Properties;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import com.metaweb.gridworks.ProjectManager;
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.browsing.FilteredRows;
|
||||
@ -27,7 +25,7 @@ public class HtmlTableExporter implements Exporter {
|
||||
|
||||
public void export(Project project, Properties options, Engine engine,
|
||||
OutputStream outputStream) throws IOException {
|
||||
throw new NotImplementedException();
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
public void export(Project project, Properties options, Engine engine, Writer writer) throws IOException {
|
||||
|
@ -5,8 +5,6 @@ import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.Properties;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.model.Project;
|
||||
import com.metaweb.gridworks.protograph.Protograph;
|
||||
@ -24,7 +22,7 @@ public class TripleloaderExporter implements Exporter {
|
||||
|
||||
public void export(Project project, Properties options, Engine engine,
|
||||
OutputStream outputStream) throws IOException {
|
||||
throw new NotImplementedException();
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
public void export(Project project, Properties options, Engine engine,
|
||||
|
@ -5,8 +5,6 @@ import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.Properties;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.browsing.FilteredRows;
|
||||
import com.metaweb.gridworks.browsing.RowVisitor;
|
||||
@ -26,7 +24,7 @@ public class TsvExporter implements Exporter {
|
||||
|
||||
public void export(Project project, Properties options, Engine engine,
|
||||
OutputStream outputStream) throws IOException {
|
||||
throw new NotImplementedException();
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
public void export(Project project, Properties options, Engine engine, Writer writer) throws IOException {
|
||||
|
@ -12,8 +12,6 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import com.metaweb.gridworks.ProjectManager;
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.browsing.FilteredRows;
|
||||
@ -33,7 +31,7 @@ public class XlsExporter implements Exporter {
|
||||
}
|
||||
|
||||
public void export(Project project, Properties options, Engine engine, Writer writer) throws IOException {
|
||||
throw new NotImplementedException();
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
public void export(Project project, Properties options, Engine engine,
|
||||
|
@ -20,28 +20,26 @@ public class Diff implements Function {
|
||||
if (o1 != null && o2 != null) {
|
||||
if (o1 instanceof String && o2 instanceof String) {
|
||||
return StringUtils.difference((String) o1,(String) o2);
|
||||
} else if (o1 instanceof Calendar) {
|
||||
if (args.length == 3) {
|
||||
Object o3 = args[3];
|
||||
if (o3 != null && o3 instanceof String) {
|
||||
try {
|
||||
String unit = ((String) o3).toLowerCase();
|
||||
Calendar c1 = (Calendar) o1;
|
||||
Calendar c2 = (o2 instanceof Calendar) ? (Calendar) o2 : CalendarParser.parse((o2 instanceof String) ? (String) o2 : o2.toString());
|
||||
long delta = (c1.getTimeInMillis() - c2.getTimeInMillis()) / 1000;
|
||||
if ("seconds".equals(unit)) return delta;
|
||||
delta /= 60;
|
||||
if ("minutes".equals(unit)) return delta;
|
||||
delta /= 60;
|
||||
if ("hours".equals(unit)) return delta;
|
||||
long days = delta / 24;
|
||||
if ("days".equals(unit)) return days;
|
||||
if ("weeks".equals(unit)) return days / 7;
|
||||
if ("months".equals(unit)) return days / 30;
|
||||
if ("years".equals(unit)) return days / 365;
|
||||
} catch (CalendarParserException e) {
|
||||
// we should throw at this point because it's important to know that date parsing failed
|
||||
}
|
||||
} else if (o1 instanceof Calendar && args.length == 3) {
|
||||
Object o3 = args[3];
|
||||
if (o3 != null && o3 instanceof String) {
|
||||
try {
|
||||
String unit = ((String) o3).toLowerCase();
|
||||
Calendar c1 = (Calendar) o1;
|
||||
Calendar c2 = (o2 instanceof Calendar) ? (Calendar) o2 : CalendarParser.parse((o2 instanceof String) ? (String) o2 : o2.toString());
|
||||
long delta = (c1.getTimeInMillis() - c2.getTimeInMillis()) / 1000;
|
||||
if ("seconds".equals(unit)) return delta;
|
||||
delta /= 60;
|
||||
if ("minutes".equals(unit)) return delta;
|
||||
delta /= 60;
|
||||
if ("hours".equals(unit)) return delta;
|
||||
long days = delta / 24;
|
||||
if ("days".equals(unit)) return days;
|
||||
if ("weeks".equals(unit)) return days / 7;
|
||||
if ("months".equals(unit)) return days / 30;
|
||||
if ("years".equals(unit)) return days / 365;
|
||||
} catch (CalendarParserException e) {
|
||||
// we should throw at this point because it's important to know that date parsing failed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,14 +36,12 @@ public class ColumnGroup implements Jsonizable {
|
||||
writer.key("columnSpan"); writer.value(columnSpan);
|
||||
writer.key("keyColumnIndex"); writer.value(keyColumnIndex);
|
||||
|
||||
if (!"save".equals(options.get("mode"))) {
|
||||
if (subgroups != null && subgroups.size() > 0) {
|
||||
writer.key("subgroups"); writer.array();
|
||||
for (ColumnGroup g : subgroups) {
|
||||
g.write(writer, options);
|
||||
}
|
||||
writer.endArray();
|
||||
if (!"save".equals(options.get("mode")) && (subgroups != null) && (subgroups.size() > 0)) {
|
||||
writer.key("subgroups"); writer.array();
|
||||
for (ColumnGroup g : subgroups) {
|
||||
g.write(writer, options);
|
||||
}
|
||||
writer.endArray();
|
||||
}
|
||||
writer.endObject();
|
||||
}
|
||||
|
@ -69,14 +69,10 @@ public class CellChange implements Change {
|
||||
row = Integer.parseInt(value);
|
||||
} else if ("cell".equals(field)) {
|
||||
cellIndex = Integer.parseInt(value);
|
||||
} else if ("new".equals(field)) {
|
||||
if (value.length() > 0) {
|
||||
newCell = Cell.load(value);
|
||||
}
|
||||
} else if ("old".equals(field)) {
|
||||
if (value.length() > 0) {
|
||||
oldCell = Cell.load(value);
|
||||
}
|
||||
} else if ("new".equals(field) && value.length() > 0) {
|
||||
newCell = Cell.load(value);
|
||||
} else if ("old".equals(field) && value.length() > 0) {
|
||||
oldCell = Cell.load(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,6 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONWriter;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import com.metaweb.gridworks.model.Cell;
|
||||
import com.metaweb.gridworks.model.Project;
|
||||
import com.metaweb.gridworks.model.Recon;
|
||||
@ -36,13 +34,12 @@ public class DataExtensionReconConfig extends StrictReconConfig {
|
||||
@Override
|
||||
public ReconJob createJob(Project project, int rowIndex, Row row,
|
||||
String columnName, Cell cell) {
|
||||
|
||||
throw new NotImplementedException();
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
throw new NotImplementedException();
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
public void write(JSONWriter writer, Properties options)
|
||||
@ -56,12 +53,12 @@ public class DataExtensionReconConfig extends StrictReconConfig {
|
||||
|
||||
@Override
|
||||
public List<Recon> batchRecon(List<ReconJob> jobs) {
|
||||
throw new NotImplementedException();
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBriefDescription(Project project, String columnName) {
|
||||
throw new NotImplementedException();
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,9 +25,7 @@ public class SaveProtographOperation extends AbstractOperation {
|
||||
);
|
||||
}
|
||||
|
||||
public SaveProtographOperation(
|
||||
Protograph protograph
|
||||
) {
|
||||
public SaveProtographOperation(Protograph protograph) {
|
||||
_protograph = protograph;
|
||||
}
|
||||
|
||||
@ -55,8 +53,8 @@ public class SaveProtographOperation extends AbstractOperation {
|
||||
}
|
||||
|
||||
static public class ProtographChange implements Change {
|
||||
final protected Protograph _newProtograph;
|
||||
protected Protograph _oldProtograph;
|
||||
final protected Protograph _newProtograph;
|
||||
protected Protograph _oldProtograph;
|
||||
|
||||
public ProtographChange(Protograph protograph) {
|
||||
_newProtograph = protograph;
|
||||
@ -91,16 +89,11 @@ public class SaveProtographOperation extends AbstractOperation {
|
||||
CharSequence field = line.subSequence(0, equal);
|
||||
String value = line.substring(equal + 1);
|
||||
|
||||
if ("oldProtograph".equals(field)) {
|
||||
if (value.length() > 0) {
|
||||
oldProtograph = Protograph.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
}
|
||||
} else if ("newProtograph".equals(field)) {
|
||||
if (value.length() > 0) {
|
||||
newProtograph = Protograph.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
}
|
||||
if ("oldProtograph".equals(field) && value.length() > 0) {
|
||||
oldProtograph = Protograph.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
} else if ("newProtograph".equals(field) && value.length() > 0) {
|
||||
newProtograph = Protograph.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ProtographChange change = new ProtographChange(newProtograph);
|
||||
|
@ -81,21 +81,19 @@ public class Protograph implements Jsonizable {
|
||||
node = new AnonymousNode(reconstructType(o.getJSONObject("type")));
|
||||
}
|
||||
|
||||
if (node != null) {
|
||||
if (node instanceof NodeWithLinks && o.has("links")) {
|
||||
NodeWithLinks node2 = (NodeWithLinks) node;
|
||||
if (node != null && node instanceof NodeWithLinks && o.has("links")) {
|
||||
NodeWithLinks node2 = (NodeWithLinks) node;
|
||||
|
||||
JSONArray links = o.getJSONArray("links");
|
||||
int linkCount = links.length();
|
||||
JSONArray links = o.getJSONArray("links");
|
||||
int linkCount = links.length();
|
||||
|
||||
for (int j = 0; j < linkCount; j++) {
|
||||
JSONObject oLink = links.getJSONObject(j);
|
||||
for (int j = 0; j < linkCount; j++) {
|
||||
JSONObject oLink = links.getJSONObject(j);
|
||||
|
||||
node2.addLink(new Link(
|
||||
reconstructProperty(oLink.getJSONObject("property")),
|
||||
reconstructNode(oLink.getJSONObject("target"))
|
||||
));
|
||||
}
|
||||
node2.addLink(new Link(
|
||||
reconstructProperty(oLink.getJSONObject("property")),
|
||||
reconstructNode(oLink.getJSONObject("target"))
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,9 +121,7 @@ public class Protograph implements Jsonizable {
|
||||
);
|
||||
}
|
||||
|
||||
public void write(JSONWriter writer, Properties options)
|
||||
throws JSONException {
|
||||
|
||||
public void write(JSONWriter writer, Properties options) throws JSONException {
|
||||
writer.object();
|
||||
writer.key("rootNodes"); writer.array();
|
||||
|
||||
|
@ -55,11 +55,10 @@ public class Transposer {
|
||||
Column column = project.columnModel.getColumnByName(node2.columnName);
|
||||
Cell cell = row.getCell(column.getCellIndex());
|
||||
if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
|
||||
if (node2 instanceof CellTopicNode) {
|
||||
if (!((CellTopicNode) node2).createForNoReconMatch &&
|
||||
(cell.recon == null || cell.recon.judgment == Judgment.None)) {
|
||||
if (node2 instanceof CellTopicNode &&
|
||||
!((CellTopicNode) node2).createForNoReconMatch &&
|
||||
(cell.recon == null || cell.recon.judgment == Judgment.None)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
context.count++;
|
||||
|
@ -37,7 +37,10 @@ import com.metaweb.util.threads.ThreadPoolExecutorAdapter;
|
||||
|
||||
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 int DEFAULT_PORT = 3333;
|
||||
|
||||
static private File tempDir;
|
||||
|
||||
private static Logger root = Logger.getRootLogger();
|
||||
@ -64,7 +67,7 @@ public class Gridworks {
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
return version;
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
public static File getTempFile(String name) {
|
||||
@ -99,8 +102,8 @@ public class Gridworks {
|
||||
|
||||
public void init(String[] args) throws Exception {
|
||||
|
||||
int port = Configurations.getInteger("gridworks.port",3333);
|
||||
String host = Configurations.get("gridworks.host","127.0.0.1");
|
||||
int port = Configurations.getInteger("gridworks.port",DEFAULT_PORT);
|
||||
String host = Configurations.get("gridworks.host",DEFAULT_HOST);
|
||||
|
||||
GridworksServer server = new GridworksServer();
|
||||
server.init(host,port);
|
||||
|
Loading…
Reference in New Issue
Block a user