actions by role
This commit is contained in:
parent
c6d71a6d0d
commit
be8cf2bafc
|
@ -14,6 +14,13 @@ public class OtherName implements Serializable {
|
||||||
|
|
||||||
private String lang;
|
private String lang;
|
||||||
|
|
||||||
|
public OtherName() {}
|
||||||
|
|
||||||
|
public OtherName(final String name, final String lang) {
|
||||||
|
this.name = name;
|
||||||
|
this.lang = lang;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ public interface OpenaireConflictRepository extends JpaRepository<OpenaireConfli
|
||||||
void resetGroupIds();
|
void resetGroupIds();
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "update oa_conflicts set modified_by = ?3, modification_date = ?4 where (id1 = ?1 and id2 = ?2) or (id1 = ?2 and id2 = ?1)", nativeQuery = true)
|
@Query(value = "update oa_conflicts set reltype = ?3, modified_by = ?4, modification_date = ?5 where (id1 = ?1 and id2 = ?2) or (id1 = ?2 and id2 = ?1)", nativeQuery = true)
|
||||||
void updateModificationDate(String id1, String id2, String user, OffsetDateTime now);
|
void updateStatus(String id1, String id2, String status, String user, OffsetDateTime now);
|
||||||
|
|
||||||
long countByGroupNull();
|
long countByGroupNull();
|
||||||
|
|
||||||
|
|
|
@ -98,9 +98,9 @@ public class DatabaseUtils {
|
||||||
@Transactional
|
@Transactional
|
||||||
public String insertOrUpdateOrganization(final OrganizationView orgView, final String user, final boolean isSimpleUser) {
|
public String insertOrUpdateOrganization(final OrganizationView orgView, final String user, final boolean isSimpleUser) {
|
||||||
|
|
||||||
final String oldStatus = organizationRepository.findById(orgView.getId())
|
final String oldStatus = orgView.getId() != null ? organizationRepository.findById(orgView.getId())
|
||||||
.map(Organization::getStatus)
|
.map(Organization::getStatus)
|
||||||
.orElse(null);
|
.orElse(null) : null;
|
||||||
|
|
||||||
final boolean alreadyApproved = StringUtils.equals(oldStatus, OrganizationStatus.approved.toString());
|
final boolean alreadyApproved = StringUtils.equals(oldStatus, OrganizationStatus.approved.toString());
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ public class DatabaseUtils {
|
||||||
dup.setRelType(SimilarityType.is_similar.toString());
|
dup.setRelType(SimilarityType.is_similar.toString());
|
||||||
|
|
||||||
openaireDuplicateRepository.save(dup);
|
openaireDuplicateRepository.save(dup);
|
||||||
openaireConflictRepository.updateModificationDate(newId, oldId, user, now);
|
openaireDuplicateRepository.updateModificationDate(newId, oldId, user, now);
|
||||||
organizationRepository.updateStatus(oldId, OrganizationStatus.duplicate.toString());
|
organizationRepository.updateStatus(oldId, OrganizationStatus.duplicate.toString());
|
||||||
organizationRepository.updateModificationDate(oldId, user, now);
|
organizationRepository.updateModificationDate(oldId, user, now);
|
||||||
}
|
}
|
||||||
|
@ -393,6 +393,14 @@ public class DatabaseUtils {
|
||||||
newOrg.setUrls(findAll(views, OrganizationView::getUrls));
|
newOrg.setUrls(findAll(views, OrganizationView::getUrls));
|
||||||
newOrg.setRelations(findAll(views, OrganizationView::getRelations));
|
newOrg.setRelations(findAll(views, OrganizationView::getRelations));
|
||||||
|
|
||||||
|
newOrg.getOtherNames()
|
||||||
|
.addAll(views.stream()
|
||||||
|
.map(OrganizationView::getName)
|
||||||
|
.filter(StringUtils::isNotBlank)
|
||||||
|
.filter(s -> StringUtils.equalsIgnoreCase(s, newOrg.getName()))
|
||||||
|
.map(s -> new eu.dnetlib.organizations.model.view.OtherName(s, "UNKNOWN"))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
final String masterId = insertOrUpdateOrganization(newOrg, user, false);
|
final String masterId = insertOrUpdateOrganization(newOrg, user, false);
|
||||||
|
|
||||||
// I hide the merged organizations
|
// I hide the merged organizations
|
||||||
|
@ -406,6 +414,14 @@ public class DatabaseUtils {
|
||||||
newDuplicates.forEach(d -> d.setLocalId(masterId));
|
newDuplicates.forEach(d -> d.setLocalId(masterId));
|
||||||
saveDuplicates(newDuplicates, user);
|
saveDuplicates(newDuplicates, user);
|
||||||
|
|
||||||
|
final OffsetDateTime now = OffsetDateTime.now();
|
||||||
|
|
||||||
|
for (int i = 0; i < ids.size(); i++) {
|
||||||
|
for (int j = i + 1; j < ids.size(); j++) {
|
||||||
|
openaireConflictRepository.updateStatus(ids.get(i), ids.get(j), SimilarityType.is_similar.toString(), user, now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return masterId;
|
return masterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -536,7 +536,12 @@ FROM
|
||||||
LEFT OUTER JOIN organizations o1 ON (c.id1 = o1.id)
|
LEFT OUTER JOIN organizations o1 ON (c.id1 = o1.id)
|
||||||
LEFT OUTER JOIN organizations o2 ON (c.id2 = o2.id)
|
LEFT OUTER JOIN organizations o2 ON (c.id2 = o2.id)
|
||||||
WHERE
|
WHERE
|
||||||
o1.id IS NOT NULL AND O2.id IS NOT NULL AND c.idgroup IS NOT NULL;
|
o1.id IS NOT NULL
|
||||||
|
AND o2.id IS NOT NULL
|
||||||
|
AND o1.status = 'approved'
|
||||||
|
AND o2.status = 'approved'
|
||||||
|
AND c.idgroup IS NOT NULL
|
||||||
|
AND c.reltype = 'suggested';
|
||||||
|
|
||||||
CREATE VIEW duplicate_groups_view AS SELECT
|
CREATE VIEW duplicate_groups_view AS SELECT
|
||||||
o.id,
|
o.id,
|
||||||
|
|
Loading…
Reference in New Issue