Package de.iritgo.aktera.ui.listing

Examples of de.iritgo.aktera.ui.listing.ListingDescriptor


   * @throws ModelException
   */
  public ListingDescriptor createListingDescriptor(ModelRequest request)
    throws ConfigurationException, PersistenceException, ModelException
  {
    ListingDescriptor listing = (ListingDescriptor) UserTools.getContextObject(request, id);

    if (listing != null)
    {
      return listing;
    }

    listing = de.iritgo.aktera.ui.listing.Listing.createListingFromConfig(getConfiguration(), getDerivationPath());

    listing.setNg(true);
    listing.setCommandStyle(commandStyle);
    listing.setTitle(title);
    listing.setTitleBundle(titleBundle);

    if (header != null)
    {
      listing.setHeader(header);
    }

    listing.setIcon(icon);
    listing.setEmbedded(embedded);
    listing.setSingleSelection(singleSelection);
    listing.setSelectable(selectable);
    listing.setKeyName(keyName);
    listing.setId(listId);
    listing.setListModel(listModel);

    listing.setCommand(ListingDescriptor.COMMAND_VIEW, cmdView);
    listing.setCommand(ListingDescriptor.COMMAND_SEARCH, cmdSearch);
    listing.setCommand(ListingDescriptor.COMMAND_NEW, cmdNew);
    listing.setCommand(ListingDescriptor.COMMAND_BACK, cmdBack);
    listing.setCommand(ListingDescriptor.COMMAND_EXECUTE, cmdExecute);

    if (commandConfig.size() > 0)
    {
      CommandDescriptor cmdDescriptor = new CommandDescriptor();

      for (Iterator i = commandConfig.iterator(); i.hasNext();)
      {
        Configuration aCommandConfig = (Configuration) i.next();

        String permission = aCommandConfig.getAttribute("permission", null);

        if (permission != null && ! UserTools.currentUserHasPermission(request, permission))
        {
          continue;
        }

        String role = aCommandConfig.getAttribute("role", null);

        if (role != null && ! UserTools.currentUserIsInGroup(request, role))
        {
          continue;
        }

        CommandInfo cmdInfo = new CommandInfo(aCommandConfig.getAttribute("model"), aCommandConfig
                .getAttribute("id"), aCommandConfig.getAttribute("label"), aCommandConfig.getAttribute(
                "icon", null));

        cmdInfo.setBundle(aCommandConfig.getAttribute("bundle", "Aktera"));

        Configuration[] params = aCommandConfig.getChildren("param");

        setParameters(cmdInfo, params);

        cmdDescriptor.add(cmdInfo);
      }

      listing.setListCommands(cmdDescriptor);
    }

    if (! overview && itemCommandConfig.size() > 0)
    {
      CommandDescriptor cmdDescriptor = new CommandDescriptor("selectedItems");

      for (Iterator i = itemCommandConfig.iterator(); i.hasNext();)
      {
        Configuration aItemCommandConfig = (Configuration) i.next();

        if (! NumberTools.toBool(aItemCommandConfig.getAttribute("visible", "true"), true))
        {
          continue;
        }

        if (cmdDescriptor.hasCommand(aItemCommandConfig.getAttribute("id")))
        {
          continue;
        }

        CommandInfo cmdInfo = new CommandInfo(aItemCommandConfig.getAttribute("model", aItemCommandConfig
                .getAttribute("bean", null)), aItemCommandConfig.getAttribute("id"), aItemCommandConfig
                .getAttribute("label"), aItemCommandConfig.getAttribute("icon", null));

        cmdInfo.setStyle(aItemCommandConfig.getAttribute("style", null));
        cmdInfo.setBundle(aItemCommandConfig.getAttribute("bundle", "Aktera"));

        if (aItemCommandConfig.getAttribute("bean", null) != null)
        {
          cmdInfo.setBean(true);
        }

        Configuration[] params = aItemCommandConfig.getChildren("param");

        setParameters(cmdInfo, params);

        cmdDescriptor.add(cmdInfo);
      }

      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)
    {
    }
    finally
    {
      KeelTools.releaseService(persistentManager);
    }

    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 : "");

    UserTools.setContextObject(request, id, listing);

    return listing;
  }
View Full Code Here


      ModelRequestWrapper wrappedRequest = new ModelRequestWrapper(request);
      ModelResponseWrapper wrappedResponse = new ModelResponseWrapper(response);

      readConfig();

      ListingDescriptor listing = createListingDescriptor(wrappedRequest);

      if (! StringTools.isEmpty(request.getParameterAsString("listId")))
      {
        listing.setId(request.getParameterAsString("listId"));
      }

      if (request.getParameter(listing.getId() + "Page") != null)
      {
        listing.setPage(NumberTools.toInt(request.getParameter(listing.getId() + "Page"), listing.getPage()));
      }

      listing.updateSort(wrappedRequest);

      if (! StringTools.isTrimEmpty(request.getParameterAsString(listId
              + ListingDescriptor.SEARCH_CATEGORY_PARAMETER_SUFFIX)))
      {
        listing.setCategory(request.getParameterAsString(listId
                + ListingDescriptor.SEARCH_CATEGORY_PARAMETER_SUFFIX));
      }

      Map<String, String> searchCategories = handler.createSearchCategories(wrappedRequest, listing);

      if (searchCategories != null)
      {
        listing.setCategories(searchCategories);
      }

      String currentSearchCategory = handler.getCurrentSearchCategory(wrappedRequest, listing);

      if (currentSearchCategory != null)
      {
        listing.setCategory(currentSearchCategory);
      }

      ListContext context = createListContext(wrappedRequest, listing);

      handler.adjustListing(wrappedRequest, listing, context);

      ListFiller filler = handler.createListing(wrappedRequest, listing, handler, context);

      ListTools.createListing(wrappedRequest, wrappedResponse, listing, handler, context, filler);

      wrappedResponse.get(listing.getId()).setAttribute("formAction", "bean");

      if (forward != null)
      {
        response.setForward(forward);
      }
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.ui.listing.ListingDescriptor

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.