Package de.iritgo.aktera.ui.form

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


        formular.setPage(NumberTools.toInt(request.getParameter("AKTERA_page"), formular.getPage()));
      }

      handler.prepareFormular(wrappedRequest, wrappedResponse, formular);

      PersistentDescriptor persistents = formular.getPersistents();
      context.setPersistents(persistents);

      if (persistents == null
              || (request.getParameter("error") == null && request.getParameter("reedit") == null && ! reeditAlways))
      {
        persistents = new PersistentDescriptor(persistentsId);
        context.setPersistents(persistents);

        for (Configuration configuration : attributeConfig)
        {
          String name = configuration.getAttribute("name");
          Object value = null;
          try
          {
            value = context.evalExpressionLanguageValue(configuration.getAttribute("value"));
            if (value != null)
            {
              persistents.putAttribute(name, value);
            }
          }
          catch (IllegalArgumentException x)
          {
            logger.error("Unable to retrieve value for attribute " + name);
View Full Code Here


      }

      listing.setItemCommands(cmdDescriptor);
    }

    PersistentDescriptor persistents = new PersistentDescriptor();
    PersistentFactory persistentManager = null;

    try
    {
      persistentManager = (PersistentFactory) KeelTools.getService(PersistentFactory.ROLE);

      if (persistentConfig.size() > 0)
      {
        Iterator persistentConfigIterator = persistentConfig.iterator();
        Configuration aPersistentConfig = (Configuration) persistentConfigIterator.next();

        Persistent persistent = persistentManager.create(aPersistentConfig.getAttribute("name"));

        persistents.put(aPersistentConfig.getAttribute("id"), persistent);

        for (; persistentConfigIterator.hasNext();)
        {
          aPersistentConfig = (Configuration) persistentConfigIterator.next();

          persistent = persistentManager.create(aPersistentConfig.getAttribute("name"));

          String join = aPersistentConfig.getAttribute("join", null);

          if (join != null)
          {
            persistents.put(aPersistentConfig.getAttribute("id"), persistent).join(join,
                    aPersistentConfig.getAttribute("otherKey"),
                    aPersistentConfig.getAttribute("myKey"),
                    aPersistentConfig.getAttribute("condition", null));
          }
          else
          {
            persistents.put(aPersistentConfig.getAttribute("id"), persistent);
          }
        }
      }
    }
    catch (ServiceException x)
View Full Code Here

   * @return The SQL SELECT fields clause (SELECT a,b,c...)
   */
  private static String createSqlSelectFields(ListingDescriptor listing)
    throws ModelException, PersistenceException, SQLException
  {
    PersistentDescriptor persistents = listing.getPersistents();
    StringBuffer sql = new StringBuffer("SELECT ");
    PersistentMetaData idPersistentMeta = persistents.getMetaData(listing.getIdPersistent());

    if (idPersistentMeta == null)
    {
      throw new ModelException("ListTools: Unknown persistent specified for id column '" + listing.getIdColumn()
              + "'");
    }

    if (listing.getNumIdColumns() == 1)
    {
      sql.append(listing.getIdPersistent() + "." + idPersistentMeta.getDBFieldName(listing.getIdField())
              + " AS id");
    }
    else
    {
      int col = 1;

      for (Iterator i = listing.getIdColumns().iterator(); i.hasNext();)
      {
        ListingDescriptor.IdColumnInfo idInfo = (ListingDescriptor.IdColumnInfo) i.next();

        if (col > 1)
        {
          sql.append(", ");
        }

        sql
                .append(idInfo.persistent + "." + idPersistentMeta.getDBFieldName(idInfo.field)
                        + " AS id" + (col++));
      }
    }

    for (Iterator i = listing.columnIterator(); i.hasNext();)
    {
      ColumnDescriptor column = (ColumnDescriptor) i.next();

      if ("custom".equals(column.getViewer()) || column.getViewer().startsWith("js:"))
      {
        continue;
      }

      sql.append(", ");

      PersistentMetaData columnPersistentMeta = persistents.getMetaData(column.getPersistent());

      if (columnPersistentMeta == null)
      {
        throw new ModelException("ListTools: Unknown persistent specified for column '" + column.getName()
                + "'");
View Full Code Here

   * @return The SQL FROM clause
   */
  private static String createSqlFrom(ListingDescriptor listing)
    throws ModelException, PersistenceException, SQLException
  {
    PersistentDescriptor persistents = listing.getPersistents();
    StringBuffer sql = new StringBuffer("");
    Iterator iKey = persistents.keyIterator();

    if (! iKey.hasNext())
    {
      throw new ModelException("No persistents defined for listing " + listing.getHeader());
    }

    String key = (String) iKey.next();
    PersistentMetaData persistentMeta = persistents.getMetaData(key);

    sql.append(" FROM " + persistentMeta.getTableName() + " AS " + key);

    for (; iKey.hasNext();)
    {
      key = (String) iKey.next();
      persistentMeta = persistents.getMetaData(key);
      sql.append(" LEFT JOIN " + persistentMeta.getTableName() + " AS " + key + " ON ");

      PersistentDescriptor.JoinInfo join = persistents.getJoin(key);

      if (join == null)
      {
        throw new ModelException("ListTools: No join info defined for persistent '" + key + "'");
      }

      PersistentMetaData persistentMetaJoin = persistents.getMetaData(join.getPersistent());

      sql.append(join.getPersistent() + "." + persistentMetaJoin.getDBFieldName(join.getKey()) + " = " + key
              + "." + persistentMeta.getDBFieldName(join.getMyKey()));

      if (join.getCondition() != null)
View Full Code Here

   *            The listing for which to generate the statement
   * @return The SQL WHERE clause
   */
  private static String createSqlWhere(ModelRequest request, ListingDescriptor listing) throws PersistenceException
  {
    PersistentDescriptor persistents = listing.getPersistents();
    PersistentMetaData idPersistentMeta = persistents.getMetaData(listing.getIdPersistent());

    StringBuffer condition = new StringBuffer();

    if (! StringTools.isTrimEmpty(listing.getCondition()))
    {
      condition.append(" WHERE " + listing.getCondition());
    }

    if (listing.getSortColumns().size() > 0)
    {
      condition.append(" ORDER BY ");
    }

    for (Iterator i = listing.sortColumnIterator(); i.hasNext();)
    {
      ColumnDescriptor column = (ColumnDescriptor) i.next();

      condition.append(column.getName() + (column.getSort() == SortOrder.DESCENDING ? " DESC" : " ASC"));

      if (i.hasNext())
      {
        condition.append(", ");
      }
    }

    StringBuffer sqlCondition = new StringBuffer();

    for (StringTokenizer st = new StringTokenizer(condition.toString()); st.hasMoreTokens();)
    {
      String token = st.nextToken();
      int dotIndex = token.indexOf('.');

      if (dotIndex != - 1)
      {
        String persistent = token.substring(0, dotIndex);
        String field = token.substring(dotIndex + 1);
        PersistentMetaData meta = persistents.getMetaData(persistent);

        if (meta != null)
        {
          sqlCondition.append(" " + persistent + "." + meta.getDBFieldName(field) + " ");
        }
View Full Code Here

TOP

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

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.