@GET @Path("shops") @Produces(MediaType.APPLICATION_JSON) public Response getShop(@QueryParam("offset") @DefaultValue("0") Integer offset, @QueryParam("number") @DefaultValue("25") Integer number) { Client client = getSearchEngine().getClient(); SearchResponse response = client.prepareSearch("entities").setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setFrom(offset) .setSize(number) .setTypes("tenant") .setExplain(false) .execute() .actionGet(); List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); for (SearchHit hit : response.getHits()) { result.add(hit.getSource()); } String thisAPIHref = urlHelper.getContextPlatformURL("/marketplace/api/shops/?number=" + number + "&offset=" + offset).toString(); ResultSetRepresentation<List<Map<String, Object>>> resultSet = new ResultSetRepresentation(thisAPIHref, number, offset, result, Long.valueOf(response.getHits().getTotalHits()).intValue()); return Response.ok(resultSet).build(); }
@GET @Path("products") @Produces(MediaType.APPLICATION_JSON) public Response getProducts(@QueryParam("offset") @DefaultValue("0") Integer offset, @QueryParam("number") @DefaultValue("25") Integer number) { Client client = getSearchEngine().getClient(); SearchResponse response = client.prepareSearch("entities").setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setFrom(offset) .setSize(number) .setTypes("product") .setExplain(false) .execute() .actionGet(); List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); for (SearchHit hit : response.getHits()) { result.add(hit.getSource()); } String thisAPIHref = urlHelper.getContextPlatformURL("/marketplace/api/products?number=" + number + "&offset=" + offset).toString(); ResultSetRepresentation<List<Map<String, Object>>> resultSet = new ResultSetRepresentation(thisAPIHref, number, offset, result, Long.valueOf(response.getHits().getTotalHits()).intValue()); return Response.ok(resultSet).build(); }
public Map<String, Object> purveyDocument(Tenant tenant) { Preconditions.checkNotNull(tenant); this.dao = this.dbi.get().onDemand(CollectionDAO.class); Map<String, Object> extracted = extractSourceFromEntity(tenant, tenant); List<Collection> collections = dao.findAll("collection", tenant.getId()); List<Map<String, Object>> collectionsSource = Lists.newArrayList(); for (Collection collection : collections) { Map<String, Object> collectionSource = extractSourceFromEntity(collection, tenant); collectionSource .put("api_url", urlHelper.getContextPlatformURL("/marketplace/api/shop/" + tenant.getSlug() + "/collections/" + collection.getSlug()).toString()); collectionsSource.add(collectionSource); } extracted.put("collections", collectionsSource); return extracted; } }
@GET @Path("shops/{shop}/products") @Produces(MediaType.APPLICATION_JSON) public Response getShopProducts(@PathParam("shop") String shop, @QueryParam("offset") @DefaultValue("0") Integer offset, @QueryParam("number") @DefaultValue("25") Integer number) { Client client = getSearchEngine().getClient(); SearchResponse response = client.prepareSearch("entities").setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setFrom(offset) .setSize(number) .setTypes("product") .setQuery(QueryBuilders.termQuery("site.slug", shop)) .setExplain(false) .execute() .actionGet(); List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); for (SearchHit hit : response.getHits()) { result.add(hit.getSource()); } String thisAPIHref = urlHelper.getContextPlatformURL("/marketplace/api/shops/" + shop + "/products?number=" + number + "&offset=" + offset).toString(); ResultSetRepresentation<List<Map<String, Object>>> resultSet = new ResultSetRepresentation(thisAPIHref, number, offset, result, Long.valueOf(response.getHits().getTotalHits()).intValue()); return Response.ok(resultSet).build(); }
urlHelper.getContextPlatformURL((webContext.getTenant() == null ? "marketplace/" : "") + "payment/" + order.getId() + "/acknowledgement/" + gatewayId));