This commit is contained in:
Michele Artini 2020-10-28 09:48:46 +01:00
parent 1f5e812bfa
commit 9bb4da72c4
7 changed files with 40 additions and 7 deletions

View File

@ -46,6 +46,9 @@ public class OpenaireDuplicateView implements Serializable {
@Column(name = "reltype")
private String relType;
@Column(name = "created_by")
private String createdBy;
public String getLocalId() {
return localId;
}
@ -110,4 +113,12 @@ public class OpenaireDuplicateView implements Serializable {
this.relType = relType;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(final String createdBy) {
this.createdBy = createdBy;
}
}

View File

@ -20,4 +20,8 @@ public interface OpenaireDuplicateRepository extends JpaRepository<OpenaireDupli
@Query(value = "update oa_duplicates set modified_by = ?3, modification_date = ?4 where (local_id = ?1 and oa_original_id = ?2) or (local_id = ?2 and oa_original_id = ?1)", nativeQuery = true)
void updateModificationDate(String id1, String id2, String user, OffsetDateTime now);
@Modifying
@Query(value = "update oa_duplicates set created_by = ?3 where ((local_id = ?1 and oa_original_id = ?2) or (local_id = ?2 and oa_original_id = ?1)) and (created_by is null or created_by = '')", nativeQuery = true)
void updateCreatedByIfMissing(String id1, String id2, String user);
}

View File

@ -151,7 +151,10 @@ public class DatabaseUtils {
.collect(Collectors.toList()));
openaireDuplicateRepository.saveAll(dups);
dups.forEach(d -> openaireDuplicateRepository.updateModificationDate(d.getLocalId(), d.getOaOriginalId(), user, now));
dups.forEach(d -> {
openaireDuplicateRepository.updateCreatedByIfMissing(d.getLocalId(), d.getOaOriginalId(), user);
openaireDuplicateRepository.updateModificationDate(d.getLocalId(), d.getOaOriginalId(), user, now);
});
organizationRepository.updateStatus(oldId, OrganizationStatus.duplicate.toString());
organizationRepository.updateModificationDate(oldId, user, now);
@ -168,6 +171,7 @@ public class DatabaseUtils {
final List<OpenaireDuplicate> list = openaireDuplicateRepository.saveAll(simrels);
list.forEach(d -> {
openaireDuplicateRepository.updateCreatedByIfMissing(d.getLocalId(), d.getOaOriginalId(), user);
openaireDuplicateRepository.updateModificationDate(d.getLocalId(), d.getOaOriginalId(), user, now);
if (d.getRelType().equals(SimilarityType.is_different.toString())) {

View File

@ -405,7 +405,8 @@ CREATE VIEW oa_duplicates_view AS
o.country as oa_country,
array_to_string(array_agg(u.url), ', ') as oa_url,
d.oa_collectedfrom as oa_collectedfrom,
d.reltype as reltype
d.reltype as reltype,
d.created_by as created_by
FROM
oa_duplicates d
LEFT OUTER JOIN organizations o ON (o.id = d.oa_original_id)
@ -414,6 +415,7 @@ FROM
GROUP BY
d.local_id,
d.oa_original_id,
d.created_by,
o.name,
o.country,
d.oa_collectedfrom,

View File

@ -15,12 +15,16 @@
</thead>
<tbody>
<tr class="d-flex" ng-repeat="sr in duplicates">
<td class="col-4 pl-3">{{sr.oaName}} <span class="small" ng-if="sr.oaUrl"><br />
<b>URL: </b><a href="{{sr.oaUrl}}" target="_blank">{{sr.oaUrl}}</a></span>
<td class="col-4 pl-3">{{sr.oaName}} <span class="small"><br />
<b>URL: </b><a href="{{sr.oaUrl}}" target="_blank" ng-if="sr.oaUrl">{{sr.oaUrl}}</a></span>
</td>
<td class="col-1 text-center small">{{sr.oaAcronym}}</td>
<td class="col-2 text-center small"><img ng-src="resources/images/flags/{{sr.oaCountry}}.gif" /> {{sr.oaCountry}}</td>
<td class="col-3 small"><b>Collected from:</b> {{sr.oaCollectedFrom}}<br /> <b>Original Id:</b> <span class="text-monospace">{{sr.oaOriginalId}}</span></td>
<td class="col-3 small">
<b>Original Id:</b> <span class="text-monospace">{{sr.oaOriginalId}}</span>
<span ng-if="sr.oaCollectedFrom"><br /><b>Provenance:</b> {{sr.oaCollectedFrom}}</span>
<span ng-if="sr.createdBy && sr.createdBy != 'dedupWf'"><br /><b>Added by:</b> {{sr.createdBy}}</span>
</td>
<td class="col-2 text-right">
<div class="btn-group btn-group-toggle btn-group-sm" data-toggle="buttons" ng-hide="readonly">
<label class="btn" ng-class="{'btn-danger' : sr.relType == 'is_different', 'btn-outline-danger' : sr.relType != 'is_different'}"> <input type="radio" autocomplete="off" ng-model="sr.relType"

View File

@ -245,7 +245,8 @@ orgsModule.directive('orgDuplicates', function($http, $location, $route) {
'oaAcronym' : scope.newDuplicate.acronyms.join(),
'oaCountry' : scope.newDuplicate.country,
'oaUrl' : scope.newDuplicate.urls.join(),
'oaCollectedFrom' : 'user',
'oaCollectedFrom' : '',
'createdBy' : currentUser(),
'relType' : 'is_similar'
});

View File

@ -111,7 +111,7 @@ fieldset > legend { font-size : 1.2rem !important; }
<a class="nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown"><i class="fa fa-user"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<p class="px-4 pt-2 text-muted small">
<b>Logged as:</b><br /><span sec:authentication="name"></span><br />
<b>Logged as:</b><br /><span sec:authentication="name" id="current_user"></span><br />
<b>Role:</b><br /><span sec:authentication="principal.authorities"></span>
</p>
<div class="dropdown-divider"></div>
@ -139,6 +139,13 @@ fieldset > legend { font-size : 1.2rem !important; }
function adminMode() { return false; }
</script>
<script>
function currentUser() {
return document.getElementById('current_user').textContent;
}
</script>
<script src="resources/js/jquery-3.4.1.min.js"></script>
<script src="resources/js/popper.min.js"></script>
<script src="resources/js/bootstrap.min.js"></script>