Revert properties. Remove some comments. Remove mongodb DAOs. Move primitives classes and enums to new package primitives.
This commit is contained in:
parent
76c39d6eb3
commit
1158b676e4
|
@ -1,10 +1,13 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoamonitorservice.dao.*;
|
||||
import eu.dnetlib.uoamonitorservice.dao.CategoryDAO;
|
||||
import eu.dnetlib.uoamonitorservice.dao.StakeholderDAO;
|
||||
import eu.dnetlib.uoamonitorservice.dao.SubCategoryDAO;
|
||||
import eu.dnetlib.uoamonitorservice.dao.TopicDAO;
|
||||
import eu.dnetlib.uoamonitorservice.entities.*;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -45,7 +48,7 @@ public class CategoryController {
|
|||
|
||||
List<String> subCategories = new ArrayList<>();
|
||||
List<SubCategory> subCategoriesFull = new ArrayList<>();
|
||||
for(SubCategory<Section<Indicator>> subCategory : categoryFull.getSubCategories()) {
|
||||
for (SubCategory<Section<Indicator>> subCategory : categoryFull.getSubCategories()) {
|
||||
SubCategory<Section<Indicator>> subcategoryFull = subCategoryController.buildSubCategory(subCategory);
|
||||
subCategoriesFull.add(subcategoryFull);
|
||||
subCategories.add(subcategoryFull.getId());
|
||||
|
@ -72,28 +75,28 @@ public class CategoryController {
|
|||
@PathVariable("topicId") String topicId,
|
||||
@RequestBody Category<SubCategory> categoryFull) {
|
||||
log.debug("save category");
|
||||
log.debug("Alias: "+categoryFull.getAlias() + " - Id: "+categoryFull.getId() + " - Stakeholder: "+stakeholderId + " - Topic: "+topicId);
|
||||
log.debug("Alias: " + categoryFull.getAlias() + " - Id: " + categoryFull.getId() + " - Stakeholder: " + stakeholderId + " - Topic: " + topicId);
|
||||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
|
||||
if(stakeholder != null) {
|
||||
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
if (stakeholder != null) {
|
||||
if (!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("Save Category: You are not authorized to update stakeholder with id: "+stakeholderId);
|
||||
throw new ForbiddenException("Save Category: You are not authorized to update stakeholder with id: " + stakeholderId);
|
||||
}
|
||||
|
||||
Category<String> oldCategory = null;
|
||||
if(categoryFull.getId() != null) {
|
||||
if (categoryFull.getId() != null) {
|
||||
oldCategory = categoryDAO.findById(categoryFull.getId());
|
||||
if(oldCategory == null) {
|
||||
if (oldCategory == null) {
|
||||
// EXCEPTION - Category not found
|
||||
throw new EntityNotFoundException("save category: Category with id: " + categoryFull.getId() + " not found");
|
||||
}
|
||||
}
|
||||
|
||||
Topic<String> topic = topicDAO.findById(topicId);
|
||||
if(topic != null) {
|
||||
if(stakeholder.getTopics().contains(topicId)) {
|
||||
if (topic != null) {
|
||||
if (stakeholder.getTopics().contains(topicId)) {
|
||||
Category<String> category = new Category<>(categoryFull);
|
||||
|
||||
Date date = new Date();
|
||||
|
@ -103,7 +106,7 @@ public class CategoryController {
|
|||
List<String> subCategories = new ArrayList<>();
|
||||
|
||||
// if category not exists (no id), create a new default subcategory, identical to category
|
||||
if(categoryFull.getId() == null) {
|
||||
if (categoryFull.getId() == null) {
|
||||
category.setCreationDate(date);
|
||||
categoryFull.setCreationDate(date);
|
||||
|
||||
|
@ -115,15 +118,15 @@ public class CategoryController {
|
|||
List<SubCategory> subCategoriesFull = categoryFull.getSubCategories();
|
||||
subCategoriesFull.add(subCategory);
|
||||
|
||||
for(SubCategory oldSubCategory : subCategoriesFull) {
|
||||
for (SubCategory oldSubCategory : subCategoriesFull) {
|
||||
subCategories.add(oldSubCategory.getId());
|
||||
}
|
||||
} else {
|
||||
for(String subCategoryId : oldCategory.getSubCategories()) {
|
||||
for (String subCategoryId : oldCategory.getSubCategories()) {
|
||||
SubCategory subCategory = subCategoryDAO.findById(subCategoryId);
|
||||
if (subCategory == null) {
|
||||
// EXCEPTION - SubCategory not found
|
||||
throw new EntityNotFoundException("Save category: SubCategory with id: "+subCategoryId+" not found (subcategory exists in category: "+category.getId()+")");
|
||||
throw new EntityNotFoundException("Save category: SubCategory with id: " + subCategoryId + " not found (subcategory exists in category: " + category.getId() + ")");
|
||||
}
|
||||
subCategories.add(subCategory.getId());
|
||||
}
|
||||
|
@ -131,8 +134,8 @@ public class CategoryController {
|
|||
|
||||
category.setSubCategories(subCategories);
|
||||
|
||||
if(stakeholder.getDefaultId() == null) {
|
||||
if(categoryFull.getId() == null) {
|
||||
if (stakeholder.getDefaultId() == null) {
|
||||
if (categoryFull.getId() == null) {
|
||||
categoryDAO.save(category);
|
||||
onSaveDefaultCategory(category, topicId);
|
||||
} else {
|
||||
|
@ -145,27 +148,24 @@ public class CategoryController {
|
|||
|
||||
List<String> categories = topic.getCategories();
|
||||
int index = categories.indexOf(category.getId());
|
||||
if(index == -1) {
|
||||
if (index == -1) {
|
||||
categories.add(category.getId());
|
||||
topicDAO.save(topic);
|
||||
log.debug("Category saved!");
|
||||
|
||||
categoryFull.setId(category.getId());
|
||||
}
|
||||
|
||||
subCategories = null;
|
||||
category = null;
|
||||
} else {
|
||||
// EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
|
||||
throw new PathNotValidException("Save category: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId);
|
||||
throw new PathNotValidException("Save category: Topic with id: " + topicId + " not found in Stakeholder: " + stakeholderId);
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Topic not found
|
||||
throw new EntityNotFoundException("Save category: Topic with id: "+topicId+" not found");
|
||||
throw new EntityNotFoundException("Save category: Topic with id: " + topicId + " not found");
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Stakeholder not found
|
||||
throw new EntityNotFoundException("Save category: Stakeholder with id: "+stakeholderId+" not found");
|
||||
throw new EntityNotFoundException("Save category: Stakeholder with id: " + stakeholderId + " not found");
|
||||
}
|
||||
return categoryFull;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class CategoryController {
|
|||
log.debug("On save default category");
|
||||
|
||||
List<Topic> topics = topicDAO.findByDefaultId(topicId);
|
||||
for(Topic topic : topics) {
|
||||
for (Topic topic : topics) {
|
||||
Category categoryNew = new Category();
|
||||
categoryNew.copyFromDefault(category);
|
||||
|
||||
|
@ -195,28 +195,24 @@ public class CategoryController {
|
|||
|
||||
List<Category> categories = categoryDAO.findByDefaultId(category.getId());
|
||||
boolean changed = false;
|
||||
for(Category categoryBasedOnDefault : categories) {
|
||||
if(category.getName() != null && !category.getName().equals(categoryBasedOnDefault.getName())
|
||||
for (Category categoryBasedOnDefault : categories) {
|
||||
if (category.getName() != null && !category.getName().equals(categoryBasedOnDefault.getName())
|
||||
&& (oldCategory.getName() == null || oldCategory.getName().equals(categoryBasedOnDefault.getName()))) {
|
||||
|
||||
categoryBasedOnDefault.setName(category.getName());
|
||||
categoryBasedOnDefault.setAlias(category.getAlias());
|
||||
changed = true;
|
||||
}
|
||||
if(category.getDescription() != null && !category.getDescription().equals(categoryBasedOnDefault.getDescription())
|
||||
if (category.getDescription() != null && !category.getDescription().equals(categoryBasedOnDefault.getDescription())
|
||||
&& (oldCategory.getDescription() == null || oldCategory.getDescription().equals(categoryBasedOnDefault.getDescription()))) {
|
||||
|
||||
categoryBasedOnDefault.setDescription(category.getDescription());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if(!changed) {
|
||||
// break;
|
||||
if (!changed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// categoryBasedOnDefault.setName(category.getName());
|
||||
// categoryBasedOnDefault.setDescription(category.getDescription());
|
||||
categoryBasedOnDefault.setUpdateDate(category.getUpdateDate());
|
||||
categoryDAO.save(categoryBasedOnDefault);
|
||||
}
|
||||
|
@ -229,34 +225,34 @@ public class CategoryController {
|
|||
@PathVariable("categoryId") String categoryId,
|
||||
@RequestParam(required = false) String children) {
|
||||
log.debug("delete category");
|
||||
log.debug("Id: "+categoryId + " - Stakeholder: "+stakeholderId + " - Topic: "+topicId);
|
||||
log.debug("Id: " + categoryId + " - Stakeholder: " + stakeholderId + " - Topic: " + topicId);
|
||||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
|
||||
if(stakeholder != null) {
|
||||
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
if (stakeholder != null) {
|
||||
if (!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("Delete category: You are not authorized to update stakeholder with id: "+stakeholderId);
|
||||
throw new ForbiddenException("Delete category: You are not authorized to update stakeholder with id: " + stakeholderId);
|
||||
}
|
||||
|
||||
Topic<String> topic = topicDAO.findById(topicId);
|
||||
if(topic != null) {
|
||||
if(stakeholder.getTopics().contains(topicId)) {
|
||||
if (topic != null) {
|
||||
if (stakeholder.getTopics().contains(topicId)) {
|
||||
|
||||
Category<String> category = categoryDAO.findById(categoryId);
|
||||
if(category != null) {
|
||||
if (category != null) {
|
||||
|
||||
if(category.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
|
||||
if (category.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("Delete category: You are not authorized to delete a default Category in stakeholder with id: "+stakeholderId);
|
||||
throw new ForbiddenException("Delete category: You are not authorized to delete a default Category in stakeholder with id: " + stakeholderId);
|
||||
}
|
||||
|
||||
|
||||
List<String> categories = topic.getCategories();
|
||||
int index = categories.indexOf(categoryId);
|
||||
if(index != -1) {
|
||||
if (index != -1) {
|
||||
// this category belongs in default profile
|
||||
if(topic.getDefaultId() == null && children != null) {
|
||||
if (topic.getDefaultId() == null && children != null) {
|
||||
onDeleteDefaultCategory(categoryId, topicId, children);
|
||||
}
|
||||
subCategoryController.deleteTree(category);
|
||||
|
@ -267,42 +263,42 @@ public class CategoryController {
|
|||
log.debug("Category deleted!");
|
||||
} else {
|
||||
// EXCEPTION - Category not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias();
|
||||
throw new PathNotValidException("Delete category: Category with id: "+categoryId+" not found in Topic: "+topicId);
|
||||
throw new PathNotValidException("Delete category: Category with id: " + categoryId + " not found in Topic: " + topicId);
|
||||
}
|
||||
|
||||
} else {
|
||||
// EXCEPTION - Category not found
|
||||
throw new EntityNotFoundException("Delete category: Category with id: "+categoryId+" not found");
|
||||
throw new EntityNotFoundException("Delete category: Category with id: " + categoryId + " not found");
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
|
||||
throw new PathNotValidException("Delete category: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId);
|
||||
throw new PathNotValidException("Delete category: Topic with id: " + topicId + " not found in Stakeholder: " + stakeholderId);
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Topic not found
|
||||
throw new EntityNotFoundException("Delete category: Topic with id: "+topicId+" not found");
|
||||
throw new EntityNotFoundException("Delete category: Topic with id: " + topicId + " not found");
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Stakeholder not found
|
||||
throw new EntityNotFoundException("Delete category: Stakeholder with id: "+stakeholderId+" not found");
|
||||
throw new EntityNotFoundException("Delete category: Stakeholder with id: " + stakeholderId + " not found");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean onDeleteDefaultCategory(String defaultCategoryId, String defaultTopicId, String children) {
|
||||
if(children.equals("delete")) {
|
||||
if (children.equals("delete")) {
|
||||
List<Topic> topics = topicDAO.findByDefaultId(defaultTopicId);
|
||||
List<Category> categories = categoryDAO.findByDefaultId(defaultCategoryId);
|
||||
|
||||
for(Topic topic : topics) {
|
||||
for (Topic topic : topics) {
|
||||
Iterator<Category> categoriesIterator = categories.iterator();
|
||||
while(categoriesIterator.hasNext()) {
|
||||
while (categoriesIterator.hasNext()) {
|
||||
Category category = categoriesIterator.next();
|
||||
|
||||
String categoryId = category.getId();
|
||||
|
||||
if(topic.getCategories() != null && topic.getCategories().contains(categoryId)) {
|
||||
if (topic.getCategories() != null && topic.getCategories().contains(categoryId)) {
|
||||
categoriesIterator.remove();
|
||||
|
||||
topic.getCategories().remove(categoryId);
|
||||
|
@ -311,21 +307,21 @@ public class CategoryController {
|
|||
subCategoryController.deleteTree(category);
|
||||
|
||||
categoryDAO.delete(categoryId);
|
||||
log.debug("Category with id: "+categoryId+" deleted!");
|
||||
log.debug("Category with id: " + categoryId + " deleted!");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(children.equals("disconnect")) {
|
||||
} else if (children.equals("disconnect")) {
|
||||
List<Category> categories = categoryDAO.findByDefaultId(defaultCategoryId);
|
||||
for(Category category : categories) {
|
||||
for (Category category : categories) {
|
||||
subCategoryController.disConnectTree(category);
|
||||
|
||||
category.setDefaultId(null);
|
||||
categoryDAO.save(category);
|
||||
|
||||
log.debug("DefaultId for Category with id: "+category.getId()+" empty!");
|
||||
log.debug("DefaultId for Category with id: " + category.getId() + " empty!");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -337,7 +333,7 @@ public class CategoryController {
|
|||
@PathVariable("topicId") String topicId,
|
||||
@RequestBody List<String> categories) {
|
||||
log.debug("reorder categories");
|
||||
log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId);
|
||||
log.debug("Stakeholder: " + stakeholderId + " - Topic: " + topicId);
|
||||
|
||||
Topic<String> topic = checkForExceptions(stakeholderId, topicId);
|
||||
|
||||
|
@ -350,9 +346,9 @@ public class CategoryController {
|
|||
topic.setCategories(categories);
|
||||
|
||||
List<Category> categoriesFull = new ArrayList<>();
|
||||
for(String categoryId : categories) {
|
||||
for (String categoryId : categories) {
|
||||
Category category = categoryDAO.findById(categoryId);
|
||||
if(category == null) {
|
||||
if (category == null) {
|
||||
// EXCEPTION - Category not found
|
||||
throw new EntityNotFoundException("Reorder Categories: Category with id: " + categoryId + " not found");
|
||||
}
|
||||
|
@ -371,15 +367,15 @@ public class CategoryController {
|
|||
@PathVariable("topicId") String topicId,
|
||||
@PathVariable("categoryId") String categoryId,
|
||||
@RequestParam("visibility") Visibility visibility, @RequestParam(required = false) Boolean propagate) {
|
||||
log.debug("change category visibility: "+visibility + " - toggle propagate: "+((propagate != null && propagate) ? "true" : "false"));
|
||||
log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId);
|
||||
log.debug("change category visibility: " + visibility + " - toggle propagate: " + ((propagate != null && propagate) ? "true" : "false"));
|
||||
log.debug("Stakeholder: " + stakeholderId + " - Topic: " + topicId + " - Category: " + categoryId);
|
||||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
|
||||
if (stakeholder != null) {
|
||||
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
if (!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("Toggle category: You are not authorized to update stakeholder with id: "+stakeholderId);
|
||||
throw new ForbiddenException("Toggle category: You are not authorized to update stakeholder with id: " + stakeholderId);
|
||||
}
|
||||
|
||||
Topic<String> topic = topicDAO.findById(topicId);
|
||||
|
@ -389,19 +385,19 @@ public class CategoryController {
|
|||
return changeVisibilityTree(categoryId, visibility, propagate);
|
||||
} else {
|
||||
// EXCEPTION - Category not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias();
|
||||
throw new PathNotValidException("Toggle category: Category with id: "+categoryId+" not found in Topic: "+topicId);
|
||||
throw new PathNotValidException("Toggle category: Category with id: " + categoryId + " not found in Topic: " + topicId);
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
|
||||
throw new PathNotValidException("Toggle category: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId);
|
||||
throw new PathNotValidException("Toggle category: Topic with id: " + topicId + " not found in Stakeholder: " + stakeholderId);
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Topic not found
|
||||
throw new EntityNotFoundException("Toggle category: Topic with id: "+topicId+" not found");
|
||||
throw new EntityNotFoundException("Toggle category: Topic with id: " + topicId + " not found");
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Stakeholder not found
|
||||
throw new EntityNotFoundException("Toggle category: Stakeholder with id: "+stakeholderId+" not found");
|
||||
throw new EntityNotFoundException("Toggle category: Stakeholder with id: " + stakeholderId + " not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,13 +405,13 @@ public class CategoryController {
|
|||
Category<String> category = categoryDAO.findById(categoryId);
|
||||
if (category == null) {
|
||||
// EXCEPTION - Category not found
|
||||
throw new EntityNotFoundException("Change category visibility: Category with id: "+categoryId+" not found");
|
||||
throw new EntityNotFoundException("Change category visibility: Category with id: " + categoryId + " not found");
|
||||
}
|
||||
|
||||
Category<SubCategory> categoryFull = new Category(category);
|
||||
List<SubCategory> subCategoriesFull = new ArrayList<>();
|
||||
|
||||
if(propagate != null && propagate) {
|
||||
if (propagate != null && propagate) {
|
||||
for (String subCategoryId : category.getSubCategories()) {
|
||||
subCategoriesFull.add(subCategoryController.changeVisibilityTree(subCategoryId, visibility, propagate));
|
||||
}
|
||||
|
@ -436,24 +432,24 @@ public class CategoryController {
|
|||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
|
||||
if(stakeholder == null) {
|
||||
if (stakeholder == null) {
|
||||
// EXCEPTION - Stakeholder not found
|
||||
throw new EntityNotFoundException("checkForExceptions category: Stakeholder with id: " + stakeholderId + " not found");
|
||||
}
|
||||
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
if (!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("checkForExceptions category: You are not authorized to update stakeholder with id: "+stakeholderId);
|
||||
throw new ForbiddenException("checkForExceptions category: You are not authorized to update stakeholder with id: " + stakeholderId);
|
||||
}
|
||||
|
||||
Topic<String> topic = topicDAO.findById(topicId);
|
||||
if(topic == null) {
|
||||
if (topic == null) {
|
||||
// EXCEPTION - Topic not found
|
||||
throw new EntityNotFoundException("checkForExceptions category: Topic with id: "+topicId+" not found");
|
||||
throw new EntityNotFoundException("checkForExceptions category: Topic with id: " + topicId + " not found");
|
||||
}
|
||||
|
||||
if(!stakeholder.getTopics().contains(topicId)) {
|
||||
if (!stakeholder.getTopics().contains(topicId)) {
|
||||
// EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
|
||||
throw new PathNotValidException("checkForExceptions category: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId);
|
||||
throw new PathNotValidException("checkForExceptions category: Topic with id: " + topicId + " not found in Stakeholder: " + stakeholderId);
|
||||
}
|
||||
|
||||
return topic;
|
||||
|
@ -461,11 +457,11 @@ public class CategoryController {
|
|||
|
||||
public void deleteTree(Topic topic) {
|
||||
List<String> categories = topic.getCategories();
|
||||
for(String categoryId : categories) {
|
||||
for (String categoryId : categories) {
|
||||
Category category = categoryDAO.findById(categoryId);
|
||||
if (category == null) {
|
||||
// EXCEPTION - Category not found
|
||||
throw new EntityNotFoundException("Category delete tree: Category with id: "+categoryId+" not found (category exists in topic: "+topic.getId()+")");
|
||||
throw new EntityNotFoundException("Category delete tree: Category with id: " + categoryId + " not found (category exists in topic: " + topic.getId() + ")");
|
||||
}
|
||||
|
||||
subCategoryController.deleteTree(category);
|
||||
|
@ -476,11 +472,11 @@ public class CategoryController {
|
|||
|
||||
public void disConnectTree(Topic topic) {
|
||||
List<String> categories = topic.getCategories();
|
||||
for(String categoryId : categories) {
|
||||
for (String categoryId : categories) {
|
||||
Category category = categoryDAO.findById(categoryId);
|
||||
if (category == null) {
|
||||
// EXCEPTION - Category not found
|
||||
throw new EntityNotFoundException("Category disconnect tree: Category with id: "+categoryId+" not found (category exists in topic: "+topic.getId()+")");
|
||||
throw new EntityNotFoundException("Category disconnect tree: Category with id: " + categoryId + " not found (category exists in topic: " + topic.getId() + ")");
|
||||
}
|
||||
|
||||
subCategoryController.disConnectTree(category);
|
||||
|
|
|
@ -10,7 +10,10 @@ import org.apache.logging.log4j.Logger;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
|
@ -40,17 +43,17 @@ public class EmailController {
|
|||
String failureString = "failure";
|
||||
Map<String, ArrayList<String>> mailResults = new HashMap<>();
|
||||
boolean bcc = optional.orElse(true);
|
||||
for(String userMail:email.getRecipients()){
|
||||
for (String userMail : email.getRecipients()) {
|
||||
ArrayList<String> sendTo = new ArrayList<>();
|
||||
sendTo.add(userMail);
|
||||
boolean success =emailSender.send(sendTo,email.getSubject(),email.getBody(), bcc);
|
||||
if(success){
|
||||
if(!mailResults.containsKey(successString)) {
|
||||
boolean success = emailSender.send(sendTo, email.getSubject(), email.getBody(), bcc);
|
||||
if (success) {
|
||||
if (!mailResults.containsKey(successString)) {
|
||||
mailResults.put(successString, new ArrayList<>());
|
||||
}
|
||||
mailResults.get(successString).add(userMail);
|
||||
} else {
|
||||
if(!mailResults.containsKey(failureString)) {
|
||||
if (!mailResults.containsKey(failureString)) {
|
||||
mailResults.put(failureString, new ArrayList<>());
|
||||
}
|
||||
mailResults.get(failureString).add(userMail);
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
|
||||
import eu.dnetlib.uoamonitorservice.dao.*;
|
||||
import eu.dnetlib.uoamonitorservice.entities.*;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
|
||||
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
|
||||
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
|
||||
import eu.dnetlib.uoamonitorservice.primitives.IndicatorPath;
|
||||
import eu.dnetlib.uoamonitorservice.primitives.ReorderEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -56,22 +58,20 @@ public class IndicatorController {
|
|||
@PathVariable("subcategoryId") String subcategoryId,
|
||||
@RequestBody List<Section<Indicator>> sections) throws UnsupportedEncodingException {
|
||||
log.debug("save bulk indicators");
|
||||
log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId);
|
||||
log.debug("Stakeholder: " + stakeholderId + " - Topic: " + topicId + " - Category: " + categoryId + " - SubCategory: " + subcategoryId);
|
||||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
createSectionsAndSaveBulk(date, sections, stakeholder, topicId, categoryId, subcategoryId);
|
||||
// createSectionAndSaveBulk(date, "number", "Numbers imported from file", number_indicators, stakeholder, topicId, categoryId, subcategoryId);
|
||||
|
||||
return stakeholderController.setFullEntities(stakeholder);
|
||||
}
|
||||
|
||||
private void createSectionsAndSaveBulk(Date date, List<Section<Indicator>> old_sections,
|
||||
Stakeholder stakeholder, String topicId, String categoryId, String subcategoryId) throws UnsupportedEncodingException {
|
||||
for(Section<Indicator> section : old_sections) {
|
||||
if(section == null) {
|
||||
for (Section<Indicator> section : old_sections) {
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -81,17 +81,17 @@ public class IndicatorController {
|
|||
List<String> chart_indicators = null;
|
||||
List<String> number_indicators = null;
|
||||
|
||||
if(section.getType().equals("chart")) {
|
||||
if (section.getType().equals("chart")) {
|
||||
chart_section = createSection(chart_section, "chart", section.getTitle(), date, stakeholder, topicId, categoryId, subcategoryId);
|
||||
chart_indicators = chart_section.getIndicators();
|
||||
} else if(section.getType().equals("number")) {
|
||||
} else if (section.getType().equals("number")) {
|
||||
number_section = createSection(number_section, "number", section.getTitle(), date, stakeholder, topicId, categoryId, subcategoryId);
|
||||
number_indicators = number_section.getIndicators();
|
||||
}
|
||||
|
||||
List<Indicator> indicators = section.getIndicators();
|
||||
for (Indicator indicator : indicators) {
|
||||
if(indicator == null) {
|
||||
if (indicator == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -126,10 +126,6 @@ public class IndicatorController {
|
|||
return section;
|
||||
}
|
||||
|
||||
// private void saveIndicatorAndAddInSection(Indicator indicator, Date date, Stakeholder stakeholder, Section section, List<String> indicators) throws UnsupportedEncodingException {
|
||||
// saveIndicatorAndAddInSection(indicator, date, stakeholder, section, indicators);
|
||||
// }
|
||||
|
||||
private void saveIndicatorAndAddInSection(Indicator indicator, Date date, Stakeholder stakeholder, String subcategoryId, Section section, List<String> indicators) throws UnsupportedEncodingException {
|
||||
// indicator does not exist in DB
|
||||
indicator.setCreationDate(date);
|
||||
|
@ -155,7 +151,7 @@ public class IndicatorController {
|
|||
@PathVariable("sectionId") String sectionId,
|
||||
@RequestBody Indicator indicator) throws UnsupportedEncodingException {
|
||||
log.debug("save indicator");
|
||||
log.debug("Name: "+indicator.getName() + " - Id: "+indicator.getId() + " - Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId + " - Section: "+sectionId);
|
||||
log.debug("Name: " + indicator.getName() + " - Id: " + indicator.getId() + " - Stakeholder: " + stakeholderId + " - Topic: " + topicId + " - Category: " + categoryId + " - SubCategory: " + subcategoryId + " - Section: " + sectionId);
|
||||
|
||||
Section<String> section = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId, sectionId, indicator.getType());
|
||||
|
||||
|
@ -163,9 +159,9 @@ public class IndicatorController {
|
|||
indicator.setUpdateDate(date);
|
||||
|
||||
Indicator oldIndicator = null;
|
||||
if(indicator.getId() != null) {
|
||||
if (indicator.getId() != null) {
|
||||
oldIndicator = indicatorDAO.findById(indicator.getId());
|
||||
if(oldIndicator == null) {
|
||||
if (oldIndicator == null) {
|
||||
// EXCEPTION - Indicator not found
|
||||
throw new EntityNotFoundException("save indicator: Indicator with id: " + indicator.getId() + " not found");
|
||||
}
|
||||
|
@ -177,12 +173,11 @@ public class IndicatorController {
|
|||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
// this indicator belongs in default profile and it is new or it is updated
|
||||
if(stakeholder.getDefaultId() == null) {
|
||||
if(indicatorId == null) {
|
||||
if (stakeholder.getDefaultId() == null) {
|
||||
if (indicatorId == null) {
|
||||
indicatorDAO.save(indicator);
|
||||
onSaveDefaultIndicator(indicator, section, subcategoryId);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
onUpdateDefaultIndicator(indicator, stakeholder, oldIndicator);
|
||||
indicatorDAO.save(indicator);
|
||||
}
|
||||
|
@ -210,7 +205,7 @@ public class IndicatorController {
|
|||
for (SubCategory subCategory : subCategories) {
|
||||
|
||||
List<String> sections = null;
|
||||
if(defaultSection.getType().equals("chart")) {
|
||||
if (defaultSection.getType().equals("chart")) {
|
||||
sections = subCategory.getCharts();
|
||||
} else {
|
||||
sections = subCategory.getNumbers();
|
||||
|
@ -218,7 +213,7 @@ public class IndicatorController {
|
|||
|
||||
for (String sectionId : sections) {
|
||||
Section section = sectionDAO.findById(sectionId);
|
||||
if(section.getDefaultId() != null && section.getDefaultId().equals(defaultSection.getId())) {
|
||||
if (section.getDefaultId() != null && section.getDefaultId().equals(defaultSection.getId())) {
|
||||
Indicator indicatorNew = new Indicator();
|
||||
indicatorNew.copyFromDefault(indicator, subCategory.getVisibility());
|
||||
indicatorDAO.save(indicatorNew);
|
||||
|
@ -238,12 +233,9 @@ public class IndicatorController {
|
|||
boolean changed;
|
||||
List<Indicator> indicators = indicatorDAO.findByDefaultId(indicator.getId());
|
||||
|
||||
for(Indicator indicatorBasedOnDefault : indicators) {
|
||||
for (Indicator indicatorBasedOnDefault : indicators) {
|
||||
changed = false;
|
||||
|
||||
// if(indicator.getName() != null && !indicator.getName().equals(indicatorBasedOnDefault.getName())
|
||||
// && (oldIndicator.getName() == null || oldIndicator.getName().equals(indicatorBasedOnDefault.getName()))) {
|
||||
if((
|
||||
if ((
|
||||
(indicator.getName() == null && oldIndicator.getName() != null)
|
||||
||
|
||||
(indicator.getName() != null && !indicator.getName().equals(indicatorBasedOnDefault.getName()))
|
||||
|
@ -256,16 +248,13 @@ public class IndicatorController {
|
|||
changed = true;
|
||||
}
|
||||
|
||||
if(indicator.getDescription() != null && !indicator.getDescription().equals(indicatorBasedOnDefault.getDescription())
|
||||
if (indicator.getDescription() != null && !indicator.getDescription().equals(indicatorBasedOnDefault.getDescription())
|
||||
|| indicator.getDescription() == null && indicatorBasedOnDefault.getDescription() != null) {
|
||||
|
||||
indicatorBasedOnDefault.setDescription(indicator.getDescription());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// if(indicator.getAdditionalDescription() != null && !indicator.getAdditionalDescription().equals(indicatorBasedOnDefault.getAdditionalDescription())
|
||||
// && (oldIndicator.getAdditionalDescription() == null || oldIndicator.getAdditionalDescription().equals(indicatorBasedOnDefault.getAdditionalDescription()))) {
|
||||
if((
|
||||
if ((
|
||||
(indicator.getAdditionalDescription() == null && oldIndicator.getAdditionalDescription() != null)
|
||||
||
|
||||
(indicator.getAdditionalDescription() != null && !indicator.getAdditionalDescription().equals(indicatorBasedOnDefault.getAdditionalDescription()))
|
||||
|
@ -280,17 +269,17 @@ public class IndicatorController {
|
|||
|
||||
int i = 0;
|
||||
List<IndicatorPath> indicatorPaths = indicatorBasedOnDefault.getIndicatorPaths();
|
||||
if(indicatorPaths == null && indicator.getIndicatorPaths() != null) {
|
||||
if (indicatorPaths == null && indicator.getIndicatorPaths() != null) {
|
||||
indicatorPaths = new ArrayList<>();
|
||||
}
|
||||
|
||||
for (IndicatorPath indicatorPath : indicator.getIndicatorPaths()) {
|
||||
IndicatorPath indicatorPathBasedOnDefault = null;
|
||||
if(i < indicatorPaths.size()) {
|
||||
if (i < indicatorPaths.size()) {
|
||||
indicatorPathBasedOnDefault = indicatorPaths.get(i);
|
||||
}
|
||||
|
||||
if(indicatorPathBasedOnDefault == null) {
|
||||
if (indicatorPathBasedOnDefault == null) {
|
||||
// Add new indicator path in existing indicators
|
||||
IndicatorPath indicatorPathNew = new IndicatorPath(indicatorPath);
|
||||
indicatorPaths.add(indicatorPathNew);
|
||||
|
@ -299,12 +288,8 @@ public class IndicatorController {
|
|||
IndicatorPath oldIndicatorPath = oldIndicator.getIndicatorPaths().get(i);
|
||||
|
||||
// Check if there are changes in indicator path and update existing indicators if needed
|
||||
log.debug("update indicator path: "+i + " (indicator id: "+indicatorBasedOnDefault.getId()+")");
|
||||
|
||||
// if(indicatorPath.getType() != null
|
||||
// && !indicatorPath.getType().equals(indicatorPathBasedOnDefault.getType())
|
||||
// && (oldIndicatorPath.getType().equals(indicatorPathBasedOnDefault.getType()))) {
|
||||
if((
|
||||
log.debug("update indicator path: " + i + " (indicator id: " + indicatorBasedOnDefault.getId() + ")");
|
||||
if ((
|
||||
(indicatorPath.getType() == null && oldIndicatorPath.getType() != null)
|
||||
||
|
||||
(indicatorPath.getType() != null && !indicatorPath.getType().equals(indicatorPathBasedOnDefault.getType()))
|
||||
|
@ -316,9 +301,9 @@ public class IndicatorController {
|
|||
indicatorPathBasedOnDefault.setType(indicatorPath.getType());
|
||||
changed = true; // parameter "type" needs to be changed as well
|
||||
}
|
||||
log.debug("After type check: "+changed);
|
||||
log.debug("After type check: " + changed);
|
||||
|
||||
if((
|
||||
if ((
|
||||
(indicatorPath.getFormat() == null && oldIndicatorPath.getFormat() != null)
|
||||
||
|
||||
(indicatorPath.getFormat() != null && !indicatorPath.getFormat().equals(indicatorPathBasedOnDefault.getFormat()))
|
||||
|
@ -330,12 +315,8 @@ public class IndicatorController {
|
|||
indicatorPathBasedOnDefault.setFormat(indicatorPath.getFormat());
|
||||
changed = true;
|
||||
}
|
||||
log.debug("After type check: "+changed);
|
||||
|
||||
// if(indicatorPath.getSource() != null
|
||||
// && !indicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource())
|
||||
// && (oldIndicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()))) {
|
||||
if((
|
||||
log.debug("After type check: " + changed);
|
||||
if ((
|
||||
(indicatorPath.getSource() == null && oldIndicatorPath.getSource() != null)
|
||||
||
|
||||
(indicatorPath.getSource() != null && !indicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()))
|
||||
|
@ -347,12 +328,8 @@ public class IndicatorController {
|
|||
indicatorPathBasedOnDefault.setSource(indicatorPath.getSource());
|
||||
changed = true;
|
||||
}
|
||||
log.debug("After source check: "+changed);
|
||||
|
||||
// if(indicatorPath.getUrl() != null
|
||||
// && !indicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl())
|
||||
// && (oldIndicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl()))) {
|
||||
if((
|
||||
log.debug("After source check: " + changed);
|
||||
if ((
|
||||
(indicatorPath.getUrl() == null && oldIndicatorPath.getUrl() != null)
|
||||
||
|
||||
(indicatorPath.getUrl() != null && !indicatorPath.getUrl().equals(indicatorPathBasedOnDefault.getUrl()))
|
||||
|
@ -364,9 +341,9 @@ public class IndicatorController {
|
|||
indicatorPathBasedOnDefault.setUrl(indicatorPath.getUrl());
|
||||
changed = true;
|
||||
}
|
||||
log.debug("After url check: "+changed);
|
||||
log.debug("After url check: " + changed);
|
||||
|
||||
if((
|
||||
if ((
|
||||
(indicatorPath.getChartObject() == null && oldIndicatorPath.getChartObject() != null)
|
||||
||
|
||||
(indicatorPath.getChartObject() != null && !indicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject()))
|
||||
|
@ -379,18 +356,16 @@ public class IndicatorController {
|
|||
indicatorPathBasedOnDefault.setChartObject(indicatorPath.getChartObject());
|
||||
changed = true;
|
||||
}
|
||||
log.debug("After chartObject check: "+changed);
|
||||
log.debug("After chartObject check: " + changed);
|
||||
|
||||
if(indicatorPath.getParameters() != null) {
|
||||
if (indicatorPath.getParameters() != null) {
|
||||
if (indicatorPathBasedOnDefault.getParameters() == null) {
|
||||
indicatorPathBasedOnDefault.setParameters(new HashMap<>());
|
||||
}
|
||||
//if (indicatorPath.getParameters().size() != indicatorPathBasedOnDefault.getParameters().size()) {
|
||||
//log.debug("Different number of parameters");
|
||||
for (Map.Entry<String, String> parameter : indicatorPath.getParameters().entrySet()) {
|
||||
log.debug("\nindicatorPath: parameter.getKey(): "+parameter.getKey()+" - value: "+parameter.getValue()
|
||||
+"\nindicatorPathBasedOnDefault:parameters:key: "+ indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())
|
||||
+"\noldIndicatorPath:parameters:key: "+ (oldIndicatorPath.getParameters() == null ? "null" : oldIndicatorPath.getParameters().get(parameter.getKey())));
|
||||
log.debug("\nindicatorPath: parameter.getKey(): " + parameter.getKey() + " - value: " + parameter.getValue()
|
||||
+ "\nindicatorPathBasedOnDefault:parameters:key: " + indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())
|
||||
+ "\noldIndicatorPath:parameters:key: " + (oldIndicatorPath.getParameters() == null ? "null" : oldIndicatorPath.getParameters().get(parameter.getKey())));
|
||||
if (!indicatorPathBasedOnDefault.getParameters().containsKey(parameter.getKey())
|
||||
|| (oldIndicatorPath.getParameters() == null || oldIndicatorPath.getParameters().get(parameter.getKey()) == null
|
||||
|| (oldIndicatorPath.getParameters().get(parameter.getKey()).equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey()))
|
||||
|
@ -402,9 +377,9 @@ public class IndicatorController {
|
|||
}
|
||||
|
||||
// When deleting indicator path parameters in a default profile, delete them also from all children profiles
|
||||
if(oldIndicatorPath.getParameters() != null && indicatorPath.getParameters().size() < oldIndicatorPath.getParameters().size()) {
|
||||
if (oldIndicatorPath.getParameters() != null && indicatorPath.getParameters().size() < oldIndicatorPath.getParameters().size()) {
|
||||
for (Map.Entry<String, String> parameter : oldIndicatorPath.getParameters().entrySet()) {
|
||||
if(!indicatorPath.getParameters().containsKey(parameter.getKey())) {
|
||||
if (!indicatorPath.getParameters().containsKey(parameter.getKey())) {
|
||||
indicatorPathBasedOnDefault.getParameters().remove(parameter.getKey());
|
||||
}
|
||||
}
|
||||
|
@ -412,21 +387,21 @@ public class IndicatorController {
|
|||
}
|
||||
log.debug("After parameters check: " + changed);
|
||||
|
||||
if(indicatorPath.getJsonPath() != null) {
|
||||
if (indicatorPath.getJsonPath() != null) {
|
||||
boolean jsonPathChanged = false;
|
||||
boolean breaked = false;
|
||||
|
||||
int oldJsonPathSize = 0;
|
||||
if(oldIndicatorPath.getJsonPath() != null) {
|
||||
if (oldIndicatorPath.getJsonPath() != null) {
|
||||
oldJsonPathSize = oldIndicatorPath.getJsonPath().size();
|
||||
}
|
||||
int basedOnDefaultJsonPathSize = 0;
|
||||
if(indicatorPathBasedOnDefault.getJsonPath() != null) {
|
||||
if (indicatorPathBasedOnDefault.getJsonPath() != null) {
|
||||
basedOnDefaultJsonPathSize = indicatorPathBasedOnDefault.getJsonPath().size();
|
||||
}
|
||||
log.debug("old: "+oldJsonPathSize+" - based on default: "+basedOnDefaultJsonPathSize+" - new: "+indicatorPath.getJsonPath().size());
|
||||
if(oldJsonPathSize == basedOnDefaultJsonPathSize) {
|
||||
if(indicatorPathBasedOnDefault.getJsonPath() == null && indicatorPath.getJsonPath().size() > 0) {
|
||||
log.debug("old: " + oldJsonPathSize + " - based on default: " + basedOnDefaultJsonPathSize + " - new: " + indicatorPath.getJsonPath().size());
|
||||
if (oldJsonPathSize == basedOnDefaultJsonPathSize) {
|
||||
if (indicatorPathBasedOnDefault.getJsonPath() == null && indicatorPath.getJsonPath().size() > 0) {
|
||||
indicatorPathBasedOnDefault.setJsonPath(new ArrayList<>());
|
||||
}
|
||||
|
||||
|
@ -436,12 +411,12 @@ public class IndicatorController {
|
|||
Iterator<String> jsonStringBasedOnDefaultIterator = indicatorPathBasedOnDefault.getJsonPath().iterator();
|
||||
while (jsonStringBasedOnDefaultIterator.hasNext()) {
|
||||
String jsonStringBasedOnDefault = jsonStringBasedOnDefaultIterator.next();
|
||||
if(oldIndicatorPath.getJsonPath().get(oldIndex).equals(jsonStringBasedOnDefault)) {
|
||||
if(basedOnDefaultIndex >= indicatorPath.getJsonPath().size()) { // string deleted
|
||||
if (oldIndicatorPath.getJsonPath().get(oldIndex).equals(jsonStringBasedOnDefault)) {
|
||||
if (basedOnDefaultIndex >= indicatorPath.getJsonPath().size()) { // string deleted
|
||||
jsonStringBasedOnDefaultIterator.remove();
|
||||
jsonPathChanged = true;
|
||||
} else { // check if string changed
|
||||
if(!indicatorPath.getJsonPath().get(basedOnDefaultIndex).equals(jsonStringBasedOnDefault)) {
|
||||
if (!indicatorPath.getJsonPath().get(basedOnDefaultIndex).equals(jsonStringBasedOnDefault)) {
|
||||
indicatorPathBasedOnDefault.getJsonPath().set(basedOnDefaultIndex, indicatorPath.getJsonPath().get(basedOnDefaultIndex));
|
||||
jsonPathChanged = true;
|
||||
}
|
||||
|
@ -451,20 +426,20 @@ public class IndicatorController {
|
|||
} else {
|
||||
breaked = true;
|
||||
jsonPathChanged = false;
|
||||
log.debug("not the same: "+oldIndex);
|
||||
log.debug("not the same: " + oldIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int index=0;
|
||||
if(!breaked && indicatorPath.getJsonPath().size() > indicatorPathBasedOnDefault.getJsonPath().size()) { // strings added
|
||||
int index = 0;
|
||||
if (!breaked && indicatorPath.getJsonPath().size() > indicatorPathBasedOnDefault.getJsonPath().size()) { // strings added
|
||||
jsonPathChanged = true;
|
||||
for(index=indicatorPathBasedOnDefault.getJsonPath().size(); index < indicatorPath.getJsonPath().size(); index++) {
|
||||
for (index = indicatorPathBasedOnDefault.getJsonPath().size(); index < indicatorPath.getJsonPath().size(); index++) {
|
||||
indicatorPathBasedOnDefault.getJsonPath().add(indicatorPath.getJsonPath().get(index));
|
||||
}
|
||||
}
|
||||
|
||||
if(jsonPathChanged) {
|
||||
if (jsonPathChanged) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +451,7 @@ public class IndicatorController {
|
|||
}
|
||||
// TODO when deleting indicator paths...
|
||||
|
||||
if(!changed) {
|
||||
if (!changed) {
|
||||
// break;
|
||||
continue;
|
||||
}
|
||||
|
@ -496,16 +471,16 @@ public class IndicatorController {
|
|||
@PathVariable("indicatorId") String indicatorId,
|
||||
@RequestParam(required = false) String children) {
|
||||
log.debug("delete indicator");
|
||||
log.debug("Id: "+indicatorId + " - Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId + " - Section: "+sectionId);
|
||||
log.debug("Id: " + indicatorId + " - Stakeholder: " + stakeholderId + " - Topic: " + topicId + " - Category: " + categoryId + " - SubCategory: " + subcategoryId + " - Section: " + sectionId);
|
||||
|
||||
Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
if(indicator != null) {
|
||||
if (indicator != null) {
|
||||
Section<String> section = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId, sectionId, indicator.getType());
|
||||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
if(indicator.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
|
||||
if (indicator.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("Delete indicator: You are not authorized to delete a default Indicator in stakeholder with id: "+stakeholderId);
|
||||
throw new ForbiddenException("Delete indicator: You are not authorized to delete a default Indicator in stakeholder with id: " + stakeholderId);
|
||||
}
|
||||
|
||||
List<String> indicators = section.getIndicators();
|
||||
|
@ -514,7 +489,7 @@ public class IndicatorController {
|
|||
if (index != -1) {
|
||||
|
||||
// this indicator belongs in default profile
|
||||
if(section.getDefaultId() == null && children != null) {
|
||||
if (section.getDefaultId() == null && children != null) {
|
||||
onDeleteDefaultIndicator(indicatorId, sectionId, children);
|
||||
}
|
||||
|
||||
|
@ -526,44 +501,44 @@ public class IndicatorController {
|
|||
log.debug("Indicator deleted!");
|
||||
} else {
|
||||
// EXCEPTION - Indicator not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); -> SubCategory: subcategory.getAlias(); -> Section: section.getTitle();
|
||||
throw new PathNotValidException("Delete indicator: Indicator with id: "+indicatorId+" not found in Sectiom: "+sectionId);
|
||||
throw new PathNotValidException("Delete indicator: Indicator with id: " + indicatorId + " not found in Sectiom: " + sectionId);
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Indicator not found
|
||||
throw new EntityNotFoundException("Delete indicator: Indicator with id: "+indicatorId+" not found");
|
||||
throw new EntityNotFoundException("Delete indicator: Indicator with id: " + indicatorId + " not found");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onDeleteDefaultIndicator(String defaultIndicatorId, String defaultSectionId, String children) {
|
||||
if(children.equals("delete")) {
|
||||
if (children.equals("delete")) {
|
||||
// 2nd way
|
||||
List<Section> sections = sectionDAO.findByDefaultId(defaultSectionId);
|
||||
List<Indicator> indicators = indicatorDAO.findByDefaultId(defaultIndicatorId);
|
||||
|
||||
for(Section section : sections) {
|
||||
for (Section section : sections) {
|
||||
Iterator<Indicator> indicatorsIterator = indicators.iterator();
|
||||
while(indicatorsIterator.hasNext()) {
|
||||
while (indicatorsIterator.hasNext()) {
|
||||
String indicatorId = indicatorsIterator.next().getId();
|
||||
if(section.getIndicators().contains(indicatorId)) {
|
||||
if (section.getIndicators().contains(indicatorId)) {
|
||||
indicatorsIterator.remove();
|
||||
|
||||
section.getIndicators().remove(indicatorId);
|
||||
sectionDAO.save(section);
|
||||
|
||||
indicatorDAO.delete(indicatorId);
|
||||
log.debug("Indicator with id: "+indicatorId+" deleted!");
|
||||
log.debug("Indicator with id: " + indicatorId + " deleted!");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(children.equals("disconnect")) {
|
||||
} else if (children.equals("disconnect")) {
|
||||
List<Indicator> indicators = indicatorDAO.findByDefaultId(defaultIndicatorId);
|
||||
for(Indicator indicator : indicators) {
|
||||
for (Indicator indicator : indicators) {
|
||||
indicator.setDefaultId(null);
|
||||
indicatorDAO.save(indicator);
|
||||
log.debug("DefaultId for Indicator with id: "+indicator.getId()+" empty!");
|
||||
log.debug("DefaultId for Indicator with id: " + indicator.getId() + " empty!");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -578,8 +553,8 @@ public class IndicatorController {
|
|||
@PathVariable("sectionId") String sectionId,
|
||||
@PathVariable("type") String type,
|
||||
@RequestBody ReorderEvent reorderEvent) {
|
||||
log.debug("reorder indicators of type: "+type);
|
||||
log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId + " - Section: "+sectionId);
|
||||
log.debug("reorder indicators of type: " + type);
|
||||
log.debug("Stakeholder: " + stakeholderId + " - Topic: " + topicId + " - Category: " + categoryId + " - SubCategory: " + subcategoryId + " - Section: " + sectionId);
|
||||
|
||||
List<String> indicators = reorderEvent.getIds();
|
||||
String actionType = reorderEvent.getAction();
|
||||
|
@ -596,9 +571,9 @@ public class IndicatorController {
|
|||
section.setIndicators(indicators);
|
||||
|
||||
List<Indicator> indicatorsFull = new ArrayList<>();
|
||||
for(String indicatorId : indicators) {
|
||||
for (String indicatorId : indicators) {
|
||||
Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
if(indicator == null) {
|
||||
if (indicator == null) {
|
||||
// EXCEPTION - Indicator not found
|
||||
throw new EntityNotFoundException("Reorder indicators: Indicator with id: " + indicatorId + " not found");
|
||||
}
|
||||
|
@ -620,8 +595,8 @@ public class IndicatorController {
|
|||
@PathVariable("sectionId") String sectionId,
|
||||
@PathVariable("indicatorId") String indicatorId,
|
||||
@RequestParam("visibility") Visibility visibility) {
|
||||
log.debug("change indicator visibility: "+visibility);
|
||||
log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId + " - Section: "+sectionId+ " - Indicator: "+indicatorId);
|
||||
log.debug("change indicator visibility: " + visibility);
|
||||
log.debug("Stakeholder: " + stakeholderId + " - Topic: " + topicId + " - Category: " + categoryId + " - SubCategory: " + subcategoryId + " - Section: " + sectionId + " - Indicator: " + indicatorId);
|
||||
|
||||
Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
if (indicator == null) {
|
||||
|
@ -632,16 +607,16 @@ public class IndicatorController {
|
|||
Section<String> section = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId, sectionId, indicator.getType());
|
||||
List<String> indicators = section.getIndicators();
|
||||
|
||||
if(indicators.contains(indicatorId)) {
|
||||
if (indicators.contains(indicatorId)) {
|
||||
return changeVisibilityTree(indicatorId, indicator, visibility);
|
||||
} else {
|
||||
// EXCEPTION - Indicator not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); -> SubCategory: subCategory.getAlias(); -> Section: section.getTitle();
|
||||
throw new PathNotValidException("Toggle indicators: Indicator with id: "+indicatorId+" not found in Section: "+sectionId);
|
||||
throw new PathNotValidException("Toggle indicators: Indicator with id: " + indicatorId + " not found in Section: " + sectionId);
|
||||
}
|
||||
}
|
||||
|
||||
public Indicator changeVisibilityTree(String indicatorId, Indicator indicator, Visibility visibility) {
|
||||
if(indicator == null) {
|
||||
if (indicator == null) {
|
||||
indicator = indicatorDAO.findById(indicatorId);
|
||||
if (indicator == null) {
|
||||
// EXCEPTION - Indicator not found
|
||||
|
@ -660,60 +635,60 @@ public class IndicatorController {
|
|||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
|
||||
if(stakeholder == null) {
|
||||
if (stakeholder == null) {
|
||||
// EXCEPTION - Stakeholder not found
|
||||
throw new EntityNotFoundException("Save indicator: Stakeholder with id: " + stakeholderId + " not found");
|
||||
}
|
||||
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
if (!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("CheckForExceptions Indicator: You are not authorized to update stakeholder with id: "+stakeholderId);
|
||||
throw new ForbiddenException("CheckForExceptions Indicator: You are not authorized to update stakeholder with id: " + stakeholderId);
|
||||
}
|
||||
|
||||
Topic<String> topic = topicDAO.findById(topicId);
|
||||
if(topic == null) {
|
||||
if (topic == null) {
|
||||
// EXCEPTION - Topic not found
|
||||
throw new EntityNotFoundException("Save indicator: Topic with id: "+topicId+" not found");
|
||||
throw new EntityNotFoundException("Save indicator: Topic with id: " + topicId + " not found");
|
||||
}
|
||||
|
||||
if(!stakeholder.getTopics().contains(topicId)) {
|
||||
if (!stakeholder.getTopics().contains(topicId)) {
|
||||
// EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
|
||||
throw new PathNotValidException("Save indicator: Topic with id: " + topicId + " not found in Stakeholder: " + stakeholderId);
|
||||
}
|
||||
|
||||
Category<String> category = categoryDAO.findById(categoryId);
|
||||
if(category == null) {
|
||||
if (category == null) {
|
||||
// EXCEPTION - Category not found
|
||||
throw new EntityNotFoundException("Save indicator: Category with id: "+categoryId+" not found");
|
||||
throw new EntityNotFoundException("Save indicator: Category with id: " + categoryId + " not found");
|
||||
}
|
||||
|
||||
if(!topic.getCategories().contains(categoryId)) {
|
||||
if (!topic.getCategories().contains(categoryId)) {
|
||||
// EXCEPTION - Category not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias();
|
||||
throw new PathNotValidException("Save indicator: Category with id: "+categoryId+" not found in Topic: "+topicId);
|
||||
throw new PathNotValidException("Save indicator: Category with id: " + categoryId + " not found in Topic: " + topicId);
|
||||
}
|
||||
|
||||
SubCategory<String> subcategory = subCategoryDAO.findById(subcategoryId);
|
||||
if(subcategory == null) {
|
||||
if (subcategory == null) {
|
||||
// EXCEPTION - SubCategory not found
|
||||
throw new EntityNotFoundException("Save indicator: SubCategory with id: "+subcategoryId+" not found");
|
||||
throw new EntityNotFoundException("Save indicator: SubCategory with id: " + subcategoryId + " not found");
|
||||
}
|
||||
|
||||
if (!category.getSubCategories().contains(subcategoryId)) {
|
||||
// EXCEPTION - SubCategory not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias();
|
||||
throw new PathNotValidException("Save indicator: SubCategory with id: "+subcategoryId+" not found in Category: "+categoryId);
|
||||
throw new PathNotValidException("Save indicator: SubCategory with id: " + subcategoryId + " not found in Category: " + categoryId);
|
||||
}
|
||||
|
||||
Section<String> section = sectionDAO.findById(sectionId);
|
||||
if(section == null) {
|
||||
if (section == null) {
|
||||
// EXCEPTION - Section not found
|
||||
throw new EntityNotFoundException("Save indicator: Section with id: "+sectionId+" not found");
|
||||
throw new EntityNotFoundException("Save indicator: Section with id: " + sectionId + " not found");
|
||||
}
|
||||
|
||||
if(indicatorType.equals("chart")) {
|
||||
if (indicatorType.equals("chart")) {
|
||||
if (!subcategory.getCharts().contains(sectionId)) {
|
||||
// EXCEPTION - Section not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); -> SubCategory: subcategory.getAlias();
|
||||
throw new PathNotValidException("Save indicator: SubCategory with id: " + subcategoryId + " not found in Category: " + categoryId);
|
||||
}
|
||||
} else if(indicatorType.equals("number")) {
|
||||
} else if (indicatorType.equals("number")) {
|
||||
if (!subcategory.getNumbers().contains(sectionId)) {
|
||||
// EXCEPTION - Section not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); -> SubCategory: subcategory.getAlias();
|
||||
throw new PathNotValidException("Save indicator: SubCategory with id: " + subcategoryId + " not found in Category: " + categoryId);
|
||||
|
@ -725,14 +700,14 @@ public class IndicatorController {
|
|||
|
||||
public void deleteTree(Section section) {
|
||||
List<String> indicators = section.getIndicators();
|
||||
for(String indicatorId : indicators) {
|
||||
for (String indicatorId : indicators) {
|
||||
indicatorDAO.delete(indicatorId);
|
||||
}
|
||||
}
|
||||
|
||||
public void disConnectTree(Section section) {
|
||||
List<String> indicators = section.getIndicators();
|
||||
for(String indicatorId : indicators) {
|
||||
for (String indicatorId : indicators) {
|
||||
Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
indicator.setDefaultId(null);
|
||||
indicatorDAO.save(indicator);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Category;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CategoryDAO {
|
||||
@Repository
|
||||
public interface CategoryDAO extends MongoRepository<Category, String> {
|
||||
List<Category> findAll();
|
||||
List<Category> findByDefaultId(String DefaultId);
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Indicator;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IndicatorDAO {
|
||||
@Repository
|
||||
public interface IndicatorDAO extends MongoRepository<Indicator, String> {
|
||||
List<Indicator> findAll();
|
||||
List<Indicator> findByDefaultId(String DefaultId);
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Category;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBCategoryDAO extends CategoryDAO, MongoRepository<Category, String> {
|
||||
List<Category> findAll();
|
||||
List<Category> findByDefaultId(String DefaultId);
|
||||
|
||||
Category findBySubCategoriesContaining(String subCategory);
|
||||
|
||||
Category findById(String Id);
|
||||
|
||||
void delete(String Id);
|
||||
|
||||
Category save(Category category);
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Indicator;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBIndicatorDAO extends IndicatorDAO, MongoRepository<Indicator, String> {
|
||||
List<Indicator> findAll();
|
||||
List<Indicator> findByDefaultId(String DefaultId);
|
||||
|
||||
Indicator findById(String Id);
|
||||
|
||||
void delete(String Id);
|
||||
|
||||
Indicator save(Indicator indicator);
|
||||
//List<Indicator> saveAll(List<Indicator> indicators);
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Section;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBSectionDAO extends SectionDAO, MongoRepository<Section, String> {
|
||||
List<Section> findAll();
|
||||
List<Section> findByDefaultId(String DefaultId);
|
||||
|
||||
Section findById(String Id);
|
||||
|
||||
void delete(String Id);
|
||||
|
||||
Section save(Section indicator);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBStakeholderDAO extends StakeholderDAO, MongoRepository<Stakeholder, String> {
|
||||
List<Stakeholder> findAll();
|
||||
List<Stakeholder> findByType(String Type);
|
||||
|
||||
List<Stakeholder> findByDefaultId(String DefaultId);
|
||||
List<Stakeholder> findByDefaultIdAndType(String DefaultId, String Type);
|
||||
|
||||
List<Stakeholder> findByDefaultIdNot(String DefaultId);
|
||||
List<Stakeholder> findByDefaultIdNotAndType(String DefaultId, String Type);
|
||||
|
||||
Stakeholder findByTopicsContaining(String topic);
|
||||
|
||||
Stakeholder findById(String Id);
|
||||
Stakeholder findByAlias(String Alias);
|
||||
|
||||
void delete(String Id);
|
||||
|
||||
Stakeholder save(Stakeholder stakeholder);
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.SubCategory;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBSubCategoryDAO extends SubCategoryDAO, MongoRepository<SubCategory, String> {
|
||||
List<SubCategory> findAll();
|
||||
List<SubCategory> findByDefaultId(String DefaultId);
|
||||
|
||||
SubCategory findById(String Id);
|
||||
|
||||
void delete(String Id);
|
||||
|
||||
SubCategory save(SubCategory subCategory);
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Topic;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MongoDBTopicDAO extends TopicDAO, MongoRepository<Topic, String> {
|
||||
List<Topic> findAll();
|
||||
List<Topic> findByDefaultId(String DefaultId);
|
||||
|
||||
Topic findByCategoriesContaining(String category);
|
||||
|
||||
Topic findById(String Id);
|
||||
|
||||
void delete(String Id);
|
||||
|
||||
Topic save(Topic topic);
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Section;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SectionDAO {
|
||||
@Repository
|
||||
public interface SectionDAO extends MongoRepository<Section, String> {
|
||||
List<Section> findAll();
|
||||
List<Section> findByDefaultId(String DefaultId);
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StakeholderDAO {
|
||||
@Repository
|
||||
public interface StakeholderDAO extends MongoRepository<Stakeholder, String> {
|
||||
List<Stakeholder> findAll();
|
||||
List<Stakeholder> findByType(String Type);
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.SubCategory;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SubCategoryDAO {
|
||||
@Repository
|
||||
public interface SubCategoryDAO extends MongoRepository<SubCategory, String> {
|
||||
List<SubCategory> findAll();
|
||||
List<SubCategory> findByDefaultId(String DefaultId);
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package eu.dnetlib.uoamonitorservice.dao;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.entities.Topic;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TopicDAO {
|
||||
@Repository
|
||||
public interface TopicDAO extends MongoRepository<Topic, String> {
|
||||
List<Topic> findAll();
|
||||
List<Topic> findByDefaultId(String DefaultId);
|
||||
|
||||
|
|
|
@ -1,23 +1,14 @@
|
|||
package eu.dnetlib.uoamonitorservice.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import eu.dnetlib.uoamonitorservice.primitives.IndicatorPath;
|
||||
import eu.dnetlib.uoamonitorservice.primitives.IndicatorSize;
|
||||
import eu.dnetlib.uoamonitorservice.primitives.IndicatorType;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
enum IndicatorType {
|
||||
// Do not rename or remove existring values. This may cause problems with already stored values in DB
|
||||
number, chart,
|
||||
NUMBER, CHART;
|
||||
}
|
||||
|
||||
enum IndicatorSize {
|
||||
// Do not rename or remove existring values. This may cause problems with already stored values in DB
|
||||
small, medium, large,
|
||||
SMALL, MEDIUM, LARGE;
|
||||
}
|
||||
|
||||
public class Indicator {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
package eu.dnetlib.uoamonitorservice.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import eu.dnetlib.uoamonitorservice.primitives.IndicatorType;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
enum SectionType {
|
||||
// Do not rename or remove existring values. This may cause problems with already stored values in DB
|
||||
number, chart,
|
||||
NUMBER, CHART;
|
||||
}
|
||||
|
||||
public class Section<StringOrIndicator> {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
|
@ -21,7 +16,7 @@ public class Section<StringOrIndicator> {
|
|||
private String title;
|
||||
private String defaultId;
|
||||
private String stakeholderAlias;
|
||||
private SectionType type;
|
||||
private IndicatorType type;
|
||||
private Date creationDate;
|
||||
private Date updateDate;
|
||||
private List<StringOrIndicator> indicators;
|
||||
|
@ -90,8 +85,7 @@ public class Section<StringOrIndicator> {
|
|||
if(type == null) {
|
||||
this.type = null;
|
||||
} else {
|
||||
SectionType sectionType = SectionType.valueOf(type);
|
||||
this.type = sectionType;
|
||||
this.type = IndicatorType.valueOf(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,32 +1,14 @@
|
|||
package eu.dnetlib.uoamonitorservice.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import eu.dnetlib.uoamonitorservice.primitives.Locale;
|
||||
import eu.dnetlib.uoamonitorservice.primitives.StakeholderType;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
enum StakeholderType
|
||||
{
|
||||
// Do not rename or remove existing values. This may cause problems with already stored values in DB
|
||||
funder, ri, project, organization,
|
||||
country, researcher, datasource,
|
||||
FUNDER, RI, PROJECT, ORGANIZATION,
|
||||
COUNTRY, RESEARCHER, DATASOURCE;
|
||||
}
|
||||
|
||||
enum Locale {
|
||||
EN("en"), EU("eu");
|
||||
|
||||
public final String label;
|
||||
|
||||
Locale(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Stakeholder<StringOrTopic> {
|
||||
@Id
|
||||
@JsonProperty("_id")
|
||||
|
@ -84,14 +66,6 @@ public class Stakeholder<StringOrTopic> {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
// public StakeholderType getType() {
|
||||
// return type;
|
||||
// }
|
||||
//
|
||||
// public void setType(StakeholderType type) {
|
||||
// this.type = type;
|
||||
// }
|
||||
|
||||
public String getType() {
|
||||
if(type == null) {
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package eu.dnetlib.uoamonitorservice.primitives;
|
||||
|
||||
public enum Format {
|
||||
NUMBER, PERCENTAGE
|
||||
}
|
|
@ -1,22 +1,8 @@
|
|||
package eu.dnetlib.uoamonitorservice.entities;
|
||||
package eu.dnetlib.uoamonitorservice.primitives;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
enum IndicatorPathType {
|
||||
// Do not rename or remove existring values. This may cause problems with already stored values in DB
|
||||
table, bar, column, pie, line, other,
|
||||
TABLE, BAR, COLUMN, PIE, LINE, OTHER;
|
||||
}
|
||||
|
||||
//enum SourceType {
|
||||
// STATISTICS, SEARCH, METRICS, STATS_TOOL,OLD,IMAGE;
|
||||
//}
|
||||
|
||||
enum Format {
|
||||
NUMBER, PERCENTAGE
|
||||
}
|
||||
|
||||
public class IndicatorPath {
|
||||
private IndicatorPathType type; // for charts is type of chart {table, bar, column, etc}
|
||||
private Format format = Format.NUMBER; // for numbers is if number is percentage or not
|
|
@ -0,0 +1,7 @@
|
|||
package eu.dnetlib.uoamonitorservice.primitives;
|
||||
|
||||
public enum IndicatorPathType {
|
||||
// Do not rename or remove existing values. This may cause problems with already stored values in DB
|
||||
table, bar, column, pie, line, other,
|
||||
TABLE, BAR, COLUMN, PIE, LINE, OTHER;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package eu.dnetlib.uoamonitorservice.primitives;
|
||||
|
||||
public enum IndicatorSize {
|
||||
// Do not rename or remove existring values. This may cause problems with already stored values in DB
|
||||
small, medium, large,
|
||||
SMALL, MEDIUM, LARGE;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package eu.dnetlib.uoamonitorservice.primitives;
|
||||
|
||||
public enum IndicatorType {
|
||||
// Do not rename or remove existing values. This may cause problems with already stored values in DB
|
||||
number, chart,
|
||||
NUMBER, CHART;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package eu.dnetlib.uoamonitorservice.primitives;
|
||||
|
||||
public enum Locale {
|
||||
EN("en"), EU("eu");
|
||||
|
||||
public final String label;
|
||||
|
||||
Locale(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.uoamonitorservice.entities;
|
||||
package eu.dnetlib.uoamonitorservice.primitives;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package eu.dnetlib.uoamonitorservice.primitives;
|
||||
|
||||
public enum StakeholderType {
|
||||
// Do not rename or remove existing values. This may cause problems with already stored values in DB
|
||||
funder, ri, project, organization,
|
||||
country, researcher, datasource,
|
||||
FUNDER, RI, PROJECT, ORGANIZATION,
|
||||
COUNTRY, RESEARCHER, DATASOURCE;
|
||||
}
|
|
@ -25,31 +25,3 @@ monitorservice.globalVars.version=@version@
|
|||
#production
|
||||
#monitorservice.userInfoUrl = https://services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=
|
||||
#monitorservice.originServer = .openaire.eu
|
||||
|
||||
# Monitor
|
||||
monitorservice.mongodb.host=localhost
|
||||
monitorservice.mongodb.port=27017
|
||||
monitorservice.mongodb.database=production
|
||||
|
||||
# Notification
|
||||
notification.mongodb.host = localhost
|
||||
notification.mongodb.port = 27017
|
||||
notification.mongodb.database = openaire_notification
|
||||
|
||||
# Admin Tools Library
|
||||
admintoolslibrary.mail.from = openaire.test@gmail.com
|
||||
admintoolslibrary.mail.username = openaire.test@gmail.com
|
||||
admintoolslibrary.mail.password = koujreltgjduicjp
|
||||
admintoolslibrary.mail.host = smtp.gmail.com
|
||||
admintoolslibrary.mail.port = 587
|
||||
admintoolslibrary.mail.auth = true
|
||||
admintoolslibrary.mail.sslProtocols = TLSv1.2
|
||||
admintoolslibrary.mail.defaultEncoding=UTF-8
|
||||
admintoolslibrary.mail.protocol=smtp
|
||||
admintoolslibrary.mail.testConnection=false
|
||||
admintoolslibrary.google.secret = 6LcVtFIUAAAAAIlEaz6Am2PBC3j5lHG7vBo6uW4_
|
||||
|
||||
# Authorization
|
||||
authorization.security.userInfoUrl = http://mpagasas.di.uoa.gr:19080/login-service/userInfo
|
||||
|
||||
server.port=8888
|
Loading…
Reference in New Issue