Package evolaris.framework.smsservices.business

Examples of evolaris.framework.smsservices.business.CommandEntryManager


 
  // gets sorted template command entries
  private TreeSet<CommandEntry> getSortedCommandEntries(HttpServletRequest req){
    // template selector: first set content from the template, if selected; content will be changed later if not allowed (except destination group, which  has to be checked explicitly)

    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    Set<HttpCommandEntry> commandEntries = commandEntryManager.getTemplateCommandEntries(groupFromSession(req), new HttpCommandEntry());
    TreeSet<CommandEntry> sortedCommandEntries = new TreeSet<CommandEntry>(new Comparator<CommandEntry>(){
      public int compare(CommandEntry o1, CommandEntry o2) {
        String leftName = o1.getSortLabel();
        String rightName = o2.getSortLabel();
        if (leftName.startsWith("(") && !rightName.startsWith("(")) {  // "(no template)" first in list
View Full Code Here


    if (f.getSortLabel() == null || f.getSortLabel().equals("")){
      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 HttpCommandEntry)){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.editedInteractionDoesNotExistAnymore"))// may have been deleted
    }
   
    HttpCommandEntry httpCommandEntry = (HttpCommandEntry)commandEntry;
    checkAccessRights(req, httpCommandEntry.getGroup());
    commandEntryManager.evict(httpCommandEntry)// do not modify in this session yet (might be erroneous)

    httpCommandEntry.setSortLabel(f.getSortLabel());
    httpCommandEntry.setUrl(f.getUrl());
    httpCommandEntry.setNofEvaluatedResponseLetters(Integer.parseInt(f.getNofEvaluatedResponseLetters()))
    LOGGER.info("User " + UserManagerBase.toString(webUser) + ": http interaction entry with id: " + commandEntryId + " has been modified");
View Full Code Here

    if (f.getSortLabel() == null || f.getSortLabel().equals("")){
      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 BlogCommandEntry)){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.editedInteractionDoesNotExistAnymore"))// may have been deleted
    }
   
    BlogCommandEntry blogCommandEntry = (BlogCommandEntry)commandEntry;
    checkAccessRights(req, blogCommandEntry.getGroup());
    commandEntryManager.evict(blogCommandEntry)// do not modify in this session yet (might be erroneous)

    blogCommandEntry.setSortLabel(f.getSortLabel());
    if (f.getBlogId() > 0) {
      BlogManager blogMgr = new BlogManager(locale, session);
      Blog blog = blogMgr.getBlog(f.getBlogId());
View Full Code Here

   *      org.apache.struts.action.ActionForm,
   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    String commandEntryIdParam = req.getParameter("commandEntryId");
    if (commandEntryIdParam == null){
      throw new BugException("missing command entry id parameter");
    }
    long commandEntryId = Long.parseLong(commandEntryIdParam);
    CommandEntry commandEntry = commandEntryManager.getCommandEntry(commandEntryId);
    if (commandEntry == null){  // command may have been deleted
      throw new InputException(getResources(req).getMessage(locale,"smssvc.commandEntryNotAvailable"));
    }
    LOGGER.info("distributing edit action according to command entry type: " + commandEntry.getClass().getSimpleName());
    req.setAttribute("commandEntryId",commandEntryId);
View Full Code Here

   
    // group assignment is not editable => perform source to destination automatically
    mappingSet.add(new Entry(oldFragment.getGroup()), new Entry(newFragment.getGroup()));
   
    // Create duplicated command entries according to the original execution order
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    SortedSet<CommandEntry> newCommandEntries = new TreeSet<CommandEntry>(new CommandEntryManager.CommandEntryComparator());
    Set<CommandEntry> oldCommandEntries = oldFragment.getCommandEntries();
    SortedSet<CommandEntry> sortedOldCommandEntries = new TreeSet<CommandEntry>(new CommandEntryManager.CommandEntryComparator());
    sortedOldCommandEntries.addAll(oldCommandEntries);
    for (CommandEntry oldCommandEntry : sortedOldCommandEntries) {
      CommandEntryExtender extender = commandEntryManager.createCommandEntryExtender(oldCommandEntry);
      CommandEntry duplicatedCommandEntry = extender.duplicateCommandEntry(newFragment.getGroup(),mappingSet);
      Set<InteractionList> fragments = new TreeSet<InteractionList>();
      fragments.add(newFragment);
      duplicatedCommandEntry.setInteractionLists(fragments);
      commandEntryManager.create(duplicatedCommandEntry)// also sets the ID for sorting
      newCommandEntries.add(duplicatedCommandEntry);
    }
    newFragment.setCommandEntries(newCommandEntries);
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    smsDbManager.createFragment(newFragment);
View Full Code Here

   */
  public ActionForward modify(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {
    IterateInteractionEnterOrEditForm f = (IterateInteractionEnterOrEditForm)form;
    MessageResources resources = getResources(req);
    long commandEntryId = f.getCommandEntryId();
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    CommandEntry commandEntry = commandEntryManager.getCommandEntry(commandEntryId);
    if (commandEntry == null || !(commandEntry instanceof IterateCommandEntry)){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.editedInteractionDoesNotExistAnymore"))// may have been deleted
    }
    IterateCommandEntry iterateCommandEntry = (IterateCommandEntry)commandEntry;
    checkAccessRights(req, iterateCommandEntry.getGroup());
    commandEntryManager.evict(iterateCommandEntry)// do not modify in this session yet (might be erroneous)
    f.toEntry(iterateCommandEntry, iterateCommandEntry.getGroup(), locale, session, resources);
    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase() + ": Command Entry with id: " + commandEntryId + " has been modified");
    setCommandEntryInRequest(req, iterateCommandEntry);
    return mapping.findForward("modified");
  }
View Full Code Here

   * Gets command entry object from commandEntryId in the request (exception if does not exist)
   * @param req  request
   * @return  command entry object
   */
  protected CommandEntry commandEntryFromRequest(HttpServletRequest req) {
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    Object commandEntryIdParameter = req.getAttribute("commandEntryId");
    if (commandEntryIdParameter == null || !(commandEntryIdParameter instanceof Long)){
      throw new BugException("no command entry id passed to the edit action");
    }
    long commandEntryId = ((Long)commandEntryIdParameter).longValue();
    CommandEntry commandEntry = commandEntryManager.getCommandEntry(commandEntryId);
    if(commandEntry == null){
      throw new ConfigurationException("There is no command entry with id: " + commandEntryId + " -> cannot edit the interaction");
    }
    return commandEntry;
  }
View Full Code Here

  public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {

    InteractionEnterOrEditBaseForm interactionForm = (InteractionEnterOrEditBaseForm)form;

    long commandEntryId = interactionForm.getCommandEntryId();
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    CommandEntry commandEntry = commandEntryManager.getCommandEntry(commandEntryId);
    if (commandEntry == null){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.InteractionToBeDeletedDoesNotExistAnymore."),"command entry id = " + commandEntryId,null,null)// may have been deleted
    }
    checkAccessRights(req, commandEntry.getGroup());
    commandEntryManager.delete(commandEntry);
    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase() + ": Command Entry #" + commandEntryId + " has been deleted");

    return mapping.findForward("deleted");
  }
View Full Code Here

    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


  // checks the label of a newly created command entry, associates it with the current keyword/service, then forwards 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,interactionListFromSession(req).getCommandEntries());
    associate(req,commandEntryManager, commandEntry);
    return list(mapping,form,req,resp);
  }
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.