Skip to content

Commit 820e5f6

Browse files
committed
Merge branch 'develop' into feature/#165_Rest-API-New
# Conflicts: # pom.xml
2 parents 75b2bf9 + eab713c commit 820e5f6

File tree

10 files changed

+92
-91
lines changed

10 files changed

+92
-91
lines changed

.github/workflows/mavenCi.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ jobs:
2222
version: 2.0.${{ github.run_number }}
2323

2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626

2727
- name: Set up JDK 17
28-
uses: actions/setup-java@v3
28+
uses: actions/setup-java@v4
2929
with:
3030
java-version: '17'
3131
distribution: 'corretto'
3232
cache: maven
3333

3434
- name: Initialize CodeQL
35-
uses: github/codeql-action/init@v2
35+
uses: github/codeql-action/init@v3
3636
with:
3737
languages: 'java'
3838

3939
- name: Build
40-
run: mvn -V -B clean package org.jacoco:jacoco-maven-plugin:0.8.7:prepare-agent org.jacoco:jacoco-maven-plugin:0.8.7:report -Pcoverage -Dproject.version=${{ env.version }}-SNAPSHOT -Djava.awt.headless=true -Dtestfx.robot=glass -Dtestfx.headless=true
40+
run: mvn -V -B clean package org.jacoco:jacoco-maven-plugin:0.8.7:prepare-agent org.jacoco:jacoco-maven-plugin:0.8.7:report -Pcoverage -Dproject.version=${{ env.version }}-SNAPSHOT
4141

