com.hazelcast.query.Predicate Java Examples

The following examples show how to use com.hazelcast.query.Predicate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapPredicateTest.java    From hazelcast-simulator with Apache License 2.0 6 votes vote down vote up
@TimeStep(prob = 0.2)
public void pagePredicate(ThreadState state) {
    double maxSalary = state.randomDouble() * Employee.MAX_SALARY;
    Predicate predicate = Predicates.lessThan("salary", maxSalary);
    SalaryComparator salaryComparator = new SalaryComparator();
    PagingPredicate pagingPredicate = new PagingPredicateImpl(predicate, salaryComparator, pageSize);

    Collection<Employee> employees;
    List<Employee> employeeList;
    do {
        employees = map.values(pagingPredicate);
        employeeList = fillListWithQueryResultSet(employees);
        Employee nextEmployee;
        Employee currentEmployee;
        for (int i = 0; i < employeeList.size() - 1; i++) {
            currentEmployee = employeeList.get(i);
            nextEmployee = employeeList.get(i + 1);
            // check the order & max salary
            assertTrue(format(baseAssertMessage, currentEmployee.getSalary(), predicate),
                    currentEmployee.getSalary() <= nextEmployee.getSalary() && nextEmployee.getSalary() < maxSalary);
        }
        pagingPredicate.nextPage();
    } while (!employees.isEmpty());

    state.operationCounter.pagePredicateCount++;
}
 
Example #2
Source File: MapPredicateTest.java    From hazelcast-simulator with Apache License 2.0 6 votes vote down vote up
@TimeStep(prob = 0.2)
public void predicateBuilder(ThreadState state) {
    long startMs = System.currentTimeMillis();

    int age = state.randomInt(Employee.MAX_AGE);
    String name = Employee.getRandomName();

    // TODO: Still broken because it relies on reflection which is dog slow, so we need an explicit AgeNamePredicate
    PredicateBuilder.EntryObject entryObject = new PredicateBuilderImpl().getEntryObject();
    Predicate agePredicate = entryObject.get("age").lessThan(age);
    Predicate ageNamePredicate = entryObject.get("name").equal(name).and(agePredicate);

    Collection<Employee> employees = map.values(ageNamePredicate);
    for (Employee emp : employees) {
        String assertMessage = format(baseAssertMessage, emp, ageNamePredicate);
        assertTrue(assertMessage, emp.getAge() < age);
        assertTrue(assertMessage, emp.getName().equals(name));
    }
    state.operationCounter.predicateBuilderCount++;

    updateStats(state, startMs);
}
 
Example #3
Source File: MultiValueMapTest.java    From hazelcast-simulator with Apache License 2.0 6 votes vote down vote up
@TimeStep(prob = -1)
public void query(ThreadState state, Probe probe, @StartNanos long startNanos) {
    int key = state.getRandomKey();
    Predicate predicate = Predicates.equal("payloadField[any]", key);
    Collection<Object> result = null;
    try {
        result = map.values(predicate);
    } finally {
        probe.done(startNanos);
    }

    if (throttlingLogger.requestLogSlot()) {
        throttlingLogger.logInSlot(Level.INFO,
                format("Query 'payloadField[any]= %d' returned %d results.", key, result.size()));
    }

    for (Object resultSillySequence : result) {
        state.assertValidSequence(resultSillySequence);
    }
}
 
Example #4
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 6 votes vote down vote up
@Override
protected KeyValueQuery<Predicate<?, ?>> complete(Predicate<?, ?> criteria, Sort sort) {

    KeyValueQuery<Predicate<?, ?>> keyValueQuery;

    if (this.limit == 0) {
        keyValueQuery = new KeyValueQuery<>(criteria);
    } else {
        keyValueQuery = new KeyValueQuery<Predicate<?, ?>>(new PagingPredicateImpl(criteria, this.limit));
    }

    if (sort != null) {
        keyValueQuery.setSort(sort);
    }
    return keyValueQuery;
}
 
