BrightSide Workbench Full Report + Source Code
org.turro.timetracker.TimeTrackerQueue Class Reference
Inheritance diagram for org.turro.timetracker.TimeTrackerQueue:
Collaboration diagram for org.turro.timetracker.TimeTrackerQueue:

Public Member Functions

boolean hasIntegrity ()
 
boolean correctDate (CheckDate dateTrack)
 
TimeTracker addTrack (TimeTrackerType type, Date dateTrack)
 
TimeTrackerType getLastType ()
 
Set< TimeTrackerTypegetNextValids ()
 
List< TimeTrackergetActiveTracks ()
 
List< TimeTrackergetInactiveTracks ()
 
List< TimeTrackergetTracksByStatus (Set< TimeTrackerType > types)
 
void deleteLastTrack ()
 
boolean hasFullIntegrity ()
 
void repairWith (Duration max)
 

Static Public Member Functions

static TimeTrackerQueue load (String entityPath, String trackedPath)
 
static TimeTrackerQueue load (String entityPath, String trackedPath, int hours)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 43 of file TimeTrackerQueue.java.

Member Function Documentation

◆ addTrack()

TimeTracker org.turro.timetracker.TimeTrackerQueue.addTrack ( TimeTrackerType  type,
Date  dateTrack 
)

Definition at line 65 of file TimeTrackerQueue.java.

65  {
66  if(type != null && type.isPreviousValid(getLastType())) {
67  TimeTracker tt = new TimeTracker();
68  tt.setEntityPath(entityPath);
69  tt.setTrackedPath(trackedPath);
70  tt.setTrackType(type);
71  tt.setTimeTrack(dateTrack);
72  if(!tt.isEmpty()) {
73  tt = getDao().saveObject(tt);
74  if(!tt.getTrackType().isStarts()) {
75  setHours();
76  tt = getDao().find(TimeTracker.class, TimeTrackerPK.from(tt));
77  }
78  return tt;
79  }
80  }
81  return null;
82  }
Here is the call graph for this function:

◆ correctDate()

boolean org.turro.timetracker.TimeTrackerQueue.correctDate ( CheckDate  dateTrack)

Definition at line 56 of file TimeTrackerQueue.java.

56  {
57  if(isEmpty()) return true;
58  TimeTracker tt = last();
59  if(tt != null) {
60  return tt.getTimeTrack().before(dateTrack.getDate());
61  }
62  return false;
63  }
Here is the call graph for this function:

◆ deleteLastTrack()

void org.turro.timetracker.TimeTrackerQueue.deleteLastTrack ( )

Definition at line 117 of file TimeTrackerQueue.java.

117  {
118  getDao().deleteObject(last());
119  }
void deleteObject(Object obj)
Definition: Dao.java:162
Here is the call graph for this function:

◆ getActiveTracks()

List<TimeTracker> org.turro.timetracker.TimeTrackerQueue.getActiveTracks ( )

Definition at line 94 of file TimeTrackerQueue.java.

94  {
95  return getTracksByStatus(TimeTrackerType.getActiveTypes());
96  }
List< TimeTracker > getTracksByStatus(Set< TimeTrackerType > types)
Here is the call graph for this function:

◆ getInactiveTracks()

List<TimeTracker> org.turro.timetracker.TimeTrackerQueue.getInactiveTracks ( )

Definition at line 98 of file TimeTrackerQueue.java.

98  {
99  return getTracksByStatus(TimeTrackerType.getInactiveTypes());
100  }
Here is the call graph for this function:

◆ getLastType()

TimeTrackerType org.turro.timetracker.TimeTrackerQueue.getLastType ( )

Definition at line 84 of file TimeTrackerQueue.java.

