List of usage examples for org.springframework.data.mongodb.core.query Query Query
public Query(CriteriaDefinition criteriaDefinition)
From source file:com.sangupta.jerry.mongodb.MongoTemplateBasicOperations.java
/** * //from ww w .jav a 2 s.c o m */ @Override public List<T> getForIdentifiers(X... ids) { if (AssertUtils.isEmpty(ids)) { return null; } if (this.idKey == null) { fetchMappingContextAndConversionService(); } Query query = new Query(Criteria.where(this.idKey).in(ids)); return this.mongoTemplate.find(query, this.entityClass); }
From source file:it.f2informatica.mongodb.repositories.impl.ConsultantRepositoryImpl.java
@Override public int removeExperience(String consultantId, String experienceId) { Query query = new Query( where(ID).is(consultantId).and(EXPERIENCES + "." + Fields.UNDERSCORE_ID).is(experienceId)); Update update = new Update().pull(EXPERIENCES, findExperience(consultantId, experienceId)); return updateConsultant(query, update).getN(); }
From source file:demo.SpringTest.java
@Test public void testOKBecauseOfNoCyclicRelationBetweenDocumentsLazyDbRefRelated() { LazyFrom one = new LazyFrom("one"); LazyTo two = new LazyTo("two"); template.save(one);// w w w . j av a 2s .c o m template.save(two); one.refToTwo = two; template.save(one); LazyFrom foundOne = template.findOne(Query.query(Criteria.where("id").is(one.id)), LazyFrom.class); Assert.assertThat(foundOne.refToTwo, Matchers.notNullValue()); Assert.assertThat(foundOne.refToTwo, IsInstanceOf.instanceOf(LazyTo.class)); Assert.assertThat(foundOne.refToTwo.id, Matchers.is("two")); Assert.assertThat(foundOne.refToTwo.refToOne, Matchers.nullValue()); LazyTo foundTwo = template.findOne(Query.query(Criteria.where("id").is(two.id)), LazyTo.class); Assert.assertThat(foundTwo.refToOne, Matchers.nullValue()); }
From source file:org.maodian.flyingcat.im.repository.AccountRepositoryImpl.java
@Override public void updateContact(String uid, SimpleUser su) { Query query = Query.query(Criteria.where(Account.USERNAME).is(uid).and("cont.uid").is(su.getUsername())); Update update = new Update().set("cont.$.nick", su.getNickname()).set("cont.$.pin", su.isPendingIn()) .set("cont.$.pout", su.isPendingOut()).set("cont.$.stat", su.getSubState().name()); getMongoTemplate().updateFirst(query, update, Account.class); }
From source file:uk.gov.nationalarchives.discovery.taxonomy.common.service.impl.IAViewServiceImpl.java
public Long countUntaggedDocumentsBySeriesMongo(String seriesIaid) { Query query = Query.query(Criteria.where("series").is(seriesIaid).and("categories").size(0)); query.with(new Sort(Sort.Direction.ASC, "_id")); return mongoTemplate.count(query, MongoInformationAssetView.class); }
From source file:com.epam.ta.reportportal.database.dao.ProjectRepositoryCustomImpl.java
@Override public Map<String, ProjectRole> findProjectRoles(String login) { final Query q = Query.query(userExists(login)); q.fields().include("users"); return mongoTemplate.find(q, Project.class).stream() .collect(Collectors.toMap(Project::getName, p -> p.getUsers().get(login).getProjectRole())); }
From source file:org.starfishrespect.myconsumption.server.business.repositories.repositoriesimpl.ValuesRepositoryImpl.java
@Override public List<SensorDataset> getSensor(Date startTime, Date endTime) throws DaoException { Query timeQuery = new Query(new Criteria().andOperator(Criteria.where("timestamp").gte(startTime), Criteria.where("timestamp").lte(endTime))); timeQuery.with(new Sort(Sort.Direction.ASC, "timestamp")); return mongoOperation.find(timeQuery, SensorDataset.class, collectionName); }
From source file:eu.trentorise.smartcampus.communicatorservice.manager.UserAccountManager.java
/** * retrieves all the {@link UserAccount} for a given appId * // w w w .j av a2 s . co m * @param uid * id of the owner of user storage accounts * @param appName * * @return a list of UserAccount of the given user id and appName */ public List<UserAccount> findByAppName(String appId) { Criteria criteria = new Criteria(); criteria = criteria.and("appId").is(appId); return db.find(Query.query(criteria), UserAccount.class); }
From source file:com.telefonica.euro_iaas.sdc.puppetwrapper.services.impl.CatalogManagerMongoImpl.java
public void removeNodesByGroupName(String groupName) { Query searchNodeQuery = new Query(Criteria.where("groupName").is(groupName)); mongoTemplate.remove(searchNodeQuery, Node.class); }
From source file:io.cos.cas.services.OpenScienceFrameworkServiceRegistryDao.java
@Override public final synchronized List<RegisteredService> load() { List<OAuth> oAuthServices = this.mongoTemplate.find(new Query(Criteria.where("active").is(true)), OAuth.class); ReturnAllowedAttributeReleasePolicy attributeReleasePolicy = new ReturnAllowedAttributeReleasePolicy(); ArrayList<String> allowedAttributes = new ArrayList<>(); allowedAttributes.add("username"); allowedAttributes.add("givenName"); allowedAttributes.add("familyName"); attributeReleasePolicy.setAllowedAttributes(allowedAttributes); final Map<Long, RegisteredService> temp = new ConcurrentHashMap<>(); for (final OAuth oAuthService : oAuthServices) { OAuthRegisteredService service = new OAuthRegisteredService(); service.setId(new BigInteger(oAuthService.getId(), 16).longValue()); service.setName(oAuthService.getName()); service.setDescription(oAuthService.getDescription()); service.setServiceId(oAuthService.getCallbackUrl()); service.setBypassApprovalPrompt(false); service.setClientId(oAuthService.getClientId()); service.setClientSecret(oAuthService.getClientSecret()); service.setAttributeReleasePolicy(attributeReleasePolicy); temp.put(service.getId(), service); }//from w w w .ja v a 2 s .co m this.serviceMap = temp; return new ArrayList<>(this.serviceMap.values()); }