本文整理汇总了Java中org.sunbird.common.ElasticSearchUtil.updateData方法的典型用法代码示例。如果您正苦于以下问题:Java ElasticSearchUtil.updateData方法的具体用法?Java ElasticSearchUtil.updateData怎么用?Java ElasticSearchUtil.updateData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sunbird.common.ElasticSearchUtil
的用法示例。
在下文中一共展示了ElasticSearchUtil.updateData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateEs
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void updateEs(String userId) {
// get all records from cassandra as list and add that list to user in ElasticSearch ...
Response response = cassandraOperation.getRecordsByProperty(userSkillDbInfo.getKeySpace() , userSkillDbInfo.getTableName(), JsonKey.USER_ID , userId);
List<Map<String,Object>> responseList = (List<Map<String, Object>>) response.get(JsonKey.RESPONSE);
Map<String , Object> esMap = new HashMap<>();
esMap.put(JsonKey.SKILLS , responseList);
Map<String,Object> profile = ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), userId);
if(null!= profile && !profile.isEmpty()){
Map<String,String> visibility = (Map<String, String>) profile.get(JsonKey.PROFILE_VISIBILITY);
if((null!=visibility && !visibility.isEmpty())&& visibility.containsKey(JsonKey.SKILLS)){
Map<String,Object> visibilityMap = ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.userprofilevisibility.getTypeName(), userId);
if (null != visibilityMap && !visibilityMap.isEmpty()) {
visibilityMap.putAll(esMap);
ElasticSearchUtil.createData(ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.userprofilevisibility.getTypeName(), userId , visibilityMap);
}
}else {
ElasticSearchUtil.updateData(ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), userId , esMap);
}
}
}
示例2: updateUserLoginTime
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
* This method will update user login time under cassandra and Elasticsearch.
*
* @param reqMap Map<String, Object>
* @return boolean
*/
private boolean updateUserLoginTime(Map<String, Object> reqMap) {
ProjectLogger.log("Start saving user login time==", LoggerEnum.INFO.name());
boolean response = false;
String lastLoginTime = (String) reqMap.get(JsonKey.CURRENT_LOGIN_TIME);
String userId = (String) reqMap.get(JsonKey.USER_ID);
reqMap.clear();
reqMap.put(JsonKey.LAST_LOGIN_TIME, lastLoginTime);
reqMap.put(JsonKey.CURRENT_LOGIN_TIME, Long.toString(System.currentTimeMillis()));
response = ElasticSearchUtil.updateData(ProjectUtil.EsIndex.sunbird.getIndexName(),
ProjectUtil.EsType.user.getTypeName(), userId, reqMap);
Util.DbInfo usrDbInfo = Util.dbInfoMap.get(JsonKey.USER_DB);
reqMap.put(JsonKey.ID, userId);
cassandraOperation.updateRecord(usrDbInfo.getKeySpace(), usrDbInfo.getTableName(), reqMap);
ProjectLogger.log("End saving user login time== " + response, LoggerEnum.INFO.name());
return response;
}
示例3: updateDataToElastic
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
* Method to update data to ES .
*
* @param indexName
* @param typeName
* @param identifier
* @param data
* @return
*/
private boolean updateDataToElastic(String indexName, String typeName, String identifier,
Map<String, Object> data) {
boolean response = ElasticSearchUtil.updateData(indexName, typeName, identifier, data);
if (response) {
return true;
}
ProjectLogger.log("unable to save the data inside ES with identifier " + identifier,
LoggerEnum.INFO.name());
return false;
}
示例4: updateUserDetails
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private void updateUserDetails(Entry<String, Object> entry) {
String userId = entry.getKey();
ProjectLogger.log("updating user data started");
Map<String, Object> userMap = (Map<String, Object>) entry.getValue();
// Decrypt user data
UserUtility.decryptUserData(userMap);
Util.DbInfo dbInfo = Util.dbInfoMap.get(JsonKey.USER_DB);
if(isSSOEnabled){
try {
String res = ssoManager.syncUserData(userMap);
if (!(!ProjectUtil.isStringNullOREmpty(res) && res.equalsIgnoreCase(JsonKey.SUCCESS))) {
if(null == userMap.get(JsonKey.EMAIL_VERIFIED)){
Map<String,Object> map = new HashMap<>();
if(SSOServiceFactory.getInstance().isEmailVerified(userId)){
map.put(JsonKey.EMAIL_VERIFIED, true);
map.put(JsonKey.ID, userId);
}else{
map.put(JsonKey.EMAIL_VERIFIED, false);
map.put(JsonKey.ID, userId);
}
cassandraOperation.updateRecord(dbInfo.getKeySpace(), dbInfo.getTableName(), map);
ElasticSearchUtil.updateData(ProjectUtil.EsIndex.sunbird.getIndexName(),
ProjectUtil.EsType.user.getTypeName(), userId, map);
}
ProjectLogger.log("User sync failed in KeyCloakSyncActor for userID : "+ userId);
}
} catch (Exception e) {
ProjectLogger.log(e.getMessage(), e);
ProjectLogger.log("User sync failed in KeyCloakSyncActor for userID : "+ userId);
}
}else{
ProjectLogger.log("SSO is disabled , cann't sync user data to keycloak.");
}
}
示例5: updateTcStatusOfUser
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
* Methos to update the Terms and condition status of user , the status may be ACCEPTED or REJECTED .
* @param actorMessage
*/
private void updateTcStatusOfUser(Request actorMessage) {
ProjectLogger.log("TenantPreferenceManagementActor-updateTcStatusOfUser called");
Map<String, Object> reqBody = (Map<String, Object>) actorMessage.getRequest().get(JsonKey.TENANT_PREFERENCE);
String requestedBy = (String) actorMessage.getRequest().get(JsonKey.REQUESTED_BY);
Response response1=cassandraOperation.getRecordById(userDbInfo.getKeySpace(), userDbInfo.getTableName(), requestedBy);
String tcStatus = (String) reqBody.get(JsonKey.TERM_AND_CONDITION_STATUS);
Map<String , Object> userMap = ((List<Map<String, Object>>) response1.get(JsonKey.RESPONSE)).get(0);
Map<String , Object> dbMap = new HashMap<>();
dbMap.put(JsonKey.TERM_AND_CONDITION_STATUS , tcStatus);
dbMap.put(JsonKey.TC_UPDATED_DATE , format.format(new Date()));
dbMap.put(JsonKey.ID , userMap.get(JsonKey.ID));
//update cassandra
cassandraOperation.updateRecord(userDbInfo.getKeySpace(), userDbInfo.getTableName(), dbMap);
// update elastic search
dbMap.remove(JsonKey.ID);
ElasticSearchUtil
.updateData(ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), requestedBy , dbMap);
Response finalResponse = new Response();
finalResponse.getResult().put(JsonKey.RESPONSE, JsonKey.SUCCESS);
sender().tell(finalResponse , self());
}
示例6: updateDataToElastic
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private boolean updateDataToElastic(String indexName, String typeName, String identifier,
Map<String, Object> data) {
boolean response = ElasticSearchUtil.updateData(indexName, typeName, identifier, data);
if (response) {
return true;
}
ProjectLogger.log("unbale to save the data inside ES with identifier " + identifier,
LoggerEnum.INFO.name());
return false;
}
示例7: updateDataIntoES
import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
*
* @param val
*/
public static boolean updateDataIntoES (Map<String,Object> map) {
Boolean flag = true;
try{
flag = ElasticSearchUtil.updateData(ProjectUtil.EsIndex.sunbird.getIndexName(),
ProjectUtil.EsType.course.getTypeName(), (String)map.get(JsonKey.ID), map) ;
}catch(Exception e){
ProjectLogger.log("Exception occured while saving course batch data to ES",e);
flag = false;
}
return flag;
}