diff --git a/RemoteSystemsTempFiles/.project b/RemoteSystemsTempFiles/.project new file mode 100644 index 0000000..5447a64 --- /dev/null +++ b/RemoteSystemsTempFiles/.project @@ -0,0 +1,12 @@ + + + RemoteSystemsTempFiles + + + + + + + org.eclipse.rse.ui.remoteSystemsTempNature + + diff --git a/Trello/.classpath b/Trello/.classpath new file mode 100644 index 0000000..fb565a5 --- /dev/null +++ b/Trello/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Trello/.gitignore b/Trello/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Trello/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Trello/.project b/Trello/.project new file mode 100644 index 0000000..c86bfbe --- /dev/null +++ b/Trello/.project @@ -0,0 +1,17 @@ + + + Trello + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Trello/.settings/org.eclipse.jdt.core.prefs b/Trello/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7341ab1 --- /dev/null +++ b/Trello/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/Trello/src/enums/Access.java b/Trello/src/enums/Access.java new file mode 100644 index 0000000..9bf9694 --- /dev/null +++ b/Trello/src/enums/Access.java @@ -0,0 +1,5 @@ +package enums; + +public enum Access { + PUBLIC, PRIVATE; +} diff --git a/Trello/src/exceptions/BoardNotFoundException.java b/Trello/src/exceptions/BoardNotFoundException.java new file mode 100644 index 0000000..8185a8f --- /dev/null +++ b/Trello/src/exceptions/BoardNotFoundException.java @@ -0,0 +1,7 @@ +package exceptions; + +public class BoardNotFoundException extends Exception { + public BoardNotFoundException(String s) { + super(s); + } +} diff --git a/Trello/src/exceptions/CardNotFoundException.java b/Trello/src/exceptions/CardNotFoundException.java new file mode 100644 index 0000000..44fe1dd --- /dev/null +++ b/Trello/src/exceptions/CardNotFoundException.java @@ -0,0 +1,7 @@ +package exceptions; + +public class CardNotFoundException extends Exception { + public CardNotFoundException(String s) { + super(s); + } +} diff --git a/Trello/src/exceptions/DifferentBoardException.java b/Trello/src/exceptions/DifferentBoardException.java new file mode 100644 index 0000000..88e0d91 --- /dev/null +++ b/Trello/src/exceptions/DifferentBoardException.java @@ -0,0 +1,7 @@ +package exceptions; + +public class DifferentBoardException extends Exception{ + public DifferentBoardException(String s) { + super(s); + } +} diff --git a/Trello/src/exceptions/ListNotFoundException.java b/Trello/src/exceptions/ListNotFoundException.java new file mode 100644 index 0000000..b48b248 --- /dev/null +++ b/Trello/src/exceptions/ListNotFoundException.java @@ -0,0 +1,7 @@ +package exceptions; + +public class ListNotFoundException extends Exception { + public ListNotFoundException(String s) { + super(s); + } +} diff --git a/Trello/src/exceptions/UserNotFoundException.java b/Trello/src/exceptions/UserNotFoundException.java new file mode 100644 index 0000000..ba72538 --- /dev/null +++ b/Trello/src/exceptions/UserNotFoundException.java @@ -0,0 +1,7 @@ +package exceptions; + +public class UserNotFoundException extends Exception { + public UserNotFoundException(String s) { + super(s); + } +} diff --git a/Trello/src/models/Application.java b/Trello/src/models/Application.java new file mode 100644 index 0000000..8006a9f --- /dev/null +++ b/Trello/src/models/Application.java @@ -0,0 +1,32 @@ +package models; +import java.util.*; + +public class Application { + private Map boards; + private Map users; // Here key would be user-email + private Map lists; + private Map cards; + + public Application() { + this.boards = new HashMap(); + this.users = new HashMap(); + this.lists = new HashMap(); + this.cards = new HashMap(); + } + + public Map getBoards() { + return this.boards; + } + + public Map getUsers() { + return this.users; + } + + public Map getLists() { + return this.lists; + } + + public Map getCards() { + return this.cards; + } +} diff --git a/Trello/src/models/Board.java b/Trello/src/models/Board.java new file mode 100644 index 0000000..be44173 --- /dev/null +++ b/Trello/src/models/Board.java @@ -0,0 +1,103 @@ +package models; +import java.util.*; + +import enums.Access; + +public class Board { + private UUID id; + private String name; + private Access privacy; + private List members; + private List lists; + + public Board(String name) + { + this.id = UUID.randomUUID(); + this.name = name; + this.privacy = Access.PUBLIC; + this.members = new ArrayList(); + this.lists = new ArrayList(); + } + + public UUID getId() { + return this.id; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public void setPrivacy(Access privacy) { + this.privacy = privacy; + } + + public void addUser(User user) { + this.members.add(user); + } + + public void removeUser(User user) { + this.members.remove(user); + } + + public void addList(BoardList list) { + this.lists.add(list); + } + + public void removeList(BoardList list) { + this.lists.remove(list); + } + + public List getLists() { + return this.lists; + } + + @Override + public String toString() { + int index; + StringBuilder displayString = new StringBuilder("{ id : "+id+", name: "+name+", privacy : "+privacy); + if(lists.size()>0) + { + displayString.append(", lists : ["); + for(index=0; index0) + { + displayString.append(", members : ["); + for(index=0; index cards; + private Board board; + + public BoardList(String name,Board board) + { + this.userId = UUID.randomUUID(); + this.name = name; + this.board = board; + this.cards = new ArrayList(); + } + + public UUID getId() { + return this.userId; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public void addCard(Card card) { + this.cards.add(card); + } + + public void removeCard(Card card) { + this.cards.remove(card); + } + + public List getCards() { + return this.cards; + } + + public Board getBoard() { + return this.board; + } + + @Override + public String toString() { + StringBuilder displayString = new StringBuilder("{ id : "+userId+", name: "+name); + if(cards.size()>0) + { + displayString.append(", cards : ["); + for(int index=0; index0) + displayString.append(", description: "+description); + if(assignee!=null) + displayString.append(", assignedTo: "+assignee.getEmail()); + displayString.append('}'); + return new String(displayString); + } + + @Override + public boolean equals(Object card) { + if(card == this) { + return true; + } + + if(!(card instanceof Card)) { + return false; + } + + return this.getId().equals(((Card)card).getId()); + } + + @Override + public int hashCode() { + return this.id.hashCode(); + } +} diff --git a/Trello/src/models/User.java b/Trello/src/models/User.java new file mode 100644 index 0000000..540ec13 --- /dev/null +++ b/Trello/src/models/User.java @@ -0,0 +1,52 @@ +package models; + +public class User { + private String id; + private String name; + private String email; + + public User(String id,String name,String email) { + this.id = id; + this.name = name; + this.email = email; + } + + public String getId() { + return this.id; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return this.email; + } + + @Override + public String toString() { + return "{ id : "+id+", name : "+name+", email : "+email+" }"; + } + + @Override + public boolean equals(Object user) { + if(user == this) { + return true; + } + + if(!(user instanceof User)) { + return false; + } + + return this.getEmail().equals(((User)user).getEmail()); + } + + @Override + public int hashCode() { + return this.email.hashCode(); + } +} diff --git a/Trello/src/services/ApplicationService.java b/Trello/src/services/ApplicationService.java new file mode 100644 index 0000000..2a3875d --- /dev/null +++ b/Trello/src/services/ApplicationService.java @@ -0,0 +1,249 @@ +package services; +import models.*; +import java.util.*; + +import enums.Access; + +public class ApplicationService { + private Application application; + + public ApplicationService() { + this.application = new Application(); + } + + public boolean createBoard(String name) { + Board newBoard = new Board(name); + application.getBoards().put(newBoard.getId(),newBoard); + System.out.println("Created board: "+newBoard.getId()); + return true; + } + + public boolean deleteBoard(UUID boardID) { + if(!application.getBoards().containsKey(boardID)) { + System.out.println("The board which you are trying to delete doesn't exists"); + return false; + } + Board boardToDelete = application.getBoards().get(boardID); + int index; + for(index=0; index board: application.getBoards().entrySet()) { + System.out.println(board.getValue()); + } + } + + public boolean createUser(String id,String name,String email) { + User user=new User(id,name,email); + application.getUsers().put(email, user); + return true; + } + + public boolean deleteUser(String email) { + if(!application.getUsers().containsKey(email)) { + System.out.println("User which you are trying to delete doesn't exists"); + return false; + } + application.getUsers().remove(email); + return true; + } +} diff --git a/Trello/src/services/Driver.java b/Trello/src/services/Driver.java new file mode 100644 index 0000000..9bfdc59 --- /dev/null +++ b/Trello/src/services/Driver.java @@ -0,0 +1,96 @@ +package services; +import java.util.*; + +public class Driver { + + public static void main(String[] args) { + // TODO Auto-generated method stub + Scanner input = new Scanner(System.in); + ApplicationService tool= new ApplicationService(); + + while(input.hasNextLine()) + { + String line = input.nextLine(); + String[] commands = line.split(" "); + int length = commands.length; + if(commands[0].toUpperCase().equals("SHOW")) { + if(length==3) + { + if(commands[1].toUpperCase().equals("BOARD")) + tool.showBoard(UUID.fromString(commands[2])); + else if(commands[1].toUpperCase().equals("LIST")) + tool.showList(UUID.fromString(commands[2])); + else + tool.showCard(UUID.fromString(commands[2])); + } + else + tool.showAll(); + } + else if(commands[0].toUpperCase().equals("BOARD")) { + if(length>1) + { + if(commands[1].toUpperCase().equals("CREATE")) { + tool.createBoard(commands[2]); + } + else if(commands[1].toUpperCase().equals("DELETE")) { + tool.deleteBoard(UUID.fromString(commands[2])); + } + else { + if(commands[2].toUpperCase().equals("NAME")) + tool.setBoardName(UUID.fromString(commands[1]), commands[3]); + else if(commands[2].toUpperCase().equals("PRIVACY")) + tool.changeBoardPrivacy(UUID.fromString(commands[1]), commands[3]); + else if(commands[2].toUpperCase().equals("ADD_MEMBER")) + tool.addMemberToBoard(UUID.fromString(commands[1]), commands[3]); + } + } + } + else if(commands[0].toUpperCase().equals("LIST")) { + if(length>1) { + StringBuilder sb=new StringBuilder(""); + for(int index=3;index1) { + StringBuilder sb=new StringBuilder(""); + for(int index=3;index2) { + if(commands[2].toUpperCase().equals("NAME")) + tool.setCardName(UUID.fromString(commands[1]), new String(sb)); + else if(commands[2].toUpperCase().equals("DESCRIPTION")) + tool.setCardDescription(UUID.fromString(commands[1]), new String(sb)); + else if(commands[2].toUpperCase().equals("UNASSIGN")) + tool.unassignCard(UUID.fromString(commands[1])); + else if(commands[2].toUpperCase().equals("ASSIGN")) + tool.assignCardToMember(UUID.fromString(commands[1]), commands[3]); + else if(commands[2].toUpperCase().equals("MOVE")) + tool.moveCardToDifferentList(UUID.fromString(commands[1]), UUID.fromString(commands[3])); + } + } + } + } + } + input.close(); + } + +}