diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ICommunication.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ICommunication.java new file mode 100644 index 0000000000000000000000000000000000000000..60683f26df3391e962e0a08889f0e783387b77fb --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ICommunication.java @@ -0,0 +1,81 @@ +package unipotsdam.gf.interfaces; + +import unipotsdam.gf.modules.communication.model.chat.ChatMessage; +import unipotsdam.gf.modules.communication.model.chat.ChatRoom; +import unipotsdam.gf.modules.communication.model.user.User; +import unipotsdam.gf.modules.communication.model.user.UserCredentials; +import unipotsdam.gf.modules.communication.model.user.UserRegistrationInformation; + +import java.util.List; + +/** + * Provides connection to rocket chat + */ +public interface ICommunication { + + /** + * related endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/history/ + * get last 20 chat messages of specific chatroom + * + * @param roomId ID of room of user + * @return List of Chat Messages + */ + List<ChatMessage> getChatHistory(String roomId); + + + /** + * endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/create/ + * creates chatroom + * + * @param name chat room name + * @param userIds member of chat by id; can be empty + * @return chat room id + */ + String createChatRoom(String name, List<String> userIds); + + + /** + * endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/invite/ + * + * @param roomId chat room the user should be add to + * @param userId userID to add + * @return if user was added successfully + */ + boolean addUserToChatRoom(String roomId, String userId); + + /** + * endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/settopic/ + * + * @param roomId chat room where topic should be set + * @param topic topic of chat room + * @return true, if topic was set correctly + */ + boolean setChatRoomTopic(String roomId, String topic); + + + /** + * api: https://rocket.chat/docs/developer-guides/rest-api/groups/info/ + * get information about the chat room + * + * @param roomId chat room id + * @return chat room information + */ + ChatRoom getChatRoomInfo(String roomId); + + /** + * api: https://rocket.chat/docs/developer-guides/rest-api/authentication/login/ + * + * @param userCredentials username and password + * @return information about user, especially authtoken for later use of endpoints + */ + User loginUser(UserCredentials userCredentials); + + /** + * registers new user to rocket chat + * + * @param userRegistrationInformation registers user to rocket.chat + * @return user id + */ + String registerUser(UserRegistrationInformation userRegistrationInformation); + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IContributionReview.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IContributionReview.java new file mode 100644 index 0000000000000000000000000000000000000000..833670ba2c11c871b9dcbe9399b5e70e492ca1ea --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IContributionReview.java @@ -0,0 +1,84 @@ +package unipotsdam.gf.interfaces; + +/** + * Interface that defines a review for a students/groups contribution + * + * A review contains a feedback text and several scales which can be rated + * It can also be exported to certain formats. + */ +public interface IContributionReview { + + /** + * sets the reviews feedbackText. + * + * @param feedbackText + */ + void setFeedbackText(String feedbackText); + + /** + * returns the reviews feedbackText. + * + * @return feedbackText + */ + String getFeedbackText(); + + /** + * adds a rating scale to the review. The scales name and the maximum value + * that can be selected must be provided. The function returns an ID by + * which the scale can be accessed. + * + * TODO: maybe address scales by their name instead? + * + * @param description + * @param maxValue + * @return scaleID + */ + int addRatingScale(String description, int maxValue); + + /** + * removes an existing scale from the review. The scale must be addressed by + * a scaleID that was returned when it was created. + * + * TODO: maybe not necessary anyway? + * + * @param scaleID + */ + void removeRatingScale(int scaleID); + + /** + * sets the rating of an existing scale. Will throw an + * IllegalArgumentException if the rating is higher than possible. + * + * @param scaleID + * @param rating + */ + void setRatingForScale(int scaleID, int rating) throws IllegalArgumentException; + + /** + * returns the rating of an existing scale, addressed by it's scaleID. + * + * @param scaleID + * @return rating + */ + int getRatingOfScale(int scaleID); + + /** + * exports (or rather serializes) the review as an object so that it can be + * used by other applications. + * + * TODO: think of exportTypes + * @param exportType + * @return this object in another format + */ + String exportAs(String exportType); + + /** + * override for toString. Might just call .exportAs() internally + * @return this objects String representation. Maybe not necessary, but nice + * for sure. + */ + @Override + String toString(); + + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IJournal.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IJournal.java new file mode 100644 index 0000000000000000000000000000000000000000..af88032ca1d32d94023eed01af4a3fc4fd9c59f4 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IJournal.java @@ -0,0 +1,63 @@ +package unipotsdam.gf.interfaces; + +import unipotsdam.gf.modules.journal.JournalEntry; + +/** + * Interface for learning journal entry + */ +public interface IJournal { + + /** + * Enum for visibility + */ + enum Visibility{ALL, STUDENT, DOZENT, NONE} + + + /** + * Add a new journal entry + * + * @param text text of the entry + * @param visibility visibility of the entry + */ + void addJournal(String text, Visibility visibility); + + /** + * Change an existing journal entry + * + * @param newText the new text + */ + void editJournal(String newText); + + /** + * Delete a journal entry + * + * @param journaId id of the entry + */ + void deleteJournal(long journaId); + + /** + * change visibility of an entry + * @param journaId id of the entry + * @param visibility new visibility + */ + void setVisibility(long journaId, Visibility visibility); + + /** + + * Get specific journal entry + * + * @param journaId id of the entry + * @return JournalEntry from database + */ + JournalEntry getJournal(long journaId); + + /** + * Get all JournalEntry for a project + * + * @param projectId id of project + * @return all JournalEnrys for that project + */ + JournalEntry getAllJournalEntrysProject(long projectId); + + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IProjectDescription.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IProjectDescription.java new file mode 100644 index 0000000000000000000000000000000000000000..cc89a2870180ac12f5aaf13668e3291e3e63bcd6 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IProjectDescription.java @@ -0,0 +1,67 @@ +package unipotsdam.gf.interfaces; + +import java.util.ArrayList; + +/** + * Interface for Project Description + */ +public interface IProjectDescription { + + /** + * Save description to database + * @param description + */ + void saveDescription(String description); + + /** + * Add a new link to ProjectDescription + * @param link url of the link + * @param name name to shoe on website + */ + void addLink(String link, String name); + + /** + * Delete link + * @param name name of the link + */ + void deleteLink(String name); + + /** + * Get name of the project + * @param projectId Id of the project + * @return name of the project + */ + + String getName(long projectId); + + /** + * Get Description of the project + * @param projectId Id of the project + * @return Desription of the project + */ + String getDescription(long projectId); + + /** + * Get Lecturer of the project + * @param projectId Id of the project + * @return Lecturer of the project + */ + long getLecturer(long projectId); + + /** + * Get all Students of the project (Group) + * @param projectId Id of the Project + * @return Students of the project + */ + ArrayList<Long> getStudents(long projectId); + + /** + * Get all Links of the project + * @param projectId Id of the Project + * @return all links of the project + */ + ArrayList<Long> getLinks(long projectId); + + + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ResearchReport.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ResearchReport.java index f4d466100439a28ddcec7405f47b4dd778276bfd..a35936a46c5fd0facbb0c39d252e55740e3f2cc8 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ResearchReport.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ResearchReport.java @@ -1,5 +1,5 @@ package unipotsdam.gf.interfaces; - +import java.io.*; /** * Created by Johannes Zeiße on 30.05.2018. diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/chat/ChatMessage.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/chat/ChatMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..eb28777f80350922a2dd291b690e0d7134a15504 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/chat/ChatMessage.java @@ -0,0 +1,52 @@ +package unipotsdam.gf.modules.communication.model.chat; + +import java.time.Instant; + +public class ChatMessage { + + String id; + String message; + Instant timestamp; + String username; + + public ChatMessage() {} + + public ChatMessage(String id, String message, Instant timestamp, String username) { + this.id = id; + this.message = message; + this.timestamp = timestamp; + this.username = username; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Instant getTimestamp() { + return timestamp; + } + + public void setTimestamp(Instant timestamp) { + this.timestamp = timestamp; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/chat/ChatRoom.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/chat/ChatRoom.java new file mode 100644 index 0000000000000000000000000000000000000000..0a97bfcaa8956ee862866c8cb1df48335a9301ed --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/chat/ChatRoom.java @@ -0,0 +1,30 @@ +package unipotsdam.gf.modules.communication.model.chat; + +public class ChatRoom { + + String id; + String name; + + public ChatRoom() {} + + public ChatRoom(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/user/User.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/user/User.java new file mode 100644 index 0000000000000000000000000000000000000000..92914711702ca737194fd2c15544f3b6f9ab0909 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/user/User.java @@ -0,0 +1,30 @@ +package unipotsdam.gf.modules.communication.model.user; + +public class User { + + String id; + String authToken; + + public User() {} + + public User(String id, String authToken) { + this.id = id; + this.authToken = authToken; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthToken() { + return authToken; + } + + public void setAuthToken(String authToken) { + this.authToken = authToken; + } +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/user/UserCredentials.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/user/UserCredentials.java new file mode 100644 index 0000000000000000000000000000000000000000..97ec8969ce07f4268ed61496aefd6d4baf9a1f45 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/user/UserCredentials.java @@ -0,0 +1,30 @@ +package unipotsdam.gf.modules.communication.model.user; + +public class UserCredentials { + + String username; + String password; + + public UserCredentials() {} + + public UserCredentials(String username, String password) { + this.username = username; + this.password = password; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/user/UserRegistrationInformation.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/user/UserRegistrationInformation.java new file mode 100644 index 0000000000000000000000000000000000000000..b109f1f66c64331254491af5eddaa50f35a6f032 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/communication/model/user/UserRegistrationInformation.java @@ -0,0 +1,41 @@ +package unipotsdam.gf.modules.communication.model.user; + +public class UserRegistrationInformation { + + private String username; + private String email; + private String pass; + private String name; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPass() { + return pass; + } + + public void setPass(String pass) { + this.pass = pass; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/JournalEntry.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/JournalEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..496f0418ec8da00214b8d27c5061b691508bf9c4 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/JournalEntry.java @@ -0,0 +1,89 @@ +package unipotsdam.gf.modules.journal; + +import unipotsdam.gf.interfaces.IJournal; + +/** + * Prototype of JournalEntry Class + */ +public class JournalEntry { + + long id; + long owner; + long project; + long timestamp; + IJournal.Visibility visibility; + String text; + + + public JournalEntry() { + } + + public JournalEntry(long id, long owner, long project, long timestamp, IJournal.Visibility visibility, String text) { + this.id = id; + this.owner = owner; + this.project = project; + this.timestamp = timestamp; + this.visibility = visibility; + this.text = text; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public long getOwner() { + return owner; + } + + public void setOwner(long owner) { + this.owner = owner; + } + + public long getProject() { + return project; + } + + public void setProject(long project) { + this.project = project; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public IJournal.Visibility getVisibility() { + return visibility; + } + + public void setVisibility(IJournal.Visibility visibility) { + this.visibility = visibility; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + @Override + public String toString() { + return "JournalEntry{" + + "id=" + id + + ", owner=" + owner + + ", project=" + project + + ", timestamp=" + timestamp + + ", visibility=" + visibility + + ", text='" + text + '\'' + + '}'; + } +}