Skip to content

Commit

Permalink
TSK-843: implemented foldable report in frontend. (structure only)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustaphazorgati authored and holgerhagen committed Apr 30, 2019
1 parent 91392c9 commit b75be88
Show file tree
Hide file tree
Showing 26 changed files with 339 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
import org.slf4j.LoggerFactory;

import pro.taskana.TaskState;
import pro.taskana.impl.report.item.TimestampQueryItem;
import pro.taskana.report.Timestamp;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.header.TimeIntervalColumnHeader;
import pro.taskana.impl.report.item.TimestampQueryItem;
import pro.taskana.impl.report.preprocessor.DaysToWorkingDaysPreProcessor;
import pro.taskana.mappings.TaskMonitorMapper;
import pro.taskana.report.Timestamp;
import pro.taskana.report.TimestampReport;

/**
* The implementation of {@link TimestampReport.Builder}.
*/
public class TimestampReportBuilderImpl extends
TimeIntervalReportBuilderImpl<TimestampReport.Builder, TimestampQueryItem, TimeIntervalColumnHeader.Date>
TimeIntervalReportBuilderImpl<TimestampReport.Builder, TimestampQueryItem, TimeIntervalColumnHeader>
implements TimestampReport.Builder {

private static final Logger LOGGER = LoggerFactory.getLogger(TimestampReport.Builder.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ public abstract class Report<I extends QueryItem, H extends ColumnHeader<? super
private Map<String, Row<I>> reportRows = new LinkedHashMap<>();
private Row<I> sumRow;
private String rowDesc;
private String[] expandableHeaders;

protected Report(List<H> columnHeaders, String rowDesc) {
protected Report(List<H> columnHeaders, String rowDesc, String[] expandableHeaders) {
this.rowDesc = rowDesc;
sumRow = createRow(columnHeaders.size());
this.columnHeaders = new ArrayList<>(columnHeaders);
this.expandableHeaders = expandableHeaders;
}

protected Report(List<H> columnHeaders, String rowDesc) {
this(columnHeaders, rowDesc, new String[0]);
}

public final Map<String, Row<I>> getRows() {
Expand All @@ -48,6 +54,10 @@ public final String getRowDesc() {
return rowDesc;
}

public final String[] getExpandableHeaders() {
return expandableHeaders;
}

public Row<I> getRow(String key) {
return reportRows.get(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
/**
* A {@link TimestampReport} displays created and competed tasks for a specific dates.
*/
public class TimestampReport extends Report<TimestampQueryItem, TimeIntervalColumnHeader.Date> {
public class TimestampReport extends Report<TimestampQueryItem, TimeIntervalColumnHeader> {

public TimestampReport(List<TimeIntervalColumnHeader.Date> dates) {
super(dates, "STATES");
public TimestampReport(List<TimeIntervalColumnHeader> dates) {
super(dates, "STATES", new String[] {"ORG LEVEL 1", "ORG LEVEL 2", "ORG LEVEL 3", "ORG LEVEL 4"});
}

@Override
Expand All @@ -32,7 +32,7 @@ public TimestampRow getRow(String key) {
* Builder for {@link TimestampReport}.
*/
public interface Builder extends
TimeIntervalReportBuilder<TimestampReport.Builder, TimestampQueryItem, TimeIntervalColumnHeader.Date> {
TimeIntervalReportBuilder<TimestampReport.Builder, TimestampQueryItem, TimeIntervalColumnHeader> {

@Override
TimestampReport buildReport() throws NotAuthorizedException, InvalidArgumentException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import pro.taskana.TaskMonitorService;
import pro.taskana.impl.report.header.TimeIntervalColumnHeader;
import pro.taskana.impl.report.item.TimestampQueryItem;
import pro.taskana.impl.report.row.TimestampRow;
import pro.taskana.impl.report.row.SingleRow;
import pro.taskana.impl.report.row.TimestampRow;
import pro.taskana.report.TimestampReport;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
Expand All @@ -43,7 +43,7 @@ public void testProperInsertionOfQueryItems() throws Exception {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();

//last 14 days. Today excluded.
List<TimeIntervalColumnHeader.Date> headers = IntStream.range(-14, 0)
List<TimeIntervalColumnHeader> headers = IntStream.range(-14, 0)
.mapToObj(TimeIntervalColumnHeader.Date::new)
.collect(Collectors.toList());
TimestampReport timestampReport = taskMonitorService.createTimestampReportBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public ResponseEntity<ReportResource> getTasksClassificationReport()
return response;
}

@GetMapping(path = "/daily-entry-exit-report")
@GetMapping(path = "/timestamp-report")
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<ReportResource> getDailyEntryExitReport()
throws NotAuthorizedException, InvalidArgumentException {
List<TimeIntervalColumnHeader.Date> columnHeaders = IntStream.range(-14, 0)
List<TimeIntervalColumnHeader> columnHeaders = IntStream.range(-14, 0)
.mapToObj(TimeIntervalColumnHeader.Date::new)
.collect(Collectors.toList());
return ResponseEntity.status(HttpStatus.OK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.row.FoldableRow;
import pro.taskana.impl.report.row.SingleRow;
import pro.taskana.report.ClassificationReport;
import pro.taskana.report.TimestampReport;
import pro.taskana.report.TaskStatusReport;
import pro.taskana.report.WorkbasketReport;
import pro.taskana.impl.report.structure.ColumnHeader;
import pro.taskana.impl.report.structure.QueryItem;
import pro.taskana.impl.report.structure.Report;
import pro.taskana.impl.report.structure.Row;
import pro.taskana.report.ClassificationReport;
import pro.taskana.report.TaskStatusReport;
import pro.taskana.report.TimestampReport;
import pro.taskana.report.WorkbasketReport;
import pro.taskana.rest.MonitorController;

/**
Expand Down Expand Up @@ -80,7 +80,7 @@ <I extends QueryItem, H extends ColumnHeader<? super I>> ReportResource toReport
report.getClass().getSimpleName(),
time.toString(),
header,
report.getRowDesc());
report.getExpandableHeaders(), report.getRowDesc());

// iterate over each Row and transform it to a RowResource while keeping the domain key.
Map<String, ReportResource.RowResource> rows = report.getRows()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ public static class MetaInformation {
private String name;
private String date;
private String[] header;
private String[] expHeader;
private String rowDesc;

public MetaInformation(String name, String date, String[] header, String rowDesc) {
public MetaInformation(String name, String date, String[] header, String[] expHeader, String rowDesc) {
this.name = name;
this.date = date;
this.header = header;
this.expHeader = expHeader;
this.rowDesc = rowDesc;
}

Expand All @@ -134,18 +136,18 @@ public String[] getHeader() {
return header;
}

public String[] getExpHeader() {
return expHeader;
}

public String getRowDesc() {
return rowDesc;
}

@Override
public String toString() {
return "MetaInformation ["
+ "name= " + this.name
+ "date= " + this.date
+ "header= " + Arrays.toString(this.header)
+ "rowDesc= " + this.rowDesc
+ "]";
return String.format("MetaInformation [name= %s, date= %s, header= %s, expHeader= %s, rowDesc= %s]",
name, date, Arrays.toString(header), Arrays.toString(expHeader), rowDesc);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import pro.taskana.impl.report.item.DetailedMonitorQueryItem;
import pro.taskana.impl.report.item.MonitorQueryItem;
import pro.taskana.report.ClassificationReport;
import pro.taskana.report.TimestampReport;
import pro.taskana.report.WorkbasketReport;
import pro.taskana.rest.TestConfiguration;

Expand Down Expand Up @@ -67,6 +68,7 @@ public void testEmptyReport() {
assertEquals("2019-01-02T00:00:00Z", meta.getDate());
assertEquals("WORKBASKET KEYS", meta.getRowDesc());
assertArrayEquals(headers.stream().map(TimeIntervalColumnHeader::getDisplayName).toArray(), meta.getHeader());
assertArrayEquals(new String[0], meta.getExpHeader());
assertEquals("Total", meta.getTotalDesc());

// rows
Expand Down Expand Up @@ -103,6 +105,7 @@ public void testOneSingleRow() {
assertEquals("2019-01-02T00:00:00Z", meta.getDate());
assertEquals("CLASSIFICATION KEYS", meta.getRowDesc());
assertArrayEquals(headers.stream().map(TimeIntervalColumnHeader::getDisplayName).toArray(), meta.getHeader());
assertArrayEquals(new String[0], meta.getExpHeader());
assertEquals("Total", meta.getTotalDesc());

// rows
Expand Down Expand Up @@ -154,6 +157,7 @@ public void testMultipleSingleRows() {
assertEquals("2019-01-02T00:00:00Z", meta.getDate());
assertEquals("CLASSIFICATION KEYS", meta.getRowDesc());
assertArrayEquals(headers.stream().map(TimeIntervalColumnHeader::getDisplayName).toArray(), meta.getHeader());
assertArrayEquals(new String[0], meta.getExpHeader());
assertEquals("Total", meta.getTotalDesc());

// rows
Expand Down Expand Up @@ -219,6 +223,7 @@ public void testOneFoldableRow() {
assertEquals("2019-01-02T00:00:00Z", meta.getDate());
assertEquals("TASK CLASSIFICATION KEYS", meta.getRowDesc());
assertArrayEquals(headers.stream().map(TimeIntervalColumnHeader::getDisplayName).toArray(), meta.getHeader());
assertArrayEquals(new String[0], meta.getExpHeader());
assertEquals("Total", meta.getTotalDesc());

// rows
Expand Down Expand Up @@ -319,6 +324,7 @@ public void testMultipleFoldableRows() {
assertEquals("2019-01-02T00:00:00Z", meta.getDate());
assertEquals("TASK CLASSIFICATION KEYS", meta.getRowDesc());
assertArrayEquals(headers.stream().map(TimeIntervalColumnHeader::getDisplayName).toArray(), meta.getHeader());
assertArrayEquals(new String[0], meta.getExpHeader());
assertEquals("Total", meta.getTotalDesc());

// rows
Expand Down Expand Up @@ -418,4 +424,20 @@ public void testMultipleFoldableRows() {
assertEquals(0, cells.get("2018-12-28").intValue());
}

@Test
public void testExpandableHeader() {
//given
TimestampReport report = new TimestampReport(headers);
//when
ReportResource resource = reportAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
//then
ReportResource.MetaInformation meta = resource.getMeta();
assertEquals("TimestampReport", meta.getName());
assertEquals("2019-01-02T00:00:00Z", meta.getDate());
assertEquals("STATES", meta.getRowDesc());
assertArrayEquals(headers.stream().map(TimeIntervalColumnHeader::getDisplayName).toArray(), meta.getHeader());
assertArrayEquals(new String[] {"ORG LEVEL 1", "ORG LEVEL 2", "ORG LEVEL 3", "ORG LEVEL 4"},
meta.getExpHeader());
assertEquals("Total", meta.getTotalDesc());
}
}
Loading

0 comments on commit b75be88

Please sign in to comment.