/* Copyright 2006 - 2010 Under Dusken Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package no.dusken.aranea.service; import no.dusken.aranea.model.Page; import no.dusken.aranea.model.Person; import no.dusken.aranea.model.Section; import org.springframework.dao.DataAccessException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.util.*; /** * * @author Erlend Hamnaberg<erlenha@underdusken.no> * @author Marvin B. Lillehaug <lillehau@underdusken.no> */ @Service("pageService") @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.DEFAULT, readOnly = true) public class PageServiceImpl extends AbstractPageServiceImpl<Page> implements PageService { public PageServiceImpl() { super(Page.class); } public List<Page> getSectionPagePublished(int numberOfPages, Section section) { List<Page> pages = Collections.emptyList(); try { Map<String, Object> map = new HashMap<String, Object>(); map.put("time", new GregorianCalendar()); map.put("section", section); pages = genericDao.getByNamedQuery("page_bysection_published", map, 0, numberOfPages); } catch (DataAccessException e) { log.error("Unable to get pages by section", e); } return pages; } public List<Person> getPhotographers(Page page) { List<Person> list = Collections.emptyList(); try { Map<String, Object> map = new HashMap<String, Object>(); map.put("page", page); list = genericDao.getByNamedQuery("photographers_bypage", map); } catch (DataAccessException dae) { log.info("Unable to get photographs", dae); } return list; } public List<Person> getDrawers(Page page) { List<Person> list = Collections.emptyList(); try { Map<String, Object> map = new HashMap<String, Object>(); map.put("page", page); list = genericDao.getByNamedQuery("drawers_bypage", map); } catch (DataAccessException dae) { log.info("Unable to get drawers", dae); } return list; } public List<Page> getPages(int offset, int number) { List<Page> list = Collections.emptyList(); try { list = genericDao.getByNamedQuery("page_all", null, offset, number); } catch (DataAccessException dae) { log.info("Unable to get pages", dae); } return list; } public List<Page> getNotPublishedPages(int offset, int number) { List<Page> list = Collections.emptyList(); try { list = genericDao.getByNamedQuery("page_all_not_published", null, offset, number); } catch (DataAccessException dae) { log.info("Unable to get pages", dae); } return list; } }