forked from nus-tic4002-AY2021S2/tp2
-
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.
Merge pull request nus-tic4002-AY2021S2#8 from AY2021S2-TIC4002-F18-3…
…/master Merge from team repo on 21 Mar 2021
- Loading branch information
Showing
21 changed files
with
396 additions
and
49 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 |
---|---|---|
|
@@ -70,3 +70,7 @@ shadowJar { | |
} | ||
|
||
defaultTasks 'clean', 'test' | ||
|
||
run { | ||
enableAssertions = true | ||
} |
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 |
---|---|---|
|
@@ -5,57 +5,64 @@ | |
"email" : "[email protected]", | ||
"address" : "Blk 30 Lorong 3 Serangoon Gardens, #07-18", | ||
"tagged" : [ "friends" ], | ||
"group" : "NA" | ||
"group" : "N/A" | ||
}, { | ||
"name" : "Bernice Yu", | ||
"phone" : "99272758", | ||
"email" : "[email protected]", | ||
"address" : "Blk 30 Lorong 3 Serangoon Gardens, #07-18", | ||
"tagged" : [ "colleagues", "friends" ], | ||
"group" : "NIL" | ||
"group" : "N/A" | ||
}, { | ||
"name" : "Charlotte Oliveiro", | ||
"phone" : "93210283", | ||
"email" : "[email protected]", | ||
"address" : "Blk 11 Ang Mo Kio Street 74, #11-04", | ||
"tagged" : [ "neighbours" ], | ||
"group" : "NIL" | ||
"group" : "N/A" | ||
}, { | ||
"name" : "David Li", | ||
"phone" : "91031282", | ||
"email" : "[email protected]", | ||
"address" : "Blk 436 Serangoon Gardens Street 26, #16-43", | ||
"tagged" : [ "family" ], | ||
"group" : "NA" | ||
"group" : "N/A" | ||
}, { | ||
"name" : "Irfan Ibrahim", | ||
"phone" : "92492021", | ||
"email" : "[email protected]", | ||
"address" : "Blk 47 Tampines Street 20, #17-35", | ||
"tagged" : [ "classmates" ], | ||
"group" : "NA" | ||
"group" : "N/A" | ||
}, { | ||
"name" : "Roy Balakrishnan", | ||
"phone" : "92624417", | ||
"email" : "[email protected]", | ||
"address" : "Blk 45 Aljunied Street 85, #11-31", | ||
"tagged" : [ "colleagues" ], | ||
"group" : "NIL" | ||
"group" : "N/A" | ||
}, { | ||
"name" : "John Doe", | ||
"phone" : "98765432", | ||
"email" : "[email protected]", | ||
"address" : "John street, block 123, #01-01", | ||
"tagged" : [ ], | ||
"group" : "NA" | ||
"group" : "N/A" | ||
}, { | ||
"name" : "John Poh", | ||
"phone" : "98765432", | ||
"email" : "[email protected]", | ||
"address" : "John street, block 123, #01-01", | ||
"tagged" : [ ], | ||
"group" : "N/A" | ||
} ], | ||
"groups" : [ { | ||
"group" : "NA" | ||
"group" : "N/A" | ||
}, { | ||
"group" : "A" | ||
}, { | ||
"group" : "B" | ||
}, { | ||
"group" : "NIL" | ||
"group" : "C" | ||
} ] | ||
} |
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
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 |
---|---|---|
|
@@ -29,11 +29,15 @@ Addressbook NS Edition (ABNS) is a **desktop app for managing contacts, optimize | |
|
||
* **`listGroup all`** : Shows a list of all groups in the address book. | ||
|
||
* **`create -g`** : Creates a new group to the address book. | ||
* **`create`** : Creates a new group to the address book. | ||
|
||
* **`list -g [group name]`** : Lists all persons in a particular group. | ||
* **`list g/[GROUP NAME]`** : Lists all persons in a particular group. | ||
|
||
* **`delete -g`** : Deletes the specified group from the address book. | ||
* **`delete`** : Deletes the specified group from the address book. | ||
|
||
* **`assignptg`** : Assign a person by using his name to the specified group. | ||
|
||
* **`rename`** : Renaming an existing group to another name. | ||
|
||
* **`list`** : Lists all contacts. | ||
|
||
|
@@ -92,11 +96,14 @@ Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…` | |
|
||
<div markdown="span" class="alert alert-primary">:bulb: **Tip:** | ||
A person can have any number of tags (including 0) | ||
A person who is created will have have default group created. The group shall be "N/A". | ||
If a person is created with a group, then it can be pre-assigned with a user given group. | ||
</div> | ||
|
||
Examples: | ||
* `add n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01` | ||
* `add n/Betsy Crowe t/friend e/[email protected] a/Newgate Prison p/1234567 t/criminal` | ||
* * `add n/Betsy Crowe t/friend e/[email protected] a/Newgate Prison p/1234567 t/criminal g/GroupA` | ||
|
||
### Listing all persons : `list` | ||
|
||
|
@@ -177,11 +184,11 @@ AddressBook data are saved as a JSON file `[JAR file location]/data/addressbook. | |
If your changes to the data file makes its format invalid, AddressBook will discard all data and start with an empty data file at the next run. | ||
</div> | ||
|
||
### Creating a group: `create g/` | ||
### Creating a group: `create` | ||
|
||
Creates a new group to the Address book NS Edition | ||
|
||
Format: `create g/<group name>` | ||
Format: `create g/<GROUP NAME>` | ||
|
||
Examples: | ||
* `create g/FITNESS` Creates a group called Fitness | ||
|
@@ -196,34 +203,47 @@ Format: `show` | |
Examples: | ||
* `show` Lists all groups | ||
|
||
|
||
### Rename the group: `rename -g` | ||
### Rename the group: `rename` | ||
|
||
Rename an existing group to another name. | ||
|
||
Format: `rename INDEX [n/NAME]` | ||
Format: `rename <INDEX> g/<GROUP NAME>` | ||
|
||
* Rename the group at the specified INDEX | ||
* The index refers to the index number shown in the displayed group list. | ||
* The index must be a positive integer 1, 2, 3, … | ||
* Existing values will be updated to the input values. | ||
* Invalid index and command will trigger a message to tell the correct command format | ||
|
||
Examples: | ||
* `rename 1 g/PERFORMANCE ` Rename the group with index 1 into PERFORMANCE. | ||
|
||
### Assign a person to group: `assignptg` | ||
|
||
Assign a person to a specified group by using person's name. | ||
|
||
Format: `assignptg n/<PERSON NAME> g/<GROUP NAME>` | ||
|
||
* Using the person's name to assign | ||
* Both person and group should exist. | ||
* Invalid command or format will trigger an error message | ||
|
||
Examples: | ||
* `rename 1 n/PERFORMANCE ` Rename the group with index 1 into PERFORMANCE. | ||
* `assignptg n/Alice g/TEST ` Assign Alice to the group TEST. | ||
|
||
### List all persons in a group: `list -g [group name]` | ||
### List all persons in a group: `listfromgrp` | ||
|
||
Lists all persons in a particular group. | ||
|
||
Format: `list -g [group_name]` | ||
Format: `list g/<GROUP NAME>` | ||
|
||
* The group name is case-insensitive. e.g IPPT will match ippt | ||
|
||
Examples: | ||
* `list -g PERFORMANCE ` Lists all persons in PERFORMANCE. | ||
* `list g/PERFORMANCE ` Lists all persons in PERFORMANCE. | ||
|
||
|
||
### Deleting a group: `deletegrp [Index Number]` | ||
### Deleting a group: `deletegrp` | ||
|
||
Deletes the specified group from the address book. | ||
|
||
|
@@ -238,6 +258,16 @@ Examples: | |
* `List all` followed by `delete 1` deletes the 1st group in the results of the `find` command. | ||
|
||
|
||
### Deleting every person from a group: `deletepsngrp` | ||
|
||
Deletes every person from that group in the addressbook. | ||
|
||
Format: `deletepsngrp g/<GROUP NAME>` | ||
|
||
* Deletes every person currently assigned to that group. | ||
* If there is no person to delete, then nothing will happen. | ||
|
||
|
||
### Archiving data files `[coming in v2.0]` | ||
|
||
_Details coming soon ..._ | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
60 changes: 60 additions & 0 deletions
60
src/main/java/seedu/address/logic/commands/DeleteAllPersonFromGroupCommand.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,60 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_GROUP; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
||
import java.util.ArrayList; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.group.Group; | ||
import seedu.address.model.person.Person; | ||
|
||
public class DeleteAllPersonFromGroupCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "deletepsngrp"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": delete all person in a group. " | ||
+ "Parameters: " + PREFIX_GROUP + "GROUP NAME "; | ||
|
||
public static final String MESSAGE_SUCCESS = "all Person has been deleted from Group %1$s. "; | ||
public static final String MESSAGE_NO_EXIST_GROUP = "The Group doesn't exists in the address book"; | ||
|
||
private final Group group; | ||
|
||
/** | ||
* constructor to set the group | ||
* @param group | ||
*/ | ||
public DeleteAllPersonFromGroupCommand(Group group) { | ||
requireNonNull(group); | ||
this.group = group; | ||
} | ||
|
||
/** | ||
* Run the process of deleting all people from the group | ||
* @param model {@code Model} which the command should operate on. | ||
* @return Message success | ||
* @throws CommandException if group does not exists | ||
*/ | ||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
if (!model.hasGroup(this.group)) { | ||
throw new CommandException(MESSAGE_NO_EXIST_GROUP); | ||
} | ||
|
||
// select all people in this.group | ||
ArrayList<Person> personInGroup = model.getPersonListInThisGroup(this.group); | ||
// remove this.group from each of them | ||
for (int i = 0; i < personInGroup.size(); i++) { | ||
Person person = personInGroup.get(i); | ||
model.unAssignPersonToGroup(person); | ||
} | ||
|
||
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, group)); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/seedu/address/logic/commands/RenameGroupCommand.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,48 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_GROUP; | ||
|
||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.group.Group; | ||
|
||
public class RenameGroupCommand extends Command { | ||
public static final String COMMAND_WORD = "rename"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Rename the group identified by the index number used in the displayed group list and a specified " | ||
+ "new name.\n" | ||
+ "Parameters: INDEX (must be a positive integer from 1 to the size of group list) " | ||
+ PREFIX_GROUP + " GROUP_NAME\n" | ||
+ "Example: " + COMMAND_WORD + " 1 " + PREFIX_GROUP + "NEW_GROUP_NAME"; | ||
|
||
public static final String MESSAGE_SUCCESS = "Group index %1$d rename successfully: %2$s"; | ||
|
||
private final Index targetIndex; | ||
private final Group group; | ||
|
||
/** | ||
* @param targetIndex the target specified index | ||
* @param group the renamed group name | ||
*/ | ||
public RenameGroupCommand(Index targetIndex, Group group) { | ||
this.targetIndex = targetIndex; | ||
this.group = group; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
if (targetIndex.getOneBased() <= 0 || targetIndex.getOneBased() >= model.getGroupSize()) { | ||
throw new CommandException(MESSAGE_USAGE); | ||
} | ||
|
||
//To '+1' here in the index is due to the groupList is start from 2. Index 1 is reserved for N/A, | ||
// which shouldn't be renamed | ||
model.renameGroup(targetIndex.getOneBased() + 1, group.toString()); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, targetIndex.getOneBased(), group.toString())); | ||
} | ||
} |
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
Oops, something went wrong.