Search in sources :

Example 6 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class ShareReportDialog method show.

public void show(final Report report) {
    super.show();
    this.currentReport = report;
    // we need to combine the databases which already have visiblity with
    // those
    // that could potentially be added
    BatchCommand batch = new BatchCommand();
    batch.add(new GetSchema());
    batch.add(new GetReportVisibility(currentReport.getId()));
    dispatcher.execute(batch, new MaskingAsyncMonitor(grid, I18N.CONSTANTS.loading()), new AsyncCallback<BatchResult>() {

        @Override
        public void onFailure(Throwable caught) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onSuccess(BatchResult batch) {
            populateGrid((SchemaDTO) batch.getResult(0), (ReportVisibilityResult) batch.getResult(1));
        }
    });
}
Also used : ReportVisibilityResult(org.activityinfo.shared.command.result.ReportVisibilityResult) GetReportVisibility(org.activityinfo.shared.command.GetReportVisibility) MaskingAsyncMonitor(org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor) BatchCommand(org.activityinfo.shared.command.BatchCommand) BatchResult(org.activityinfo.shared.command.result.BatchResult) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO)

Example 7 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class DimensionTree method onModelChanged.

private void onModelChanged() {
    if (needToReloadDimensions(model)) {
        clearIndicatorSpecificDimensions();
        dispatcher.execute(new GetSchema(), new MaskingAsyncMonitor(treePanel, I18N.CONSTANTS.loading()), new AsyncCallback<SchemaDTO>() {

            @Override
            public void onFailure(Throwable caught) {
            }

            @Override
            public void onSuccess(SchemaDTO result) {
                populateIndicatorSpecificDimensions(result);
                applyModelState(result);
            }
        });
    }
}
Also used : MaskingAsyncMonitor(org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO)

Example 8 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class ExportSitesServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    Set<Integer> activities = new HashSet<Integer>();
    if (req.getParameterValues("a") != null) {
        for (String activity : req.getParameterValues("a")) {
            activities.add(Integer.parseInt(activity));
        }
    }
    Filter filter = FilterUrlSerializer.fromQueryParameter(req.getParameter("filter"));
    SchemaDTO schema = dispatcher.execute(new GetSchema());
    SiteExporter export = new SiteExporter(dispatcher);
    for (UserDatabaseDTO db : schema.getDatabases()) {
        for (ActivityDTO activity : db.getActivities()) {
            if (!filter.isRestricted(DimensionType.Activity) || filter.getRestrictions(DimensionType.Activity).contains(activity.getId())) {
                export.export(activity, filter);
            }
        }
    }
    export.done();
    resp.setContentType("application/vnd.ms-excel");
    if (req.getHeader("User-Agent").indexOf("MSIE") != -1) {
        resp.addHeader("Content-Disposition", "attachment; filename=ActivityInfo.xls");
    } else {
        resp.addHeader("Content-Disposition", "attachment; filename=" + ("ActivityInfo Export " + new Date().toString() + ".xls").replace(" ", "_"));
    }
    OutputStream os = resp.getOutputStream();
    export.getBook().write(os);
}
Also used : Filter(org.activityinfo.shared.command.Filter) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) OutputStream(java.io.OutputStream) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Date(java.util.Date) HashSet(java.util.HashSet)

Example 9 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class SiteChangeServlet method sendNotifications.

@VisibleForTesting
void sendNotifications(int editorUserId, int siteId, ChangeType type) {
    User user = entityManager.get().find(User.class, editorUserId);
    /*
         * For our purposes, the user who initiated the change will be
         * considered the authenticated user for this thread
         */
    authProvider.set(user);
    SiteResult siteResult = dispatcher.execute(GetSites.byId(siteId));
    SiteDTO siteDTO = siteResult.getData().get(0);
    SchemaDTO schemaDTO = dispatcher.execute(new GetSchema());
    ActivityDTO activityDTO = schemaDTO.getActivityById(siteDTO.getActivityId());
    UserDatabaseDTO userDatabaseDTO = activityDTO.getDatabase();
    Date date = new Date();
    List<User> recipients = findRecipients(userDatabaseDTO.getId());
    for (User recipient : recipients) {
        try {
            // themselves!
            if (recipient.getId() != editorUserId) {
                LOGGER.info("sending sitechange notification email to " + recipient.getEmail());
                UpdateMessageBuilder message = new UpdateMessageBuilder();
                message.setDate(date);
                message.setEditor(user);
                message.setRecipient(recipient);
                message.setUserDatabaseDTO(userDatabaseDTO);
                message.setSiteDTO(siteDTO);
                message.setActivityDTO(activityDTO);
                message.setChangeType(type);
                mailSender.get().send(message.build());
            }
        } catch (Throwable t) {
            LOGGER.warning("failed sending notification email to " + recipient.getName() + " <" + recipient.getEmail() + ">: " + t.getMessage());
            t.printStackTrace();
        }
    }
}
Also used : User(org.activityinfo.server.database.hibernate.entity.User) SiteResult(org.activityinfo.shared.command.result.SiteResult) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Date(java.util.Date) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 10 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class RemoteDispatcherTest method commandsUnsuccessfullyExecutedThroughProxiesShouldBeSentToServer.

@Test
public void commandsUnsuccessfullyExecutedThroughProxiesShouldBeSentToServer() {
    GetSchema command = new GetSchema();
    expect(proxy.maybeExecute(eq(command))).andReturn(CacheResult.couldNotExecute());
    replay(proxy);
    expectRemoteCall(command);
    andCallbackWihSuccess(new SchemaDTO());
    replay(service);
    AsyncCallback callback = makeCallbackThatExpectsNonNullSuccess();
    proxyManager.registerProxy(GetSchema.class, proxy);
    dispatcher.execute(new GetSchema(), callback);
    processPendingCommands();
    verify(proxy, service, callback);
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) Test(org.junit.Test)

Aggregations

SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)66 GetSchema (org.activityinfo.shared.command.GetSchema)56 Test (org.junit.Test)41 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)20 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)10 CreateResult (org.activityinfo.shared.command.result.CreateResult)9 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)8 MockEventBus (org.activityinfo.client.MockEventBus)6 HashMap (java.util.HashMap)5 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)5 UIConstants (org.activityinfo.client.i18n.UIConstants)5 StateManagerStub (org.activityinfo.client.mock.StateManagerStub)5 OnDataSet (org.activityinfo.server.database.OnDataSet)5 Delete (org.activityinfo.shared.command.Delete)5 Filter (org.activityinfo.shared.command.Filter)5 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)5 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)5 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)4 CreateEntity (org.activityinfo.shared.command.CreateEntity)4 VoidResult (org.activityinfo.shared.command.result.VoidResult)4