コード例 #1
0
ファイル: MetaTab.java プロジェクト: OpenXavaEx/OpenXavaEx
 public void setDefaultValues() {
   for (MetaTab t : MetaTabsDefaultValues.getMetaTabsForModel(getMetaComponent().getName())) {
     if (t.getMetaFilter() != null && getMetaFilter() == null) setMetaFilter(t.getMetaFilter());
     if (t.getMetaRowStyles() != null && getMetaRowStyles() == null)
       setMetaRowStyles(t.getMetaRowStyles());
     if (t.properties != null && properties == null) properties = t.properties;
     if (!Is.emptyString(t.getBaseCondition()) && Is.emptyString(getBaseCondition()))
       setBaseCondition(t.getBaseCondition());
     if (!Is.emptyString(t.getDefaultOrder()) & Is.emptyString(getDefaultOrder()))
       setDefaultOrder(t.getDefaultOrder());
   }
 }
コード例 #2
0
 public String getTable() {
   // Change this if by polymorphism ?
   if (isCodeGenerationTime()) return table;
   if (XavaPreferences.getInstance().isJPAPersistence()
       && getSchema() == null
       && !Is.emptyString(XPersistence.getDefaultSchema())) {
     return XPersistence.getDefaultSchema() + "." + table;
   } else if (XavaPreferences.getInstance().isHibernatePersistence()
       && getSchema() == null
       && !Is.emptyString(XHibernate.getDefaultSchema())) {
     return XHibernate.getDefaultSchema() + "." + table;
   }
   return table;
 }
コード例 #3
0
  public String getQualifiedColumn(String modelProperty) throws XavaException {
    PropertyMapping propertyMapping = (PropertyMapping) propertyMappings.get(modelProperty);
    if (propertyMapping != null && propertyMapping.hasFormula()) return getColumn(modelProperty);

    String tableColumn = getTableColumn(modelProperty, true);
    if (Is.emptyString(tableColumn)) return "'" + modelProperty + "'";
    if (referencePropertyWithFormula) {
      referencePropertyWithFormula = false;
      return tableColumn;
    }
    // for calculated fields or created by multiple converter

    if (modelProperty.indexOf('.') >= 0) {
      if (tableColumn.indexOf('.') < 0) return tableColumn;
      String reference = modelProperty.substring(0, modelProperty.lastIndexOf('.'));
      if (tableColumn.startsWith(getTableToQualifyColumn() + ".")) {
        String member = modelProperty.substring(modelProperty.lastIndexOf('.') + 1);
        if (getMetaModel().getMetaReference(reference).getMetaModelReferenced().isKey(member))
          return tableColumn;
      }

      // The next code uses the alias of the table instead of its name. In order to
      // support multiple references to the same model
      if (reference.indexOf('.') >= 0) {
        if (getMetaModel().getMetaProperty(modelProperty).isKey()) {
          reference = reference.substring(0, reference.lastIndexOf('.'));
        }
        reference = reference.replaceAll("\\.", "_");
      }
      return "T_" + reference + tableColumn.substring(tableColumn.lastIndexOf('.'));
    } else {
      return getTableToQualifyColumn() + "." + tableColumn;
    }
  }
コード例 #4
0
ファイル: MetaTab.java プロジェクト: OpenXavaEx/OpenXavaEx
 private List obtainPropertiesNamesUsedToCalculate() throws XavaException {
   Set result = new HashSet();
   Iterator itProperties = getMetaPropertiesCalculated().iterator();
   while (itProperties.hasNext()) {
     MetaProperty metaProperty = (MetaProperty) itProperties.next();
     if (!metaProperty.hasCalculator()) continue;
     MetaSetsContainer metaCalculator = metaProperty.getMetaCalculator();
     if (!metaCalculator.containsMetaSets()) continue;
     Iterator itSets = metaCalculator.getMetaSets().iterator();
     while (itSets.hasNext()) {
       MetaSet set = (MetaSet) itSets.next();
       String propertyNameFrom = set.getPropertyNameFrom();
       if (!Is.emptyString(propertyNameFrom)) {
         String qualifiedName = metaProperty.getQualifiedName();
         int idx = qualifiedName.indexOf('.');
         String ref = idx < 0 ? "" : qualifiedName.substring(0, idx + 1);
         String qualifiedPropertyNameFrom = ref + propertyNameFrom;
         if (!getPropertiesNames().contains(qualifiedPropertyNameFrom)) {
           result.add(qualifiedPropertyNameFrom);
         }
       }
     }
   }
   return new ArrayList(result);
 }
コード例 #5
0
ファイル: MetaTab.java プロジェクト: OpenXavaEx/OpenXavaEx
 public static String getTitleI18n(Locale locale, String modelName, String tabName)
     throws XavaException {
   String id = null;
   if (Is.emptyString(tabName)) {
     id = modelName + ".tab.title";
   } else {
     id = modelName + ".tabs." + tabName + ".title";
   }
   if (Labels.existsExact(id, locale)) {
     return Labels.get(id, locale);
   } else {
     return null;
   }
 }
コード例 #6
0
  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");
    }
  }
コード例 #7
0
ファイル: MetaTab.java プロジェクト: OpenXavaEx/OpenXavaEx
 public boolean hasDefaultOrder() {
   return !Is.emptyString(this.defaultOrder);
 }
コード例 #8
0
ファイル: MetaTab.java プロジェクト: OpenXavaEx/OpenXavaEx
 public boolean hasBaseCondition() {
   return !Is.emptyString(this.baseCondition);
 }