2019-11-04 10:03:49 +01:00
|
|
|
package eu.dnetlib.uoamonitorservice.entities;
|
|
|
|
|
2024-03-08 19:55:51 +01:00
|
|
|
import eu.dnetlib.uoamonitorservice.dto.CategoryFull;
|
|
|
|
import eu.dnetlib.uoamonitorservice.generics.CategoryGeneric;
|
2024-03-12 23:20:55 +01:00
|
|
|
import eu.dnetlib.uoamonitorservice.generics.Common;
|
2024-03-08 19:55:51 +01:00
|
|
|
import eu.dnetlib.uoamonitorservice.generics.TopicGeneric;
|
|
|
|
import org.springframework.data.mongodb.core.mapping.Document;
|
2019-11-19 14:05:43 +01:00
|
|
|
|
2019-12-19 16:04:25 +01:00
|
|
|
import java.util.ArrayList;
|
2024-03-12 23:20:55 +01:00
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.stream.Collectors;
|
2019-11-04 10:03:49 +01:00
|
|
|
|
2024-03-08 19:55:51 +01:00
|
|
|
@Document
|
|
|
|
public class Category extends CategoryGeneric<String> {
|
|
|
|
public Category() {
|
|
|
|
super();
|
|
|
|
}
|
2019-11-04 10:03:49 +01:00
|
|
|
|
2024-03-27 13:07:41 +01:00
|
|
|
public Category(Category category) {
|
|
|
|
super(category);
|
|
|
|
}
|
|
|
|
|
2024-03-08 19:55:51 +01:00
|
|
|
public Category(CategoryFull category) {
|
|
|
|
super(category);
|
2024-03-12 23:20:55 +01:00
|
|
|
this.subCategories = category.getSubCategories().stream().map(Common::getId).collect(Collectors.toList());
|
|
|
|
this.subCategories.removeIf(Objects::isNull);
|
2019-12-19 16:04:25 +01:00
|
|
|
}
|
|
|
|
|
2024-03-27 13:07:41 +01:00
|
|
|
public Category copy() {
|
|
|
|
Category category = new Category(this);
|
|
|
|
category.setDefaultId(this.getId());
|
|
|
|
category.setId(null);
|
|
|
|
return category;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Category override(Category category, Category old) {
|
|
|
|
return (Category) super.override(category, old);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SubCategory createOverview() {
|
|
|
|
SubCategory subCategory = new SubCategory();
|
|
|
|
subCategory.setName("Overview");
|
|
|
|
subCategory.setAlias("overview");
|
|
|
|
subCategory.setVisibility(this.getVisibility());
|
|
|
|
subCategory.setCharts(new ArrayList<>());
|
|
|
|
subCategory.setNumbers(new ArrayList<>());
|
|
|
|
return subCategory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addSubCategory(String id) {
|
|
|
|
this.subCategories.add(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeSubCategory(String id) {
|
|
|
|
this.subCategories.remove(id);
|
2019-11-04 10:03:49 +01:00
|
|
|
}
|
|
|
|
}
|