From 61031f5031cabe49e9dd867cdad1207ab6c1574b Mon Sep 17 00:00:00 2001 From: H4mes <123077808+H4mes@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:20:28 +0800 Subject: [PATCH] Update DG with porposed template command --- docs/DeveloperGuide.md | 37 ++++++++++ .../ProposedTemplateSequenceDiagram.puml | 70 +++++++++++++++++++ docs/diagrams/UiClassDiagram.puml | 10 ++- 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 docs/diagrams/ProposedTemplateSequenceDiagram.puml diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 3931afd7592..7e0789a8879 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -264,6 +264,43 @@ The proposed lookup feature is enabled by altering `Article` such that whenever * Make sure Edits and Deletes of Persons and Articles are handled correctly. * Consider including a UI alternative to access the list: Pressing a button in the Article's display will show the list of Persons involved. +### \[Proposed\] Templating of Articles + +The proposed templating feature is enabled by creating a `Template` superclass that `Article` inherits from. + +The `Template` class will have the following attributes: +- `Name` - The name of the template. +- `Authors` - A list of `Person` objects that are the authors of the article. +- `Sources` - A list of `Person` objects that are the sources of the article. +- `Tags` - A list of tags that are associated with the article. + +The `Template` class will also have getter methods for accessing each of the attributes. + +The `Article` class will be augmented to have the `applyTemplate` method, which will take a `Template` object as an argument and apply the template to the article. This will involve setting the `Authors`, `Sources`, `Tags`, and `Status` attributes of the article to the corresponding attributes of the template if the values are not `null`. + +The `Model` component will be augmented with a `UniqueTemplateList` to store the templates. The `Model` will also have methods to add, delete, and list templates. + +#### Proposed Implementation + +Step 1. The user creates a new `Template` object by entering the correct CLI input and providing the index of an article and the attributes to be used in the template. + +Step 2. `MakeTemplateCommandParser` parses the attribute prefixes and corresponding values from the user input. + +Step 3. `MakeTemplateCommand` is created with the parsed attributes. + +Step 4. The newly made `Template` object is added to the `UniqueTemplateList` in the `Model` component and throws an error if there is a duplicate. + +Step 5. The user can apply the template to an article by entering the correct CLI input and providing the index of the article and the index of the template. + +Step 6. `ApplyTemplateCommandParser` parses the indexes from the user input. + +Step 7. `ApplyTemplateCommand` is created with the parsed indexes. + +Step 8. The `ApplyTemplateCommand` is executed, and the template is applied to the article. + +The following sequence diagram shows how the `MakeTemplateCommand` is executed: + + ### \[Proposed\] Data archiving diff --git a/docs/diagrams/ProposedTemplateSequenceDiagram.puml b/docs/diagrams/ProposedTemplateSequenceDiagram.puml new file mode 100644 index 00000000000..2a09b5a7da0 --- /dev/null +++ b/docs/diagrams/ProposedTemplateSequenceDiagram.puml @@ -0,0 +1,70 @@ +@startuml +!include style.puml +skinparam ArrowFontStyle plain + +box Logic LOGIC_COLOR_T1 +participant ":LogicManager" as LogicManager LOGIC_COLOR +participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR +participant ":MakeTemplateCommandParser" as MakeTemplateCommandParser LOGIC_COLOR +participant "d:MakeTemplateCommand" as MakeTemplateCommand LOGIC_COLOR +participant "r:CommandResult" as CommandResult LOGIC_COLOR +end box + +box Model MODEL_COLOR_T1 +participant "m:Model" as Model MODEL_COLOR +end box + +[-> LogicManager : execute("makeTemplate 1 TAG/") +activate LogicManager + +LogicManager -> AddressBookParser : parseCommand("makeTemplate 1 TAG/") +activate AddressBookParser + +create MakeTemplateCommandParser +AddressBookParser -> MakeTemplateCommandParser +activate MakeTemplateCommandParser + +MakeTemplateCommandParser --> AddressBookParser +deactivate MakeTemplateCommandParser + +AddressBookParser -> MakeTemplateCommandParser : parse("1 TAG/") +activate MakeTemplateCommandParser + +create MakeTemplateCommand +MakeTemplateCommandParser -> MakeTemplateCommand +activate MakeTemplateCommand + +MakeTemplateCommand --> MakeTemplateCommandParser : +deactivate MakeTemplateCommand + +MakeTemplateCommandParser --> AddressBookParser : d +deactivate MakeTemplateCommandParser +'Hidden arrow to position the destroy marker below the end of the activation bar. +MakeTemplateCommandParser -[hidden]-> AddressBookParser +destroy MakeTemplateCommandParser + +AddressBookParser --> LogicManager : d +deactivate AddressBookParser + +LogicManager -> MakeTemplateCommand : execute(m) +activate MakeTemplateCommand + +MakeTemplateCommand -> Model : makeTemplate(1 TAG/) +activate Model + +Model --> MakeTemplateCommand +deactivate Model + +create CommandResult +MakeTemplateCommand -> CommandResult +activate CommandResult + +CommandResult --> MakeTemplateCommand +deactivate CommandResult + +MakeTemplateCommand --> LogicManager : r +deactivate MakeTemplateCommand + +[<--LogicManager +deactivate LogicManager +@enduml diff --git a/docs/diagrams/UiClassDiagram.puml b/docs/diagrams/UiClassDiagram.puml index 95473d5aa19..34c0e76f195 100644 --- a/docs/diagrams/UiClassDiagram.puml +++ b/docs/diagrams/UiClassDiagram.puml @@ -13,6 +13,8 @@ Class HelpWindow Class ResultDisplay Class PersonListPanel Class PersonCard +Class ArticleListPanel +Class ArticleCard Class StatusBarFooter Class CommandBox } @@ -33,24 +35,30 @@ UiManager -down-> "1" MainWindow MainWindow *-down-> "1" CommandBox MainWindow *-down-> "1" ResultDisplay MainWindow *-down-> "1" PersonListPanel +MainWindow *-down-> "1" ArticleListPanel MainWindow *-down-> "1" StatusBarFooter MainWindow --> "0..1" HelpWindow PersonListPanel -down-> "*" PersonCard +ArticleListPanel -down-> "*" ArticleCard + MainWindow -left-|> UiPart ResultDisplay --|> UiPart CommandBox --|> UiPart PersonListPanel --|> UiPart -PersonCard --|> UiPart +ArticleListPanel --|> UiPart +ArticleCard --|> UiPart StatusBarFooter --|> UiPart HelpWindow --|> UiPart PersonCard ..> Model +ArticleCard ..> Model UiManager -right-> Logic MainWindow -left-> Logic +ArticleListPanel -[hidden]left- PersonListPanel PersonListPanel -[hidden]left- HelpWindow HelpWindow -[hidden]left- CommandBox CommandBox -[hidden]left- ResultDisplay