List of usage examples for org.springframework.data.mongodb.core.query Update push
public Update push(String key, Object value)
From source file:edu.fing.tagsi.mongodb.services.PackageTrackingService.java
public void Add(PackageInfo pi, PackageNode pn) { if (pi != null && pn != null) { Query query = new Query(); //_id = idPaquete query.addCriteria(Criteria.where("_id").is(pi.getIdPaquete()).and("idCliente").is(pi.getIdCliente())); Update update = new Update(); update.push("nodes", pn); mongoOperations.upsert(query, update, PackageInfo.class); }/*from w w w.j av a 2 s . co m*/ }
From source file:quanlyhocvu.api.mongodb.DAO.LopHocDAO.java
public boolean insertHocSinh(String classId, HocSinhDTO studentIds) { boolean res = true; Query query = Query.query(Criteria.where("id").is(classId)); Update update = new Update(); update.push("listHocSinh", studentIds); mongoOperation.findAndModify(query, update, LopHocDTO.class); return res;/*from w w w . jav a 2 s . c om*/ }
From source file:org.slc.sli.dal.repository.MongoRepository.java
public WriteResult updateFirst(NeutralQuery query, Map<String, Object> update, String collectionName) { // Enforcing the tenantId query. The rationale for this is all CRUD // Operations should be restricted based on tenant. this.addDefaultQueryParams(query, collectionName); Query convertedQuery = this.queryConverter.convert(collectionName, query); Update convertedUpdate = new Update(); for (Map.Entry<String, Object> entry : update.entrySet()) { String operation = entry.getKey(); @SuppressWarnings("unchecked") Map<String, Object> operands = (Map<String, Object>) entry.getValue(); if (operation.equals("push")) { for (Map.Entry<String, Object> fieldValues : operands.entrySet()) { convertedUpdate.push(fieldValues.getKey(), fieldValues.getValue()); }//from www . ja v a 2 s. c om } else if (operation.equals("pushAll")) { for (Map.Entry<String, Object> fieldValues : operands.entrySet()) { convertedUpdate.pushAll(fieldValues.getKey(), (Object[]) fieldValues.getValue()); } } else if (operation.equals("addToSet")) { for (Map.Entry<String, Object> fieldValues : operands.entrySet()) { convertedUpdate.addToSet(fieldValues.getKey(), fieldValues.getValue()); } } } return updateFirst(convertedQuery, convertedUpdate, collectionName); }
From source file:org.slc.sli.dal.repository.MongoRepository.java
@Override public WriteResult updateMulti(NeutralQuery query, Map<String, Object> update, String collectionName) { // Enforcing the tenantId query. The rationale for this is all CRUD // Operations should be restricted based on tenant. this.addDefaultQueryParams(query, collectionName); Query convertedQuery = this.queryConverter.convert(collectionName, query); Update convertedUpdate = new Update(); for (Map.Entry<String, Object> entry : update.entrySet()) { String operation = entry.getKey(); @SuppressWarnings("unchecked") Map<String, Object> operands = (Map<String, Object>) entry.getValue(); if (operation.equals("push")) { for (Map.Entry<String, Object> fieldValues : operands.entrySet()) { convertedUpdate.push(fieldValues.getKey(), fieldValues.getValue()); }/*www. j ava 2 s. c o m*/ } else if (operation.equals("pushAll")) { for (Map.Entry<String, Object> fieldValues : operands.entrySet()) { convertedUpdate.pushAll(fieldValues.getKey(), (Object[]) fieldValues.getValue()); } } else if (operation.equals("addToSet")) { for (Map.Entry<String, Object> fieldValues : operands.entrySet()) { convertedUpdate.addToSet(fieldValues.getKey(), fieldValues.getValue()); } } } guideIfTenantAgnostic(collectionName); return template.updateMulti(convertedQuery, convertedUpdate, collectionName); }
From source file:piecework.repository.concrete.ProcessInstanceRepositoryCustomImpl.java
@Override public ProcessInstance update(String id, Operation operation, String applicationStatus, String applicationStatusExplanation, String processStatus, Set<Task> tasks) { Query query = new Query(where("_id").is(id)); Update update = new Update(); if (applicationStatus != null) update.set("applicationStatus", applicationStatus); if (applicationStatusExplanation != null) update.set("applicationStatusExplanation", applicationStatusExplanation); if (processStatus != null) update.set("processStatus", processStatus); if (tasks != null) { for (Task task : tasks) { update.set("tasks." + task.getTaskInstanceId(), task); }//w w w. j a va 2 s .co m } update.push("operations", operation); update.set("lastModifiedTime", new Date()); FindAndModifyOptions options = new FindAndModifyOptions(); options.returnNew(true); return mongoOperations.findAndModify(query, update, options, ProcessInstance.class); }
From source file:piecework.repository.concrete.ProcessInstanceRepositoryCustomImpl.java
private static void include(Update update, Submission submission) { if (submission != null) update.push("submissions", submission.getSubmissionId()); }