001/*
002 *  Copyright 2023 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.workspaces.forum;
017
018import java.time.ZonedDateTime;
019import java.util.List;
020
021import org.ametys.cms.data.RichText;
022import org.ametys.cms.data.ametysobject.ModifiableModelAwareDataAwareAmetysObject;
023import org.ametys.cms.repository.AttachableAmetysObject;
024import org.ametys.cms.repository.CommentableAmetysObject;
025import org.ametys.cms.repository.comment.RichTextComment;
026import org.ametys.core.user.UserIdentity;
027import org.ametys.plugins.repository.AmetysRepositoryException;
028import org.ametys.plugins.repository.RemovableAmetysObject;
029import org.ametys.plugins.repository.tag.TaggableAmetysObject;
030
031/**
032 * Interface representing a forum's thread
033 */
034public interface Thread extends ModifiableModelAwareDataAwareAmetysObject, RemovableAmetysObject, TaggableAmetysObject, AttachableAmetysObject, CommentableAmetysObject<RichTextComment>
035{
036    /** Attribute Threadid */
037    public static final String ATTRIBUTE_ID = "id";
038    /** Attribute Label */
039    public static final String ATTRIBUTE_TITLE = "title";
040    /** Attribute Description */
041    public static final String ATTRIBUTE_CONTENT = "content";
042    /** Attribute Description for editing */
043    public static final String ATTRIBUTE_CONTENT_FOR_EDITING = "contentEditing";
044    /** Attribute Description for editing */
045    public static final String ATTRIBUTE_CONTENT_FOR_RENDERING = "contentRendering";
046    /** Attribute Description abstract */
047    public static final String ATTRIBUTE_CONTENT_ABSTRACT = "contentAbstract";
048    /** Attribute Author */
049    public static final String ATTRIBUTE_AUTHOR = "author";
050    /** Attribute Creationdate */
051    public static final String ATTRIBUTE_CREATIONDATE = "creationDate";
052    /** Attribute Lastmodified */
053    public static final String ATTRIBUTE_LASTMODIFIED = "lastModified";
054    /** Attribute LastContribution : set on creation, updated for each anwer added */
055    public static final String ATTRIBUTE_LASTCONTRIBUTION = "lastContribution";
056    /** Attribute Category */
057    public static final String ATTRIBUTE_CATEGORY = "category";
058    /** Attribute Category */
059    public static final String ATTRIBUTE_CLOSEAUTHOR = "closeAuthor";
060    /** Attribute Category */
061    public static final String ATTRIBUTE_CLOSEDATE = "closeDate";
062    /** Attribute Attachments */
063    public static final String ATTRIBUTE_ATTACHMENTS = "attachments";
064    /** Attribute Tags */
065    public static final String ATTRIBUTE_TAGS = "tags";
066    /** Attribute Comments */
067    public static final String ATTRIBUTE_COMMENTS = "comments";
068    /** Attribute CommentsLength, used to get number of comments without parsing them */
069    public static final String ATTRIBUTE_COMMENTS_LENTGH = "commentsLength";
070    /** Attribute CommentAuthors, used to get number of comments without parsing them */
071    public static final String ATTRIBUTE_COMMENTS_AUTHORS = "commentAuthors";
072    /** Computed hasNotificationDot attribute */
073    public static final String HAS_UNOPENED_THREAD_NOTIFICATION = "hasUnopenedThreadNotification";
074    /** Computed acceptedAnswer attribute */
075    public static final String ACCEPTED_ANSWER_COMMENT_ID = "acceptedAnswer";
076    /** Computed unreadComments attribute */
077    public static final String UNREAD_COMMENTS = "unreadComments";
078    /** Computed isAuthor attribute */
079    public static final String IS_AUTHOR = "isAuthor";
080    
081    /**
082     * The title of the thread
083     * @return The title
084     */
085    public String getTitle();
086    
087    /**
088     * Set the title of the thread
089     * @param title The title
090     */
091    public void setTitle(String title);
092    
093    /**
094     * The content of the thread
095     * @return The content
096     */
097    public RichText getContent();
098    
099    /**
100     * Set the content of the thread
101     * @param content The content
102     */
103    public void setContent(RichText content);
104    
105    /**
106     * Get the author of the thread
107     * @return the author
108     */
109    public UserIdentity getAuthor();
110    
111    /**
112     * Set the author of this thread.
113     * @param author the author
114     */
115    public void setAuthor(UserIdentity author);
116
117    /**
118     * Get the thread's creation date.
119     * @return the thread's creation date.
120     */
121    public ZonedDateTime getCreationDate();
122    
123    /**
124     * Set the thread's creation date.
125     * @param startDate the task's creation date.
126     */
127    public void setCreationDate(ZonedDateTime startDate);
128
129    /**
130     * Get the thread's last modification date.
131     * @return the thread's last modification date.
132     */
133    public ZonedDateTime getLastModified();
134    
135    /**
136     * Set the thread's modification date.
137     * @param date the last modification date to set.
138     */
139    public void setLastModified(ZonedDateTime date);
140
141    /**
142     * Get the thread's last contribution date.
143     * @return the thread's last contribution date.
144     */
145    public ZonedDateTime getLastContribution();
146    
147    /**
148     * Set the thread's contribution date.
149     * @param date the last contribution date to set.
150     */
151    public void setLastContribution(ZonedDateTime date);
152
153    /**
154     * The category of the thread
155     * @return The category
156     */
157    public ThreadCategoryEnum getCategory();
158    
159    /**
160     * Set the category of the thread
161     * @param category The category
162     */
163    public void setCategory(ThreadCategoryEnum category);
164    
165    /**
166     * Get the close author of the thread
167     * @return the close author
168     */
169    public UserIdentity getCloseAuthor();
170    
171    /**
172     * Set the close author of this thread.
173     * @param author the close author
174     */
175    public void setCloseAuthor(UserIdentity author);
176
177    /**
178     * Get the thread's close date.
179     * @return the thread's close date.
180     */
181    public ZonedDateTime getCloseDate();
182    
183    /**
184     * Set the thread's close date.
185     * @param date the close date to set.
186     */
187    public void setCloseDate(ZonedDateTime date);
188
189    /**
190     * Get the accepted answer.
191     * @return the accepted answer if present, null otherwise.
192     */
193    public RichTextComment getAcceptedAnswer();
194    
195    /**
196     * Get the list of available comments (validated, not validated, both or none :))
197     * @param includeNotValidatedComments true to get the non validated comments.
198     * @param includeValidatedComments true to get the validated comment.
199     * @return A non null list of comments on the ametys object.
200     * @throws AmetysRepositoryException if an error occurred
201     */
202    public List<RichTextComment> getFlattenComments(boolean includeNotValidatedComments, boolean includeValidatedComments) throws AmetysRepositoryException;
203
204}