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

Update DG Storage Components and Implementation #190

Merged
merged 19 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 8 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
224 changes: 195 additions & 29 deletions docs/DeveloperGuide.md

Large diffs are not rendered by default.

Binary file added docs/attachments/AddingContentSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/attachments/StorageComponent.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/attachments/StorageInitializeSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions docs/uml/content/AddingContentSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@startuml
'https://plantuml.com/sequence-diagram

skinparam sequenceMessageAlign center

box Command #thistle
participant ":AddNoteCommand" as AddNoteCommand #violet
endbox

box Content #goldenrod
participant ":ContentManager" as ContentManager #gold
participant ":Note" as Note #gold
endbox

-> AddNoteCommand : execute()
activate AddNoteCommand
create Note
AddNoteCommand -> Note : Note()
activate Note
return
AddNoteCommand -> ContentManager : add(:Note)
activate ContentManager
note right : Add the new Note into \nthe arraylist of Note \nin ContentManager.
return
return :CommandResult

@enduml
36 changes: 36 additions & 0 deletions docs/uml/content/DeletingContentSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@startuml
'https://plantuml.com/sequence-diagram


skinparam sequenceMessageAlign center

box Command #thistle
participant ":DeleteCommand" as DeleteCommand #violet
endbox

box Content #goldenrod
participant ":ContentManager" as ContentManager #gold
participant ":Content" as Content #gold
endbox

-> DeleteCommand : execute()
activate DeleteCommand
DeleteCommand -> ContentManager : deleteContent(contentNumber:int)
activate ContentManager
ContentManager -> ContentManager : isNotValidNumber(:int)
activate ContentManager
note left : Invalid contentNumber: \ncontentNumber < 1 and \ncontentNumber > the size of arraylist
return
alt contentNumber is not valid
ContentManager --> DeleteCommand : InvalidArgumentException()
else else
ContentManager -> Content : getName()
activate Content
return
note left : Remove the Content from \nthe arraylist of Content \nin ContentManager.
destroy Content
end
return deletedContentName:String
return :CommandResult

@enduml
48 changes: 0 additions & 48 deletions docs/uml/storage/AddModuleStorage.puml

This file was deleted.

34 changes: 0 additions & 34 deletions docs/uml/storage/AddNoteCommand_Storage_SequenceDiagram.puml

This file was deleted.

48 changes: 0 additions & 48 deletions docs/uml/storage/DeleteModuleCommand_Storage_SequenceDiagram.puml

This file was deleted.

95 changes: 69 additions & 26 deletions docs/uml/storage/Storage.puml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@startuml
'https://plantuml.com/class-diagram


hide circle
skinparam classAttributeIconSize 0

'abstract class DGS
'abstract AbstractCollection
Expand All @@ -15,38 +16,80 @@
'AbstractCollection <|- AbstractList
'AbstractList <|-- ArrayList

Terminus "1" --> "1 " ModuleStorage: moduleStorage
StorageManager --> "1" NoteStorage
StorageManager --> "1" PdfStorage
StorageManager --> "1" JsonStorage
StorageManager --> "1" FolderStorage

FilterManager <.. StorageManager : "filters \n ModuleManager <"

Command "0..* " ..> "0..1 " ModuleStorage: uses >
NoteStorage --|> Storage
PdfStorage --|> Storage
JsonStorage --|> Storage
FolderStorage --|> Storage

class Terminus {
+ main(): void {static}
+ run(): void
- start(): void
- runUntilCommandExit(): void
- handleIoException(e: IOException): void
- exit(): void
class StorageManager #mistyrose{
- isDisabled : Boolean
- baseDirectory : Path
+ StorageManager(Path baseDirectory, String mainJsonFileName)
+ executeCommandResult(ModuleManager moduleManager, CommandResult result) : void
+ updateMainJsonFile(ModuleManager moduleManager) : void
+ initialize() : ModuleManager
+ save() : void
}

