Package evolaris.framework.um.datamodel

Examples of evolaris.framework.um.datamodel.Group


      // reset also confirmation pending because enter will not be called
      smsSendForm.setSendConfirmationPending(false);
      return mapping.findForward("invalidToken");
    }

    Group group = getCurrentGroup(req);
    Sender sender = validSenderFromForm(req, smsSendForm,group);
    if (!validText(smsSendForm)){
      String noMessageOrLinkString = getResources(req).getMessage(locale,"smssvc.noMessageOrLink");
      req.setAttribute("generalError",noMessageOrLinkString);
      return mapping.findForward("notSent");
View Full Code Here


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

    TimerEventListForm timerEventListForm = (TimerEventListForm) form;
    UserManager userManager = new UserManager(locale, session);

    Group groupToDisplay = getCurrentGroup(req);
    if (Boolean.TRUE.equals(timerEventListForm.getAllGroups()) && UserManager.isUserInRole(webUser, UserManagerBase.ADMINISTRATOR)) {
      groupToDisplay = null;
    }
    User userToDisplay = null;
    Long selectedUserId = timerEventListForm.getUserId() == null ? ALL_ID : timerEventListForm.getUserId();

    if (UserManager.isUserInRole(webUser, UserManagerBase.GROUP_ADMINISTRATOR)) {
      User[] users;
      if (groupToDisplay == null) {
        users = userManager.getUsers(false);
      } else {
        users = userManager.getUsers(groupToDisplay, false)// all users with a username
      }
      if (users.length > MAX_USERLIST_LENGTH) {
        users = new User[0];
      }
      // sort users by username
      Arrays.sort(users, new Comparator<User>() {
        public int compare(User o1, User o2) {
          String n1 = o1.getUsername() != null ? o1.getUsername() : "";
          String n2 = o2.getUsername() != null ? o2.getUsername() : "";
          return n1.compareToIgnoreCase(n2);
        }});
      req.setAttribute("users", users);
    } else {
      selectedUserId = webUser.getId();
      timerEventListForm.setUserId(selectedUserId);
      req.setAttribute("users", new User[]{webUser});
    }
    if (!selectedUserId.equals(ALL_ID)) {
      userToDisplay = userManager.getUserDetails(selectedUserId);
      Hibernate.initialize(userToDisplay); // used to fetch
    }

    // 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 += "; ...";
      }
      displayListEntry.setDescription(description);
     
      displayListEntry.setStatus(event.getProcessing() == 0 ? resources.getMessage(locale,"smssvc.scheduled") : resources.getMessage(locale,"smssvc.processing"));
      if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_WEEK) {
        long weeks = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_WEEK;
        displayListEntry.setRepeat(resources.getMessage(locale,"smssvc.repeatEveryNWeeks", weeks +""));
      } else if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_DAY){
        long days = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_DAY;
        displayListEntry.setRepeat(resources.getMessage(locale,"smssvc.repeatEveryNDays", days+""));
      } else if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_HOUR){
        long hours = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_HOUR;
        displayListEntry.setRepeat(resources.getMessage(locale,"smssvc.repeatEveryNHours", hours+""));
      } else if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_MINUTE){
        long minutes = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_MINUTE;
        displayListEntry.setRepeat(resources.getMessage(locale,"smssvc.repeatEveryNMinutes", minutes+""));
      }
      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();
      }
      displayListEntry.setApplyTo(applyTo);
      displayListEntries[i++] = displayListEntry;
    }
    req.setAttribute("displayListEntries", displayListEntries);
    req.getSession().setAttribute("groupId", groupToDisplay != null ? groupToDisplay.getId() : ALL_ID)// needed when creating entry
    return mapping.findForward("list");
  }
