@Override public void removeRequirement(String id, String rid) { mongoTemplate.findAndModify( new Query(Criteria.where("_id").is(id)), new Update().pull("requirements", rid).inc("count", -1), DocumentDAO.class); }
@Override public void addTag(String id, TagDAO tag) { mongoTemplate.findAndModify( new Query(Criteria.where("_id").is(id)), new Update().addToSet("tag", tag), DocumentDAO.class); }
@Override public void remove(DocumentDAO document) { mongoTemplate.findAndModify( new Query(Criteria.where("position").gt(document.getPosition())), new Update().inc("position", -1), ProjectDAO.class); mongoTemplate.remove(document); }
/** * updateSetValue. * * @param assetID a {@link java.lang.String} object. * @param value a {@link java.util.Map} object. * @return a {@link com.digitalbridge.domain.Address} object. */ @Secured({"ROLE_USER"}) public Address updateSetValue(String assetID, Map<String, Object> value) { LOGGER.debug("received update request for assetID {}", assetID); String addressID = assetWrapperRepository.findOne(assetID).getAddress().getId(); Query query = new Query(Criteria.where("_id").is(addressID)); Update update = new Update(); for (Entry<String, Object> entry : value.entrySet()) { update.set(entry.getKey(), entry.getValue()); } Address result = mongoTemplate.findAndModify( query, update, new FindAndModifyOptions().returnNew(true).upsert(false), Address.class); LOGGER.debug("Result : {}", result); Assert.isTrue(result.getId().equalsIgnoreCase(addressID), "Address Matched"); return result; }