// Path: src/main/java/com/hillert/botanic/dao/ImageRepository.java
// public interface ImageRepository extends CrudRepository<Image, Long>, ImageRepositoryCustom {
// }
// 
// Path: src/main/java/com/hillert/botanic/model/Image.java
// @Entity
// public class Image extends BaseModelObject {
// 
// 	private String name;
// 
// 	@Lob
// 	private byte[] image;
// 
// 	@ManyToOne
// 	private Plant plant;
// 
// 	public Image(String name, Resource data, Plant plant) {
// 		super();
// 		this.name = name;
// 		this.plant = plant;
// 
// 		InputStream is = null;
// 		try {
// 			is = data.getInputStream();
// 			this.image = StreamUtils.copyToByteArray(is);
// 			is.close();
// 		} catch (IOException e) {
// 			// TODO Auto-generated catch block
// 			e.printStackTrace();
// 		}
// 		finally {
// 			try {
// 				if (is != null) {
// 					is.close();
// 				}
// 			} catch (IOException e) {
// 				e.printStackTrace();
// 			}
// 		}
// 	}
// 
// 	public Image() {
// 		super();
// 	}
// 
// 	/**
// 	 * @return the name
// 	 */
// 	public String getName() {
// 		return name;
// 	}
// 	/**
// 	 * @param name the name to set
// 	 */
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	/**
// 	 * @return the image
// 	 */
// 	public byte[] getImage() {
// 		return image;
// 	}
// 	/**
// 	 * @param image the image to set
// 	 */
// 	public void setImage(byte[] image) {
// 		this.image = image;
// 	}
// 
// 	/**
// 	 * @return the plant
// 	 */
// 	public Plant getPlant() {
// 		return plant;
// 	}
// 	/**
// 	 * @param plant the plant to set
// 	 */
// 	public void setPlant(Plant plant) {
// 		this.plant = plant;
// 	}
// 
// }


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import com.hillert.botanic.dao.ImageRepository;
import com.hillert.botanic.model.Image;
/*
 * Copyright 2014 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 com.hillert.botanic.service;



/**
*
* @author Gunnar Hillert
* @since 1.0
*
*/
@Service
public class DefaultPictureService implements PictureService {

	private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPictureService.class);

	@Autowired
	private SimpMessageSendingOperations messagingTemplate;

	@Autowired
// Path: src/main/java/com/hillert/botanic/dao/ImageRepository.java
// public interface ImageRepository extends CrudRepository<Image, Long>, ImageRepositoryCustom {
// }
// 
// Path: src/main/java/com/hillert/botanic/model/Image.java
// @Entity
// public class Image extends BaseModelObject {
// 
// 	private String name;
// 
// 	@Lob
// 	private byte[] image;
// 
// 	@ManyToOne
// 	private Plant plant;
// 
// 	public Image(String name, Resource data, Plant plant) {
// 		super();
// 		this.name = name;
// 		this.plant = plant;
// 
// 		InputStream is = null;
// 		try {
// 			is = data.getInputStream();
// 			this.image = StreamUtils.copyToByteArray(is);
// 			is.close();
// 		} catch (IOException e) {
// 			// TODO Auto-generated catch block
// 			e.printStackTrace();
// 		}
// 		finally {
// 			try {
// 				if (is != null) {
// 					is.close();
// 				}
// 			} catch (IOException e) {
// 				e.printStackTrace();
// 			}
// 		}
// 	}
// 
// 	public Image() {
// 		super();
// 	}
// 
// 	/**
// 	 * @return the name
// 	 */
// 	public String getName() {
// 		return name;
// 	}
// 	/**
// 	 * @param name the name to set
// 	 */
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	/**
// 	 * @return the image
// 	 */
// 	public byte[] getImage() {
// 		return image;
// 	}
// 	/**
// 	 * @param image the image to set
// 	 */
// 	public void setImage(byte[] image) {
// 		this.image = image;
// 	}
// 
// 	/**
// 	 * @return the plant
// 	 */
// 	public Plant getPlant() {
// 		return plant;
// 	}
// 	/**
// 	 * @param plant the plant to set
// 	 */
// 	public void setPlant(Plant plant) {
// 		this.plant = plant;
// 	}
// 
// }


// Path: src/main/java/com/hillert/botanic/service/DefaultPictureService.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import com.hillert.botanic.dao.ImageRepository;
import com.hillert.botanic.model.Image;

/*
 * Copyright 2014 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 com.hillert.botanic.service;



/**
*
* @author Gunnar Hillert
* @since 1.0
*
*/
@Service
public class DefaultPictureService implements PictureService {

	private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPictureService.class);

	@Autowired
	private SimpMessageSendingOperations messagingTemplate;

	@Autowired
	private ImageRepository imageRepository;