Esempio n. 1
0
  protected ModelAndView handleRequestInternal(
      HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView mv = new ModelAndView(successView);

    Collection items = presidentService.getPresidents();

    TableFacade tableFacade = new TableFacadeImpl(id, request);
    tableFacade.setItems(items);
    tableFacade.setColumnProperties(
        new String[] {"name.firstName", "name.lastName", "term", "career", "born"});
    tableFacade.setExportTypes(
        response,
        new ExportType[] {
          ExportType.CSV, ExportType.EXCEL
        }); // Tell the tableFacade what exports to use.
    tableFacade.addFilterMatcherMap(new TagFilterMatcherMap());

    Limit limit = tableFacade.getLimit();
    if (limit.isExported()) {
      tableFacade.getTable().setCaption("Presidents");
      tableFacade.getTable().getRow().getColumn("name.firstName").setTitle("First Name");
      tableFacade.getTable().getRow().getColumn("name.lastName").setTitle("Last Name");
      tableFacade.render();
      return null;
    }

    request.setAttribute(
        "presidents", items); // Set the items in the request for the TableTag to use.

    return mv;
  }
Esempio n. 2
0
  private boolean listar(
      VerComentariosForm verComentariosForm,
      HttpServletRequest request,
      HttpServletResponse response) {
    CliComComentarioDAO comentarioDAO = new CliComComentarioDAO(getSessionHibernate(request));
    try {
      List<CliComComentario> comentarios =
          comentarioDAO.buscarPorFechas(
              verComentariosForm.getFechaInicioDate(), verComentariosForm.getFechaFinDate());
      TableFacade tableFacade = new TableFacadeImpl(TABLA_ID, request);
      tableFacade.setItems(comentarios);

      tableFacade.setExportTypes(response, ExportType.CSV, ExportType.JEXCEL); // , ExportType.PDF);
      tableFacade.setStateAttr("restore");
      Limit limit = tableFacade.getLimit();
      if (limit.isExported()) {
        // ---- exporta la tabla
        export(tableFacade);
        return false;
      } else {
        // ---- genera el html de la tabla para ser mostrada
        String html = html(tableFacade, request);
        request.setAttribute(Constantes.LISTA_KEY, html);
      }
    } catch (ParseException e) {
      log.error("Error al parsear las fechas", e);
    }
    return true;
  }
  @Override
  public void processRequest() throws Exception {
    resetPanel();
    panel.setStudyInfoShown(false);
    panel.setOrderedData(true);
    panel.setSubmitDataModule(false);
    panel.setExtractData(false);
    panel.setCreateDataset(false);

    setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering"));
    setToPanel(
        resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading"));
    setToPanel(
        resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version"));
    setToPanel(
        resword.getString("CRF_spreadsheet_template"),
        respage.getString("br_download_blank_CRF_spreadsheet_from"));
    setToPanel(
        resword.getString("example_CRF_br_spreadsheets"),
        respage.getString("br_download_example_CRF_instructions_from"));

    FormProcessor fp = new FormProcessor(request);

    // checks which module the requests are from, manage or admin
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);

    int crfId = fp.getInt(CRF_ID);
    if (crfId == 0) {
      addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
      forwardPage(Page.CRF_LIST);
    } else {
      CRFDAO cdao = new CRFDAO(sm.getDataSource());
      CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
      CRFBean crf = (CRFBean) cdao.findByPK(crfId);
      ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId);
      crf.setVersions(versions);
      // Collection<RuleSetBean> items =
      // getRuleSetService().getRuleSetsByCrf(crf);
      Collection<TableColumnHolder> items = populate(crf, versions);
      TableFacade tableFacade = createTableFacade("rules", request);
      tableFacade.setItems(items); // set the items
      tableFacade.setExportTypes(response, CSV, JEXCEL);
      tableFacade.setStateAttr("restore");

      Limit limit = tableFacade.getLimit();
      if (limit.isExported()) {
        export(tableFacade);
        // return null; // In Spring returning null tells the controller
        // not to do anything.
      }

      String html = html(tableFacade);
      request.setAttribute("rules", html); // Set the Html in the
      // request for the JSP.

      request.setAttribute(CRF, crf);
      forwardPage(Page.VIEW_CRF);
    }
  }
  @SuppressWarnings("unchecked")
  @Override
  public void setDataAndLimitVariables(TableFacade tableFacade) {
    // initialize i18n
    resword = ResourceBundleProvider.getWordsBundle(getLocale());
    resformat = ResourceBundleProvider.getFormatBundle(getLocale());

    Limit limit = tableFacade.getLimit();
    ListSubjectFilter listSubjectFilter = getListSubjectFilter(limit);

    if (!limit.isComplete()) {
      int totalRows = getSubjectDao().getCountWithFilter(listSubjectFilter, getCurrentStudy());
      tableFacade.setTotalRows(totalRows);
    }

    ListSubjectSort listSubjectSort = getListSubjectSort(limit);
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();

    Collection<SubjectBean> items =
        getSubjectDao()
            .getWithFilterAndSort(
                getCurrentStudy(), listSubjectFilter, listSubjectSort, rowStart, rowEnd);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();

    for (SubjectBean subject : items) {
      UserAccountBean owner = (UserAccountBean) getUserAccountDao().findByPK(subject.getOwnerId());
      UserAccountBean updater =
          subject.getUpdaterId() == 0
              ? null
              : (UserAccountBean) getUserAccountDao().findByPK(subject.getUpdaterId());
      HashMap<Object, Object> h = new HashMap<Object, Object>();
      String studySubjectIdAndStudy = "";
      List<StudySubjectBean> studySubjects =
          getStudySubjectDao().findAllBySubjectId(subject.getId());
      for (StudySubjectBean studySubjectBean : studySubjects) {
        StudyBean study = (StudyBean) getStudyDao().findByPK(studySubjectBean.getStudyId());
        studySubjectIdAndStudy += studySubjectIdAndStudy.length() == 0 ? "" : ",";
        studySubjectIdAndStudy += study.getIdentifier() + "-" + studySubjectBean.getLabel();
      }

      h.put("studySubjectIdAndStudy", studySubjectIdAndStudy);
      h.put("subject", subject);
      h.put("subject.uniqueIdentifier", subject.getUniqueIdentifier());
      h.put("subject.gender", subject.getGender());
      h.put("subject.createdDate", subject.getCreatedDate());
      h.put("subject.owner", owner);
      h.put("subject.updatedDate", subject.getUpdatedDate());
      h.put("subject.updater", updater);
      h.put("subject.status", subject.getStatus());

      theItems.add(h);
    }

    tableFacade.setItems(theItems);
  }
 public ActionForward lista(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response) {
   RelacionModuloContaForm relacionForm = (RelacionModuloContaForm) form;
   ConMxcModuloxCuentacontableDAO moduloxCuentacontableDAO =
       new ConMxcModuloxCuentacontableDAO(getSessionHibernate(request));
   InvTprTipoProveedorDAO tipoProveedorDAO =
       new InvTprTipoProveedorDAO(getSessionHibernate(request));
   ConCueCuentaDAO cuentaDAO = new ConCueCuentaDAO(getSessionHibernate(request));
   ConCpaConceptoPartidaDAO conceptoPartidaDAO =
       new ConCpaConceptoPartidaDAO(getSessionHibernate(request));
   List cpaList = moduloxCuentacontableDAO.findByModulo(3);
   TableFacade tableFacade = new TableFacadeImpl(TABLA_ID, request);
   tableFacade.setItems(cpaList);
   // ---- Genera los tipos de formas con que se podran exportar los datos
   tableFacade.setExportTypes(response, ExportType.CSV, ExportType.JEXCEL);
   tableFacade.setStateAttr("restore");
   Limit limit = tableFacade.getLimit();
   if (limit.isExported()) {
     // ---- exporta la tabla
     //    export(tableFacade);
     return null;
   } else {
     String html = html(tableFacade, request);
     request.setAttribute(Constantes.LISTA_KEY, html);
   }
   // reseteamos el form
   relacionForm.setParametro(2, "-1");
   relacionForm.setParametro(3, "-1");
   relacionForm.getConCueCuenta().setCueId(-1);
   relacionForm.setConCpaConceptoPartida(new ConCpaConceptoPartida());
   relacionForm.getConCpaConceptoPartida().setCpaId(-2);
   relacionForm.setCxcCargoAbono((byte) -1);
   // ----- Variables de configuracion
   request.setAttribute("tiposProv", tipoProveedorDAO.findAll());
   request.setAttribute("conceptos", conceptoPartidaDAO.findByCpaDescripcionConcepto(1));
   request.setAttribute("cuentasContables", cuentaDAO.findByCuePosteable(0));
   request.setAttribute("form", form);
   request.setAttribute(Constantes.ACCION_KEY, "/relacionOrdenCompra");
   return mapping.findForward("lista");
 }
  /**
   * A very custom way to sort the items. The AuditUserLoginSort acts as a command for the Hibernate
   * criteria object. Take the Limit information and sort the rows.
   *
   * @param limit The Limit to use.
   */
  protected ListSubjectSort getListSubjectSort(Limit limit) {
    ListSubjectSort listSubjectSort = new ListSubjectSort();
    SortSet sortSet = limit.getSortSet();
    Collection<Sort> sorts = sortSet.getSorts();
    for (Sort sort : sorts) {
      String property = sort.getProperty();
      String order = sort.getOrder().toParam();
      listSubjectSort.addSort(property, order);
    }

    return listSubjectSort;
  }
  /**
   * A very custom way to filter the items. The AuditUserLoginFilter acts as a command for the
   * Hibernate criteria object. Take the Limit information and filter the rows.
   *
   * @param limit The Limit to use.
   */
  protected ListSubjectFilter getListSubjectFilter(Limit limit) {
    ListSubjectFilter listSubjectFilter = new ListSubjectFilter(getDateFormat());
    FilterSet filterSet = limit.getFilterSet();
    Collection<Filter> filters = filterSet.getFilters();
    for (Filter filter : filters) {
      String property = filter.getProperty();
      String value = filter.getValue();
      listSubjectFilter.addFilter(property, value);
    }

    return listSubjectFilter;
  }
