Refactor to break up huge method. Get rid of autogenerated comments. No functional changes.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2473 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
7002737fd3
commit
00d8827d16
@ -95,14 +95,10 @@ public class Transposer {
|
||||
|
||||
@Override
|
||||
public void start(Project project) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(Project project) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public RowVisitor init(
|
||||
@ -135,104 +131,15 @@ public class Transposer {
|
||||
Link link = context.parent == null ? null : context.link;
|
||||
|
||||
if (node instanceof CellNode) {
|
||||
CellNode node2 = (CellNode) node;
|
||||
for (String columnName : node2.columnNames) {
|
||||
Column column = project.columnModel.getColumnByName(columnName);
|
||||
if (column != null) {
|
||||
int cellIndex = column.getCellIndex();
|
||||
|
||||
Cell cell = row.getCell(cellIndex);
|
||||
if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
|
||||
if (node2 instanceof CellTopicNode &&
|
||||
(cell.recon == null || cell.recon.judgment == Judgment.None)) {
|
||||
if (!descendCellNode(project, nodeFactory, rowIndex, row, node, context, tnodes, link)) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.count++;
|
||||
if (context.limit > 0 && context.count > context.limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.parent == null) {
|
||||
tnodes.add(nodeFactory.transposeCellNode(
|
||||
null,
|
||||
link,
|
||||
node2,
|
||||
rowIndex,
|
||||
cellIndex,
|
||||
cell
|
||||
));
|
||||
} else {
|
||||
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||
tnodes.add(nodeFactory.transposeCellNode(
|
||||
parentNode,
|
||||
link,
|
||||
node2,
|
||||
rowIndex,
|
||||
cellIndex,
|
||||
cell
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (node instanceof AnonymousNode) {
|
||||
if (context.parent == null) {
|
||||
tnodes.add(nodeFactory.transposeAnonymousNode(
|
||||
null,
|
||||
link,
|
||||
(AnonymousNode) node,
|
||||
rowIndex
|
||||
));
|
||||
} else {
|
||||
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||
tnodes.add(nodeFactory.transposeAnonymousNode(
|
||||
parentNode,
|
||||
link,
|
||||
(AnonymousNode) node,
|
||||
rowIndex
|
||||
));
|
||||
}
|
||||
}
|
||||
} else if (node instanceof AnonymousNode) {
|
||||
descendAnonymousNode(nodeFactory, rowIndex, node, context, tnodes, link);
|
||||
} else if (node instanceof FreebaseTopicNode) {
|
||||
if (context.parent == null) {
|
||||
tnodes.add(nodeFactory.transposeTopicNode(
|
||||
null,
|
||||
link,
|
||||
(FreebaseTopicNode) node,
|
||||
rowIndex
|
||||
));
|
||||
} else {
|
||||
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||
tnodes.add(nodeFactory.transposeTopicNode(
|
||||
parentNode,
|
||||
link,
|
||||
(FreebaseTopicNode) node,
|
||||
rowIndex
|
||||
));
|
||||
}
|
||||
}
|
||||
descendFreebaseTopicNode(nodeFactory, rowIndex, node, context, tnodes, link);
|
||||
} else if (node instanceof ValueNode) {
|
||||
if (context.parent == null) {
|
||||
tnodes.add(nodeFactory.transposeValueNode(
|
||||
null,
|
||||
link,
|
||||
(ValueNode) node,
|
||||
rowIndex
|
||||
));
|
||||
} else {
|
||||
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||
tnodes.add(nodeFactory.transposeValueNode(
|
||||
parentNode,
|
||||
link,
|
||||
(ValueNode) node,
|
||||
rowIndex
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
descendValueNode(nodeFactory, rowIndex, node, context, tnodes, link);
|
||||
}
|
||||
|
||||
if (tnodes.size() > 0) {
|
||||
@ -261,6 +168,116 @@ public class Transposer {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean descendCellNode(Project project, TransposedNodeFactory nodeFactory, int rowIndex, Row row,
|
||||
Node node, Context context, List<TransposedNode> tnodes, Link link) {
|
||||
CellNode node2 = (CellNode) node;
|
||||
for (String columnName : node2.columnNames) {
|
||||
Column column = project.columnModel.getColumnByName(columnName);
|
||||
if (column != null) {
|
||||
int cellIndex = column.getCellIndex();
|
||||
|
||||
Cell cell = row.getCell(cellIndex);
|
||||
if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
|
||||
if (node2 instanceof CellTopicNode &&
|
||||
(cell.recon == null || cell.recon.judgment == Judgment.None)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
context.count++;
|
||||
if (context.limit > 0 && context.count > context.limit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.parent == null) {
|
||||
tnodes.add(nodeFactory.transposeCellNode(
|
||||
null,
|
||||
link,
|
||||
node2,
|
||||
rowIndex,
|
||||
cellIndex,
|
||||
cell
|
||||
));
|
||||
} else {
|
||||
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||
tnodes.add(nodeFactory.transposeCellNode(
|
||||
parentNode,
|
||||
link,
|
||||
node2,
|
||||
rowIndex,
|
||||
cellIndex,
|
||||
cell
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void descendAnonymousNode(TransposedNodeFactory nodeFactory, int rowIndex, Node node,
|
||||
Context context, List<TransposedNode> tnodes, Link link) {
|
||||
if (context.parent == null) {
|
||||
tnodes.add(nodeFactory.transposeAnonymousNode(
|
||||
null,
|
||||
link,
|
||||
(AnonymousNode) node,
|
||||
rowIndex
|
||||
));
|
||||
} else {
|
||||
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||
tnodes.add(nodeFactory.transposeAnonymousNode(
|
||||
parentNode,
|
||||
link,
|
||||
(AnonymousNode) node,
|
||||
rowIndex
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void descendFreebaseTopicNode(TransposedNodeFactory nodeFactory, int rowIndex, Node node,
|
||||
Context context, List<TransposedNode> tnodes, Link link) {
|
||||
if (context.parent == null) {
|
||||
tnodes.add(nodeFactory.transposeTopicNode(
|
||||
null,
|
||||
link,
|
||||
(FreebaseTopicNode) node,
|
||||
rowIndex
|
||||
));
|
||||
} else {
|
||||
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||
tnodes.add(nodeFactory.transposeTopicNode(
|
||||
parentNode,
|
||||
link,
|
||||
(FreebaseTopicNode) node,
|
||||
rowIndex
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void descendValueNode(TransposedNodeFactory nodeFactory, int rowIndex, Node node, Context context,
|
||||
List<TransposedNode> tnodes, Link link) {
|
||||
if (context.parent == null) {
|
||||
tnodes.add(nodeFactory.transposeValueNode(
|
||||
null,
|
||||
link,
|
||||
(ValueNode) node,
|
||||
rowIndex
|
||||
));
|
||||
} else {
|
||||
for (TransposedNode parentNode : context.parent.transposedNodes) {
|
||||
tnodes.add(nodeFactory.transposeValueNode(
|
||||
parentNode,
|
||||
link,
|
||||
(ValueNode) node,
|
||||
rowIndex
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Context {
|
||||
List<TransposedNode> transposedNodes = new LinkedList<TransposedNode>();
|
||||
List<Context> subContexts;
|
||||
|
Loading…
Reference in New Issue
Block a user