Exemplo n.º 1
0
  public Set<User> getWatchers() {
    Set<User> actualWatchers = new HashSet<>();

    actualWatchers.add(this.contributor);
    for (PullRequestComment c : comments) {
      User user = User.find.byId(c.authorId);
      if (user != null) {
        actualWatchers.add(user);
      }
    }

    return WatchService.findActualWatchers(actualWatchers, asResource());
  }
Exemplo n.º 2
0
  private void populateTrainingSessions() {
    if (null == sessions) {
      sessions = new HashSet<TrainingSession>();
    }

    Set<Event> events = getSubscribedEvents();
    for (Event ev : events) {
      TrainingSession ts1 =
          new TrainingSession(
              ev.getId(),
              this,
              new java.util.Date(1227817411),
              "a workout desc",
              true,
              "something for now",
              "something");
      TrainingSession ts2 =
          new TrainingSession(
              ev.getId(),
              this,
              new java.util.Date(1229459011),
              "a workout desc",
              true,
              "something for now",
              "something");

      UserRegistry.getCurrentInstance().userEJB.addTrainingSession(ts1);
      UserRegistry.getCurrentInstance().userEJB.addTrainingSession(ts2);

      sessions.add(ts1);
      sessions.add(ts2);
    }

    UserRegistry.getCurrentInstance().updateUser(this);
  }
Exemplo n.º 3
0
 public Set<String> getProviders() {
   final Set<String> providerKeys = new HashSet<String>(this.linkedAccounts.size());
   for (final LinkedAccount acc : this.linkedAccounts) {
     providerKeys.add(acc.providerKey);
   }
   return providerKeys;
 }
Exemplo n.º 4
0
  /**
   * Programa uma disciplina nesse período.
   *
   * @param disciplina a disciplina para programar
   * @throws NullPointerException se {@code disciplina == null}
   * @throws PoliticaDeCreditosException se a operação for inválida
   */
  public void programar(Disciplina disciplina) throws PoliticaDeCreditosException {
    Parametro.naoNulo("disciplina", disciplina);

    if (!politicaDeCreditos.podeProgramar(disciplina, this))
      throw new PoliticaDeCreditosException("Máximo de créditos excedido");

    disciplinas.add(disciplina);
  }
Exemplo n.º 5
0
  public Set<String> getulr() {
    final Set<String> provideruserids = new HashSet<String>(this.linkedAccounts.size());
    for (final LinkedAccount acc : this.linkedAccounts) {
      if (acc.providerUserId.length() > 25) {

      } else {
        provideruserids.add(acc.providerUserId);
      }
    }
    return provideruserids;
  }
Exemplo n.º 6
0
 @Override
 @JsonIgnore
 public Collection<? extends GrantedAuthority> getAuthorities() {
   Set<Role> roles = this.getRoles();
   if (roles == null) {
     return Collections.emptyList();
   }
   Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
   for (Role role : roles) {
     authorities.add(new SimpleGrantedAuthority(role.name()));
   }
   return authorities;
 }
Exemplo n.º 7
0
 @Override
 public Collection<? extends GrantedAuthority> getAuthorities() {
   /*
           Set<String> roles = this.getRoles();
           if (roles == null) {
               return Collections.emptyList();
           }
   */
   Set<GrantedAuthority> authorities = new HashSet<>();
   for (Role role : roles) {
     authorities.add(new SimpleGrantedAuthority(role.toString()));
   }
   return authorities;
 }
  /**
   * Disable the cell containing the given point
   *
   * @param x
   * @param y
   */
  public void disableCell(int x, int y) {
    int col = getCorrespondingCol(x);
    int row = getCorrespondingRow(y);

    // If a cell is already dead, it wouldn't be disabled again; Do this to reduce the number of
    // dead points created
    if (valid(row, col) && !cellContainer[row][col].isDead()) {
      cellContainer[row][col].disableCell();
      deadPoints.add(new DeadPoint(x, y, this));

      // removing this cell from the graph and all of its touching edges
      g.removeVertex(cellContainer[row][col]);
    }
  }
Exemplo n.º 9
0
  public Set<NotificationCom> notificationComs() {
    Set set = new LinkedHashSet();

    int[] masId = new int[notificationComs.size()];

    int i = 0;
    for (NotificationCom not : notificationComs) masId[i++] = not.getId();

    Arrays.sort(masId);

    for (int id : masId)
      for (NotificationCom not : notificationComs) if (not.getId() == id) set.add(not);

    return set;
  }
