Subversion Repositories SmartDukaan

Rev

Rev 32584 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.web.config;

import com.spice.profitmandi.service.warehouse.BillingWarehouseService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.Map;

@ControllerAdvice(basePackages = "com.spice.profitmandi")

public class ControllerSetup
{
    private static final Logger LOGGER = LogManager.getLogger(ControllerSetup.class);

    @Autowired
    private BillingWarehouseService billingWarehouseService;

    @InitBinder
    public void initBinder ( WebDataBinder binder )
    {
        StringTrimmerEditor stringtrimmer = new StringTrimmerEditor(false);
        binder.registerCustomEditor(String.class, stringtrimmer);
    }

    // Name of any billing warehouse, whatever its status, for views that label rows by the warehouse in the data;
    // $warehouseMap stays the list a screen offers (active only on dashboards).
    @ModelAttribute("warehouseNames")
    public Map<Integer, String> warehouseNames() {
        return billingWarehouseService.getAllNames();
    }
}