use of org.broadleafcommerce.openadmin.server.domain.FetchPageRequest in project BroadleafCommerce by BroadleafCommerce.
the class AdminEntityServiceImpl method getAllRecordsForAllSubCollections.
@Override
public Map<String, DynamicResultSet> getAllRecordsForAllSubCollections(ClassMetadata cmd, Entity containingEntity, List<SectionCrumb> sectionCrumb) throws ServiceException {
Map<String, DynamicResultSet> map = new HashMap<>();
for (Property p : cmd.getProperties()) {
FieldMetadata fieldMetadata = p.getMetadata();
boolean fieldAvailable = ArrayUtils.contains(fieldMetadata.getAvailableToTypes(), containingEntity.getType()[0]);
if (fieldAvailable && fieldMetadata instanceof CollectionMetadata) {
FetchPageRequest pageRequest = new FetchPageRequest().withPageSize(Integer.MAX_VALUE);
PersistenceResponse resp = getPagedRecordsForCollection(cmd, containingEntity, p, null, pageRequest, null, sectionCrumb);
map.put(p.getName(), resp.getDynamicResultSet());
}
}
return map;
}
use of org.broadleafcommerce.openadmin.server.domain.FetchPageRequest in project BroadleafCommerce by BroadleafCommerce.
the class AdminAbstractController method getCollectionListGrid.
// **********************************
// HELPER METHODS FOR BUILDING DTOS *
// **********************************
/**
* Convenience method for obtaining a ListGrid DTO object for a collection. Note that if no <b>criteria</b> is
* available, then this should be null (or empty)
*
* @param mainMetadata class metadata for the root entity that this <b>collectionProperty</b> relates to
* @param entity
* @param collectionProperty property that this collection should be based on from the root entity
* @param requestParams
* @param sectionKey the current main section key
* @param persistenceResponse
* @param sectionCrumbs
* @return the list grid
* @throws ServiceException
*/
protected ListGrid getCollectionListGrid(ClassMetadata mainMetadata, Entity entity, Property collectionProperty, MultiValueMap<String, String> requestParams, String sectionKey, PersistenceResponse persistenceResponse, List<SectionCrumb> sectionCrumbs) throws ServiceException {
String idProperty = service.getIdProperty(mainMetadata);
if (persistenceResponse != null && persistenceResponse.getAdditionalData().containsKey(PersistenceResponse.AdditionalData.CLONEID)) {
entity.findProperty(idProperty).setValue((String) persistenceResponse.getAdditionalData().get(PersistenceResponse.AdditionalData.CLONEID));
}
FetchPageRequest pageRequest = new FetchPageRequest().withLastId(getLastId(requestParams)).withFirstId(getFirstId(requestParams)).withStartIndex(getStartIndex(requestParams)).withMaxIndex(getMaxIndex(requestParams)).withUpperCount(getUpperCount(requestParams)).withLowerCount(getLowerCount(requestParams)).withPageSize(getPageSize(requestParams));
DynamicResultSet drs = service.getPagedRecordsForCollection(mainMetadata, entity, collectionProperty, getCriteria(requestParams), pageRequest, null, sectionCrumbs).getDynamicResultSet();
ListGrid listGrid = formService.buildCollectionListGrid(entity.findProperty(idProperty).getValue(), drs, collectionProperty, sectionKey, sectionCrumbs);
return listGrid;
}
Aggregations