Package evolaris.framework.smsservices.business

Examples of evolaris.framework.smsservices.business.CommandEntryManager


  /**
   * Check the label of a newly created command entry and associate it with the current timer event, then forward to list
   */
  @Override
  protected ActionForward adaptCreated(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale, session);
    CommandEntry commandEntry = commandEntryFromRequest(req, commandEntryManager);
    checkSortLabel(req, commandEntry,eventFromSession(req).getCommandEntries());
    associate(req, commandEntryManager, commandEntry);
    return list(mapping,form,req,resp);
  }
View Full Code Here


  }

  // checks the label of a modified command entry, then forwards to list
  @Override
  protected ActionForward adaptModified(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    CommandEntry commandEntry = commandEntryFromRequest(req, commandEntryManager);
    checkSortLabel(req, commandEntry,eventFromSession(req).getCommandEntries());
    return list(mapping,form,req,resp);
  }
View Full Code Here

    smsInteractionEnterOrEditForm.setSendingMsisdn((smsCommandEntry.getSender() == null || senderList[0].startsWith("(")) ? senderList[0] :smsCommandEntry.getSender().getMsisdn() + "");

    req.getSession().setAttribute("msisdnList",senderList);
    req.getSession().setAttribute("interactionGroupName",group.getGroupname());

    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    Set<SmsCommandEntry> commandEntries = commandEntryManager.getTemplateCommandEntries(group, new SmsCommandEntry());
    req.getSession().setAttribute("templates",commandEntries);
   
    req.getSession().setAttribute("enterOrEdit", "edit");
    req.getSession().setAttribute("formActionPath", req.getParameter("formActionPath"));
    return mapping.findForward("edit");
