Search in sources :

Example 16 with JPAQuery

use of com.querydsl.jpa.impl.JPAQuery in project kylo by Teradata.

the class OpsFeedManagerFeedProvider method findFeedsWithFilter.

public List<OpsManagerFeed> findFeedsWithFilter(String filter) {
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    BooleanBuilder where = GenericQueryDslFilter.buildFilter(feed, filter);
    JPAQuery query = factory.select(feed).from(feed).where(where);
    return query.fetch();
}
Also used : BooleanBuilder(com.querydsl.core.BooleanBuilder) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 17 with JPAQuery

use of com.querydsl.jpa.impl.JPAQuery in project kylo by Teradata.

the class NifiFeedProcessorStatisticsProvider method findFeedProcessorStatisticsByProcessorId.

@Override
public List<? extends JpaNifiFeedProcessorStats> findFeedProcessorStatisticsByProcessorId(String feedName, DateTime start, DateTime end) {
    QJpaNifiFeedProcessorStats stats = QJpaNifiFeedProcessorStats.jpaNifiFeedProcessorStats;
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    JPAQuery query = factory.select(Projections.bean(JpaNifiFeedProcessorStats.class, stats.feedName, stats.processorId, stats.processorName, stats.bytesIn.sum().as("bytesIn"), stats.bytesOut.sum().as("bytesOut"), stats.duration.sum().as("duration"), stats.jobsStarted.sum().as("jobsStarted"), stats.jobsFinished.sum().as("jobsFinished"), stats.jobDuration.sum().as("jobDuration"), stats.flowFilesStarted.sum().as("flowFilesStarted"), stats.flowFilesFinished.sum().as("flowFilesFinished"), stats.totalCount.sum().as("totalCount"), stats.maxEventTime.max().as("maxEventTime"), stats.minEventTime.min().as("minEventTime"), stats.jobsFailed.sum().as("jobsFailed"), stats.failedCount.sum().as("failedCount"), stats.count().as("resultSetCount"))).from(stats).innerJoin(feed).on(feed.name.eq(stats.feedName)).where(stats.feedName.eq(feedName).and(FeedAclIndexQueryAugmentor.generateExistsExpression(feed.id, accessController.isEntityAccessControlled())).and(stats.minEventTime.goe(start).and(stats.maxEventTime.loe(end)))).groupBy(stats.feedName, stats.processorId, stats.processorName).orderBy(stats.processorName.asc());
    return (List<JpaNifiFeedProcessorStats>) query.fetch();
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) List(java.util.List) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 18 with JPAQuery

use of com.querydsl.jpa.impl.JPAQuery in project Settler by EmhyrVarEmreis.

the class TransactionService method getMostUsedUsers.

public ResponseEntity<List<UserListDTO>> getMostUsedUsers(Long count) {
    QUser user = QUser.user;
    QTransaction transaction = QTransaction.transaction;
    QRedistribution redistribution = QRedistribution.redistribution;
    List<User> userList = new JPAQuery<>(entityManager).from(user).select(user).where(user.id.in(JPAExpressions.selectFrom(transaction).select(redistribution.id.user.id).leftJoin(redistribution).on(redistribution.id.parent.id.eq(transaction.id)).where(transaction.creator.id.eq(Security.currentUser().getId())).groupBy(redistribution.id.user.id).orderBy(redistribution.id.user.id.count().desc()).limit(count))).fetch();
    Type listType = new TypeToken<List<UserListDTO>>() {
    }.getType();
    List<UserListDTO> userListDTOList = getModelMapper().map(userList, listType);
    return new ResponseEntity<>(userListDTOList, HttpStatus.OK);
}
Also used : TransactionType(pl.morecraft.dev.settler.domain.dictionaries.TransactionType) OperationType(pl.morecraft.dev.settler.domain.dictionaries.OperationType) RedistributionType(pl.morecraft.dev.settler.domain.dictionaries.RedistributionType) Type(java.lang.reflect.Type) ResponseEntity(org.springframework.http.ResponseEntity) UserListDTO(pl.morecraft.dev.settler.web.dto.UserListDTO) ArrayList(java.util.ArrayList) List(java.util.List) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 19 with JPAQuery

