List of usage examples for org.springframework.data.mongodb.core.query Criteria where
public static Criteria where(String key)
From source file:it.smartcommunitylab.climb.contextstore.controller.ChildController.java
@RequestMapping(value = "/api/image/upload/png/{ownerId}/{objectId}", method = RequestMethod.POST) public @ResponseBody String uploadImage(@RequestParam("file") MultipartFile file, @PathVariable String ownerId, @PathVariable String objectId, HttpServletRequest request) throws Exception { Criteria criteria = Criteria.where("objectId").is(objectId); Child child = storage.findOneData(Child.class, criteria, ownerId); if (!validateAuthorizationByExp(ownerId, child.getInstituteId(), child.getSchoolId(), null, "ALL", request)) {/*from w w w . j a va2 s.c om*/ throw new UnauthorizedException("Unauthorized Exception: token not valid"); } String name = objectId + ".png"; if (logger.isInfoEnabled()) { logger.info("uploadImage:" + name); } if (!file.isEmpty()) { BufferedOutputStream stream = new BufferedOutputStream( new FileOutputStream(new File(imageUploadDir + "/" + name))); FileCopyUtils.copy(file.getInputStream(), stream); stream.close(); } return "{\"status\":\"OK\"}"; }
From source file:net.cit.tetrad.utility.QueryUtils.java
public static Query setAuthority(int authority) { Query query = new Query(Criteria.where("authority").is(authority)); return query; }
From source file:br.com.ezequieljuliano.argos.persistence.LoggerDAO.java
public List<LoggerMarkerCount> groupByMarkerUsingUserAndOccurrence(User user, Date startDate, Date endDate) { Criteria criteria = Criteria.where("entity._id").in(findEntityObjectIdsByUser(user)).andOperator( Criteria.where("occurrence").lte(endDate), Criteria.where("occurrence").gte(startDate)); GroupByResults<LoggerMarkerCount> results = getMongoOperations().group(criteria, Logger.COLLECTION_NAME, GroupBy.key("marker").initialDocument("{ count: 0 }") .reduceFunction("function(doc, prev) { prev.count += 1 }"), LoggerMarkerCount.class); List<LoggerMarkerCount> counts = new ArrayList<LoggerMarkerCount>(); for (LoggerMarkerCount marker : results) { counts.add(marker);/*from w w w . ja va 2 s . c o m*/ } return counts; }
From source file:com.appleframework.monitor.model.Project.java
private Query fetchTimeQuery() { return new Query(Criteria.where(Constants.TIME_STAMP_FIELD_NAME).gt(timeRange.getStart().getTime())); }
From source file:com.mobileman.moments.core.security.UserSecurityService.java
public User getUserDetail(String idToken) { User user = this.mongoTemplate.findOne(new Query(Criteria.where("id").is(idToken)), User.class); if (user == null) { throw new UsernameNotFoundException("User account with idToken " + idToken + " not found"); }/* w w w . j ava2 s .c o m*/ return user; }
From source file:com.handu.open.dubbo.monitor.DubboMonitorService.java
/** * ?/*from w w w . j a v a 2 s . com*/ * * @param dubboInvoke */ public List<DubboInvoke> countDubboInvoke(DubboInvoke dubboInvoke) { if (StringUtils.isEmpty(dubboInvoke.getService())) { logger.error("???"); throw new RuntimeException("???"); } TypedAggregation<DubboInvoke> aggregation = Aggregation.newAggregation(DubboInvoke.class, Aggregation.match(Criteria.where("service").is(dubboInvoke.getService()).and("method") .is(dubboInvoke.getMethod()).and("type").is(dubboInvoke.getType()).and("invokeDate") .gte(dubboInvoke.getInvokeDateFrom()).lte(dubboInvoke.getInvokeDateTo())), Aggregation .project("service", "method", "type", "success", "failure", "elapsed", "maxElapsed", "maxConcurrent", "invokeTime") .andExpression("(invokeTime / " + dubboInvoke.getTimeParticle() + ") * " + dubboInvoke.getTimeParticle()) .as("invokeTime"), Aggregation.group("service", "method", "type", "invokeTime").sum("success").as("success") .sum("failure").as("failure").sum("elapsed").as("elapsed").max("maxElapsed") .as("maxElapsed").min("maxConcurrent").as("maxConcurrent"), Aggregation.sort(Sort.Direction.ASC, "invokeTime")); AggregationResults<DubboInvoke> result = mongoTemplate.aggregate(aggregation, "dubboInvoke", DubboInvoke.class); return result.getMappedResults(); }
From source file:com.skymobi.monitor.model.Project.java
public List<MetricValue> findMetricData(String metricName) { Query query = fetchTimeQuery(); query.addCriteria(Criteria.where("name").is(metricName)); query.sort().on(Constants.TIME_STAMP_FIELD_NAME, Order.ASCENDING); logger.debug("find metric value by {} ,mongo={}", query.getQueryObject(), mongoUri); return fetchMongoTemplate().find(query, MetricValue.class, metricCollection); }
From source file:com.gongpingjia.carplay.service.impl.ActivityServiceImpl.java
private void saveUserActivity(String userId, Activity activity, Long current) { Activity oldActivity = activityDao.findOne(Query .query(Criteria.where("userId").is(userId).and("deleteFlag").is(false).and("majorType") .is(activity.getMajorType()).and("type").is(activity.getType())) .with(new Sort(new Sort.Order(Sort.Direction.DESC, "createTime")))); if (oldActivity == null) { LOG.debug("Old activity is not exist, create a new"); //??//from w ww . j a va 2 s.c o m activity.setActivityId(null); //ID activity.setUserId(userId); List<String> memberIds = new ArrayList<String>(1); //? memberIds.add(userId); activity.setMembers(memberIds); activity.setCreateTime(current); activity.setDeleteFlag(false); activityDao.save(activity); } else { LOG.debug("Old activity is exist, update activity info, activityId:{}", activity.getActivityId()); //?? Update update = new Update(); update.set("pay", activity.getPay()); update.set("destPoint", activity.getDestPoint()); update.set("destination", activity.getDestination()); update.set("estabPoint", activity.getEstabPoint()); update.set("establish", activity.getEstablish()); update.set("transfer", activity.isTransfer()); update.set("createTime", current); update.set("applyIds", new ArrayList<>(0)); update.set("cover", activity.getCover()); activityDao.update(Query.query(Criteria.where("activityId").is(oldActivity.getActivityId())), update); activity.setActivityId(oldActivity.getActivityId()); } }
From source file:net.cit.tetrad.utility.QueryUtils.java
public static Query setType(Query query, String type) { query.addCriteria(Criteria.where(CLRITICAL_TYPE).is(type)); return query; }