View Full Code Here

   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward modify(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {
    SmsInteractionEnterOrEditForm msgForm = (SmsInteractionEnterOrEditForm) form;
    long commandEntryId = msgForm.getCommandEntryId();
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    CommandEntry commandEntry = commandEntryManager.getCommandEntry(commandEntryId);
    if (commandEntry == null || !(commandEntry instanceof SmsCommandEntry)){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.editedInteractionDoesNotExistAnymore"))// may have been deleted
    }
    SmsCommandEntry smsCommandEntry = (SmsCommandEntry)commandEntry;
    Group group = smsCommandEntry.getGroup();
    checkAccessRights(req, group);
    commandEntryManager.evict(smsCommandEntry)// do not modify in this session yet (might be erroneous)

    String messageText = msgForm.getMessage();
    if (grossSmsMessageLength(messageText) > MAX_MESSAGE_TEXT_LENGTH){
      throw new InputException(getResources(req).getMessage(locale,"smssvc.messageLongerThan450characters"));
    }
View Full Code Here

   * @param sendForm
   */
  @SuppressWarnings("unchecked")
  private void prepareTemplate(HttpServletRequest req, SmsInteractionEnterOrEditForm sendForm) {

    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    Set<SmsCommandEntry> commandEntries = commandEntryManager.getTemplateCommandEntries(groupFromSession(req), new SmsCommandEntry());
    req.getSession().setAttribute("templates",commandEntries);

    Long selectedTemplateId = sendForm.getTemplateId();
    sendForm.setTemplateId(-1L)// none selected
    if (selectedTemplateId != null && selectedTemplateId != -1){
View Full Code Here

  private ActionForward getFormDataByTemplate(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    Long selectedTemplateId = Long.parseLong(req.getParameter("id"));
   
    if (selectedTemplateId != null && selectedTemplateId != -1){
      SmsInteractionEnterOrEditForm f = new SmsInteractionEnterOrEditForm();
      CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
      SmsCommandEntry templateEntry = (SmsCommandEntry)commandEntryManager.getCommandEntry(selectedTemplateId);
      f.initializeFromTemplate(templateEntry);
     
      JSONObject jsonObject = JSONObject.fromObject(f);
      writeJsonResult(jsonObject.toString(), resp);
    }
View Full Code Here

    // create displayable list of timer events
    SmsServiceDbManager smsServiceDbManager = new SmsServiceDbManager(locale, session);
    TimerEvent[] timerEvents = smsServiceDbManager.getTimerEvents(null,null, 0, true, groupToDisplay,userToDisplay)// show also out-of-date timer events, but not processed entries (shouldn't occur anyhow)
    TimerEventListForm.DisplayListEntry[] displayListEntries = new TimerEventListForm.DisplayListEntry[timerEvents.length];
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    MessageResources resources = getResources(req);
    String noInteractionsString = resources.getMessage(locale,"smssvc.noInteractions");
    int i = 0;
    for (TimerEvent event : timerEvents) {
      TimerEventListForm.DisplayListEntry displayListEntry = new TimerEventListForm.DisplayListEntry();
      displayListEntry.setTimerEventId(event.getId());
      displayListEntry.setGroupname(event.getGroup().getGroupname());
      displayListEntry.setUsername( event.getOwningUser().getUsername())// not-null in the database
      displayListEntry.setPointInTime(dateFormat.format(event.getScheduledTime()));
     
      // description shows first command entry; "..." if more are available; empty comments at the beginning are ignored
      String description = noInteractionsString;
      SortedSet<CommandEntry> sortedCommandEntries = CommandEntryManager.sortedCommandEntries(event.getCommandEntries());
      Iterator<CommandEntry> iterator = sortedCommandEntries.iterator();
      while (iterator.hasNext()){
        CommandEntry commandEntry = iterator.next();
        if (commandEntry instanceof CommentCommandEntry){
          String commentDescription = ((CommentCommandEntry)commandEntry).getDescription();
          if (commentDescription != null){
            description = "(" + commentDescription + ")";
            break;
          }
        } else {
          description = commandEntryManager.createCommandEntryExtender(commandEntry).readableCommandDescription(req);
          break;
        }
      }
      if (iterator.hasNext()) {
        description += "; ...";
View Full Code Here

      throw new InputException(resources.getMessage(locale, "smssvc.labelMustBeProvided"));
    }


    long commandEntryId = f.getCommandEntryId();
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    CommandEntry commandEntry = commandEntryManager.getCommandEntry(commandEntryId);
    if (commandEntry == null || !(commandEntry instanceof CommentCommandEntry)){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.editedInteractionDoesNotExistAnymore"))// may have been deleted
    }

    CommentCommandEntry commentCommandEntry = (CommentCommandEntry)commandEntry;
    checkAccessRights(req, commentCommandEntry.getGroup());
    commandEntryManager.evict(commentCommandEntry)// do not modify in this session yet (might be erroneous)

    commentCommandEntry.setSortLabel(f.getSortLabel());
    commentCommandEntry.setDescription(f.getComment().length() == 0?null:f.getComment());
    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase() + ": comment entry #" + commandEntryId + " has been modified to comment value: " + commentCommandEntry.getDescription());
    setCommandEntryInRequest(req, commentCommandEntry);
View Full Code Here

  public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    Group groupToDisplay = getCurrentGroup(req);
    req.getSession().setAttribute("groupId", groupToDisplay.getId());
    ((InteractionListForm)form).setGroupId(groupToDisplay.getId());
    ((InteractionListForm)form).setApplicationId(-1)// no application information for templates
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    Set<CommandEntry> templates = commandEntryManager.getTemplateCommandEntries(groupToDisplay, null);
    DisplayableInteractionContent[] interactions = null;
    SortedSet<CommandEntry> sortedCommandEntries = new TreeSet<CommandEntry>(new CommandEntryManager.TemplateCommandEntryComparator());
    for (CommandEntry entry : templates) {
      if(!req.isUserInRole(SmsDbManager.INTERACTION_ADMINISTRATOR) && entry.getClass().isInstance(new UpcallCommandEntry())
          || !req.isUserInRole(SmsDbManager.SMS_SENDER) && entry.getClass().isInstance(new SmsCommandEntry())
          || !req.isUserInRole(SmsDbManager.EMAIL_SENDER) && entry.getClass().isInstance(new EmailCommandEntry())){
        // only users in role interaction_administrator are allowed to view upcall command templates,
        // users in roles sms_sender / email_sender are allowed to see sms / email templates
      } else {
        sortedCommandEntries.add(entry);
      }
    }
    interactions = new DisplayableInteractionContent[sortedCommandEntries.size()];
    int i = 0;
    for (CommandEntry commandEntry : sortedCommandEntries) {
      DisplayableInteractionContent interaction = new DisplayableInteractionContent();
      interaction.setCommandEntry(commandEntry);
      interaction.setSortLabelDescription(commandEntry.getSortLabel())// no tooltip for templates
      interaction.setInteractionDescription(commandEntryManager.createCommandEntryExtender(commandEntry).readableCommandDescription(req));
      interaction.setIndentation(1)// no block structure
      interactions[i++] = interaction;
    }
    req.setAttribute("interactions",interactions);
View Full Code Here

   * checks label, converts command entry to template and lists
   * @see evolaris.platform.smssvc.web.action.InteractionListBaseAction#adaptCreated(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  @Override
  protected ActionForward adaptCreated(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    CommandEntry commandEntry = commandEntryFromRequest(req, commandEntryManager);
    checkSortLabel(req, commandEntry,commandEntryManager.getTemplateCommandEntries(getCurrentGroup(req), null));
    // set template flag
    commandEntry.setUseAsTemplate(1);
    commandEntryManager.modify(commandEntry);
    LOGGER.info("set template flag in command entry #" + commandEntry.getId());
    //return list(mapping,form,req,resp);
    return mapping.findForward("reload")// reload to avoid re-post of form when admin changes group
  }
View Full Code Here

TOP

Related Classes of evolaris.framework.smsservices.business.CommandEntryManager

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.