2019-11-04 10:03:49 +01:00
|
|
|
package eu.dnetlib.uoamonitorservice.entities;
|
|
|
|
|
2024-03-12 23:20:55 +01:00
|
|
|
import eu.dnetlib.uoamonitorservice.dto.SubCategoryFull;
|
|
|
|
import eu.dnetlib.uoamonitorservice.generics.Common;
|
2024-03-08 19:55:51 +01:00
|
|
|
import eu.dnetlib.uoamonitorservice.generics.SubCategoryGeneric;
|
|
|
|
import org.springframework.data.mongodb.core.mapping.Document;
|
1. Stakeholder.java: Create constructor and copy constructor & change getters-setters for 'isDeafult', 'isPublic' and 'isActive' fields.
2. Topic.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields.
3. Category.java: Create constructor and copy constructor & change getters-setters for 'isOverview, 'isPublic' and 'isActive' fields & remove field 'description'.
4. SubCategory.java: Create constructor and copy constructor & change getters-setters for 'isPublic' and 'isActive' fields & remove field 'description' &
make charts and numbers (List) generic (String or Indicator).
5. Indicator.java: Change getters-setters for 'indicatorPaths', 'isPublic' and 'isActive' fields & create method: public boolean hasType(String str), to check if "chart" or "number".
6. IndicatorPath.java: Add fields in schema (chartObject, parameters, filters) & add in enum IndicatorPathType types: pie, line, image.
7. MongoDBStakeholderDAO.java & StakeholderDAO.java: Add method: Stakeholder findByAlias(String Alias)
8. StakeholderController.java:
a. Add method: public Stakeholder setIndicatorsForStakeholder(Stakeholder stakeholder) to replace indicator ids with Indicator objects
(used by: getAllStakeholders, getAllDefaultStakeholders, getAllRealStakeholders, getStakeholder (by alias))
b. Add method: public Stakeholder getStakeholder(@PathVariable("alias") String alias) - /stakeholder/{alias}
c. Add method: public Stakeholder saveStakeholder(@RequestBody Stakeholder stakeholder) - /stakeholder/save
d. Add method: public boolean deleteIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/{id}
e. Add method: public Indicator saveIndicator(...) - /{stakeholder}/{topic}/{category}/{subcategory}/indicator/save (in body send Indicator object)
2019-11-11 17:38:36 +01:00
|
|
|
|
2024-03-27 13:07:41 +01:00
|
|
|
import java.util.ArrayList;
|
2024-03-12 23:20:55 +01:00
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
2024-03-08 19:55:51 +01:00
|
|
|
@Document
|
|
|
|
public class SubCategory extends SubCategoryGeneric<String> {
|
2024-03-27 13:07:41 +01:00
|
|
|
public SubCategory() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
public SubCategory(SubCategory subCategory) {
|
|
|
|
super(subCategory);
|
|
|
|
}
|
2019-11-04 10:03:49 +01:00
|
|
|
|
2024-03-12 23:20:55 +01:00
|
|
|
public SubCategory(SubCategoryFull subCategory) {
|
2024-03-08 19:55:51 +01:00
|
|
|
super(subCategory);
|
2024-03-12 23:20:55 +01:00
|
|
|
this.numbers = subCategory.getNumbers().stream().map(Common::getId).collect(Collectors.toList());
|
|
|
|
this.charts = subCategory.getCharts().stream().map(Common::getId).collect(Collectors.toList());
|
|
|
|
this.numbers.removeIf(Objects::isNull);
|
|
|
|
this.charts.removeIf(Objects::isNull);
|
2019-11-04 10:03:49 +01:00
|
|
|
}
|
2024-03-27 13:07:41 +01:00
|
|
|
|
|
|
|
public SubCategory copy() {
|
|
|
|
SubCategory subCategory = new SubCategory(this);
|
|
|
|
subCategory.setDefaultId(this.getId());
|
|
|
|
subCategory.setId(null);
|
|
|
|
return subCategory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public SubCategory override(SubCategory subCategory, SubCategory old) {
|
|
|
|
return (SubCategory) super.override(subCategory, old);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addNumber(String id, int index) {
|
|
|
|
if(index == -1) {
|
|
|
|
this.numbers.add(id);
|
|
|
|
} else {
|
|
|
|
this.numbers.add(index, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeNumber(String id) {
|
|
|
|
this.numbers.remove(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addChart(String id, int index) {
|
|
|
|
if(index == -1) {
|
|
|
|
this.charts.add(id);
|
|
|
|
} else {
|
|
|
|
this.charts.add(index, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeChart(String id) {
|
|
|
|
this.charts.remove(id);
|
|
|
|
}
|
2019-11-04 10:03:49 +01:00
|
|
|
}
|