Package evolaris.framework.smsservices.datamodel

Examples of evolaris.framework.smsservices.datamodel.TimerEvent


   */
  @Override
  public TimerEvent toEntry(TimerEvent timerEvent, Locale locale, Session session, MessageResources resources) {
    TimerEventEnterOrEditForm f = this;
    if ((timerEvent == null)){
      timerEvent = new TimerEvent();
    }
   
    // ID, group
    timerEvent.setId(f.getId());
    GroupManager groupMgr = new GroupManager(locale, session);
View Full Code Here


   
    TimerEventExecutionForm teForm = (TimerEventExecutionForm)form;
   
   
    SmsServiceDbManager smsServiceDbManager = new SmsServiceDbManager(locale,session);
    TimerEvent timerEvent = smsServiceDbManager.getTimerEvent(teForm.getId());
    if (timerEvent == null){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"));
    }
   
    MessageResources resources = getResources(req);
View Full Code Here

    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);
View Full Code Here

  @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();
View Full Code Here

  }

  // associates the command entry with the current invocation
  private void associate(HttpServletRequest req,CommandEntryManager commandEntryManager, CommandEntry commandEntry) {

    TimerEvent event = eventFromSession(req);

    // check access rights
    if (!req.isUserInRole(SmsDbManager.INTERACTION_ADMINISTRATOR)
          || !req.isUserInRole(UserManagerBase.ADMINISTRATOR) && event.getGroup() != webUser.getGroup()
          || event.getGroup() != commandEntry.getGroup()) {
      throw new InputException(getResources(req).getMessage(locale, "smssvc.insufficientRights"));
    }

    // associate the new command entry with the timer event
    Set<TimerEvent> events = new HashSet<TimerEvent>(1);
    events.add(event);
    commandEntry.setTimerEvents(events);
    commandEntryManager.modify(commandEntry);
    Set<CommandEntry> commandEntries = event.getCommandEntries();
    commandEntries.add(commandEntry);
    event.setCommandEntries(commandEntries)// necessary to receive complete list already within this session
    LOGGER.info("associated command entry #" + commandEntry.getId() + " with timer event entry #" + event.getId());
  }
View Full Code Here

    }
    long eventId = ((Long)eventIdParam).longValue();
    if (eventId == -1) {
      throw new BugException("id -1 in session");
    }
    TimerEvent event = serviceMgr.getTimerEvent(eventId);
    if(event == null) {
      throw new ConfigurationException("There is no event with id: " + eventId + " -> cannot add a new interaction");
    }
    return event;
  }
View Full Code Here

   * @req  HTTP servlet request
   * @return an object extending the EventParameters class; null => list will never be executed directly (fragment)
   */
  @Override
  public EventParameters dummyEventParametersForList(HttpServletRequest req){
    TimerEvent timerEvent = eventFromSession(req);
    return new TimerEventParameters(locale,session,null,null);
  }
View Full Code Here

  private ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    Object idAttribute = req.getParameter("id");
    if (idAttribute != null && idAttribute instanceof String){
      long timerEventId = Long.parseLong((String)idAttribute);
      SmsServiceDbManager serviceDbManager = new SmsServiceDbManager(locale,session);
      TimerEvent timerEvent = serviceDbManager.getTimerEvent(timerEventId);
      if (timerEvent == null){
        throw new InputException(getResources(req).getMessage(locale, "smssvc.timerEventToBeDeletedDoesNotExistAnymore"),"timer event  id = " + timerEventId,null,null)// may have just been excuted
      }
      if (!(req.isUserInRole(UserManagerBase.ADMINISTRATOR)
          || req.isUserInRole(UserManagerBase.GROUP_ADMINISTRATOR) && timerEvent.getGroup() == webUser.getGroup()
          || req.isUserInRole(UserManagerBase.USER) && timerEvent.getRequestingUser() == webUser)) {
        throw new InputException(getResources(req).getMessage(locale, "smssvc.insufficientRights"));
      }
      serviceDbManager.deleteTimerEvent(timerEvent);
      LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase() + ": Timer event #" + timerEventId + " has been deleted");
    } else {
View Full Code Here

   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward createIncludingInteractions(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {
    TimerEventEnterOrEditForm f = (TimerEventEnterOrEditForm)form;
   
    TimerEvent oldTimerEvent = entryFromDatabase(f.getId());
    if (oldTimerEvent == null){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"));
    }
    checkAccessRights(req,oldTimerEvent.getGroup(),null);
    req.getSession().setAttribute("oldInteractionListId", oldTimerEvent.getId());
    Set<CommandEntry> commandEntries = oldTimerEvent.getCommandEntries();
    f.setOwningUserId(webUser.getId());
    TimerEvent editedTimerEvent = f.toEntry(new TimerEvent(), locale, session, getResources(req));
    req.getSession().setAttribute("newTimerEvent", editedTimerEvent)// needed when we duplicate or come back
   
    // mapping from command entries of the duplication source
    MappingSet mappingSet = new MappingSet(commandEntries,editedTimerEvent.getGroup(), locale, session);
   
    req.getSession().setAttribute("mappingSet", mappingSet);
    req.getSession().setAttribute("destinationGroupId", editedTimerEvent.getGroup().getId());
    return mapping.findForward("duplicateIncludingInteractions");
  }
View Full Code Here

   */
  protected ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    ActionForward actionForward = super.edit(mapping, form, req, resp);
    TimerEventEnterOrEditForm f = (TimerEventEnterOrEditForm)form;
    requestingUserAndUserSetPreparation(f, groupPreparation(req, f.getGroupId()), req);
    TimerEvent entry = entryFromDatabase(f.getId());
    if (entry == null){
      throw new InputException(getLocalizedMessage("SystemWeb", "sys.entryNotAvailable"),"id = " + f.getId(),null,null);
    }
    req.getSession().setAttribute("deleteMode", entry.getCommandEntries().size() == 0 ? "delete" : "deleteIncludingInteractions");   
    return actionForward;
  }
View Full Code Here

TOP

Related Classes of evolaris.framework.smsservices.datamodel.TimerEvent

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.