Allow to search organizations based on reference

This commit is contained in:
George Kalampokis 2021-04-30 15:25:31 +03:00
parent fe8a0ff109
commit a155f2cbec
2 changed files with 12 additions and 8 deletions

View File

@ -26,6 +26,9 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
@Override @Override
public QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria) { public QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria) {
QueryableList<Organisation> query = this.getDatabaseService().getQueryable(Organisation.class); QueryableList<Organisation> query = this.getDatabaseService().getQueryable(Organisation.class);
if (criteria.getLabelLike() != null && criteria.getLike() != null) {
query.where((builder, root) -> builder.or(builder.equal(root.get("reference"), criteria.getLike()), builder.like(builder.upper(root.get("label")), "%" + criteria.getLabelLike().toUpperCase() + "%")));
} else {
if (criteria.getLike() != null) if (criteria.getLike() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike())); query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike()));
if (criteria.getLabelLike() != null) { if (criteria.getLabelLike() != null) {
@ -34,6 +37,7 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
if (criteria.getPublic() != null && criteria.getPublic()) { if (criteria.getPublic() != null && criteria.getPublic()) {
query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DMP.DMPStatus.FINALISED.getValue())); query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DMP.DMPStatus.FINALISED.getValue()));
} }
}
return query; return query;
} }

View File

@ -147,7 +147,7 @@ export class MainInfoComponent extends BaseComponent implements OnInit {
} }
filterOrganisations(value: string): Observable<ExternalSourceItemModel[]> { filterOrganisations(value: string): Observable<ExternalSourceItemModel[]> {
return this.organizationService.searchGeneralOrganisations({ criteria: { labelLike: value } }); return this.organizationService.searchGeneralOrganisations({ criteria: { labelLike: value, like: value } });
} }
cantAddOrganizations(): boolean { cantAddOrganizations(): boolean {