use of com.linkedin.data.DataMap in project rest.li by linkedin.
the class ResourceModelEncoder method buildResourceSchema.
/**
* @param resourceModel {@link ResourceModel} to build the schema for
* @return {@link ResourceSchema} for the provided resource model
*/
public ResourceSchema buildResourceSchema(final ResourceModel resourceModel) {
ResourceSchema rootNode = new ResourceSchema();
switch(resourceModel.getResourceType()) {
case ACTIONS:
appendActionsModel(rootNode, resourceModel);
break;
case SIMPLE:
appendSimple(rootNode, resourceModel);
break;
default:
appendCollection(rootNode, resourceModel);
break;
}
final DataMap customAnnotation = resourceModel.getCustomAnnotationData();
if (!customAnnotation.isEmpty()) {
rootNode.setAnnotations(new CustomAnnotationContentSchemaMap(customAnnotation));
}
return rootNode;
}
use of com.linkedin.data.DataMap 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.data.DataMap in project rest.li by linkedin.
the class BatchPatchArgumentBuilder method extractRequestData.
@SuppressWarnings("unchecked")
@Override
public RestLiRequestData extractRequestData(RoutingResult routingResult, RestRequest request) {
DataMap dataMap = DataMapUtils.readMap(request);
Set<?> ids = routingResult.getContext().getPathKeys().getBatchIds();
@SuppressWarnings({ "rawtypes" }) Map inputMap = ArgumentBuilder.buildBatchRequestMap(routingResult, dataMap, PatchRequest.class, ids, ProtocolVersionUtil.extractProtocolVersion(request.getHeaders()));
final RestLiRequestDataImpl.Builder builder = new RestLiRequestDataImpl.Builder();
if (inputMap != null) {
builder.batchKeyEntityMap(inputMap);
}
return builder.build();
}
use of com.linkedin.data.DataMap in project rest.li by linkedin.
the class BatchUpdateArgumentBuilder method extractRequestData.
@SuppressWarnings("unchecked")
@Override
public RestLiRequestData extractRequestData(RoutingResult routingResult, RestRequest request) {
Class<? extends RecordTemplate> valueClass = ArgumentUtils.getValueClass(routingResult);
DataMap dataMap = DataMapUtils.readMap(request);
Set<?> ids = routingResult.getContext().getPathKeys().getBatchIds();
@SuppressWarnings({ "rawtypes" }) Map inputMap = ArgumentBuilder.buildBatchRequestMap(routingResult, dataMap, valueClass, ids, ProtocolVersionUtil.extractProtocolVersion(request.getHeaders()));
final RestLiRequestDataImpl.Builder builder = new RestLiRequestDataImpl.Builder();
if (inputMap != null) {
builder.batchKeyEntityMap(inputMap);
}
return builder.build();
}
use of com.linkedin.data.DataMap in project rest.li by linkedin.
the class TestRestLiFilterResponseContextFactory method testFromResult.
@Test
public void testFromResult() throws Exception {
DataMap dataMap = new DataMap();
dataMap.put("foo", "bar");
Map<String, String> headers = Maps.newHashMap();
headers.put("x", "y");
RecordTemplate entity1 = new Foo(dataMap);
RestLiResponseDataImpl responseData = new RestLiResponseDataImpl(HttpStatus.S_200_OK, headers, Collections.<HttpCookie>emptyList());
responseData.setResponseEnvelope(new GetResponseEnvelope(entity1, responseData));
when(_responseHandler.buildRestLiResponseData(_restRequest, _routingResult, entity1)).thenReturn(responseData);
FilterResponseContext responseContext = _filterResponseContextFactory.fromResult(entity1);
assertEquals(responseContext.getResponseData(), responseData);
verify(_responseHandler).buildRestLiResponseData(_restRequest, _routingResult, entity1);
}
Aggregations