Example #5
Source File: ClientServerIT.java    From spring-data-hazelcast with Apache License 2.0 6 votes vote down vote up
@Test
public void notJavaDuke() {
    String FIRST_NAME_IS_JOHN = "John";
    String LAST_NAME_IS_WAYNE = "Wayne";
    String NINETEEN_SIXTY_NINE = "1969";

    Predicate<?, ?> predicate = Predicates
            .and(Predicates.equal("firstname", FIRST_NAME_IS_JOHN), Predicates.equal("lastname", LAST_NAME_IS_WAYNE));

    // Force operation to server's content, not remote
    Set<String> localKeySet = super.server_personMap.localKeySet((Predicate<String, Person>) predicate);

    assertThat("Entry exists", localKeySet.size(), equalTo(1));
    String key = localKeySet.iterator().next();

    assertThat("Correct key", key, equalTo(NINETEEN_SIXTY_NINE));

    Person person = super.server_personMap.get(key);
    assertThat("Not invalidated", person, notNullValue());
    assertThat("@Id matches key", person.getId(), equalTo(key));
    assertThat("First name", person.getFirstname(), equalTo(FIRST_NAME_IS_JOHN));
    assertThat("Last name", person.getLastname(), equalTo(LAST_NAME_IS_WAYNE));
}
 
Example #6
Source File: HazelcastCriteriaAccessor.java    From spring-data-hazelcast with Apache License 2.0 6 votes vote down vote up
/**
 * @param A query in Spring form
 * @return The same in Hazelcast form
 */
public Predicate<?, ?> resolve(KeyValueQuery<?> query) {

    if (query == null) {
        return null;
    }

    final Object criteria = query.getCriteria();
    if (criteria == null) {
        return null;
    }

    if (criteria instanceof PagingPredicateImpl) {
        PagingPredicateImpl pagingPredicate = (PagingPredicateImpl) criteria;
        query.limit(pagingPredicate.getPageSize());
        return pagingPredicate.getPredicate();
    }

    if (criteria instanceof Predicate) {
        return (Predicate<?, ?>) criteria;
    }

    throw new UnsupportedOperationException(query.toString());
}
 
