[TE] detection - migrate with user-specified or default last timestamp
@@ -52,13 +52,20 @@ public class DetectionMigrationResource {
@POST
public Response migrateToDetectionPipeline(
@QueryParam("id") long anomalyFunctionId,
- @QueryParam("name") String name) throws Exception {
+ @QueryParam("name") String name,
+ @QueryParam("lastTimestamp") Long lastTimestamp) throws Exception {
AnomalyFunctionDTO anomalyFunctionDTO = this.anomalyFunctionDAO.findById(anomalyFunctionId);
DetectionConfigDTO config = this.translator.translate(anomalyFunctionDTO);
+
if (!StringUtils.isBlank(name)) {
config.setName(name);
}
+ config.setLastTimestamp(System.currentTimeMillis());
+ if (lastTimestamp != null) {
+ config.setLastTimestamp(lastTimestamp);
+ }
+
this.detectionConfigDAO.save(config);
if (config.getId() == null) {
throw new WebApplicationException(String.format("Could not migrate anomaly function %d", anomalyFunctionId));
