Search in sources :

Example 1 with SiteAttachmentDTO

use of org.activityinfo.legacy.shared.model.SiteAttachmentDTO 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)

Aggregations

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 SiteAttachmentResult (org.activityinfo.legacy.shared.command.result.SiteAttachmentResult)1 SiteAttachmentDTO (org.activityinfo.legacy.shared.model.SiteAttachmentDTO)1