use of io.apiman.manager.api.beans.clients.ClientBean_ in project apiman by apiman.
the class JpaStorage method findClients.
/**
* {@inheritDoc}
*/
@Override
public SearchResultsBean<ClientSummaryBean> findClients(SearchCriteriaBean criteria, PermissionConstraint permissionConstraint) throws StorageException {
// If unconstrained, do nothing.
Consumer<CriteriaBuilder<ClientBean>> constraintFunc = builder -> {
};
if (permissionConstraint.isConstrained()) {
constraintFunc = (builder) -> builder.where("organization.id").in(permissionConstraint.getPermittedOrgs());
}
SearchResultsBean<ClientBean> result = find(criteria, List.of(new OrderByBean(true, ClientBean_.ID), new OrderByBean(true, "organization.id")), constraintFunc, ClientBean.class, "client", true);
SearchResultsBean<ClientSummaryBean> rval = new SearchResultsBean<>();
rval.setTotalSize(result.getTotalSize());
List<ClientBean> beans = result.getBeans();
rval.setBeans(new ArrayList<>(beans.size()));
for (ClientBean client : beans) {
ClientSummaryBean summary = new ClientSummaryBean();
OrganizationBean organization = client.getOrganization();
summary.setId(client.getId());
summary.setName(client.getName());
summary.setDescription(client.getDescription());
summary.setImage(client.getImage());
// TODO find the number of contracts - probably need native SQL for that
summary.setNumContracts(0);
summary.setOrganizationId(client.getOrganization().getId());
summary.setOrganizationName(organization.getName());
rval.getBeans().add(summary);
}
return rval;
}
Aggregations