diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 683c7dbd7d05..5c12597dc9db 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -372,7 +372,7 @@ The successful execution of `AddJobCommand` adds the `Job` to CarviciM. === Set command feature ==== Current Implementation -.ClassDiagram of CommandWords at runtime +.Object Diagram of CommandWords at runtime image::SetCommandObjectDiagram.png[width="800"] [none] @@ -421,12 +421,97 @@ As you can see from figure 12, AddressBookParser makes a reference to CommandWor // end::set[] // tag::importexport[] -=== Import/Export feature #Coming in v2.0# +=== Import/Save feature ==== Current Implementation -image::blank.png[width="800"] +.Object Diagram of `session` component +image::SessionComponentClassDiagram.png[width="800"] + +`ImportSession` uses a Singleton design pattern. It is responsible for initializing and closing the session. +`ImportSession` has 4 methods: + +* `static getInstance()`: Used to retrieve the single instance of `ImportSession`. +* `setData(sessionData)`: Used to set `sessionData` for `ImportSession`. +* `initialize(fileName)`: Initializes `sessionData` with and excel file located at `fileName`. +* `closeSession()`: Writes the comments as a save file to same directory of import file, + with a timestamp added to the back of the filename. + +`ImportSession` is designed to be stateless on its own, with all data stored in `SessionData`. This helps to +support `UndoableCommand` + +The flow of using `ImportSession` is as follows: + +===== Loading a file into `ImportSession` + +* Figure 14 below shows the process of initializing ImportSession. On the `import` command, +`getInstance` is used to retrieve the `importSession` instance, before it calls +`initialize(fileName)`. A new `SheetParser` is created to populate `sessionData` with excel sheet data +as shown in Figure 11, which comes as: +1. `SheetWithHeaderField`: augmented `Sheet` that provides API to indicate approval status and +write comments. +2. `JobEntry`: Augmented `Job` stores the sheet number and row number for writing into the excel file. +`JobEntry` also contains the `Job` data which will be imported upon approval. ++ +.Sequence Diagram of `ImportSession` initialization +image::SessionInitializationSequenceDiagram.png[width="800"] + +===== Reviewing job entries + +* Figure 15 below shows the process of reviewing job entries in an import session. On the `review` +command, `sessionData` updates the relevant `jobEntry` and retrieves the sheet and row number, +which is used to update `sheetWithHeaderFields`. Upon reviewing a job, CarviciM will add the job and +any employees not present in the application. ++ +.Sequence Digram of `ImportSession` during the reviewing of a job +image::SessionReviewSequenceDiagram.png[width="800"] + +===== Saving feedback from an `ImportSession` + +* Figure 16 below shows the process of saving a session. On the `save` command, `importSession` writes the +modified excel sheets from `sheetWithHeaderFields` to the same path as the imported excel file, with +a timestamp added to the back of the filename. + +.Sequence Digram of `ImportSession` when saving feedback to a file +image::SessionCloseSequenceDiagram.png[width="800"] ==== Design Considerations +===== Aspect: Supporting UndoableCommand + +* **Current choice:** Add the previous instance of `sessionData` when setting data for `Command`, with a +`SaveFileStack` as shown in Figure 11. Load this `sessionData` on `undo` or `redo` command. +** Pros: `sessionData` stores data for `importSession`, making it appropriate to be used as data in `undo` +and `redo`. Modification is only limited to `UndoableCommand`. Single Responsibility Principle is maintained, +as the storage of save file locations is limited to `SaveFileStack`. +** Cons: `sessionData` will have to store the boolean `initialized` in `sessionData` so that it will +stay up-to-date with the `UndoRedoStack`. + +* _Alternative:_ `importSession` provides API to `undo` and `redo`. +** Pros: Open Closed Principle is respected, there is no need to modify `UndoableCommand`. +** Cons: Commands that modify `sessionData` have to be written differently from other commands to support +`undo` and `redo`. The delimiter rule is also violated as `importSession` is unnecessarily involved. + +===== Aspect: Supporting mass add methods addJobs/addMissingEmployees + +* **Current choice:** Add the methods to `Model` +** Pros: Cohesion is maximized, these methods can also be reused by other classes. +** Cons: Open Closed Principle is violated and adding these methods may result in confusion on the +behavior of `Model`. + +* _Alternative:_ Add the methods to `ImportSession` +** Pros: The behavior of these methods can be tailored specifically to `ImportSession`. +** Cons: Unnecessary coupling between `Model` and `ImportSession` when `Command` is already coupled to `Model`. +The Single Responsibility Principle is also violated. + +===== Aspect: Persistent Data + +* **Current choice:** Keep all data from `ImportSession` on `sessionData` and use it to initialize on startup. +** Pros: `ImportSession` gets to stay as a `Singleton`, preventing confusion. +** Cons: There will be increased coupling between `Session` and `Storage`. + +* _Alternative:_ Combine `ImportSession` and `SessionData` into 1 single class and store +it directly. +** Pros: `ImportSession` can be directly initialized on startup and coupling is reduced. +** Cons: Confusion may occur due to allowing more than one `ImportSession`. // end::importexport[] // tag::theme[] diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index cef04cf8f9e5..e09e893d4037 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -330,13 +330,14 @@ Examples: ==== Sharing your feedback with your employees -If you want to share your feedback, you can export it as an excel file, reflecting accept/reject with comments. -Format: `export FILE_PATH` +If you want to share your feedback, you can save it as an excel file, reflecting accept/reject with comments. +Format: `save FILE_PATH` [TIP] ==== * You can type any filename supported by your computer's storage format. -* If you forgot to export your feedback, you can find it under C:\User\Documents\CarviciM\feedback.xls. +* If you forgot to save your feedback, you can find it in the same directory as the imported excel file, with the time +it is saved added to the end of the filename. * The feedback file's format is support for future imports. ==== diff --git a/docs/images/SessionCloseSequenceDiagram.png b/docs/images/SessionCloseSequenceDiagram.png new file mode 100644 index 000000000000..e18bc542254d Binary files /dev/null and b/docs/images/SessionCloseSequenceDiagram.png differ diff --git a/docs/images/SessionComponentClassDiagram.png b/docs/images/SessionComponentClassDiagram.png index fe81a7a76ab2..fd4eb20911d6 100644 Binary files a/docs/images/SessionComponentClassDiagram.png and b/docs/images/SessionComponentClassDiagram.png differ diff --git a/docs/images/SetCommandObjectDiagram.png b/docs/images/SetCommandObjectDiagram.png index 54f925f88a67..9b2e8d2d49c6 100644 Binary files a/docs/images/SetCommandObjectDiagram.png and b/docs/images/SetCommandObjectDiagram.png differ diff --git a/docs/images/sessionInitializationSequenceDiagram.png b/docs/images/sessionInitializationSequenceDiagram.png index d127a159d84e..94af2edc95f3 100644 Binary files a/docs/images/sessionInitializationSequenceDiagram.png and b/docs/images/sessionInitializationSequenceDiagram.png differ diff --git a/docs/images/sessionReviewSequenceDiagram.png b/docs/images/sessionReviewSequenceDiagram.png index 5669e9c995d4..626df0a64503 100644 Binary files a/docs/images/sessionReviewSequenceDiagram.png and b/docs/images/sessionReviewSequenceDiagram.png differ diff --git a/src/main/java/seedu/carvicim/storage/session/ImportSession.java b/src/main/java/seedu/carvicim/storage/session/ImportSession.java index 973b216e63e2..1db79bd6ddf1 100644 --- a/src/main/java/seedu/carvicim/storage/session/ImportSession.java +++ b/src/main/java/seedu/carvicim/storage/session/ImportSession.java @@ -151,27 +151,4 @@ private void freeResources() { inFile = null; outFile = null; } - - /** - * For localized testing purposes - */ - public static void main(String[] args) { - ImportSession importSession = getInstance(); - String path; - try { - path = new File(".").getCanonicalPath(); - System.out.println(path); - } catch (IOException e) { - e.printStackTrace(); - } - try { - importSession.initializeSession( - ".\\src\\test\\resources\\model.session.ImportSessionTest\\CS2103-testsheet.xlsx"); - importSession.reviewAllRemainingJobEntries(true); - importSession.closeSession(); - } catch (Exception e) { - e.printStackTrace(); - } - - } }