actions by role
This commit is contained in:
parent
c6d71a6d0d
commit
be8cf2bafc
|
@ -14,6 +14,13 @@ public class OtherName implements Serializable {
|
|||
|
||||
private String lang;
|
||||
|
||||
public OtherName() {}
|
||||
|
||||
public OtherName(final String name, final String lang) {
|
||||
this.name = name;
|
||||
this.lang = lang;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ public interface OpenaireConflictRepository extends JpaRepository<OpenaireConfli
|
|||
void resetGroupIds();
|
||||
|
||||
@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)
|
||||
void updateModificationDate(String id1, String id2, String user, OffsetDateTime now);
|
||||
@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 updateStatus(String id1, String id2, String status, String user, OffsetDateTime now);
|
||||
|
||||
long countByGroupNull();
|
||||
|
||||
|
|
|
@ -98,9 +98,9 @@ public class DatabaseUtils {
|
|||
@Transactional
|
||||
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)
|
||||
.orElse(null);
|
||||
.orElse(null) : null;
|
||||
|
||||
final boolean alreadyApproved = StringUtils.equals(oldStatus, OrganizationStatus.approved.toString());
|
||||
|
||||
|
@ -146,7 +146,7 @@ public class DatabaseUtils {
|
|||
dup.setRelType(SimilarityType.is_similar.toString());
|
||||
|
||||
openaireDuplicateRepository.save(dup);
|
||||
openaireConflictRepository.updateModificationDate(newId, oldId, user, now);
|
||||
openaireDuplicateRepository.updateModificationDate(newId, oldId, user, now);
|
||||
organizationRepository.updateStatus(oldId, OrganizationStatus.duplicate.toString());
|
||||
organizationRepository.updateModificationDate(oldId, user, now);
|
||||
}
|
||||
|
@ -393,6 +393,14 @@ public class DatabaseUtils {
|
|||
newOrg.setUrls(findAll(views, OrganizationView::getUrls));
|
||||
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);
|
||||
|
||||
// I hide the merged organizations
|
||||
|
@ -406,6 +414,14 @@ public class DatabaseUtils {
|
|||
newDuplicates.forEach(d -> d.setLocalId(masterId));
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -536,7 +536,12 @@ FROM
|
|||
LEFT OUTER JOIN organizations o1 ON (c.id1 = o1.id)
|
||||
LEFT OUTER JOIN organizations o2 ON (c.id2 = o2.id)
|
||||
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
|
||||
o.id,
|
||||
|
|
Loading…
Reference in New Issue