Skip to content

Commit

Permalink
Merge pull request #518 from bryanljx/bryan/update-tag-DG
Browse files Browse the repository at this point in the history
Update DG Tag implementations
  • Loading branch information
RichDom2185 authored Nov 6, 2022
2 parents 8668109 + a82627f commit 8c662fb
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 4 deletions.
22 changes: 21 additions & 1 deletion docs/_dg/implementations/TagFeatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,24 @@ Here is the sequence diagram showing the interactions between the different comp
When the `TagCommand` is executed to tag a tag to an item, a copy of the item is created and the tag is added to it before replacing this new copy of the item with the original item in the list of items in FoodRem. We chose to replace the original item with the new item because this will allow the UI to detect a change in the `UniqueItemList` and thus update and show the item with their new tag included.

#### Filtering Items by Tag Name
<!-- TODO: Fill up -->

##### Overview

The `filtertag` command filters the Item List for items tagged with the specified `tag`.

##### Feature Details

Here is the activity diagram showing the process of the `tag` command:

![FilterTagItemActivityDiagram](images/FilterTagActivityDiagram.png)


Here is the sequence diagram showing the interactions between the different components during a `tag` command.

![FilterTagSequenceDiagram](images/FilterTagSequenceDiagram.png)

1. The user specifies a tag name of the tag to filter for.
1. If the tag name is not provided, the user will be prompted to enter the command correctly via an error message.
1. The tag name is cross-referenced with the current tags in the database and an error is thrown if the tag does not exist in the database.
1. If the tag name is valid, the model filters the Item List for items that are tagged with this specified tag.
1. If step 1 - 4 successfully complete, the displayed Item List in the GUI will be updated to only display items tagged with the specified tag.
18 changes: 18 additions & 0 deletions docs/diagrams/FilterTagActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@startuml
!pragma useVerticalIf on
start
:User enters filtertag command;
if () then ([else])
:Error:Invalid command format;
stop
([tag name provided]) elseif () then ([else])
:Error: Tag does not exist;
stop
else ([tag exists in model])
endif
-Model filters Item List for items that are tagged with the tag specified.
:FilterTag Command successfully executes.
Item gets tagged with tag.;
stop

@enduml
90 changes: 90 additions & 0 deletions docs/diagrams/FilterTagSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":FoodRemParser" as FoodRemParser LOGIC_COLOR
participant ":FilterTagCommandParser" as FilterTagCommandParser LOGIC_COLOR
participant ":Tag" as Tag LOGIC_COLOR
participant ":FilterTagCommand" as FilterTagCommand LOGIC_COLOR
participant ":TagSetContainsTagPredicate" as TagSetContainsTagPredicate LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR


end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box

[-> LogicManager : execute("filtertag n/tagname")
activate LogicManager

LogicManager -> FoodRemParser : parseCommand("filtertag n/tagname")
activate FoodRemParser

create FilterTagCommandParser
FoodRemParser -> FilterTagCommandParser
activate FilterTagCommandParser


FilterTagCommandParser --> FoodRemParser
deactivate FilterTagCommandParser


FoodRemParser -> FilterTagCommandParser : parse("n/tagname")
activate FilterTagCommandParser

create Tag
FilterTagCommandParser -> Tag
activate Tag
Tag --> FilterTagCommandParser
deactivate Tag

create FilterTagCommand
FilterTagCommandParser -> FilterTagCommand : FilterTagCommand(tag)
activate FilterTagCommand

create TagSetContainsTagPredicate
FilterTagCommand --> TagSetContainsTagPredicate
activate TagSetContainsTagPredicate

TagSetContainsTagPredicate --> FilterTagCommand
deactivate TagSetContainsTagPredicate

FilterTagCommand --> FilterTagCommandParser :
deactivate FilterTagCommand

FilterTagCommand --> FoodRemParser :
deactivate FilterTagCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
FilterTagCommandParser -[hidden]-> FoodRemParser
destroy FilterTagCommandParser

FoodRemParser --> LogicManager :
deactivate FoodRemParser

LogicManager -> FilterTagCommand : execute(model)
activate FilterTagCommand


FilterTagCommand -> Model : updateFilteredItemList(pred)
activate Model

Model --> FilterTagCommand
deactivate Model

create CommandResult
FilterTagCommand -> CommandResult
activate CommandResult

CommandResult --> FilterTagCommand
deactivate CommandResult

FilterTagCommand --> LogicManager
deactivate FilterTagCommand

[<--LogicManager
deactivate LogicManager
@enduml
4 changes: 2 additions & 2 deletions docs/diagrams/NewTagSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end box
[-> LogicManager : execute("newtag n/tagname")
activate LogicManager

LogicManager -> FoodRemParser : parseCommand("newtag n/tagname")
LogicManager -> FoodRemParser : parseCommand("n/tagname")
activate FoodRemParser

create NewTagCommandParser
Expand All @@ -32,7 +32,7 @@ NewTagCommandParser --> FoodRemParser
deactivate NewTagCommandParser


FoodRemParser -> NewTagCommandParser : parse("newtag n/tagname")
FoodRemParser -> NewTagCommandParser : parse("n/tagname")
activate NewTagCommandParser

create Tag
Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/TagSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ activate TagCommandParser
TagCommandParser --> FoodRemParser
deactivate TagCommandParser

FoodRemParser -> TagCommandParser : parse("tag 1 n/tagname")
FoodRemParser -> TagCommandParser : parse("1 n/tagname")
activate TagCommandParser

create TagCommand
Expand Down
Binary file added docs/images/FilterTagActivityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/FilterTagSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/NewTagSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/TagSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8c662fb

Please sign in to comment.