From e4f6ba97088e4eabfdeccb3a201eb783624779c8 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Thu, 21 Jan 2021 12:10:38 +0100 Subject: [PATCH] country selection --- .../controller/SuggestionInfo.java | 48 ++++++++++++++----- .../view/SuggestionInfoViewByCountry.java | 23 ++++++--- .../src/main/resources/sql/schema.sql | 7 ++- .../html/pages/advanced/conflicts.html | 19 ++++---- .../html/pages/advanced/duplicates.html | 25 ++++++---- .../html/pages/advanced/pendingOrgs.html | 31 ++++++------ .../static/resources/js/organizations.js | 18 +++---- 7 files changed, 110 insertions(+), 61 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/SuggestionInfo.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/SuggestionInfo.java index 8e0c0fe0..066f3156 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/SuggestionInfo.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/SuggestionInfo.java @@ -1,7 +1,7 @@ package eu.dnetlib.organizations.controller; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.ArrayList; +import java.util.List; import eu.dnetlib.organizations.model.view.SuggestionInfoViewByCountry; @@ -9,12 +9,42 @@ public class SuggestionInfo { public class SuggestionCounter { + private String code; + + private String desc; + private long nDuplicates = 0; private long nConflicts = 0; private long nPendingOrgs = 0; + public SuggestionCounter() {} + + public SuggestionCounter(final SuggestionInfoViewByCountry infoCountry) { + this.code = infoCountry.getCode(); + this.desc = infoCountry.getName(); + this.nDuplicates = infoCountry.getnDuplicates(); + this.nConflicts = infoCountry.getnConflicts(); + this.nPendingOrgs = infoCountry.getnPendingOrgs(); + } + + public String getCode() { + return code; + } + + public void setCode(final String code) { + this.code = code; + } + + public String getDesc() { + return desc; + } + + public void setDesc(final String desc) { + this.desc = desc; + } + public long getnDuplicates() { return nDuplicates; } @@ -35,7 +65,7 @@ public class SuggestionInfo { return nPendingOrgs; } - public void setnPenfingOrgs(final long nPendingOrgs) { + public void setnPendingOrgs(final long nPendingOrgs) { this.nPendingOrgs = nPendingOrgs; } @@ -47,18 +77,12 @@ public class SuggestionInfo { } - public SuggestionCounter total = new SuggestionCounter();; + public SuggestionCounter total = new SuggestionCounter(); - public Map byCountry = new LinkedHashMap<>(); + public List byCountry = new ArrayList<>(); public void add(final SuggestionInfoViewByCountry infoCountry) { - final String country = infoCountry.getCountry(); - - if (!byCountry.containsKey(country)) { - byCountry.put(country, new SuggestionCounter()); - - } - byCountry.get(country).add(infoCountry); + byCountry.add(new SuggestionCounter(infoCountry)); total.add(infoCountry); } diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/model/view/SuggestionInfoViewByCountry.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/model/view/SuggestionInfoViewByCountry.java index ef8125b3..5956acce 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/model/view/SuggestionInfoViewByCountry.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/model/view/SuggestionInfoViewByCountry.java @@ -17,8 +17,11 @@ public class SuggestionInfoViewByCountry implements Serializable { private static final long serialVersionUID = -6814272980951063075L; @Id - @Column(name = "country") - private String country; + @Column(name = "code") + private String code; + + @Column(name = "name") + private String name; @Column(name = "n_duplicates") private long nDuplicates; @@ -29,12 +32,20 @@ public class SuggestionInfoViewByCountry implements Serializable { @Column(name = "n_pending_orgs") private long nPendingOrgs; - public String getCountry() { - return country; + public String getCode() { + return code; } - public void setCountry(final String country) { - this.country = country; + public void setCode(final String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; } public long getnDuplicates() { diff --git a/apps/dnet-orgs-database-application/src/main/resources/sql/schema.sql b/apps/dnet-orgs-database-application/src/main/resources/sql/schema.sql index cb25ee12..d0e0d865 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/sql/schema.sql +++ b/apps/dnet-orgs-database-application/src/main/resources/sql/schema.sql @@ -518,14 +518,17 @@ FROM GROUP BY u.email, u.valid, u.role, u.first_access, u.last_access ORDER BY u.email; -CREATE VIEW suggestions_info_by_country_view AS SELECT c.val AS country, +CREATE VIEW suggestions_info_by_country_view AS SELECT + c.val AS code, + c.name AS name, coalesce(t1.n_duplicates, 0) AS n_duplicates, coalesce(t2.n_conflicts, 0) AS n_conflicts, coalesce(t3.n_pending_orgs, 0) AS n_pending_orgs FROM countries c LEFT OUTER JOIN (SELECT o.country AS country, count(DISTINCT d.local_id) AS n_duplicates FROM oa_duplicates d LEFT OUTER JOIN organizations o ON (d.local_id = o.id) WHERE d.reltype = 'suggested' AND o.status = 'approved' GROUP BY o.country) AS t1 ON (t1.country = c.val) LEFT OUTER JOIN (SELECT o.country AS country, count(DISTINCT c.idgroup) AS n_conflicts FROM oa_conflicts c LEFT OUTER JOIN organizations o ON (c.id1 = o.id) WHERE c.reltype = 'suggested' AND o.status = 'approved' GROUP BY o.country) AS t2 ON (t2.country = c.val) - LEFT OUTER JOIN (SELECT o.country AS country, count(DISTINCT o.id) AS n_pending_orgs FROM organizations o WHERE o.status = 'suggested' GROUP BY o.country) AS t3 ON (t3.country = c.val); + LEFT OUTER JOIN (SELECT o.country AS country, count(DISTINCT o.id) AS n_pending_orgs FROM organizations o WHERE o.status = 'suggested' GROUP BY o.country) AS t3 ON (t3.country = c.val) +ORDER BY c.name; CREATE VIEW conflict_groups_view AS SELECT c.idgroup AS idgroup, diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/conflicts.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/conflicts.html index 3ac20211..81edce9f 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/conflicts.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/conflicts.html @@ -1,16 +1,15 @@

Conflicts

-
- +
- Country: - + Current country: + @@ -19,6 +18,10 @@
No conflicts
+

+ +

+
Group {{$index+1}}
diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/duplicates.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/duplicates.html index 536db91e..a8c4cb43 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/duplicates.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/duplicates.html @@ -1,24 +1,29 @@

Duplicates

-

No duplicates

- -
- + - + +
No duplicates
+ +

+ +

+ +
diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/pendingOrgs.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/pendingOrgs.html index 27a88f55..5158c9a9 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/pendingOrgs.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/pendingOrgs.html @@ -1,24 +1,27 @@

Pending Organizations

-

No pending organizations

- -
- +
- Country: + Current country: - +
+
No pending organizations
+ +

+ +

+
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 c46ed787..8d37b098 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 @@ -543,9 +543,9 @@ orgsModule.controller('pendingOrgsCtrl', function ($scope, $http, $routeParams, suggestionInfo.updateInfo(function(info) { if ($scope.country == '_') { var found = ''; - angular.forEach(info.data.byCountry, function(values, c) { - if (!found && values.nPendingOrgs > 0) { - found = c; + angular.forEach(info.data.byCountry, function(c) { + if (!found && c.nPendingOrgs > 0) { + found = c.code; } }); if (found) { $location.url('/pendings/' + found); } @@ -585,9 +585,9 @@ orgsModule.controller('duplicatesCtrl', function ($scope, $http, $routeParams, $ suggestionInfo.updateInfo(function(info) { if ($scope.country == '_') { var found = ''; - angular.forEach(info.data.byCountry, function(values, c) { - if (!found && values.nDuplicates > 0) { - found = c; + angular.forEach(info.data.byCountry, function(c) { + if (!found && c.nDuplicates > 0) { + found = c.code; } }); if (found) { $location.url('/duplicates/' + found); } @@ -694,9 +694,9 @@ orgsModule.controller('conflictsCtrl', function ($scope, $http, $routeParams, $l if ($scope.country == '_') { var found = ''; - angular.forEach(info.data.byCountry, function(values, c) { - if (!found && values.nConflicts > 0) { - found = c; + angular.forEach(info.data.byCountry, function(c) { + if (!found && c.nConflicts > 0) { + found = c.code; } }); if (found) { $location.url('/conflicts/' + found); }