FeedURLFactory factory = FeedURLFactory.getDefault();
URL recordFeedUrl = factory.getRecordFeedUrl(ssKey, tableId);
// Get "valueType" row for update.
logger.info("Checking valueType row in :" + kind);
RecordQuery query = new RecordQuery(recordFeedUrl);
query.setSpreadsheetQuery(Entity.KEY_RESERVED_PROPERTY + "=" + VALUE_TYPE);
RecordEntry valueTypeRow = ss.query(query, RecordFeed.class).getEntries().get(0);
Map<String, Field> valueTypeRowMap = new HashMap<String, Field>();
boolean valueTypeNotSet = false;
for (Field field : valueTypeRow.getFields()) {
valueTypeRowMap.put(field.getName(), field);
if (field.getValue().equals(VALUE_TYPE_NOT_SET)) {
valueTypeNotSet = true;
}
}
// When retrying, Check if already exists
List<String> duplicateCheckList = new ArrayList<String>();
if (retry) {
/*
* If you use query like setSpreadsheetQuery("__key__=Kind(1)"),
* '()' in __key__ conflicts with '()' as parameter...
*/
RecordQuery query2 = new RecordQuery(recordFeedUrl);
query2.setMaxResults(list.size());
query2.setReverse(true);
final List<RecordEntry> entries = ss.query(query2, RecordFeed.class).getEntries();
for (RecordEntry entry : entries) {
for (Field field : entry.getFields()) {
if (field.getName().equals(Entity.KEY_RESERVED_PROPERTY)) {
duplicateCheckList.add(field.getValue());