Fixed Issue 397: New UI Importer Branch - individual JSON record nodes do not preview well.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2258 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
81d0072bda
commit
5762efebf6
@ -316,8 +316,17 @@ public class XmlImportUtilities extends TreeImportUtilities {
|
|||||||
Token eventType = parser.next();
|
Token eventType = parser.next();
|
||||||
if (eventType == Token.StartEntity) {
|
if (eventType == Token.StartEntity) {
|
||||||
findRecord(project, parser, recordPath, pathIndex + 1, rootColumnGroup, limit);
|
findRecord(project, parser, recordPath, pathIndex + 1, rootColumnGroup, limit);
|
||||||
} else if (eventType == Token.EndEntity ) {
|
} else if (eventType == Token.EndEntity) {
|
||||||
break;
|
break;
|
||||||
|
} else if (eventType == Token.Value) {
|
||||||
|
// This is when the user picks a specific field to import, not a whole object or element.
|
||||||
|
if (pathIndex == recordPath.length - 2) {
|
||||||
|
String desiredFieldName = recordPath[pathIndex + 1];
|
||||||
|
String currentFieldName = parser.getFieldName();
|
||||||
|
if (desiredFieldName.equals(currentFieldName)) {
|
||||||
|
processFieldAsRecord(project, parser, rootColumnGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -356,7 +365,39 @@ public class XmlImportUtilities extends TreeImportUtilities {
|
|||||||
ImportRecord record = new ImportRecord();
|
ImportRecord record = new ImportRecord();
|
||||||
|
|
||||||
processSubRecord(project, parser, rootColumnGroup, record);
|
processSubRecord(project, parser, rootColumnGroup, record);
|
||||||
|
addImportRecordToProject(record, project);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* processRecord 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
|
||||||
|
* @param rootColumnGroup
|
||||||
|
* @throws ServletException
|
||||||
|
*/
|
||||||
|
static protected void processFieldAsRecord(
|
||||||
|
Project project,
|
||||||
|
TreeReader parser,
|
||||||
|
ImportColumnGroup rootColumnGroup
|
||||||
|
) throws Exception {
|
||||||
|
logger.trace("processFieldAsRecord(Project,TreeReader,ImportColumnGroup)");
|
||||||
|
|
||||||
|
String text = parser.getFieldValue().trim();
|
||||||
|
if (text.length() > 0) {
|
||||||
|
ImportRecord record = new ImportRecord();
|
||||||
|
addCell(
|
||||||
|
project,
|
||||||
|
rootColumnGroup,
|
||||||
|
record,
|
||||||
|
parser.getFieldName(),
|
||||||
|
text
|
||||||
|
);
|
||||||
|
addImportRecordToProject(record, project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void addImportRecordToProject(ImportRecord record, Project project) {
|
||||||
if (record.rows.size() > 0) {
|
if (record.rows.size() > 0) {
|
||||||
for (List<Cell> row : record.rows) {
|
for (List<Cell> row : record.rows) {
|
||||||
Row realRow = new Row(row.size());
|
Row realRow = new Row(row.size());
|
||||||
|
Loading…
Reference in New Issue
Block a user