84  {
85  TimeTracker last = isEmpty() ? null : last();
86  return last == null ? null : last.getTrackType();
87  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNextValids()

Set<TimeTrackerType> org.turro.timetracker.TimeTrackerQueue.getNextValids ( )

Definition at line 89 of file TimeTrackerQueue.java.

89  {
90  TimeTracker last = isEmpty() ? null : last();
91  return last == null ? EnumSet.of(TimeTrackerType.TRACK_START) : TimeTrackerType.getValidNexts(last.getTrackType());
92  }
Here is the call graph for this function:

◆ getTracksByStatus()

List<TimeTracker> org.turro.timetracker.TimeTrackerQueue.getTracksByStatus ( Set< TimeTrackerType types)

Definition at line 102 of file TimeTrackerQueue.java.

102  {
103  WhereClause wc = new WhereClause();
104  wc.addClause("select tt from TimeTracker tt");
105  wc.addClause("where tt.trackedPath = :trackedPath");
106  wc.addNamedValue("trackedPath", trackedPath);
107  wc.addClause("and tt.trackType in (:types)");
108  wc.addNamedValue("types", types);
109  wc.addClause("and tt.timeTrack = (");
110  wc.addClause("select max(t2.timeTrack) from TimeTracker t2");
111  wc.addClause("where tt.entityPath = t2.entityPath");
112  wc.addClause("and tt.trackedPath = t2.trackedPath");
113  wc.addClause(")");
114  return getDao().getResultList(TimeTracker.class, wc);
115  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasFullIntegrity()

boolean org.turro.timetracker.TimeTrackerQueue.hasFullIntegrity ( )

Definition at line 148 of file TimeTrackerQueue.java.

148  {
149  WhereClause wc = new WhereClause();
150  wc.addClause("select tt from TimeTracker tt");
151  wc.addClause("where tt.entityPath = :entityPath");
152  wc.addNamedValue("entityPath", entityPath);
153  wc.addClause("and tt.trackedPath = :trackedPath");
154  wc.addNamedValue("trackedPath", trackedPath);
155  wc.addClause("order by tt.timeTrack ASC");
156  TimeTrackerType[] previousType = new TimeTrackerType[1];
157  try(Stream<TimeTracker> entries = getDao().stream(TimeTracker.class, wc)) {
158  return entries.noneMatch(e -> {
159  boolean match = !e.getTrackType().isPreviousValid(previousType[0]);
160  previousType[0] = e.getTrackType();
161  return match;
162  });
163  }
164  }
Here is the call graph for this function:

◆ hasIntegrity()

boolean org.turro.timetracker.TimeTrackerQueue.hasIntegrity ( )

Definition at line 47 of file TimeTrackerQueue.java.

47  {
48  TimeTrackerType[] previousType = new TimeTrackerType[1];
49  return stream().noneMatch(e -> {
50  boolean match = !e.getTrackType().isPreviousValid(previousType[0]);
51  previousType[0] = e.getTrackType();
52  return match;
53  });
54  }

◆ load() [1/2]

static TimeTrackerQueue org.turro.timetracker.TimeTrackerQueue.load ( String  entityPath,
String  trackedPath 
)
static

Definition at line 196 of file TimeTrackerQueue.java.

196  {
197  TimeTrackerQueue ttq = new TimeTrackerQueue(entityPath, trackedPath);
198  ttq.loadLastActiveTrack();
199  return ttq;
200  }

◆ load() [2/2]

static TimeTrackerQueue org.turro.timetracker.TimeTrackerQueue.load ( String  entityPath,
String  trackedPath,
int  hours 
)
static

Definition at line 202 of file TimeTrackerQueue.java.

202  {
203  TimeTrackerQueue ttq = new TimeTrackerQueue(entityPath, trackedPath);
204  ttq.loadLastHoursEntries(hours);
205  return ttq;
206  }

◆ repairWith()

void org.turro.timetracker.TimeTrackerQueue.repairWith ( Duration  max)

Definition at line 166 of file TimeTrackerQueue.java.

166  {
167  WhereClause wc = new WhereClause();
168  wc.addClause("select tt from TimeTracker tt");
169  wc.addClause("where tt.entityPath = :entityPath");
170  wc.addNamedValue("entityPath", entityPath);
171  wc.addClause("and tt.trackedPath = :trackedPath");
172  wc.addNamedValue("trackedPath", trackedPath);
173  wc.addClause("order by tt.timeTrack ASC");
174  TimeTracker[] previous = new TimeTracker[1];
175  try(Stream<TimeTracker> entries = getDao().stream(TimeTracker.class, wc)) {
176  entries.forEach(e -> {
177  if(!e.isPreviousValid(previous[0])) {
178  repair(max, previous[0], e);
179  }
180  previous[0] = e;
181  });
182  }
183  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: