use of org.activityinfo.io.xform.formList.XFormListItem in project activityinfo by bedatadriven.
the class FormLister method formList.
public Response formList(UriInfo uri, Optional<Integer> dbIdFilter) throws Exception {
AuthenticatedUser user = authProvider.get();
LOGGER.finer("ODK form list requested by " + user.getEmail() + " (" + user.getId() + ")");
SchemaDTO schema = dispatcher.execute(new GetSchema());
XFormList formList = new XFormList();
for (UserDatabaseDTO db : schema.getDatabases()) {
if (dbIdFilter.isPresent() && db.getId() != dbIdFilter.get()) {
// skip
continue;
}
if (db.isEditAllowed()) {
for (ActivityDTO activity : db.getActivities()) {
if (hasAdminLevelLocation(activity)) {
// Admin Level Locations are invalid for ODK forms - do not show
continue;
}
XFormListItem form = new XFormListItem();
form.setName(db.getName() + " / " + activity.getName());
form.setFormId("activityinfo.org:" + activity.getId());
form.setVersion(getVersion());
form.setDownloadUrl(uri.getBaseUriBuilder().path(XFormResources.class).path(Integer.toString(activity.getId())).path("xform").build());
formList.getItems().add(form);
}
}
}
return OpenRosaResponse.build(formList);
}
Aggregations