use of com.querydsl.jpa.impl.JPAQuery in project Settler by EmhyrVarEmreis.

the class UserService method getUsersWithValue.

public ResponseEntity<List<UserWithValueDTO>> getUsersWithValue(Long userId) {
    getPermissionManager().authorizeGlobalAdmin();
    if (Objects.isNull(userId) || userId < 0) {
        userId = Security.currentUser().getId();
    }
    QUser user = QUser.user;
    QTransaction transaction = QTransaction.transaction;
    List<Tuple> fetch = new JPAQuery<>(entityManager).from(user, transaction).select(user, transaction.value.sum()).where(transaction.creator.id.eq(userId)).where(user.id.ne(userId)).where(transaction.owners.any().id.user.eq(user).or(transaction.contractors.any().id.user.eq(user))).groupBy(user.id, user.firstName, user.lastName, user.email, user.created, user.avatar, user.login, user.accountExpireDate).orderBy(transaction.value.sum().desc()).fetch();
    ModelMapper preparedModelMapper = getModelMapper();
    List<UserWithValueDTO> userWithValueDTOList = new ArrayList<>(fetch.size());
    for (Tuple tuple : fetch) {
        User u = tuple.get(user);
        Double d = tuple.get(transaction.value.sum());
        if (Objects.nonNull(u)) {
            userWithValueDTOList.add(new UserWithValueDTO(userId, preparedModelMapper.map(u, String.class), d));
        }
    }
    return new ResponseEntity<>(userWithValueDTOList, HttpStatus.OK);
}
Also used : QUser(pl.morecraft.dev.settler.domain.QUser) QTransaction(pl.morecraft.dev.settler.domain.QTransaction) ResponseEntity(org.springframework.http.ResponseEntity) User(pl.morecraft.dev.settler.domain.User) QUser(pl.morecraft.dev.settler.domain.QUser) ArrayList(java.util.ArrayList) JPAQuery(com.querydsl.jpa.impl.JPAQuery) Tuple(com.querydsl.core.Tuple) ModelMapper(org.modelmapper.ModelMapper)

Example 20 with JPAQuery

use of com.querydsl.jpa.impl.JPAQuery in project jeeshop by remibantos.

the class CatalogItemFinder method countAll.

public Long countAll(EntityPath<? extends CatalogItem> entityPath) {
    QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
    JPAQuery query = new JPAQueryFactory(entityManager).selectFrom(qCatalogItem);
    return query.fetchCount();
}
Also used : JPAQuery(com.querydsl.jpa.impl.JPAQuery) JPAQueryFactory(com.querydsl.jpa.impl.JPAQueryFactory)

Aggregations

JPAQuery (com.querydsl.jpa.impl.JPAQuery)24 QJpaOpsManagerFeed (com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed)9 List (java.util.List)9 BooleanBuilder (com.querydsl.core.BooleanBuilder)7 ArrayList (java.util.ArrayList)6 Person (org.baeldung.entity.Person)5 QPerson (org.baeldung.entity.QPerson)5 Predicate (com.querydsl.core.types.Predicate)4 JPAQueryFactory (com.querydsl.jpa.impl.JPAQueryFactory)4 JPQLQuery (com.querydsl.jpa.JPQLQuery)3 Stopwatch (com.google.common.base.Stopwatch)2 ConstructorExpression (com.querydsl.core.types.ConstructorExpression)2 Expression (com.querydsl.core.types.Expression)2 Projections (com.querydsl.core.types.Projections)2 JPAExpressions (com.querydsl.jpa.JPAExpressions)2 DateTimeUtil (com.thinkbiganalytics.DateTimeUtil)2 Alert (com.thinkbiganalytics.alerts.api.Alert)2 AlertProvider (com.thinkbiganalytics.alerts.api.AlertProvider)2 AlertManager (com.thinkbiganalytics.alerts.spi.AlertManager)2 DefaultAlertChangeEventContent (com.thinkbiganalytics.alerts.spi.DefaultAlertChangeEventContent)2