import org.apache.commons.io.IOUtils;
import org.argeo.ArgeoException;
import org.argeo.jcr.ArgeoTypes;
-import org.argeo.jcr.JcrUtils;
import org.argeo.util.CsvParser;
import org.argeo.util.tabular.ArrayTabularRow;
import org.argeo.util.tabular.TabularColumn;
if (node.isNodeType(ArgeoTypes.ARGEO_COLUMN)) {
Integer type = PropertyType.valueFromName(node.getProperty(
Property.JCR_REQUIRED_TYPE).getString());
- TabularColumn tc = new TabularColumn(node.getName(), type);
+ TabularColumn tc = new TabularColumn(node.getProperty(
+ Property.JCR_TITLE).getString(), type);
header.add(tc);
// } else if (node.getName().equals(Property.JCR_CONTENT)) {
// contentNode = node;
// TODO Auto-generated catch block
e.printStackTrace();
}
- //textLines.add(tokens);
+ // textLines.add(tokens);
if (hasNext == null) {
hasNext = true;
synchronized (JcrTabularRowIterator.this) {
return true;
// (parsingCompleted && textLines.isEmpty())
- return false;
-
-// if (!hasNext && textLines.isEmpty()) {
-// if (in != null) {
-// IOUtils.closeQuietly(in);
-// in = null;
-// }
-// if (binary != null) {
-// JcrUtils.closeQuietly(binary);
-// binary = null;
-// }
-// return false;
-// } else
-// return true;
+ return false;
+
+ // if (!hasNext && textLines.isEmpty()) {
+ // if (in != null) {
+ // IOUtils.closeQuietly(in);
+ // in = null;
+ // }
+ // if (binary != null) {
+ // JcrUtils.closeQuietly(binary);
+ // binary = null;
+ // }
+ // return false;
+ // } else
+ // return true;
}
public synchronized TabularRow next() {
String contentNodeType) {
try {
for (TabularColumn column : columns) {
- Node columnNode = tableNode.addNode(column.getName(),
+ String normalized = JcrUtils.replaceInvalidChars(column
+ .getName());
+ Node columnNode = tableNode.addNode(normalized,
ArgeoTypes.ARGEO_COLUMN);
- columnNode.setProperty(Property.JCR_REQUIRED_TYPE,
- PropertyType.nameFromValue(column.getType()));
+ columnNode.setProperty(Property.JCR_TITLE, column.getName());
+ if (column.getType() != null)
+ columnNode.setProperty(Property.JCR_REQUIRED_TYPE,
+ PropertyType.nameFromValue(column.getType()));
+ else
+ columnNode.setProperty(Property.JCR_REQUIRED_TYPE,
+ PropertyType.TYPENAME_STRING);
}
contentNode = tableNode.addNode(Property.JCR_CONTENT,
contentNodeType);
}
}
- public void appendRow(List<?> row) {
+ public void appendRow(Object[] row) {
csvWriter.writeLine(row);
}