package no.dusken.aranea.web.control;
import no.dusken.aranea.model.BannerLocation;
import no.dusken.aranea.service.BannerLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.LinkedList;
import java.util.List;
/**
* @author Marvin B. Lillehaug <lillehau@underdusken.no>
*/
@Controller
public class BannerLocationController {
private BannerLocationService bannerLocationService;
@RequestMapping("/bannerlocations.do")
public String handleBannerLocations(@RequestParam long[] bannerlocations, Model model){
List<BannerLocation> bannerLocationlist = new LinkedList<BannerLocation>();
for(long blid : bannerlocations){
BannerLocation bannerLocation = bannerLocationService.getEntity(blid);
if(bannerLocation != null && bannerLocation.getBanner() != null){
bannerLocationlist.add(bannerLocation);
}
}
model.addAttribute("bannerlocations", bannerLocationlist);
return "no/dusken/aranea/base/web/bannerlocation/view";
}
@RequestMapping("/bannerlocationByName.do")
public String handleBannerLocationsByName(@RequestParam String[] urls, Model model) {
List<BannerLocation> bannerLocationlist = new LinkedList<BannerLocation>();
for(String url : urls){
BannerLocation bannerLocation = bannerLocationService.getByUrl(url);
if(bannerLocation != null && bannerLocation.getBanner() != null){
bannerLocationlist.add(bannerLocation);
}
}
model.addAttribute("bannerlocations", bannerLocationlist);
return "no/dusken/aranea/base/web/bannerlocation/view";
}
@Required
@Autowired
public void setBannerLocationService(BannerLocationService bannerLocationService) {
this.bannerLocationService = bannerLocationService;
}
}