Fix indentation so indent levels match logical block levels. No code changes.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@1940 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
748b5699b9
commit
af20157532
@ -61,11 +61,7 @@ public abstract class TreeImportUtilities {
|
|||||||
int count;
|
int count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static protected abstract class ImportVertical {
|
static protected abstract class ImportVertical {
|
||||||
public String name = "";
|
public String name = "";
|
||||||
public int nonBlankCount;
|
public int nonBlankCount;
|
||||||
@ -134,142 +130,142 @@ public abstract class TreeImportUtilities {
|
|||||||
static public void createColumnsFromImport(
|
static public void createColumnsFromImport(
|
||||||
Project project,
|
Project project,
|
||||||
ImportColumnGroup columnGroup
|
ImportColumnGroup columnGroup
|
||||||
) {
|
) {
|
||||||
int startColumnIndex = project.columnModel.columns.size();
|
int startColumnIndex = project.columnModel.columns.size();
|
||||||
|
|
||||||
List<ImportColumn> columns = new ArrayList<ImportColumn>(columnGroup.columns.values());
|
List<ImportColumn> columns = new ArrayList<ImportColumn>(columnGroup.columns.values());
|
||||||
Collections.sort(columns, new Comparator<ImportColumn>() {
|
Collections.sort(columns, new Comparator<ImportColumn>() {
|
||||||
public int compare(ImportColumn o1, ImportColumn o2) {
|
public int compare(ImportColumn o1, ImportColumn o2) {
|
||||||
if (o1.blankOnFirstRow != o2.blankOnFirstRow) {
|
if (o1.blankOnFirstRow != o2.blankOnFirstRow) {
|
||||||
return o1.blankOnFirstRow ? 1 : -1;
|
return o1.blankOnFirstRow ? 1 : -1;
|
||||||
}
|
|
||||||
|
|
||||||
int c = o2.nonBlankCount - o1.nonBlankCount;
|
|
||||||
return c != 0 ? c : (o1.name.length() - o2.name.length());
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
for (int i = 0; i < columns.size(); i++) {
|
int c = o2.nonBlankCount - o1.nonBlankCount;
|
||||||
ImportColumn c = columns.get(i);
|
return c != 0 ? c : (o1.name.length() - o2.name.length());
|
||||||
|
|
||||||
Column column = new com.google.refine.model.Column(c.cellIndex, c.name);
|
|
||||||
project.columnModel.columns.add(column);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
List<ImportColumnGroup> subgroups = new ArrayList<ImportColumnGroup>(columnGroup.subgroups.values());
|
for (int i = 0; i < columns.size(); i++) {
|
||||||
Collections.sort(subgroups, new Comparator<ImportColumnGroup>() {
|
ImportColumn c = columns.get(i);
|
||||||
public int compare(ImportColumnGroup o1, ImportColumnGroup o2) {
|
|
||||||
int c = o2.nonBlankCount - o1.nonBlankCount;
|
|
||||||
return c != 0 ? c : (o1.name.length() - o2.name.length());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (ImportColumnGroup g : subgroups) {
|
Column column = new com.google.refine.model.Column(c.cellIndex, c.name);
|
||||||
createColumnsFromImport(project, g);
|
project.columnModel.columns.add(column);
|
||||||
}
|
|
||||||
|
|
||||||
int endColumnIndex = project.columnModel.columns.size();
|
|
||||||
int span = endColumnIndex - startColumnIndex;
|
|
||||||
if (span > 1 && span < project.columnModel.columns.size()) {
|
|
||||||
project.columnModel.addColumnGroup(startColumnIndex, span, startColumnIndex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ImportColumnGroup> subgroups = new ArrayList<ImportColumnGroup>(columnGroup.subgroups.values());
|
||||||
|
Collections.sort(subgroups, new Comparator<ImportColumnGroup>() {
|
||||||
|
public int compare(ImportColumnGroup o1, ImportColumnGroup o2) {
|
||||||
|
int c = o2.nonBlankCount - o1.nonBlankCount;
|
||||||
|
return c != 0 ? c : (o1.name.length() - o2.name.length());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (ImportColumnGroup g : subgroups) {
|
||||||
|
createColumnsFromImport(project, g);
|
||||||
|
}
|
||||||
|
|
||||||
|
int endColumnIndex = project.columnModel.columns.size();
|
||||||
|
int span = endColumnIndex - startColumnIndex;
|
||||||
|
if (span > 1 && span < project.columnModel.columns.size()) {
|
||||||
|
project.columnModel.addColumnGroup(startColumnIndex, span, startColumnIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static protected void addCell(
|
static protected void addCell(
|
||||||
Project project,
|
Project project,
|
||||||
ImportColumnGroup columnGroup,
|
ImportColumnGroup columnGroup,
|
||||||
ImportRecord record,
|
ImportRecord record,
|
||||||
String columnLocalName,
|
String columnLocalName,
|
||||||
String text
|
String text
|
||||||
) {
|
) {
|
||||||
if (text == null || ((String) text).isEmpty()) {
|
if (text == null || ((String) text).isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Serializable value = ImporterUtilities.parseCellValue(text);
|
|
||||||
|
|
||||||
ImportColumn column = getColumn(project, columnGroup, columnLocalName);
|
|
||||||
int cellIndex = column.cellIndex;
|
|
||||||
|
|
||||||
int rowIndex = Math.max(columnGroup.nextRowIndex, column.nextRowIndex);
|
|
||||||
while (rowIndex >= record.rows.size()) {
|
|
||||||
record.rows.add(new ArrayList<Cell>());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Cell> row = record.rows.get(rowIndex);
|
|
||||||
while (cellIndex >= row.size()) {
|
|
||||||
row.add(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
row.set(cellIndex, new Cell(value, null));
|
|
||||||
|
|
||||||
column.nextRowIndex = rowIndex + 1;
|
|
||||||
column.nonBlankCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Serializable value = ImporterUtilities.parseCellValue(text);
|
||||||
|
|
||||||
|
ImportColumn column = getColumn(project, columnGroup, columnLocalName);
|
||||||
|
int cellIndex = column.cellIndex;
|
||||||
|
|
||||||
|
int rowIndex = Math.max(columnGroup.nextRowIndex, column.nextRowIndex);
|
||||||
|
while (rowIndex >= record.rows.size()) {
|
||||||
|
record.rows.add(new ArrayList<Cell>());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Cell> row = record.rows.get(rowIndex);
|
||||||
|
while (cellIndex >= row.size()) {
|
||||||
|
row.add(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
row.set(cellIndex, new Cell(value, null));
|
||||||
|
|
||||||
|
column.nextRowIndex = rowIndex + 1;
|
||||||
|
column.nonBlankCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static protected ImportColumn getColumn(
|
static protected ImportColumn getColumn(
|
||||||
Project project,
|
Project project,
|
||||||
ImportColumnGroup columnGroup,
|
ImportColumnGroup columnGroup,
|
||||||
String localName
|
String localName
|
||||||
) {
|
) {
|
||||||
if (columnGroup.columns.containsKey(localName)) {
|
if (columnGroup.columns.containsKey(localName)) {
|
||||||
return columnGroup.columns.get(localName);
|
return columnGroup.columns.get(localName);
|
||||||
}
|
|
||||||
|
|
||||||
ImportColumn column = createColumn(project, columnGroup, localName);
|
|
||||||
columnGroup.columns.put(localName, column);
|
|
||||||
|
|
||||||
return column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected ImportColumn createColumn(
|
ImportColumn column = createColumn(project, columnGroup, localName);
|
||||||
|
columnGroup.columns.put(localName, column);
|
||||||
|
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected ImportColumn createColumn(
|
||||||
Project project,
|
Project project,
|
||||||
ImportColumnGroup columnGroup,
|
ImportColumnGroup columnGroup,
|
||||||
String localName
|
String localName
|
||||||
) {
|
) {
|
||||||
ImportColumn newColumn = new ImportColumn();
|
ImportColumn newColumn = new ImportColumn();
|
||||||
|
|
||||||
newColumn.name =
|
newColumn.name = columnGroup.name.length() == 0 ?
|
||||||
columnGroup.name.length() == 0 ?
|
|
||||||
(localName == null ? "Text" : localName) :
|
(localName == null ? "Text" : localName) :
|
||||||
(localName == null ? columnGroup.name : (columnGroup.name + " - " + localName));
|
(localName == null ? columnGroup.name : (columnGroup.name + " - " + localName));
|
||||||
|
|
||||||
newColumn.cellIndex = project.columnModel.allocateNewCellIndex();
|
newColumn.cellIndex = project.columnModel.allocateNewCellIndex();
|
||||||
newColumn.nextRowIndex = columnGroup.nextRowIndex;
|
newColumn.nextRowIndex = columnGroup.nextRowIndex;
|
||||||
|
|
||||||
return newColumn;
|
return newColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected ImportColumnGroup getColumnGroup(
|
static protected ImportColumnGroup getColumnGroup(
|
||||||
Project project,
|
Project project,
|
||||||
ImportColumnGroup columnGroup,
|
ImportColumnGroup columnGroup,
|
||||||
String localName
|
String localName
|
||||||
) {
|
) {
|
||||||
if (columnGroup.subgroups.containsKey(localName)) {
|
if (columnGroup.subgroups.containsKey(localName)) {
|
||||||
return columnGroup.subgroups.get(localName);
|
return columnGroup.subgroups.get(localName);
|
||||||
}
|
|
||||||
|
|
||||||
ImportColumnGroup subgroup = createColumnGroup(project, columnGroup, localName);
|
|
||||||
columnGroup.subgroups.put(localName, subgroup);
|
|
||||||
|
|
||||||
return subgroup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected ImportColumnGroup createColumnGroup(
|
ImportColumnGroup subgroup = createColumnGroup(project, columnGroup, localName);
|
||||||
|
columnGroup.subgroups.put(localName, subgroup);
|
||||||
|
|
||||||
|
return subgroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected ImportColumnGroup createColumnGroup(
|
||||||
Project project,
|
Project project,
|
||||||
ImportColumnGroup columnGroup,
|
ImportColumnGroup columnGroup,
|
||||||
String localName
|
String localName
|
||||||
) {
|
) {
|
||||||
ImportColumnGroup newGroup = new ImportColumnGroup();
|
ImportColumnGroup newGroup = new ImportColumnGroup();
|
||||||
|
|
||||||
newGroup.name =
|
newGroup.name =
|
||||||
columnGroup.name.length() == 0 ?
|
columnGroup.name.length() == 0 ?
|
||||||
(localName == null ? "Text" : localName) :
|
(localName == null ? "Text" : localName) :
|
||||||
(localName == null ? columnGroup.name : (columnGroup.name + " - " + localName));
|
(localName == null ? columnGroup.name : (columnGroup.name + " - " + localName));
|
||||||
|
|
||||||
newGroup.nextRowIndex = columnGroup.nextRowIndex;
|
newGroup.nextRowIndex = columnGroup.nextRowIndex;
|
||||||
|
|
||||||
return newGroup;
|
return newGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user