implemented update of time states upon update of document state
This commit is contained in:
@@ -5,6 +5,7 @@ import static de.srsoftware.tools.jdbc.Condition.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||
import static de.srsoftware.umbrella.core.model.Time.State.Complete;
|
||||
import static de.srsoftware.umbrella.time.Constants.*;
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
@@ -85,7 +86,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
db.setAutoCommit(false);
|
||||
return timeId;
|
||||
} catch (SQLException e) {
|
||||
throw UmbrellaException.databaseException("Failed to delete time with id = {0}",timeId);
|
||||
throw databaseException("Failed to delete time with id = {0}",timeId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +203,21 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
return track;
|
||||
} catch (SQLException e){
|
||||
LOG.log(ERROR,"Failed to write time to DB",e);
|
||||
throw UmbrellaException.databaseException("Failed to write time to DB");
|
||||
throw databaseException("Failed to write time to DB");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStates(Collection<Long> timeIds, Time.State timeState) {
|
||||
try {
|
||||
update(TABLE_TIMES)
|
||||
.set(STATE)
|
||||
.where(ID,in(timeIds.toArray()))
|
||||
.prepare(db)
|
||||
.apply(timeState.code())
|
||||
.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to update state of several times");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,6 @@ public interface TimeDb {
|
||||
Time load(long timeId);
|
||||
|
||||
Time save(Time track) throws UmbrellaException;
|
||||
|
||||
void updateStates(Collection<Long> timeIds, Time.State timeState);
|
||||
}
|
||||
|
||||
@@ -316,4 +316,8 @@ public class TimeModule extends BaseHandler implements TimeService {
|
||||
return sendContent(ex,track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStates(Collection<Long> timeIds, Time.State timeState) {
|
||||
timeDb.updateStates(timeIds,timeState);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user