All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dream.services.DreamService Maven / Gradle / Ivy

The newest version!
package com.dream.services;

import com.dream.dtos.DreamDTO;
import com.dream.exceptions.NotFoundException;
import com.dream.exceptions.OperationNotPermittedException;
import com.dream.models.Dream;
import com.dream.models.DreamNumbers;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

/**
 * Dream service interface
 */

public interface DreamService {

    /**
     * Create dream from dto
     *
     * @param dream {@link DreamDTO}
     * @return created dream {@link Dream}
     */
    Dream create(DreamDTO dream);

    /**
     * Get dream by id
     *
     * @param id
     * @return {@link Dream}
     * @throws NotFoundException
     */
    DreamDTO getDTOById(Long id) throws NotFoundException;
    
    /**
     * Get dream by id
     *
     * @param id
     * @return {@link Dream}
     * @throws NotFoundException
     */
    Dream getById(Long id) throws NotFoundException;

    /**
     * Delete dream by id
     *
     * @param id
     * @throws NotFoundException
     */
    void delete(Long id) throws NotFoundException;

    /**
     * Update dream from dto
     *
     * @param dream {@link DreamDTO}
     * @return updated dream {@link Dream}
     */
    Dream update(DreamDTO dream);

    /**
     * Like a dream
     *
     * @param id
     * @param ipAddress
     * @return {@link DreamDTO}
     * @throws OperationNotPermittedException
     */
    DreamDTO like(Long id, String ipAddress) throws OperationNotPermittedException;

    /**
     * Dislike a dream
     *
     * @param id
     * @param ipAddress
     * @return {@link DreamDTO}
     * @throws OperationNotPermittedException
     */
    DreamDTO dislike(Long id, String ipAddress) throws OperationNotPermittedException;

    /**
     * Approve a dream
     *
     * @param id
     */
    void approve(Long id);

    /**
     * Add same dream to the dream
     * @param id
     * @param ipAddress
     * @return {@link DreamDTO}
     * @throws OperationNotPermittedException
     */
    DreamDTO addSameDream(Long id, String ipAddress) throws OperationNotPermittedException;

    /**
     * Get a random dream
     *
     * @return {@link Dream}
     * @throws NotFoundException
     */
    DreamDTO getRandom() throws NotFoundException;

    /**
     * Get most liked dream
     *
     * @return {@link Dream}
     * @throws NotFoundException 
     */
    DreamDTO getMostLiked() throws NotFoundException;

    /**
     * Get most disliked dream
     *
     * @return {@link Dream}
     * @throws NotFoundException 
     */
    DreamDTO getMostDisliked() throws NotFoundException;

    /**
     * Get all unapproved dreams
     *
     * @param pageable
     * @return page {@link Dream}
     */
    Page getAllUnapproved(Pageable pageable);

    /**
     * Get all dreams
     *
     * @param tagId    optional param for search by tag id
     * @param pageable
     * @return page {@link Dream}
     */
    Page getAll(String keyword, Long tagId, Pageable pageable);

    /**
     * Get most the same dream
     *
     * @return {@link Dream}
     * @throws NotFoundException 
     */
    DreamDTO getMostSame() throws NotFoundException;
    
    /**
     * Get count of all approved dreams
     *
     * @return {@link Integer} 
     */
    int countAllApprovedDreams();
    
    /**
     * Get count of all approved dreams by tag
     * @param tagId
     * @return {@link Integer} 
     */
    int countAllApprovedByTagId(long tagId);
    
    /**
     * Get id of last approved dream
     * @return {@link Integer} 
     */
    DreamDTO getLastApprovedDream() throws NotFoundException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy