Exemplo n.º 1
0
  /**
   * @param iModel
   * @return the pageableListView of Upload
   */
  @SuppressWarnings("unchecked")
  public PageableListView<Upload> buildPageableListView(IModel iModel) {
    PageableListView<Upload> sitePageableListView =
        new PageableListView<Upload>(
            Constants.RESULT_LIST,
            iModel,
            iArkCommonService.getUserConfig(Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) {

          private static final long serialVersionUID = 1L;

          @Override
          protected void populateItem(final ListItem<Upload> item) {
            Upload upload = item.getModelObject();

            // The ID
            if (upload.getId() != null) {
              // Add the id component here
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_ID,
                      upload.getId().toString()));
            } else {
              item.add(new Label(au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_ID, ""));
            }

            // / The filename
            if (upload.getFilename() != null) {
              // Add the id component here
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FILENAME,
                      upload.getFilename()));
            } else {
              item.add(
                  new Label(au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FILENAME, ""));
            }

            // File Format
            if (upload.getFileFormat() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FILE_FORMAT,
                      upload.getFileFormat().getName()));
            } else {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FILE_FORMAT, ""));
            }

            // UserId
            if (upload.getUserId() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_USER_ID,
                      upload.getUserId()));
            } else {
              item.add(
                  new Label(au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_USER_ID, ""));
            }

            // Start time
            if (upload.getStartTime() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_START_TIME,
                      upload.getStartTime().toString()));
            } else {
              item.add(
                  new Label(au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_START_TIME, ""));
            }

            // Finish time
            if (upload.getFinishTime() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FINISH_TIME,
                      upload.getFinishTime().toString()));
            } else {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FINISH_TIME, ""));
            }
            if (upload.getUploadStatus() != null
                && upload.getUploadStatus().getShortMessage() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME,
                      upload.getUploadStatus().getShortMessage()));
            } else {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME,
                      ""));
            }

            // Download file link button
            item.add(buildDownloadButton(upload));

            // Download upload report button
            item.add(buildDownloadReportButton(upload));

            item.add(buildDeleteUploadButton(upload));
            // Delete the upload file
            // item.add(buildDeleteButton(upload));

            // For the alternative stripes
            item.add(
                new AttributeModifier(
                    "class",
                    new AbstractReadOnlyModel<String>() {

                      private static final long serialVersionUID = 1L;

                      @Override
                      public String getObject() {
                        return (item.getIndex() % 2 == 1) ? "even" : "odd";
                      }
                    }));
          }
        };
    return sitePageableListView;
  }