diff --git a/src/main/java/eu/dnetlib/uoaadmintools/controllers/StatisticsController.java b/src/main/java/eu/dnetlib/uoaadmintools/controllers/StatisticsController.java index 2b3e595..15821c0 100644 --- a/src/main/java/eu/dnetlib/uoaadmintools/controllers/StatisticsController.java +++ b/src/main/java/eu/dnetlib/uoaadmintools/controllers/StatisticsController.java @@ -38,6 +38,15 @@ public class StatisticsController { return statistics; } + @RequestMapping(value = "/statistics/{id}/toggle", method = RequestMethod.POST) + public Boolean toggleStatistics(@PathVariable String id) throws Exception { + Statistics statistics = statisticsDAO.findById(id); + boolean status = statistics.getIsActive(); + statistics.setIsActive(!status); + statisticsDAO.save(statistics); + return statistics.getIsActive(); + } + @RequestMapping(value = "/statistics/save", method = RequestMethod.POST) public Statistics insertStatistics(@RequestBody Statistics statistics) { Statistics savedStatistics = statisticsDAO.save(statistics); diff --git a/src/main/java/eu/dnetlib/uoaadmintools/entities/statistics/Statistics.java b/src/main/java/eu/dnetlib/uoaadmintools/entities/statistics/Statistics.java index 1762bb9..f3d232f 100644 --- a/src/main/java/eu/dnetlib/uoaadmintools/entities/statistics/Statistics.java +++ b/src/main/java/eu/dnetlib/uoaadmintools/entities/statistics/Statistics.java @@ -14,9 +14,11 @@ public class Statistics { @JsonProperty("_id") private String id; private String pid; + private boolean isActive = true; Map entities = new HashMap(); public Statistics(String pid){ this.pid = pid; + this.isActive = true; entities.put("publication",new StatisticsEntity()); entities.put("dataset",new StatisticsEntity()); entities.put("software",new StatisticsEntity()); @@ -38,6 +40,14 @@ public class Statistics { this.pid = pid; } + public boolean getIsActive() { + return isActive; + } + + public void setIsActive(boolean isActive) { + this.isActive = isActive; + } + public Map getEntities() { return entities; } @@ -51,6 +61,7 @@ public class Statistics { return "Statistics{" + "id='" + id + '\'' + ", pid='" + pid + '\'' + + ", isActive= "+isActive + ", entities=" + entities + '}'; }