package no.dusken.aranea.web.control;
import no.dusken.aranea.model.Banner;
import no.dusken.aranea.model.BannerLocation;
import no.dusken.aranea.model.Page;
import no.dusken.aranea.model.Section;
import no.dusken.aranea.service.BannerLocationService;
import no.dusken.aranea.service.PageService;
import no.dusken.aranea.service.SectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Marvin B. Lillehaug <lillehau@underdusken.no>
*/
public class AdditionalSectionController extends AbstractController {
private BannerLocationService bannerLocationService;
private SectionService sectionService;
private PageService pageService;
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
List<BannerLocation> bannerLocations = bannerLocationService
.getBannerLocations();
for (BannerLocation bannerLocation : bannerLocations) {
Banner banner = bannerLocation.getBanner();
if (banner != null) {
map.put("banner" + bannerLocation.getID(), banner);
}
}
Section meninger = sectionService.getSectionByUrl("meninger", null);
List<Page> pages = pageService.getSectionPagePublished(1, meninger);
map.put("mening", pages);
return new ModelAndView("section/view", map);
}
@Required
@Autowired
public void setBannerLocationService(BannerLocationService bannerLocationService) {
this.bannerLocationService = bannerLocationService;
}
@Required
@Autowired
public void setSectionService(SectionService sectionService) {
this.sectionService = sectionService;
}
@Required
@Autowired
public void setPageService(PageService pageService) {
this.pageService = pageService;
}
}