static Map getTokensToChangeDollarsAndNL() {
   if (tokensToChangeDollarsAndNL == null) {
     tokensToChangeDollarsAndNL = new HashMap();
     tokensToChangeDollarsAndNL.put("${", "o.");
     tokensToChangeDollarsAndNL.put("}", "");
     tokensToChangeDollarsAndNL.put("\n", "");
   }
   return tokensToChangeDollarsAndNL;
 }
Example #2
0
 public void addPropertyMapping(PropertyMapping propertyMapping) throws XavaException {
   propertyMappings.put(propertyMapping.getProperty(), propertyMapping);
   modelProperties.add(propertyMapping.getProperty());
   // To keep order
   tableColumns.add(propertyMapping.getColumn());
   if (propertyMapping.hasFormula() && !getMetaModel().isAnnotatedEJB3()) {
     propertyMapping.getMetaProperty().setReadOnly(true);
   }
 }
 private static Map getArgumentsToHQL() {
   if (argumentsToHQL == null) {
     argumentsToHQL = new HashMap();
     for (int i = 0; i < 30; i++) {
       argumentsToHQL.put("{" + i + "}", ":arg" + i);
     }
   }
   return argumentsToHQL;
 }
 private static Map getArgumentsJBoss11ToEJBQL() {
   if (argumentsJBoss11ToEJBQL == null) {
     argumentsJBoss11ToEJBQL = new HashMap();
     for (int i = 0; i < 30; i++) {
       argumentsJBoss11ToEJBQL.put("{" + i + "}", "?" + (i + 1));
     }
   }
   return argumentsJBoss11ToEJBQL;
 }
 /**
  * This method must be used to obtain the dir allocation context for a particular value of the
  * context name. The context name must be an item defined in the Configuration object for which we
  * want to control the dir allocations (e.g., <code>mapred.local.dir</code>). The method will
  * create a context for that name if it doesn't already exist.
  */
 private AllocatorPerContext obtainContext(String contextCfgItemName) {
   synchronized (contexts) {
     AllocatorPerContext l = contexts.get(contextCfgItemName);
     if (l == null) {
       contexts.put(contextCfgItemName, (l = new AllocatorPerContext(contextCfgItemName)));
     }
     return l;
   }
 }
Example #6
0
 public void addReferenceMapping(ReferenceMapping referenceMapping) throws XavaException {
   if (referenceMappings == null) referenceMappings = new HashMap();
   referenceMappings.put(referenceMapping.getReference(), referenceMapping);
   referenceMapping.setContainer(this);
 }
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      Locales.setCurrent(request);
      if (Users.getCurrent() == null) { // for a bug in websphere portal 5.1 with Domino LDAP
        Users.setCurrent((String) request.getSession().getAttribute("xava.user"));
      }
      request.getParameter("application"); // for a bug in websphere 5.1
      request.getParameter("module"); // for a bug in websphere 5.1
      Tab tab = (Tab) request.getSession().getAttribute("xava_reportTab");
      int[] selectedRowsNumber =
          (int[]) request.getSession().getAttribute("xava_selectedRowsReportTab");
      Map[] selectedKeys = (Map[]) request.getSession().getAttribute("xava_selectedKeysReportTab");
      int[] selectedRows = getSelectedRows(selectedRowsNumber, selectedKeys, tab);
      request.getSession().removeAttribute("xava_selectedRowsReportTab");
      Integer columnCountLimit =
          (Integer) request.getSession().getAttribute("xava_columnCountLimitReportTab");
      request.getSession().removeAttribute("xava_columnCountLimitReportTab");

      setDefaultSchema(request);
      String user = (String) request.getSession().getAttribute("xava_user");
      request.getSession().removeAttribute("xava_user");
      Users.setCurrent(user);
      String uri = request.getRequestURI();
      if (uri.endsWith(".pdf")) {
        InputStream is;
        JRDataSource ds;
        Map parameters = new HashMap();
        synchronized (tab) {
          tab.setRequest(request);
          parameters.put("Title", tab.getTitle());
          parameters.put("Organization", getOrganization());
          parameters.put("Date", getCurrentDate());
          for (String totalProperty : tab.getTotalPropertiesNames()) {
            parameters.put(totalProperty + "__TOTAL__", getTotal(request, tab, totalProperty));
          }
          TableModel tableModel = getTableModel(request, tab, selectedRows, false, true, null);
          tableModel.getValueAt(0, 0);
          if (tableModel.getRowCount() == 0) {
            generateNoRowsPage(response);
            return;
          }
          is = getReport(request, response, tab, tableModel, columnCountLimit);
          ds = new JRTableModelDataSource(tableModel);
        }
        JasperPrint jprint = JasperFillManager.fillReport(is, parameters, ds);
        response.setContentType("application/pdf");
        response.setHeader(
            "Content-Disposition", "inline; filename=\"" + getFileName(tab) + ".pdf\"");
        JasperExportManager.exportReportToPdfStream(jprint, response.getOutputStream());
      } else if (uri.endsWith(".csv")) {
        String csvEncoding = XavaPreferences.getInstance().getCSVEncoding();
        if (!Is.emptyString(csvEncoding)) {
          response.setCharacterEncoding(csvEncoding);
        }
        response.setContentType("text/x-csv");
        response.setHeader(
            "Content-Disposition", "inline; filename=\"" + getFileName(tab) + ".csv\"");
        synchronized (tab) {
          tab.setRequest(request);
          response
              .getWriter()
              .print(
                  TableModels.toCSV(
                      getTableModel(request, tab, selectedRows, true, false, columnCountLimit)));
        }
      } else {
        throw new ServletException(
            XavaResources.getString("report_type_not_supported", "", ".pdf .csv"));
      }
    } catch (Exception ex) {
      log.error(ex.getMessage(), ex);
      throw new ServletException(XavaResources.getString("report_error"));
    } finally {
      request.getSession().removeAttribute("xava_reportTab");
    }
  }
Example #8
0
 public void addMetaProperty(MetaProperty metaProperty) {
   if (metaPropertiesTab == null) {
     metaPropertiesTab = new HashMap();
   }
   metaPropertiesTab.put(metaProperty.getName(), metaProperty);
 }