Package evolaris.platform.smssvc.web.form

Examples of evolaris.platform.smssvc.web.form.InteractionListForm


   * interaction lists referred by msisdn/keyword for message queue SMSSERVICES and interaction lists referred by serviceId/authenticationKey are editable
   *
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    InteractionListForm interactionListForm = (InteractionListForm) form;
    String idParam = req.getParameter("id");
    if (idParam != null) {
      req.getSession().setAttribute("interactionListId", new Long(idParam)); // required for command entries
    }
    InteractionList interactionList = interactionListFromSession(req);

    // page title and information according to actual type; must be extended for additional types!
    MessageResources resources = getResources(req);
    if (interactionList instanceof Invocation) {
      Invocation invocation = (Invocation) interactionList;
      req.setAttribute("title",resources.getMessage(locale,"smssvc.EditServiceInteractions"));
      req.setAttribute("information1Title",resources.getMessage(locale,"smssvc.MSISDN") + " / " + resources.getMessage(locale,"smssvc.Keywords"));
      req.setAttribute("information1Value",invocation.getMsisdn() == null ? "" : (invocation.getMsisdn() + (invocation.getKeywords() == null ? "" : (" / " + invocation.getKeywords()))));
      req.setAttribute("information2Title",resources.getMessage(locale,"smssvc.ServiceId") + " / " + resources.getMessage(locale,"smssvc.Authentication"));
      req.setAttribute("information2Value",invocation.getServiceId() == null ? "" : (invocation.getServiceId() + (invocation.getAuthenticationKey() == null ? "" : (" / " + invocation.getAuthenticationKey()))));
      req.getSession().setAttribute("interactionListType", "invocation")// required for cancelling
    } else if (interactionList instanceof Fragment){
      Fragment fragment = (Fragment)interactionList;
      req.setAttribute("title",resources.getMessage(locale,"smssvc.EditFragmentInteractions"));
      req.setAttribute("information1Title", resources.getMessage(locale,"smssvc.FragmentName"));
      req.setAttribute("information1Value",fragment.getFragmentName());
      req.setAttribute("information2Title", null)// second line not used
      req.getSession().setAttribute("interactionListType", "fragment")// required for cancelling
    } else {
      throw new BugException("can't do anything with list of type: " + interactionList.getClass().getName());
    }
   
    req.setAttribute("interactionList", interactionList);
    interactionListForm.setGroupId(interactionList.getGroup().getId());   
    req.getSession().setAttribute("groupId", interactionList.getGroup().getId());
   
    interactionListForm.setInteractionListId(interactionList.getId());
    SortedSet<CommandEntry> sortedCommandEntries = sortedCommandEntries(interactionList);
    List<DisplayableInteractionContent> displayableInteractions = buildInteractionList(req, interactionList.getGroup(), sortedCommandEntries,interactionList instanceof Fragment, Boolean.TRUE.equals(interactionListForm.getExpandFragments()));
    req.setAttribute("interactions",displayableInteractions);
    long defaultInsertionPointId = sortedCommandEntries.size() == 0 ? 0L :  insertionPointFromRequest(req, sortedCommandEntries.last()).getId();
    interactionListForm.setInsertCommandEntryId(defaultInsertionPointId);
    interactionListForm.setInsertionType(2);
    req.setAttribute("commandEntries", sortedCommandEntries);
    return mapping.findForward("list");
  }
