}
}
private void saveTable(final ScriptableObject table)
throws GameEngineException {
Step step = MiniProfiler.step("API.saveTable");
try {
Object id = table.get("id");
if (id == null) {
Entity result = ge.persistence.save("Table");
// id = result.getKey().getId();
setId(table, result.getKey().getId());
id = result.getKey().getId();
}
saveMementos(table);
ScriptableObject.deleteProperty(table, "mementos");
// System.out.print("mementosRemoved:" + mementosRemoved);
HashMap<String, Object> properties = new HashMap<String, Object>();
// json
String json = stringify(table, ge.execute("[\"json\"]"));
properties.put("json", json);
// players
properties.put("players",
((NativeArray) table.get("playerOrder")).toArray());
// currentplayer
properties.put("currentPlayer", ((ScriptableObject) table
.get("memento")).get("currentPlayer"));
// segment
properties.put("segment",
((ScriptableObject) table.get("memento")).get("segment"));
properties.put("mementoId", table.get("mementoId"));
ge.persistence.save("Table", getId(table), properties);
table.put("json", table, json);
} finally {
step.close();
}
}