approve and discard orgs
This commit is contained in:
parent
637a683723
commit
90d7bba929
|
@ -1,6 +1,7 @@
|
||||||
package eu.dnetlib.organizations.utils;
|
package eu.dnetlib.organizations.utils;
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
@ -140,13 +141,18 @@ public class DatabaseUtils {
|
||||||
organizationRepository.updateCreationDate(newId, user, now);
|
organizationRepository.updateCreationDate(newId, user, now);
|
||||||
makeRelations(newId, orgView, false);
|
makeRelations(newId, orgView, false);
|
||||||
if (oldId != null) {
|
if (oldId != null) {
|
||||||
final OpenaireDuplicate dup = new OpenaireDuplicate();
|
|
||||||
dup.setLocalId(newId);
|
|
||||||
dup.setOaOriginalId(oldId);
|
|
||||||
dup.setRelType(SimilarityType.is_similar.toString());
|
|
||||||
|
|
||||||
openaireDuplicateRepository.save(dup);
|
final List<OpenaireDuplicate> dups = new ArrayList<>();
|
||||||
openaireDuplicateRepository.updateModificationDate(newId, oldId, user, now);
|
|
||||||
|
dups.add(new OpenaireDuplicate(newId, oldId, SimilarityType.is_similar.toString()));
|
||||||
|
dups.addAll(openaireDuplicateRepository.findByLocalId(oldId)
|
||||||
|
.stream()
|
||||||
|
.map(d -> new OpenaireDuplicate(newId, d.getOaOriginalId(), SimilarityType.suggested.toString()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
openaireDuplicateRepository.saveAll(dups);
|
||||||
|
dups.forEach(d -> openaireDuplicateRepository.updateModificationDate(d.getLocalId(), d.getOaOriginalId(), user, now));
|
||||||
|
|
||||||
organizationRepository.updateStatus(oldId, OrganizationStatus.duplicate.toString());
|
organizationRepository.updateStatus(oldId, OrganizationStatus.duplicate.toString());
|
||||||
organizationRepository.updateModificationDate(oldId, user, now);
|
organizationRepository.updateModificationDate(oldId, user, now);
|
||||||
}
|
}
|
||||||
|
@ -164,10 +170,10 @@ public class DatabaseUtils {
|
||||||
list.forEach(d -> {
|
list.forEach(d -> {
|
||||||
openaireDuplicateRepository.updateModificationDate(d.getLocalId(), d.getOaOriginalId(), user, now);
|
openaireDuplicateRepository.updateModificationDate(d.getLocalId(), d.getOaOriginalId(), user, now);
|
||||||
|
|
||||||
if (d.getRelType().equals(SimilarityType.is_similar.toString())) {
|
if (d.getRelType().equals(SimilarityType.is_different.toString())) {
|
||||||
updateStatus(d.getOaOriginalId(), OrganizationStatus.duplicate, user, now);
|
|
||||||
} else {
|
|
||||||
updateStatus(d.getOaOriginalId(), OrganizationStatus.suggested, user, now);
|
updateStatus(d.getOaOriginalId(), OrganizationStatus.suggested, user, now);
|
||||||
|
} else {
|
||||||
|
updateStatus(d.getOaOriginalId(), OrganizationStatus.duplicate, user, now);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -363,6 +369,9 @@ public class DatabaseUtils {
|
||||||
public OrganizationView markAsDiscarded(final String id, final String user) {
|
public OrganizationView markAsDiscarded(final String id, final String user) {
|
||||||
final OffsetDateTime now = OffsetDateTime.now();
|
final OffsetDateTime now = OffsetDateTime.now();
|
||||||
updateStatus(id, OrganizationStatus.discarded, user, now);
|
updateStatus(id, OrganizationStatus.discarded, user, now);
|
||||||
|
|
||||||
|
openaireDuplicateRepository.findByLocalId(id).forEach(d -> updateStatus(d.getOaOriginalId(), OrganizationStatus.suggested, user, now));
|
||||||
|
|
||||||
return organizationViewRepository.findById(id).get();
|
return organizationViewRepository.findById(id).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,43 @@
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
DELETE FROM organizations WHERE status = 'suggested' and created_by = 'dedupWf';
|
DELETE FROM oa_conflicts WHERE created_by = 'dedupWf' and reltype = 'suggested';
|
||||||
DELETE FROM oa_duplicates WHERE reltype = 'suggested' and created_by = 'dedupWf';
|
DELETE FROM oa_duplicates WHERE created_by = 'dedupWf' and reltype = 'suggested';
|
||||||
DELETE FROM oa_conflicts WHERE reltype = 'suggested' and created_by = 'dedupWf';
|
DELETE FROM organizations WHERE created_by = 'dedupWf' and modified_by = 'dedupWf';
|
||||||
|
|
||||||
-- FIX IMPORT DATA
|
-- FIX IMPORT DATA
|
||||||
UPDATE tmp_dedup_events SET oa_country = 'UNKNOWN' WHERE oa_country = '' OR oa_country IS NULL;
|
UPDATE tmp_dedup_events SET oa_country = 'UNKNOWN' WHERE oa_country = '' OR oa_country IS NULL;
|
||||||
|
|
||||||
-- NEW ORGANIZATIONS
|
-- NEW ORGANIZATIONS
|
||||||
INSERT INTO organizations(id, name, country, status, created_by, modified_by) SELECT oa_original_id, oa_name, oa_country, 'suggested', 'dedupWf', 'dedupWf' FROM tmp_dedup_events WHERE oa_original_id NOT LIKE 'openorgs\_\_\_\_::%' ON CONFLICT DO NOTHING;
|
INSERT INTO organizations(id, name, country, status, created_by, modified_by)
|
||||||
|
SELECT oa_original_id, oa_name, oa_country, 'suggested', 'dedupWf', 'dedupWf'
|
||||||
|
FROM tmp_dedup_events
|
||||||
|
WHERE oa_original_id NOT LIKE 'openorgs\_\_\_\_::%' AND oa_original_id = local_id
|
||||||
|
ON CONFLICT DO NOTHING;
|
||||||
|
|
||||||
|
INSERT INTO organizations(id, name, country, status, created_by, modified_by)
|
||||||
|
SELECT oa_original_id, oa_name, oa_country, 'duplicate', 'dedupWf', 'dedupWf'
|
||||||
|
FROM tmp_dedup_events
|
||||||
|
WHERE oa_original_id NOT LIKE 'openorgs\_\_\_\_::%' AND oa_original_id != local_id
|
||||||
|
ON CONFLICT DO NOTHING;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO acronyms(id, acronym) SELECT oa_original_id, oa_acronym FROM tmp_dedup_events WHERE oa_original_id NOT LIKE 'openorgs\_\_\_\_::%' ON CONFLICT DO NOTHING;
|
INSERT INTO acronyms(id, acronym) SELECT oa_original_id, oa_acronym FROM tmp_dedup_events WHERE oa_original_id NOT LIKE 'openorgs\_\_\_\_::%' ON CONFLICT DO NOTHING;
|
||||||
INSERT INTO urls(id, url) SELECT oa_original_id, oa_url FROM tmp_dedup_events WHERE oa_original_id NOT LIKE 'openorgs\_\_\_\_::%' ON CONFLICT DO NOTHING;
|
INSERT INTO urls(id, url) SELECT oa_original_id, oa_url FROM tmp_dedup_events WHERE oa_original_id NOT LIKE 'openorgs\_\_\_\_::%' ON CONFLICT DO NOTHING;
|
||||||
|
|
||||||
-- DUPLICATES
|
-- DUPLICATES
|
||||||
INSERT INTO oa_duplicates (local_id, oa_original_id, oa_collectedfrom, created_by)
|
INSERT INTO oa_duplicates (local_id, oa_original_id, oa_collectedfrom, created_by, modified_by)
|
||||||
SELECT local_id, oa_original_id, oa_collectedfrom, 'dedupWf'
|
SELECT local_id, oa_original_id, oa_collectedfrom, 'dedupWf', 'dedupWf'
|
||||||
FROM tmp_dedup_events
|
FROM tmp_dedup_events
|
||||||
WHERE local_id IS NOT NULL AND local_id != '' AND oa_original_id NOT LIKE 'openorgs\_\_\_\_::%' AND local_id != oa_original_id
|
WHERE local_id IS NOT NULL AND local_id != '' AND oa_original_id NOT LIKE 'openorgs\_\_\_\_::%' AND local_id != oa_original_id
|
||||||
ON CONFLICT DO NOTHING;
|
ON CONFLICT DO NOTHING;
|
||||||
|
|
||||||
|
|
||||||
-- CONFLICTS
|
-- CONFLICTS
|
||||||
INSERT INTO oa_conflicts (id1, id2, idgroup, created_by)
|
INSERT INTO oa_conflicts (id1, id2, idgroup, created_by, modified_by)
|
||||||
SELECT local_id, oa_original_id, group_id, 'dedupWf'
|
SELECT local_id, oa_original_id, group_id, 'dedupWf', 'dedupWf'
|
||||||
FROM tmp_dedup_events
|
FROM tmp_dedup_events
|
||||||
WHERE local_id LIKE 'openorgs\_\_\_\_::%' AND oa_original_id LIKE 'openorgs\_\_\_\_::%' AND local_id != oa_original_id
|
WHERE local_id LIKE 'openorgs\_\_\_\_::%' AND oa_original_id LIKE 'openorgs\_\_\_\_::%' AND local_id != oa_original_id AND group_id IS NOT NULL AND group_id != ''
|
||||||
ON CONFLICT DO NOTHING;
|
ON CONFLICT DO NOTHING;
|
||||||
|
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
<thead class="thead-light">
|
<thead class="thead-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="col-6">{{field}}</th>
|
<th class="col-6">{{field}}</th>
|
||||||
<th class="col-1 text-right text-nowrap"># approved</th>
|
<th class="col-1 text-right text-nowrap" title="valid organizations"># approved</th>
|
||||||
<th class="col-1 text-right text-nowrap"># pending</th>
|
<th class="col-1 text-right text-nowrap" title="to be approved by an administrator"># suggested</th>
|
||||||
<th class="col-1 text-right text-nowrap"># deleted</th>
|
<th class="col-1 text-right text-nowrap" title="deleted by an administrator"># deleted</th>
|
||||||
<th class="col-1 text-right text-nowrap"># duplicated</th>
|
<th class="col-1 text-right text-nowrap" title="duplicates(not openorgs) of a valid organization"># duplicated</th>
|
||||||
<th class="col-1 text-right text-nowrap"># discarded</th>
|
<th class="col-1 text-right text-nowrap" title="suggestions rejected by an administrator"># discarded</th>
|
||||||
<th class="col-1 text-right text-nowrap"># hidden</th>
|
<th class="col-1 text-right text-nowrap" title="organizations hidden by the system (for example fixing a conflict)"># hidden</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
|
@ -182,7 +182,7 @@ orgsModule.directive('orgFormMetadata', function($http, $location, $route, $rout
|
||||||
alert("Session expired !");
|
alert("Session expired !");
|
||||||
location.reload(true);
|
location.reload(true);
|
||||||
} else {
|
} else {
|
||||||
alert("Organization marked as deleted !!!");
|
alert("Organization marked as discarded !!!");
|
||||||
$route.reload();
|
$route.reload();
|
||||||
}
|
}
|
||||||
}, function errorCallback(res) {
|
}, function errorCallback(res) {
|
||||||
|
|
Loading…
Reference in New Issue