4242
- name: Upload Build Artifact
43-
uses: actions/upload-artifact@v3
43+
uses: actions/upload-artifact@v4
4444
with:
4545
name: KeepTime-${{ env.version }}
4646
path: /home/runner/work/KeepTime/KeepTime/target/*-bin.zip
@@ -52,17 +52,17 @@ jobs:
5252
run: mvn -V -B sonar:sonar -Dsonar.host.url=${{ secrets.HOST_URL }} -Dsonar.organization=${{ secrets.ORGANIZATION_NAME }} -Dsonar.projectKey=${{ secrets.PROJECT_KEY }} -Dsonar.java.binaries=. -Dsonar.qualitygate.wait=false
5353

5454
- name: Perform CodeQL Analysis
55-
uses: github/codeql-action/analyze@v2
55+
uses: github/codeql-action/analyze@v3
5656

5757
dependency-check:
5858

5959
runs-on: ubuntu-latest
6060

6161
steps:
62-
- uses: actions/checkout@v3
62+
- uses: actions/checkout@v4
6363

6464
- name: Set up JDK 17
65-
uses: actions/setup-java@v3
65+
uses: actions/setup-java@v4
6666
with:
6767
java-version: '17'
6868
distribution: 'corretto'

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ You should put the .jar in an extra folder as a *logs* and a *db* folder will be
6464
7. To see the changes just start the new KeepTime again
6565

6666
## Requirements
67-
68-
* Windows 7, 10
69-
* Linux (tested on Ubuntu 18.04)
70-
* Java 11
67+
* Operating System
68+
* Windows 7, 10, 11
69+
* Linux (tested on Ubuntu 18.04)
70+
* Mac (tested on MacBook M2 Pro (ARM based CPU))
71+
* Java 17

pom.xml

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<parent>
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
9-
<version>3.1.3</version>
9+
<version>3.1.10</version>
1010
<relativePath />
1111
<!-- lookup parent from repository -->
1212
</parent>
1313
<groupId>de.doubleslash</groupId>
1414
<artifactId>keeptime</artifactId>
15-
<version>2.0.0-SNAPSHOT</version>
15+
<version>${project.version}</version>
1616

1717
<packaging>jar</packaging>
1818
<name>KeepTime</name>
@@ -33,12 +33,13 @@
3333
</licenses>
3434

3535
<properties>
36+
<project.version>2.0.0-SNAPSHOT</project.version>
3637
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3738
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
3839
<java.version>17</java.version>
39-
<javafx.version>20.0.1</javafx.version>
40+
<javafx.version>22</javafx.version>
4041

41-
<maven-dependency-check.version>8.0.2</maven-dependency-check.version>
42+
<maven-dependency-check.version>9.1.0</maven-dependency-check.version>
4243
<!-- USING HTML,XML (comma-separated list) did not work with plugin version 5.1.0 -->
4344
<maven-dependency-check.format>ALL</maven-dependency-check.format>
4445
<maven-dependency-check.failOnError>true</maven-dependency-check.failOnError>
@@ -108,7 +109,12 @@
108109
<groupId>org.springframework.boot</groupId>
109110
<artifactId>spring-boot-starter-validation</artifactId>
110111
</dependency>
111-
112+
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security -->
113+
<dependency>
114+
<groupId>org.springframework.boot</groupId>
115+
<artifactId>spring-boot-starter-security</artifactId>
116+
<version>3.1.3</version>
117+
</dependency>
112118

113119

114120
<dependency>
@@ -143,50 +149,32 @@
143149
<dependency>
144150
<groupId>org.apache.maven.plugins</groupId>
145151
<artifactId>maven-assembly-plugin</artifactId>
146-
<version>3.4.2</version>
152+
<version>3.7.1</version>
147153
<type>maven-plugin</type>
148154
</dependency>
149155
<dependency>
150156
<groupId>org.sonarsource.scanner.maven</groupId>
151157
<artifactId>sonar-maven-plugin</artifactId>
152-
<version>3.9.1.2184</version>
158+
<version>3.11.0.3922</version>
153159
</dependency>
154160
<dependency>
155161
<groupId>org.hamcrest</groupId>
156162
<artifactId>hamcrest-library</artifactId>
157163
<scope>test</scope>
158164
</dependency>
159-
<dependency>
160-
<groupId>org.testfx</groupId>
161-
<artifactId>testfx-junit5</artifactId>
162-
<version>4.0.16-alpha</version>
163-
<scope>test</scope>
164-
</dependency>
165-
<!-- https://mvnrepository.com/artifact/org.testfx/openjfx-monocle -->
166-
<dependency>
167-
<groupId>org.testfx</groupId>
168-
<artifactId>openjfx-monocle</artifactId>
169-
<version>jdk-12.0.1+2</version>
170-
<scope>test</scope>
171-
</dependency>
172-
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security -->
173-
<dependency>
174-
<groupId>org.springframework.boot</groupId>
175-
<artifactId>spring-boot-starter-security</artifactId>
176-
<version>3.1.3</version>
177-
</dependency>
178-
179165
</dependencies>
180166
<build>
167+
<finalName>keeptime-${project.version}</finalName>
168+
181169
<plugins>
182170
<plugin>
183171
<groupId>org.springframework.boot</groupId>
184172
<artifactId>spring-boot-maven-plugin</artifactId>
185173
</plugin>
186174

187175
<plugin>
188-
<groupId>pl.project13.maven</groupId>
189-
<artifactId>git-commit-id-plugin</artifactId>
176+
<groupId>io.github.git-commit-id</groupId>
177+
<artifactId>git-commit-id-maven-plugin</artifactId>
190178
<configuration>
191179
<generateGitPropertiesFile>false</generateGitPropertiesFile>
192180
</configuration>
@@ -205,7 +193,6 @@
205193
<descriptors>
206194
<descriptor>./assembly.xml</descriptor>
207195
</descriptors>
208-
<finalName>keeptime-${project.version}</finalName>
209196
</configuration>
210197
</execution>
211198
</executions>

src/main/java/de/doubleslash/keeptime/App.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public void init() throws Exception {
9595

9696
model = springContext.getBean(Model.class);
9797
controller = springContext.getBean(Controller.class);
98+
controller.enableAutoSave();
9899
model.setSpringContext(springContext);
99100
}
100101

src/main/java/de/doubleslash/keeptime/common/BrowserHelper.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,43 @@ public static void openURL(final String url) {
3434
openUrlWindows(rt, url);
3535
} else if (OS.isLinux()) {
3636
openUrlLinux(rt, url);
37+
} else if (OS.isMacOS()) {
38+
openUrlMac(rt, url);
3739
} else {
38-
LOG.warn("OS is not supported");
40+
LOG.warn("OS '{}' is not supported", OS.getOSName());
3941
}
4042
}
4143

4244
private static void openUrlWindows(final Runtime rt, final String url) {
4345
final String command = "rundll32 url.dll,FileProtocolHandler " + url;
46+
executeCommand(rt, command, url);
47+
}
48+
49+
private static void openUrlLinux(final Runtime rt, final String url) {
50+
final String[] command = {"xdg-open", url};
51+
executeCommand(rt, command, url);
52+
}
53+
54+
private static void openUrlMac(final Runtime rt, final String url) {
55+
final String[] command = {"open", url};
56+
executeCommand(rt, command, url);
57+
}
58+
59+
private static void executeCommand(final Runtime rt, final String command, final String url) {
4460
try {
4561
LOG.debug("Executing command: {}", command);
4662
rt.exec(command);
4763
} catch (final Exception e) {
48-
LOG.error("Could not open url '" + url + "' with command '" + command + "'.", e);
64+
LOG.error("Could not open url '{}' with command '{}'.", url, command, e);
4965
}
5066
}
5167

52-
private static void openUrlLinux(final Runtime rt, final String url) {
53-
final String[] command = {
54-
"xdg-open", url
55-
};
68+
private static void executeCommand(final Runtime rt, final String[] command, final String url) {
5669
try {
5770
LOG.debug("Executing command: {}", Arrays.toString(command));
58-
rt.exec(command);
71+
rt.exec(command);
5972
} catch (final Exception e) {
60-
LOG.error("Could not open url '" + url + "' with command '" + Arrays.toString(command) + "'.", e);
73+
LOG.error("Could not open url '{}' with command '{}'.", url, Arrays.toString(command), e);
6174
}
6275
}
6376
}

src/main/java/de/doubleslash/keeptime/common/FileOpenHelper.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ public static boolean openFile(final String filePath) {
3232
final File file = new File(filePath);
3333
final Runtime rt = Runtime.getRuntime();
3434

35-
if (file.exists() && file.isFile()) {
36-
if (OS.isWindows()) {
37-
openFileWindows(rt, file);
38-
} else if (OS.isLinux()) {
39-
openFileLinux(rt, filePath);
40-
} else {
41-
LOG.warn("OS is not supported");
42-
}
43-
return true;
44-
} else {
35+
if (!file.exists() || file.isFile()) {
36+
LOG.warn("Filepath does not seem to exist or does not point to a file: '{}'.", filePath);
4537
return false;
4638
}
39+
40+
if (OS.isWindows()) {
41+
openFileWindows(rt, file);
42+
} else if (OS.isLinux()) {
43+
openFileLinux(rt, filePath);
44+
} else {
45+
LOG.warn("OS '{}' is not supported", OS.getOSName());
46+
}
47+
return true;
4748
}
4849

4950
private static void openFileWindows(final Runtime rt, final File file) {
@@ -52,7 +53,7 @@ private static void openFileWindows(final Runtime rt, final File file) {
5253
LOG.debug("executing command: {}", command);
5354
rt.exec(command);
5455
} catch (final Exception e) {
55-
LOG.error("Could not open file '" + file + "' with command '" + command + "'.", e);
56+
LOG.error("Could not open file '{}' with command '{}'.", file, command, e);
5657
}
5758
}
5859

@@ -64,7 +65,8 @@ private static void openFileLinux(final Runtime rt, final String filePath) {
6465
LOG.debug("executing command: {}", Arrays.toString(command));
6566
rt.exec(command);
6667
} catch (final Exception e) {
67-
LOG.error("Could not open file '" + filePath + "' with command '" + Arrays.toString(command) + "'.", e);
68+
LOG.error("Could not open file '{}' with command '{}'.", filePath, Arrays.toString(command),
69+
e);
6870
}
6971
}
7072
}

src/main/java/de/doubleslash/keeptime/common/OS.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,26 @@
1919
public class OS {
2020

2121
private static final String OS_PROPERTY = "os.name";
22+
private static final String OS_NAME = System.getProperty(OS_PROPERTY).toLowerCase();
2223

2324
private OS() {
2425
// prevent instance creation
2526
}
2627

2728
public static boolean isWindows() {
28-
if (System.getProperty(OS_PROPERTY).toLowerCase().contains("windows")) {
29-
return true;
30-
}
31-
32-
return false;
29+
return OS_NAME.contains("windows");
3330
}
3431

3532
public static boolean isLinux() {
36-
if (System.getProperty(OS_PROPERTY).toLowerCase().contains("linux")) {
37-
return true;
38-
}
33+
return OS_NAME.contains("linux");
34+
}
3935

40-
return false;
36+
public static String getOSName() {
37+
return OS_NAME;
4138
}
4239

43-
public static String getOSname() {
44-
return System.getProperty(OS_PROPERTY);
40+
public static boolean isMacOS() {
41+
return OS_NAME.contains("mac os x");
4542
}
4643

4744
}

src/main/java/de/doubleslash/keeptime/controller/Controller.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,28 @@
3838

3939
@Service
4040
public class Controller {
41-
private final long QUICK_SAVE_INTERVAL = 60;
4241

4342
private static final Logger LOG = LoggerFactory.getLogger(Controller.class);
4443

44+
private final long AUTO_SAVE_INTERVAL_SECONDS = 60;
45+
private Interval autoSaveInterval;
46+
4547
private final Model model;
4648

4749
private final DateProvider dateProvider;
4850

4951
public Controller(final Model model, final DateProvider dateProvider) {
5052
this.model = model;
5153
this.dateProvider = dateProvider;
54+
}
5255

53-
// initiate quicksaving
54-
new Interval(QUICK_SAVE_INTERVAL).registerCallBack(() -> saveCurrentWork(dateProvider.dateTimeNow()));
56+
public void enableAutoSave() {
57+
LOG.info("Enabling auto save with interval '{}' seconds.", AUTO_SAVE_INTERVAL_SECONDS);
58+
autoSaveInterval = new Interval(AUTO_SAVE_INTERVAL_SECONDS);
59+
autoSaveInterval.registerCallBack(() -> {
60+
LOG.debug("Auto saving current work.");
61+
saveCurrentWork(dateProvider.dateTimeNow());
62+
});
5563
}
5664

5765
public void changeProject(final Project newProject) {
@@ -178,7 +186,7 @@ public void deleteProject(final Project p) {
178186
changeProject(model.getIdleProject());
179187
}
180188

181-
LOG.info("Disabeling project '{}'.", p);
189+
LOG.info("Disabling project '{}'.", p);
182190

183191
final int indexToRemove = p.getIndex();
184192
p.setEnabled(false); // we don't delete it because of the referenced work
@@ -311,7 +319,7 @@ public void setComment(final String notes) {
311319
}
312320

313321
/**
314-
* Calculate todays seconds counted as work
322+
* Calculate today's seconds counted as work
315323
*/
316324
public long calcTodaysWorkSeconds() {
317325
final List<Work> workItems = new ArrayList<>();
@@ -332,16 +340,12 @@ public long calcTodaysWorkSeconds() {
332340
}
333341

334342
/**
335-
* Calculate todays present seconds (work+nonWork)
343+
* Calculate today's present seconds (work+nonWork)
336344
*/
337345
public long calcTodaysSeconds() {
338346
return calcSeconds(model.getPastWorkItems());
339347
}
340348

341-
public ObservableList<Project> getAvailableProjects() {
342-
return model.getAvailableProjects();
343-
}
344-
345349
public long calcSeconds(final List<Work> workItems) {
346350
long seconds = 0;
347351

0 commit comments

Comments
 (0)