changed approved(boolean) to status(text)
This commit is contained in:
parent
bcc5a4aef0
commit
f025d61006
|
@ -230,12 +230,10 @@ public class OrganizationController {
|
|||
@PathVariable final String code,
|
||||
final Authentication authentication) {
|
||||
if (UserInfo.isSuperAdmin(authentication) || userCountryRepository.verifyAuthorizationForCountry(code, authentication.getName())) {
|
||||
if (status.equalsIgnoreCase("approved")) {
|
||||
return organizationSimpleViewRepository.findByCountryAndApprovedOrderByName(code, true);
|
||||
} else if (status.equalsIgnoreCase("pending")) {
|
||||
return organizationSimpleViewRepository.findByCountryAndApprovedOrderByName(code, false);
|
||||
} else {
|
||||
if (status.equalsIgnoreCase("all")) {
|
||||
return organizationSimpleViewRepository.findByCountryOrderByName(code);
|
||||
} else {
|
||||
return organizationSimpleViewRepository.findByCountryAndStatusOrderByName(code, status);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("User not authorized");
|
||||
|
|
|
@ -41,9 +41,13 @@ public class Organization implements Serializable {
|
|||
@Column(name = "country")
|
||||
private String country;
|
||||
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
public Organization() {}
|
||||
|
||||
public Organization(final String id, final String name, final String type, final Double lat, final Double lng, final String city, final String country) {
|
||||
public Organization(final String id, final String name, final String type, final Double lat, final Double lng, final String city, final String country,
|
||||
final String status) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
|
@ -51,6 +55,7 @@ public class Organization implements Serializable {
|
|||
this.lng = lng;
|
||||
this.city = city;
|
||||
this.country = country;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -109,4 +114,12 @@ public class Organization implements Serializable {
|
|||
this.country = country;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(final String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ public class OrganizationSimpleView implements Serializable, Comparable<Organiza
|
|||
@Column(name = "acronyms", columnDefinition = "text[]")
|
||||
private String[] acronyms;
|
||||
|
||||
@Column(name = "approved")
|
||||
private boolean approved = false;
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
public OrganizationSimpleView() {}
|
||||
|
||||
|
@ -56,14 +56,14 @@ public class OrganizationSimpleView implements Serializable, Comparable<Organiza
|
|||
}
|
||||
|
||||
public OrganizationSimpleView(final String id, final String name, final String type, final String city, final String country, final String[] acronyms,
|
||||
final boolean approved) {
|
||||
final String status) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.city = city;
|
||||
this.country = country;
|
||||
this.acronyms = acronyms;
|
||||
this.approved = approved;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -114,12 +114,12 @@ public class OrganizationSimpleView implements Serializable, Comparable<Organiza
|
|||
this.acronyms = acronyms;
|
||||
}
|
||||
|
||||
public boolean isApproved() {
|
||||
return approved;
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setApproved(final boolean approved) {
|
||||
this.approved = approved;
|
||||
public void setStatus(final String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,8 +70,8 @@ public class OrganizationView implements Serializable {
|
|||
@Column(name = "relations", columnDefinition = "jsonb")
|
||||
private Set<RelationByOrg> relations;
|
||||
|
||||
@Column(name = "approved")
|
||||
private boolean approved = false;
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -169,12 +169,12 @@ public class OrganizationView implements Serializable {
|
|||
this.relations = relations;
|
||||
}
|
||||
|
||||
public boolean isApproved() {
|
||||
return approved;
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setApproved(final boolean approved) {
|
||||
this.approved = approved;
|
||||
public void setStatus(final String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public interface OrganizationSimpleViewRepository extends ReadOnlyRepository<Org
|
|||
|
||||
Iterable<OrganizationSimpleView> findByCountryOrderByName(String code);
|
||||
|
||||
Iterable<OrganizationSimpleView> findByCountryAndApprovedOrderByName(String code, boolean approved);
|
||||
Iterable<OrganizationSimpleView> findByCountryAndStatusOrderByName(String code, String status);
|
||||
|
||||
Page<OrganizationSimpleView> findByTypeOrderByName(String type, Pageable pageable);
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public class DatabaseUtils {
|
|||
cleanOldRelations(orgView.getId());
|
||||
}
|
||||
|
||||
if (!orgView.isApproved()) {
|
||||
if (!StringUtils.equals(orgView.getStatus(), OrganizationStatus.approved.toString())) {
|
||||
cleanOldRelations(orgView.getId());
|
||||
organizationRepository.deleteById(orgView.getId());
|
||||
orgView.setId(null);
|
||||
|
@ -108,7 +108,8 @@ public class DatabaseUtils {
|
|||
orgView.getName(),
|
||||
orgView.getType(),
|
||||
orgView.getLat(), orgView.getLng(),
|
||||
orgView.getCity(), orgView.getCountry());
|
||||
orgView.getCity(), orgView.getCountry(),
|
||||
OrganizationStatus.approved.toString());
|
||||
|
||||
final String orgId = organizationRepository.save(org).getId();
|
||||
|
||||
|
@ -279,29 +280,29 @@ public class DatabaseUtils {
|
|||
// BROWSE BY COUNTRY
|
||||
public List<BrowseEntry> browseCountries() {
|
||||
final String sql =
|
||||
"select country as value, sum(case when approved then 1 else 0 end) as approved, sum(case when approved then 0 else 1 end) as pending from organizations group by country order by approved desc;";
|
||||
"select country as value, sum(case when status='approved' then 1 else 0 end) as approved, sum(case when status='pending' then 1 else 0 end) as pending from organizations group by country order by approved desc";
|
||||
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BrowseEntry.class));
|
||||
}
|
||||
|
||||
// BROWSE BY COUNTRY FOR USER
|
||||
public List<BrowseEntry> browseCountriesForUser(final String email) {
|
||||
final String sql =
|
||||
"select o.country as value, sum(case when approved then 1 else 0 end) as approved, sum(case when approved then 0 else 1 end) as pending from user_countries uc left outer join organizations o on (uc.country = o.country) where uc.email=? group by o.country order by approved desc";
|
||||
"select o.country as value, sum(case when status='approved' then 1 else 0 end) as approved, sum(case when status='pending' then 1 else 0 end) as pending from user_countries uc left outer join organizations o on (uc.country = o.country) where uc.email=? group by o.country order by approved desc";
|
||||
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BrowseEntry.class), email);
|
||||
}
|
||||
|
||||
// BROWSE BY ORG TYPE
|
||||
public List<BrowseEntry> browseTypes() {
|
||||
final String sql =
|
||||
"select type as value, sum(case when approved then 1 else 0 end) as approved, sum(case when approved then 0 else 1 end) as pending from organizations group by type order by approved desc";
|
||||
"select type as value, sum(case when status='approved' then 1 else 0 end) as approved, sum(case when status='pending' then 1 else 0 end) as pending from organizations group by type order by approved desc";
|
||||
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BrowseEntry.class));
|
||||
}
|
||||
|
||||
// BROWSE BY ORG TYPE FOR USER
|
||||
public List<BrowseEntry> browseTypesForUser(final String email) {
|
||||
final String sql = "select o.type as value, "
|
||||
+ "sum(case when approved then 1 else 0 end) as approved, "
|
||||
+ "sum(case when approved then 0 else 1 end) as pending "
|
||||
+ "sum(case when status='approved' then 1 else 0 end) as approved, "
|
||||
+ "sum(case when status='pending' then 1 else 0 end) as pending "
|
||||
+ "from organizations o "
|
||||
+ "left outer join user_countries uc on (uc.country = o.country) "
|
||||
+ "where uc.email=? "
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package eu.dnetlib.organizations.utils;
|
||||
|
||||
public enum OrganizationStatus {
|
||||
pending,
|
||||
approved,
|
||||
discarded,
|
||||
hidden
|
||||
}
|
|
@ -82,7 +82,7 @@ CREATE TABLE organizations (
|
|||
creation_date timestamp with time zone DEFAULT now(),
|
||||
modified_by text,
|
||||
modification_date timestamp with time zone DEFAULT now(),
|
||||
approved boolean NOT NULL DEFAULT false
|
||||
status text NOT NULL DEFAULT 'pending'
|
||||
);
|
||||
CREATE INDEX organizations_type_idx ON organizations(type);
|
||||
CREATE INDEX organizations_country_idx ON organizations(country);
|
||||
|
@ -165,7 +165,7 @@ CREATE VIEW organizations_view AS SELECT
|
|||
org.lng,
|
||||
org.city,
|
||||
org.country,
|
||||
org.approved,
|
||||
org.status,
|
||||
COALESCE(jsonb_agg(DISTINCT jsonb_build_object('id', oid.otherid, 'type', oid.type)) FILTER (WHERE oid.otherid IS NOT NULL), '[]') AS other_ids,
|
||||
COALESCE(jsonb_agg(DISTINCT jsonb_build_object('name', n.name, 'lang', n.lang)) FILTER (WHERE n.name IS NOT NULL), '[]') AS other_names,
|
||||
COALESCE(jsonb_agg(DISTINCT a.acronym) FILTER (WHERE a.acronym IS NOT NULL), '[]') AS acronyms,
|
||||
|
@ -187,7 +187,7 @@ GROUP BY
|
|||
org.lng,
|
||||
org.city,
|
||||
org.country,
|
||||
org.approved;
|
||||
org.status;
|
||||
|
||||
CREATE VIEW organizations_info_view AS SELECT
|
||||
org.id,
|
||||
|
@ -209,7 +209,7 @@ CREATE VIEW organizations_simple_view AS SELECT
|
|||
org.type,
|
||||
org.city,
|
||||
org.country,
|
||||
org.approved,
|
||||
org.status,
|
||||
array_remove(array_agg(DISTINCT a.acronym), NULL) AS acronyms
|
||||
FROM
|
||||
organizations org
|
||||
|
@ -220,7 +220,7 @@ GROUP BY
|
|||
org.type,
|
||||
org.city,
|
||||
org.country,
|
||||
org.approved;
|
||||
org.status;
|
||||
|
||||
CREATE VIEW users_view AS SELECT
|
||||
u.email,
|
||||
|
@ -240,7 +240,7 @@ CREATE VIEW suggestions_info_by_country_view AS SELECT c.val AS country,
|
|||
FROM countries c
|
||||
LEFT OUTER JOIN (SELECT o.country AS country, count(DISTINCT d.*) AS n_duplicates FROM oa_duplicates d LEFT OUTER JOIN organizations o ON (d.local_id = o.id) WHERE d.reltype = 'suggested' 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' 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.approved = false 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 = 'pending' GROUP BY o.country) AS t3 ON (t3.country = c.val);
|
||||
|
||||
CREATE VIEW conflict_groups_view AS SELECT
|
||||
c.idgroup AS idgroup,
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
<div class="card">
|
||||
<org-tabs-menu org-id="{{orgId}}" info="info" org="org" events="events" selected="currentTab"></org-tabs-menu>
|
||||
|
||||
<org-form-metadata org-id="{{orgId}}" org="org" vocabularies="vocabularies" info-method="getInfo()" ng-if="currentTab == 1 && org.approved" mode="update"></org-form-metadata>
|
||||
<org-form-metadata org-id="{{orgId}}" org="org" vocabularies="vocabularies" info-method="getInfo()" ng-if="currentTab == 1 && !org.approved" mode="approve"></org-form-metadata>
|
||||
<org-form-metadata org-id="{{orgId}}" org="org" vocabularies="vocabularies" info-method="getInfo()" ng-if="currentTab == 1 && org.status == 'approved'" mode="update"></org-form-metadata>
|
||||
<org-form-metadata org-id="{{orgId}}" org="org" vocabularies="vocabularies" info-method="getInfo()" ng-if="currentTab == 1 && org.status == 'pending'" mode="approve"></org-form-metadata>
|
||||
|
||||
<org-dedup-events org-id="{{orgId}}" events="events" vocabularies="vocabularies" info-method="getInfo()" ng-if="currentTab == 2"></org-dedup-events>
|
||||
</div>
|
||||
|
|
|
@ -48,11 +48,11 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="o in orgs.content" class="d-flex" ng-class="{'table-warning' : !o.approved }">
|
||||
<tr ng-repeat="o in orgs.content" class="d-flex" ng-class="{'table-warning' : o.status != 'approved'}">
|
||||
<td class="col-6">
|
||||
<a ng-if="mode == 'select-modal'" href="javascript:void(0)" title="select" ng-click="selectOrg(o)" data-dismiss="modal">{{o.name}}</a>
|
||||
<a ng-if="mode != 'select-modal'" href="#!/edit/0/{{o.id}}" title="{{o.id}}">{{o.name}}</a>
|
||||
<span class="badge badge-warning" ng-if="!o.approved">pending</span>
|
||||
<span class="badge badge-warning" ng-if="o.status != 'approved'">{{o.status}}</span>
|
||||
</td>
|
||||
<td class="col-4"><img ng-src="resources/images/flags/{{o.country}}.gif" /> {{o.city}}, {{o.country}}</td>
|
||||
<td class="col-1 text-center">{{o.acronyms.join()}}</td>
|
||||
|
|
Loading…
Reference in New Issue