001/*
002 *  Copyright 2013 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 */
016package org.ametys.plugins.repository.metadata;
017
018import java.util.Date;
019import java.util.List;
020
021/**
022 * Commentable {@link CompositeMetadata}.
023 */
024public interface CommentableCompositeMetadata extends CompositeMetadata
025{
026    /**
027     * Retrieves the comments of a metadata
028     * @param metadataName The metadata name
029     * @return the list of {@link MetadataComment}
030     */
031    List<MetadataComment> getComments(String metadataName);
032    
033    /**
034     * Indicates if a metadata has any comments
035     * @param metadataName The metadata name
036     * @return true if at least one comment exists for this metadata
037     */
038    boolean hasComments(String metadataName);
039    
040    /**
041     * Indicates if a metadata has a comment
042     * @param metadataName The metadata name
043     * @param index The comment index
044     * @return true if a comment at this index exists for this metadata
045     */
046    boolean hasComment(String metadataName, int index);
047    
048    /**
049     * Add a metadata comment.
050     * @param metadataName The metadata name
051     * @param text The text of the comment
052     * @param author The comment author
053     * @param date The date of the comment (null to use the current date)
054     */
055    void addComment(String metadataName, String text, String author, Date date);
056    
057    /**
058     * Edit the text of a metadata comment.
059     * @param metadataName The metadata name
060     * @param index The comment index
061     * @param text The new text for the comment
062     * @param author The comment author
063     * @param date The date of the comment (null to use the current date) 
064     */
065    void editComment(String metadataName, int index, String text, String author, Date date);
066    
067    /**
068     * Delete a metadata comment.
069     * @param metadataName The metadata name
070     * @param index The comment index
071     */
072    void deleteComment(String metadataName, int index);
073}