/*******************************************************************************
 * MIT License
 *
 * Copyright (c) 2017 Piotr Rusin <piotr.rusin88@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *******************************************************************************/
package com.github.piotr_rusin.yule.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.github.piotr_rusin.yule.domain.Article;

/**
 * @author Piotr Rusin <piotr.rusin88@gmail.com>
 *
 */
public interface ArticleRepository extends JpaRepository<Article, Integer>,
JpaSpecificationExecutor<Article> {

	@Query(
		"select a from Article a where a.post = true " +
		" and a.status = 'PUBLIC' order by a.publicationDate desc"
	)
	Page<Article> findPublicPosts(Pageable pageRequest);

	@Query(
		"select a from Article a where a.post = true " +
		"and a.status = 'PUBLIC' and a.slug = :slug"
	)
	Article findPublicPostBy(@Param("slug") String slug);

	@Query(
		"select a from Article a where a.post = false " +
		"and a.status = 'PUBLIC' and a.slug = :slug"
	)
	Article findPublicPageBy(@Param("slug") String slug);

	Article findOneBySlug(String slug);
}

/*******************************************************************************
 * MIT License
 *
 * Copyright (c) 2017 Piotr Rusin <piotr.rusin88@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *******************************************************************************/
package com.github.piotr_rusin.yule.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.github.piotr_rusin.yule.domain.Article;

public interface ArticleRepository extends JpaRepository<Article, Integer>,
JpaSpecificationExecutor<Article> {

	@Query(
		"select a from Article a where a.post = true " +
		" and a.status = 'PUBLIC' order by a.publicationDate desc"
	)
	Page<Article> findPublicPosts(Pageable pageRequest);

	@Query(
		"select a from Article a where a.post = true " +
		"and a.status = 'PUBLIC' and a.slug = :slug"
	)
	Article findPublicPostBy(@Param("slug") String slug);

	@Query(
		"select a from Article a where a.post = false " +
		"and a.status = 'PUBLIC' and a.slug = :slug"
	)
	Article findPublicPageBy(@Param("slug") String slug);

	Article findOneBySlug(String slug);
}

Remove an unnecessary docstring