Skip to content

Commit

Permalink
Merge pull request #182 from melpulomas/master
Browse files Browse the repository at this point in the history
Mid 1.4
  • Loading branch information
jtankw3 authored Apr 8, 2019
2 parents 0295e01 + 4688897 commit 3d0c4fb
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 66 deletions.
1 change: 0 additions & 1 deletion PDF/foo.txt

This file was deleted.

89 changes: 51 additions & 38 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -461,60 +461,46 @@ image::UndoRedoActivityDiagram.png[width="650"]
** Cons: Requires dealing with commands that have already been undone: We must remember to skip these commands. Violates Single Responsibility Principle and Separation of Concerns as `HistoryManager` now needs to do two different things.
// end::undoredo[]

// tag::dataencryption[]
=== [Proposed] Data Encryption

Data encryption is likely to be implemented in future versions of the MediTabs if a reasonable implementation is found.

==== Design Considerations
// tag::labelcommand[]
=== Medicine Label using Label Command

===== Aspect: How data encryption is executed
Users can use the command to output medicines information to a specific folder. Information will be in Portable Document Format (PDF) files.

* **Alternative 1:** Encrypt the entire inventory.
** Pros: Easy to implement. Use pre-existing encryption libraries to encrypt the entire inventory.
** Cons: May have performance issues when encrypting/decrypting large amounts of data.
* **Alternative 2:** Only encrypt parts of the inventory user selects.
** Pros: More efficient in terms of performance (cuts down on encryption/decryption time).
** Cons: Add `encrypt` and `decrypt` command to allow user to choose what needs to be encrypted and decrypted respectively. Need to encrypt/decrypt different chunks of data correctly.
Current implementation:
Under the build.gradle file, we have added new dependency implementation group: `org.apache.pdfbox`, name: `pdfbox`, version: `2.0.13`. This imports the library over to the project for use.

===== Aspect: Data structure to support data encryption
There are many operations available added in the Apache PDFBox, the key operations that we are using would only be:

* **Alternative 1:** Save the entire inventory as encrypted data in the database.
** Pros: Data is secure and not viewable without encryption key.
** Cons: Implement log in page for decryption of inventory. Require alternative if encryption key is forgotten.
* **Alternative 2:** Save encrypted parts of inventory and plaintext in database.
** Pros: Able to salvage some information if encryption key is lost.
** Cons: Need to implement packing/unpacking of encrypted data and plaintext during startup/shutdown.
* `PDDocument()` - For creating a new blank PDF file for the medicine details to be exported to.
* `PDPage()` - Creates a new PDPage instance for embedding.
* `PDPageContentStream(PDDocument, PDPage)` - Provides the ability to write a page content stream.

// end::dataencryption[]
The following sequence diagram shows how the label operation works:

// tag::labelcommand[]
=== Exporting Medicine Label
image::LabelUML.png[width="800"]
Fig 4.4.1

The exporting of a medicine label to a PDF formatted file is implemented by using Apache PDFBox.
==== Usage scenario example
===== Below shows how the label command behaves in each step:

Current implementation:
Under the build.gradle file, we have added new dependency implementation group: `org.apache.pdfbox`, name: `pdfbox`, version: `2.0.13`. This imports the library over to the project for use.
. The user launches the application for the first time. An empty InformationPanel is displayed. (Fig 4.5.2 )

There are many operations available added in the Apache PDFBox, the key operations that we are using would only be:
. The user executes the `label 2` to output the label of the 2nd medicine indexed in the inventory. Since no file name is included in the argument, the default filename 'to_print' is used instead. `LabelCommand#execute()` is called.

`PDDocument()` - For creating a new blank PDF file for the medicine details to be exported to.
`PDPage()` - Creates a new PDPage instance for embedding.
`PDPageContentStream(PDDocument , PDPage)` - Provides the ability to write a page content stream.
. The user can find the file `to_print` under the main folder. (Fig 4.5.3)

image::UMLLabelDiagram.png[width="800"]

Given below is an example usage scenario and how the label command behaves in each step:
image::label2_taken.png[width="790"]
Fig 4.4.1.1

Step 1. The user launches the application for the first time. An empty InformationPanel is displayed.
image::mainPDF.png[width="790"]
Fig 4.4.1.2 (PDF folder highlighted)

Step 2. The user executes the `label 2` to output the label of the 2nd medicine indexed in the inventory. Since no file name is included in the argument, the default filename 'to_print' is used instead. Then, `LabelCommand#execute()` is called.
===== Label command with filename specified

Step 3. The user can find the file `to_print` under the main folder.
. The user executes `label 1 f/file_to_print` to output the label of the 1st medicine indexed in the inventory. The `LabelCommandParser` class will be able to tokenize and read the desired file name. Then, `LabelCommand#execute()` is called.

