/* 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.MediaResource; import no.dusken.aranea.model.Page; import no.dusken.aranea.model.PageMediaResource; import no.dusken.common.service.impl.GenericServiceImpl; import org.springframework.dao.DataAccessException; import org.springframework.dao.support.DataAccessUtils; 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.HashMap; import java.util.Map; @Service("pageMediaResourceService") @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.DEFAULT, readOnly = true) public class PageMediaResourceServiceImpl extends GenericServiceImpl<PageMediaResource> implements PageMediaResourceService { public PageMediaResourceServiceImpl() { super(PageMediaResource.class); } public PageMediaResource getPageMediaResource(Page page, MediaResource mediaResource) { PageMediaResource pmr = null; try { Map<String, Object> map = new HashMap<String, Object>(); map.put("page", page); map.put("mediaResource", mediaResource); pmr = (PageMediaResource) DataAccessUtils.uniqueResult(genericDao .getByNamedQuery("mediaResourcepage_bymediaResourceandpage", map)); } catch (DataAccessException e) { log.error("Error getting PageMediaResource for {} and {}", page, mediaResource); } return pmr; } }