diff --git a/docs/_dg/implementations/TagFeatures.md b/docs/_dg/implementations/TagFeatures.md index 27860ae9ba5..731ab6594ba 100644 --- a/docs/_dg/implementations/TagFeatures.md +++ b/docs/_dg/implementations/TagFeatures.md @@ -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 - + +##### 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. diff --git a/docs/diagrams/FilterTagActivityDiagram.puml b/docs/diagrams/FilterTagActivityDiagram.puml new file mode 100644 index 00000000000..9f3ba344ad0 --- /dev/null +++ b/docs/diagrams/FilterTagActivityDiagram.puml @@ -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 diff --git a/docs/diagrams/FilterTagSequenceDiagram.puml b/docs/diagrams/FilterTagSequenceDiagram.puml new file mode 100644 index 00000000000..284afb4b61b --- /dev/null +++ b/docs/diagrams/FilterTagSequenceDiagram.puml @@ -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 diff --git a/docs/diagrams/NewTagSequenceDiagram.puml b/docs/diagrams/NewTagSequenceDiagram.puml index b4eb53c93e2..af1da724603 100644 --- a/docs/diagrams/NewTagSequenceDiagram.puml +++ b/docs/diagrams/NewTagSequenceDiagram.puml @@ -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 @@ -32,7 +32,7 @@ NewTagCommandParser --> FoodRemParser deactivate NewTagCommandParser -FoodRemParser -> NewTagCommandParser : parse("newtag n/tagname") +FoodRemParser -> NewTagCommandParser : parse("n/tagname") activate NewTagCommandParser create Tag diff --git a/docs/diagrams/TagSequenceDiagram.puml b/docs/diagrams/TagSequenceDiagram.puml index e1e08cc6c59..d2df6cb4fc5 100644 --- a/docs/diagrams/TagSequenceDiagram.puml +++ b/docs/diagrams/TagSequenceDiagram.puml @@ -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 diff --git a/docs/images/FilterTagActivityDiagram.png b/docs/images/FilterTagActivityDiagram.png new file mode 100644 index 00000000000..dc6145d8f94 Binary files /dev/null and b/docs/images/FilterTagActivityDiagram.png differ diff --git a/docs/images/FilterTagSequenceDiagram.png b/docs/images/FilterTagSequenceDiagram.png new file mode 100644 index 00000000000..10007e8bf86 Binary files /dev/null and b/docs/images/FilterTagSequenceDiagram.png differ diff --git a/docs/images/NewTagSequenceDiagram.png b/docs/images/NewTagSequenceDiagram.png index 4fbe2064707..2808d90637f 100644 Binary files a/docs/images/NewTagSequenceDiagram.png and b/docs/images/NewTagSequenceDiagram.png differ diff --git a/docs/images/TagSequenceDiagram.png b/docs/images/TagSequenceDiagram.png index 6585dade3af..f8882419b9e 100644 Binary files a/docs/images/TagSequenceDiagram.png and b/docs/images/TagSequenceDiagram.png differ