use of org.activityinfo.store.spi.VersionedFormStorage in project activityinfo by bedatadriven.
the class AsyncClientStub method getRecordVersionRange.
@Override
public Promise<FormSyncSet> getRecordVersionRange(String formId, long localVersion, long toVersion) {
if (!connected) {
return offlineResult();
}
Optional<FormStorage> form = storageProvider.getForm(ResourceId.valueOf(formId));
if (!form.isPresent()) {
return Promise.rejected(new RuntimeException("No such form"));
}
VersionedFormStorage formStorage = (VersionedFormStorage) form.get();
return Promise.resolved(formStorage.getVersionRange(localVersion, toVersion, resourceId -> true));
}
use of org.activityinfo.store.spi.VersionedFormStorage in project activityinfo by bedatadriven.
the class FormResource method getVersionRange.
@GET
@NoCache
@Path("records/versionRange")
@Operation(summary = "Get the records that have changed between two versions of this form")
public FormSyncSet getVersionRange(@QueryParam("localVersion") long localVersion, @QueryParam("version") long version) {
FormStorage collection = assertVisible(formId);
// Compute a predicate that will tell us whether a given
// record should be visible to the user, based on their *current* permissions.
java.util.function.Predicate<ResourceId> visibilityPredicate = computeVisibilityPredicate();
FormSyncSet syncSet;
if (collection instanceof VersionedFormStorage) {
syncSet = ((VersionedFormStorage) collection).getVersionRange(localVersion, version, visibilityPredicate);
} else {
syncSet = FormSyncSet.emptySet(formId);
}
return syncSet;
}
use of org.activityinfo.store.spi.VersionedFormStorage in project activityinfo by bedatadriven.
the class MySqlCatalogTest method partnerVersionRange.
@Test
public void partnerVersionRange() {
ResourceId partnerFormId = CuidAdapter.partnerFormId(1);
VersionedFormStorage form = (VersionedFormStorage) catalog.getForm(partnerFormId).get();
System.out.println("version = " + form.cacheVersion());
assertThat(form.cacheVersion(), greaterThan(0L));
FormSyncSet versionRange = form.getVersionRange(0, form.cacheVersion(), resourceId -> true);
assertThat(versionRange.getUpdatedRecordCount(), equalTo(3));
System.out.println(versionRange);
}
Aggregations