return information about the plotted sequences
this information can be used for tests
This commit is contained in:
18
pdb-ui/src/main/java/org/lucares/pdbui/BadRequest.java
Normal file
18
pdb-ui/src/main/java/org/lucares/pdbui/BadRequest.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "BadRequest")
|
||||
public class BadRequest extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 694206253376122420L;
|
||||
|
||||
public BadRequest(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public BadRequest(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
@@ -19,8 +17,10 @@ import org.lucares.pdbui.domain.AutocompleteResponse;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.PlotResponse;
|
||||
import org.lucares.performance.db.CollectionUtils;
|
||||
import org.lucares.recommind.logs.DataSeries;
|
||||
import org.lucares.recommind.logs.InternalPlottingException;
|
||||
import org.lucares.recommind.logs.NoDataPointsException;
|
||||
import org.lucares.recommind.logs.PlotResult;
|
||||
import org.lucares.recommind.logs.Plotter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -73,13 +73,12 @@ public class PdbController implements HardcodedValues, CollectionUtils {
|
||||
final PlotSettings plotSettings = PlotSettingsTransformer.toSettings(request);
|
||||
|
||||
try {
|
||||
final File image = plotter.plot(plotSettings);
|
||||
final PlotResult result = plotter.plot(plotSettings);
|
||||
|
||||
final Path relativeImagePath = plotter.getOutputDir().relativize(image.toPath());
|
||||
final String relativeImgUrl = relativeImagePath.toString().replace('\\', '/');
|
||||
final String imageUrl = WEB_IMAGE_OUTPUT_PATH + "/" + relativeImgUrl;
|
||||
final String imageUrl = WEB_IMAGE_OUTPUT_PATH + "/" + result.getImageName();
|
||||
LOGGER.trace("image url: {}", imageUrl);
|
||||
return new PlotResponse(imageUrl);
|
||||
|
||||
return new PlotResponse(DataSeries.toMap(result.getDataSeries()), imageUrl);
|
||||
} catch (final NoDataPointsException e) {
|
||||
throw new NotFoundException(e);
|
||||
}
|
||||
|
||||
@@ -3,15 +3,14 @@ package org.lucares.pdbui.domain;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlotResponse {
|
||||
private List<String> imageUrls = new ArrayList<>();
|
||||
private Map<String, Integer> dataSeries;
|
||||
|
||||
public PlotResponse() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PlotResponse(final String... imageUrls) {
|
||||
public PlotResponse(final Map<String, Integer> dataSeries, final String... imageUrls) {
|
||||
this.dataSeries = dataSeries;
|
||||
this.imageUrls.addAll(Arrays.asList(imageUrls));
|
||||
}
|
||||
|
||||
@@ -23,9 +22,17 @@ public class PlotResponse {
|
||||
this.imageUrls = imageUrls;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getDataSeries() {
|
||||
return dataSeries;
|
||||
}
|
||||
|
||||
public void setDataSeries(final Map<String, Integer> dataSeries) {
|
||||
this.dataSeries = dataSeries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(imageUrls);
|
||||
return String.valueOf(imageUrls) + " " + dataSeries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user