View Full Code Here

      searchResults = new ArrayList<Long>();
    }
   
    GroupManager groupMgr = new GroupManager(locale, session);
    BlogManager blogMgr = new BlogManager(locale, session);
    Group mgblGroup = groupMgr.getGroup("mgbl");
    Blog gameBlog = blogMgr.getBlog("mgblgameinstances", mgblGroup);
    List<DisplayableApplicationType> entries = new ArrayList<DisplayableApplicationType>();
    for (Long id : searchResults) {
      Article blogArticle = blogMgr.getArticle(id);
      DisplayableApplicationType entry = new DisplayableApplicationType(blogArticle);
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  protected ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    GroupManager groupMgr = new GroupManager(locale, session);
    BlogManager blogMgr = new BlogManager(locale, session);
    Group mgblGroup = groupMgr.getGroup("mgbl");
    Blog gameStyleBlog = blogMgr.getBlog("mgblgamestyles", mgblGroup);
    if (req.getParameter("id") == null) {
      req.setAttribute("id", Long.toString(gameStyleBlog.getId()));
    }
    super.view(mapping, form, req, resp);
View Full Code Here

   * @param blog
   * @return
   */
  protected Set<Long> getPermissions(Blog blog, User user) {
    PermissionManager permissionMgr = new PermissionManager(locale, session);
    Group originalGroup = blog.getGroup();
    if (originalGroup.getClientProject().getName().equals("mgbl")) {
      blog.setGroup(user.getGroup())// outflank getRolesPermissions()
    }
    Set<Long> permissions = new HashSet<Long>();
    permissions.addAll(permissionMgr.getAnonymousPermissions(blog));
    permissions.addAll(permissionMgr.getRolesPermissions(blog, user));     
View Full Code Here

 
  @SuppressWarnings("unchecked")
  protected ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogManager blogMgr = new BlogManager(locale, session);
    GroupManager groupMgr = new GroupManager(locale, session);
    Group mgblGroup = groupMgr.getGroup("mgbl");
    Blog blog = blogMgr.getBlog("mgblgameinstances", mgblGroup);
    req.setAttribute("id", Long.toString(blog.getId()));
   
    // inject labelarchive param if mgblpresetlabel is there
    String labelArchiveParam = req.getParameter("labelarchive");
View Full Code Here

   * @param blog
   * @return
   */
  protected Set<Long> getPermissions(Blog blog, User user) {
    PermissionManager permissionMgr = new PermissionManager(locale, session);
    Group originalGroup = blog.getGroup();
    if (originalGroup.getClientProject().getName().equals("mgbl")) {
      blog.setGroup(user.getGroup())// outflank getRolesPermissions()
    }
    Set<Long> permissions = new HashSet<Long>();
    permissions.addAll(permissionMgr.getAnonymousPermissions(blog));
    permissions.addAll(permissionMgr.getRolesPermissions(blog, user));     
View Full Code Here

  @SuppressWarnings("unchecked")
  public ActionForward enter(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {
    EmailSendForm emailSendForm = (EmailSendForm) form;
    emailSendForm.setSendConfirmationPending(false);

    Group group = getCurrentGroup(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)
    prepareTemplate(req, emailSendForm, group, new EmailCommandEntry());

    // set defaults, if no user or template entries

    if (emailSendForm.getDestinationSelection() == null){
      emailSendForm.setDestinationSelection(-1)// none selected
    }
    if (emailSendForm.getFromEmail() == null || emailSendForm.getFromEmail().trim().length() == 0){
      if (webUser.getEmail() != null){
        EmailAddress webUserEmailAddress = new EmailAddress(webUser);
        emailSendForm.setFromEmail(webUserEmailAddress.getEmail());
        emailSendForm.setFromPersonalName(webUserEmailAddress.getPersonalName());
      }
      // no from setting if web user does not have e-mail configured => non-administrators must configure in personal settings
    }
    if (emailSendForm.getFromPersonalName() == null || emailSendForm.getFromPersonalName().trim().length() == 0){
      emailSendForm.setFromPersonalName((webUser.getFirstName() == null ? "" : webUser.getFirstName()) + " " + (webUser.getLastName() == null ? "" : webUser.getLastName()).trim());
    }

    // user sets
    UserSet userSet = prepareUserSets(req, emailSendForm, group);

    // destination users
    Set<User> users = userSet == null ? group.getUsers() : userSet.getUsers();
    SortedSet<EmailAddress> userAddresses = EmailAddress.availableAddresses(users);
    prepareUser(req, emailSendForm, userAddresses);

    // initial send date
    prepareSendDate(emailSendForm);
View Full Code Here

    if (f.getSortLabel() == null ||  f.getSortLabel().equals("")){
      throw new InputException(resources.getMessage(locale, "smssvc.labelMustBeProvided"));
    }

    CommentCommandEntry commandEntry = new CommentCommandEntry();
    Group group = groupFromSession(req);
    checkAccessRights(req, group);
    commandEntry.setGroup(group);
    commandEntry.setDescription(f.getComment().length() == 0 ? null : f.getComment())// empty input => null
    commandEntry.setSortLabel(f.getSortLabel());
    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase() + ": Created comment entry with comment value: `" + f.getComment() + "`");
View Full Code Here

   * interaction lists referred by invocation 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) {
    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());
View Full Code Here

TOP

Related Classes of evolaris.framework.um.datamodel.Group

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.