Example usage for org.springframework.data.mongodb.core.query Query Query

List of usage examples for org.springframework.data.mongodb.core.query Query Query

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.query Query Query.

Prototype

public Query() 

Source Link

Usage

From source file:curly.artifactory.web.ArtifactResourceControllerTests.java

@After
public void tearDown() throws Exception {
    mongoTemplate.findAllAndRemove(new Query(), Artifact.class);
}

From source file:com.traffitruck.service.MongoDAO.java

public List<Alert> getUserAlerts(String username) {
    Query q = new Query().addCriteria(Criteria.where("username").is(username));
    return mongoTemplate.find(q, Alert.class);
}

From source file:com.monkeyk.sos.infrastructure.mongo.UserRepositoryMongo.java

@Override
public List<User> findUsersByUsername(String username) {
    Query query = new Query();
    if (StringUtils.isNotEmpty(username)) {
        query.addCriteria(Criteria.where(username).regex("/*" + username + "/*"));
    }//from   www  . j  ava 2  s  .co  m
    return mongoTemplate().find(query, User.class);
}

From source file:de.steilerdev.myVerein.server.model.GridFSRepository.java

/**
 * This function gathers the current club logo. If several files or none matches the defined club logo filename, all of them get deleted.
 * @return The current club logo, or null if there is none or more than one.
 *//*www . ja  v a2 s .c  om*/
public GridFSDBFile findClubLogo() {
    List<GridFSDBFile> clubLogoFiles;
    try {
        clubLogoFiles = gridFS.find(new Query().addCriteria(Criteria.where("filename").is(clubLogoFileName)));
    } catch (MongoTimeoutException e) {
        logger.warn("Timeout while trying to find club logo");
        return null;
    }

    if (clubLogoFiles == null || clubLogoFiles.isEmpty()) {
        logger.warn("Unable to find any club logo");
        return null;
    } else if (clubLogoFiles.size() > 1) {
        logger.warn("Multiple files matching club logo name, deleting all");
        deleteCurrentClubLogo();
        return null;
    } else {
        return clubLogoFiles.get(0);
    }
}

From source file:curly.artifactory.web.ArtifactResourceControllerTests.java

@Test
public void testArtifactResources() throws Exception {
    mongoTemplate.findAllAndRemove(new Query(), Artifact.class);
    mockMvc.perform(asyncDispatch(mockMvc.perform(get("/artifacts")).andExpect(request().asyncStarted())
            .andExpect(request().asyncResult(instanceOf(ResponseEntity.class))).andReturn()));

}

From source file:example.springdata.mongodb.aggregation.SpringBooksIntegrationTests.java

@SuppressWarnings("unchecked")
@Before//w w w . j av a2s .co m
public void before() throws Exception {

    if (operations.count(new Query(), "books") == 0) {

        File file = new ClassPathResource("books.json").getFile();
        String content = Files.contentOf(file, StandardCharsets.UTF_8);
        List<Object> books = (List<Object>) JSON.parse(content);

        operations.insert(books, "books");
    }
}

From source file:com.card.loop.xyz.dao.UserDAO.java

public boolean blockUser(User user) throws UnknownHostException {
    boolean ok = false;
    Query query = new Query();
    query.addCriteria(where("_id").is(user.getId()));
    User obj = this.user.findOne(query, User.class);
    obj.setId(user.getId());/*from   w w  w  .  j av  a2 s.  c o  m*/
    obj.setBlocked(true);
    this.user.save(obj);
    return ok;
}

From source file:jp.co.ctc_g.rack.connector.process.WooreaProcessRepository.java

@Override
public void updateMetadata(String groupId, String pid, Map<String, String> map) {

    for (Map.Entry<String, String> e : map.entrySet()) {
        operations.updateFirst(//from  w  ww  .ja va2s  . c  o  m
                new Query().addCriteria(Criteria.where("groupId").is(groupId))
                        .addCriteria(Criteria.where("metadata.pid").is(pid)),
                Update.update("metadata." + e.getKey(), e.getValue()), WooreaProcess.class);
    }
}

From source file:com.comcast.video.dawg.service.park.MongoParkService.java

/**
 * {@inheritDoc}/*from w  w w  .j  av a 2s. c o m*/
 */
@Override
public List<DawgModel> getModels() {
    return template.find(new Query(), DawgModel.class, DawgModel.class.getSimpleName());
}

From source file:st.malike.service.mongo.DemographicSummaryService.java

public DemographicSummary getDemographicSummaryByEventAndDateForMin(String event, String dateCreated) {
    try {//from   ww w . ja  v  a2s  .  c o m
        Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:00").parse(dateCreated);
        Date endDate = new DateTime(startDate).plusMinutes(1).toDate();
        Query query = new Query();
        query.addCriteria(Criteria.where("event").is(event));
        query.addCriteria(Criteria.where("dateCreated").gte(startDate).lte(endDate));
        return mongoTemplate.findOne(query, DemographicSummary.class, "demographic_summary");
    } catch (ParseException ex) {
        Logger.getLogger(DemographicSummaryService.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}