Search in sources :

Example 1 with Bookmark

use of org.c4sg.entity.Bookmark in project c4sg-services by Code4SocialGood.

the class BookmarkServiceImpl method createBookmark.

@Override
public BookmarkDTO createBookmark(Integer userId, Integer projectId) {
    User user = userDAO.findById(userId);
    requireNonNull(user, "Invalid User Id");
    Project project = projectDAO.findById(projectId);
    requireNonNull(project, "Invalid Project Id");
    isBookmarked(userId, projectId);
    Bookmark bookmark = new Bookmark();
    bookmark.setUser(user);
    bookmark.setProject(project);
    bookmarkDAO.save(bookmark);
    return bookmarkMapper.getBookmarkDtoFromEntity(bookmark);
}
Also used : Project(org.c4sg.entity.Project) User(org.c4sg.entity.User) Bookmark(org.c4sg.entity.Bookmark)

Example 2 with Bookmark

use of org.c4sg.entity.Bookmark in project c4sg-services by Code4SocialGood.

the class BookmarkMapper method getBookmarkDtosFromEntities.

public List<BookmarkDTO> getBookmarkDtosFromEntities(List<Bookmark> bookmarks) {
    List<BookmarkDTO> bookmarkList = new ArrayList<BookmarkDTO>();
    Iterator<Bookmark> bookmarkIter = bookmarks.iterator();
    while (bookmarkIter.hasNext()) {
        Bookmark bookmark = bookmarkIter.next();
        bookmarkList.add(getBookmarkDtoFromEntity(bookmark));
    }
    return bookmarkList;
}
Also used : BookmarkDTO(org.c4sg.dto.BookmarkDTO) Bookmark(org.c4sg.entity.Bookmark) ArrayList(java.util.ArrayList)

Example 3 with Bookmark

use of org.c4sg.entity.Bookmark in project c4sg-services by Code4SocialGood.

the class BookmarkMapper method getProjectDtosFromBookmarkEntities.

public List<ProjectDTO> getProjectDtosFromBookmarkEntities(List<Bookmark> bookmarks) {
    List<ProjectDTO> projectList = new ArrayList<ProjectDTO>();
    Iterator<Bookmark> bookmarkIter = bookmarks.iterator();
    while (bookmarkIter.hasNext()) {
        Bookmark bookmark = bookmarkIter.next();
        projectList.add(getProjectDtoFromEntity(bookmark));
    }
    return projectList;
}
Also used : ProjectDTO(org.c4sg.dto.ProjectDTO) Bookmark(org.c4sg.entity.Bookmark) ArrayList(java.util.ArrayList)

Aggregations

Bookmark (org.c4sg.entity.Bookmark)3 ArrayList (java.util.ArrayList)2 BookmarkDTO (org.c4sg.dto.BookmarkDTO)1 ProjectDTO (org.c4sg.dto.ProjectDTO)1 Project (org.c4sg.entity.Project)1 User (org.c4sg.entity.User)1