Esempio n. 8
0
  @Override
  public String render() {

    Limit limit = getCoreContext().getLimit();
    int page = limit.getRowSelect().getPage();

    StringBuilder action = new StringBuilder("javascript:");
    action.append(
        "jQuery.jmesa.setPage('"
            + limit.getId()
            + "','"
            + (page + 1)
            + "');"
            + getOnInvokeActionJavaScript());

    int totalPages = HtmlUtils.totalPages(getCoreContext());
    if (!HtmlUtils.isNextPageEnabled(page, totalPages)) {
      return disabled();
    }

    return enabled(action.toString());
  }
  @Override
  public String execute() throws Exception {

    String tblid = "etairportTbl";
    TableFacade tableFacade = new TableFacadeImpl(tblid, request);

    tableFacade.setStateAttr("restore");
    tableFacade.setEditable(false);

    tableFacade.setMaxRows(10);
    // tableFacade.setTotalRows(etairports.size());
    tableFacade.setMaxRowsIncrements(10, 20, 50);
    Limit limit = tableFacade.getLimit();

    RowSelect rowSelect = limit.getRowSelect();

    FilterSet filterSet = limit.getFilterSet();
    Collection<Filter> filters = filterSet.getFilters();

    // tableFacade.setItems(etairports);

    request.setAttribute("traveler_tbl", ""); // buildTable(tableFacade)
    return SUCCESS;
  }
  @SuppressWarnings("unchecked")
  public String paging() {
    String tblid = "traveler_tbl";

    TableFacade tableFacade = new TableFacadeImpl(tblid, request);
    String min = request.getParameter(tblid + "_rng_min");
    String max = request.getParameter(tblid + "_rng_max");
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date mindate = null;
    Date maxdate = null;
    if (min != null && max != null) {
      try {
        mindate = dateFormat.parse(min);
        maxdate = dateFormat.parse(max);
        System.out.println("mindate=" + mindate + ";maxdate=" + maxdate);
        HttpSession session = request.getSession();
        if (session != null) {
          session.setAttribute(tblid + "_rng_min", mindate);
          session.setAttribute(tblid + "_rng_max", maxdate);
        }
      } catch (ParseException e) {
        e.printStackTrace();
      }

    } else {
      HttpSession session = request.getSession();
      if (session != null) {
        mindate = (Date) session.getAttribute(tblid + "_rng_min");
        maxdate = (Date) session.getAttribute(tblid + "_rng_max");
      }
    }
    tableFacade.setStateAttr("restore");
    tableFacade.setMaxRows(10);
    Map<String, Object> param = new HashMap(2);
    PagingAndSorting pg = new PagingAndSorting();

    String sql = "select o from " + TargetCustomerTicket.class.getName() + " as o ";
    if (mindate != null && maxdate != null) {
      sql += " where o.fltDate>=:mindate and o.fltDate<=:maxdate";
      param.put("mindate", mindate);
      param.put("maxdate", maxdate);
    }
    etairports = this.baseService.query(sql, param, null);
    tableFacade.setTotalRows(etairports.size());
    tableFacade.setMaxRowsIncrements(10, 20, 50);
    Limit limit = tableFacade.getLimit();
    RowSelect rowSelect = limit.getRowSelect();
    SortSet sortSet = limit.getSortSet();
    if (sortSet != null) {
      Collection<Sort> sorts = sortSet.getSorts();
      if (sorts != null) {
        for (Iterator iterator = sorts.iterator(); iterator.hasNext(); ) {
          Sort sort = (Sort) iterator.next();
          Order order = sort.getOrder();
          String s = "";
          if (order.equals(Order.ASC)) s = "asc";
          if (order.equals(Order.DESC)) s = "desc";
          int position = sort.getPosition();
          String property = sort.getProperty();
          System.out.println(
              "{property:'" + property + "',position:" + position + ",order:'" + s + "'}");
        }
      }
    }
    if (rowSelect != null) {
      int rowStart = rowSelect.getRowStart();
      int rowEnd = rowSelect.getRowEnd();
      int page = rowSelect.getPage();
      System.out.println("rowstart=" + rowStart + ";rowend=" + rowEnd + ";page=" + page);
      ArrayList rs = new ArrayList(10);
      for (int i = rowStart; i < rowEnd && i < etairports.size(); i++) {
        rs.add(etairports.get(i));
      }
      tableFacade.setItems(rs);
    }
    final String buildTable = buildTable(tableFacade);
    ByteArrayInputStream inputStream = null;
    try {
      inputStream = new ByteArrayInputStream(buildTable.getBytes("UTF8"));
    } catch (UnsupportedEncodingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    this.setPgInputStream(inputStream);
    return "pgresult";
  }