prepare for pull request
- add javadoc - rename Permission to BoardPermission - edit BoardPrototype.Builder, now uses MemberPermission - add getter to Label, Member and MemberPermission
This commit is contained in:
parent
850f33eeff
commit
aafc05cc32
@ -10,31 +10,77 @@ import wekan.wrapper.entity.BoardPrototype;
|
||||
import java.util.List;
|
||||
|
||||
public interface BoardService {
|
||||
|
||||
/**
|
||||
* Get all public boards.
|
||||
*
|
||||
* @return the list with all public boards
|
||||
*/
|
||||
@GET("api/boards")
|
||||
Call<List<Board>> getPublicBoards();
|
||||
|
||||
/**
|
||||
* Create a board.
|
||||
*
|
||||
* @param boardPrototype the prototype of the new board
|
||||
* @return the new board
|
||||
* @see BoardPrototype
|
||||
*/
|
||||
@POST("api/boards")
|
||||
Call<Board> newBoard(@Body BoardPrototype boardPrototype);
|
||||
|
||||
/**
|
||||
* Get the board with that particular ID.
|
||||
*
|
||||
* @param boardId The ID of the board
|
||||
* @return The board with the matching ID
|
||||
*/
|
||||
@GET("api/boards/{boardId}")
|
||||
Call<Board> getBoard(@Path("boardId") String boardId);
|
||||
|
||||
/**
|
||||
* Delete the board with that particular ID
|
||||
*
|
||||
* @param boardId The ID of the board
|
||||
*/
|
||||
@DELETE("api/boards/{boardId}")
|
||||
Call<Void> deleteBoard(@Path("boardId") String boardId);
|
||||
|
||||
/**
|
||||
* Add a label to a board.
|
||||
*
|
||||
* @param boardId The ID of the board
|
||||
* @param labelPrototype The prototype of new label
|
||||
* @return The ID of new label
|
||||
* @see LabelPrototype
|
||||
*/
|
||||
@PUT("/api/boards/{boardId}/labels")
|
||||
Call<String> addLabel(
|
||||
@Path("boardId") String board,
|
||||
@Path("boardId") String boardId,
|
||||
@Body LabelPrototype labelPrototype
|
||||
);
|
||||
|
||||
/**
|
||||
* Change the permission of a member of a board.
|
||||
*
|
||||
* @param boardId The ID of the board
|
||||
* @param memberId The ID of the member
|
||||
* @param memberPermission The new role of the member
|
||||
* @see MemberPermission
|
||||
*/
|
||||
@POST("/api/boards/{boardId}/members/{memberId}")
|
||||
Call<Void> setMemberPermission(
|
||||
@Path("boardId") String board,
|
||||
@Path("memberId") String member,
|
||||
@Path("boardId") String boardId,
|
||||
@Path("memberId") String memberId,
|
||||
@Body MemberPermission memberPermission
|
||||
);
|
||||
|
||||
/**
|
||||
* Get all boards attached to a user.
|
||||
*
|
||||
* @param userId The ID of the user
|
||||
* @return The list with all user's boards
|
||||
*/
|
||||
@GET("api/users/{userId}/boards")
|
||||
Call<List<Board>> getBoardsFromUser(@Path("userId") String userId);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class Board {
|
||||
private int starts;
|
||||
private List<Label> labels;
|
||||
private List<Member> members;
|
||||
private Permission permission;
|
||||
private BoardPermission permission;
|
||||
@SerializedName("color")
|
||||
private BoardBackgroundColor backgroundColor;
|
||||
private String description;
|
||||
@ -68,7 +68,7 @@ public class Board {
|
||||
return members;
|
||||
}
|
||||
|
||||
public Permission getPermission() {
|
||||
public BoardPermission getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package wekan.wrapper.entity;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public enum Permission {
|
||||
public enum BoardPermission {
|
||||
@SerializedName("public")
|
||||
PUBLIC,
|
||||
@SerializedName("private")
|
@ -2,6 +2,9 @@ package wekan.wrapper.entity;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Describes the properties of the new board
|
||||
*/
|
||||
public class BoardPrototype {
|
||||
private String title;
|
||||
private String owner;
|
||||
@ -9,7 +12,7 @@ public class BoardPrototype {
|
||||
private boolean isActive;
|
||||
private boolean isNoComments;
|
||||
private boolean isCommentOnly;
|
||||
private Permission permission;
|
||||
private BoardPermission permission;
|
||||
@SerializedName("color")
|
||||
private BoardBackgroundColor backgroundColor;
|
||||
|
||||
@ -20,7 +23,7 @@ public class BoardPrototype {
|
||||
boolean isActive,
|
||||
boolean isNoComments,
|
||||
boolean isCommentOnly,
|
||||
Permission permission,
|
||||
BoardPermission permission,
|
||||
BoardBackgroundColor backgroundColor
|
||||
) {
|
||||
this.title = title;
|
||||
@ -36,64 +39,90 @@ public class BoardPrototype {
|
||||
public static class Builder {
|
||||
private String title;
|
||||
private String owner;
|
||||
private boolean isAdmin = true;
|
||||
private boolean isActive = true;
|
||||
private boolean isNoComments = false;
|
||||
private boolean isCommentOnly = false;
|
||||
private Permission permission = Permission.PRIVATE;
|
||||
private MemberPermission memberPermission = MemberPermission.ADMIN;
|
||||
private BoardPermission boardPermission = BoardPermission.PRIVATE;
|
||||
private BoardBackgroundColor backgroundColor = BoardBackgroundColor.BELIZE;
|
||||
|
||||
public Builder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new BoardPrototype
|
||||
*
|
||||
* @return The board prototype
|
||||
*/
|
||||
public BoardPrototype build() {
|
||||
return new BoardPrototype(
|
||||
title,
|
||||
owner,
|
||||
isAdmin,
|
||||
memberPermission.isAdmin(),
|
||||
isActive,
|
||||
isNoComments,
|
||||
isCommentOnly,
|
||||
permission,
|
||||
memberPermission.isNoComments(),
|
||||
memberPermission.isCommentOnly(),
|
||||
boardPermission,
|
||||
backgroundColor
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title of the new board.
|
||||
*
|
||||
* @param title The title of the new board
|
||||
*/
|
||||
public Builder setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the owner of the new board.
|
||||
*
|
||||
* @param owner The owner of the new board
|
||||
*/
|
||||
public Builder setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAdmin(boolean admin) {
|
||||
isAdmin = admin;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the owner like an active member of the new board.
|
||||
*
|
||||
* @param active True by default
|
||||
*/
|
||||
public Builder setActive(boolean active) {
|
||||
isActive = active;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setNoComments(boolean noComments) {
|
||||
isNoComments = noComments;
|
||||
/**
|
||||
* Set the permission of the owner on the new board.
|
||||
*
|
||||
* @param memberPermission ADMIN by default
|
||||
* @see MemberPermission
|
||||
*/
|
||||
public Builder setMemberPermission(MemberPermission memberPermission) {
|
||||
this.memberPermission = memberPermission;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCommentOnly(boolean commentOnly) {
|
||||
isCommentOnly = commentOnly;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPermission(Permission permission) {
|
||||
this.permission = permission;
|
||||
/**
|
||||
* Set the visibility of the new board.
|
||||
*
|
||||
* @param boardPermission PRIVATE by default
|
||||
* @see BoardPermission
|
||||
*/
|
||||
public Builder setBoardPermission(BoardPermission boardPermission) {
|
||||
this.boardPermission = boardPermission;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background color of the new board.
|
||||
*
|
||||
* @param backgroundColor BELIZE by default
|
||||
* @see BoardBackgroundColor
|
||||
*/
|
||||
public Builder setBackgroundColor(BoardBackgroundColor backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
return this;
|
||||
|
@ -14,6 +14,18 @@ public class Label {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public LabelColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Label{" +
|
||||
|
@ -1,8 +1,15 @@
|
||||
package wekan.wrapper.entity;
|
||||
|
||||
/**
|
||||
* Describes the properties of the new label.
|
||||
*/
|
||||
public class LabelPrototype {
|
||||
private Label label;
|
||||
|
||||
/**
|
||||
* @param name The name of the new label
|
||||
* @param color The color of the new label
|
||||
*/
|
||||
public LabelPrototype(String name, LabelColor color) {
|
||||
label = new Label(null, name, color);
|
||||
}
|
||||
|
@ -15,6 +15,26 @@ public class Member {
|
||||
this.isCommentOnly = isCommentOnly;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return isAdmin;
|
||||
}
|
||||
|
||||
public boolean isNoComments() {
|
||||
return isNoComments;
|
||||
}
|
||||
|
||||
public boolean isCommentOnly() {
|
||||
return isCommentOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Member{" +
|
||||
|
@ -1,21 +1,36 @@
|
||||
package wekan.wrapper.entity;
|
||||
|
||||
public class MemberPermission {
|
||||
/**
|
||||
* The user is an admin of the board
|
||||
*/
|
||||
public final static MemberPermission ADMIN = new MemberPermission(
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
/**
|
||||
* The use is an normal member of the board
|
||||
*/
|
||||
public final static MemberPermission NORMAL = new MemberPermission(
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
/**
|
||||
* The user isn't allowed to make comments on the board
|
||||
*/
|
||||
public final static MemberPermission NO_COMMENTS = new MemberPermission(
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
/**
|
||||
* The user is only allowed to make comments on the board
|
||||
*/
|
||||
public final static MemberPermission COMMENT_ONLY = new MemberPermission(
|
||||
false,
|
||||
false,
|
||||
@ -31,4 +46,16 @@ public class MemberPermission {
|
||||
this.isNoComments = isNoComments;
|
||||
this.isCommentOnly = isCommentOnly;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return isAdmin;
|
||||
}
|
||||
|
||||
public boolean isNoComments() {
|
||||
return isNoComments;
|
||||
}
|
||||
|
||||
public boolean isCommentOnly() {
|
||||
return isCommentOnly;
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class BoardServiceTest {
|
||||
assertEquals("my-title-1", board.getSlug());
|
||||
assertFalse(board.isArchived());
|
||||
assertEquals(0, board.getStarts());
|
||||
assertEquals(Permission.PRIVATE, board.getPermission());
|
||||
assertEquals(BoardPermission.PRIVATE, board.getPermission());
|
||||
assertEquals(BoardBackgroundColor.CORTEZA, board.getBackgroundColor());
|
||||
assertTrue(board.isAllowsSubtasks());
|
||||
assertEquals(PresentParentTask.NO_PARENT, board.getPresentParentTask());
|
||||
|
Loading…
Reference in New Issue
Block a user