class ModuleStorage {
- filePath: Path
- gson: Gson
- ModuleStorage()
+ init(filePath: Path): void
+ getInstance(): ModuleStorage {static}
+ loadFile(): ModuleManager
+ saveFile(moduleManager: ModuleManager): void
+ loadNotesFromModule(moduleManager: ModuleManager, mod: String): void
+ saveAllNotes(moduleManager: ModuleManager): void
+ saveNotesFromModule(moduleManager: ModuleManager, mod: String, toDeleteAll: Boolean): void
+ removeNoteFromModule(moduleName: String, noteName, String): void
+ addNoteFromModule(moduleName: String, newNote: Note): void
+ createModuleDirectory(moduleName: String): boolean
+ cleanAfterDeleteModule(mod: String): void
class NoteStorage #mistyrose{
+ execute() : void
# createNoteFile() : void
# loadNoteIntoModuleManager() : void
# saveAllNotes() : void
}

abstract Command {
class PdfStorage #mistyrose{
+ execute() : void
# exportModuleNotes() : void
}

class JsonStorage #mistyrose{
+ execute() : void
+ loadJson() : ModuleManager
# createJson() : void
# saveJson() : void
}

class FolderStorage #mistyrose{
+ execute() : void
# createModuleFolder() : void
# deleteModuleFolder() : void
# renameModuleFolder() : void
}

class Storage #mistyrose{
+ createFolder(Path folderPath) : void
+ createFile(Path filePath) : void
+ readFile(Path filePath) : String
+ writeFile(Path filePath, String data): void
+ delete(Path filePath) : void
+ getListOfFiles(Path folderPath) : File[]
+ renameFolder(Path oldPath, Path newPath) : void
+ getBufferedReader(Path filePath) : void
+ getFileType(File file) : String
+ getAppendPath(Path corePath, String path) : Path
# cleanAllFilesInclusive(Path filePath) : void

}

class FilterManager #mistyrose{
+ filter(ModuleManager moduleManager) : void
# filterLink(ContentManager<Link> linkContentManager) : void
# filterQuestion(ContentManager<Question> questionContentManager) : void
+ {static} isQuestionValid(Question question) : Boolean
+ {static} isScheduleValid(Link link) : Boolean
+ {static} isModuleValid(String module) : Boolean

}

note "The input parameters in all functions \nfor <Type>Storage has been left out \nto make this diagram more compact." as note1


@enduml
50 changes: 50 additions & 0 deletions docs/uml/storage/StorageCommandResultSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@startuml
'https://plantuml.com/sequence-diagram

skinparam sequenceMessageAlign center

box Terminus #whitesmoke
participant ":Terminus" as Terminus #white
endbox

box Storage #lightpink
participant ":StorageManager" as StorageManager #mistyrose
participant ":JsonStorage" as JsonStorage #mistyrose
participant ":PdfStorage" as PdfStorage #mistyrose
participant ":FolderStorage" as FolderStorage #mistyrose
participant ":NoteStorage" as NoteStorage #mistyrose
endbox


activate Terminus
opt CommandResult has data change
Terminus -> StorageManager : executeCommandResult(:ModuleManager, :CommandResult)
activate StorageManager
StorageManager -> StorageManager : execute()
activate StorageManager
note right : execute() takes in the following arguments \n\nmoduleManager : ModuleManager \naffectedModule : String \ndeletedItemName : String \nstorageAction : StorageActionEnum \nstorageType : StorageTypeEnum
alt StorageTypeEnum == JSON
StorageManager -> JsonStorage : execute(moduleManager, storageAction)
activate JsonStorage
return
else PDF
StorageManager -> PdfStorage : execute(affectedModule, deletedItemName, storageAction)
activate PdfStorage
return
else FOLDER
StorageManager -> FolderStorage : execute(affectedModule, deletedItemName, storageAction)
activate FolderStorage
return
else NOTE
StorageManager -> NoteStorage : execute(moduleManager, affectedModule, deletedItemName, storageAction)
activate NoteStorage
return
end
return
return
end




@enduml
Loading