diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java index c9d99822..c9282302 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java @@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import eu.dnetlib.organizations.model.OpenaireDuplicate; -import eu.dnetlib.organizations.model.Organization; import eu.dnetlib.organizations.model.utils.BrowseEntry; import eu.dnetlib.organizations.model.utils.OrganizationConflict; import eu.dnetlib.organizations.model.view.ConflictGroupView; @@ -44,6 +43,7 @@ import eu.dnetlib.organizations.repository.readonly.OrganizationSimpleViewReposi import eu.dnetlib.organizations.repository.readonly.OrganizationViewRepository; import eu.dnetlib.organizations.repository.readonly.SuggestionInfoViewByCountryRepository; import eu.dnetlib.organizations.utils.DatabaseUtils; +import eu.dnetlib.organizations.utils.OrganizationStatus; @RestController @RequestMapping("/api/organizations") @@ -120,30 +120,6 @@ public class OrganizationController { } } - @GetMapping("/delete") - public OrganizationView deleteById(@RequestParam final String id, final Authentication authentication) { - final Organization org = organizationRepository.findById(id).get(); - - if (UserInfo.isSuperAdmin(authentication) || UserInfo.isNationalAdmin(authentication) && - userCountryRepository.verifyAuthorizationForCountry(org.getCountry(), authentication.getName())) { - return databaseUtils.markAsDeleted(id, authentication.getName()); - } else { - throw new RuntimeException("User not authorized"); - } - } - - @GetMapping("/discard") - public OrganizationView discardById(@RequestParam final String id, final Authentication authentication) { - final Organization org = organizationRepository.findById(id).get(); - - if (UserInfo.isSuperAdmin(authentication) || UserInfo.isNationalAdmin(authentication) && - userCountryRepository.verifyAuthorizationForCountry(org.getCountry(), authentication.getName())) { - return databaseUtils.markAsDiscarded(id, authentication.getName()); - } else { - throw new RuntimeException("User not authorized"); - } - } - @GetMapping("/conflicts") public List conflicts(@RequestParam final String id, final Authentication authentication) { if (UserInfo.isSuperAdmin(authentication) || userCountryRepository.verifyAuthorizationForId(id, authentication.getName())) { @@ -234,12 +210,23 @@ public class OrganizationController { public Page search(@PathVariable final int page, @PathVariable final int size, @RequestParam final String q, - @RequestParam(required = false, defaultValue = "suggested,approved") final String status, + @RequestParam(required = false, defaultValue = "") final String status, final Authentication authentication) { + final List statuses; + + if (StringUtils.isNotBlank(status)) { + statuses = Arrays.asList(status.split(",")); + } else if (UserInfo.isSimpleUser(authentication)) { + statuses = Arrays.asList(OrganizationStatus.approved.toString()); + } else { + statuses = Arrays.asList(OrganizationStatus.approved.toString(), OrganizationStatus.suggested.toString()); + } + return UserInfo.isSuperAdmin(authentication) - ? organizationSimpleViewRepository.search(q, Arrays.asList(status.split(",")), PageRequest.of(page, size)) - : organizationSimpleViewRepository.searchForUser(q, authentication.getName(), Arrays.asList(status.split(",")), PageRequest.of(page, size)); + ? organizationSimpleViewRepository.search(q, statuses, PageRequest.of(page, size)) + : organizationSimpleViewRepository.searchForUser(q, authentication.getName(), statuses, PageRequest.of(page, size)); + } @GetMapping("/byCountry/{status}/{code}/{page}/{size}") diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/DatabaseUtils.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/DatabaseUtils.java index 5c8f8ca4..7a3c4469 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/DatabaseUtils.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/DatabaseUtils.java @@ -320,23 +320,6 @@ public class DatabaseUtils { } } - @Transactional - public OrganizationView markAsDeleted(final String id, final String user) { - final OffsetDateTime now = OffsetDateTime.now(); - updateStatus(id, OrganizationStatus.deleted, user, now); - return organizationViewRepository.findById(id).get(); - } - - @Transactional - public OrganizationView markAsDiscarded(final String id, final String user) { - final OffsetDateTime now = OffsetDateTime.now(); - updateStatus(id, OrganizationStatus.discarded, user, now); - - openaireDuplicateRepository.findByLocalId(id).forEach(d -> updateStatus(d.getOaOriginalId(), OrganizationStatus.suggested, user, now)); - - return organizationViewRepository.findById(id).get(); - } - private void updateStatus(final String id, final OrganizationStatus status, final String user, final OffsetDateTime now) { organizationRepository.updateStatus(id, status.toString()); organizationRepository.updateModificationDate(id, user, now); diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/OrganizationStatus.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/OrganizationStatus.java index 0b135680..6d23133d 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/OrganizationStatus.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/OrganizationStatus.java @@ -3,8 +3,6 @@ package eu.dnetlib.organizations.utils; public enum OrganizationStatus { suggested, // from user or dedup depends by created_by field approved, // normal status of valid organizations - discarded, // suggested organization that have been rejected by an administrator hidden, // hidden organizations after the fix of a conflict - deleted, // organizations that are virtually deleted duplicate // organizations that duplicate of a valid organization (their id is not an openorgs id) } diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/browse.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/browse.html index 64fe3048..c5d4b0df 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/browse.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/browse.html @@ -9,13 +9,11 @@ - + - - @@ -30,18 +28,10 @@ {{e.values.suggested}}- - -
{{field}}{{field}} # # approved # suggested# deleted # duplicate# discarded # hidden
- {{e.values.deleted}} - - - {{e.values.duplicate}} - - {{e.values.discarded}} - - - {{e.values.hidden}} - diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_duplicates.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_duplicates.html index 81ee02a8..774fcbaa 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_duplicates.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_duplicates.html @@ -54,4 +54,4 @@ - + diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html index 5552e717..a5587064 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html @@ -293,14 +293,12 @@
-
-
diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js index 4b65f5d2..c341af34 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js @@ -156,23 +156,6 @@ orgsModule.directive('orgFormMetadata', function($http, $location, $route, $rout else { $location.url('/edit/2/' + res.data[0]); } }); } - - scope.deleteOrg = function() { - if (confirm("Are you sure?")) { - call_http_get($http, 'api/organizations/delete?id=' + scope.org.id, function(res) { - alert("Organization marked as deleted !!!"); - $route.reload(); - }); - } - }; - scope.saveAsDiscarded = function() { - if (confirm("Are you sure?")) { - call_http_get($http, 'api/organizations/discard?id=' + scope.org.id, function(res) { - alert("Organization marked as discarded !!!"); - $route.reload(); - }); - } - }; } } });