Package de.iritgo.aktera.model

Examples of de.iritgo.aktera.model.ModelResponse


   * @param params
   *            Model parameters.
   */
  public static ModelResponse callModel(ModelRequest req, String model, Properties params) throws ModelException
  {
    ModelResponse res = req.createResponse();
    Command cmd = res.createCommand(model);

    if (params != null)
    {
      for (Iterator i = params.entrySet().iterator(); i.hasNext();)
      {
View Full Code Here


   *            The name of the model to call.
   */
  public static void callModel(ModelRequest req, ModelResponse res, String model) throws ModelException
  {
    Command cmd = res.createCommand(model);
    ModelResponse newRes = cmd.execute(req, res, true, false);

    KeelTools.copyResponseElements(res, newRes);
  }
View Full Code Here

   * @param params
   *            Model parameters.
   */
  public static ModelResponse callModel(ModelRequest req, String model, Object... params) throws ModelException
  {
    ModelResponse res = req.createResponse();
    Command cmd = res.createCommand(model);

    for (Pair<String, Object> param : new PairwiseIterator<Object, String, Object>(params))
    {
      cmd.setParameter(param.get1(), param.get2());
    }
View Full Code Here

   * @param req The model request.
   * @throws ModelException In case of a business failure.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    if (! UserTools.currentUserIsInGroup(req, "root"))
    {
      return res;
    }

    SystemConfigManager systemConfigManager = (SystemConfigManager) req.getSpringBean(SystemConfigManager.ID);

    String state = systemConfigManager.getConfigState();

    if (SystemConfigManager.CHANGE_REBOOT.equals(state))
    {
      Output out = res.createOutput("warning", "configurationWasModifiedAndNeedsRebootHint");

      out.setAttribute("bundle", "IPtellBase");
      res.add(out);
    }
    else if (systemConfigManager.isRebootFlagSet())
    {
      Output out = res.createOutput("warning", "rebootIsNeededHint");

      out.setAttribute("bundle", "IPtellBase");
      res.add(out);
    }
    else if (systemConfigManager.configNeedsRestart())
    {
      Output out = res.createOutput("warning", "restartIsNeededHint");

      out.setAttribute("bundle", "IPtellBase");
      res.add(out);
    }
    else if (! SystemConfigManager.CHANGE_NO.equals(state))
    {
      Output out = res.createOutput("warning", "configurationWasModifiedHint");

      out.setAttribute("bundle", "IPtellBase");
      res.add(out);
    }

    return res;
  }
View Full Code Here

   *            The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    try
    {
      Configuration config = getConfiguration();

      FormularDescriptor formular = new FormularDescriptor();

      formular.setBundle(config.getChild("bundle").getValue("Aktera"));

      formular.setIdField(config.getChild("key").getValue(null));
      formular.setLabelWidth(NumberTools.toInt(config.getChild("labelWidth").getValue("0"), 0));

      createGroups(config, formular);

      Configuration[] pagesConfig = config.getChildren("page");

      for (Configuration pageConfig : pagesConfig)
      {
        String pageBundle = pageConfig.getAttribute("bundle", formular.getBundle());

        PageDescriptor page = formular.addPage(pageConfig.getAttribute("name"), pageBundle);

        page.setPosition(positionStringToValue(pageConfig.getAttribute("pos", "C")));
        page.setIcon(pageConfig.getAttribute("icon", null));
        page.setInactiveIcon(pageConfig.getAttribute("inactiveIcon", null));

        createGroups(pageConfig, formular);
      }

      modifyGroups(config, formular);

      formular.sort();

      Output output = res.createOutput("formular");

      output.setContent(formular);
      res.add(output);
    }
    catch (ConfigurationException x)
    {
      throw new ModelException(x);
    }
View Full Code Here

  /**
   * @see de.iritgo.aktera.model.Model#execute(de.iritgo.aktera.model.ModelRequest)
   */
  public ModelResponse execute(ModelRequest request) throws ModelException
  {
    ModelResponse res = request.createResponse();

    Output outAppList = res.createOutput("apps");

    res.add(outAppList);

    for (Iterator<Info> i = appById.values().iterator(); i.hasNext();)
    {
      Info appInfo = i.next();

      if (SYSTEM.equals(appInfo.getId()))
      {
        continue;
      }

      if (LicenseTools.getLicenseInfo().appAllowed(appInfo.getId()))
      {
        Output outApp = res.createOutput("app_" + appInfo.getId());

        outAppList.add(outApp);
        outApp.setAttribute("name", appInfo.getNameLong());
        outApp.setAttribute("version", appInfo.getVersion());
        outApp.setAttribute("description", appInfo.getDescription());
View Full Code Here

  {
    int showMonth = req.getParameterAsInt("showMonth", - 1);
    int showYear = req.getParameterAsInt("showYear", - 1);
    String dayModel = req.getParameterAsString("dayModel", null);

    ModelResponse res = req.createResponse();

    Output outCalendar = res.createOutput("calendar");

    res.add(outCalendar);

    Calendar cal = new GregorianCalendar();

    cal.setFirstDayOfWeek(Calendar.MONDAY);

    int currentDayOfYear = cal.get(Calendar.DAY_OF_YEAR);
    int currentMonth = cal.get(Calendar.MONTH);
    int currentYear = cal.get(Calendar.YEAR);

    outCalendar.setAttribute("currentDate", cal.getTime());

    Command cmdCurrentMonth = ModelTools.createPreviousModelCommand(req, res);

    cmdCurrentMonth.setParameter("showMonth", new Integer(cal.get(Calendar.MONTH)));
    cmdCurrentMonth.setParameter("showYear", new Integer(cal.get(Calendar.YEAR)));
    outCalendar.setAttribute("cmdCurrentMonth", cmdCurrentMonth);

    if (showMonth != - 1)
    {
      cal.set(Calendar.MONTH, showMonth);
    }
    else
    {
      showMonth = currentMonth;
    }

    if (showYear != - 1)
    {
      cal.set(Calendar.YEAR, showYear);
    }

    outCalendar.setAttribute("showDate", cal.getTime());

    cal.add(Calendar.MONTH, - 1);

    Command cmdPrevMonth = ModelTools.createPreviousModelCommand(req, res);

    cmdPrevMonth.setParameter("showMonth", new Integer(cal.get(Calendar.MONTH)));
    cmdPrevMonth.setParameter("showYear", new Integer(cal.get(Calendar.YEAR)));
    outCalendar.setAttribute("cmdPrevMonth", cmdPrevMonth);

    cal.add(Calendar.MONTH, 2);

    Command cmdNextMonth = ModelTools.createPreviousModelCommand(req, res);

    cmdNextMonth.setParameter("showMonth", new Integer(cal.get(Calendar.MONTH)));
    cmdNextMonth.setParameter("showYear", new Integer(cal.get(Calendar.YEAR)));
    outCalendar.setAttribute("cmdNextMonth", cmdNextMonth);

    cal.add(Calendar.MONTH, - 1);
    cal.add(Calendar.YEAR, - 1);

    Command cmdPrevYear = ModelTools.createPreviousModelCommand(req, res);

    cmdPrevYear.setParameter("showMonth", new Integer(cal.get(Calendar.MONTH)));
    cmdPrevYear.setParameter("showYear", new Integer(cal.get(Calendar.YEAR)));
    outCalendar.setAttribute("cmdPrevYear", cmdPrevYear);

    cal.add(Calendar.YEAR, 2);

    Command cmdNextYear = ModelTools.createPreviousModelCommand(req, res);

    cmdNextYear.setParameter("showMonth", new Integer(cal.get(Calendar.MONTH)));
    cmdNextYear.setParameter("showYear", new Integer(cal.get(Calendar.YEAR)));
    outCalendar.setAttribute("cmdNextYear", cmdNextYear);

    cal.add(Calendar.YEAR, - 1);

    Output outWeeks = res.createOutput("weeks");

    outCalendar.setAttribute("weeks", outWeeks);

    cal.set(Calendar.WEEK_OF_MONTH, 1);
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);

    for (int i = 0; i < 6; ++i)
    {
      Output outWeek = res.createOutput("week");

      outWeeks.add(outWeek);
      outWeek.setAttribute("num", new Integer(cal.get(Calendar.WEEK_OF_YEAR)));

      for (int j = 0; j < 7; ++j)
      {
        Output outDay = res.createOutput("day");

        outWeek.add(outDay);

        outDay.setAttribute("num", new Integer(cal.get(Calendar.DAY_OF_MONTH)));

        if (cal.get(Calendar.YEAR) == currentYear && cal.get(Calendar.DAY_OF_YEAR) == currentDayOfYear)
        {
          outDay.setAttribute("isCurrent", Boolean.TRUE);
        }

        if (cal.get(Calendar.MONTH) == showMonth)
        {
          if (dayModel != null)
          {
            Command cmdDoDay = res.createCommand(dayModel);

            outDay.setAttribute("cmdDoDay", cmdDoDay);
          }
        }
        else
View Full Code Here

   * @param req The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();
    String fixedDomain = null;
    String rememberConfig = configuration.getAttribute("remember", "prompt");
    String defaultLoginName = null;
    String defaultPassword = null;
    String defaultDomain = null;
    HashMap cookies = (HashMap) req.getAttribute("cookies");

    if (cookies != null)
    {
      defaultLoginName = SuperString.notNull((String) cookies.get(getLoginCookieName(configuration)));
      defaultPassword = SuperString.notNull((String) cookies.get(getPasswordCookieName(configuration)));
      defaultDomain = SuperString.notNull((String) cookies.get(getDomainCookieName(configuration)));
    }

    String[] cookieSeq = getCryptSeq(configuration, "cookie");

    if (defaultLoginName != null && ! "".equals(defaultLoginName))
    {
      defaultLoginName = decodeWithSeq(cookieSeq, defaultLoginName, req);
    }

    if (defaultPassword != null && ! "".equals(defaultPassword))
    {
      defaultPassword = decodeWithSeq(cookieSeq, defaultPassword, req);
    }

    if (defaultDomain != null && ! "".equals(defaultDomain))
    {
      defaultDomain = decodeWithSeq(cookieSeq, defaultDomain, req);
    }

    String domain = SuperString.notNull((String) req.getParameter("domain"));

    if (domain != null && ! "".equals(domain))
    {
      res.addOutput("currentDomain", domain);
      fixedDomain = domain;
    }
    else
    {
      try
      {
        int domainCount = 0;
        TreeMap valids = new TreeMap();
        Configuration domainConfig = getConfiguration().getChild("domains");

        Configuration[] dChildren = domainConfig.getChildren();
        Configuration oneDomain = null;

        for (int j = 0; j < dChildren.length; j++)
        {
          oneDomain = dChildren[j];
          domainCount++;
          valids.put(oneDomain.getAttribute("name"), oneDomain.getAttribute("descrip"));
          fixedDomain = oneDomain.getAttribute("name");
        }

        if (domainCount > 1)
        {
          Input domainInput = res.createInput("domain");

          domainInput.setLabel("Domain");
          domainInput.setDefaultValue(defaultDomain);
          domainInput.setValidValues(valids);
          res.add(domainInput);
          fixedDomain = defaultDomain;
        }
      }
      catch (ConfigurationException x)
      {
        throw new ModelException(x);
      }
    }

    Input loginName = res.createInput("loginName");

    loginName.setDefaultValue(defaultLoginName);
    loginName.setLabel("Login");
    res.add(loginName);

    Input password = res.createInput("password");

    password.setDefaultValue(defaultPassword);
    password.setLabel("Password");

    password.setAttribute("type", "password");
    res.add(password);

    String loginModel = Constants.LOGIN;

    if (req.getParameter("loginmodel") != null)
    {
      loginModel = (String) req.getParameter("loginmodel");
    }

    Command login = res.createCommand(loginModel);

    login.setName("login");
    login.setLabel("$login");

    if (fixedDomain != null)
    {
      login.setParameter("domain", fixedDomain);
    }

    if (rememberConfig.equals("prompt") || rememberConfig.equals("last"))
    {
      Input remember = res.createInput("remember");

      remember.setLabel("Remember Login");
      remember.setAttribute("checkbox", "Y");

      String rememberChecked = configuration.getAttribute("remember-checked", "false");

      if (rememberConfig.equals("last"))
      {
        remember.setDefaultValue((defaultLoginName != null && ! defaultLoginName.equals("")) ? "on" : "off");
      }
      else if (rememberChecked.equals("true"))
      {
        remember.setDefaultValue("on");
      }

      res.add(remember);
    }
    else if (rememberConfig.equals("always"))
    {
      login.setParameter("remember", "Y");
    }
    else if (rememberConfig.equals("never"))
    {
      login.setParameter("remember", "N");
    }

    res.add(login);

    res.setDefaultsFromPrevious();

    Command logout = res.createCommand(Constants.LOGOFF);

    logout.setLabel("$logoff");
    res.add(logout);

    Command promptSendPassword = res.createCommand(Constants.PROMPT_SEND_PASSWORD);

    promptSendPassword.setName("sendPassword");
    promptSendPassword.setLabel("$sendPassword");
    res.add(promptSendPassword);

    Command promptRegister = res.createCommand(Constants.PROMPT_REGISTRATION);

    promptRegister.setLabel("$register");
    res.add(promptRegister);

    res.setDefaultsFromPrevious();

    return res;
  }
View Full Code Here

   * @param req The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    UserTools.setContextObject(req, "aktera.currentMenu", "aktera.menu.personal");
    UserTools.removeContextObject(req, "aktera.currentMenuItem");

    return res;
View Full Code Here

   * @param req The model request.
   * @return The model response.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    ModelResponse res = req.createResponse();

    Context ctx = req.getContext();

    if (ctx != null)
    {
      UserEnvironment userEnv = null;

      try
      {
        userEnv = (UserEnvironment) ctx.get(UserEnvironment.CONTEXT_KEY);
      }
      catch (ContextException x)
      {
      }

      try
      {
        if (userEnv != null && userEnv.getUid() != UserEnvironment.ANONYMOUS_UID)
        {
          if (userEnv.getAttribute("sessionInfoLoaded") == null
                  || "N".equals(userEnv.getAttribute("sessionInfoLoaded")))
          {
            try
            {
              PersistentFactory persistentManager = (PersistentFactory) req.getService(
                      PersistentFactory.ROLE, req.getDomain());

              Persistent preferences = persistentManager.create("aktera.Preferences");

              preferences.setField("userId", new Integer(userEnv.getUid()));
              preferences.find();
              userEnv.setAttribute("sessionPreferences", preferences.getBean());

              Persistent party = persistentManager.create("aktera.Party");

              party.setField("userId", new Integer(userEnv.getUid()));

              if (party.find())
              {
                Persistent address = persistentManager.create("aktera.Address");

                address.setField("partyId", party.getField("partyId"));

                if (address.find())
                {
                  String firstName = address.getFieldString("firstName");
                  String lastName = address.getFieldString("lastName");
                  String displayName = (firstName != null ? firstName + " " : "") + lastName;

                  userEnv.setAttribute("sessionDisplayName", displayName);
                  userEnv.setAttribute("sessionFirstName", firstName != null ? firstName : "");
                  userEnv.setAttribute("sessionLastName", lastName != null ? lastName : "");

                  Locale locale = (Locale) languages.get(preferences.getFieldString("language"));

                  userEnv.setAttribute("sessionLanguage", locale != null ? locale : Locale.GERMAN);
                  userEnv.setAttribute(I18N.USER_CONTEXT_LOCALE_KEY, locale != null ? locale
                          : Locale.GERMAN);
                  userEnv.setAttribute("sessionInfoLoaded", "Y");
                }
              }
            }
            catch (PersistenceException x)
            {
              throw new ModelException(x);
            }
          }

          res.addOutput("sessionDisplayName", (String) userEnv.getAttribute("sessionDisplayName"));
          res.addOutput("sessionFirstName", (String) userEnv.getAttribute("sessionFirstName"));
          res.addOutput("sessionLastName", (String) userEnv.getAttribute("sessionLastName"));
          res.addOutput("sessionLoginName", (String) userEnv.getLoginName());

          Output lang = res.createOutput("sessionLanguage");

          lang.setContent(userEnv.getAttribute("sessionLanguage"));
          res.add(lang);
        }
        else
        {
          Output lang = res.createOutput("sessionLanguage");

          lang.setContent(Locale.GERMAN);
          res.add(lang);
        }
      }
      catch (AuthorizationException x)
      {
        throw new ModelException(x);
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.model.ModelResponse

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.