diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/controllers/CategoryController.java b/src/main/java/eu/dnetlib/uoamonitorservice/controllers/CategoryController.java index e3f6634..ea5110e 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/controllers/CategoryController.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/controllers/CategoryController.java @@ -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 subCategories = new ArrayList<>(); List subCategoriesFull = new ArrayList<>(); - for(SubCategory> subCategory : categoryFull.getSubCategories()) { + for (SubCategory> subCategory : categoryFull.getSubCategories()) { SubCategory> subcategoryFull = subCategoryController.buildSubCategory(subCategory); subCategoriesFull.add(subcategoryFull); subCategories.add(subcategoryFull.getId()); @@ -72,28 +75,28 @@ public class CategoryController { @PathVariable("topicId") String topicId, @RequestBody Category 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 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 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 topic = topicDAO.findById(topicId); - if(topic != null) { - if(stakeholder.getTopics().contains(topicId)) { + if (topic != null) { + if (stakeholder.getTopics().contains(topicId)) { Category category = new Category<>(categoryFull); Date date = new Date(); @@ -103,7 +106,7 @@ public class CategoryController { List 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 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 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 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 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 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 topic = topicDAO.findById(topicId); - if(topic != null) { - if(stakeholder.getTopics().contains(topicId)) { + if (topic != null) { + if (stakeholder.getTopics().contains(topicId)) { Category 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 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 topics = topicDAO.findByDefaultId(defaultTopicId); List categories = categoryDAO.findByDefaultId(defaultCategoryId); - for(Topic topic : topics) { + for (Topic topic : topics) { Iterator 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 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; @@ -334,10 +330,10 @@ public class CategoryController { @PreAuthorize("isAuthenticated()") @RequestMapping(value = "/{stakeholderId}/{topicId}/reorder", method = RequestMethod.POST) public List reorderCategories(@PathVariable("stakeholderId") String stakeholderId, - @PathVariable("topicId") String topicId, - @RequestBody List categories) { + @PathVariable("topicId") String topicId, + @RequestBody List categories) { log.debug("reorder categories"); - log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId); + log.debug("Stakeholder: " + stakeholderId + " - Topic: " + topicId); Topic topic = checkForExceptions(stakeholderId, topicId); @@ -350,9 +346,9 @@ public class CategoryController { topic.setCategories(categories); List 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"); } @@ -368,18 +364,18 @@ public class CategoryController { @PreAuthorize("isAuthenticated()") @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/change-visibility", method = RequestMethod.POST) public Category changeCategoryVisibility(@PathVariable("stakeholderId") String stakeholderId, - @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); + @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); Stakeholder 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 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 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 categoryFull = new Category(category); List subCategoriesFull = new ArrayList<>(); - if(propagate != null && propagate) { + if (propagate != null && propagate) { for (String subCategoryId : category.getSubCategories()) { subCategoriesFull.add(subCategoryController.changeVisibilityTree(subCategoryId, visibility, propagate)); } @@ -436,36 +432,36 @@ public class CategoryController { Stakeholder 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 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; + return topic; } public void deleteTree(Topic topic) { List 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 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); diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/controllers/EmailController.java b/src/main/java/eu/dnetlib/uoamonitorservice/controllers/EmailController.java index d8380ac..960fe75 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/controllers/EmailController.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/controllers/EmailController.java @@ -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 = "*") @@ -27,7 +30,7 @@ public class EmailController { } @RequestMapping(value = "/contact", method = RequestMethod.POST) - public Boolean contact(@RequestBody EmailRecaptcha form) throws InvalidReCaptchaException { + public Boolean contact(@RequestBody EmailRecaptcha form) throws InvalidReCaptchaException { verifyRecaptcha.processResponse(form.getRecaptcha()); Email email = form.getEmail(); return emailSender.send(email.getRecipients(), email.getSubject(), email.getBody(), false); @@ -40,17 +43,17 @@ public class EmailController { String failureString = "failure"; Map> mailResults = new HashMap<>(); boolean bcc = optional.orElse(true); - for(String userMail:email.getRecipients()){ + for (String userMail : email.getRecipients()) { ArrayList 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); diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/controllers/IndicatorController.java b/src/main/java/eu/dnetlib/uoamonitorservice/controllers/IndicatorController.java index f67c5c2..f8746a5 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/controllers/IndicatorController.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/controllers/IndicatorController.java @@ -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; @@ -51,27 +53,25 @@ public class IndicatorController { @PreAuthorize("isAuthenticated()") @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/save-bulk", method = RequestMethod.POST) public Stakeholder saveBulkIndicators(@PathVariable("stakeholderId") String stakeholderId, - @PathVariable("topicId") String topicId, - @PathVariable("categoryId") String categoryId, - @PathVariable("subcategoryId") String subcategoryId, - @RequestBody List> sections) throws UnsupportedEncodingException { + @PathVariable("topicId") String topicId, + @PathVariable("categoryId") String categoryId, + @PathVariable("subcategoryId") String subcategoryId, + @RequestBody List> 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 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> old_sections, - Stakeholder stakeholder, String topicId, String categoryId, String subcategoryId) throws UnsupportedEncodingException { - for(Section section : old_sections) { - if(section == null) { + Stakeholder stakeholder, String topicId, String categoryId, String subcategoryId) throws UnsupportedEncodingException { + for (Section section : old_sections) { + if (section == null) { continue; } @@ -81,17 +81,17 @@ public class IndicatorController { List chart_indicators = null; List 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 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 indicators) throws UnsupportedEncodingException { -// saveIndicatorAndAddInSection(indicator, date, stakeholder, section, indicators); -// } - private void saveIndicatorAndAddInSection(Indicator indicator, Date date, Stakeholder stakeholder, String subcategoryId, Section section, List 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 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 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 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 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()) - || indicator.getDescription() == null && indicatorBasedOnDefault.getDescription() != null) { + 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 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,37 +341,35 @@ 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())) - ) && ( + || + (indicatorPath.getChartObject() != null && !indicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject())) + ) && ( (oldIndicatorPath.getChartObject() == null && indicatorPathBasedOnDefault.getChartObject() == null) - || - (oldIndicatorPath.getChartObject() != null && oldIndicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject())) + || + (oldIndicatorPath.getChartObject() != null && oldIndicatorPath.getChartObject().equals(indicatorPathBasedOnDefault.getChartObject())) )) { 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 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())) - && !parameter.getValue().equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())))) + || (oldIndicatorPath.getParameters().get(parameter.getKey()).equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())) + && !parameter.getValue().equals(indicatorPathBasedOnDefault.getParameters().get(parameter.getKey())))) ) { indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue()); changed = true; @@ -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 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 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 section = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId, sectionId, indicator.getType()); Stakeholder 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 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
sections = sectionDAO.findByDefaultId(defaultSectionId); List indicators = indicatorDAO.findByDefaultId(defaultIndicatorId); - for(Section section : sections) { + for (Section section : sections) { Iterator 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 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 indicators = reorderEvent.getIds(); String actionType = reorderEvent.getAction(); @@ -596,9 +571,9 @@ public class IndicatorController { section.setIndicators(indicators); List 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"); } @@ -614,14 +589,14 @@ public class IndicatorController { @PreAuthorize("isAuthenticated()") @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{sectionId}/{indicatorId}/change-visibility", method = RequestMethod.POST) public Indicator changeIndicatorVisibility(@PathVariable("stakeholderId") String stakeholderId, - @PathVariable("topicId") String topicId, - @PathVariable("categoryId") String categoryId, - @PathVariable("subcategoryId") String subcategoryId, - @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); + @PathVariable("topicId") String topicId, + @PathVariable("categoryId") String categoryId, + @PathVariable("subcategoryId") String subcategoryId, + @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); Indicator indicator = indicatorDAO.findById(indicatorId); if (indicator == null) { @@ -632,16 +607,16 @@ public class IndicatorController { Section section = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId, sectionId, indicator.getType()); List 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,79 +635,79 @@ public class IndicatorController { Stakeholder 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 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 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 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 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); } } - return section; + return section; } public void deleteTree(Section section) { List indicators = section.getIndicators(); - for(String indicatorId : indicators) { + for (String indicatorId : indicators) { indicatorDAO.delete(indicatorId); } } public void disConnectTree(Section section) { List indicators = section.getIndicators(); - for(String indicatorId : indicators) { + for (String indicatorId : indicators) { Indicator indicator = indicatorDAO.findById(indicatorId); indicator.setDefaultId(null); indicatorDAO.save(indicator); diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/CategoryDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/CategoryDAO.java index fed3a16..b8d4db0 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/CategoryDAO.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/dao/CategoryDAO.java @@ -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 { List findAll(); List findByDefaultId(String DefaultId); diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/IndicatorDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/IndicatorDAO.java index 0ac32bd..8940da8 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/IndicatorDAO.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/dao/IndicatorDAO.java @@ -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 { List findAll(); List findByDefaultId(String DefaultId); diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBCategoryDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBCategoryDAO.java deleted file mode 100644 index fc71604..0000000 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBCategoryDAO.java +++ /dev/null @@ -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 { - List findAll(); - List findByDefaultId(String DefaultId); - - Category findBySubCategoriesContaining(String subCategory); - - Category findById(String Id); - - void delete(String Id); - - Category save(Category category); -} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBIndicatorDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBIndicatorDAO.java deleted file mode 100644 index f35ee01..0000000 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBIndicatorDAO.java +++ /dev/null @@ -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 { - List findAll(); - List findByDefaultId(String DefaultId); - - Indicator findById(String Id); - - void delete(String Id); - - Indicator save(Indicator indicator); - //List saveAll(List indicators); -} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBSectionDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBSectionDAO.java deleted file mode 100644 index 51eeb6c..0000000 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBSectionDAO.java +++ /dev/null @@ -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 { - List
findAll(); - List
findByDefaultId(String DefaultId); - - Section findById(String Id); - - void delete(String Id); - - Section save(Section indicator); -} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBStakeholderDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBStakeholderDAO.java deleted file mode 100644 index 0258a37..0000000 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBStakeholderDAO.java +++ /dev/null @@ -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 { - List findAll(); - List findByType(String Type); - - List findByDefaultId(String DefaultId); - List findByDefaultIdAndType(String DefaultId, String Type); - - List findByDefaultIdNot(String DefaultId); - List 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); -} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBSubCategoryDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBSubCategoryDAO.java deleted file mode 100644 index 375085e..0000000 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBSubCategoryDAO.java +++ /dev/null @@ -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 { - List findAll(); - List findByDefaultId(String DefaultId); - - SubCategory findById(String Id); - - void delete(String Id); - - SubCategory save(SubCategory subCategory); -} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBTopicDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBTopicDAO.java deleted file mode 100644 index 1f7e967..0000000 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/MongoDBTopicDAO.java +++ /dev/null @@ -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 { - List findAll(); - List findByDefaultId(String DefaultId); - - Topic findByCategoriesContaining(String category); - - Topic findById(String Id); - - void delete(String Id); - - Topic save(Topic topic); -} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/SectionDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/SectionDAO.java index 7a75e99..cd24e5a 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/SectionDAO.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/dao/SectionDAO.java @@ -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 { List
findAll(); List
findByDefaultId(String DefaultId); diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/StakeholderDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/StakeholderDAO.java index d5daaad..113c105 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/StakeholderDAO.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/dao/StakeholderDAO.java @@ -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 { List findAll(); List findByType(String Type); diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/SubCategoryDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/SubCategoryDAO.java index 8a9f406..2e22285 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/SubCategoryDAO.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/dao/SubCategoryDAO.java @@ -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 { List findAll(); List findByDefaultId(String DefaultId); diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/dao/TopicDAO.java b/src/main/java/eu/dnetlib/uoamonitorservice/dao/TopicDAO.java index b57f8ce..f6a36fc 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/dao/TopicDAO.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/dao/TopicDAO.java @@ -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 { List findAll(); List findByDefaultId(String DefaultId); diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/entities/Indicator.java b/src/main/java/eu/dnetlib/uoamonitorservice/entities/Indicator.java index ca6947c..a4aa824 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/entities/Indicator.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/entities/Indicator.java @@ -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") diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/entities/Section.java b/src/main/java/eu/dnetlib/uoamonitorservice/entities/Section.java index 1f0f064..c0664af 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/entities/Section.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/entities/Section.java @@ -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 { @Id @JsonProperty("_id") @@ -21,7 +16,7 @@ public class Section { private String title; private String defaultId; private String stakeholderAlias; - private SectionType type; + private IndicatorType type; private Date creationDate; private Date updateDate; private List indicators; @@ -90,8 +85,7 @@ public class Section { if(type == null) { this.type = null; } else { - SectionType sectionType = SectionType.valueOf(type); - this.type = sectionType; + this.type = IndicatorType.valueOf(type); } } diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/entities/Stakeholder.java b/src/main/java/eu/dnetlib/uoamonitorservice/entities/Stakeholder.java index 089e459..4d72840 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/entities/Stakeholder.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/entities/Stakeholder.java @@ -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 { @Id @JsonProperty("_id") @@ -84,14 +66,6 @@ public class Stakeholder { this.id = id; } -// public StakeholderType getType() { -// return type; -// } -// -// public void setType(StakeholderType type) { -// this.type = type; -// } - public String getType() { if(type == null) { return null; diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/primitives/Format.java b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/Format.java new file mode 100644 index 0000000..7e2a0f1 --- /dev/null +++ b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/Format.java @@ -0,0 +1,5 @@ +package eu.dnetlib.uoamonitorservice.primitives; + +public enum Format { + NUMBER, PERCENTAGE +} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/entities/IndicatorPath.java b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorPath.java similarity index 88% rename from src/main/java/eu/dnetlib/uoamonitorservice/entities/IndicatorPath.java rename to src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorPath.java index 63bc04a..60ed5f4 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/entities/IndicatorPath.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorPath.java @@ -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 diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorPathType.java b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorPathType.java new file mode 100644 index 0000000..72ef0ba --- /dev/null +++ b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorPathType.java @@ -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; +} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorSize.java b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorSize.java new file mode 100644 index 0000000..3228307 --- /dev/null +++ b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorSize.java @@ -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; +} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorType.java b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorType.java new file mode 100644 index 0000000..1e5019f --- /dev/null +++ b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/IndicatorType.java @@ -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; +} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/primitives/Locale.java b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/Locale.java new file mode 100644 index 0000000..49adf2b --- /dev/null +++ b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/Locale.java @@ -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; + } +} diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/entities/ReorderEvent.java b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/ReorderEvent.java similarity index 94% rename from src/main/java/eu/dnetlib/uoamonitorservice/entities/ReorderEvent.java rename to src/main/java/eu/dnetlib/uoamonitorservice/primitives/ReorderEvent.java index 9818c8f..caba8e8 100644 --- a/src/main/java/eu/dnetlib/uoamonitorservice/entities/ReorderEvent.java +++ b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/ReorderEvent.java @@ -1,4 +1,4 @@ -package eu.dnetlib.uoamonitorservice.entities; +package eu.dnetlib.uoamonitorservice.primitives; import java.util.List; diff --git a/src/main/java/eu/dnetlib/uoamonitorservice/primitives/StakeholderType.java b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/StakeholderType.java new file mode 100644 index 0000000..8e58b2b --- /dev/null +++ b/src/main/java/eu/dnetlib/uoamonitorservice/primitives/StakeholderType.java @@ -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; +} diff --git a/src/main/resources/monitorservice.properties b/src/main/resources/monitorservice.properties index 82627cb..86a31d4 100644 --- a/src/main/resources/monitorservice.properties +++ b/src/main/resources/monitorservice.properties @@ -24,32 +24,4 @@ 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 \ No newline at end of file +#monitorservice.originServer = .openaire.eu \ No newline at end of file