use of org.eclipse.persistence.jpa.rs.util.list.ReportQueryResultCollection in project eclipselink by eclipse-ee4j.
the class PersistenceContext method preMarshallIndividualEntity.
/**
* Add any data required prior to marshalling an entity to XML or JSON
* In general, this will only affect fields that have been weaved into the object
*/
@SuppressWarnings("rawtypes")
protected void preMarshallIndividualEntity(Object entity) {
if (entity instanceof ReportQueryResultListItem) {
ReportQueryResultListItem item = (ReportQueryResultListItem) entity;
for (JAXBElement field : item.getFields()) {
// one or more fields in the MultiResultQueryListItem might be a domain object,
// so, we need to set the relationshipInfo for those domain objects.
setRelationshipInfo(field.getValue());
}
} else if (entity instanceof SingleResultQueryList) {
SingleResultQueryList item = (SingleResultQueryList) entity;
for (JAXBElement field : item.getFields()) {
// one or more fields in the SingleResultQueryList might be a domain object,
// so, we need to set the relationshipInfo for those domain objects.
setRelationshipInfo(field.getValue());
}
} else if (entity instanceof ReportQueryResultList) {
ReportQueryResultList list = (ReportQueryResultList) entity;
for (ReportQueryResultListItem item : list.getItems()) {
for (JAXBElement field : item.getFields()) {
// one or more fields in the MultiResultQueryList might be a domain object,
// so, we need to set the relationshipInfo for those domain objects.
setRelationshipInfo(field.getValue());
}
}
} else if (entity instanceof ReadAllQueryResultCollection) {
ReadAllQueryResultCollection list = (ReadAllQueryResultCollection) entity;
List<Object> items = list.getItems();
if ((items != null) && (!items.isEmpty())) {
for (Object item : items) {
setRelationshipInfo(item);
}
}
} else if (entity instanceof ReportQueryResultCollection) {
ReportQueryResultCollection list = (ReportQueryResultCollection) entity;
List<ReportQueryResultListItem> items = list.getItems();
if ((items != null) && (!items.isEmpty())) {
for (ReportQueryResultListItem item : items) {
setRelationshipInfo(item);
}
}
} else {
setRelationshipInfo(entity);
}
}
use of org.eclipse.persistence.jpa.rs.util.list.ReportQueryResultCollection in project eclipselink by eclipse-ee4j.
the class SelfLinksResponseBuilder method buildReportQueryResponse.
@Override
public Object buildReportQueryResponse(PersistenceContext context, Map<String, Object> queryParams, List<Object[]> results, List<ReportItem> items, UriInfo uriInfo) {
ReportQueryResultCollection response = new ReportQueryResultCollection();
for (Object result : results) {
ReportQueryResultListItem queryResultListItem = new ReportQueryResultListItem();
List<JAXBElement<?>> jaxbFields = createShellJAXBElementList(items, result);
generateLinksInElementsList(context, jaxbFields);
queryResultListItem.setFields(jaxbFields);
response.addItem(queryResultListItem);
}
response.addLink(new LinkV2(ReservedWords.JPARS_REL_SELF, uriInfo.getRequestUri().toString()));
return response;
}
use of org.eclipse.persistence.jpa.rs.util.list.ReportQueryResultCollection in project eclipselink by eclipse-ee4j.
the class PagingResponseBuilder method populatePagedReportQueryCollectionLinks.
/**
* Populate paged report query collection links.
*
* @param queryParams the query params
* @param results the results
* @param reportItems the report items
* @param uriInfo the uri info
* @return the pageable collection
*/
@SuppressWarnings({ "rawtypes" })
private PageableCollection populatePagedReportQueryCollectionLinks(Map<String, Object> queryParams, List<Object[]> results, List<ReportItem> reportItems, UriInfo uriInfo) {
ReportQueryResultCollection response = new ReportQueryResultCollection();
for (Object result : results) {
ReportQueryResultListItem queryResultListItem = new ReportQueryResultListItem();
List<JAXBElement<?>> jaxbFields = createShellJAXBElementList(reportItems, result);
// We don't have a way of determining self links for the report query responses
// so, no links array will be inserted into individual items in the response
queryResultListItem.setFields(jaxbFields);
response.addItem(queryResultListItem);
}
response.setCount(results.size());
return populatePagedCollectionLinks(queryParams, uriInfo, response);
}
use of org.eclipse.persistence.jpa.rs.util.list.ReportQueryResultCollection in project eclipselink by eclipse-ee4j.
the class ObjectGraphBuilder method createNodeForPageableCollection.
private void createNodeForPageableCollection(PageableCollection<?> collection, Node node) {
node.addAttributeNode("hasMore");
node.addAttributeNode("count");
node.addAttributeNode("offset");
node.addAttributeNode("limit");
node.addAttributeNode("links");
if (collection.getItems() != null && !collection.getItems().isEmpty()) {
final Node subNode = node.addSubNode("items");
if (collection instanceof ReportQueryResultCollection) {
final ReportQueryResultCollection reportQueryResultCollection = (ReportQueryResultCollection) collection;
processFieldsList(subNode.addSubNode("fields"), reportQueryResultCollection.getItems().get(0).getFields());
} else {
createNodeForEntity(collection.getItems().get(0), subNode);
}
}
}
Aggregations