Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to get all versions of rows in the /diff API #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public void testGetRowsSince() throws ODKEntityPersistException, ODKDatastoreExc
row = round3changes.get(0);
expected.put(row.getRowId(), row);

WebsafeRows websafeRows = dm.getRowsSince(beginETag, null, 2000);
WebsafeRows websafeRows = dm.getRowsSince(beginETag, null, 2000, false);
List<Row> actual = websafeRows.rows;
Util.assertCollectionSameElements(expected.values(), actual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private Query buildRowsQuery(DbTable table) {
* @throws PermissionDeniedException
* @throws BadColumnNameException
*/
public WebsafeRows getRowsSince(String dataETag, QueryResumePoint startCursor, int fetchLimit)
public WebsafeRows getRowsSince(String dataETag, QueryResumePoint startCursor, int fetchLimit, boolean fullLog)
throws ODKDatastoreException, ODKTaskLockException, InconsistentStateException,
PermissionDeniedException, BadColumnNameException {

Expand Down Expand Up @@ -377,7 +377,7 @@ public WebsafeRows getRowsSince(String dataETag, QueryResumePoint startCursor, i
rows.add(row);
}
}
return new WebsafeRows(computeDiff(rows), currentDataETag, result.websafeRefetchCursor,
return new WebsafeRows(fullLog ? rows : computeDiff(rows), currentDataETag, result.websafeRefetchCursor,
result.websafeBackwardCursor, result.websafeResumeCursor, result.hasMore, result.hasPrior);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public interface DiffService {
public static final String QUERY_SEQUENCE_VALUE = "sequence_value";
public static final String CURSOR_PARAMETER = "cursor";
public static final String FETCH_LIMIT = "fetchLimit";
public static final String GET_FULL_LOG = "getFullLog";

/**
*
Expand All @@ -54,7 +55,7 @@ public interface DiffService {
*/
@GET
@Produces({MediaType.APPLICATION_JSON, ApiConstants.MEDIA_TEXT_XML_UTF8, ApiConstants.MEDIA_APPLICATION_XML_UTF8})
public Response /*RowResourceList*/ getRowsSince(@QueryParam(QUERY_DATA_ETAG) String dataETag, @QueryParam(CURSOR_PARAMETER) String cursor, @QueryParam(FETCH_LIMIT) String fetchLimit)
public Response /*RowResourceList*/ getRowsSince(@QueryParam(QUERY_DATA_ETAG) String dataETag, @QueryParam(CURSOR_PARAMETER) String cursor, @QueryParam(FETCH_LIMIT) String fetchLimit, @QueryParam(GET_FULL_LOG) String getFullLog)
throws ODKDatastoreException, PermissionDeniedException, InconsistentStateException, ODKTaskLockException, BadColumnNameException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ public DiffServiceImpl(String appId, String tableId, String schemaETag, UriInfo
}

@Override
public Response getRowsSince(@QueryParam(QUERY_DATA_ETAG) String dataETag, @QueryParam(CURSOR_PARAMETER) String cursor, @QueryParam(FETCH_LIMIT) String fetchLimit) throws ODKDatastoreException,
public Response getRowsSince(@QueryParam(QUERY_DATA_ETAG) String dataETag, @QueryParam(CURSOR_PARAMETER) String cursor, @QueryParam(FETCH_LIMIT) String fetchLimit, @QueryParam(GET_FULL_LOG) String getFullLog) throws ODKDatastoreException,
PermissionDeniedException, InconsistentStateException, ODKTaskLockException, BadColumnNameException {
int limit = (fetchLimit == null || fetchLimit.length() == 0) ? 2000 : Integer.valueOf(fetchLimit);
WebsafeRows websafeResult = dm.getRowsSince(dataETag, QueryResumePoint.fromWebsafeCursor(WebUtils.safeDecode(cursor)), limit);
boolean fullLog = (getFullLog == null) ? false : getFullLog.equalsIgnoreCase("true");
WebsafeRows websafeResult = dm.getRowsSince(dataETag, QueryResumePoint.fromWebsafeCursor(WebUtils.safeDecode(cursor)), limit, fullLog);
RowResourceList rowResourceList = new RowResourceList(getResources(websafeResult.rows),
websafeResult.dataETag, getTableUri(),
WebUtils.safeEncode(websafeResult.websafeRefetchCursor),
Expand Down