当前位置: 首页>>代码示例>>Java>>正文


Java Update.update方法代码示例

本文整理汇总了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;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:24,代码来源:TenantMongoDA.java

示例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;
    }
 
开发者ID:Zephery,项目名称:newblog,代码行数:15,代码来源:MongoDao.java

示例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);
	}
}
 
开发者ID:noseparte,项目名称:Spring-Boot-Server,代码行数:39,代码来源:AppCustomerRestful.java

示例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));
}
 
开发者ID:fernandonogueira,项目名称:okra,代码行数:29,代码来源:OkraSpring.java

示例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;
}
 
开发者ID:cloudade,项目名称:authorization-server-with-mongodb,代码行数:12,代码来源:MongoApprovalRepositoryImpl.java

示例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);
}
 
开发者ID:vberetti,项目名称:ippevent-20-05-2014,代码行数:8,代码来源:UserRepository.java

示例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;
}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:12,代码来源:MongoApprovalRepositoryImpl.java

示例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;
}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:12,代码来源:MongoClientDetailsRepositoryImpl.java


注:本文中的org.springframework.data.mongodb.core.query.Update.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。