use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class ShareableRepositoryImpl method findAllByFilter.
@Override
public Page<T> findAllByFilter(Filter filter, Pageable pageable, String projectName, String owner) {
if (filter == null || pageable == null || projectName == null || owner == null) {
return new PageImpl<>(emptyList());
}
Query query = QueryBuilder.newBuilder().with(filter).with(pageable).build();
query.addCriteria(getAllEntitiesCriteria(projectName, owner));
return findPage(query, pageable);
}
use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method updateItemsIssues.
@Override
public void updateItemsIssues(Map<String, TestItemIssue> forUpdate) {
Query query = query(where(ID).in(forUpdate.keySet()));
Update update = new Update();
mongoTemplate.stream(query, TestItem.class).forEachRemaining(dbo -> {
String currentId = dbo.getId();
TestItemIssue newValue = forUpdate.get(currentId);
update.set(ISSUE_TYPE, newValue.getIssueType());
update.set(ISSUE_DESCRIPTION, newValue.getIssueDescription());
update.set(ISSUE_TICKET, newValue.getExternalSystemIssues());
update.set(ISSUE_ANALYZED, newValue.isAutoAnalyzed());
mongoTemplate.updateFirst(Query.query(Criteria.where(ID).is(currentId)), update, mongoTemplate.getCollectionName(TestItem.class));
});
}
use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method findForSpecifiedSubType.
@Override
public List<TestItem> findForSpecifiedSubType(List<String> launchesIds, boolean hasChild, StatisticSubType type) {
String issueField = "statistics.issueCounter." + TestItemIssueType.valueOf(type.getTypeRef()).awareStatisticsField() + "." + type.getLocator();
Query query = query(where(LAUNCH_REFERENCE).in(launchesIds)).addCriteria(where(HAS_CHILD).is(hasChild)).addCriteria(where(issueField).exists(true)).with(new Sort(Sort.Direction.ASC, START_TIME));
return mongoTemplate.find(query, TestItem.class);
}
use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class UserPreferenceRepositoryCustomImpl method deleteUnsharedFilters.
@Override
public void deleteUnsharedFilters(String username, String project, String filterId) {
Query query = Query.query(where("userRef").ne(username)).addCriteria(where("projectRef").is(project)).addCriteria(where("launchTabs.filters").is(filterId));
Update update = new Update().pull("launchTabs.filters", filterId);
mongoTemplate.updateMulti(query, update, UserPreference.class);
}
use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class UserRepositoryCustomImpl method findUserPhoto.
@Override
public BinaryData findUserPhoto(String login) {
BinaryData photo = null;
Query q = query(where(User.LOGIN).is(login));
q.fields().include(User.PHOTO_ID);
User user = mongoOperations.findOne(q, User.class);
if (user != null && user.getPhotoId() != null)
photo = dataStorage.fetchData(user.getPhotoId());
if (null == photo) {
// Get default photo avatar (batman)
photo = dataStorage.findByFilename(photoFilename(Constants.NONAME_USER.toString())).get(0);
}
return photo;
}
Aggregations