Added several improvements, changes and bug fixes
This commit is contained in:
parent
f4717913b6
commit
402ff5b0a5
10
Readme.md
10
Readme.md
@ -184,14 +184,20 @@ Smileys can be colored or white-black (can be set in configuration)
|
||||
## Command button
|
||||
|
||||
## Todos
|
||||
* New table: YEAR
|
||||
|
||||
### New features
|
||||
|
||||
* Custom arrival target
|
||||
* Split to Maven modules
|
||||
* Junit, Mockito, etc.
|
||||
* Checkstyle
|
||||
* Sonarlint
|
||||
* Sonarqube
|
||||
* Add SQLite support and store times of arrivals and departures and time of activities
|
||||
|
||||
### Fix these known bugs
|
||||
|
||||
* Clock, square and circle are grey, if visibility mode is weakly colored.
|
||||
* Decreasing real time sometimes does not work correctly.
|
||||
|
||||
## For Developers
|
||||
|
||||
|
@ -14,7 +14,7 @@ import lombok.ToString;
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class Activity {
|
||||
public class Activity implements Comparable<Activity> {
|
||||
|
||||
private static final String SUBJECT_FIELD_SEPARATOR = " : ";
|
||||
|
||||
@ -28,6 +28,7 @@ public class Activity {
|
||||
private int spentHours;
|
||||
private int spentMinutes;
|
||||
private String flags;
|
||||
private String nextActivityId;
|
||||
|
||||
public String createSubject() {
|
||||
return ticket + SUBJECT_FIELD_SEPARATOR + name;
|
||||
@ -56,6 +57,28 @@ public class Activity {
|
||||
set.remove(flag);
|
||||
this.flags = set.stream().collect(Collectors.joining(":"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(Activity o) {
|
||||
|
||||
int result = Integer.valueOf(year).compareTo(Integer.valueOf(o.year));
|
||||
if(result != 0) {
|
||||
return result;
|
||||
}
|
||||
result = Integer.valueOf(month).compareTo(Integer.valueOf(o.month));
|
||||
if(result != 0) {
|
||||
return result;
|
||||
}
|
||||
result = Integer.valueOf(day).compareTo(Integer.valueOf(o.day));
|
||||
if(result != 0) {
|
||||
return result;
|
||||
}
|
||||
if(this.nextActivityId != null && this.nextActivityId.equals(o.getId())) {
|
||||
return -1;
|
||||
}
|
||||
if(o.nextActivityId != null && o.nextActivityId.equals(o.getId())) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.nanoboot.utils.timecalc.persistence.api;
|
||||
|
||||
import org.nanoboot.utils.timecalc.entity.Activity;
|
||||
import org.nanoboot.utils.timecalc.entity.WorkingDay;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -13,11 +12,13 @@ public interface ActivityRepositoryApi {
|
||||
|
||||
void create(Activity activity);
|
||||
|
||||
Activity getLastActivityForDay(int year, int month, int day);
|
||||
|
||||
List<Activity> list(int year, int month, int day);
|
||||
|
||||
void update(Activity activity);
|
||||
|
||||
WorkingDay read(String id);
|
||||
Activity read(String id);
|
||||
|
||||
void delete(String id);
|
||||
|
||||
|
@ -4,8 +4,8 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import org.nanoboot.utils.timecalc.entity.WorkingDay;
|
||||
import org.nanoboot.utils.timecalc.persistence.api.ActivityRepositoryApi;
|
||||
|
||||
import java.util.List;
|
||||
@ -23,17 +23,15 @@ public class ActivityRepositorySQLiteImpl implements ActivityRepositoryApi {
|
||||
public ActivityRepositorySQLiteImpl(SqliteConnectionFactory sqliteConnectionFactory) {
|
||||
this.sqliteConnectionFactory = sqliteConnectionFactory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void create(Activity activity) {
|
||||
|
||||
|
||||
Activity lastActivityForDay = getLastActivityForDay(activity.getYear(), activity.getMonth(), activity.getDay());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb
|
||||
.append("INSERT INTO ")
|
||||
.append(ActivityTable.TABLE_NAME)
|
||||
.append(" VALUES (?,?,?,?, ?,?,?,?,?)");
|
||||
.append(" VALUES (?,?,?,?, ?,?,?,?,?,?)");
|
||||
|
||||
String sql = sb.toString();
|
||||
|
||||
@ -52,6 +50,7 @@ public class ActivityRepositorySQLiteImpl implements ActivityRepositoryApi {
|
||||
stmt.setInt(++i, activity.getSpentHours());
|
||||
stmt.setInt(++i, activity.getSpentMinutes());
|
||||
stmt.setString(++i, activity.getFlags());
|
||||
stmt.setNull(++i, Types.VARCHAR);
|
||||
|
||||
//
|
||||
stmt.execute();
|
||||
@ -64,6 +63,11 @@ public class ActivityRepositorySQLiteImpl implements ActivityRepositoryApi {
|
||||
throw new TimeCalcException(ex);
|
||||
}
|
||||
|
||||
if(lastActivityForDay != null) {
|
||||
lastActivityForDay.setNextActivityId(activity.getId());
|
||||
update(lastActivityForDay);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,7 +76,7 @@ public class ActivityRepositorySQLiteImpl implements ActivityRepositoryApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkingDay read(String id) {
|
||||
public Activity read(String id) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@ -244,6 +248,12 @@ public class ActivityRepositorySQLiteImpl implements ActivityRepositoryApi {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Activity getLastActivityForDay(int year, int month, int day) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Activity> list(int year, int month, int day) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
|
@ -37,6 +37,7 @@ class ActivityTable {
|
||||
public static final String SPENT_HOURS = "SPENT_HOURS";
|
||||
public static final String SPENT_MINUTES = "SPENT_MINUTES";
|
||||
public static final String FLAGS = "FLAGS";
|
||||
public static final String NEXT_ACTIVITY_ID = "NEXT_ACTIVITY_ID";
|
||||
|
||||
private ActivityTable() {
|
||||
//Not meant to be instantiated.
|
||||
|
@ -0,0 +1 @@
|
||||
ALTER TABLE "ACTIVITY" ADD COLUMN "NEXT_ACTIVITY_ID" TEXT;
|
@ -184,13 +184,20 @@ Smileys can be colored or white-black (can be set in configuration)
|
||||
## Command button
|
||||
|
||||
## Todos
|
||||
* New table: YEAR
|
||||
|
||||
### New features
|
||||
|
||||
* Custom arrival target
|
||||
* Split to Maven modules
|
||||
* Junit, Mockito, etc.
|
||||
* Checkstyle
|
||||
* Sonarlint
|
||||
* Sonarqube
|
||||
* Add SQLite support and store times of arrivals and departures and time of activities
|
||||
|
||||
### Fix these known bugs
|
||||
|
||||
* Clock, square and circle are grey, if visibility mode is weakly colored.
|
||||
* Decreasing real time sometimes does not work correctly.
|
||||
|
||||
## For Developers
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user