importDedupEvents as SQL procedure

This commit is contained in:
Michele Artini 2022-04-13 14:45:56 +02:00
parent dcc5174f4d
commit f143d1f0c9
3 changed files with 6 additions and 6 deletions

View File

@ -175,7 +175,7 @@ public class AdminController extends AbstractDnetController {
@GetMapping("/api/restartSuggestionsImport")
public List<String> restartSuggestionsImport(final Authentication authentication) {
if (UserInfo.isSuperAdmin(authentication)) {
importExecutor.startImport("the portal, user: " + authentication.getName());
importExecutor.startImport("the portal, user: " + UserInfo.getEmail(authentication));
return Arrays.asList("The import is running");
} else {
throw new RuntimeException("User not authorized");

View File

@ -1,6 +1,5 @@
package eu.dnetlib.organizations.utils;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
@ -18,7 +17,6 @@ import java.util.stream.Collectors;
import javax.transaction.Transactional;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -436,7 +434,7 @@ public class DatabaseUtils {
@Transactional
public void importDedupEvents() throws Exception {
jdbcTemplate.update(IOUtils.toString(getClass().getResourceAsStream("/sql/importDedupEvents.sql"), StandardCharsets.UTF_8));
jdbcTemplate.update("CALL import_dedup_events();");
// verifyConflictGroups(true);
}

View File

@ -1,4 +1,5 @@
BEGIN;
CREATE OR REPLACE PROCEDURE import_dedup_events() LANGUAGE plpgsql AS $$
BEGIN
DELETE FROM oa_conflicts WHERE created_by = 'dedupWf' and modified_by = 'dedupWf' and reltype = 'suggested';
DELETE FROM oa_duplicates WHERE created_by = 'dedupWf' and modified_by = 'dedupWf' and reltype = 'suggested';
@ -153,4 +154,5 @@ DELETE FROM oa_duplicates d
USING oa_duplicates d1
WHERE d.oa_original_id = d1.oa_original_id AND d.reltype = 'suggested' AND d1.reltype = 'is_similar';
COMMIT;
END;
$$;