Skip to content

Commit

Permalink
Merge pull request nus-tic4002-AY2021S2#8 from AY2021S2-TIC4002-F18-3…
Browse files Browse the repository at this point in the history
…/master

Merge from team repo on 21 Mar 2021
  • Loading branch information
ZhengShijieNUS authored Mar 21, 2021
2 parents d758742 + 2d039f2 commit edc4cae
Show file tree
Hide file tree
Showing 21 changed files with 396 additions and 49 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ shadowJar {
}

defaultTasks 'clean', 'test'

run {
enableAssertions = true
}
25 changes: 16 additions & 9 deletions data/addressbook.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
} ]
}
1 change: 1 addition & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
| `* * *` | user | delete a group | remove the groups that I no longer need |
| `* * *` | user | list all groups | keep track of what has been created in the system |
| `* * *` | user | list all persons in a group | give a punishment or a reward to soldiers in the specific group |
| `* * *` | user | load groups from json file | the previous record will be maintained |
| `* * *` | user | find a person by name | locate details of persons without having to go through the entire list |
| `* *` | user | hide private contact details | minimize chance of someone else seeing them by accident |
| `*` | user with many persons in the address book | sort persons by name | locate a person easily |
Expand Down
56 changes: 43 additions & 13 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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`

Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand All @@ -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 ..._
Expand Down
Binary file modified docs/images/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
layout: page
title: AddressBook Level-3
title: Addressbook NS Edition (ABNS)
---

[![CI Status](https://github.com/se-edu/addressbook-level3/workflows/Java%20CI/badge.svg)](https://github.com/se-edu/addressbook-level3/actions)
[![CI Status](https://github.com/AY2021S2-TIC4002-F18-3/tp2/workflows/Java%20CI/badge.svg)](https://github.com/AY2021S2-TIC4002-F18-3/tp2/actions)
[![codecov](https://codecov.io/gh/se-edu/addressbook-level3/branch/master/graph/badge.svg)](https://codecov.io/gh/se-edu/addressbook-level3)

![Ui](images/Ui.png)

**AddressBook is a desktop application for managing your contact details.** While it has a GUI, most of the user interactions happen using a CLI (Command Line Interface).
**Addressbook NS Edition (ABNS) is a desktop application for managing contact details and grouping people.** While it has a GUI, most of the user interactions happen using a CLI (Command Line Interface).

* If you are interested in using AddressBook, head over to the [_Quick Start_ section of the **User Guide**](UserGuide.html#quick-start).
* If you are interested about developing AddressBook, the [**Developer Guide**](DeveloperGuide.html) is a good place to start.
* If you are interested in using Addressbook NS Edition (ABNS), head over to the [_Quick Start_ section of the **User Guide**](https://ay2021s2-tic4002-f18-3.github.io/tp2/UserGuide.html#quick-start).
* If you are interested about developing Addressbook NS Edition (ABNS), the [**Developer Guide**](https://ay2021s2-tic4002-f18-3.github.io/tp2/DeveloperGuide.html) is a good place to start.


**Acknowledgements**
Expand Down
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 src/main/java/seedu/address/logic/commands/RenameGroupCommand.java
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()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import seedu.address.logic.commands.AssignPersonToGroupCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.DeleteAllPersonFromGroupCommand;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.DeleteGroupCommand;
import seedu.address.logic.commands.EditCommand;
Expand All @@ -19,6 +20,7 @@
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListAllFromGroupCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.RenameGroupCommand;
import seedu.address.logic.commands.ShowCommand;
import seedu.address.logic.parser.exceptions.ParseException;

Expand Down Expand Up @@ -62,6 +64,9 @@ public Command parseCommand(String userInput) throws ParseException {
case DeleteGroupCommand.COMMAND_WORD:
return new DeleteGroupCommandParser().parse(arguments);

case RenameGroupCommand.COMMAND_WORD:
return new RenameGroupCommandParser().parse(arguments);

case EditCommand.COMMAND_WORD:
return new EditCommandParser().parse(arguments);

Expand Down Expand Up @@ -89,6 +94,9 @@ public Command parseCommand(String userInput) throws ParseException {
case HelpCommand.COMMAND_WORD:
return new HelpCommand();

case DeleteAllPersonFromGroupCommand.COMMAND_WORD:
return new DeleteAllPersonFromGroupCommandParser().parse(arguments); // Delete everyone from a group

default:
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
}
Expand Down
Loading

0 comments on commit edc4cae

Please sign in to comment.