use of io.apiman.manager.api.beans.summary.ApiVersionSummaryBean in project apiman by apiman.
the class JpaStorage method getApiVersions.
// TODO(msavy): rewrite using projection
/**
* {@inheritDoc}
*/
@Override
public List<ApiVersionSummaryBean> getApiVersions(String orgId, String apiId) throws StorageException {
try {
EntityManager entityManager = getActiveEntityManager();
String jpql = "SELECT v " + " FROM ApiVersionBean v" + " JOIN v.api s" + " JOIN s.organization o" + " WHERE o.id = :orgId" + " AND s.id = :apiId" + " ORDER BY v.createdOn DESC";
TypedQuery<ApiVersionBean> query = entityManager.createQuery(jpql, ApiVersionBean.class).setMaxResults(500).setParameter("orgId", orgId).setParameter("apiId", apiId);
List<ApiVersionBean> apiVersions = query.getResultList();
return apiVersions.stream().map(e -> apiMapper.toSummary(e)).collect(Collectors.toList());
} catch (Throwable t) {
LOGGER.error(t.getMessage(), t);
throw new StorageException(t);
}
}
use of io.apiman.manager.api.beans.summary.ApiVersionSummaryBean in project apiman by apiman.
the class EsStorage method getApiVersions.
/**
* @see io.apiman.manager.api.core.IStorageQuery#getApiVersions(java.lang.String, java.lang.String)
*/
@Override
@SuppressWarnings("nls")
public List<ApiVersionSummaryBean> getApiVersions(String organizationId, String apiId) throws StorageException {
BoolQueryBuilder query = QueryBuilders.boolQuery();
List<QueryBuilder> filter = query.filter();
filter.add(QueryBuilders.termQuery("organizationId", organizationId));
filter.add(QueryBuilders.termQuery("apiId", apiId));
SearchSourceBuilder builder = new SearchSourceBuilder().sort(new FieldSortBuilder("createdOn").order(SortOrder.ASC)).query(query).size(500);
List<SearchHit> hits = listEntities(INDEX_MANAGER_POSTFIX_API_VERSION, builder);
List<ApiVersionSummaryBean> rval = new ArrayList<>(hits.size());
for (SearchHit hit : hits) {
ApiVersionSummaryBean bean = EsMarshalling.unmarshallApiVersionSummary(hit.getSourceAsMap());
rval.add(bean);
}
return rval;
}
use of io.apiman.manager.api.beans.summary.ApiVersionSummaryBean in project apiman by apiman.
the class EsMarshalling method unmarshallApiVersionSummary.
/**
* Unmarshals the given map source into a bean.
* @param source the source
* @return the API version summary
*/
public static ApiVersionSummaryBean unmarshallApiVersionSummary(Map<String, Object> source) {
if (source == null) {
return null;
}
ApiVersionSummaryBean bean = new ApiVersionSummaryBean();
bean.setDescription(asString(source.get("apiDescription")));
bean.setId(asString(source.get("apiId")));
bean.setName(asString(source.get("apiName")));
bean.setOrganizationId(asString(source.get("organizationId")));
bean.setOrganizationName(asString(source.get("organizationName")));
bean.setStatus(asEnum(source.get("status"), ApiStatus.class));
bean.setVersion(asString(source.get("version")));
bean.setPublicAPI(asBoolean(source.get("publicAPI")));
postMarshall(bean);
return bean;
}
Aggregations