001/*
002 *  Copyright 2021 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016
017package org.ametys.cms.repository;
018
019import java.time.ZonedDateTime;
020import java.util.List;
021
022import org.ametys.cms.repository.comment.AbstractComment;
023import org.ametys.plugins.repository.AmetysObject;
024import org.ametys.plugins.repository.AmetysRepositoryException;
025
026/**
027 * A commentable ametys object
028 * @param <T> type of the referenced model item
029 */
030public interface CommentableAmetysObject<T extends AbstractComment> extends AmetysObject
031{
032    /**
033     * Creates a comment
034     * @return The new comment
035     */
036    public T createComment();
037    
038    /**
039     * Creates a comment with the given id and creation date
040     * This method allow to create a comment from existing data (ex: data import from archive)
041     * The id is not generated here, the source is trusted. Be careful using this method
042     * @param commentId the comment's id
043     * @param creationDate the comment's creation date
044     * @return the new comment
045     */
046    public T createComment(String commentId, ZonedDateTime creationDate);
047    
048    /**
049     * Get a comment
050     * @param commentId The comment
051     * @return The comment
052     * @throws AmetysRepositoryException if  error occurs
053     */
054    public T getComment(String commentId) throws AmetysRepositoryException;
055
056    /**
057     * Get the list of available comments (validated, not validated, both or none :))
058     * @param includeNotValidatedComments true to get the non validated comments.
059     * @param includeValidatedComments true to get the validated comment.
060     * @return A non null list of comments on the ametys object.
061     * @throws AmetysRepositoryException if an error occurred
062     */
063    public List<T> getComments(boolean includeNotValidatedComments, boolean includeValidatedComments) throws AmetysRepositoryException;
064}