FeedURLFactory factory = FeedURLFactory.getDefault();
URL tableFeedUrl = factory.getTableFeedUrl(ssKey);
// Check if already exists.
TableEntry tableEntry = null;
TableFeed feed = ss.getFeed(tableFeedUrl, TableFeed.class);
for (TableEntry entry : feed.getEntries()) {
if (entry.getTitle().getPlainText().equals(kind)) {
tableEntry = entry;
logger.info("TableFeed:" + kind + " already exists.");
break;
}
}
// Add TableFeed
if (tableEntry == null) {
tableEntry = new TableEntry();
tableEntry.setTitle(new PlainTextConstruct(kind));
tableEntry.setWorksheet(new Worksheet(kind));
tableEntry.setHeader(new Header(1));
Data tableData = new Data();
tableData.setNumberOfRows(0);
tableData.setStartIndex(2);
tableData.setInsertionMode(InsertionMode.INSERT);
// Create a title row
tableData.addColumn(new Column("A", Entity.KEY_RESERVED_PROPERTY));
for (int i = 0; i < properties.size(); i++) {
String index = number2columnName(i + 1);
String columnName = properties.get(i).getName();
tableData.addColumn(new Column(index, columnName));
}
tableEntry.setData(tableData);
tableEntry = ss.insert(tableFeedUrl, tableEntry);
logger.info("Craeted tableFeed:" + kind);
}
String[] split = tableEntry.getId().split("/");
final String tableId = split[split.length - 1];
// Add a "valueType" row (the cells are filled with "*" to be replaced)
int numberOfRows = tableEntry.getData().getNumberOfRows();
if (numberOfRows == 0) {
RecordEntry newEntry = new RecordEntry();
newEntry.addField(new Field(null, Entity.KEY_RESERVED_PROPERTY, VALUE_TYPE));
for (int i = 0; i < properties.size(); i++) {
GbProperty gbProperty = properties.get(i);