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