From 3ed1b50faee04b4a253255ea6335364cf0d060b3 Mon Sep 17 00:00:00 2001 From: Marcus Phua Zheng Jie <32394182+marcus-pzj@users.noreply.github.com> Date: Sat, 23 Mar 2019 00:50:21 +0800 Subject: [PATCH] Merge (#19) * Resolve checkstyle errors * FIx Bug in FindCommand (#97) Fix Bug in FindCommand * Update User Guide documentation (#98) * Update User Guide documentation (#99) * Planner: Initialize weekType for each Day * Planner: Fix Codacy issue * Planner: Update code for initialisation of semester * Planner: Fix Codacy and checkstyle issues * Planner: Fix build error * Planner: Dynamic generation of semester from date * PlannerTest: Add JUnit test for generateSemester * Update documentation for view command * Add view command for monthly calendar view * Fix Codacy issue * UserGuide: Update user guide documentation * UserGuide: Update user guide documentation * Update UserGuide.adoc (#100) * v1.1 * fix some errors and typos * Refactor entire project, remove all traces of Addressbook * Update developer guide for ExportCommandP (#80) * Update documentation for view command (#81) * Remove remaining Addressbook classes * Refactor some classes * fix missing files issue * Add test cases for add function, Utils and other code enhancements * fix codacy issues * fix codacy issues * Add tests for Utils * Add diagrams * Update Ui.png * fix issue with Ui.png * Update Codacy Badge link due to reinitialization. * Enhance ordering of slots printed * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide (#101) * Merge (#17) * FIx Bug in FindCommand (#97) Fix Bug in FindCommand * Update User Guide documentation (#98) * Update User Guide documentation (#99) * Planner: Initialize weekType for each Day * Planner: Fix Codacy issue * Planner: Update code for initialisation of semester * Planner: Fix Codacy and checkstyle issues * Planner: Fix build error * Planner: Dynamic generation of semester from date * PlannerTest: Add JUnit test for generateSemester * Update documentation for view command * Add view command for monthly calendar view * Fix Codacy issue * UserGuide: Update user guide documentation * UserGuide: Update user guide documentation * Update UserGuide.adoc (#100) * v1.1 * fix some errors and typos * Refactor entire project, remove all traces of Addressbook * Update developer guide for ExportCommandP (#80) * Update documentation for view command (#81) * Remove remaining Addressbook classes * Refactor some classes * fix missing files issue * Add test cases for add function, Utils and other code enhancements * fix codacy issues * fix codacy issues * Add tests for Utils * Add diagrams * Update Ui.png * fix issue with Ui.png * Update Codacy Badge link due to reinitialization. * Enhance ordering of slots printed * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Update User Guide * Add config file for Reposense * Add config file for Reposense (#102) * Move config.json to _reposense folder * Move config.json to _reposense folder (#103) * Edit config file for reposense * Update User Guide (#105) * Update use cases in developer guide * edit user guide * add encryption key skeleton * user guide edits * Update User Guide (#106) * Planner: Initialize weekType for each Day * Planner: Fix Codacy issue * Planner: Update code for initialisation of semester * Planner: Fix Codacy and checkstyle issues * Planner: Fix build error * Planner: Dynamic generation of semester from date * PlannerTest: Add JUnit test for generateSemester * Update documentation for view command * Add view command for monthly calendar view * Fix Codacy issue * UserGuide: Update user guide documentation * UserGuide: Update user guide documentation * Update README.adoc and UserGuide.adoc: change table layouts (#110) * v1.1 * fix some errors and typos * Refactor entire project, remove all traces of Addressbook * Update developer guide for ExportCommandP (#80) * Update documentation for view command (#81) * Remove remaining Addressbook classes * Refactor some classes * fix missing files issue * Add test cases for add function, Utils and other code enhancements * fix codacy issues * fix codacy issues * Add tests for Utils * Add diagrams * Update Ui.png * fix issue with Ui.png * Update Codacy Badge link due to reinitialization. * Enhance ordering of slots printed * Update UserGuide.adoc with feedback from peers * Update UserGuide.adoc with nicer tables * Update UserGuide.adoc: fix formatting issues * UserGuide.adoc Remove potential Netlify breaking code * README.adoc revert changes * UserGuide.adoc revert Netlify breakdown test code * Update User Guide (#108) * Planner: Initialize weekType for each Day * Planner: Fix Codacy issue * Planner: Update code for initialisation of semester * Planner: Fix Codacy and checkstyle issues * Planner: Fix build error * Planner: Dynamic generation of semester from date * PlannerTest: Add JUnit test for generateSemester * Update documentation for view command * Add view command for monthly calendar view * Fix Codacy issue * UserGuide: Update user guide documentation * UserGuide: Update user guide documentation * UserGuide: Update user guide documentation * UserGuide: Update user guide documentation * UserGuide: Update user guide documentation --- README.adoc | 8 ++--- src/planmysem/commands/EditCommand.java | 11 ++----- src/planmysem/commands/FindCommand.java | 1 + src/planmysem/data/Planner.java | 9 +++++ src/planmysem/data/semester/Semester.java | 19 +++++++++++ src/planmysem/storage/KeyStorage.java | 40 +++++++++++++++++++++++ src/planmysem/ui/DarkTheme.css | 2 +- 7 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 src/planmysem/storage/KeyStorage.java diff --git a/README.adoc b/README.adoc index 95e0efca1..add67da75 100644 --- a/README.adoc +++ b/README.adoc @@ -7,13 +7,11 @@ https://ci.appveyor.com/project/seanieyap/main-r8jp5[image:https://ci.appveyor.c https://app.netlify.com/sites/planmysem/deploys[image:https://api.netlify.com/api/v1/badges/6c19b45b-dbdd-4eff-afe2-200356d6ebb4/deploy-status[Build Status]] https://coveralls.io/github/CS2113-AY1819S2-T08-3/main?branch=master[image:https://coveralls.io/repos/github/CS2113-AY1819S2-T08-3/main/badge.svg?branch=master[Coverage Status]] https://www.codacy.com/app/CS2113T-T08-3/main?utm_source=github.com&utm_medium=referral&utm_content=CS2113-AY1819S2-T08-3/main&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/90f57d16da5049858ef67b6eaaf692f2[Codacy Badge]] +https://opensource.org/licenses/MIT[image:https://img.shields.io/badge/License-MIT-yellow.svg[License: MIT]] image::Ui.png[] -PlanMySem is a CLI (Command Line Interface) scheduling/calendar application that targets NUS students and staff who prefer to use a desktop application for managing their schedule/calendar. -PlanMySem automatically creates a planner that is synchronised according to the NUS academic calendar for the current semester and enables easy creation, editing and deleting of items. -Special weeks such as recess week and reading week are taken into account within our unique recursion system. -Items can then be efficiently managed via the intuitive tagging system. +PlanMySem is a CLI (Command Line Interface) scheduling/calendar application that targets NUS students and staff who prefer to use a desktop application for managing their schedule/calendar. PlanMySem automatically creates a planner that is synchronised according to the NUS academic calendar for the current semester and enables easy creation, editing and deleting of items. Special weeks such as recess week and reading week are taken into account within our unique recursion system. Items can then be efficiently managed via the intuitive tagging system. PlanMySem is optimized for those who prefer to work with a Command Line Interface (CLI) and/or are learning to work more efficiently with CLI tools. Additionally, unlike traditional calendar/scheduling applications, PlanMySem utilizes minimal resources on the user’s machine while still allowing the user to view their schedules swiftly and efficiently. @@ -42,3 +40,5 @@ PlanMySem is optimized for those who prefer to work with a Command Line Interfac * *Bug reports, Suggestions* : Post in our https://github.com/CS2113-AY1819S2-T08-3/main/issues[issue tracker] if you noticed bugs or have suggestions on how to improve. * *Contributing* : We welcome pull requests. Follow the process described https://github.com/oss-generic/process[here] + +== Licence : link:LICENSE[MIT] \ No newline at end of file diff --git a/src/planmysem/commands/EditCommand.java b/src/planmysem/commands/EditCommand.java index 8ac80eea6..7857c4894 100644 --- a/src/planmysem/commands/EditCommand.java +++ b/src/planmysem/commands/EditCommand.java @@ -12,10 +12,8 @@ import planmysem.common.Messages; import planmysem.common.Utils; import planmysem.data.exception.IllegalValueException; -import planmysem.data.semester.Day; import planmysem.data.semester.Semester; import planmysem.data.slot.ReadOnlySlot; -import planmysem.data.slot.Slot; import planmysem.data.tag.Tag; /** @@ -95,13 +93,8 @@ public CommandResult execute() { Map selectedSlots = new TreeMap<>(); if (getTargetIndex() == -1) { - for (Map.Entry day : planner.getSemester().getDays().entrySet()) { - for (Slot slot : day.getValue().getSlots()) { - if (slot.getTags().containsAll(tags)) { - selectedSlots.put(LocalDateTime.of(day.getKey(), slot.getStartTime()), slot); - } - } - } + planner.getSlots(tags); + if (selectedSlots.size() == 0) { return new CommandResult(String.format(MESSAGE_SUCCESS_NO_CHANGE, Messages.craftSelectedMessage(tags))); diff --git a/src/planmysem/commands/FindCommand.java b/src/planmysem/commands/FindCommand.java index 28c3bcee6..e0df29207 100644 --- a/src/planmysem/commands/FindCommand.java +++ b/src/planmysem/commands/FindCommand.java @@ -33,6 +33,7 @@ public class FindCommand extends Command { public FindCommand(String keyword) { this.keyword = keyword; } + @Override public CommandResult execute() { final List> relevantSlots = new ArrayList<>(); diff --git a/src/planmysem/data/Planner.java b/src/planmysem/data/Planner.java index 473f92451..843b6ca4b 100644 --- a/src/planmysem/data/Planner.java +++ b/src/planmysem/data/Planner.java @@ -2,6 +2,7 @@ import java.time.DayOfWeek; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.LocalTime; import java.time.temporal.TemporalAdjusters; import java.time.temporal.WeekFields; @@ -291,6 +292,14 @@ public void addDay(LocalDate date, Day day) throws Semester.DuplicateDayExceptio semester.addDay(date, day); } + /** + * Get set of slots which contain all specified tags. + */ + public Map getSlots(Set tags) { + return semester.getSlots(tags); + } + + /** * Adds a slot to the Planner. * diff --git a/src/planmysem/data/semester/Semester.java b/src/planmysem/data/semester/Semester.java index dd1565747..3c18db98e 100644 --- a/src/planmysem/data/semester/Semester.java +++ b/src/planmysem/data/semester/Semester.java @@ -1,12 +1,14 @@ package planmysem.data.semester; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.LocalTime; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.TreeMap; import planmysem.data.exception.DuplicateDataException; import planmysem.data.exception.IllegalValueException; @@ -92,6 +94,23 @@ public void addDay(LocalDate date, Day day) throws DuplicateDayException { days.put(date, day); } + /** + * Get set of slots which contain all specified tags. + */ + public Map getSlots(Set tags) { + Map selectedSlots = new TreeMap<>(); + + for (Map.Entry day : days.entrySet()) { + for (Slot slot : day.getValue().getSlots()) { + if (slot.getTags().containsAll(tags)) { + selectedSlots.put(LocalDateTime.of(day.getKey(), slot.getStartTime()), slot); + } + } + } + + return selectedSlots; + } + /** * Adds a Slot to the Semester. * diff --git a/src/planmysem/storage/KeyStorage.java b/src/planmysem/storage/KeyStorage.java new file mode 100644 index 000000000..95f69da67 --- /dev/null +++ b/src/planmysem/storage/KeyStorage.java @@ -0,0 +1,40 @@ +package planmysem.storage; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; + +import javax.crypto.SecretKey; + +/** + * Manages key storage and load. + */ +public class KeyStorage { + + private char[] pwdArray = "password".toCharArray(); + + KeyStorage(String password) { + this.pwdArray = password.toCharArray(); + } + + /** + * Saves the secret key. + */ + private void save(SecretKey key) throws KeyStoreException, IOException, NoSuchAlgorithmException, + CertificateException { + //Initialize keystore. + KeyStore ks = KeyStore.getInstance("JKS"); + + //Save key. + KeyStore.SecretKeyEntry secret = new KeyStore.SecretKeyEntry(key); + KeyStore.ProtectionParameter password = new KeyStore.PasswordProtection(pwdArray); + ks.setEntry("db-encryption-secret", secret, password); + + try (FileOutputStream fos = new FileOutputStream("newKeyStoreFileName.jks")) { + ks.store(fos, pwdArray); + } + } +} diff --git a/src/planmysem/ui/DarkTheme.css b/src/planmysem/ui/DarkTheme.css index 1c619d1de..bc2968ca0 100644 --- a/src/planmysem/ui/DarkTheme.css +++ b/src/planmysem/ui/DarkTheme.css @@ -10,7 +10,7 @@ .text-area { -fx-background-color: black; -fx-control-inner-background: black; - -fx-font-family: "Lucida Console"; + -fx-font-family: "Monospace"; -fx-font-size: 10pt; -fx-padding: 5 5 5 5; }