Search in sources :

Example 1 with SiteAttachmentResult

use of org.activityinfo.legacy.shared.command.result.SiteAttachmentResult in project activityinfo by bedatadriven.

the class GetSiteAttachmentsHandler method execute.

@Override
public void execute(GetSiteAttachments command, ExecutionContext context, final AsyncCallback<SiteAttachmentResult> callback) {
    dtos = new ArrayList<SiteAttachmentDTO>();
    SqlQuery.selectAll().from(Tables.SITE_ATTACHMENT, "s").where("s.siteid").equalTo(command.getSiteId()).execute(context.getTransaction(), new SqlResultCallback() {

        @Override
        public void onSuccess(SqlTransaction tx, SqlResultSet results) {
            for (SqlResultSetRow row : results.getRows()) {
                SiteAttachmentDTO dto = new SiteAttachmentDTO();
                dto.setSiteId(row.getInt("siteid"));
                dto.setBlobId(row.getString("blobid"));
                dto.setFileName(row.getString("filename"));
                dto.setUploadedBy(row.getInt("uploadedby"));
                dto.setBlobSize(row.getInt("blobsize"));
                dto.setContentType(row.getString("contenttype"));
                dtos.add(dto);
            }
            callback.onSuccess(new SiteAttachmentResult(dtos));
        }
    });
}
Also used : SqlResultSet(com.bedatadriven.rebar.sql.client.SqlResultSet) SiteAttachmentDTO(org.activityinfo.legacy.shared.model.SiteAttachmentDTO) SqlResultCallback(com.bedatadriven.rebar.sql.client.SqlResultCallback) SqlTransaction(com.bedatadriven.rebar.sql.client.SqlTransaction) SqlResultSetRow(com.bedatadriven.rebar.sql.client.SqlResultSetRow) SiteAttachmentResult(org.activityinfo.legacy.shared.command.result.SiteAttachmentResult)

Example 2 with SiteAttachmentResult

use of org.activityinfo.legacy.shared.command.result.SiteAttachmentResult in project activityinfo by bedatadriven.

the class AttachmentsTab method setAttachmentStore.

@Override
public void setAttachmentStore(int siteId) {
    GetSiteAttachments getAttachments = new GetSiteAttachments();
    getAttachments.setSiteId(siteId);
    dispatcher.execute(getAttachments, new AsyncCallback<SiteAttachmentResult>() {

        @Override
        public void onFailure(Throwable caught) {
        // callback.onFailure(caught);
        }

        @Override
        public void onSuccess(SiteAttachmentResult result) {
            store.removeAll();
            store.add(result.getData());
        }
    });
}
Also used : GetSiteAttachments(org.activityinfo.legacy.shared.command.GetSiteAttachments) SiteAttachmentResult(org.activityinfo.legacy.shared.command.result.SiteAttachmentResult)

Aggregations

SiteAttachmentResult (org.activityinfo.legacy.shared.command.result.SiteAttachmentResult)2 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)1 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)1 GetSiteAttachments (org.activityinfo.legacy.shared.command.GetSiteAttachments)1 SiteAttachmentDTO (org.activityinfo.legacy.shared.model.SiteAttachmentDTO)1