country selection

This commit is contained in:
Michele Artini 2021-01-21 12:10:38 +01:00
parent 66e0238d73
commit e4f6ba9708
7 changed files with 110 additions and 61 deletions

View File

@ -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<String, SuggestionCounter> byCountry = new LinkedHashMap<>();
public List<SuggestionCounter> 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);
}

View File

@ -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() {

View File

@ -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,

View File

@ -1,16 +1,15 @@
<h2>Conflicts</h2>
<div class="input-group input-group-sm mb-3">
<input type="text" class="form-control" ng-model="conflictFilter" placeholder="Filter...">
<div class="input-group input-group-sm mt-3 mb-3">
<div class="input-group-append">
<span class="input-group-text text-outline-primary">Country:</span>
<button class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown">{{country}}</button>
<span class="input-group-text text-outline-primary">Current country:</span>
<button class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown">{{country}}</button>
<div class="dropdown-menu">
<small>
<a class="dropdown-item" href="#!/conflicts/{{c}}"
ng-repeat="(c, vals) in info.data.byCountry"
ng-if="vals.nConflicts > 0">
{{c}} <span class="badge badge-danger float-right">{{vals.nConflicts}}</span>
<a class="dropdown-item" href="#!/conflicts/{{c.code}}"
ng-repeat="c in info.data.byCountry"
ng-if="c.nConflicts > 0">
{{c.desc}} ({{c.code}}) <span class="badge badge-danger float-right">{{c.nConflicts}}</span>
</a>
</small>
</div>
@ -19,6 +18,10 @@
<h5 class="text-muted" ng-if="conflicts.length == 0">No conflicts</h5>
<p ng-show="conflicts.length > 0">
<input type="text" class="form-control form-control-sm" ng-model="conflictFilter" placeholder="Filter..." />
</p>
<div class="card text-white mb-3" ng-repeat="w in conflicts | filter:conflictFilter" class="mb-2">
<div class="card-header bg-primary text-white py-1">Group {{$index+1}}</div>
<table class="table table-sm">

View File

@ -1,24 +1,29 @@
<h2>Duplicates</h2>
<h4 class="text-muted" ng-if="duplicates.length == 0">No duplicates</h4>
<div class="input-group input-group-sm mb-3" ng-show="duplicates.length > 0">
<input type="text" class="form-control" ng-model="duplicateFilter" placeholder="Filter...">
<div class="input-group input-group-sm mt-3 mb-3">
<div class="input-group-append">
<span class="input-group-text text-outline-primary">Country:</span>
<span class="input-group-text text-outline-primary">Current country:</span>
<button class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown">{{country}}</button>
<div class="dropdown-menu">
<small>
<a class="dropdown-item" href="#!/duplicates/{{c}}"
ng-repeat="(c, vals) in info.data.byCountry"
ng-if="vals.nDuplicates > 0">
{{c}} <span class="badge badge-primary float-right">{{vals.nDuplicates}}</span>
<a class="dropdown-item" href="#!/duplicates/{{c.code}}"
ng-repeat="c in info.data.byCountry"
ng-if="c.nDuplicates > 0">
{{c.desc}} ({{c.code}}) <span class="badge badge-primary float-right">{{c.nDuplicates}}</span>
</a>
</small>
</div>
</div>
</div>
<h5 class="text-muted" ng-if="duplicates.length == 0">No duplicates</h5>
<p ng-show="duplicates.length > 0">
<input type="text" class="form-control" ng-model="duplicateFilter" placeholder="Filter..." />
</p>
<table class="table table-sm table-hover" ng-if="duplicates.length > 0">
<thead class="thead-light">
<tr class="d-flex">

View File

@ -1,24 +1,27 @@
<h2>Pending Organizations</h2>
<h4 class="text-muted" ng-if="orgs.length == 0">No pending organizations</h4>
<div class="input-group input-group-sm mb-3" ng-show="orgs.length > 0">
<input type="text" class="form-control" ng-model="orgFilter" placeholder="Filter..."/>
<div class="input-group input-group-sm mt-3 mb-3">
<div class="input-group-append">
<span class="input-group-text text-outline-primary">Country:</span>
<span class="input-group-text text-outline-primary">Current country:</span>
<button class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown">{{country}}</button>
<div class="dropdown-menu">
<small>
<a class="dropdown-item" href="#!/pendings/{{c}}"
ng-repeat="(c, vals) in info.data.byCountry"
ng-if="vals.nPendingOrgs > 0">
{{c}} <span class="badge badge-primary float-right">{{vals.nPendingOrgs}}</span>
</a>
</small>
</div>
<div class="dropdown-menu">
<small>
<a class="dropdown-item" href="#!/pendings/{{c.code}}"
ng-repeat="c in info.data.byCountry"
ng-if="c.nPendingOrgs > 0">
{{c.desc}} ({{c.code}}) <span class="badge badge-primary float-right">{{c.nPendingOrgs}}</span>
</a>
</small>
</div>
</div>
</div>
<h5 class="text-muted" ng-if="orgs.length == 0">No pending organizations</h5>
<p ng-show="orgs.length > 0">
<input type="text" class="form-control form-control-sm" ng-model="orgFilter" placeholder="Filter..."/>
</p>
<table class="table table-sm table-hover" ng-if="orgs.length > 0">
<thead class="thead-light">
<tr class="d-flex">

View File

@ -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); }