Exemplo n.º 1
0
 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());
   }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
    }
  }
Exemplo n.º 4
0
 public String getEJBQLCondition() throws XavaException {
   StringBuffer sb = new StringBuffer("SELECT OBJECT(o) FROM ");
   sb.append(getMetaModel().getName());
   sb.append(" o");
   if (!Is.emptyString(this.condition)) {
     sb.append(" WHERE ");
     String attributesCondition =
         getMetaModel().getMapping().changePropertiesByCMPAttributes(this.condition);
     sb.append(Strings.change(attributesCondition, getArgumentsJBoss11ToEJBQL()));
   }
   if (!Is.emptyString(this.order)) {
     sb.append(" ORDER BY ");
     sb.append(getMetaModel().getMapping().changePropertiesByCMPAttributes(this.order));
   }
   return sb.toString();
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 private String getHQLCondition(boolean order) throws XavaException {
   StringBuffer sb = new StringBuffer("from ");
   sb.append(getMetaModel().getName());
   sb.append(" as o");
   if (!Is.emptyString(this.condition)) {
     sb.append(" where ");
     String condition = transformAggregateProperties(getCondition());
     condition = Strings.change(condition, getArgumentsToHQL());
     sb.append(Strings.change(condition, getTokensToChangeDollarsAndNL()));
   }
   if (order && !Is.emptyString(this.order)) {
     sb.append(" order by ");
     sb.append(
         Strings.change(
             transformAggregateProperties(this.order), getTokensToChangeDollarsAndNL()));
   }
   return sb.toString();
 }
Exemplo n.º 7
0
 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;
   }
 }
Exemplo n.º 8
0
 public void testValidValuesInList() throws Exception {
   int quantity = getListRowCount();
   assertTrue("For this test is needed at least one created delivery", quantity > 0);
   Collection values = new ArrayList();
   values.add("Lokal");
   values.add("Nachional");
   values.add("Internachional");
   boolean thereIsOne = false;
   for (int i = 0; i < quantity; i++) {
     String value = getValueInList(i, "distance");
     if (Is.emptyString(value)) continue;
     if (values.contains(value)) {
       thereIsOne = true;
       continue;
     }
     fail("Only the next values are valid: " + values);
   }
   assertTrue(
       "For this test is need at least one delivery with value in 'distance' property",
       thereIsOne);
 }
  public void execute() throws Exception {
    // TODO Auto-generated method stub

    Long key = (Long) getView().getAllValues().get("id");

    System.out.println("\n\n\n\n\n\n\n\n\n\n The value sent===" + getView().getAllValues());
    Map payingAcct = (Map) getView().getAllValues().get("payingAccount");

    PaymentBatch batch = XPersistence.getManager().find(PaymentBatch.class, key);
    TransitAccount debitAccount = batch.getPayingAccount();

    if (payingAcct.get("id") != null) {
      debitAccount = (TransitAccount) MapFacade.findEntity("TransitAccount", payingAcct);
      batch.setPayingAccount(debitAccount);
      XPersistence.getManager().merge(batch);
    }
    if (UserManager.loginUserHasRole("funder") && debitAccount == null) {
      addError("As funder, You Need to Attach Debit Account", null);
      return;
    }

    Long transId = (Long) getView().getObject("transId");

    Boolean fina = (Boolean) getView().getObject("final");

    if (fina) {
      if (debitAccount == null) {
        addError(" Debit Account Yet To be Attached", null);
        return;
      }
      String token = (String) getView().getObject("token");
      String softToken = (String) getView().getValue("softToken");
      if (Is.empty(softToken)) {
        addError("Soft Token Is Required", null);
        return;
      }
      DateTime dT = (DateTime) getView().getObject("fiveMinutes");
      DateTime presentTime = new DateTime(Dates.withTime(Dates.createCurrent()));

      if (!Is.equalAsStringIgnoreCase(token, softToken)) {
        addError("Incorrect Soft Token", null);
        return;
      }
      if (dT.getMillis() < presentTime.getMillis()) {
        addError("Token Has Expired", null);
        return;
      }

      System.out.println(
          "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n The sent object to this place ===" + transId);
    }

    Transaction transaction = XPersistence.getManager().find(Transaction.class, transId);

    AsyncEventBus eventBus = new AsyncEventBus(Executors.newCachedThreadPool());
    eventBus.register(transaction);
    System.out.println(" 1111111approve already commented out......... ");
    eventBus.post(new Object());

    // transaction.approve();
    closeDialog();
    setNextMode(LIST);
  }
  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");
    }
  }
Exemplo n.º 11
0
 public boolean hasDefaultOrder() {
   return !Is.emptyString(this.defaultOrder);
 }
Exemplo n.º 12
0
 public boolean hasBaseCondition() {
   return !Is.emptyString(this.baseCondition);
 }