use of com.linkedin.restli.common.CollectionRequest in project rest.li by linkedin.
the class BatchCreateArgumentBuilder method extractRequestData.
@Override
public RestLiRequestData extractRequestData(RoutingResult routingResult, RestRequest request) {
Class<? extends RecordTemplate> valueClass = ArgumentUtils.getValueClass(routingResult);
DataMap dataMap = DataMapUtils.readMap(request);
@SuppressWarnings({ "unchecked", "rawtypes" }) CollectionRequest<RecordTemplate> collectionRequest = new CollectionRequest(dataMap, valueClass);
return new RestLiRequestDataImpl.Builder().batchEntities(collectionRequest.getElements()).build();
}
use of com.linkedin.restli.common.CollectionRequest in project rest.li by linkedin.
the class BatchPartialUpdateRequestBuilder method buildReadOnlyInput.
private CollectionRequest<KeyValueRecord<K, PatchRequest<V>>> buildReadOnlyInput() {
try {
DataMap map = new DataMap();
@SuppressWarnings({ "unchecked", "rawtypes" }) CollectionRequest<KeyValueRecord<K, PatchRequest<V>>> input = new CollectionRequest(map, KeyValueRecord.class);
for (Map.Entry<K, PatchRequest<V>> inputEntityEntry : _partialUpdateInputMap.entrySet()) {
K key = getReadOnlyOrCopyKey(inputEntityEntry.getKey());
PatchRequest<V> entity = getReadOnlyOrCopyDataTemplate(inputEntityEntry.getValue());
KeyValueRecord<K, PatchRequest<V>> keyValueRecord = _keyValueRecordFactory.create(key, entity);
keyValueRecord.data().setReadOnly();
input.getElements().add(keyValueRecord);
}
map.setReadOnly();
return input;
} catch (CloneNotSupportedException cloneException) {
throw new IllegalArgumentException("Entity cannot be copied.", cloneException);
}
}
use of com.linkedin.restli.common.CollectionRequest in project rest.li by linkedin.
the class FluentClientUtils method buildBatchEntityInputs.
/**
* Converts list of entities for batch_* requests to a {@link CollectionRequest} as needed by the request classes.
* @param entities Inputs to the batch_* methods.
* @param valueClass Entity's class.
* @param <V> Value type
*/
public static <V extends RecordTemplate> CollectionRequest<V> buildBatchEntityInputs(List<V> entities, Class<V> valueClass) {
DataMap map = new DataMap();
CollectionRequest<V> input = new CollectionRequest<>(map, valueClass);
for (V entity : entities) {
input.getElements().add(entity);
}
return input;
}
use of com.linkedin.restli.common.CollectionRequest in project rest.li by linkedin.
the class BatchKVRequestBuilder method buildReadOnlyInput.
protected <E extends RecordTemplate> CollectionRequest<KeyValueRecord<K, E>> buildReadOnlyInput(Map<K, E> readOnlyInputEntities, Map<K, E> inputMap, KeyValueRecordFactory<K, E> keyValueRecordFactory) {
try {
DataMap map = new DataMap();
@SuppressWarnings({ "unchecked", "rawtypes" }) CollectionRequest<KeyValueRecord<K, E>> input = new CollectionRequest(map, KeyValueRecord.class);
for (Map.Entry<K, E> inputEntityEntry : inputMap.entrySet()) {
K key = getReadOnlyOrCopyKey(inputEntityEntry.getKey());
E entity = getReadOnlyOrCopyDataTemplate(inputEntityEntry.getValue());
readOnlyInputEntities.put(key, entity);
KeyValueRecord<K, E> keyValueRecord = keyValueRecordFactory.create(key, entity);
keyValueRecord.data().setReadOnly();
input.getElements().add(keyValueRecord);
}
map.setReadOnly();
return input;
} catch (CloneNotSupportedException cloneException) {
throw new IllegalArgumentException("Entity cannot be copied.", cloneException);
}
}
use of com.linkedin.restli.common.CollectionRequest in project rest.li by linkedin.
the class BatchCreateRequestBuilder method buildReadOnlyInput.
private CollectionRequest<V> buildReadOnlyInput() {
try {
DataMap map = new DataMap();
CollectionRequest<V> input = new CollectionRequest<>(map, _valueClass);
for (V entity : _entities) {
input.getElements().add(getReadOnlyOrCopyDataTemplate(entity));
}
map.setReadOnly();
return input;
} catch (CloneNotSupportedException cloneException) {
throw new IllegalArgumentException("Entity cannot be copied.", cloneException);
}
}
Aggregations