Skip to content

Commit

Permalink
Merge pull request CS2103-AY1819S1-T12-3#100 from CrimsonAng/test-rel…
Browse files Browse the repository at this point in the history
…ease

fix: jar unable work
  • Loading branch information
CrimsonAng authored Oct 25, 2018
2 parents 63b52ed + 8dd5c8a commit 76ff82a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (JavaVersion.current() == JavaVersion.VERSION_1_10
}

// Specifies the entry point of the application
mainClassName = 'ssp/scheduleplanner.MainApp'
mainClassName = 'ssp.scheduleplanner.MainApp'

sourceCompatibility = JavaVersion.VERSION_1_9
targetCompatibility = JavaVersion.VERSION_1_9
Expand Down
Binary file modified build/jar/scheduleplanner.jar
Binary file not shown.
44 changes: 30 additions & 14 deletions src/main/java/ssp/scheduleplanner/MainApp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ssp.scheduleplanner;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Optional;
Expand Down Expand Up @@ -126,22 +127,37 @@ protected Config initConfig(Path configFilePath) throws CommandException {

logger.info("Using config file : " + configFilePathUsed);

//added to update based on date range
try {
Config updateConfig = new Config();
FirstDayCommand fdc = new FirstDayCommand();
String[][] rangeOfWeek = new String[FirstDayCommand.WEEKS_IN_SEMESTER][3];
rangeOfWeek = fdc.retrieveRangeOfWeeks(rangeOfWeek);

if (fdc.isWithinDateRange(rangeOfWeek[0][0], rangeOfWeek[16][1])) {
updateConfig.setAppTitle("Schedule Planner" + " - " + fdc.retrieveWeekDescription(rangeOfWeek));
//Only when 'rangeofweek.xml' exist then the application check for possible week description
//solution below adapted from
//https://stackoverflow.com/questions/1816673/how-do-i-check-if-a-file-exists-in-java
File checkFileExist = new File("rangeofweek.xml");
if (checkFileExist.exists()) {
try {
Config updateConfig = new Config();
FirstDayCommand fdc = new FirstDayCommand();
String[][] rangeOfWeek = new String[FirstDayCommand.WEEKS_IN_SEMESTER][3];
rangeOfWeek = fdc.retrieveRangeOfWeeks(rangeOfWeek);

if (fdc.isWithinDateRange(rangeOfWeek[0][0], rangeOfWeek[16][1])) {
updateConfig.setAppTitle("Schedule Planner" + " - " + fdc.retrieveWeekDescription(rangeOfWeek));
ConfigUtil.saveConfig(updateConfig, configFilePathUsed);
} else {
updateConfig.setAppTitle("Schedule Planner");
}
ConfigUtil.saveConfig(updateConfig, configFilePathUsed);
} else {
updateConfig.setAppTitle("Schedule Planner");
} catch (IOException e) {
logger.warning("Failed to update config file : " + StringUtil.getDetails(e));
}
}

//When user launch the application for the first time or deleted the 'rangeofweek.xml'
// generate the file to allow user to use'firstday' command
if (!checkFileExist.exists()) {
try {
checkFileExist.createNewFile();
} catch (java.io.IOException e) {
logger.warning("Filed to create rangeofweek.xml");
}
ConfigUtil.saveConfig(updateConfig, configFilePathUsed);
} catch (IOException e) {
logger.warning("Failed to update config file : " + StringUtil.getDetails(e));
}
//end added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class LogsCenter {
private static final int MAX_FILE_COUNT = 5;
private static final int MAX_FILE_SIZE_IN_BYTES = (int) (Math.pow(2, 20) * 5); // 5MB
private static final String LOG_FILE = "addressbook.log";
private static final String LOG_FILE = "scheduleplanner.log";
private static Level currentLogLevel = Level.INFO;
private static final Logger logger = LogsCenter.getLogger(LogsCenter.class);
private static FileHandler fileHandler;
Expand Down
24 changes: 6 additions & 18 deletions src/main/java/ssp/scheduleplanner/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,12 @@
public class SampleDataUtil {
public static Task[] getSampleTasks() {
return new Task[] {
new Task(new Name("Alex Yeoh"), new Date("121107"), new Priority("1"),
new Venue("Blk 30 Geylang Street 29, #06-40"),
getTagSet("friends")),
new Task(new Name("Bernice Yu"), new Date("141258"), new Priority("1"),
new Venue("Blk 30 Lorong 3 Serangoon Gardens, #07-18"),
getTagSet("colleagues", "friends")),
new Task(new Name("Charlotte Oliveiro"), new Date("150983"), new Priority("1"),
new Venue("Blk 11 Ang Mo Kio Street 74, #11-04"),
getTagSet("neighbours")),
new Task(new Name("David Li"), new Date("120782"), new Priority("1"),
new Venue("Blk 436 Serangoon Gardens Street 26, #16-43"),
getTagSet("family")),
new Task(new Name("Irfan Ibrahim"), new Date("230721"), new Priority("1"),
new Venue("Blk 47 Tampines Street 20, #17-35"),
getTagSet("classmates")),
new Task(new Name("Roy Balakrishnan"), new Date("080717"), new Priority("1"),
new Venue("Blk 45 Aljunied Street 85, #11-31"),
getTagSet("colleagues"))
new Task(new Name("Homework"), new Date("111118"), new Priority("3"),
new Venue("Home"),
getTagSet("CS2100")),
new Task(new Name("Assignment"), new Date("121118"), new Priority("3"),
new Venue("Home"),
getTagSet("CS2101"))
};
}

Expand Down

0 comments on commit 76ff82a

Please sign in to comment.