Fixes bug on not fetching internal saved Grants.
This commit is contained in:
parent
3327131ad8
commit
a80a935ff3
|
@ -53,7 +53,7 @@ public class GrantDaoImpl extends DatabaseAccess<Grant> implements GrantDao {
|
|||
if (criteria.getFunderId() != null && !criteria.getFunderId().trim().isEmpty())
|
||||
query.where((builder, root) -> builder.equal(root.get("funder").get("id"), UUID.fromString(criteria.getFunderId())));
|
||||
if (criteria.getFunderReference() != null && !criteria.getFunderReference().isEmpty())
|
||||
query.where((builder, root) -> builder.equal(root.join("funder", JoinType.LEFT).get("reference"), criteria.getFunderReference()));
|
||||
query.where((builder, root) -> builder.or(builder.like(root.join("funder", JoinType.LEFT).get("reference"), "%" + criteria.getFunderReference())));
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
|
||||
return query;
|
||||
}
|
||||
|
|
|
@ -109,21 +109,24 @@ public class GrantManager {
|
|||
public List<eu.eudat.models.data.grant.Grant> getCriteriaWithExternal(GrantCriteriaRequest grantCriteria, Principal principal) throws HugeResultSet, NoURLFound {
|
||||
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
if (grantCriteria.getCriteria().getFunderReference() != null && !grantCriteria.getCriteria().getFunderReference().trim().isEmpty()) {
|
||||
/*if (grantCriteria.getCriteria().getFunderReference() != null && !grantCriteria.getCriteria().getFunderReference().trim().isEmpty()) {
|
||||
FunderCriteria funderCriteria = new FunderCriteria();
|
||||
funderCriteria.setReference(grantCriteria.getCriteria().getFunderReference());
|
||||
Funder funder = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(funderCriteria).getSingleOrDefault();
|
||||
if (funder != null) {
|
||||
grantCriteria.getCriteria().setFunderId(funder.getId().toString());
|
||||
}
|
||||
}*/
|
||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(grantCriteria.getCriteria().getLike());
|
||||
if (grantCriteria.getCriteria().getFunderReference() != null) {
|
||||
externalUrlCriteria.setFunderId(grantCriteria.getCriteria().getFunderReference());
|
||||
grantCriteria.getCriteria().setFunderReference(null);
|
||||
}
|
||||
grantCriteria.getCriteria().setReference("dmp:");
|
||||
QueryableList<eu.eudat.data.entities.Grant> items = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(grantCriteria.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.Grant> authItems = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getAuthenticated(items, userInfo);
|
||||
List<eu.eudat.models.data.grant.Grant> grants = authItems.select(item -> new Grant().fromDataModel(item));
|
||||
|
||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(grantCriteria.getCriteria().getLike());
|
||||
if (grantCriteria.getCriteria().getFunderReference() != null) externalUrlCriteria.setFunderId(grantCriteria.getCriteria().getFunderReference());
|
||||
List<Map<String, String>> remoteRepos = remoteFetcher.getGrants(externalUrlCriteria);
|
||||
|
||||
GrantsExternalSourcesModel grantsExternalSourcesModel = new GrantsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
|
|
Loading…
Reference in New Issue