Skip to content

Commit

Permalink
Update DG with porposed template command
Browse files Browse the repository at this point in the history
  • Loading branch information
H4mes committed Mar 29, 2024
1 parent b3d5839 commit 61031f5
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 1 deletion.
37 changes: 37 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<puml src="diagrams/ProposedTemplateSequenceDiagram.puml" alt="Proposed Sequence Diagram for MakeTemplateCommand" />

### \[Proposed\] Data archiving

Expand Down
70 changes: 70 additions & 0 deletions docs/diagrams/ProposedTemplateSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 9 additions & 1 deletion docs/diagrams/UiClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Class HelpWindow
Class ResultDisplay
Class PersonListPanel
Class PersonCard
Class ArticleListPanel
Class ArticleCard
Class StatusBarFooter
Class CommandBox
}
Expand All @@ -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
Expand Down

0 comments on commit 61031f5

Please sign in to comment.