Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit dg #306

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 43 additions & 43 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Given below is a quick overview of main components and how they interact with ea
**Main components of the architecture**

**`Main`** (consisting of
classes [`Main`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/Main.java)
and [`MainApp`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/MainApp.java)) is
classes [`Main`](https://github.com/AY2324S1-CS2103T-W15-2/tp/blob/master/src/main/java/seedu/address/Main.java)
and [`MainApp`](https://github.com/AY2324S1-CS2103T-W15-2/tp/blob/master/src/main/java/seedu/address/MainApp.java)) is
in charge of the app launch and shut down.

* At app launch, it initializes the other components in the correct sequence, and connects them up with each other.
Expand Down Expand Up @@ -241,18 +241,18 @@ we shall be narrowing our scope to adding a todo tasks to a specified group, g.

How the `Model` component works:

* Depending on the nature of the command, a static method is called to generate a `TaskOperation` or
a `ChildrenOperation` object that acts as an interface manipulate the Model
* Depending on the nature of the command, the corresponding method is called to generate a `TaskOperation` or
a `ChildOperation` object that acts as an interface manipulate the model
* In this case, a `TaskOperation` object is created. This object would store all the necessary information to make
changes directly on the correct state.
* The `Command` instance calls the required method in the `TaskOperation` object which results in the `TaskOperation`
object performing the addition of the Todo task to the group.

<box type="info" seamless>

**Note:** For ChildrenOperation, ModelManager provides more specific static factory methods (e.g., GroupChildOperation,
RootChildOperation) to generate the `ChildOperation` object. It is implemented this way so that ModelManager is able
to check that the Operation required matches with the intended effect of the Command object's Execution.
**Note:** For `ChildrenOperation`, `ModelManager` provides more specific factory methods (e.g., `groupChildOperation`,
`rootChildOperation`) to generate the `ChildOperation` object. It is implemented this way so that `ModelManager` is able
to check that the operation required matches with the intended effect of the `Command` object's execution.

</box>

Expand Down Expand Up @@ -280,7 +280,7 @@ Here is a class diagram for the path package:
* `AbsolutePath` represents an absolute path within the system and strictly commences with the `~` element.
* The `resolve` method is crucial to resolve a `RelativePath` and return the resolved path in `AbsolutePath` type.
* e.g. Consider an `AbsolutePath` represents `~/grp-001/0001A`. If the `resolve` method is called with the
`RelativePath` representing `../grp-002`, the resolve method will return the `AbsolutePath` representing the path
`RelativePath` representing `../../grp-002`, the resolve method will return the `AbsolutePath` representing the path
`~/grp-002`.

<div style="page-break-after: always;"></div>
Expand Down Expand Up @@ -378,13 +378,13 @@ implementation for the harder one, which is creating a student. Should you have
us.

Most of the logic for creating a student is encapsulated in the `CreateStudentCommand` class, this class utilise
the `GroupChildOperation` class to add the student to the group and the `Model` class to check for duplicates.
The following methods of `ModelManager` and `GroupChildOperation` are used:
the `ChildOperation<Student>` class to add the student to the group and the `Model` class to check for duplicates.
The following methods of `ModelManager` and `ChildOperation<Student>` are used:

1. `ModelManager::groupChildOperation` - To generate an operation class specific to the current group, it also checks for
the validity and presence of the specified group.
2. `ModelManager::hasStudentWithId` - To check if the new student id is unique.
3. `GroupChildOperation::addChild` - To add the current student into the group.
3. `ChildOperation<Student>::addChild` - To add the current student into the group.

Given below is an example usage scenario on how an existing user can create a student.

Expand All @@ -400,14 +400,14 @@ Given below is an example usage scenario on how an existing user can create a st
3. The parser would retrieve all the relevant information from the input and encapsulates it in a `CreateStudentCommand`.
4. This command would first do these checks:
* checks if the specified path contains the group. This is done via the `ModelManager::hasGroup` method.
* checks if the specified path is a valid student path. This is done via the `Path::isStudentDirectory` method.
* checks if the specified path is a valid student path. This is done via the `AbsolutePath::isStudentDirectory` method.
* checks if adding the student would result in a duplicate within whole of ProfBook, ie if the student id is
already taken. This is done via the `ModelManager::hasStudentWithId` method.
5. In this case, if the input was `touch ~/grp-001/1234Y ...` or `touch ~/grp-001/9876A ...` a `CommandException` will
be thrown.
6. If all checks out, the command would create a new student and add the student to the `Model`. This addition is done
through getting a `GroupChildOperation` class from the `Model::groupChildOperation` method. This would ensure
the path to the group is present and valid. The student is added through the `GroupChildOperation::addChild` method.
through getting a `ChildOperation<Student>` class from the `Model::groupChildOperation` method. This would ensure
the path to the group is present and valid. The student is added through the `ChildOperation<Student>::addChild` method.
7. It should look something like this.

<puml src="diagrams/AddFinalState.puml" width="650" />
Expand All @@ -422,7 +422,7 @@ component, do head over to their respective documentation.

Below is an activity diagram showing the general activity of the add student command.

<puml src="diagrams/CreateStudentActivityDiagram.puml" width="550" />
<puml src="diagrams/CreateStudentActivityDiagram.puml" width="700" />

#### Design Consideration

Expand Down Expand Up @@ -462,14 +462,14 @@ tasks can be found at the `Model` component.


Most of the logic for creating a task is encapsulated in the `CreateDeadlineCommand` class, this class utilises
the `GroupChildOperation` class to add the Deadline to the group and check for duplicates.
The following methods of `ModelManager` and `GroupChildOperation` are used:
the `ChildOperation<Student>` class to add the Deadline to the group and check for duplicates.
The following methods of `ModelManager` and `ChildOperation<Student>` are used:

1. `ModelManager::groupChildOperation` - To generate an operation class specific to the current group, it also checks for
the validity and presence of the specified group.
2. `GroupChildOperation::addAllTasks` - To add the tasks to all student within a group, it also checks if it is a
2. `ChildOperation<Student>::addAllTasks` - To add the tasks to all student within a group, it also checks if it is a
duplicate task before adding.
3. `GroupChildOperation::checkIfAllChildrenHaveTask` - To check if all children within a group already has the task.
3. `ChildOperation<Student>::checkIfAllChildrenHaveTask` - To check if all children within a group already has the task.

It is important to note that for adding a task to a singular group/student, the operation class `TaskOperation` is used
instead, a sequence diagram illustrating this can be found in the `Model` component.
Expand All @@ -488,13 +488,13 @@ Given below is an example usage scenario on how an existing user can add Deadlin
3. The parser would retrieve all the relevant information from the input and encapsulate it in
a `CreateDeadlineCommand`.
4. This command would first
* check if the specified path is a valid and present group path. This is done via `Path::isGroupDirectory` method.
* check if the specified path is a valid and present group path. This is done via `AbsolutePath::isGroupDirectory` method.
* check if all students in the group already has the task. This is done
via `GroupChildOperation::checkIfAllChildrenHaveTask` method.
via `ChildOperation<Student>::checkIfAllChildrenHaveTask` method.
5. If all checks out, the command would create a new `Deadline` instance and add the deadline to all student that do not
already have the aforementioned task. This is done
through getting a `GroupChildOperation` class from the `Model::groupChildOperation` method. The tasks are then
added through the `GroupChildOperation::addTaskToAllStudent` method. For each student, the method would check if the
through getting a `ChildOperation<Student>` class from the `Model::groupChildOperation` method. The tasks are then
added through the `ChildOperation<Student>::addTaskToAllStudent` method. For each student, the method would check if the
task is already present, if not it would add the task.
6. It should look something like this.

Expand All @@ -512,7 +512,7 @@ diagram for adding a deadline task to a *single* student can be found in the `Mo

This is an activity diagram showing the general activity of the add deadline command.

<puml src="diagrams/CreateDeadlineActivityDiagram.puml" width="550" />
<puml src="diagrams/CreateDeadlineActivityDiagram.puml" width="700" />

#### Design Consideration

Expand Down Expand Up @@ -554,8 +554,8 @@ This is an activity diagram showing the general activity of the add deadline com

Due to the dynamic need of our target users, professors and TAs, there is a need for our edit command to be equally dynamic.
Our edit command need to be general enough to allow the users to edit both students and groups. This is done by checking
the type of directory that was passed in. This is done through the `Path::isGroupDirectory`
and `Path::isStudentDirectory` method.
the type of directory that was passed in. This is done through the `AbsolutePath::isGroupDirectory`
and `AbsolutePath::isStudentDirectory` method.

<box type="info" seamless>

Expand All @@ -567,13 +567,13 @@ for `path` package. This then allows parser to check for the validity of the giv
As the implementation for editing students and groups is similar, for simplicity, I would be going through
implementation of editing a group.

The following methods of `ModelManager`, `Path` and `RootChildOperation` are used:
The following methods of `ModelManager`, `AbsolutePath` and `ChildOperation<Group>` are used:

1. `ModelManager::rootChildOperation` - To generate an operation class with logic specific to the current root.
2. `ModelManager::hasGroupWithId` - To check if editing results in a duplicate.
3. `RootChildOperation::editChild` - To edit the group with the values extracted from parser.
4. `Path::isGroupDirectory` - To check if the path leads to a group directory.
5. `Path::isStudentDirectory` - To check if the path leads to a student directory.
3. `ChildOperation<Group>::editChild` - To edit the group with the values extracted from parser.
4. `AbsolutePath::isGroupDirectory` - To check if the path leads to a group directory.
5. `AbsolutePath::isStudentDirectory` - To check if the path leads to a student directory.

Given below is an example usage scenario on how an existing user can edit the name of a group

Expand All @@ -587,7 +587,7 @@ Given below is an example usage scenario on how an existing user can edit the na
4. The fields to be edited is then stored in an `EditGroupDescriptor` instance. (For student it would be stored in
an `EditStudentDescriptor`)
5. If the id is being edited, `ModelManager::hasGroupWithId` is called to ensure it does not result in a duplicate.
6. The `RootChildOperation::editChild` then makes a copy of the existing group while updating the values found in
6. The `ChildOperation<Group>::editChild` then makes a copy of the existing group while updating the values found in
the `EditGroupDescriptor`.

<puml src="diagrams/EditIntermediateState.puml" width="600" />
Expand Down Expand Up @@ -630,7 +630,7 @@ Initially, implementing this feature seemed like a daunting task. However, after
realised that implementing move was quite straight forward. Moving a student can be easily done by removing the
student's reference from its current group by removing its key-value pair from the group's `Map<Id, Student>` field.
Then to complete the move, the student is added to the target group by adding it into the target
group's `Map<Id, Student>` field. All of this operation is facilitated by the `GroupChildOperation` class.
group's `Map<Id, Student>` field. All of this operation is facilitated by the `ChildOperation<Student>` class.

Given below is an example usage scenario whereby a student is moved from group1 to group2.

Expand All @@ -639,8 +639,8 @@ Given below is an example usage scenario whereby a student is moved from group1
user would execute the following command: `mv ~/grp-001/1234Y ~/grp-002`.
3. The parser would extract the relevant information and creates a `MoveStudentCommand` instance.
4. The command would check that path to the student and target group is valid and present.
5. Command would then add the student to the target group via the `GroupChildOperation::addChild` method. The old
reference is removed via the `GroupChildOperation::deleteChild` method.
5. Command would then add the student to the target group via the `ChildOperation<Student>::addChild` method. The old
reference is removed via the `ChildOperation<Student>::deleteChild` method.
6. As uniqueness of student is validated before each student is added, there is no need to check for clashes when
executing.

Expand Down Expand Up @@ -668,7 +668,7 @@ improve this validation by enforcing a tighter validation. This can be achieved
common phone extensions to their length and then enforcing that the phone number be of that length. This allows our
users to have the peace of mind that the phone number is validated and robust enough to handle international numbers.

### Better marking and un-marking validation (// TODO low priority, remove when needed )
### Better marking and un-marking validation

Currently, our application does not check if the tasks are marked or unmarked before any operation. This results in
users being able to mark/un-mark tasks infinitely, this is not intuitive and may mislead some users. Hence, we plan to
Expand All @@ -683,7 +683,7 @@ and only if their ids are identical. This means that two students with identical
considered different in ProfBook, needless to say this does not reflect requirements in the real world. Therefore, we
plan to revamp our duplication checking for students by checking for equality between their phone number and email.

### More descriptive error message (// TODO low priority, remove when needed )
### More descriptive error message

Currently, while our application tries to output a descriptive and apt message for each error, we have received feedback
that some of our error message could be more descriptive. One such example is trying to edit the root `~/` directory or
Expand Down Expand Up @@ -1303,7 +1303,7 @@ need to change according to your current directory. More information can be foun

- Creating a new group,

- Prerequisites: There exist a group with GroupId `grp-001`.<br>
- Prerequisites: No existing group with GroupId grp-001.<br>
Test case: `mkdir grp-001 --name Amazing Group1`<br>
Expected: A new group will be added to the list in the bottom output box, with name `Amazing Group1` and GroupId `grp-001`.

Expand All @@ -1320,13 +1320,13 @@ need to change according to your current directory. More information can be foun

- Adding a student into the specified directory,

- Prerequisites: There exist a group with GroupId `grp-001`
- Prerequisites for all test cases: There exist a group with GroupId `grp-001`

- Prerequisites: ProfBook does not contain a student with id `0199Y`.<br>
Test case: `touch ~/grp-001/0199Y --name Mary --email [email protected] --phone 65412987 --address 4 Loyang Walk Loyang Industrial Estate`<br>
Expected: The student with id `0199Y` will be added to `grp-001`.

- Prerequisites: ProfBook does not contain a student with id`0123Y`.
- Prerequisites: ProfBook does not contain a student with id`0123Y`.<br>
Test case: `touch ~/grp-001/0123Y --name Mary`<br>
Expected: The student with id `0123Y` will be added to `grp-001`.

Expand Down Expand Up @@ -1379,7 +1379,7 @@ need to change according to your current directory. More information can be foun
- Test case: `edit --name Lucy --email [email protected] --phone 91919191`<br>
Expected: An error message indicating the root directory cannot be edited will be shown.

- Other incorrect `edit` commands to try: `edit ~/grp-001 --name Lucy --email [email protected] --phone 91919191`, `...`
- Other incorrect `edit` commands to try: `edit ~/grp-001 --name Lucy --email [email protected] --phone 91919191`, `edit ~/grp-001`
(Where one or more required fields are missing)<br>
Expected: An error message indicating the command format is invalid will be displayed.

Expand Down Expand Up @@ -1592,17 +1592,17 @@ need to change according to your current directory. More information can be foun

- Prerequisites: Place ProfBook.jar in an empty home folder. Perform the following step in the root directory.

- Test case: `todo grp-001/0001Y --desc Assignment One`
- Test case: `todo grp-001/0001Y --desc Assignment One`<br>
Expected: `profbook.json` appears in data folder inside home folder. Student with name `Tejas` has a field history in profbook.json whereas the other students do not. Sample output [here](https://github.com/AY2324S1-CS2103T-W15-2/tp/tree/master/docs/sample/addTodo.json).

- Test case: `rm grp-001/0001Y`
- Test case: `rm grp-001/0001Y`<br>
Expected: `profbook.json` is updated with `Tejas removed`. Sample output [here](https://github.com/AY2324S1-CS2103T-W15-2/tp/tree/master/docs/sample/removeTejas.json).

- Clearing the save file.

- Prerequisites: Have `profbook.json` in the data folder. Perform the previous step if the file isn’t there.

- Test case: `clear`
- Test case: `clear`<br>
Expected: An empty `profbook.json` file like [here](https://github.com/AY2324S1-CS2103T-W15-2/tp/tree/master/docs/sample/empty.json)).

<div style="page-break-after: always;"></div>
Expand Down
4 changes: 2 additions & 2 deletions docs/diagrams/ArchitectureSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ activate ui UI_COLOR
ui -[UI_COLOR]> logic : execute("rm 0001Y")
activate logic LOGIC_COLOR

logic -[LOGIC_COLOR]> model : deletePerson(p)
logic -[LOGIC_COLOR]> model : remove student with id 0001Y
activate model MODEL_COLOR

model -[MODEL_COLOR]-> logic
deactivate model

logic -[LOGIC_COLOR]> storage : saveAddressBook(addressBook)
logic -[LOGIC_COLOR]> storage : saveProfBook(root)
activate storage STORAGE_COLOR

storage -[STORAGE_COLOR]> storage : Save to file
Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/DeleteTaskSequenceModelDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mainframe **sd** Execution of DeleteTaskCommand

activate DeleteTaskCommand

DeleteTaskCommand -> ModelManagerStatic : taskOperation(new Path("~/grp-001"))
DeleteTaskCommand -> ModelManagerStatic : taskOperation(displayPath)
activate ModelManagerStatic

create TaskOperation
Expand Down
Loading