本文整理汇总了Java中org.springframework.data.mongodb.core.query.Update.update方法的典型用法代码示例。如果您正苦于以下问题:Java Update.update方法的具体用法?Java Update.update怎么用?Java Update.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.mongodb.core.query.Update
的用法示例。
在下文中一共展示了Update.update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreloadFiles
import org.springframework.data.mongodb.core.query.Update; //导入方法依赖的package包/类
@Override
public Map<String, List<String>> getPreloadFiles() {
NeutralQuery preloadReadyTenantQuery = new NeutralQuery().addCriteria(
new NeutralCriteria(STATUS_FIELD, "=", "ready")).setIncludeFields(
Arrays.asList(LANDING_ZONE + "." + PRELOAD_DATA, LANDING_ZONE_PATH, TENANT_ID));
Update update = Update.update(ALL_STATUS_FIELDS, "started");
Map<String, List<String>> fileMap = new HashMap<String, List<String>>();
Entity tenant;
while ((tenant = entityRepository.findAndUpdate(TENANT_COLLECTION, preloadReadyTenantQuery, update)) != null) {
LOG.info("Found new tenant to preload! [" + tenant.getBody().get(TENANT_ID) + "]");
List<Map<String, Object>> landingZones = (List<Map<String, Object>>) tenant.getBody().get(LANDING_ZONE);
for (Map<String, Object> landingZone : landingZones) {
List<String> files = new ArrayList<String>();
Map<String, Object> preloadData = (Map<String, Object>) landingZone.get(PRELOAD_DATA);
if (preloadData != null) {
files.addAll((Collection<? extends String>) preloadData.get(PRELOAD_FILES));
fileMap.put((String) landingZone.get(PATH), files);
}
}
}
return fileMap;
}
示例2: getUpdater
import org.springframework.data.mongodb.core.query.Update; //导入方法依赖的package包/类
private Update getUpdater(Map<String, Object> setMap) {
Update updater = null;
for (String key : setMap.keySet()) {
Object obj = setMap.get(key);// 得到每个key对用value的值
if (updater == null) {
updater = Update.update(key, obj);
} else {
updater = updater.set(key, obj);
}
}
return updater;
}
示例3: sendMsg
import org.springframework.data.mongodb.core.query.Update; //导入方法依赖的package包/类
/**
*
* @Description:发送消息封装
* @param pd
* @return
* @return PageData
* @throws
*/
private PageData sendMsg(PageData pd){
String titleId=pd.getString("TITLE_ID");
if(StringUtils.isNotBlank(titleId)&&StringUtils.isNotBlank(pd.getString("CONTENT"))){
String messageType=pd.getString("MESSAGETYPE");
if(StringUtils.isBlank(messageType)){
messageType="1";
pd.put("MESSAGETYPE",messageType);
}
//将title的有效期延迟十分钟
String redisKey=String.join("_",customerCounter,titleId);
if(redisTemplate.hasKey(redisKey)){
if("1".equals(messageType)){
redisTemplate.opsForValue().set(redisKey, redisTemplate.opsForValue().get(redisKey), titleIdTimeOut, TimeUnit.SECONDS);
Criteria criteria = Criteria.where("TITLE_ID").is(pd.getString("TITLE_ID"));
Query query = new Query(criteria);
Update update = Update.update("CHANGE_TIME", new Date());
mongoTemplate.updateFirst(query, update, "IM_TITLE");
}
}else{
return WebResult.requestFailed(401,"回话已结束",null);
}
this.savePage(pd);
pd.put("CONTENT_ID", UuidUtil.get32UUID());
mongoTemplate.insert(pd, "IM_CONTENT");
return WebResult.requestSuccess();
}else{
return WebResult.requestFailed(504,"参数不正确",null);
}
}
示例4: heartbeatAndUpdateCustomAttrs
import org.springframework.data.mongodb.core.query.Update; //导入方法依赖的package包/类
@Override
public Optional<T> heartbeatAndUpdateCustomAttrs(T item, Map<String, Object> attrs) {
if (item.getId() == null
|| item.getHeartbeat() == null
|| item.getStatus() == null) {
return Optional.empty();
}
Criteria criteria =
Criteria.where("_id").is(new ObjectId(item.getId()))
.and("status").is(OkraStatus.PROCESSING)
.and("heartbeat").is(item.getHeartbeat());
Query query = Query.query(criteria);
Update update = Update.update("heartbeat", LocalDateTime.now());
if (attrs != null && !attrs.isEmpty()) {
attrs.forEach(update::set);
}
FindAndModifyOptions opts = new FindAndModifyOptions()
.returnNew(true);
LOGGER.info("Querying for schedules using query: {}", query);
return Optional.ofNullable(mongoTemplate.findAndModify(query, update, opts, scheduleItemClass));
}
示例5: updateExpiresAt
import org.springframework.data.mongodb.core.query.Update; //导入方法依赖的package包/类
@Override
public boolean updateExpiresAt(final LocalDate expiresAt,
final MongoApproval mongoApproval) {
final Update update = Update.update("expiresAt", expiresAt);
final WriteResult writeResult = mongoTemplate.updateFirst(
byUserIdAndClientIdAndScope(mongoApproval), update,
MongoApproval.class);
return writeResult.getN() == 1;
}
示例6: updateClientSecret
import org.springframework.data.mongodb.core.query.Update; //导入方法依赖的package包/类
@Override
public boolean updateClientSecret(final String clientId,
final String newSecret) {
final Query query = Query.query(Criteria.where("clientId").is(clientId));
final Update update = Update.update("clientSecret", newSecret);
final WriteResult writeResult = mongoTemplate.updateFirst(query, update, MongoClientDetails.class);
return writeResult.getN() == 1;
}
开发者ID:cloudade,项目名称:authorization-server-with-mongodb,代码行数:12,代码来源:MongoClientDetailsRepositoryImpl.java
示例7: createUser
import org.springframework.data.mongodb.core.query.Update; //导入方法依赖的package包/类
public void createUser(String username, Integer age, WriteConfiguration writeConf) {
User user = new User().username(username).age(age);
//writeTemplates.get(writeConf).insert(user);
Query query = Query.query(Criteria.where("username").is(username));
Update update = Update.update("age", age);
writeTemplates.get(writeConf).upsert(query, update, User.class);
}
示例8: updateExpiresAt
import org.springframework.data.mongodb.core.query.Update; //导入方法依赖的package包/类
@Override
public boolean updateExpiresAt(final LocalDate expiresAt,
final MongoApproval mongoApproval) {
final Update update = Update.update("expiresAt", expiresAt);
final WriteResult writeResult = mongoTemplate.updateFirst(byUserIdAndClientIdAndScope(mongoApproval),
update,
MongoApproval.class);
return writeResult.getN() == 1;
}
示例9: updateClientSecret
import org.springframework.data.mongodb.core.query.Update; //导入方法依赖的package包/类
@Override
public boolean updateClientSecret(final String clientId,
final String newSecret) {
final Query query = Query.query(Criteria.where(ID).is(clientId));
final Update update = Update.update(CLIENT_SECRET, newSecret);
final WriteResult writeResult = mongoTemplate.updateFirst(query, update, MongoClientDetails.class);
return writeResult.getN() == 1;
}