Package de.iritgo.aktera.ui.form

Examples of de.iritgo.aktera.ui.form.QueryDescriptor


    listing.setPersistents(persistents);

    if (queryConfig != null)
    {
      QueryDescriptor qd = new QueryDescriptor();

      listing.setQuery(qd);
      qd.setName(queryConfig.getAttribute("name", null));
      qd.setDaoName(queryConfig.getAttribute("dao", null));
      qd.setDaoMethodName(queryConfig.getAttribute("method", null));
      qd.setQuery(queryConfig.getChild("find").getValue(queryConfig.getChild("expression").getValue(null)));
      qd.setCountQuery(queryConfig.getChild("count").getValue(null));

      for (Configuration paramConfig : queryConfig.getChildren("param"))
      {
        String value = paramConfig.getAttribute("value", null);

        if (value == null)
        {
          value = paramConfig.getValue();
        }

        qd.setParam(paramConfig.getAttribute("name"), value);
      }
    }

    listing.setCondition(condition != null ? condition : "");
View Full Code Here


   */
  private static void createListingWithQuery(ModelRequest request, ModelResponse response, ListingDescriptor listing,
          ListingHandler handler, ListContext context) throws ModelException, PersistenceException
  {
    StandardDao standardDao = (StandardDao) SpringTools.getBean(StandardDao.ID);
    QueryDescriptor query = listing.getQuery();
    Properties queryParams = ExpressionLanguageContext.evalExpressionLanguageValue(context, request, query
            .getParams());
    int count = 0;

    if (query.getDaoName() != null)
    {
      try
      {
        java.util.List list = (java.util.List) MethodUtils.invokeExactMethod(SpringTools.getBean(query
                .getDaoName()), query.getDaoMethodName(), queryParams);

        count = list.size();
      }
      catch (NoSuchMethodException x)
      {
        throw new ModelException(x);
      }
      catch (IllegalAccessException x)
      {
        throw new ModelException(x);
      }
      catch (InvocationTargetException x)
      {
        throw new ModelException(x.getTargetException());
      }
    }
    else if (query.getCountName() != null)
    {
      count = (int) standardDao.countByNamedQuery(query.getCountName(), queryParams);
    }
    else if (query.getName() != null)
    {
      count = (int) standardDao.countByNamedFindQuery(query.getName(), queryParams);
    }
    else
    {
      if (query.getCountQuery() != null)
      {
        count = (int) standardDao.countByQuery(query.getCountQuery(), queryParams);
      }
      else
      {
        count = (int) standardDao.countByFindQuery(query.getQuery(), queryParams);
      }
    }

    int page = Math.max(listing.getPage(), 1);
    int maxPage = (Math.max(0, count - 1) / context.getResultsPerPage()) + 1;

    page = Math.min(page, maxPage);

    context.setPage(page);
    context.setFirstResult((page - 1) * context.getResultsPerPage());

    Output outList = createHeaderElements(request, response, listing, context);

    outList.setAttribute("pageCount", new Integer(maxPage));
    outList.setAttribute("page", String.valueOf(page));

    int firstResult = (page - 1) * context.getResultsPerPage();
    int maxResults = context.getResultsPerPage();
    java.util.List res = null;

    if (query.getDaoName() != null)
    {
      try
      {
        res = (java.util.List) MethodUtils.invokeExactMethod(SpringTools.getBean(query.getDaoName()), query
                .getDaoMethodName(), queryParams);
      }
      catch (NoSuchMethodException x)
      {
        throw new ModelException(x);
      }
      catch (IllegalAccessException x)
      {
        throw new ModelException(x);
      }
      catch (InvocationTargetException x)
      {
        throw new ModelException(x.getTargetException());
      }
    }
    else if (query.getName() != null)
    {
      res = standardDao.findByNamedQuery(query.getName(), queryParams, firstResult, maxResults, listing
              .getSortColumnName(), listing.getSortOrder());
    }
    else
    {
      res = standardDao.findByQuery(query.getQuery(), queryParams, firstResult, maxResults, listing
              .getSortColumnName(), listing.getSortOrder());
    }

    int rowNum = 1;

View Full Code Here

TOP

Related Classes of de.iritgo.aktera.ui.form.QueryDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.