/** * Construct a row for insertion. This is used by the remote client (ODK Tables) to construct a * REST request to insert the row. * * @param rowId * @param values */ public static Row forInsert( String rowId, String formId, String locale, String savepointType, String savepointTimestamp, String savepointCreator, RowFilterScope filterScope, ArrayList<DataKeyValue> values) { Row row = new Row(); row.rowId = rowId; row.formId = formId; row.locale = locale; row.savepointType = savepointType; row.savepointTimestamp = savepointTimestamp; row.savepointCreator = savepointCreator; row.rowFilterScope = filterScope; if (values == null) { row.orderedColumns = new ArrayList<DataKeyValue>(); } else { Collections.sort( values, new Comparator<DataKeyValue>() { @Override public int compare(DataKeyValue arg0, DataKeyValue arg1) { return arg0.column.compareTo(arg1.column); } }); row.orderedColumns = values; } return row; }
private RowResource getResource(Row row) { String appId = dm.getAppId(); String tableId = dm.getTableId(); String rowId = row.getRowId(); UriBuilder ub = info.getBaseUriBuilder(); ub.path(TableService.class); URI self = ub.clone() .path(TableService.class, "getData") .path(DataService.class, "getRow") .build(appId, tableId, rowId); URI table = ub.clone().path(TableService.class, "getTable").build(appId, tableId); RowResource resource = new RowResource(row); resource.setSelfUri(self.toASCIIString()); resource.setTableUri(table.toASCIIString()); return resource; }