Exemplo n.º 1
0
 public PostingRule getPostingRuleByEventTypeAndDate(EventType eventType, DateTime when) {
   for (final PostingRule postingRule : getActivePostingRules(when)) {
     if (postingRule.getEventType() == eventType) {
       return postingRule;
     }
   }
   return null;
 }
Exemplo n.º 2
0
  public Set<PostingRule> getActiveVisiblePostingRules(DateTime when) {
    final Set<PostingRule> result = new HashSet<PostingRule>();
    for (final PostingRule postingRule : getPostingRules()) {
      if (postingRule.isActiveForDate(when) && postingRule.isVisible()) {
        result.add(postingRule);
      }
    }

    return result;
  }
Exemplo n.º 3
0
  public Set<PostingRule> getActivePostingRules(DateTime when) {
    final Set<PostingRule> activePostingRules = new HashSet<PostingRule>();
    for (final PostingRule postingRule : getPostingRules()) {
      if (postingRule.isActiveForDate(when)) {
        activePostingRules.add(postingRule);
      }
    }

    return activePostingRules;
  }
Exemplo n.º 4
0
  public Set<PostingRule> getAllPostingRulesFor(final EventType eventType) {
    final Set<PostingRule> result = new HashSet<PostingRule>();

    for (final PostingRule postingRule : super.getPostingRulesSet()) {
      if (postingRule.getEventType() == eventType) {
        result.add(postingRule);
      }
    }

    return result;
  }
Exemplo n.º 5
0
  public PostingRule findPostingRuleBy(EventType eventType, DateTime startDate, DateTime endDate) {
    final List<PostingRule> activePostingRulesInPeriod = new ArrayList<PostingRule>();
    for (final PostingRule postingRule : getPostingRulesSet()) {
      if (postingRule.isActiveForPeriod(startDate, endDate)
          && postingRule.getEventType() == eventType) {
        activePostingRulesInPeriod.add(postingRule);
      }
    }

    return activePostingRulesInPeriod.isEmpty()
        ? null
        : Collections.max(activePostingRulesInPeriod, PostingRule.COMPARATOR_BY_START_DATE);
  }