Exemplo n.º 10
0
  public void setValueTextRoles(String valueTextRoles) {

    try {
      List<PickerItem> listOfPickerItem =
          objectStringConverterImpl.convertToListOfObjects(
              new TypeReference<List<PickerItem>>() {}, valueTextRoles);
      roles.clear();

      for (PickerItem pickerItem : listOfPickerItem) {
        roles.add(roleRepoImpl.find(Long.valueOf(pickerItem.getPickerCode().toString())));
      }
    } catch (Exception e) {
      loggerImpl.logError(e, "security.error.convert.json.to.role");
    }
  }
Exemplo n.º 11
0
 /**
  * Gets the all roles.
  *
  * @return the all roles
  */
 @Transient
 public List<String> getAllRoles() {
   Set<String> roleSet = new HashSet<String>();
   for (SiteResearchStaff siteResearchStaff : getSiteResearchStaffs()) {
     for (SiteResearchStaffRole siteResearchStaffRole :
         siteResearchStaff.getSiteResearchStaffRoles()) {
       if (siteResearchStaffRole.isActive()) {
         roleSet.add(siteResearchStaffRole.getRoleCode());
       }
     }
   }
   List<String> roleList = new ArrayList<String>();
   roleList.addAll(roleSet);
   return roleList;
 }
Exemplo n.º 12
0
 public boolean addLike(User user) {
   thoseWhoLike.add(user);
   boolean changed = user.likes.add(this);
   this.save();
   return changed;
 }
Exemplo n.º 13
0
 /**
  * Goes trough the table auction and checks which auctions are over. If the auction is over, finds
  * all bids for that auction, selects the highest bid and sends winning message, also sends to all
  * other users message that auction is over.
  */
 public static void checkAuctionOutcome() {
   // Declaring list of all auctions.
   List<Auction> auctions = finder.all();
   // Declaring variable that represents current date.
   Date currentDate = new Date();
   // Going trough all auctions.
   for (int i = 0; i < auctions.size(); i++) {
     // Declaring variable that represents auction ending date.
     Date auctionEndingDate = auctions.get(i).endingDate;
     // Checking if the auction is active and if the auction ending date is before current date.
     if (auctions.get(i).isActive && auctionEndingDate.before(currentDate)) {
       // Finding all auction bids.
       List<Bid> bids = Bid.getAuctionBids(auctions.get(i));
       // Declaring variable that represents highest bid.
       Bid highestBid = bids.get(0);
       // Declaring string variable that represents winning message.
       String winningMessage =
           "Congratulations!!! You won bitBay auction for item #"
               + auctions.get(i).product.id
               + " - "
               + auctions.get(i).product.name
               + ".\n\r \n\r To proceed with transaction please contact: "
               + auctions.get(i).product.user.email;
       // Declaring and saving winning message.
       Message message =
           new Message(
               CommonHelpers.serviceUser(), highestBid.user, "Auction Winning", winningMessage);
       message.save();
       // Sending SMS notification to auction winner.
       String sms =
           "Congratulations!!! You won bitBay auction for item #"
               + auctions.get(i).product.id
               + " - "
               + auctions.get(i).product.name
               + ". "
               + "This product has been sent to your cart";
       if (highestBid.user.phoneNumber != null) {
         SmsHelper.sendSms(sms, highestBid.user.phoneNumber);
       }
       // After user won on auction create new cart if user don't have one, and put auction item to
       // his cart
       Cart cart = Cart.findCartByUser(highestBid.user);
       if (cart == null) {
         Cart newCart = new Cart();
         newCart.user = highestBid.user;
         newCart.save();
         CartItem cartItem = new CartItem(auctions.get(i).product, highestBid.user, newCart);
         cartItem.save();
       } else {
         CartItem cartItem = new CartItem(auctions.get(i).product, highestBid.user, cart);
         cartItem.save();
       }
       // Declaring string set that will contain emails of all users that have not had highest bid.
       Set<String> bidUsers = new HashSet<>();
       // Adding all user emails to the set.
       for (int j = 0; j < bids.size(); j++) {
         bidUsers.add(bids.get(j).user.email);
       }
       // Removing email of highest bit user from the set.
       bidUsers.remove(highestBid.user.email);
       // Declaring string variable that represents losing message.
       String losingMessage =
           "Biding for item #"
               + auctions.get(i).product.id
               + " - "
               + auctions.get(i).product.name
               + " is over.\n\r \n\r We are sorry to inform you that your bid was not enough.";
       // Declaring iterator list of all user emails.
       Iterator<String> iter = bidUsers.iterator();
       // Going trough all emails and sending message.
       while (iter.hasNext()) {
         User receiver = User.getUserByEmail(iter.next());
         Message msg =
             new Message(CommonHelpers.serviceUser(), receiver, "Auction results", losingMessage);
         msg.save();
       }
       // Setting auction status to inactive.
       auctions.get(i).isActive = false;
       auctions.get(i).update();
     }
   }
 }