fix some ui bugs
This commit is contained in:
parent
7520fef31f
commit
9799ff3bda
|
@ -1,6 +1,5 @@
|
|||
package eu.dnetlib.organizations.controller;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -198,14 +197,7 @@ public class OrganizationController {
|
|||
.allMatch(id -> userCountryRepository.verifyAuthorizationForId(id, authentication.getName()));
|
||||
|
||||
if (b) {
|
||||
|
||||
final OffsetDateTime now = OffsetDateTime.now();
|
||||
final String email = authentication.getName();
|
||||
|
||||
final List<OpenaireDuplicate> list = openaireDuplicateRepository.saveAll(simrels);
|
||||
list.forEach(d -> openaireDuplicateRepository.updateModificationDate(d.getLocalId(), d.getOaOriginalId(), email, now));
|
||||
|
||||
return list;
|
||||
return databaseUtils.saveDuplicates(simrels, authentication.getName());
|
||||
} else {
|
||||
throw new RuntimeException("User not authorized");
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import eu.dnetlib.organizations.controller.UserRole;
|
|||
import eu.dnetlib.organizations.model.Acronym;
|
||||
import eu.dnetlib.organizations.model.OpenaireConflict;
|
||||
import eu.dnetlib.organizations.model.OpenaireConflictPK;
|
||||
import eu.dnetlib.organizations.model.OpenaireDuplicate;
|
||||
import eu.dnetlib.organizations.model.Organization;
|
||||
import eu.dnetlib.organizations.model.OtherIdentifier;
|
||||
import eu.dnetlib.organizations.model.OtherName;
|
||||
|
@ -41,6 +42,7 @@ import eu.dnetlib.organizations.model.view.OrganizationView;
|
|||
import eu.dnetlib.organizations.model.view.UserView;
|
||||
import eu.dnetlib.organizations.repository.AcronymRepository;
|
||||
import eu.dnetlib.organizations.repository.OpenaireConflictRepository;
|
||||
import eu.dnetlib.organizations.repository.OpenaireDuplicateRepository;
|
||||
import eu.dnetlib.organizations.repository.OrganizationRepository;
|
||||
import eu.dnetlib.organizations.repository.OtherIdentifierRepository;
|
||||
import eu.dnetlib.organizations.repository.OtherNameRepository;
|
||||
|
@ -71,6 +73,8 @@ public class DatabaseUtils {
|
|||
@Autowired
|
||||
private OpenaireConflictRepository openaireConflictRepository;
|
||||
@Autowired
|
||||
private OpenaireDuplicateRepository openaireDuplicateRepository;
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
private static final Log log = LogFactory.getLog(DatabaseUtils.class);
|
||||
|
@ -116,6 +120,15 @@ public class DatabaseUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<OpenaireDuplicate> saveDuplicates(final List<OpenaireDuplicate> simrels, final String email) {
|
||||
final OffsetDateTime now = OffsetDateTime.now();
|
||||
|
||||
final List<OpenaireDuplicate> list = openaireDuplicateRepository.saveAll(simrels);
|
||||
list.forEach(d -> openaireDuplicateRepository.updateModificationDate(d.getLocalId(), d.getOaOriginalId(), email, now));
|
||||
return list;
|
||||
}
|
||||
|
||||
private void makeNewRelations(final OrganizationView orgView, final String orgId) {
|
||||
orgView.getAcronyms().forEach(s -> acronymRepository.save(new Acronym(orgId, s)));
|
||||
orgView.getOtherNames().forEach(n -> otherNameRepository.save(new OtherName(orgId, n.getName(), n.getLang())));
|
||||
|
|
|
@ -232,8 +232,8 @@ CREATE VIEW suggestions_info_by_country_view AS SELECT c.val AS country,
|
|||
coalesce(t1.n_duplicates, 0) AS n_duplicates,
|
||||
coalesce(t2.n_conflicts, 0) AS n_conflicts
|
||||
FROM countries c
|
||||
LEFT OUTER JOIN (SELECT o.country AS country, count(DISTINCT d.*) AS n_duplicates FROM oa_duplicates d LEFT OUTER JOIN organizations o ON (d.local_id = o.id) GROUP BY o.country) AS t1 ON (t1.country = c.val)
|
||||
LEFT OUTER JOIN (SELECT o.country AS country, count(DISTINCT c.idgroup) AS n_conflicts FROM oa_conflicts c LEFT OUTER JOIN organizations o ON (c.id1 = o.id) GROUP BY o.country) AS t2 ON (t2.country = c.val);
|
||||
LEFT OUTER JOIN (SELECT o.country AS country, count(DISTINCT d.*) AS n_duplicates FROM oa_duplicates d LEFT OUTER JOIN organizations o ON (d.local_id = o.id) WHERE d.reltype = 'suggested' GROUP BY o.country) AS t1 ON (t1.country = c.val)
|
||||
LEFT OUTER JOIN (SELECT o.country AS country, count(DISTINCT c.idgroup) AS n_conflicts FROM oa_conflicts c LEFT OUTER JOIN organizations o ON (c.id1 = o.id) WHERE c.reltype = 'suggested' GROUP BY o.country) AS t2 ON (t2.country = c.val);
|
||||
|
||||
CREATE VIEW conflict_groups_view AS SELECT
|
||||
c.idgroup AS idgroup,
|
||||
|
|
|
@ -59,3 +59,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ orgsModule.directive('orgFormConflicts', function($http, $location, $route, $q)
|
|||
}
|
||||
});
|
||||
|
||||
orgsModule.directive('allDuplicates', function($http, $location, $route) {
|
||||
orgsModule.directive('allDuplicates', function($http, $location, $route, $timeout) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
|
@ -378,6 +378,15 @@ orgsModule.directive('allDuplicates', function($http, $location, $route) {
|
|||
}
|
||||
}
|
||||
scope.currentDuplicates = [];
|
||||
|
||||
$timeout(function() {
|
||||
if (scope.duplicates.length > 1) {
|
||||
$route.reload();
|
||||
} else {
|
||||
$location.url('/suggestions/_/1');
|
||||
}
|
||||
}, 600);
|
||||
|
||||
}, function errorCallback(res) {
|
||||
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue