This repository was archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
solved trello #5
Open
gdsoumya
wants to merge
2
commits into
workattech:master
Choose a base branch
from
gdsoumya:solved_trello
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,67 @@ | ||
| package com.soumya.projectManagement; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| // Model for Board | ||
| public class Board { | ||
|
|
||
| private String name, bid, url; | ||
| private Privacy privacy; | ||
| private List<CList> lists; | ||
| private List<User> members; | ||
|
|
||
| public Board(String name, String bid, String url) { | ||
| this.name = name; | ||
| this.bid = bid; | ||
| this.privacy = Privacy.PUBLIC; | ||
| this.url = url; | ||
| this.lists = new ArrayList<>(); | ||
| this.members = new ArrayList<>();; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getBid() { | ||
| return bid; | ||
| } | ||
|
|
||
| public String getUrl() { | ||
| return url; | ||
| } | ||
|
|
||
| public void setUrl(String url) { | ||
| this.url = url; | ||
| } | ||
|
|
||
| public Privacy getPrivacy() { | ||
| return privacy; | ||
| } | ||
|
|
||
| public void setPrivacy(Privacy privacy) { | ||
| this.privacy = privacy; | ||
| } | ||
|
|
||
| public List<CList> getLists() { | ||
| return lists; | ||
| } | ||
|
|
||
| public void setLists(List<CList> lists) { | ||
| this.lists = lists; | ||
| } | ||
|
|
||
| public List<User> getMembers() { | ||
| return members; | ||
| } | ||
|
|
||
| public void setMembers(List<User> members) { | ||
| this.members = members; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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,89 @@ | ||
| package com.soumya.projectManagement; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| // Core Functions related to Board Management | ||
| public class BoardManager { | ||
|
|
||
| // Checks whether BID is valid or not | ||
| public static boolean isValid(String bid, StorageUtil store) { | ||
| return store.boards.containsKey(bid); | ||
| } | ||
|
|
||
| // Creates new Board with given name | ||
| public static String createBoard(String name, StorageUtil store) { | ||
| String bid = UUID.randomUUID().toString().replace("-",""); | ||
| String url = "/boards/"+bid; | ||
| store.boards.put(bid, new Board(name, bid, url)); | ||
| return bid; | ||
| } | ||
|
|
||
| // Deletes Board with given BID | ||
| public static void deleteBoard(String bid, StorageUtil store) { | ||
| Board board = store.boards.get(bid); | ||
| for(CList list : board.getLists()) { | ||
| for(Card card : list.getCards()) | ||
| store.cards.remove(card.getCid()); | ||
| store.lists.remove(list.getLid()); | ||
| } | ||
| store.boards.remove(bid); | ||
| } | ||
|
|
||
| // Updates Board property | ||
| public static void updateBoard(String bid, String name, String privacy, StorageUtil store) { | ||
| Board board = store.boards.get(bid); | ||
| if(name!=null) | ||
| board.setName(name); | ||
| if(privacy!=null) | ||
| switch(privacy.toUpperCase()) { | ||
| case "PUBLIC": | ||
| board.setPrivacy(Privacy.PUBLIC); | ||
| break; | ||
| case "PRIVATE": | ||
| board.setPrivacy(Privacy.PRIVATE); | ||
| break; | ||
| default: | ||
| System.out.println("ERROR: Wrong Privacy Specification !"); | ||
| } | ||
| } | ||
|
|
||
| // Add Members to a Board | ||
| public static void addMember(String bid, String uid, StorageUtil store) { | ||
| Board board = store.boards.get(bid); | ||
| User user = (User) store.users.get(uid).keySet().toArray()[0]; | ||
| store.users.get(uid).get(user).add(board); | ||
| board.getMembers().add(user); | ||
| } | ||
|
|
||
| // Removes Member form a Board | ||
| public static void removeMember(String bid, String uid, StorageUtil store) { | ||
| Board board = store.boards.get(bid); | ||
| User user = (User) store.users.get(uid).keySet().toArray()[0]; | ||
| store.users.get(uid).get(user).remove(board); | ||
| board.getMembers().remove(user); | ||
| } | ||
|
|
||
| // Displays Particular Board with all sub details | ||
| public static void showBoard(String bid, Board board, StorageUtil store) { | ||
| board = board==null?store.boards.get(bid):board; | ||
| System.out.println("BID : "+bid); | ||
| System.out.println("BOARD NAME : "+board.getName()); | ||
| if(board.getPrivacy()==Privacy.PRIVATE) | ||
| System.out.println("BOARD PRIVACY : PRIVATE"); | ||
| else | ||
| System.out.println("BOARD PRIVACY : PUBLIC"); | ||
| System.out.println("BOARD MEMEBERS :"); | ||
| if(board.getMembers().size()>0) | ||
| for(User usr : board.getMembers()) | ||
| System.out.println("UID :"+usr.getUid()+" Name : "+usr.getName()+" Email : "+usr.getEmail()); | ||
| else | ||
| System.out.println("N/A"); | ||
| System.out.println("BOARD LISTS :"); | ||
| if(board.getLists().size()>0) | ||
| for(CList list : board.getLists()) | ||
| ListManager.showList(list.getLid(),list,store); | ||
| else | ||
| System.out.println("N/A"); | ||
| System.out.println(); | ||
| } | ||
| } |
This file contains hidden or 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,39 @@ | ||
| package com.soumya.projectManagement; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| // Model for List | ||
| public class CList { | ||
|
|
||
| private String lid, name; | ||
| private List<Card> cards; | ||
|
|
||
| public CList(String lid, String name) { | ||
| this.lid = lid; | ||
| this.name = name; | ||
| this.cards = new ArrayList<>(); | ||
| } | ||
|
|
||
| public String getLid() { | ||
| return lid; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public List<Card> getCards() { | ||
| return cards; | ||
| } | ||
|
|
||
| public void setCards(List<Card> cards) { | ||
| this.cards = cards; | ||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or 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,43 @@ | ||
| package com.soumya.projectManagement; | ||
|
|
||
| // Model for Card | ||
| public class Card { | ||
|
|
||
| private String cid, name, description; | ||
| private User assgndUser; | ||
|
|
||
| public Card(String cid, String name, String description) { | ||
| this.cid = cid; | ||
| this.name = name; | ||
| this.description = description; | ||
| this.assgndUser = null; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| public void setDescription(String description) { | ||
| this.description = description; | ||
| } | ||
|
|
||
| public User getAssgndUser() { | ||
| return assgndUser; | ||
| } | ||
|
|
||
| public void setAssgndUser(User assgndUser) { | ||
| this.assgndUser = assgndUser; | ||
| } | ||
|
|
||
| public String getCid() { | ||
| return cid; | ||
| } | ||
| } |
This file contains hidden or 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,92 @@ | ||
| package com.soumya.projectManagement; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.UUID; | ||
|
|
||
| //Core Functions related to Card Management | ||
| public class CardManager { | ||
|
|
||
| // Checks whether CID is valid or not | ||
| public static boolean isValid(String cid, StorageUtil store) { | ||
| return store.cards.containsKey(cid); | ||
| } | ||
|
|
||
| // Creates new Card with given name in specified List | ||
| public static String createCard(String lid, String name, StorageUtil store) { | ||
| String cid = UUID.randomUUID().toString().replace("-",""); | ||
| CList list = (CList) store.lists.get(lid).keySet().toArray()[0]; | ||
| Card card = new Card(cid, name, ""); | ||
| list.getCards().add(card); | ||
| store.cards.put(cid, new HashMap<Card, CList>()); | ||
| store.cards.get(cid).put(card, list); | ||
| return cid; | ||
| } | ||
|
|
||
| // Deletes Card with given CID | ||
| public static void deleteCard(String cid, StorageUtil store) { | ||
| CList list = (CList) store.cards.get(cid).values().toArray()[0]; | ||
| Card card = (Card) store.cards.get(cid).keySet().toArray()[0]; | ||
| store.cards.remove(cid); | ||
| list.getCards().remove(card); | ||
| } | ||
|
|
||
| // Updates Card properties | ||
| public static void updateCard(String cid, String name, String description, StorageUtil store) { | ||
| Card card = (Card) store.cards.get(cid).keySet().toArray()[0]; | ||
| if(name!=null) | ||
| card.setName(name); | ||
| if(description!=null) | ||
| card.setDescription(description); | ||
| } | ||
|
|
||
| // Assigns Member to a Card | ||
| public static void assignToCard(String cid, String uid, StorageUtil store) { | ||
| User user = (User) store.users.get(uid).keySet().toArray()[0]; | ||
| CList list = (CList) store.cards.get(cid).values().toArray()[0]; | ||
| Card card = (Card) store.cards.get(cid).keySet().toArray()[0]; | ||
| Board board = (Board) store.lists.get(list.getLid()).values().toArray()[0]; | ||
| if(board.getMembers().contains(user)) | ||
| card.setAssgndUser(user); | ||
| else | ||
| System.out.println("ERROR: USER DOESN'T BELONG TO CONTAINER BOARD - NAME: "+board.getName()+", BID: "+board.getBid()); | ||
| } | ||
|
|
||
| // Unassigns Member from a Card | ||
| public static void unassignToCard(String cid, StorageUtil store) { | ||
| Card card = (Card) store.cards.get(cid).keySet().toArray()[0]; | ||
| card.setAssgndUser(null); | ||
| } | ||
|
|
||
| // Moves Card to another List | ||
| public static void moveCard(String cid, String lid, StorageUtil store) { | ||
| CList newlist = (CList) store.lists.get(lid).keySet().toArray()[0]; | ||
| CList oldlist = (CList) store.cards.get(cid).values().toArray()[0]; | ||
| Board board = (Board) store.lists.get(lid).values().toArray()[0]; | ||
| if(!board.getLists().contains(oldlist)) { | ||
| System.out.println("ERROR: LIST : "+lid+" IS NOT IN THE SAME BOARD AS CARD : "+cid); | ||
| return; | ||
| } | ||
| Card card = (Card) store.cards.get(cid).keySet().toArray()[0]; | ||
| oldlist.getCards().remove(card); | ||
| newlist.getCards().add(card); | ||
| store.cards.get(cid).put(card, newlist); | ||
| } | ||
|
|
||
| // Displays details of Card | ||
| public static void showCard(String cid, Card card, StorageUtil store) { | ||
| card = card==null?(Card) store.cards.get(cid).keySet().toArray()[0]:card; | ||
| System.out.println("CID : "+cid); | ||
| System.out.println("CARD NAME : "+card.getName()); | ||
| if(!card.getDescription().isEmpty()) | ||
| System.out.println("CARD DESCRIPTION : "+card.getDescription()); | ||
| else | ||
| System.out.println("CARD DESCRIPTION : N/A"); | ||
| System.out.print("CARD ASSIGNED USER : "); | ||
| if(card.getAssgndUser()==null) | ||
| System.out.println("N/A"); | ||
| else { | ||
| User usr=card.getAssgndUser(); | ||
| System.out.println("\nUID :"+usr.getUid()+" Name : "+usr.getName()+" Email : "+usr.getEmail()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| package com.soumya.projectManagement; | ||
|
|
||
| import java.util.Scanner; | ||
|
|
||
| // Main Driver Class | ||
| public class DriverApp { | ||
|
|
||
| public static void main(String[] args) { | ||
|
|
||
| // Initialize ProjectManager instance | ||
| ProjectManager pm = new ProjectManager(); | ||
|
|
||
| // Hard coded registered users | ||
| pm.registerUser("User1", "user1@hello.com"); | ||
| pm.registerUser("User2", "user2@hello.com"); | ||
| pm.registerUser("User3", "user3@hello.com"); | ||
|
|
||
| // Display details of registered users with their UID | ||
| pm.showAllUsers(); | ||
|
|
||
| // User Command Input | ||
| Scanner sc=new Scanner(System.in); | ||
| while(true) { | ||
| // Execute Command | ||
| pm.handleRequest(sc.nextLine()); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is bid here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it. Could just be id. bid is not self-explanatory