package com.javaeye.jert.service.impl;
import java.util.List;
import com.javaeye.core.service.AbstractService;
import com.javaeye.jert.domain.bookmark.BookmarkFolder;
import com.javaeye.jert.service.BookmarkFolderService;
/**
* @author firebody
* @since 2005-1-5
* @version $Revision: 1.1 $
*/
public class BookmarkFolderServiceImpl extends AbstractService implements
BookmarkFolderService {
/* (non-Javadoc)
* @see com.javaeye.jert.service.BookmarkFolderService#getBookmarkFolder(java.lang.Long)
*/
public BookmarkFolder getBookmarkFolder(Long id) {
return (BookmarkFolder)this.loadById(BookmarkFolder.class,id);
}
/* (non-Javadoc)
* @see com.javaeye.jert.service.BookmarkFolderService#createBookmarkFolder(com.javaeye.jert.domain.BookmarkFolder)
*/
public void createBookmarkFolder(BookmarkFolder bm) {
this.create(bm);
}
/* (non-Javadoc)
* @see com.javaeye.jert.service.BookmarkFolderService#updateBookmarkFolder(com.javaeye.jert.domain.BookmarkFolder)
*/
public void updateBookmarkFolder(BookmarkFolder bm) {
this.update(bm);
}
/* (non-Javadoc)
* @see com.javaeye.jert.service.BookmarkFolderService#deleteBookmarkFolder(com.javaeye.jert.domain.BookmarkFolder)
*/
public void deleteBookmarkFolder(BookmarkFolder bm) {
this.delete(bm);
}
/* (non-Javadoc)
* @see com.javaeye.jert.service.BookmarkFolderService#getBookmarkFoldersByUser(com.javaeye.user.User)
*/
public List getBookmarkFoldersByUserName(String userName) {
List folders=this.findByNamedQuery("findBookmarkFoldersByUser",new Object[]{userName});
if(folders==null||folders.isEmpty()){
createDefaultBMFolder(userName);
return this.findByNamedQuery("findBookmarkFoldersByUser",new Object[]{userName});
}
else
return folders;
}
private void createDefaultBMFolder(String userName){
BookmarkFolder folder=new BookmarkFolder();
folder.setUserName(userName);
folder.setName(BookmarkFolder.DEFAULTNAME);
this.createBookmarkFolder(folder);
}
}