Package com.mysema.query.types.expr

Examples of com.mysema.query.types.expr.BooleanExpression


     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    protected Predicate getPredicate(PaginationConfiguration config) {

        PathBuilder<T> entityPath = new PathBuilder(entityClass, getAliasName(entityClass));
        BooleanExpression predicate = null;

        Map<String, Object> filters = config.getFilters();
        if (filters != null) {
          // first we process nonstandard filters
            List<String> filtersToRemove = new ArrayList<String>();
View Full Code Here


     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    protected Predicate getPredicate(PaginationConfiguration config) {

        PathBuilder<T> entityPath = new PathBuilder(entityClass, getAliasName(entityClass));
        BooleanExpression predicate = null;

        Map<String, Object> filters = config.getFilters();
        if (filters != null) {
          // first we process nonstandard filters
            List<String> filtersToRemove = new ArrayList<String>();
View Full Code Here

        applicationOrExpressions.add(application.ownedGroup.in(getExplicitGroupsForUser(user).list(group))); /*All apps which belong to a group which the user belongs to*/
        applicationOrExpressions.add(application.in(getApplicationsWithVersionsInOrgPublishStateForUser(user).list(application))); /*All apps which have versions published to organization for which user belongs to*/
        applicationOrExpressions.add(application.ownedGroup.in(getAdminOrganizationGroupsForUser(user).list(group))); /*All apps for organization admins which belong to groups of their organizations*/
        applicationOrExpressions.add(application.in(getGuestApplicationsForUser(user).list(application))); /*All apps which have a version with guest access to a group that a user belongs to*/

        BooleanExpression applicationOrExpression = BooleanExpression.anyOf(applicationOrExpressions.toArray(new BooleanExpression[applicationOrExpressions.size()]));

        // Applications with correct ApplicationTypes
        BooleanExpression applicationTypesExpression = null;
        if (applicationTypes != null && applicationTypes.length > 0) {
            applicationTypesExpression = application.applicationType.in(applicationTypes);
        }

        // Application Versions are not empty
        BooleanExpression applicationVersionsNotEmptyExpression = application.applicationVersions.isNotEmpty();

        // Application Versions with downloadable AppState
        List<AppState> downloadableAppStates = AppState.getAllDownloadable();
        BooleanExpression applicationVersionsDownloadableAppStateExpression = getApplicationVersionAppStateExpression(downloadableAppStates.toArray(new AppState[downloadableAppStates.size()]));

        // Applications with Versions in downloadable AppState
        BooleanExpression downloadableApplicationVersionsExpression = application.in(subQuery().from(applicationVersion).where(applicationVersionsDownloadableAppStateExpression).list(applicationVersion.application));

        // Both Application Versions are not empty and Application contains at least one version not disabled
        BooleanExpression applicationVersionsDownloadableExpression = BooleanExpression.allOf(applicationVersionsNotEmptyExpression, downloadableApplicationVersionsExpression);

        // Application belongs to Organization which is set as Active Organization on User
        BooleanExpression activeOrganizationBooleanExpression = getActiveOrganizationBooleanExpression(organization, user);
        BooleanExpression applicationActiveOrg = null;
        if(activeOrganizationBooleanExpression != null) {
            applicationActiveOrg = application.in(
                    subQuery().from(application)
                            .join(application.ownedGroup, group)
                            .join(group.organization, organization)
View Full Code Here

        List<AppState> downloadableAppStates = AppState.getAllDownloadable();

        JPASubQuery availableApplicationsForUser = subQuery().from(application).where(getApplicationForUserBooleanExpression(user));

        // ApplicationVersion belongs to a group which a users has access
        BooleanExpression applicationVersionOwnedGroup = applicationVersion.in(subQuery().from(applicationVersion).join(applicationVersion.application, application).where(application.ownedGroup.in(getAllGroupsForUser(user).list(group))).list(applicationVersion));

        // ApplicationVersion is shared to a Guest Group which a user belongs
        BooleanExpression applicationVersionGuestGroup = applicationVersion.in(subQuery().from(applicationVersion).join(applicationVersion.guestGroups, group).where(group.in(getAllGroupsForUser(user).list(group))).list(applicationVersion));

        BooleanExpression applicationVersionOrgPublish = applicationVersion.appState.eq(AppState.ORGANIZATION_PUBLISH)
                .and(applicationVersion.in(subQuery().from(applicationVersion)
                        .join(applicationVersion.application, application)
                        .join(application.ownedGroup, group)
                        .join(group.organization, organization)
                        .where(organization.in(getExplicitOrganizationsForUser(user).list(organization))).list(applicationVersion)));
View Full Code Here

        for (String email : emails) {
            email = StringUtils.trimAllWhitespace(email.toLowerCase());
        }

        // Boolean expression for organization
        BooleanExpression domainBooleanExpression = invitation.domain.id.in(domainIds);

        ListSubQuery<String> emailListSubQuery = subQuery().from(invitation)
                .where(invitation.email.toLowerCase().in(emails)
                        .and(domainBooleanExpression)
                ).groupBy(invitation.email).list(invitation.email);
View Full Code Here

  }

  @Test
  public void executesPredicatesCorrectly() throws Exception {

    BooleanExpression isCalledDave = user.firstname.eq("Dave");
    BooleanExpression isBeauford = user.lastname.eq("Beauford");

    List<User> result = repository.findAll(isCalledDave.or(isBeauford));

    assertThat(result.size(), is(2));
    assertThat(result, hasItems(carter, dave));
View Full Code Here

  @Test
  public void executesStringBasedPredicatesCorrectly() throws Exception {

    PathBuilder<User> builder = new PathBuilderFactory().create(User.class);

    BooleanExpression isCalledDave = builder.getString("firstname").eq("Dave");
    BooleanExpression isBeauford = builder.getString("lastname").eq("Beauford");

    List<User> result = repository.findAll(isCalledDave.or(isBeauford));

    assertThat(result.size(), is(2));
    assertThat(result, hasItems(carter, dave));
View Full Code Here

  }

  @Override
  public Page<Operation> findNonCardByAccountIdAndYearMonth(Integer accountId, YearMonth yearMonth, Pageable pageable) {

    BooleanExpression predicate = operation.type.id.ne(OperationType.CARD).and(operation.account.id.eq(accountId));
    predicate = addOperationYearMonthExpression(predicate, operation, yearMonth);

    JPQLQuery countQuery = from(operation).where(predicate);
    JPQLQuery query = applyPagination(from(operation).where(predicate).orderBy(operation.date.desc()), pageable);
View Full Code Here

  }

  @Override
  public List<Operation> sumResolvedAmountByAccountIdAndYearMonthAndSignGroupByCard(Integer accountId, YearMonth yearMonth, OperationSign sign) {

    BooleanExpression predicate = operation.type.id.eq(OperationType.CARD).and(operation.status.id.eq(OperationStatus.RESOLVED)).and(operation.account.id.eq(accountId))
        .and(buildOperationSignPredicate(sign));
    predicate = addOperationYearMonthExpression(predicate, operation, yearMonth);

    List<Tuple> tuples = from(operation).where(predicate).groupBy(operation.card.id).list(new QTuple(operation.amount.sum(), operation.card.id));
View Full Code Here

  }

  @Override
  public BigDecimal sumResolvedAmountByCardAndYearMonth(Card card, YearMonth yearMonth) {

    BooleanExpression predicate = operation.type.id.eq(OperationType.CARD).and(operation.status.id.eq(OperationStatus.RESOLVED)).and(operation.card.eq(card));
    predicate = addOperationYearMonthExpression(predicate, operation, yearMonth);

    return from(operation).where(predicate).uniqueResult(operation.amount.sum());
  }
View Full Code Here

TOP

Related Classes of com.mysema.query.types.expr.BooleanExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.