Add debugging info - mostly toString() methods for types missing them
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2343 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
b2781bda3f
commit
ab950689dd
@ -39,6 +39,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.refine.ProjectMetadata;
|
||||
import com.google.refine.expr.ExpressionUtils;
|
||||
@ -51,6 +53,7 @@ import com.google.refine.model.Row;
|
||||
import com.google.refine.util.JSONUtilities;
|
||||
|
||||
abstract public class TabularImportingParserBase extends ImportingParserBase {
|
||||
private final static Logger logger = LoggerFactory.getLogger("ImportingParserBase");
|
||||
static public interface TableDataReader {
|
||||
public List<Object> getNextRowOfCells() throws IOException;
|
||||
}
|
||||
@ -114,6 +117,7 @@ abstract public class TabularImportingParserBase extends ImportingParserBase {
|
||||
0, new Column(project.columnModel.allocateNewCellIndex(), fileNameColumnName), false);
|
||||
} catch (ModelException e) {
|
||||
// Ignore: We already checked for duplicate name.
|
||||
logger.info("ModelException",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ public class ImportColumnGroup extends ImportVertical {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("name=%s, columns={%s}, subgroups={{%s}}",
|
||||
name,StringUtils.join(columns.keySet(), ','),
|
||||
return String.format("name=%s, nextRowIndex=%d, columns={%s}, subgroups={{%s}}",
|
||||
name,nextRowIndex,StringUtils.join(columns.keySet(), ','),
|
||||
StringUtils.join(subgroups.keySet(),','));
|
||||
}
|
||||
}
|
@ -5,4 +5,9 @@ abstract class ImportVertical {
|
||||
public int nonBlankCount;
|
||||
|
||||
abstract void tabulate();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + ":" + nonBlankCount;
|
||||
}
|
||||
}
|
@ -34,6 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
package com.google.refine.importers.tree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -276,7 +277,7 @@ public class XmlImportUtilities extends TreeImportUtilities {
|
||||
ImportColumnGroup rootColumnGroup,
|
||||
int limit
|
||||
) throws TreeReaderException {
|
||||
logger.trace("findRecord(Project, TreeReader, String[], int, ImportColumnGroup");
|
||||
logger.trace("findRecord(Project, TreeReader, String[], int, ImportColumnGroup - path:"+Arrays.toString(recordPath));
|
||||
|
||||
if(parser.current() == Token.Ignorable){//XMLStreamConstants.START_DOCUMENT){
|
||||
logger.warn("Cannot use findRecord method for START_DOCUMENT event");
|
||||
@ -342,12 +343,12 @@ public class XmlImportUtilities extends TreeImportUtilities {
|
||||
logger.trace("processRecord(Project,TreeReader,ImportColumnGroup)");
|
||||
ImportRecord record = new ImportRecord();
|
||||
|
||||
processSubRecord(project, parser, rootColumnGroup, record);
|
||||
processSubRecord(project, parser, rootColumnGroup, record, 0);
|
||||
addImportRecordToProject(record, project);
|
||||
}
|
||||
|
||||
/**
|
||||
* processRecord parses Tree data for a single element and it's sub-elements,
|
||||
* processFieldAsRecord parses Tree data for a single element and it's sub-elements,
|
||||
* adding the parsed data as a row to the project
|
||||
* @param project
|
||||
* @param parser
|
||||
@ -408,9 +409,10 @@ public class XmlImportUtilities extends TreeImportUtilities {
|
||||
Project project,
|
||||
TreeReader parser,
|
||||
ImportColumnGroup columnGroup,
|
||||
ImportRecord record
|
||||
ImportRecord record,
|
||||
int level
|
||||
) throws TreeReaderException {
|
||||
logger.trace("processSubRecord(Project,TreeReader,ImportColumnGroup,ImportRecord)");
|
||||
logger.trace("processSubRecord(Project,TreeReader,ImportColumnGroup,ImportRecord) lvl:"+level+" "+columnGroup);
|
||||
|
||||
if(parser.current() == Token.Ignorable) {
|
||||
return;
|
||||
@ -444,7 +446,8 @@ public class XmlImportUtilities extends TreeImportUtilities {
|
||||
project,
|
||||
parser,
|
||||
thisColumnGroup,
|
||||
record
|
||||
record,
|
||||
level+1
|
||||
);
|
||||
} else if (//eventType == XMLStreamConstants.CDATA ||
|
||||
eventType == Token.Value) { //XMLStreamConstants.CHARACTERS) {
|
||||
@ -464,6 +467,8 @@ public class XmlImportUtilities extends TreeImportUtilities {
|
||||
}
|
||||
} else if (eventType == Token.EndEntity) {
|
||||
break;
|
||||
} else if (eventType == Token.Ignorable) {
|
||||
continue;
|
||||
} else {
|
||||
logger.info("unknown event type " + eventType);
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
package com.google.refine.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@ -41,11 +42,15 @@ import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.refine.Jsonizable;
|
||||
import com.google.refine.expr.ExpressionUtils;
|
||||
|
||||
public class RecordModel implements Jsonizable {
|
||||
final static Logger logger = LoggerFactory.getLogger("RecordModel");
|
||||
|
||||
final static public class CellDependency {
|
||||
final public int rowIndex;
|
||||
final public int cellIndex;
|
||||
@ -57,7 +62,7 @@ public class RecordModel implements Jsonizable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return rowIndex+":"+cellIndex;
|
||||
return rowIndex+","+cellIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,6 +70,11 @@ public class RecordModel implements Jsonizable {
|
||||
public int recordIndex;
|
||||
public CellDependency[] cellDependencies;
|
||||
public List<Integer> contextRows;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Idx: "+recordIndex+" CellDeps: "+Arrays.toString(cellDependencies)+" Rows:"+contextRows;
|
||||
}
|
||||
}
|
||||
|
||||
protected List<RowDependency> _rowDependencies;
|
||||
@ -232,8 +242,22 @@ public class RecordModel implements Jsonizable {
|
||||
}
|
||||
});
|
||||
|
||||
dumpKeyedGroups(keyedGroups, columnModel); // for debug
|
||||
|
||||
return keyedGroups;
|
||||
}
|
||||
|
||||
// debugging helper
|
||||
private void dumpKeyedGroups(List<KeyedGroup> groups, ColumnModel columnModel) {
|
||||
for (KeyedGroup g : groups) {
|
||||
String keyColName = columnModel.getColumnByCellIndex(g.keyCellIndex).getName();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int ci : g.cellIndices) {
|
||||
sb.append(columnModel.getColumnByCellIndex(ci).getName()).append(',');
|
||||
}
|
||||
logger.trace("KeyedGroup " + keyColName + "::" + sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void addRootKeyedGroup(ColumnModel columnModel, List<KeyedGroup> keyedGroups) {
|
||||
int count = columnModel.getMaxCellIndex() + 1;
|
||||
|
@ -47,8 +47,8 @@ public class XmlImportUtilitiesStub extends XmlImportUtilities {
|
||||
return super.detectRecordElement(parser, tag);
|
||||
}
|
||||
|
||||
public void ProcessSubRecordWrapper(Project project, TreeReader parser, ImportColumnGroup columnGroup, ImportRecord record) throws Exception{
|
||||
super.processSubRecord(project, parser, columnGroup, record);
|
||||
public void ProcessSubRecordWrapper(Project project, TreeReader parser, ImportColumnGroup columnGroup, ImportRecord record, int level) throws Exception{
|
||||
super.processSubRecord(project, parser, columnGroup, record, level);
|
||||
}
|
||||
|
||||
public void findRecordWrapper(Project project, TreeReader parser, String[] recordPath, int pathIndex, ImportColumnGroup rootColumnGroup) throws Exception{
|
||||
|
@ -370,7 +370,7 @@ public class XmlImportUtilitiesTests extends RefineTest {
|
||||
ParserSkip();
|
||||
|
||||
try {
|
||||
SUT.ProcessSubRecordWrapper(project, parser, columnGroup, record);
|
||||
SUT.ProcessSubRecordWrapper(project, parser, columnGroup, record,0);
|
||||
} catch (Exception e) {
|
||||
Assert.fail();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user