/** * Create a not equal to predicate * * @param attributeName * @param attributeValue * @return */ public static <T> AttributePredicateImpl<T> attributeIsNotEqualTo(String attributeName, T attributeValue) { return new AttributePredicateImpl<>(attributeName, attributeValue, Operator.NOT_EQUAL); }
/** * Constructor. * * @param scopeId * The scope id of the {@link KapuaQuery} * @since 1.0.0 */ public AbstractKapuaQuery(KapuaId scopeId) { this(); setScopeId(scopeId); }
/** * Constructor * * @since 0.1.0 */ public AndPredicateImpl() { setPredicates(new ArrayList<>()); }
private long countExistingCredentials(CredentialType credentialType, KapuaId scopeId, KapuaId userId) throws KapuaException { KapuaLocator locator = KapuaLocator.getInstance(); CredentialFactory credentialFactory = locator.getFactory(CredentialFactory.class); KapuaQuery<Credential> credentialQuery = credentialFactory.newQuery(scopeId); CredentialType ct = credentialType; QueryPredicate credentialTypePredicate = new AttributePredicateImpl<>(CredentialAttributes.CREDENTIAL_TYPE, ct); QueryPredicate userIdPredicate = new AttributePredicateImpl<>(CredentialAttributes.USER_ID, userId); QueryPredicate andPredicate = new AndPredicateImpl().and(credentialTypePredicate).and(userIdPredicate); credentialQuery.setPredicate(andPredicate); return count(credentialQuery); }
/** * This method apply {@link AttributePredicate}s according to the parameters contained into the {@link JobContextWrapper#getTargetSublist()}. * <p> * If the {@link JobContextWrapper#getTargetSublist()} has one or more {@link org.eclipse.kapua.model.id.KapuaId}s they will be added to the * {@link org.eclipse.kapua.model.query.predicate.AndPredicate} to select only given {@link JobTarget}. * * @param jobContextWrapper The {@link JobContextWrapper} from which extract data * @param andPredicate The {@link org.eclipse.kapua.model.query.predicate.AndPredicate} where to apply {@link org.eclipse.kapua.model.query.predicate.QueryPredicate} * @since 1.0.0 */ protected void targetSublistFiltering(JobContextWrapper jobContextWrapper, AndPredicateImpl andPredicate) { if (!jobContextWrapper.getTargetSublist().isEmpty()) { andPredicate.and(new AttributePredicateImpl<>(JobTargetAttributes.ENTITY_ID, jobContextWrapper.getTargetSublist().toArray())); } }
@Override public void addFetchAttributes(String fetchAttribute) { if (getFetchAttributes() == null) { setFetchAttributes(new ArrayList<>()); } getFetchAttributes().add(fetchAttribute); }
/** * Constructor * * @since 0.1.0 */ public OrPredicateImpl() { setPredicates(new ArrayList<>()); }
/** * Constructor. * * It defaults the {@link #sortCriteria} to order by the {@link KapuaEntity#getCreatedOn()} {@link SortOrder#ASCENDING}. * * @since 1.0.0 */ public AbstractKapuaQuery() { setSortCriteria(new FieldSortCriteria(KapuaEntityAttributes.CREATED_ON, SortOrder.ASCENDING)); }
private long countExistingCredentials(CredentialType credentialType, KapuaId scopeId, KapuaId userId) throws KapuaException { KapuaLocator locator = KapuaLocator.getInstance(); CredentialFactory credentialFactory = locator.getFactory(CredentialFactory.class); KapuaQuery<Credential> credentialQuery = credentialFactory.newQuery(scopeId); CredentialType ct = credentialType; QueryPredicate credentialTypePredicate = new AttributePredicateImpl<>(CredentialAttributes.CREDENTIAL_TYPE, ct); QueryPredicate userIdPredicate = new AttributePredicateImpl<>(CredentialAttributes.USER_ID, userId); QueryPredicate andPredicate = new AndPredicateImpl().and(credentialTypePredicate).and(userIdPredicate); credentialQuery.setPredicate(andPredicate); return count(credentialQuery); }
/** * This method apply {@link AttributePredicate}s according to the parameters contained into the {@link JobContextWrapper#getTargetSublist()}. * <p> * If the {@link JobContextWrapper#getTargetSublist()} has one or more {@link org.eclipse.kapua.model.id.KapuaId}s they will be added to the * {@link org.eclipse.kapua.model.query.predicate.AndPredicate} to select only given {@link JobTarget}. * * @param jobContextWrapper The {@link JobContextWrapper} from which extract data * @param andPredicate The {@link org.eclipse.kapua.model.query.predicate.AndPredicate} where to apply {@link org.eclipse.kapua.model.query.predicate.QueryPredicate} * @since 1.0.0 */ protected void targetSublistFiltering(JobContextWrapper jobContextWrapper, AndPredicateImpl andPredicate) { if (!jobContextWrapper.getTargetSublist().isEmpty()) { andPredicate.and(new AttributePredicateImpl<>(JobTargetAttributes.ENTITY_ID, jobContextWrapper.getTargetSublist().toArray())); } }
/** * Create an equal to predicate * * @param attributeName * @param attributeValue * @return */ public static <T> AttributePredicateImpl<T> attributeIsEqualTo(String attributeName, T attributeValue) { return new AttributePredicateImpl<>(attributeName, attributeValue); }
@Override public void addFetchAttributes(String fetchAttribute) { if (getFetchAttributes() == null) { setFetchAttributes(new ArrayList<>()); } getFetchAttributes().add(fetchAttribute); }
/** * Constructor * * @since 0.1.0 */ public OrPredicateImpl() { setPredicates(new ArrayList<>()); }
/** * Constructor. * * @param scopeId * The scope id of the {@link KapuaQuery} * @since 1.0.0 */ public AbstractKapuaQuery(KapuaId scopeId) { this(); setScopeId(scopeId); }
/** * Constructor * * @since 0.1.0 */ public AndPredicateImpl() { setPredicates(new ArrayList<>()); }
/** * Constructor. * * It defaults the {@link #sortCriteria} to order by the {@link KapuaEntity#getCreatedOn()} {@link SortOrder#ASCENDING}. * * @since 1.0.0 */ public AbstractKapuaQuery() { setSortCriteria(new FieldSortCriteria(KapuaEntityAttributes.CREATED_ON, SortOrder.ASCENDING)); }
/** * Create a not equal to predicate * * @param attributeName * @param attributeValue * @return */ public static <T> AttributePredicateImpl<T> attributeIsNotEqualTo(String attributeName, T attributeValue) { return new AttributePredicateImpl<>(attributeName, attributeValue, Operator.NOT_EQUAL); }
/** * Constructor which accepts a not null array of {@link QueryPredicate}s. * * @param predicates the {@link QueryPredicate}s to add. * @throws NullPointerException if the given parameter is {@code null}. * @since 1.0.0 */ public OrPredicateImpl(@NotNull QueryPredicate... predicates) { Objects.requireNonNull(predicates); setPredicates(Lists.newArrayList(predicates)); }
/** * Create an equal to predicate * * @param attributeName * @param attributeValue * @return */ public static <T> AttributePredicateImpl<T> attributeIsEqualTo(String attributeName, T attributeValue) { return new AttributePredicateImpl<>(attributeName, attributeValue); }
/** * Constructor which accepts a not null array of {@link QueryPredicate}s. * * @param predicates the {@link QueryPredicate}s to add. * @throws NullPointerException if the given parameter is {@code null}. * @since 1.0.0 */ public OrPredicateImpl(@NotNull QueryPredicate... predicates) { Objects.requireNonNull(predicates); setPredicates(Lists.newArrayList(predicates)); }