Search in sources :

Example 1 with FetchPageRequest

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;
}
Also used : BasicCollectionMetadata(org.broadleafcommerce.openadmin.dto.BasicCollectionMetadata) CollectionMetadata(org.broadleafcommerce.openadmin.dto.CollectionMetadata) AdornedTargetCollectionMetadata(org.broadleafcommerce.openadmin.dto.AdornedTargetCollectionMetadata) FieldMetadata(org.broadleafcommerce.openadmin.dto.FieldMetadata) BasicFieldMetadata(org.broadleafcommerce.openadmin.dto.BasicFieldMetadata) HashMap(java.util.HashMap) FetchPageRequest(org.broadleafcommerce.openadmin.server.domain.FetchPageRequest) PersistenceResponse(org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse) DynamicResultSet(org.broadleafcommerce.openadmin.dto.DynamicResultSet) BLCSystemProperty(org.broadleafcommerce.common.util.BLCSystemProperty) Property(org.broadleafcommerce.openadmin.dto.Property)

Example 2 with FetchPageRequest

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;
}
Also used : FetchPageRequest(org.broadleafcommerce.openadmin.server.domain.FetchPageRequest) DynamicResultSet(org.broadleafcommerce.openadmin.dto.DynamicResultSet) ListGrid(org.broadleafcommerce.openadmin.web.form.component.ListGrid)

Aggregations

DynamicResultSet (org.broadleafcommerce.openadmin.dto.DynamicResultSet)2 FetchPageRequest (org.broadleafcommerce.openadmin.server.domain.FetchPageRequest)2 HashMap (java.util.HashMap)1 BLCSystemProperty (org.broadleafcommerce.common.util.BLCSystemProperty)1 AdornedTargetCollectionMetadata (org.broadleafcommerce.openadmin.dto.AdornedTargetCollectionMetadata)1 BasicCollectionMetadata (org.broadleafcommerce.openadmin.dto.BasicCollectionMetadata)1 BasicFieldMetadata (org.broadleafcommerce.openadmin.dto.BasicFieldMetadata)1 CollectionMetadata (org.broadleafcommerce.openadmin.dto.CollectionMetadata)1 FieldMetadata (org.broadleafcommerce.openadmin.dto.FieldMetadata)1 Property (org.broadleafcommerce.openadmin.dto.Property)1 PersistenceResponse (org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse)1 ListGrid (org.broadleafcommerce.openadmin.web.form.component.ListGrid)1