Skip to content

Commit 5ae9620

Browse files
authored
Merge pull request #175 from owenong1/branch-ImportExportDG
Import/Export DG updates
2 parents ad50657 + 00fa35c commit 5ae9620

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

docs/DeveloperGuide.md

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
--------------------------------------------------------------------------------------------------------------------
1313

1414
## **Acknowledgements**
15-
This project is based on [AddressBook Level 3](https://se-education.org/docs/templates.html#addressbook-level-3-ab3).
15+
This project is based on [AddressBook Level 3](https://se-education.org/docs/templates.html#addressbook-level-3-ab3).
1616

1717
--------------------------------------------------------------------------------------------------------------------
1818

@@ -129,8 +129,8 @@ How the parsing works:
129129
The `Model` component,
130130

131131
* Stores the EventBook data i.e., all `Person` objects (which are contained in a `UniquePersonList` object) and all `Tag` objects (which are contained in a `UniqueTagList` object).
132-
* Not modelled in diagram due to limitations of PlantUML: `UniqueTagList` object storing EventTags.
133-
* The `UniqueTagList` class involves the use of generics to allow it to store both `Tag` and `EventTag` objects.
132+
* Not modelled in diagram due to limitations of PlantUML: `UniqueTagList` object storing EventTags.
133+
* The `UniqueTagList` class involves the use of generics to allow it to store both `Tag` and `EventTag` objects.
134134
* Each EventBook stores a list of tags of type `UniqueTagList<Tag>` and a list of event tags of type `UniqueTagList<EventTag>`. However PlantUML is unable to capture the <Tag> and <EventTag> portion, hence we were unable to include the EventTag list in the diagram.
135135
* Stores the currently 'selected' `Person` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList<Person>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
136136
* Stores a `UserPref` object that represents the user’s preferences. This is exposed to the outside as a `ReadOnlyUserPref` objects.
@@ -170,7 +170,7 @@ Given below is an example usage scenario and how delete mechanism behaves at eac
170170

171171
Step 1: The user launches the application. The application will be in its initial state showing the full list of contacts in the EventBook.
172172

173-
Step 2: The user executes `delete John Doe` command to delete the person named John Doe in the EventBook.
173+
Step 2: The user executes `delete John Doe` command to delete the person named John Doe in the EventBook.
174174

175175
<box type="info" seamless>
176176

@@ -372,35 +372,46 @@ When `executeCommand::MainWindow` is called to update the UI after the execution
372372

373373
### Importing and Exporting as .csv file
374374

375-
As student leaders, a common and easily accessible file format type for event contacts would be .csv. Eventbook
376-
aims to support the ability to import and export contacts using .csv files to facilitate fast and effective contact
377-
upload and sharing.
375+
The import/export commands allow one to easily share contact data.
376+
As student leaders, a common and easily accessible file format type for event contacts would be .csv.
377+
Eventbook supports the ability to import and export contacts using .csv files to facilitate fast and effective contact upload and sharing.
378378

379-
The proposed mechanism is as follows:
380-
* Import: Facilitated by the `import` command that takes a path parameter. The file named `import.csv` at the given
381-
path will be read in a set format. The contact details in the csv will then be imported into the address book following
382-
the format of the add command (Implication being that each field in the .csv should be compatible with the current
383-
implementation of the address book, and follow all conventions of the add command like formatting and non-duplicates)
384-
* Export: Facilitated by the `export` command that takes no parameters. The command will access the `UniquePersonList`
385-
found in the `1AddressBook` of the `Model` and parse through the relevant data, formatting it into the relevant fields.
379+
#### Implementation (Export)
380+
* The Export feature is facilitated by the ExportCommand class which extends the Command class.
381+
* In `ExportCommand::execute`, a reference to the current model is passed to the `ExportCommand::exportFile` call
382+
* `ExportCommand::exportFile` accesses the model's Person data through `model.getFilteredPersonList()`
383+
* For each Person, `ExportCommand::exportFile` accesses their details through the respective getters (e.g.`Person::getName()`)
384+
and writes their details to a .csv file through a FileWriter object
386385

387-
The .csv should be formatted with the first row having the non-case sensitive headers (separate cells marked with `|`):
388-
* `Name | Number | Email | Address | Tag`
389-
390-
An example usage scenario illustrates how the import feature operates:
386+
An example usage scenario illustrates how the export feature operates:
391387
1. The user launches the application. The application will be in its initial state showing the full list of contacts
392388
in the EventBook.
393-
2. The user executes `import ./import/import.csv` , with import.csv having 2 rows:
394-
1. `Name | Number | Email | Address | Tag`
395-
2. `John | 94756383 | john@mail.com | NUS UTown | BestFriend`
396-
3. The contact `John` is imported into the address book, with parameters as above.
389+
2. The user executes `export` to export all contacts
390+
3. All contacts in the address book will be exported to ./export/export.csv according to the format given above
391+
392+
#### Implementation (Import)
393+
* The Import feature is facilitated by the following classes:
394+
* `ImportCommand` which extends Command
395+
* `ImportCommandParser` which extends Parser
396+
* In `ImportCommandParser::parse`, the user input is parsed to determine the path of the file to be imported,
397+
and an `ImportCommand` object is returned with the parsed path (a default path is given if none is specified)
398+
* In `ImportCommand::execute`, a reference to the current model is passed and the following are called:
399+
* `ImportCommand::parse` parses the given file and stores the data in an `ArrayList` object. The data
400+
* `ImportCommand::checkFields` is called on the parsed data to check the fields. The field data is subsequently removed
401+
* `ImportCommand::addPersons` uses the parsed Person data and simulates adding them to the model through the Add command
402+
* `ImportCommand::loadEventTags` adds and assigns EventTags to the model separately, since the Add command does not support this functionality
397403

398-
An example usage scenario illustrates how the export feature operates:
404+
An example usage scenario illustrates how the import feature operates:
399405
1. The user launches the application. The application will be in its initial state showing the full list of contacts
400406
in the EventBook.
401-
2. The user executes `export` to export all contacts
402-
3. All contacts in the address book will be exported to ./export/export.csv according to the format
403-
`Name | Number | Email | Address | Tag`
407+
2. The user executes `import f/./import/import.csv` , with import.csv having 2 rows:
408+
1. `NAME,NUMBER,EMAIL,ADDRESS,EVENTS,TAGS`
409+
2. `John,94756383,john@mail.com,NUS,Orientation,BestFriend|Cool`
410+
3. The contact `John` is imported into the address book, with parameters as above (He is assigned the existing EventTag Orientation as well)
411+
412+
#### Format of the .csv files
413+
* The format of the first line of the csv should contain the fields:
414+
`NAME,NUMBER,EMAIL,ADDRESS,EVENTS,TAGS` (.csv is comma delimited, so that means each field should be in their own cell)
404415

405416
--------------------------------------------------------------------------------------------------------------------
406417

@@ -839,7 +850,7 @@ switch hello
839850
--------------------------------------------------------------------------------------------------------------------
840851
<div style="page-break-after: always;"></div>
841852

842-
## **Appendix: Enhancement**
853+
## **Appendix: Enhancement (Team Size 5)**
843854

844855
1. **To show custom error for wrong time in `ctag` command**: When creating event tags with the `ctag` command,
845856
you will not get notified correctly on why you failed when you input the incorrect time(like 25:73:74 in the 24-hour
@@ -871,4 +882,7 @@ We plane to make the window readjust properly for the future app instead of disp
871882
7. **Length inputs to be displayed in full in the EventBook**: In the current implementation,
872883
lengthy inputs for the fields appear to not be displayed in full by the UI as shown in the image below. ![](images/DG/DG_Enhancement_Lengthy.png)
873884
We plan to make the display in full for up to 3 lines' length of information in the contact panel.
885+
8. **Import to support ignoring contacts that already exist**: The current implementation will throw an error
886+
when importing a file contacts that have the same name as an existing contact. We plan to make it so the import
887+
command will still import non-conflicting contacts when this happens.
874888

0 commit comments

Comments
 (0)