Search in sources :

Example 1 with CustomPersistenceHandlerFilter

use of org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandlerFilter in project BroadleafCommerce by BroadleafCommerce.

the class PersistenceManagerImpl method getCustomPersistenceHandlers.

@Override
public List<CustomPersistenceHandler> getCustomPersistenceHandlers() {
    List<CustomPersistenceHandler> cloned = new ArrayList<>();
    cloned.addAll(customPersistenceHandlers);
    if (getCustomPersistenceHandlerFilters() != null) {
        for (CustomPersistenceHandlerFilter filter : getCustomPersistenceHandlerFilters()) {
            Iterator<CustomPersistenceHandler> itr = cloned.iterator();
            while (itr.hasNext()) {
                CustomPersistenceHandler handler = itr.next();
                if (!filter.shouldUseHandler(handler.getClass().getName())) {
                    itr.remove();
                }
            }
        }
    }
    Collections.sort(cloned, new Comparator<CustomPersistenceHandler>() {

        @Override
        public int compare(CustomPersistenceHandler o1, CustomPersistenceHandler o2) {
            return new Integer(o1.getOrder()).compareTo(new Integer(o2.getOrder()));
        }
    });
    return cloned;
}
Also used : CustomPersistenceHandler(org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandler) ArrayList(java.util.ArrayList) CustomPersistenceHandlerFilter(org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandlerFilter)

Aggregations

ArrayList (java.util.ArrayList)1 CustomPersistenceHandler (org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandler)1 CustomPersistenceHandlerFilter (org.broadleafcommerce.openadmin.server.service.handler.CustomPersistenceHandlerFilter)1