Step 4. The user executes `label 1 f/file_to_print` to output the label of the 1st medicine indexed in the inventory. The `LabelCommandParser` class will be able to tokenize and read the desired file name. Then, `LabelCommand#execute()` is called.

Step 5. The user can find a new file `file_to_print` under the same main folder.
. The user can find a new file `file_to_print` under the same main folder.

[NOTE]
If the user would execute another `label 1`, the original `to_print` file will be replaced with the information of the 1st medicine indexed in the inventory. Users are warned in the User Guide to be caution about overwriting files.
Expand All @@ -532,6 +518,33 @@ If the user would execute another `label 1`, the original `to_print` file will b

// end::labelcommand[]

// tag::dataencryption[]
=== [Proposed] Data Encryption

Data encryption is likely to be implemented in future versions of the MediTabs if a reasonable implementation is found.

==== Design Considerations

===== Aspect: How data encryption is executed

* **Alternative 1:** Encrypt the entire inventory.
** Pros: Easy to implement. Use pre-existing encryption libraries to encrypt the entire inventory.
** Cons: May have performance issues when encrypting/decrypting large amounts of data.
* **Alternative 2:** Only encrypt parts of the inventory user selects.
** Pros: More efficient in terms of performance (cuts down on encryption/decryption time).
** Cons: Add `encrypt` and `decrypt` command to allow user to choose what needs to be encrypted and decrypted respectively. Need to encrypt/decrypt different chunks of data correctly.

===== Aspect: Data structure to support data encryption

* **Alternative 1:** Save the entire inventory as encrypted data in the database.
** Pros: Data is secure and not viewable without encryption key.
** Cons: Implement log in page for decryption of inventory. Require alternative if encryption key is forgotten.
* **Alternative 2:** Save encrypted parts of inventory and plaintext in database.
** Pros: Able to salvage some information if encryption key is lost.
** Cons: Need to implement packing/unpacking of encrypted data and plaintext during startup/shutdown.

// end::dataencryption[]

// tag::warningpanel[]
=== Warning Panel
==== Current Implementation
Expand Down
38 changes: 29 additions & 9 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -437,44 +437,64 @@ From the image above, you can observe that the exported CSV file only contains e
You would observe that medicines without any batches are not included in the exported CSV file. This is by design, as our team believes that the exported CSV file should only provide *useful detailed information*. Medicines without any batches would not have any useful information such as the quantity and expiry dates which are important when it comes to keeping track of your medicine inventory.
// end::exportcommand[]

// tag::labelcommand[]
=== Printing labels : `label`

You can label any specific medicine information in the inventory using the Portable Document Format (PDF). +
Open the PDF file under the PDF folder to view and print your selected medicine +
Label will include name of medicine and standard label template. +
- You can label any specific medicine information in the inventory through the Portable Document Format (PDF). +
Open the PDF file under the PDF folder to view and print your selected medicine. +
- Label will include name of medicine and standard label template. +
This includes the company that manufactured it, expiry date and the tags that was set with it. +
Format: `label INDEX [f/FILE_NAME]`
- Your format for using the command should follow: `label INDEX [f/FILE_NAME]`

****
* Outputs the label for the medicine at the specified INDEX.
* If no file name is specified, the default file name is `to_print`.
* The index refers to the index number shown in the displayed medicine list.
* The index must be a positive integer 1, 2, 3, …
* All files output can be found under the PDF folder.
****

All PDF files can be found under the PDF folder

image::mainPDF.png[width="790"]


Examples:

* `list` +
. Open up the software interface. (Fig 5.12.1)

. Using the keyboard, enter the commands followed by hitting the enter key for each command.
* `list` followed by +
`label 2` +
This will allow you to select the 2nd medicine in the inventory and output the information to a default file named `to_print`.
+
image::label2_taken.png[width="790"]
+
Fig 5.12.1 Software interface
+
- A confirmation message will be shown to indicate to you that it have been successfully labeled.
+
* You can open the file in the PDF folder with your preferred PDF reader to print the medicine information.
. You can open the file in the PDF folder with your preferred PDF reader to print the medicine information. (Fig 5.12.2)
+
image::label2.png[width="790"]
+
Fig 5.12.2 Medicine information
+
. If you want to name the output file, follow the steps below:
* `find n/ Simvastatin` +
`label 1 f/Simvastatin` +
Similar to the example above, the 1st medicine information will be output to a file name `Simvastatin`.
Similar to the example above, the 1st medicine information will be output to a file name `Simvastatin`. (Fig 5.12.3)
+
image::label1.png[width="790"]
+
Fig 5.12.3 Simvastatin medicine information
+
[WARNING]
The `label` command will overwrite the `to_print` file every time it is used without specifying a file name. Hence, do print the required file first before using the `label` command again. This extends to all other existing file names.
The `label` command will overwrite the `to_print` file when filename is not specified. Do print the required file first before using the `label` command again.