View Full Code Here


   * @param req request
   * @param groupId group id from the form
   */
  @Override
  protected void setNewInteractionAttributes(ActionForm form, HttpServletRequest req, long groupId,long applicationId) {
    InteractionListForm interactionListForm = (InteractionListForm) form;
    Long interactionListId = interactionListForm.getInteractionListId();
    if (interactionListId == null){
      throw new BugException("no interactionList id in form");
    }
    req.getSession().setAttribute("interactionListId", interactionListId);
    req.getSession().setAttribute("groupId", groupId);
    req.getSession().setAttribute("applicationId", applicationId);
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    InteractionList interactionList = smsDbManager.getInteractionList(interactionListId);
    if (interactionList == null){  // may happen if the interactionList was deleted in the meantime
      String interactionListDeletedString = getResources(req).getMessage(locale,"smssvc.interactionDefinitionNotPossible");
      throw new InputException(interactionListDeletedString);
    }
    if (!req.isUserInRole(UserManagerBase.ADMINISTRATOR) && (!req.isUserInRole(SmsDbManager.INTERACTION_ADMINISTRATOR) || webUser.getGroup() != interactionList.getGroup())){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.insufficientRights"));
    }
    SortedSet<CommandEntry> sortedCommandEntries = sortedCommandEntries(interactionList);
    CommandEntry insertCommandEntry = null;
    Long insertId = interactionListForm.getInsertCommandEntryId();
    int insertionType = interactionListForm.getInsertionType();
    if (insertId != null && insertId >= 1 && insertionType >= 1){
      CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
      insertCommandEntry = commandEntryManager.getCommandEntry(insertId);
    }
    req.getSession().setAttribute("sortLabel", proposedSortLabel(req, sortedCommandEntries,insertCommandEntry,insertionType));
View Full Code Here

  }

  @Override
  public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    // forget the selections, if the user explicitly quits
    InteractionListForm interactionListForm = (InteractionListForm) form;
    interactionListForm.setGroupId(-1);
    interactionListForm.setApplicationId(-1);
    interactionListForm.setInteractionListId(null);
    interactionListForm.setInsertCommandEntryId(null);
    interactionListForm.setInsertionType(2);
    Object interactionListType = req.getSession().getAttribute("interactionListType");
    if (interactionListType == null || !(interactionListType instanceof String)){
      throw new BugException("invalid interaction list type");
    }
    // different cancel forwards according to interaction list type; must be extended for new interaction list types!
