/** * Copyright 2011 the original author or authors. * * 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 org.bricket.plugin.gallery.service.impl; import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import org.bricket.plugin.gallery.domain.Gallery; import org.bricket.plugin.gallery.repository.GalleryDao; import org.bricket.plugin.gallery.service.GalleryService; import org.bricket.plugin.picture.domain.Picture; import org.bricket.plugin.picture.service.PictureService; import org.bricket.service.BricketServiceException; import org.bricket.service.BricketServiceImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; /** * @author Ingo Renner * @author Henning Teek * */ @Service(value = "galleryService") @Transactional(readOnly = true) public class GalleryServiceImpl extends BricketServiceImpl implements GalleryService { private final Logger log = LoggerFactory.getLogger(GalleryServiceImpl.class); @Resource private GalleryDao galleryDao; @Resource private PictureService pictureService; @Override protected void onInit() { log.info("gallery service initialized"); } @Override @Transactional public Gallery saveGallery(Gallery gallery) throws BricketServiceException { return galleryDao.save(gallery); } @Override @Transactional public void deleteGallery(Gallery gallery) throws BricketServiceException { galleryDao.delete(galleryDao.readByPrimaryKey(gallery.getId())); } @Override public Gallery loadGallery(Long id) { return galleryDao.readByPrimaryKey(id); } @Override public List<Gallery> loadAllGallery() { return galleryDao.readAll(); } @Override public Gallery createDomainObject() { Gallery gallery = new Gallery(); gallery.setSubGalleries(new ArrayList<Gallery>()); gallery.setPictures(new ArrayList<Picture>()); return gallery; } @Override public List<Picture> loadAvailablePictures() { return pictureService.loadAllPicture(); } }