use of io.apiman.manager.api.beans.summary.OrganizationSummaryBean in project apiman by apiman.
the class EsMarshalling method unmarshallOrganizationSummary.
/**
* Unmarshals the given map source into a bean.
* @param source the source
* @return the organization summary
*/
public static OrganizationSummaryBean unmarshallOrganizationSummary(Map<String, Object> source) {
if (source == null) {
return null;
}
OrganizationSummaryBean bean = new OrganizationSummaryBean();
bean.setId(asString(source.get("id")));
bean.setName(asString(source.get("name")));
bean.setDescription(asString(source.get("description")));
postMarshall(bean);
return bean;
}
use of io.apiman.manager.api.beans.summary.OrganizationSummaryBean in project apiman by apiman.
the class EsStorage method getOrgs.
/**
* @see io.apiman.manager.api.core.IStorageQuery#getOrgs(java.util.Set)
*/
@Override
public List<OrganizationSummaryBean> getOrgs(Set<String> organizationIds) throws StorageException {
List<OrganizationSummaryBean> orgs = new ArrayList<>();
if (organizationIds == null || organizationIds.isEmpty()) {
return orgs;
}
BoolQueryBuilder query = QueryBuilders.boolQuery();
List<QueryBuilder> filter = query.should();
for (String orgId : organizationIds.toArray(new String[organizationIds.size()])) {
filter.add(QueryBuilders.termQuery("id", orgId));
}
@SuppressWarnings("nls") SearchSourceBuilder builder = new SearchSourceBuilder().sort(new FieldSortBuilder("name.keyword").order(SortOrder.ASC)).query(query).size(500);
List<SearchHit> hits = listEntities(INDEX_MANAGER_POSTFIX_ORGANIZATION, builder);
List<OrganizationSummaryBean> rval = new ArrayList<>(hits.size());
for (SearchHit hit : hits) {
OrganizationSummaryBean bean = EsMarshalling.unmarshallOrganizationSummary(hit.getSourceAsMap());
rval.add(bean);
}
return rval;
}
use of io.apiman.manager.api.beans.summary.OrganizationSummaryBean 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