use of org.activityinfo.legacy.shared.model.ActivityDTO in project activityinfo by bedatadriven.
the class AbstractGridView method confirmDeleteSelected.
@Override
public void confirmDeleteSelected(final ConfirmCallback callback) {
M selection = getSelection();
if (selection instanceof ActivityDTO) {
ActivityDTO activity = (ActivityDTO) selection;
MessageBox.confirm(fromString(ClientContext.getAppTitle()), I18N.MESSAGES.confirmDeleteForm(activity.getName()), new Listener<MessageBoxEvent>() {
@Override
public void handleEvent(MessageBoxEvent be) {
if (be.getButtonClicked().getItemId().equals(Dialog.YES)) {
callback.confirmed();
}
}
});
} else {
callback.confirmed();
}
}
use of org.activityinfo.legacy.shared.model.ActivityDTO 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);
}
use of org.activityinfo.legacy.shared.model.ActivityDTO in project activityinfo by bedatadriven.
the class SchemaCsvWriterV3 method writeForms.
public void writeForms(UserDatabaseDTO db) throws IOException {
List<ResourceId> formIds = new ArrayList<>();
for (ActivityDTO activity : db.getActivities()) {
if (activity.getReportingFrequency() == ActivityFormDTO.REPORT_ONCE) {
formIds.add(CuidAdapter.activityFormClass(activity.getId()));
}
}
writeForms(db, formIds);
}
use of org.activityinfo.legacy.shared.model.ActivityDTO in project activityinfo by bedatadriven.
the class ExportAuditLogExecutor method execute.
@Override
public ExportResult execute(ExportAuditLog descriptor) throws IOException {
UserDatabaseDTO db = dispatcher.execute(new GetSchema()).getDatabaseById(descriptor.getDatabaseId());
GeneratedResource export = storageProvider.create("text/csv;charset=UTF-8", String.format("AuditLog_%d_%s.csv", db.getId(), Filenames.timestamp()));
try (CsvWriter writer = new CsvWriter(new OutputStreamWriter(export.openOutputStream(), Charsets.UTF_8))) {
AuditLogWriter logWriter = new AuditLogWriter(entityManager.get(), db, writer);
for (ActivityDTO activityDTO : db.getActivities()) {
logWriter.writeForm(catalog, activityDTO.getFormId());
}
}
return new ExportResult(export.getDownloadUri());
}
use of org.activityinfo.legacy.shared.model.ActivityDTO in project activityinfo by bedatadriven.
the class ExportIntegrationTest method fullTest.
@Test
public void fullTest() throws Throwable {
User user = new User();
user.setId(1);
user.setName("Alex");
SchemaDTO schema = execute(new GetSchema());
TaskContext context = new TaskContext(getDispatcherSync(), new NullStorageProvider(), "XYZ");
SiteExporter export = new SiteExporter(context);
for (UserDatabaseDTO db : schema.getDatabases()) {
for (ActivityDTO activity : db.getActivities()) {
export.export(execute(new GetActivityForm(activity)), new Filter());
}
}
File outputDir = new File("target/report-test/");
outputDir.mkdirs();
FileOutputStream fos = new FileOutputStream("target/report-test/ExportTest.xls");
export.getBook().write(fos);
fos.close();
}
Aggregations