use of com.fasterxml.jackson.annotation.JsonView in project spring-framework by spring-projects.
the class MappingJackson2MessageConverter method getSerializationView.
/**
* Determine a Jackson serialization view based on the given conversion hint.
* @param conversionHint the conversion hint Object as passed into the
* converter for the current conversion attempt
* @return the serialization view class, or {@code null} if none
*/
protected Class<?> getSerializationView(Object conversionHint) {
if (conversionHint instanceof MethodParameter) {
MethodParameter methodParam = (MethodParameter) conversionHint;
JsonView annotation = methodParam.getParameterAnnotation(JsonView.class);
if (annotation == null) {
annotation = methodParam.getMethodAnnotation(JsonView.class);
if (annotation == null) {
return null;
}
}
return extractViewClass(annotation, conversionHint);
} else if (conversionHint instanceof JsonView) {
return extractViewClass((JsonView) conversionHint, conversionHint);
} else if (conversionHint instanceof Class) {
return (Class<?>) conversionHint;
} else {
return null;
}
}
use of com.fasterxml.jackson.annotation.JsonView in project spring-framework by spring-projects.
the class Jackson2ServerHttpMessageWriter method resolveWriteHints.
@Override
protected Map<String, Object> resolveWriteHints(ResolvableType streamType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request) {
Map<String, Object> hints = new HashMap<>();
Object source = streamType.getSource();
MethodParameter returnValue = (source instanceof MethodParameter ? (MethodParameter) source : null);
if (returnValue != null) {
JsonView annotation = returnValue.getMethodAnnotation(JsonView.class);
if (annotation != null) {
Class<?>[] classes = annotation.value();
if (classes.length != 1) {
throw new IllegalArgumentException("@JsonView only supported for write hints with exactly 1 class argument: " + returnValue);
}
hints.put(AbstractJackson2Codec.JSON_VIEW_HINT, classes[0]);
}
}
return hints;
}
use of com.fasterxml.jackson.annotation.JsonView in project ocvn by devgateway.
the class LocationInfowindowController method awardsByLocation.
@ApiOperation(value = "Displays the awards, filtered by location. See the location filter " + "for the options to filter by")
@RequestMapping(value = "/api/awardsByLocation", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
public List<DBObject> awardsByLocation(@ModelAttribute @Valid final YearFilterPagingRequest filter) {
Aggregation agg = newAggregation(match(where("awards.0").exists(true).orOperator(where("tender.items.deliveryLocation._id").exists(true), where("planning.budget.projectLocation._id").exists(true)).andOperator(getYearDefaultFilterCriteria(filter, "awards.date"))), project("awards").andExclude(Fields.UNDERSCORE_ID), unwind("awards"), skip(filter.getSkip()), limit(filter.getPageSize()));
AggregationResults<DBObject> results = mongoTemplate.aggregate(agg, "release", DBObject.class);
List<DBObject> tagCount = results.getMappedResults();
return tagCount;
}
use of com.fasterxml.jackson.annotation.JsonView in project ocvn by devgateway.
the class LocationInfowindowController method tendersByLocation.
@ApiOperation(value = "Displays the tenders filtered by location. See the location filter " + "for the options to filter by")
@RequestMapping(value = "/api/tendersByLocation", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
public List<DBObject> tendersByLocation(@ModelAttribute @Valid final YearFilterPagingRequest filter) {
Aggregation agg = newAggregation(match(where("tender").exists(true).orOperator(where("tender.items.deliveryLocation._id").exists(true), where("planning.budget.projectLocation._id").exists(true)).andOperator(getYearDefaultFilterCriteria(filter, MongoConstants.FieldNames.TENDER_PERIOD_START_DATE))), project("tender").andExclude(Fields.UNDERSCORE_ID), skip(filter.getSkip()), limit(filter.getPageSize()));
AggregationResults<DBObject> results = mongoTemplate.aggregate(agg, "release", DBObject.class);
List<DBObject> tagCount = results.getMappedResults();
return tagCount;
}
use of com.fasterxml.jackson.annotation.JsonView in project ocvn by devgateway.
the class LocationInfowindowController method planningByLocation.
@ApiOperation(value = "Displays the planning items, filtered by location. See the location filter " + "for the options to filter by")
@RequestMapping(value = "/api/planningByLocation", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
public List<DBObject> planningByLocation(@ModelAttribute @Valid final YearFilterPagingRequest filter) {
Aggregation agg = newAggregation(match(where("planning.budget").exists(true).orOperator(where("tender.items.deliveryLocation._id").exists(true), where("planning.budget.projectLocation._id").exists(true)).andOperator(getYearDefaultFilterCriteria(filter, "planning.bidPlanProjectDateApprove"))), project("planning").andExclude(Fields.UNDERSCORE_ID), skip(filter.getSkip()), limit(filter.getPageSize()));
AggregationResults<DBObject> results = mongoTemplate.aggregate(agg, "release", DBObject.class);
List<DBObject> tagCount = results.getMappedResults();
return tagCount;
}
Aggregations