Commit ccafa9ce authored by oleg.pahhomov's avatar oleg.pahhomov

SA0140-377 make periods non mandatory

parent 3df6533e
......@@ -35,8 +35,8 @@ public class WidgetValidator {
if (widget.getPeriods() == null) {
throw badRequest("widget", "no periods").get();
}
if (widget.getPeriods() < 1) {
throw badRequest("widget", "periods should be bigger than 0").get();
if (widget.getPeriods() != null && widget.getPeriods() < 1) {
throw badRequest("widget", "periods should be positive").get();
}
if (widget.getStatDb() != null && isNotEmpty(widget.getGraphTypes())) {
if (isEmpty(widget.getDimensions())) {
......
......@@ -15,9 +15,10 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static ee.stat.dashboard.service.statdata.builder.StatMonthUrlBuilder.*;
import static ee.stat.dashboard.service.statdata.builder.StatQuarterUrlBuilder.*;
import static ee.stat.dashboard.service.statdata.builder.StatMonthUrlBuilder.monthlyCalculation;
import static ee.stat.dashboard.service.statdata.builder.StatQuarterUrlBuilder.quarterlyCalculation;
import static ee.stat.dashboard.service.statdata.builder.StatYearUrlBuilder.yearlyCalculation;
import static ee.stat.dashboard.util.StatListUtil.first;
import static java.text.MessageFormat.format;
import static org.apache.commons.collections4.CollectionUtils.isEmpty;
import static org.apache.commons.lang3.BooleanUtils.isTrue;
......@@ -79,7 +80,7 @@ public class StatUrlBuilderService {
log.error("No time dimension, cube: {}", config.getCube());
return "";
}
XmlDimension timeDim = config.getTimeDimensions().get(0);
XmlDimension timeDim = first(config.getTimeDimensions());
timeDim.transformValues();
if (config.getTimePeriod().isYear()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment