@RestMethod.BatchGet public BatchResult<Integer, ValidationDemo> batchGet() { Map<Integer, ValidationDemo> resultMap = new HashMap<Integer, ValidationDemo>(); resultMap.put(1, _returnEntity); return new BatchResult<Integer, ValidationDemo>(resultMap, new HashMap<Integer, RestLiServiceException>()); }
statuses = batchResult.getStatuses(); serviceErrors = batchResult.getErrors();
return new BatchResult<Long, Greeting>(null, null, null); return new BatchResult<Long, Greeting>(greetingMap, statusMap, null); return new BatchResult<Long, Greeting>(greetingMap, null, null); return new BatchResult<Long, Greeting>(concurrentGreetingMap, new ConcurrentHashMap<Long, HttpStatus>(), new ConcurrentHashMap<Long, RestLiServiceException>());
@RestMethod.BatchGet public Map<String, Message> batchGet(Set<String> ids) { Map<String, Message> batch = new HashMap<String, Message>(); Map<String, RestLiServiceException> errors = new HashMap<String, RestLiServiceException>(); for (String id : ids) { Message g = _db.get(id); if (g != null) { batch.put(id, g); } else { errors.put(id, new RestLiServiceException(HttpStatus.S_404_NOT_FOUND)); } } return new BatchResult<String, Message>(batch, errors); }
@RestMethod.BatchGet public Map<Long, Greeting> batchGet(Set<Long> ids) { Map<Long, Greeting> batch = new HashMap<Long, Greeting>(); Map<Long, RestLiServiceException> errors = new HashMap<Long, RestLiServiceException>(); for (long id : ids) { Greeting g = _db.get(id); if (g != null) { batch.put(id, g); } else { errors.put(id, new RestLiServiceException(HttpStatus.S_404_NOT_FOUND)); } } return new BatchResult<Long, Greeting>(batch, errors); }
public BatchResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> batchGet( Set<ComplexResourceKey<TwoPartKey, TwoPartKey>> keys) { Map<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> data = new HashMap<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message>(); Map<ComplexResourceKey<TwoPartKey, TwoPartKey>, RestLiServiceException> errors = new HashMap<ComplexResourceKey<TwoPartKey, TwoPartKey>, RestLiServiceException>(); for (ComplexResourceKey<TwoPartKey, TwoPartKey> key : keys) { String stringKey = keyToString(key.getKey()); if (_db.containsKey(stringKey)) { data.put(key, _db.get(stringKey)); } else { errors.put(key, new RestLiServiceException(HttpStatus.S_404_NOT_FOUND)); } } return new BatchResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message>(data, errors); }
/** * @see GroupMembershipsResource2#batchGet(Set) */ @Override public BatchResult<CompoundKey, GroupMembership> batchGet(Set<CompoundKey> ids) { Map<CompoundKey, GroupMembership> result = new HashMap<CompoundKey, GroupMembership>(ids.size()); Map<CompoundKey, RestLiServiceException> errors = new HashMap<CompoundKey, RestLiServiceException>(); Iterator<CompoundKey> iterator = ids.iterator(); while (iterator.hasNext()) { CompoundKey key = iterator.next(); GroupMembership membership = _app.getMembershipMgr().get(key); if (membership != null) { result.put(key, membership); } else { errors.put(key, new RestLiServiceException(HttpStatus.S_404_NOT_FOUND)); } } return new BatchResult<CompoundKey, GroupMembership>(result, errors); }
/** * @see GroupMembershipsResource2#batchGet(Set) */ @Override public BatchResult<ComplexResourceKey<GroupMembershipKey, GroupMembershipParam>, ComplexKeyGroupMembership> batchGet(Set<ComplexResourceKey<GroupMembershipKey, GroupMembershipParam>> ids) { Map<ComplexResourceKey<GroupMembershipKey, GroupMembershipParam>, ComplexKeyGroupMembership> result = new HashMap<ComplexResourceKey<GroupMembershipKey, GroupMembershipParam>, ComplexKeyGroupMembership>(ids.size()); Map<ComplexResourceKey<GroupMembershipKey, GroupMembershipParam>, RestLiServiceException> errors = new HashMap<ComplexResourceKey<GroupMembershipKey, GroupMembershipParam>, RestLiServiceException>(); Iterator<ComplexResourceKey<GroupMembershipKey, GroupMembershipParam>> iterator = ids.iterator(); while (iterator.hasNext()) { ComplexResourceKey<GroupMembershipKey, GroupMembershipParam> key = iterator.next(); ComplexKeyGroupMembership membership = fromGroupMembership(_app.getMembershipMgr().get(complexKeyToCompoundKey(key))); if (membership != null) { result.put(key, membership); } else { errors.put(key, new RestLiServiceException(HttpStatus.S_404_NOT_FOUND)); } } return new BatchResult<ComplexResourceKey<GroupMembershipKey, GroupMembershipParam>, ComplexKeyGroupMembership>(result, errors); } /**
public ExampleRequestResponse batchGet() { checkSupports(ResourceMethod.BATCH_GET); BatchGetRequestBuilder<Object, RecordTemplatePlaceholder> batchGet = new BatchGetRequestBuilder<Object, RecordTemplatePlaceholder>( _uriTemplate, RecordTemplatePlaceholder.class, _resourceSpec, _requestOptions); Object id1 = generateKey(0); Object id2 = generateKey(1); batchGet.ids(id1, id2); addParams(batchGet, ResourceMethod.BATCH_GET); addPathKeys(batchGet); BatchGetKVRequest<Object, RecordTemplatePlaceholder> request = batchGet.buildKV(); final Map<Object, RecordTemplatePlaceholder> bgResponseData = new HashMap<Object, RecordTemplatePlaceholder>(); bgResponseData.put(id1, generateEntity()); bgResponseData.put(id2, generateEntity()); BatchResult<Object, RecordTemplatePlaceholder> result = new BatchResult<Object, RecordTemplatePlaceholder>(bgResponseData, new HashMap<Object, RestLiServiceException>()); return buildRequestResponse(request, result, buildResourceMethodDescriptorForRestMethod(request)); }
@RestMethod.BatchGet public BatchResult<Integer, ValidationDemo> batchGet(Set<Integer> ids) { Map<Integer, ValidationDemo> resultMap = new HashMap<Integer, ValidationDemo>(); Map<Integer, RestLiServiceException> errorMap = new HashMap<Integer, RestLiServiceException>(); // Generate entities that are missing a required field for (Integer id : ids) { if (id == 0) { errorMap.put(id, new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST)); } else if (id == 1) { ValidationDemo.UnionFieldWithInlineRecord union = new ValidationDemo.UnionFieldWithInlineRecord(); union.setMyRecord(new myRecord().setFoo1(100).setFoo2(200)); resultMap.put(id, new ValidationDemo().setStringA("a").setStringB("b").setUnionFieldWithInlineRecord(union)); } else { ValidationDemo.UnionFieldWithInlineRecord union = new ValidationDemo.UnionFieldWithInlineRecord(); union.setMyRecord(new myRecord()); ValidationDemo validationDemo = new ValidationDemo().setStringA("a").setStringB("b").setUnionFieldWithInlineRecord(union); resultMap.put(id, validationDemo); } }; return new BatchResult<Integer, ValidationDemo>(resultMap, errorMap); }