Example usage for org.springframework.ui ModelMap addAllAttributes

List of usage examples for org.springframework.ui ModelMap addAllAttributes

Introduction

In this page you can find the example usage for org.springframework.ui ModelMap addAllAttributes.

Prototype

public ModelMap addAllAttributes(@Nullable Map<String, ?> attributes) 

Source Link

Document

Copy all attributes in the supplied Map into this Map .

Usage

From source file:ru.codemine.ccms.router.CountersRouter.java

@Secured("ROLE_USER")
@RequestMapping(value = "/counters", method = RequestMethod.GET)
public String getCountersPage(@RequestParam Integer shopid, ModelMap model) {
    Shop shop = shopService.getById(shopid);

    model.addAllAttributes(utils.prepareModel());
    model.addAttribute("shop", shop);

    List<String> graphDataInList = new ArrayList<>();
    List<String> graphDataOutList = new ArrayList<>();

    List<Counter> countersAll = counterService.getByShop(shop);
    List<Counter> counters = new ArrayList<>();
    for (Counter counter : countersAll) {
        if (!counter.getDate().plusMonths(1).isBeforeNow()) {
            graphDataInList.add(counter.getGraphDataIn());
            graphDataOutList.add(counter.getGraphDataOut());
            counters.add(counter);/*from   w  w w.ja v  a  2s  . c o m*/
        }
    }

    model.addAttribute("counters", counters);
    model.addAttribute("graphDataIn", graphDataInList);
    model.addAttribute("graphDataOut", graphDataOutList);

    return "pages/shops/counters";
}

From source file:ru.codemine.ccms.router.ContentRouter.java

@RequestMapping(value = "/", method = RequestMethod.GET)
public String getIndex(ModelMap model) {
    model.addAllAttributes(utils.prepareModel());

    return "index";
}

From source file:ru.codemine.ccms.router.ContentRouter.java

@RequestMapping(value = "/403")
public String errorDenied(ModelMap model) {
    model.addAllAttributes(utils.prepareModel());

    return "403";
}

From source file:ru.codemine.ccms.router.ContentRouter.java

@RequestMapping(value = "/404")
public String errorNotFound(ModelMap model) {
    model.addAllAttributes(utils.prepareModel());

    return "404";
}

From source file:ru.codemine.ccms.router.ContentRouter.java

@Secured("ROLE_USER")
@RequestMapping(value = "/offices", method = RequestMethod.GET)
public String getOffices(ModelMap model, @RequestParam(required = false) String mode) {
    model.addAllAttributes(utils.prepareModel());
    model.addAttribute("alloffices", officeService.getAll());

    return "print".equals(mode) ? "printforms/offices" : "pages/offices/officesAll";
}

From source file:ru.codemine.ccms.router.ContentRouter.java

@Secured("ROLE_USER")
@RequestMapping(value = "/employees", method = RequestMethod.GET)
public String getEmployees(ModelMap model, @RequestParam(required = false) String mode) {
    model.addAllAttributes(utils.prepareModel());
    model.addAttribute("allemps", employeeService.getAll());

    return "print".equals(mode) ? "printforms/employees" : "pages/employees/employeesAll";
}

From source file:ru.codemine.ccms.router.ContentRouter.java

@Secured("ROLE_USER")
@RequestMapping(value = "/organisations", method = RequestMethod.GET)
public String getOrganisations(ModelMap model, @RequestParam(required = false) String mode) {
    model.addAllAttributes(utils.prepareModel());
    model.addAttribute("allorgs", organisationService.getAll());

    return "print".equals(mode) ? "/printforms/organisations" : "pages/organisations/organisationsAll";
}

From source file:ru.codemine.ccms.router.ContentRouter.java

@RequestMapping(value = "/shops", method = RequestMethod.GET)
public String getShops(ModelMap model, @RequestParam(required = false) String mode) {
    model.addAllAttributes(utils.prepareModel());
    model.addAttribute("allshops", shopService.getAll());
    model.addAttribute("allorgs", organisationService.getAll());

    if ("print".equals(mode)) {
        model.addAttribute("openshops", shopService.getAllOpen());
        return "/printforms/shops";
    }/*from w w  w.  j ava2 s  .c  o  m*/

    return "pages/shops/shopsAll";
}

From source file:ru.codemine.ccms.router.ContentRouter.java

@RequestMapping(value = "/login", method = RequestMethod.GET)
public String getLogin(ModelMap model, @RequestParam(required = false) boolean error) {
    model.addAllAttributes(utils.prepareModel());

    List<Employee> activeEmpsList = employeeService.getActive();
    Map<String, String> upperMap = new LinkedHashMap();
    Map<String, String> lowerMap = new LinkedHashMap();
    Map<String, String> loginMap = new LinkedHashMap();
    for (Employee employee : activeEmpsList) {
        List<Shop> empShopsList = shopService.getShopsRuledBy(employee);
        if (empShopsList != null && !empShopsList.isEmpty()) {
            String shopsString = "";
            for (Shop s : empShopsList) {
                shopsString = shopsString + ", " + s.getName();
            }/*www.  j av a 2 s .  co m*/
            shopsString = shopsString.substring(2); //   ?

            lowerMap.put(employee.getUsername(), employee.getFullName() + " (" + shopsString + ")");
        } else {
            upperMap.put(employee.getUsername(), employee.getFullName());
        }
    }

    loginMap.put("#nologin1", "   --  ? --");
    loginMap.putAll(upperMap);
    loginMap.put("#nologin2", "          --  --");
    loginMap.putAll(lowerMap);

    model.addAttribute("loginMap", loginMap);

    return "login";
}

From source file:ru.codemine.ccms.router.ContentRouter.java

@Secured("ROLE_USER")
@RequestMapping(value = "/shop", method = RequestMethod.GET)
public String getShop(ModelMap model, @RequestParam Integer id, @RequestParam(required = false) String mode) {
    Shop shop = shopService.getById(id);
    model.addAllAttributes(utils.prepareModel());
    model.addAttribute("shop", shop);

    return "print".equals(mode) ? "/printforms/shopfrm" : "pages/shops/shop";
}