/** * Creates a {@code Predicate} to determine if a date matches the filters from the request. If the request * does not contain any update date filters, the returned {@code Predicate} will return {@code true} for every date. * * @param request request to generate the updated date predicate from * @return {@code Predicate} to determine if a date matches the filters from the request */ public static Predicate<Date> inDateRange(ActivityRequest request) { Predicate<Date> alwaysTrue = Predicates.<Date>alwaysTrue(); return foldl(request.getStandardFilters().get(UPDATE_DATE.getKey()), alwaysTrue, ContainsDate.INSTANCE); }
/** * Determines the search terms (i.e. issue keys) to exclude based on the {@code ActivityRequest}. * * @param request the {@code ActivityRequest} containing the filter information * @return the search terms to be excluded */ public static Iterable<String> getExcludedSearchTerms(ActivityRequest request) { return getNotValues(request.getStandardFilters().get(ISSUE_KEY.getKey())); }
/** * Creates a {@code Predicate} to determine if a user name matches the filters from the request. If the request * does not contain any user filters, the returned {@code Predicate} will return {@code true} for every user name. * * @param request request to generate the user name predicate from * @return {@code Predicate} to determine if a user name matches the filters from the request */ public static Predicate<String> inUsers(final ActivityRequest request) { return isAndNot(request.getStandardFilters().get(USER.getKey())); }
/** * Determines the authors based on the {@code ActivityRequest}. * * @param request the {@code ActivityRequest} containing the filter information * @return the authors to be searched */ public static Iterable<String> getAuthors(ActivityRequest request) { return getIsValues(request.getStandardFilters().get(USER.getKey())); }
public NotInUsers(ActivityRequest request) { nottedUsers = getAllValues(NOT, request.getStandardFilters().get(USER.getKey())); }
/** * Determines the search terms (i.e. issue keys) based on the {@code ActivityRequest}. * * @param request the {@code ActivityRequest} containing the filter information * @return the search terms to be searched */ public static Iterable<String> getSearchTerms(ActivityRequest request) { return getIsValues(request.getStandardFilters().get(ISSUE_KEY.getKey())); }
private Collection<String> getUsers(ActivityRequest request) { Collection<Pair<Operator, Iterable<String>>> filters = request.getStandardFilters().get(USER.getKey()); if (filters.isEmpty()) { // ChangeHistoryManager is a bit stupid and will add a "reporter in ()" clause if the user list is // not null and empty. So we return null here to signal it shouldn't add any reporter clause. return null; } Collection<String> result = getIsValues(filters); if (result.isEmpty()) { // See above return null; } else { Set<String> keysFromNames = ImmutableSet.copyOf(filter(transform(result, keyToUsername),notNull())); // See above return keysFromNames.isEmpty() ? null : keysFromNames; } }
/** * Creates a {@code Predicate} to determine if an issue key matches the filters from the request. If the request * does not contain any issue key filters, the returned {@code Predicate} will return {@code true} for every issue * key. * * @param request request to generate the issue key predicate from * @return {@code Predicate} to determine if an issue key matches the filters from the request */ public static Predicate<String> inIssueKeys(ActivityRequest request) { return isAndNot(request.getStandardFilters().get(ISSUE_KEY.getKey())); }
/** * Determines the issue keys based on the {@code ActivityRequest} * @param request the {@code ActivityRequest} containing the filter information * @return the issue keys to be searched */ public static Iterable<String> getIssueKeys(ActivityRequest request) { return getIsValues(request.getStandardFilters().get(ISSUE_KEY.getKey())); }
/** * Determines the issue keys to exclude based on the {@code ActivityRequest} * @param request the {@code ActivityRequest} containing the filter information * @return the issue keys to be excluded */ public static Iterable<String> getNotIssueKeys(ActivityRequest request) { return getNotValues(request.getStandardFilters().get(ISSUE_KEY.getKey())); }
/** * Creates a {@code Predicate} to determine if an issue key matches the filters from the request. If the request * does not contain any issue key filters, the returned {@code Predicate} will return {@code true} for every issue * key. * * @param request request to generate the issue key predicate from * @param is {@code Function} which is used to construct the {@code Predicate} for checking if an issue key is in * the list of issue keys from the filter * @param not {@code Function}s which is used to construct the {@code Predicate} for checking if an issue key is not * in the list of issue keys from the filter * @return {@code Predicate} to determine if an issue key matches the filters from the request */ public static Predicate<String> inIssueKeys(ActivityRequest request, Function<Iterable<String>, Predicate<String>> is, Function<Iterable<String>, Predicate<String>> not) { return isAndNot(request.getStandardFilters().get(ISSUE_KEY.getKey()), is, not); }
static Clause filterByDate(final ActivityRequest request) { return filterBy(request.getStandardFilters().get(UPDATE_DATE.getKey()), toCreatedOrUpdatedClause()); }
@Test public void assertThatIssueIdentifierReturnsIssueFilterKey() { assertThat(provider.getFilterKey(getIssueEntityIdentifier(ISSUE_ENTITY_KEY)), equalTo(some(StandardStreamsFilterOption.ISSUE_KEY.getKey()))); }
/** * Creates a {@code Predicate} to determine if any of several usernames match the filters from the request. * If the request does not contain any author filters, the returned {@code Predicate} will return {@code true} * for every username. Only a single match is needed for the {@code Predicate} to return true. * * @param request request to generate the user predicate from * @return {@code Predicate} to determine if a set of usernames match the filters from the request */ public static Predicate<Iterable<String>> anyInUsers(ActivityRequest request) { if (isEmpty(getIsValues(request.getStandardFilters().get(USER.getKey())))) { return alwaysTrue(); } return new AnyInUsers(request); }
static Clause filterByIssueKey(final ActivityRequest request) { return filterBy(request.getStandardFilters().get(ISSUE_KEY.getKey()), toIssueKeyClause()); }
static Clause filterByUser(final ActivityRequest request) { return filterBy(request.getStandardFilters().get(USER.getKey()), toReporterClause()); }
public Set<Review> apply(Set<Review> reviews) { Pair<Set<String>, Set<String>> isAndNotIssueKeys = getIsAndNotValues(request.getStandardFilters().get(ISSUE_KEY.getKey())); Iterable<String> issueKeys = isAndNotIssueKeys.first(); Iterable<String> notIssueKeys = isAndNotIssueKeys.second(); return Sets.filter(reviews, and( nameOrDescription(containsIssueKeys(issueKeys).getOrElse(Predicates.<String>alwaysTrue())), not(nameOrDescription(containsIssueKeys(notIssueKeys).getOrElse(Predicates.<String>alwaysFalse()))))); } };
/** * Determines the maximum date filter based on the {@code ActivityRequest}. Returns null if none is specified. * * @param request the {@code ActivityRequest} containing the filter information * @return the maximum date */ public static Option<Date> getMaxDate(ActivityRequest request) { Collection<Pair<Operator, Iterable<String>>> filters = request.getStandardFilters().get(UPDATE_DATE.getKey()); //first try with BEFORE operator Option<Long> maxDate = parseLongSafely(getFirstValue(BEFORE, filters)); if (!maxDate.isDefined() && size(filters) > 0) { return getDateRange(filters).map(Pairs.<Date, Date>second()); } return maxDate.map(toDate); }
private Iterable<CrucibleActivityItemParameter> activityItemParameters(ActivityRequest request, Option<Set<Review>> reviews) { ImmutableList.Builder<CrucibleActivityItemParameter> builder = new ImmutableList.Builder<CrucibleActivityItemParameter>(); builder.add(builder(PROJECT_KEY, IN).values(getIsValues(request.getStandardFilters().get(StandardStreamsFilterOption.PROJECT_KEY))).build()); builder.add(builder(USERNAME, IN).values(getIsValues(request.getStandardFilters().get(USER.getKey()))).build()); builder.add(builder(REVIEW_ID, IN).values(transform(reviews.getOrElse(ImmutableSet.<Review>of()), toReviewId())).build()); builder.add(builder(LOG_ACTION, IN).values(SUPPORTED_ACTIONS).build()); for (Date date : getMinDate(request)) { builder.add(builder(CREATE_DATE, GT).value(date).build()); } for (Date date : getMaxDate(request)) { builder.add(builder(CREATE_DATE, LT).value(date).build()); } builder.add(builder(PROJECT_KEY, NOT_IN).values(getAllValues(NOT, request.getStandardFilters().get(StandardStreamsFilterOption.PROJECT_KEY))).build()); builder.add(builder(USERNAME, NOT_IN).values(getAllValues(NOT, request.getStandardFilters().get(USER.getKey()))).build()); return builder.build(); }
(StandardStreamsFilterOption.PROJECT_KEY))); filter.setInIssueKeys(Filters.getIsValues(activityRequest.getStandardFilters().get(StandardStreamsFilterOption .ISSUE_KEY.getKey()))); filter.setNotInIssueKeys(Filters.getNotValues(activityRequest.getStandardFilters().get (StandardStreamsFilterOption.ISSUE_KEY.getKey()))); filter.setInUsers(Filters.getIsValues(activityRequest.getStandardFilters().get(StandardStreamsFilterOption.USER .getKey()))); filter.setNotInUsers(Filters.getNotValues(activityRequest.getStandardFilters().get(StandardStreamsFilterOption .USER.getKey())));