forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-45092 Create a new tool for handling conversations in Sakai (saka…
- Loading branch information
1 parent
eed5c1d
commit 4b3c9eb
Showing
189 changed files
with
14,551 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.sakaiproject.conversations</groupId> | ||
<artifactId>sakai-conversations-base</artifactId> | ||
<version>22-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>sakai-conversations-api</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>sakai-conversations-api</name> | ||
|
||
<properties> | ||
<deploy.target>shared</deploy.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.sakaiproject.kernel</groupId> | ||
<artifactId>sakai-kernel-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
12 changes: 12 additions & 0 deletions
12
...i/src/main/java/org/sakaiproject/conversations/api/ConversationsPermissionsException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.sakaiproject.conversations.api; | ||
|
||
public class ConversationsPermissionsException extends Exception { | ||
|
||
public ConversationsPermissionsException() { | ||
super(); | ||
} | ||
|
||
public ConversationsPermissionsException(String message) { | ||
super(message); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
conversations/api/src/main/java/org/sakaiproject/conversations/api/ConversationsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.sakaiproject.conversations.api; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import java.time.Instant; | ||
|
||
import org.sakaiproject.conversations.api.Reaction; | ||
import org.sakaiproject.conversations.api.beans.CommentTransferBean; | ||
import org.sakaiproject.conversations.api.beans.PostTransferBean; | ||
import org.sakaiproject.conversations.api.beans.TopicTransferBean; | ||
import org.sakaiproject.conversations.api.model.ConvStatus; | ||
import org.sakaiproject.conversations.api.model.Settings; | ||
import org.sakaiproject.conversations.api.model.Tag; | ||
|
||
public interface ConversationsService { | ||
|
||
public static String SORT_NAME_ASCENDING = "nameAscending"; | ||
public static String SORT_NAME_DESCENDING = "nameDescending"; | ||
public static String SORT_TOPICS_CREATED_ASCENDING = "topicsCreatedAscending"; | ||
public static String SORT_TOPICS_CREATED_DESCENDING = "topicsCreatedDescending"; | ||
public static String SORT_TOPICS_VIEWED_ASCENDING = "topicsViewedAscending"; | ||
public static String SORT_TOPICS_VIEWED_DESCENDING = "topicsViewedDescending"; | ||
public static String SORT_POSTS_CREATED_ASCENDING = "postsCreatedAscending"; | ||
public static String SORT_POSTS_CREATED_DESCENDING = "postsCreatedDescending"; | ||
public static String SORT_REACTIONS_MADE_ASCENDING = "reactionsMadeAscending"; | ||
public static String SORT_REACTIONS_MADE_DESCENDING = "reactionsMadeDescending"; | ||
|
||
List<TopicTransferBean> getTopicsForSite(String siteId) throws ConversationsPermissionsException; | ||
TopicTransferBean saveTopic(TopicTransferBean topicBean) throws ConversationsPermissionsException; | ||
boolean deleteTopic(String topicId) throws ConversationsPermissionsException; | ||
void pinTopic(String topicId, boolean pinned) throws ConversationsPermissionsException; | ||
TopicTransferBean lockTopic(String topicId, boolean locked) throws ConversationsPermissionsException; | ||
void hideTopic(String topicId, boolean hidden) throws ConversationsPermissionsException; | ||
void bookmarkTopic(String topicId, boolean bookmarked) throws ConversationsPermissionsException; | ||
Map<Reaction, Integer> saveTopicReactions(String topicId, Map<Reaction, Boolean> reactions) throws ConversationsPermissionsException; | ||
|
||
PostTransferBean savePost(PostTransferBean postBean) throws ConversationsPermissionsException; | ||
List<PostTransferBean> getPostsByTopicId(String siteId, String topicId) throws ConversationsPermissionsException; | ||
boolean deletePost(String siteId, String topicId, String postId, boolean setTopicResolved) throws ConversationsPermissionsException; | ||
PostTransferBean upvotePost(String siteId, String topicId, String postId) throws ConversationsPermissionsException; | ||
PostTransferBean unUpvotePost(String siteId, String postId) throws ConversationsPermissionsException; | ||
PostTransferBean lockPost(String siteId, String topicId, String postId, boolean locked) throws ConversationsPermissionsException; | ||
void hidePost(String postId, boolean hidden, String siteId) throws ConversationsPermissionsException; | ||
Map<Reaction, Integer> savePostReactions(String postId, Map<Reaction, Boolean> reactions) throws ConversationsPermissionsException; | ||
void markPostsViewed(Set<String> postIds, String topicId) throws ConversationsPermissionsException; | ||
|
||
CommentTransferBean saveComment(CommentTransferBean commentBean) throws ConversationsPermissionsException; | ||
boolean deleteComment(String siteId, String commentId) throws ConversationsPermissionsException; | ||
|
||
List<Tag> createTags(List<Tag> tags) throws ConversationsPermissionsException; | ||
Tag saveTag(Tag tag) throws ConversationsPermissionsException; | ||
List<Tag> getTagsForSite(String siteId) throws ConversationsPermissionsException; | ||
void deleteTag(Long tagId) throws ConversationsPermissionsException; | ||
|
||
Settings getSettingsForSite(String siteId) throws ConversationsPermissionsException; | ||
Settings saveSettings(Settings settings) throws ConversationsPermissionsException; | ||
|
||
ConvStatus getConvStatusForSiteAndUser(String siteId, String userId) throws ConversationsPermissionsException; | ||
void saveConvStatus(ConvStatus convStatus) throws ConversationsPermissionsException; | ||
Map<String, Object> getSiteStats(String siteId, Instant from, Instant to, int page, String sort) throws ConversationsPermissionsException; | ||
} |
28 changes: 28 additions & 0 deletions
28
conversations/api/src/main/java/org/sakaiproject/conversations/api/ConversationsStat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/****************************************************************************** | ||
* Copyright 2015 sakaiproject.org Licensed under the Educational | ||
* Community License, Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/ECL-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
******************************************************************************/ | ||
package org.sakaiproject.conversations.api; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class ConversationsStat { | ||
|
||
public String name; | ||
public Long topicsCreated; | ||
public Long topicsViewed; | ||
public Long postsCreated; | ||
public Long reactionsMade; | ||
} |
24 changes: 24 additions & 0 deletions
24
conversations/api/src/main/java/org/sakaiproject/conversations/api/Events.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.sakaiproject.conversations.api; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public enum Events { | ||
TOPIC_CREATED("conversations.topic.created"), | ||
TOPIC_DELETED("conversations.topic.updated"), | ||
TOPIC_UPDATED("conversations.topic.deleted"), | ||
POST_CREATED("conversations.post.created"), | ||
POST_DELETED("conversations.post.updated"), | ||
POST_UPDATED("conversations.post.deleted"), | ||
REACTED_TO_TOPIC("conversations.topic.reacted"), | ||
UNREACTED_TO_TOPIC("conversations.topic.unreacted"); | ||
|
||
public final String label; | ||
|
||
private Events(String label) { | ||
this.label = label; | ||
} | ||
|
||
public static Stream<Events> stream() { | ||
return Stream.of(Events.values()); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
conversations/api/src/main/java/org/sakaiproject/conversations/api/Permissions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.sakaiproject.conversations.api; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public enum Permissions { | ||
ROLETYPE_INSTRUCTOR("conversations.roletype.instructor"), | ||
MODERATE("conversations.moderate"), | ||
TOPIC_CREATE("conversations.topic.create"), | ||
TOPIC_UPDATE_OWN("conversations.topic.update.own"), | ||
TOPIC_UPDATE_ANY("conversations.topic.update.any"), | ||
TOPIC_DELETE_OWN("conversations.topic.delete.own"), | ||
TOPIC_DELETE_ANY("conversations.topic.delete.any"), | ||
TOPIC_TAG("conversations.topic.tag"), | ||
TOPIC_PIN("conversations.topic.pin"), | ||
TAG_CREATE("conversations.tag.create"), | ||
VIEW_GROUP_TOPICS("conversations.topic.view.groups"), | ||
POST_CREATE("conversations.post.create"), | ||
POST_UPDATE_OWN("conversations.post.update.own"), | ||
POST_UPDATE_ANY("conversations.post.update.any"), | ||
POST_DELETE_OWN("conversations.post.delete.own"), | ||
POST_DELETE_ANY("conversations.post.delete.any"), | ||
POST_REACT("conversations.post.react"), | ||
POST_UPVOTE("conversations.post.upvote"), | ||
COMMENT_CREATE("conversations.comment.create"), | ||
COMMENT_UPDATE_OWN("conversations.comment.update.own"), | ||
COMMENT_UPDATE_ANY("conversations.comment.update.any"), | ||
COMMENT_DELETE_OWN("conversations.comment.delete.own"), | ||
COMMENT_DELETE_ANY("conversations.comment.delete.any"), | ||
VIEW_ANONYMOUS("conversations.anonymous.view"), | ||
VIEW_STATISTICS("conversations.statistics.view"); | ||
|
||
public final String label; | ||
|
||
private Permissions(String label) { | ||
this.label = label; | ||
} | ||
|
||
public static Stream<Permissions> stream() { | ||
return Stream.of(Permissions.values()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
conversations/api/src/main/java/org/sakaiproject/conversations/api/Reaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.sakaiproject.conversations.api; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public enum Reaction { | ||
GOOD_QUESTION, | ||
GOOD_ANSWER, | ||
LOVE_IT, | ||
GOOD_IDEA, | ||
KEY; | ||
|
||
public static Stream<Reaction> stream() { | ||
return Stream.of(Reaction.values()); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
conversations/api/src/main/java/org/sakaiproject/conversations/api/TopicType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.sakaiproject.conversations.api; | ||
|
||
public enum TopicType { | ||
QUESTION, DISCUSSION | ||
} |
5 changes: 5 additions & 0 deletions
5
conversations/api/src/main/java/org/sakaiproject/conversations/api/TopicVisibility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.sakaiproject.conversations.api; | ||
|
||
public enum TopicVisibility { | ||
SITE, INSTRUCTORS, GROUP | ||
} |
76 changes: 76 additions & 0 deletions
76
...tions/api/src/main/java/org/sakaiproject/conversations/api/beans/CommentTransferBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/****************************************************************************** | ||
* Copyright 2015 sakaiproject.org Licensed under the Educational | ||
* Community License, Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/ECL-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
******************************************************************************/ | ||
package org.sakaiproject.conversations.api.beans; | ||
|
||
import org.sakaiproject.conversations.api.model.Metadata; | ||
import org.sakaiproject.conversations.api.model.Comment; | ||
|
||
import java.time.Instant; | ||
import lombok.Setter; | ||
|
||
@Setter | ||
public class CommentTransferBean { | ||
|
||
public String id; | ||
public String message; | ||
public String creator; | ||
public Instant created; | ||
public String formattedCreatedDate; | ||
public String modifier; | ||
public Instant modified; | ||
public String formattedModifiedDate; | ||
public String post; | ||
public String siteId; | ||
public boolean locked; | ||
|
||
public String creatorDisplayName; | ||
public boolean canView; | ||
public boolean canEdit; | ||
public boolean canDelete; | ||
|
||
public static CommentTransferBean of(Comment comment) { | ||
|
||
CommentTransferBean commentBean = new CommentTransferBean(); | ||
|
||
commentBean.id = comment.getId(); | ||
commentBean.message = comment.getMessage(); | ||
Metadata metadata = comment.getMetadata(); | ||
commentBean.creator = metadata.getCreator(); | ||
commentBean.created = metadata.getCreated(); | ||
commentBean.modifier = metadata.getModifier(); | ||
commentBean.modified = metadata.getModified(); | ||
commentBean.post = comment.getPost().getId(); | ||
commentBean.siteId = comment.getSiteId(); | ||
commentBean.locked = comment.getLocked(); | ||
|
||
return commentBean; | ||
} | ||
|
||
public Comment asComment() { | ||
|
||
Comment comment = new Comment(); | ||
comment.setId(this.id); | ||
comment.setMessage(this.message); | ||
|
||
Metadata metadata = new Metadata(); | ||
metadata.setCreator(this.creator); | ||
metadata.setCreated(this.created); | ||
metadata.setModifier(this.modifier); | ||
metadata.setModified(this.modified); | ||
comment.setMetadata(metadata); | ||
comment.setSiteId(this.siteId); | ||
|
||
return comment; | ||
} | ||
} |
Oops, something went wrong.