View Full Code Here

      throw new BugException("invalid interaction list type `" + interactionListType + "`");
    }
  }
 
  public ActionForward enterData(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    InteractionListForm f = (InteractionListForm) form;
   
    Long interactionListId = f.getInteractionListId();
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
   
    InteractionList interactionList = smsDbManager.getInteractionList(interactionListId);
   
    if (interactionList == null){
      throw new InputException(getResources(req).getMessage(locale, "sys.entryNotAvailable"),"id = " + f.getInteractionListId(),null,null);
    }
   
    req.getSession().setAttribute("interactionList", interactionList);
   
    Long msisdn = webUser.getMsisdn();
View Full Code Here

  /**
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    InteractionListForm timerEventInteractionListForm = (InteractionListForm)form;
    String idParam = req.getParameter("id");
    if (idParam != null) {
      req.getSession().setAttribute("interactionListId", new Long(idParam)); // required for command entries
    }
    TimerEvent event = eventFromSession(req);
    req.setAttribute("event", event);
    timerEventInteractionListForm.setGroupId(event.getGroup().getId());
    String applyTo;
    if (event.getRequestingUser() != null){
      if (event.getRequestingUser().getUsername() != null){
        applyTo = event.getRequestingUser().getUsername();
      } else {
        applyTo = event.getRequestingUser().getMsisdn() + "";
      }
    } else if (event.getRequestingUserSet() != null){
      applyTo = event.getRequestingUserSet().getName();
    } else {
      applyTo = event.getGroup().getGroupname();
    }
    req.setAttribute("applyTo",applyTo);
   
    String repetition = "-";
    MessageResources resources = getResources(req);
    if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_WEEK) {
      long weeks = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_WEEK;
      repetition = resources.getMessage(locale,"smssvc.repeatEveryNWeeks", weeks +"");
    } else if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_DAY){
      long days = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_DAY;
      repetition = resources.getMessage(locale,"smssvc.repeatEveryNDays", days+"");
    } else if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_HOUR) {
      long hours = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_HOUR;
      repetition = resources.getMessage(locale,"smssvc.repeatEveryNHours", hours+"");
    } else if (event.getIntervalInMillis() >= 1) {
      long minutes = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_MINUTE;
      repetition = resources.getMessage(locale,"smssvc.repeatEveryNMinutes", minutes+"");     
    }
    req.setAttribute("repetition", repetition);
    SortedSet<CommandEntry> sortedCommandEntries = sortedCommandEntries(event);
    List<DisplayableInteractionContent> interactionList = buildInteractionList(req, event.getGroup(), sortedCommandEntries,false,Boolean.TRUE.equals(timerEventInteractionListForm.getExpandFragments()));
    req.setAttribute("interactions",interactionList);
    long defaultInsertionPointId = sortedCommandEntries.size() == 0 ? 0L :  insertionPointFromRequest(req, sortedCommandEntries.last()).getId();
    timerEventInteractionListForm.setInsertCommandEntryId(defaultInsertionPointId);
    timerEventInteractionListForm.setInsertionType(2);
    req.setAttribute("commandEntries", sortedCommandEntries);
    return mapping.findForward("list");
  }
View Full Code Here

   * @param req request
   * @param groupId group id from the form
   */
  @Override
  protected void setNewInteractionAttributes(ActionForm form, HttpServletRequest req, long groupId,long applicationId) {
    InteractionListForm f = (InteractionListForm)form;
    req.getSession().setAttribute("groupId", groupId);
    req.getSession().setAttribute("applicationId", applicationId);
    TimerEvent event = eventFromSession(req);
    if (event == null){  // may happen if the event was deleted in the meantime
      String msg = getResources(req).getMessage(locale, "smssvc.interactionDefinitionNotPossible");
      throw new InputException(msg,"timer event with not found",null,null);
    }
    if (!req.isUserInRole(UserManagerBase.ADMINISTRATOR) && (!req.isUserInRole(SmsDbManager.INTERACTION_ADMINISTRATOR) || webUser.getGroup() != event.getGroup())){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.insufficientRights"));
    }
    SortedSet<CommandEntry> sortedCommandEntries = sortedCommandEntries(event);
    CommandEntry insertCommandEntry = null;
    Long insertId = f.getInsertCommandEntryId();
    int insertionType = f.getInsertionType();
    if (insertId != null && insertId >= 1 && insertionType >= 1){
      CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
      insertCommandEntry = commandEntryManager.getCommandEntry(insertId);
    }
    req.getSession().setAttribute("sortLabel", proposedSortLabel(req, sortedCommandEntries,insertCommandEntry,insertionType));
View Full Code Here

  }

  @Override
  public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    // forget the selections, if the user explicitly quits
    InteractionListForm f = (InteractionListForm)form;
    f.setGroupId(-1);
    f.setApplicationId(-1);
    f.setInteractionListId(null);
    f.setInsertCommandEntryId(null);
    f.setInsertCommandEntryId(null);
    return back(mapping, form, req, resp);
  }
View Full Code Here

    TimerEvent timerEvent = eventFromSession(req);
    return new TimerEventParameters(locale,session,null,null);
  }
 
  public ActionForward runService(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    InteractionListForm f = (InteractionListForm)form;
   
    MessageResources resources = getResources(req);
    TimerEventExecutionAction.processEvent(req, eventFromSession(req), locale, session, resources);
   
    req.setAttribute("serviceType", InteractionLogManager.EVENT_TIMER_SIMULATED);
    req.setAttribute("serviceId", f.getInteractionListId());
   
   
    return mapping.findForward("executed");
  }
View Full Code Here

   *
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  public ActionForward newCommentInteraction(ActionMapping mapping, ActionForm form,
      HttpServletRequest req, HttpServletResponse resp) {
    InteractionListForm interactionListBaseForm = (InteractionListForm)form;
    setNewInteractionAttributes(form, req,interactionListBaseForm.getGroupId(),interactionListBaseForm.getApplicationId());
    return mapping.findForward("newCommentInteraction");
 
View Full Code Here

TOP

Related Classes of evolaris.platform.smssvc.web.form.InteractionListForm

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.