use of io.apiman.manager.api.beans.orgs.OrganizationBean_ in project apiman by apiman.
the class JpaStorage method findOrganizations.
/**
* {@inheritDoc}
*/
@Override
public SearchResultsBean<OrganizationSummaryBean> findOrganizations(SearchCriteriaBean criteria, PermissionConstraint permissionConstraint) throws StorageException {
Consumer<CriteriaBuilder<OrganizationBean>> constraintFunc = builder -> {
};
if (permissionConstraint.isConstrained()) {
// With constraint, first allow the user's explicitly permitted orgs, plus orgs with discoverable APIs.
constraintFunc = (builder) -> builder.whereOr().where(OrganizationBean_.ID).in(permissionConstraint.getPermittedOrgs()).where("org.id").in().from(DiscoverabilityEntity.class, "d").select("d.orgId").where("d.discoverability").isNotNull().where("d.discoverability").in(permissionConstraint.getAllowedDiscoverabilities()).end().endOr();
}
SearchResultsBean<OrganizationBean> orgs = find(criteria, List.of(new OrderByBean(true, OrganizationBean_.ID)), constraintFunc, OrganizationBean.class, "org", true);
SearchResultsBean<OrganizationSummaryBean> rval = new SearchResultsBean<>();
rval.setTotalSize(orgs.getTotalSize());
List<OrganizationBean> beans = orgs.getBeans();
for (OrganizationBean bean : beans) {
OrganizationSummaryBean osb = new OrganizationSummaryBean();
osb.setId(bean.getId());
osb.setName(bean.getName());
osb.setDescription(bean.getDescription());
rval.getBeans().add(osb);
}
return rval;
}
Aggregations