TSK-270: Delete old monitoring methods from API
- Remove old monitoring methods from service, mapper and tests - Remove unneeded monitoring specific classes - Return sample strings in the methods of the REST Service that represents the removed data
This commit is contained in:
parent
53cd04b6f8
commit
12e59f939e
|
|
@ -2,54 +2,15 @@ package pro.taskana;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import pro.taskana.model.DueWorkbasketCounter;
|
|
||||||
import pro.taskana.model.Report;
|
import pro.taskana.model.Report;
|
||||||
import pro.taskana.model.ReportLineItemDefinition;
|
import pro.taskana.model.ReportLineItemDefinition;
|
||||||
import pro.taskana.model.TaskState;
|
import pro.taskana.model.TaskState;
|
||||||
import pro.taskana.model.TaskStateCounter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Task Monitor Service manages operations on tasks regarding the monitoring.
|
* The Task Monitor Service manages operations on tasks regarding the monitoring.
|
||||||
*/
|
*/
|
||||||
public interface TaskMonitorService {
|
public interface TaskMonitorService {
|
||||||
|
|
||||||
/**
|
|
||||||
* This method counts all tasks with a given state.
|
|
||||||
*
|
|
||||||
* @param states
|
|
||||||
* the countable states
|
|
||||||
* @return a List of {@link TaskStateCounter} objects that specifies how many tasks in the specified states exist in
|
|
||||||
* the available work baskets
|
|
||||||
*/
|
|
||||||
List<TaskStateCounter> getTaskCountForState(List<TaskState> states);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Count all Tasks in a given work basket where the due date is after "daysInPast" days from today in the past and
|
|
||||||
* the tasks are in specified states.
|
|
||||||
*
|
|
||||||
* @param workbasketId
|
|
||||||
* the id of the work basket
|
|
||||||
* @param daysInPast
|
|
||||||
* identifies the days in the past from today
|
|
||||||
* @param states
|
|
||||||
* {@link List} of {@link TaskState} that identifies the states of the tasks to be searched for
|
|
||||||
* @return the number of Task objects in the given work basket that match the query parameters
|
|
||||||
*/
|
|
||||||
long getTaskCountForWorkbasketByDaysInPastAndState(String workbasketId, long daysInPast, List<TaskState> states);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Count all Tasks for all work basket objects where the due date is after "daysInPast" days from today in the past
|
|
||||||
* and the tasks are in specified states.
|
|
||||||
*
|
|
||||||
* @param daysInPast
|
|
||||||
* identifies the days in the past from today
|
|
||||||
* @param states
|
|
||||||
* {@link List} of {@link TaskState} objects that identifies the states of the tasks searched
|
|
||||||
* @return a list of of {@link DueWorkbasketCounter} objects that specifies how many tasks in the requested states
|
|
||||||
* with appropriate due date exist in the various work baskets
|
|
||||||
*/
|
|
||||||
List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast, List<TaskState> states);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Report} for a given list of {@link Workbasket}s and for a given list of {@link TaskState}s. The
|
* Returns a {@link Report} for a given list of {@link Workbasket}s and for a given list of {@link TaskState}s. The
|
||||||
* report only contains the number of all tasks of the respective workbasket as well as the total sum of all tasks.
|
* report only contains the number of all tasks of the respective workbasket as well as the total sum of all tasks.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package pro.taskana.impl;
|
package pro.taskana.impl;
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
@ -11,14 +9,12 @@ import pro.taskana.TaskMonitorService;
|
||||||
import pro.taskana.TaskanaEngine;
|
import pro.taskana.TaskanaEngine;
|
||||||
import pro.taskana.Workbasket;
|
import pro.taskana.Workbasket;
|
||||||
import pro.taskana.impl.util.LoggerUtils;
|
import pro.taskana.impl.util.LoggerUtils;
|
||||||
import pro.taskana.model.DueWorkbasketCounter;
|
|
||||||
import pro.taskana.model.MonitorQueryItem;
|
import pro.taskana.model.MonitorQueryItem;
|
||||||
import pro.taskana.model.Report;
|
import pro.taskana.model.Report;
|
||||||
import pro.taskana.model.ReportLine;
|
import pro.taskana.model.ReportLine;
|
||||||
import pro.taskana.model.ReportLineItem;
|
import pro.taskana.model.ReportLineItem;
|
||||||
import pro.taskana.model.ReportLineItemDefinition;
|
import pro.taskana.model.ReportLineItemDefinition;
|
||||||
import pro.taskana.model.TaskState;
|
import pro.taskana.model.TaskState;
|
||||||
import pro.taskana.model.TaskStateCounter;
|
|
||||||
import pro.taskana.model.mappings.TaskMonitorMapper;
|
import pro.taskana.model.mappings.TaskMonitorMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -36,70 +32,6 @@ public class TaskMonitorServiceImpl implements TaskMonitorService {
|
||||||
this.taskMonitorMapper = taskMonitorMapper;
|
this.taskMonitorMapper = taskMonitorMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<TaskStateCounter> getTaskCountForState(List<TaskState> states) {
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
|
||||||
LOGGER.debug("entry to getTaskCountForState(states = {})", LoggerUtils.listToString(states));
|
|
||||||
}
|
|
||||||
List<TaskStateCounter> result = null;
|
|
||||||
try {
|
|
||||||
taskanaEngineImpl.openConnection();
|
|
||||||
result = taskMonitorMapper.getTaskCountForState(states);
|
|
||||||
return result;
|
|
||||||
} finally {
|
|
||||||
taskanaEngineImpl.returnConnection();
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
|
||||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
|
||||||
LOGGER.debug("exit from getTaskCountForState(). Returning {} resulting Objects: {} ",
|
|
||||||
numberOfResultObjects, LoggerUtils.listToString(result));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getTaskCountForWorkbasketByDaysInPastAndState(String workbasketId, long daysInPast,
|
|
||||||
List<TaskState> states) {
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
|
||||||
LOGGER.debug(
|
|
||||||
"entry to getTaskCountForWorkbasketByDaysInPastAndState(workbasketId {}, daysInPast={}, states = {})",
|
|
||||||
workbasketId, daysInPast, LoggerUtils.listToString(states));
|
|
||||||
}
|
|
||||||
long result = -1;
|
|
||||||
try {
|
|
||||||
taskanaEngineImpl.openConnection();
|
|
||||||
Instant fromDate = Instant.now().minus(Duration.ofDays(daysInPast));
|
|
||||||
result = taskMonitorMapper.getTaskCountForWorkbasketByDaysInPastAndState(workbasketId, fromDate, states);
|
|
||||||
return result;
|
|
||||||
} finally {
|
|
||||||
taskanaEngineImpl.returnConnection();
|
|
||||||
LOGGER.debug("exit from getTaskCountForWorkbasketByDaysInPastAndState(). Returning result {} ", result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast,
|
|
||||||
List<TaskState> states) {
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
|
||||||
LOGGER.debug("entry to getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast = {}, states = {})",
|
|
||||||
daysInPast, LoggerUtils.listToString(states));
|
|
||||||
}
|
|
||||||
List<DueWorkbasketCounter> result = null;
|
|
||||||
try {
|
|
||||||
taskanaEngineImpl.openConnection();
|
|
||||||
Instant fromDate = Instant.now().minus(Duration.ofDays(daysInPast));
|
|
||||||
result = taskMonitorMapper.getTaskCountByWorkbasketIdAndDaysInPastAndState(fromDate, states);
|
|
||||||
return result;
|
|
||||||
} finally {
|
|
||||||
taskanaEngineImpl.returnConnection();
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
|
||||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
|
||||||
LOGGER.debug(
|
|
||||||
"exit from getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast,states). Returning {} resulting Objects: {} ",
|
|
||||||
numberOfResultObjects, LoggerUtils.listToString(result));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Report getWorkbasketLevelReport(List<Workbasket> workbaskets, List<TaskState> states) {
|
public Report getWorkbasketLevelReport(List<Workbasket> workbaskets, List<TaskState> states) {
|
||||||
return getWorkbasketLevelReport(workbaskets, states, null, false);
|
return getWorkbasketLevelReport(workbaskets, states, null, false);
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
package pro.taskana.model;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DueWorkbasketCounter entity.
|
|
||||||
*/
|
|
||||||
public class DueWorkbasketCounter {
|
|
||||||
|
|
||||||
private Instant due;
|
|
||||||
private String workbasketId;
|
|
||||||
private long taskCounter;
|
|
||||||
|
|
||||||
public Instant getDue() {
|
|
||||||
return due;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDue(Instant due) {
|
|
||||||
this.due = due;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWorkbasketId() {
|
|
||||||
return workbasketId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorkbasketId(String workbasketId) {
|
|
||||||
this.workbasketId = workbasketId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTaskCounter() {
|
|
||||||
return taskCounter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTaskCounter(long taskCounter) {
|
|
||||||
this.taskCounter = taskCounter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
package pro.taskana.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TaskStateCounter entity.
|
|
||||||
*/
|
|
||||||
public class TaskStateCounter {
|
|
||||||
|
|
||||||
private TaskState state;
|
|
||||||
private long counter;
|
|
||||||
|
|
||||||
public long getCounter() {
|
|
||||||
return counter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCounter(long counter) {
|
|
||||||
this.counter = counter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TaskState getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(TaskState state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("TaskStateCounter [state=");
|
|
||||||
builder.append(state);
|
|
||||||
builder.append(", counter=");
|
|
||||||
builder.append(counter);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package pro.taskana.model.mappings;
|
package pro.taskana.model.mappings;
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
@ -9,48 +8,14 @@ import org.apache.ibatis.annotations.Results;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import pro.taskana.Workbasket;
|
import pro.taskana.Workbasket;
|
||||||
import pro.taskana.model.DueWorkbasketCounter;
|
|
||||||
import pro.taskana.model.MonitorQueryItem;
|
import pro.taskana.model.MonitorQueryItem;
|
||||||
import pro.taskana.model.TaskState;
|
import pro.taskana.model.TaskState;
|
||||||
import pro.taskana.model.TaskStateCounter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the mybatis mapping of task monitoring.
|
* This class is the mybatis mapping of task monitoring.
|
||||||
*/
|
*/
|
||||||
public interface TaskMonitorMapper {
|
public interface TaskMonitorMapper {
|
||||||
|
|
||||||
@Select("<script>"
|
|
||||||
+ "SELECT STATE, COUNT (STATE) as counter "
|
|
||||||
+ "FROM TASK "
|
|
||||||
+ "WHERE STATE IN (<foreach collection='status' item='state' separator=','>#{state}</foreach>) "
|
|
||||||
+ "GROUP BY STATE"
|
|
||||||
+ "</script>")
|
|
||||||
@Results({ @Result(column = "STATE", property = "state"), @Result(column = "counter", property = "counter") })
|
|
||||||
List<TaskStateCounter> getTaskCountForState(@Param("status") List<TaskState> status);
|
|
||||||
|
|
||||||
@Select("<script>"
|
|
||||||
+ "SELECT COUNT (*) "
|
|
||||||
+ "FROM TASK "
|
|
||||||
+ "WHERE WORKBASKETID = #{workbasketId} "
|
|
||||||
+ "AND DUE >= #{fromDate} "
|
|
||||||
+ "AND STATE IN (<foreach collection='status' item='state' separator=','>#{state}</foreach>)"
|
|
||||||
+ "</script>")
|
|
||||||
long getTaskCountForWorkbasketByDaysInPastAndState(@Param("workbasketId") String workbasketId,
|
|
||||||
@Param("fromDate") Instant fromDate, @Param("status") List<TaskState> states);
|
|
||||||
|
|
||||||
@Select("<script>"
|
|
||||||
+ "SELECT CAST(DUE AS DATE) as DUE_DATE, WORKBASKETID, COUNT (*) as counter "
|
|
||||||
+ "FROM TASK "
|
|
||||||
+ "WHERE DUE >= #{fromDate} "
|
|
||||||
+ "AND STATE IN (<foreach collection='status' item='state' separator=','>#{state}</foreach>) "
|
|
||||||
+ "GROUP BY DUE_DATE, WORKBASKETID"
|
|
||||||
+ "</script>")
|
|
||||||
@Results({ @Result(column = "DUE_DATE", property = "due"),
|
|
||||||
@Result(column = "WORKBASKETID", property = "workbasketId"),
|
|
||||||
@Result(column = "counter", property = "taskCounter") })
|
|
||||||
List<DueWorkbasketCounter> getTaskCountByWorkbasketIdAndDaysInPastAndState(@Param("fromDate") Instant fromDate,
|
|
||||||
@Param("status") List<TaskState> states);
|
|
||||||
|
|
||||||
@Select("<script>"
|
@Select("<script>"
|
||||||
+ "<if test=\"_databaseId == 'db2'\">SELECT WORKBASKET_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> "
|
+ "<if test=\"_databaseId == 'db2'\">SELECT WORKBASKET_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> "
|
||||||
+ "<if test=\"_databaseId == 'h2'\">SELECT WORKBASKET_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> "
|
+ "<if test=\"_databaseId == 'h2'\">SELECT WORKBASKET_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> "
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,13 @@
|
||||||
package pro.taskana.impl;
|
package pro.taskana.impl;
|
||||||
|
|
||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -27,12 +24,10 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||||
import pro.taskana.Workbasket;
|
import pro.taskana.Workbasket;
|
||||||
import pro.taskana.WorkbasketService;
|
import pro.taskana.WorkbasketService;
|
||||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||||
import pro.taskana.model.DueWorkbasketCounter;
|
|
||||||
import pro.taskana.model.MonitorQueryItem;
|
import pro.taskana.model.MonitorQueryItem;
|
||||||
import pro.taskana.model.Report;
|
import pro.taskana.model.Report;
|
||||||
import pro.taskana.model.ReportLineItemDefinition;
|
import pro.taskana.model.ReportLineItemDefinition;
|
||||||
import pro.taskana.model.TaskState;
|
import pro.taskana.model.TaskState;
|
||||||
import pro.taskana.model.TaskStateCounter;
|
|
||||||
import pro.taskana.model.mappings.ObjectReferenceMapper;
|
import pro.taskana.model.mappings.ObjectReferenceMapper;
|
||||||
import pro.taskana.model.mappings.TaskMonitorMapper;
|
import pro.taskana.model.mappings.TaskMonitorMapper;
|
||||||
|
|
||||||
|
|
@ -70,62 +65,6 @@ public class TaskMonitorServiceImplTest {
|
||||||
Mockito.doNothing().when(taskanaEngineImpl).returnConnection();
|
Mockito.doNothing().when(taskanaEngineImpl).returnConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetTaskCountForState() {
|
|
||||||
List<TaskState> taskStates = Arrays.asList(TaskState.CLAIMED, TaskState.COMPLETED);
|
|
||||||
List<TaskStateCounter> expectedResult = new ArrayList<>();
|
|
||||||
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountForState(taskStates);
|
|
||||||
|
|
||||||
List<TaskStateCounter> actualResult = cut.getTaskCountForState(taskStates);
|
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
||||||
verify(taskMonitorMapperMock, times(1)).getTaskCountForState(taskStates);
|
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
||||||
taskMonitorMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
||||||
assertThat(actualResult, equalTo(expectedResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetTaskCountForWorkbasketByDaysInPastAndState() {
|
|
||||||
List<TaskState> taskStates = Arrays.asList(TaskState.CLAIMED, TaskState.COMPLETED);
|
|
||||||
final long daysInPast = 10L;
|
|
||||||
final long expectedResult = 5L;
|
|
||||||
String workbasketId = "1";
|
|
||||||
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountForWorkbasketByDaysInPastAndState(any(), any(),
|
|
||||||
any());
|
|
||||||
|
|
||||||
long actualResult = cut.getTaskCountForWorkbasketByDaysInPastAndState(workbasketId, daysInPast, taskStates);
|
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
||||||
verify(taskMonitorMapperMock, times(1)).getTaskCountForWorkbasketByDaysInPastAndState(any(), any(), any());
|
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
||||||
taskMonitorMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
||||||
assertThat(actualResult, equalTo(expectedResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetTaskCountByWorkbasketAndDaysInPastAndState() {
|
|
||||||
final long daysInPast = 10L;
|
|
||||||
List<TaskState> taskStates = Arrays.asList(TaskState.CLAIMED, TaskState.COMPLETED);
|
|
||||||
List<DueWorkbasketCounter> expectedResult = new ArrayList<>();
|
|
||||||
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountByWorkbasketIdAndDaysInPastAndState(
|
|
||||||
any(Instant.class),
|
|
||||||
any());
|
|
||||||
|
|
||||||
List<DueWorkbasketCounter> actualResult = cut.getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast,
|
|
||||||
taskStates);
|
|
||||||
|
|
||||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
|
||||||
verify(taskMonitorMapperMock, times(1)).getTaskCountByWorkbasketIdAndDaysInPastAndState(any(Instant.class),
|
|
||||||
any());
|
|
||||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
|
||||||
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
|
|
||||||
taskMonitorMapperMock, objectReferenceMapperMock, workbasketServiceMock);
|
|
||||||
assertThat(actualResult, equalTo(expectedResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTotalNumbersOfWorkbasketLevelReport() {
|
public void testGetTotalNumbersOfWorkbasketLevelReport() {
|
||||||
WorkbasketImpl workbasket = new WorkbasketImpl();
|
WorkbasketImpl workbasket = new WorkbasketImpl();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
package pro.taskana.rest;
|
package pro.taskana.rest;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeFormatterBuilder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
@ -13,90 +9,45 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import pro.taskana.TaskMonitorService;
|
|
||||||
import pro.taskana.WorkbasketService;
|
|
||||||
import pro.taskana.WorkbasketSummary;
|
|
||||||
import pro.taskana.model.DueWorkbasketCounter;
|
|
||||||
import pro.taskana.model.TaskState;
|
import pro.taskana.model.TaskState;
|
||||||
import pro.taskana.model.TaskStateCounter;
|
|
||||||
import pro.taskana.rest.model.WorkbasketCounterDataDto;
|
|
||||||
import pro.taskana.rest.model.WorkbasketCounterDto;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(path = "/v1/monitor", produces = { MediaType.APPLICATION_JSON_VALUE })
|
@RequestMapping(path = "/v1/monitor", produces = { MediaType.APPLICATION_JSON_VALUE })
|
||||||
public class MonitorController {
|
public class MonitorController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TaskMonitorService taskMonitorService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WorkbasketService workbasketService;
|
|
||||||
|
|
||||||
@RequestMapping(value = "/countByState")
|
@RequestMapping(value = "/countByState")
|
||||||
public ResponseEntity<List<TaskStateCounter>> getTaskcountForState(
|
public ResponseEntity<?> getTaskcountForState(
|
||||||
@RequestParam(value = "states") List<TaskState> taskStates) {
|
@RequestParam(value = "states") List<TaskState> taskStates) {
|
||||||
try {
|
String taskCount = "[{\"state\": \"READY\", \"counter\": 7},{\"state\": \"CLAIMED\",\"counter\": 4},{\"state\": \"COMPLETED\",\"counter\": 4 }]";
|
||||||
List<TaskStateCounter> taskCount = taskMonitorService.getTaskCountForState(taskStates);
|
return ResponseEntity.status(HttpStatus.OK).body(taskCount);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(taskCount);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/taskcountByWorkbasketDaysAndState")
|
@RequestMapping(value = "/taskcountByWorkbasketDaysAndState")
|
||||||
public ResponseEntity<?> getTaskCountByWorkbasketAndDaysInPastAndState(
|
public ResponseEntity<?> getTaskCountByWorkbasketAndDaysInPastAndState(
|
||||||
@RequestParam(value = "daysInPast") Long daysInPast,
|
@RequestParam(value = "daysInPast") Long daysInPast,
|
||||||
@RequestParam(value = "states") List<TaskState> states) {
|
@RequestParam(value = "states") List<TaskState> states) {
|
||||||
try {
|
|
||||||
WorkbasketCounterDto WorkbasketCounterDto = new WorkbasketCounterDto();
|
|
||||||
|
|
||||||
LocalDate date = LocalDate.now();
|
StringBuilder builder = new StringBuilder();
|
||||||
date = date.minusDays(daysInPast);
|
builder.append(
|
||||||
List<String> dates = new ArrayList<>();
|
"{ \"dates\": [\"02.02.2018\",\"03.02.2018\",\"04.02.2018\", \"05.02.2018\", \"06.02.2018\", \"07.02.2018\",\"08.02.2018\",\"09.02.2018\",\"10.02.2018\",\"11.02.2018\", \"12.02.2018\"],");
|
||||||
|
builder.append("\"data\": [");
|
||||||
for (int i = 0; i < (daysInPast * 2 + 1); i++) {
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Basket1\"},");
|
||||||
dates.add(date.format(new DateTimeFormatterBuilder().appendPattern("dd.MM.yyyy").toFormatter()));
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Basket2\"},");
|
||||||
date = date.plusDays(1);
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Basket3\"},");
|
||||||
}
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Basket4\"},");
|
||||||
WorkbasketCounterDto.setDates(dates);
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Gruppenpostkorb KSC\"},");
|
||||||
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Gruppenpostkorb KSC 1\"},");
|
||||||
List<WorkbasketCounterDataDto> data = new ArrayList<>();
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Gruppenpostkorb KSC 2\"},");
|
||||||
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"PPK Teamlead KSC 1\"},");
|
||||||
for (WorkbasketSummary workbasket : workbasketService.getWorkbaskets()) {
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"PPK Teamlead KSC 2\"},");
|
||||||
WorkbasketCounterDataDto counterDto = new WorkbasketCounterDataDto();
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"PPK User 1 KSC 1\"},");
|
||||||
counterDto.setLabel(workbasket.getName());
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"PPK User 2 KSC 1\"},");
|
||||||
List<Integer> zeroData = new ArrayList<>();
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"PPK User 1 KSC 2\"},");
|
||||||
for (int i = 0; i < dates.size(); i++) {
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"PPK User 2 KSC 2\"},");
|
||||||
zeroData.add(0);
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Gruppenpostkorb KSC B\"},");
|
||||||
}
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Gruppenpostkorb KSC B1\"},");
|
||||||
counterDto.setData(zeroData);
|
builder.append("{\"data\": [0,0,0,0,0,0,0,0,0,0,0],\"label\": \"Gruppenpostkorb KSC B2\"}");
|
||||||
data.add(counterDto);
|
builder.append("]}");
|
||||||
}
|
return ResponseEntity.status(HttpStatus.OK).body(builder.toString());
|
||||||
|
|
||||||
List<DueWorkbasketCounter> dwcList = taskMonitorService.getTaskCountByWorkbasketAndDaysInPastAndState(
|
|
||||||
daysInPast,
|
|
||||||
states);
|
|
||||||
|
|
||||||
for (DueWorkbasketCounter item : dwcList) {
|
|
||||||
String formattedDate = new DateTimeFormatterBuilder()
|
|
||||||
.appendPattern("dd.MM.yyyy")
|
|
||||||
.toFormatter()
|
|
||||||
.format(item.getDue());
|
|
||||||
for (int i = 0; i < dates.size(); i++) {
|
|
||||||
if (formattedDate.equalsIgnoreCase(dates.get(i))) {
|
|
||||||
for (int j = 0; j < data.size(); j++) {
|
|
||||||
if (data.get(j).getLabel().equalsIgnoreCase(
|
|
||||||
workbasketService.getWorkbasket(item.getWorkbasketId()).getName())) {
|
|
||||||
data.get(j).getData().set(i, (int) item.getTaskCounter());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WorkbasketCounterDto.setData(data);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(WorkbasketCounterDto);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
package pro.taskana.rest.model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WorkbasketCounterDataDto {
|
|
||||||
private List<Integer> data;
|
|
||||||
private String label;
|
|
||||||
public List<Integer> getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
public void setData(List<Integer> data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
package pro.taskana.rest.model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WorkbasketCounterDto {
|
|
||||||
|
|
||||||
private List<String> dates;
|
|
||||||
private List<WorkbasketCounterDataDto> data;
|
|
||||||
|
|
||||||
public List<String> getDates() {
|
|
||||||
return dates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDates(List<String> dates) {
|
|
||||||
this.dates = dates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WorkbasketCounterDataDto> getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(List<WorkbasketCounterDataDto> data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue