use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class ReportPortalRepositoryImpl method findByFilterWithSorting.
@Override
public List<T> findByFilterWithSorting(Queryable filter, Sort sorting) {
Class<T> entityType = getEntityInformation().getJavaType();
Query query = QueryBuilder.newBuilder().with(filter).with(sorting).build();
return getMongoOperations().find(query, entityType);
}
use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class ShareableRepositoryImpl method findOnlyOwnedEntities.
@SuppressWarnings("unchecked")
@Override
public List<T> findOnlyOwnedEntities(Set<String> ids, String owner) {
if (owner == null) {
return emptyList();
}
Query query = createOwnedEntityQuery(owner);
if (Preconditions.NOT_EMPTY_COLLECTION.test(ids)) {
query.addCriteria(Criteria.where(Shareable.ID).in(ids));
}
Class<T> entityType = getEntityInformation().getJavaType();
return getMongoOperations().find(query, entityType);
}
use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class ShareableRepositoryImpl method findSharedEntities.
@SuppressWarnings("unchecked")
@Override
public Page<T> findSharedEntities(String projectName, List<String> fields, Sort sort, Pageable pageable) {
if (projectName == null || fields == null || sort == null) {
return new PageImpl<>(emptyList(), pageable, 0);
}
Query query = createSharedEntityQuery(projectName).with(sort).with(pageable);
if (Preconditions.NOT_EMPTY_COLLECTION.test(fields)) {
for (String field : fields) {
query.fields().include(field);
}
}
Class<T> entityType = getEntityInformation().getJavaType();
return new PageImpl<>(getMongoOperations().find(query, entityType), pageable, getMongoOperations().count(query, entityType));
}
use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class ShareableRepositoryImpl method findSharedEntitiesByName.
@Override
public Page<T> findSharedEntitiesByName(String projectName, String term, Pageable pageable) {
final String regex = "(?i).*" + Pattern.quote(term.toLowerCase()) + ".*";
Query query = createSharedEntityQuery(projectName).with(pageable);
Criteria name = Criteria.where(ENTITY_NAME_FIELD).regex(regex);
Criteria owner = Criteria.where(ENTITY_OWNER_FIELD).regex(regex);
Criteria description = Criteria.where(ENTITY_DESCRIPTION_FIELD).regex(regex);
query.addCriteria(new Criteria().orOperator(name, owner, description));
Class<T> entityType = getEntityInformation().getJavaType();
List<T> searchResults = getMongoOperations().find(query, entityType);
return new PageImpl<>(searchResults, pageable, getMongoOperations().count(query, entityType));
}
use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class ShareableRepositoryImpl method findNonSharedEntities.
@SuppressWarnings("unchecked")
@Override
public List<T> findNonSharedEntities(String owner) {
if (null == owner || owner.isEmpty()) {
return emptyList();
}
Query query = ShareableRepositoryUtils.createUnsharedEntityQuery(owner);
Class<T> entityType = getEntityInformation().getJavaType();
return getMongoOperations().find(query, entityType);
}
Aggregations