- Please follow Appendix A for naming conventions.

// end::labelcommand[]

=== Listing entered commands : `history`

Expand Down
Binary file added docs/images/LabelUML.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 removed docs/images/UMLLabelDiagram.png
Binary file not shown.
Binary file added docs/images/mainPDF.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 23 additions & 18 deletions docs/team/melpulomas.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,51 @@

== PROJECT: MediTabs

---
== Introduction
This Project Portfolio shows my contributions to the group project, such as features and documentation.


== Overview

Our team of 4 was task to either enhance or morph a basic addressbook for our project. We decided to morph it to be a medicine inventory management system named MediTabs. We chose pharmacist to be our target audience, favouring keyboard inputs.
The group project, Meditabs, is a medicine inventory management for pharmacist to streamline the process of handling the stick taking process. The user mainly uses the Command-Line Interface (CLI) to interact.

== Summary of contributions

* *Major enhancement*: added the label command to allow user to output the medicine information onto a pdf file
** What it does: Enables the user to transfer the medicine information over to a pdf file. Then, the user could use printers or external 3rd party software to print or edit the file.
** Justification: Pharmacist would like to have the printed information of certain medicine and label the physical counterpart. With the PDF, the pharmacist may use external printers and print out the information on the label as a sticker. PDF is widely used as a file extension and hence very portable which all computers and printer can identify.
* *Major enhancement*: Added the `Label` command
** What it does: Allows the user to output the information of the medicine onto a Portable Document Format (PDF).
** Justification: Pharmacist would like to have the printed information of certain medicine and label the physical counterpart. With the PDF, the pharmacist may use external printers and print out the information on the label as a sticker. PDF is widely used as a file extension.
** Highlights: Added security layer to the naming of the file (Auto include .pdf extension) such that users may not over write other important files.
** Credits: Apache PDFBox external library is imported to help manipulate and output the stream of information to the PDF file.

* *Minor enhancement*:
* *Minor enhancement*: -

* *Code contributed*:
* *Code contributed*: [https://github.com[Functional code]] [https://github.com[Test code]] _{give links to collated code files}_

* *Other contributions*:


_{you can add/remove categories in the list above}_
** Project management:
*** Wrote additional tests for existing features to increase coverage (Pull requests https://github.com/CS2103-AY1819S2-T12-3/main/pull/131[#131], https://github.com/CS2103-AY1819S2-T12-3/main/pull/142[#142])
** Community:
*** PRs reviewed (with non-trivial review comments): https://github.com/CS2103-AY1819S2-T12-3/main/pull/103[#103], https://github.com/CS2103-AY1819S2-T12-3/main/pull/124[#124]
** Documentation:
*** Added label command to the User Guide: https://github.com/CS2103-AY1819S2-T12-3/main/pull/106[#106]
*** Changed About Us documentation to describe our group instead: https://github.com/CS2103-AY1819S2-T12-3/main/pull/24[#24], https://github.com/CS2103-AY1819S2-T12-3/main/pull/27[#27]
** Tools:
*** Integrated third party libraries (Apache PDFBox) to the project: https://github.com/CS2103-AY1819S2-T12-3/main/pull/40[#40]

== Contributions to the User Guide


|===
|_Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users._
|Below are my contributions to the user guide to showcase my technical skills on user end documentation.
|===

include::../UserGuide.adoc[tag=label]



include::../UserGuide.adoc[tag=labelcommand]

== Contributions to the Developer Guide

|===
|_Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project._
|Below are my contributions to the developer guide to showcase my technical skills on developer end documentation.
|===

include::../DeveloperGuide.adoc[tag=label]

include::../DeveloperGuide.adoc[tag=usecase]
include::../DeveloperGuide.adoc[tag=labelcommand]
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/commons/util/pdf/PdfWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.Objects.requireNonNull;

import java.awt.Color;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -129,6 +130,10 @@ private void writeToPdf(PDPage page, String textNextLine) {
contents.newLineAtOffset(0, -leading);
}
contents.endText();
contents.setNonStrokingColor(Color.DARK_GRAY);
contents.addRect(50, 550, 350, 200);
contents.addRect(40, 540, 370, 220);
contents.stroke();
}

doc.save(fileName);
Expand Down

0 comments on commit 3d0c4fb

Please sign in to comment.