Example #7
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 6 votes vote down vote up
private Predicate<?, ?> fromInequalityVariant(Type type, String property, Iterator<Comparable<?>> iterator) {
    switch (type) {
        case AFTER:
        case GREATER_THAN:
            return Predicates.greaterThan(property, iterator.next());
        case GREATER_THAN_EQUAL:
            return Predicates.greaterEqual(property, iterator.next());
        case BEFORE:
        case LESS_THAN:
            return Predicates.lessThan(property, iterator.next());
        case LESS_THAN_EQUAL:
            return Predicates.lessEqual(property, iterator.next());
        case BETWEEN:
            Comparable<?> first = iterator.next();
            Comparable<?> second = iterator.next();
            return Predicates.between(property, first, second);
        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example #8
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 6 votes vote down vote up
private Predicate<?, ?> fromEqualityVariant(Type type, boolean ignoreCase, String property,
                                            Iterator<Comparable<?>> iterator) {
    switch (type) {
        case SIMPLE_PROPERTY:
            if (ignoreCase) {
                return Predicates.ilike(property, iterator.next().toString());
            } else {
                return Predicates.equal(property, iterator.next());
            }
        case NEGATING_SIMPLE_PROPERTY:
            if (ignoreCase) {
                return Predicates.not(Predicates.ilike(property, iterator.next().toString()));
            } else {
                return Predicates.notEqual(property, iterator.next());
            }
        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example #9
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 6 votes vote down vote up
private Predicate<?, ?> fromLikeVariant(Type type, boolean ignoreCase, String property, Iterator<Comparable<?>> iterator) {
    String likeExpression = iterator.next().toString();
    switch (type) {
        case CONTAINING:
        case NOT_CONTAINING:
            likeExpression = String.join("", "%", likeExpression, "%");
            break;
        case STARTING_WITH:
            likeExpression = String.join("", likeExpression, "%");
            break;
        case ENDING_WITH:
            likeExpression = String.join("", "%", likeExpression);
            break;
        case LIKE:
        case NOT_LIKE:
            break;
        default:
            throw new InvalidDataAccessApiUsageException(String.format("'%s' is not supported for LIKE style query", type));
    }

    Predicate likePredicate = ignoreCase ? Predicates.ilike(property, likeExpression) : Predicates
            .like(property, likeExpression);
    return type.equals(NOT_LIKE) || type.equals(NOT_CONTAINING) ? Predicates.not(likePredicate) : likePredicate;
}
 
Example #10
Source File: HazelcastService.java    From devicehive-java-server with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private <T extends HazelcastEntity> Collection<T> find(Predicate predicate, int pageSize, Class<T> tClass) {
    final Predicate pagingPredicate = (pageSize > 0)
            ? new PagingPredicate(predicate, new HazelcastEntityComparator(), pageSize)
            : predicate;
    return (Collection<T>) mapsHolder.get(tClass).values(pagingPredicate);
}
 
Example #11
Source File: HazelcastService.java    From devicehive-java-server with Apache License 2.0 5 votes vote down vote up
public <T extends HazelcastEntity> Collection<T> find(String deviceId,
                                                      Collection<Long> networkIds,
                                                      Collection<Long> deviceTypeIds,
                                                      Collection<String> names,
                                                      Integer take,
                                                      Date timestampSt,
                                                      Date timestampEnd,
                                                      boolean returnUpdated,
                                                      String status,
                                                      Class<T> entityClass) {
    final Predicate filters = hazelcastHelper.prepareFilters(deviceId, networkIds, deviceTypeIds, names,
            timestampSt, timestampEnd, returnUpdated, status, entityClass);
    return find(filters, take, entityClass);
}
 
Example #12
Source File: HazelcastService.java    From devicehive-java-server with Apache License 2.0 5 votes vote down vote up
public <T extends HazelcastEntity> Collection<T> find(Collection<String> deviceIds,
                                                      Collection<String> names,
                                                      Integer take,
                                                      Date timestampSt,
                                                      Date timestampEnd,
                                                      boolean returnUpdated,
                                                      String status,
                                                      Class<T> entityClass) {
    final Predicate filters = hazelcastHelper.prepareFilters(deviceIds,  names, timestampSt, timestampEnd,
           returnUpdated, status, entityClass);
    return find(filters, take, entityClass);
}
 
Example #13
Source File: SerializationStrategyTest.java    From hazelcast-simulator with Apache License 2.0 5 votes vote down vote up
@TimeStep(prob = 1)
public void getByStringIndex(ThreadState state) {
    String string = state.getUniqueString();
    Predicate predicate = Predicates.equal("stringVal", string);
    Set<Map.Entry<String, DomainObject>> entries = map.entrySet(predicate);
    throttlingLogger.log(Level.INFO, "GetByStringIndex: " + entries.size() + " entries");
}
 
Example #14
Source File: MapGetVsQueryTest.java    From hazelcast-simulator with Apache License 2.0 5 votes vote down vote up
@TimeStep(prob = 0)
public void predicateBuilder(ThreadState state) {
    int id = state.randomInt(itemCount);
    PredicateBuilder.EntryObject entryObject = new PredicateBuilderImpl().getEntryObject();
    Predicate predicate = entryObject.get("id").equal(id);
    map.values(predicate);
}
 
Example #15
Source File: HazelcastSortAccessorTest.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolvingMultipleSortOrdersReturnsCompositeComparator() {
    //given
    KeyValueQuery<Predicate<String, Foo>> query = new KeyValueQuery<>();
    Sort.Order fooOrder = new Sort.Order(Sort.Direction.DESC, "foo");
    Sort.Order barOrder = new Sort.Order(Sort.Direction.DESC, "bar");

    query.setSort(Sort.by(fooOrder, barOrder));

    HazelcastSortAccessorTest.Foo testData1 = new HazelcastSortAccessorTest.Foo("zzz", "def");
    HazelcastSortAccessorTest.Foo testData2 = new HazelcastSortAccessorTest.Foo("aaa", "aaa");
    Map.Entry<String, HazelcastSortAccessorTest.Foo> entry1 = entryOf("testData1", testData1);
    Map.Entry<String, HazelcastSortAccessorTest.Foo> entry2 = entryOf("testData2", testData2);

    HazelcastSortAccessorTest.Foo testData3 = new HazelcastSortAccessorTest.Foo("aaa", "aaa");
    HazelcastSortAccessorTest.Foo testData4 = new HazelcastSortAccessorTest.Foo("aaa", "def");
    Map.Entry<String, HazelcastSortAccessorTest.Foo> entry3 = entryOf("testData3", testData3);
    Map.Entry<String, HazelcastSortAccessorTest.Foo> entry4 = entryOf("testData4", testData4);

    //when
    HazelcastSortAccessor hazelcastSortAccessor = new HazelcastSortAccessor();
    Comparator<Map.Entry<?, ?>> comparator = (Comparator<Map.Entry<?, ?>>) hazelcastSortAccessor.resolve((KeyValueQuery<?>) query);

    //then
    assertNotNull(comparator);
    assertTrue(comparator.compare(entry1, entry2) < 0);
    assertTrue(comparator.compare(entry2, entry1) > 0);
    assertFalse(comparator.compare(entry3, entry4) == 0);
    assertTrue((comparator.compare(entry3, entry4) > 0));
}
 
Example #16
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
private Predicate<?, ?> fromEmptyVariant(Type type, String property) {
    switch (type) {
        case IS_EMPTY:
            return Predicates.equal(property, "");
        case IS_NOT_EMPTY:
            return Predicates.notEqual(property, "");

        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example #17
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
private Predicate<?, ?> fromCollectionVariant(Type type, String property, Iterator<Comparable<?>> iterator) {
    switch (type) {
        case IN:
            return Predicates.in(property, collectToArray(type, iterator));
        case NOT_IN:
            return Predicates.not(Predicates.in(property, collectToArray(type, iterator)));
        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example #18
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
private Predicate<?, ?> fromBooleanVariant(Type type, String property) {
    switch (type) {
        case TRUE:
            return Predicates.equal(property, true);
        case FALSE:
            return Predicates.equal(property, false);
        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example #19
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
private Predicate<?, ?> fromNullVariant(Type type, String property) {
    switch (type) {
        case IS_NULL:
            return Predicates.equal(property, null);
        case IS_NOT_NULL:
            return Predicates.notEqual(property, null);

        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example #20
Source File: HazelcastQueryEngine.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Construct the final query predicate for Hazelcast to execute, from the base query plus any paging and sorting.
 * </P>
 * <p>
 * Variations here allow the base query predicate to be omitted, sorting to be omitted, and paging to be omitted.
 * </P>
 *
 * @param criteria Search criteria, null means match everything
 * @param sort     Possibly null collation
 * @param offset   Start point of returned page, -1 if not used
 * @param rows     Size of page, -1 if not used
 * @param keyspace The map name
 * @return Results from Hazelcast
 */
@Override
public Collection<?> execute(final Predicate<?, ?> criteria, final Comparator<Entry<?, ?>> sort, final long offset,
                             final int rows, final String keyspace) {

    final HazelcastKeyValueAdapter adapter = getAdapter();
    Assert.notNull(adapter, "Adapter must not be 'null'.");

    Predicate<?, ?> predicateToUse = criteria;
    @SuppressWarnings({"unchecked", "rawtypes"}) Comparator<Entry> sortToUse = ((Comparator<Entry>) (Comparator) sort);

    if (rows > 0) {
        PagingPredicate pp = new PagingPredicateImpl(predicateToUse, sortToUse, rows);
        long x = offset / rows;
        while (x > 0) {
            pp.nextPage();
            x--;
        }
        predicateToUse = pp;

    } else {
        if (sortToUse != null) {
            predicateToUse = new PagingPredicateImpl(predicateToUse, sortToUse, Integer.MAX_VALUE);
        }
    }

    if (predicateToUse == null) {
        return adapter.getMap(keyspace).values();
    } else {
        return adapter.getMap(keyspace).values((Predicate<Object, Object>) predicateToUse);
    }

}
 
Example #21
Source File: MatchDetailHandler.java    From match-trade with Apache License 2.0 4 votes vote down vote up
/**
 * @Title: outMatchDepth 保证了原子操作,无需事务
 * @Description: TODO(out订单处理)
 * @param @param order 入单
 * @return void 返回类型
 * @throws
 */
@Async
public void outMatchDepth(MatchOrder order) {
	List<LevelMatch> list = order.getList();
	try {
		if (null!=list&&list.size()>0) {
			Iterator<LevelMatch> itr = list.iterator();
			while (itr.hasNext()){
				LevelMatch lm = itr.next();
				itr.remove();
				BigDecimal dealNumber = lm.getNumber();
				while (dealNumber.compareTo(BigDecimal.ZERO)>0) {
					//对手盘
					IMap<Long, MatchOrder> order_map = hzInstance.getMap(HazelcastUtil.getOrderBookKey(order.getCoinTeam(), !order.getIsBuy()));
					@SuppressWarnings("rawtypes")
					Predicate pricePredicate = Predicates.equal("price", lm.getPrice());
					Collection<MatchOrder> orders = order_map.values(pricePredicate);
					for (MatchOrder mor : orders) {
						MatchOrder out = order_map.remove(mor.getId());
						if (null!=out) {
							int cpr = dealNumber.compareTo(out.getUnFinishNumber());
							if (cpr>0) {
								dealNumber=dealNumber.subtract(out.getUnFinishNumber());
								this.updateOutOder(out, OrderState.ALL, out.getUnFinishNumber());
							}else if (cpr==0) {
								this.updateOutOder(out, OrderState.ALL, dealNumber);
								dealNumber = BigDecimal.ZERO;
								break;
							}else {
								out = this.updateOutOder(out, OrderState.PART, dealNumber);
								order_map.put(out.getId(), out);
								dealNumber = BigDecimal.ZERO;
								break;
							}
						}
					}
				}
			}
		}
	} catch (Exception e) {
		log.error("===出单数据处理异常,数据原型:"+order.toJsonString()+"   本次异常:"+e);
	}
}
 
Example #22
Source File: Oauth2UserPostHandler.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    Map<String, Object> body = (Map)exchange.getAttachment(BodyHandler.REQUEST_BODY);
    User user = Config.getInstance().getMapper().convertValue(body, User.class);

    String email = user.getEmail();
    IMap<String, User> users = CacheStartupHookProvider.hz.getMap("users");
    // make sure that email is not duplicated in users.
    Predicate predicate = new SqlPredicate(String.format("email = %s", email));
    Set<User> set = (Set<User>) users.values(predicate);
    if(set != null && set.size() > 0) {
        setExchangeStatus(exchange, EMAIL_EXISTS, email);
        processAudit(exchange);
        return;
    }

    String password = user.getPassword();
    String passwordConfirm = user.getPasswordConfirm();
    if(password != null && password.length() > 0 && passwordConfirm != null && passwordConfirm.length() > 0) {
        // check if there are the same
        if(password.equals(passwordConfirm)) {
            // hash the password with salt.
            String hashedPass = HashUtil.generateStrongPasswordHash(password);
            user.setPassword(hashedPass);
            user.setPasswordConfirm(null);
            String userId = user.getUserId();
            if(users.get(userId) == null) {
                users.set(userId, user);
            } else {
                setExchangeStatus(exchange, USER_ID_EXISTS, userId);
            }
        } else {
            // password and passwordConfirm not match.
            setExchangeStatus(exchange, PASSWORD_PASSWORDCONFIRM_NOT_MATCH, password, passwordConfirm);
        }
    } else {
        // error password or passwordConform is empty
        setExchangeStatus(exchange, PASSWORD_OR_PASSWORDCONFIRM_EMPTY, password, passwordConfirm);
    }
    processAudit(exchange);
}
 
Example #23
Source File: HazelcastService.java    From devicehive-java-server with Apache License 2.0 4 votes vote down vote up
public <T extends HazelcastEntity> Optional<T> find(Long id, String deviceId, boolean returnUpdated, Class<T> entityClass) {
    final Predicate filters = hazelcastHelper.prepareFilters(id, deviceId, returnUpdated, entityClass);
    return find(filters, 1, entityClass).stream().findFirst();
}
 
Example #24
Source File: HazelcastService.java    From devicehive-java-server with Apache License 2.0 4 votes vote down vote up
public <T extends HazelcastEntity> Optional<T> find(Long id, String deviceId, Class<T> entityClass) {
    final Predicate filters = hazelcastHelper.prepareFilters(id, deviceId, entityClass);
    return find(filters, 1, entityClass).stream().findFirst();
}
 
Example #25
Source File: HazelcastHelper.java    From devicehive-java-server with Apache License 2.0 4 votes vote down vote up
private <T extends HazelcastEntity> Predicate prepareFilters(Long id, Collection<String> deviceIds, Collection<Long> networkIds,
        Collection<Long> deviceTypeIds, Collection<String> names, Date timestampSt, Date timestampEnd,
        boolean returnUpdated, String status, Class<T> entityClass) {
    final List<Predicate> predicates = new ArrayList<>();
    if (id != null) {
        predicates.add(Predicates.equal(ID.getField(), id));
    }

    if (deviceIds != null && !deviceIds.isEmpty()) {
        predicates.add(Predicates.in(DEVICE_IDS.getField(), deviceIds.toArray(new String[deviceIds.size()])));
    }

    if (networkIds != null && !networkIds.isEmpty()) {
        predicates.add(Predicates.in(NETWORK_IDS.getField(), networkIds.toArray(new Long[networkIds.size()])));
    }

    if (deviceTypeIds != null && !deviceTypeIds.isEmpty()) {
        predicates.add(Predicates.in(DEVICE_TYPE_IDS.getField(), deviceTypeIds.toArray(new Long[deviceTypeIds.size()])));
    }

    String searchableField = entityClass.equals(DeviceCommand.class) ? COMMAND.getField() : NOTIFICATION.getField();
    
    if (!CollectionUtils.isEmpty(names)) {
        predicates.add(Predicates.in(searchableField, names.toArray(new String[names.size()])));
    }
    
    if (returnUpdated) {
        predicates.add(Predicates.equal(IS_UPDATED.getField(), returnUpdated));
    }

    if (timestampSt != null) {
        String searchableFieldSt = returnUpdated ? LAST_UPDATED.getField() : TIMESTAMP.getField();
        predicates.add(Predicates.greaterThan(searchableFieldSt, timestampSt.getTime()));
    }

    if (timestampEnd != null) {
        String searchableFieldEnd = returnUpdated ? LAST_UPDATED.getField() : TIMESTAMP.getField();
        predicates.add(Predicates.lessThan(searchableFieldEnd, timestampEnd.getTime()));
    }


    if (StringUtils.isNotEmpty(status)) {
        predicates.add(Predicates.equal(STATUS.getField(), status));
    }

    final Predicate[] predicatesArray = new Predicate[predicates.size()];
    for (int i = 0; i < predicates.size(); i++) {
        predicatesArray[i] = predicates.get(i);
    }

    return Predicates.and(predicatesArray);
}
 
Example #26
Source File: HazelcastHelper.java    From devicehive-java-server with Apache License 2.0 4 votes vote down vote up
public <T extends HazelcastEntity> Predicate prepareFilters(String deviceId, Collection<Long> networkIds,
        Collection<Long> deviceTypeIds, Collection<String> names, Date timestampSt, Date timestampEnd,
        boolean returnUpdated, String status, Class<T> entityClass) {
    Set<String> deviceIdSet = deviceId != null ? Collections.singleton(deviceId) : null;
    return prepareFilters(null, deviceIdSet, networkIds, deviceTypeIds, names, timestampSt, timestampEnd, returnUpdated, status, entityClass);
}
 
Example #27
Source File: HazelcastHelper.java    From devicehive-java-server with Apache License 2.0 4 votes vote down vote up
public <T extends HazelcastEntity> Predicate prepareFilters(Collection<String> deviceIds, Collection<String> names,
        Date timestampSt, Date timestampEnd, boolean returnUpdated, String status, Class<T> entityClass) {
    return prepareFilters(null, deviceIds, null, null, names, timestampSt, timestampEnd, returnUpdated, status, entityClass);
}
 
Example #28
Source File: HazelcastHelper.java    From devicehive-java-server with Apache License 2.0 4 votes vote down vote up
public <T extends HazelcastEntity> Predicate prepareFilters(final Long id, final String deviceId, final boolean returnUpdated, Class<T> entityClass) {
    return prepareFilters(id, Collections.singleton(deviceId), null, null, null, null, null, returnUpdated, null, entityClass);
}
 
Example #29
Source File: HazelcastHelper.java    From devicehive-java-server with Apache License 2.0 4 votes vote down vote up
public <T extends HazelcastEntity> Predicate prepareFilters(final Long id, final String deviceId, Class<T> entityClass) {
    return prepareFilters(id, Collections.singleton(deviceId), null, null, null, null, null, false, null, entityClass);
}
 
Example #30
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
protected Predicate<?, ?> create(Part part, Iterator<Object> iterator) {
    return this.from(part, (Iterator<Comparable<?>>) (Iterator) iterator);
}