com.adobe.granite.ui.components.ds.SimpleDataSource Java Examples
The following examples show how to use
com.adobe.granite.ui.components.ds.SimpleDataSource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RelationTypesDataSourceServlet.java From aem-core-cif-components with Apache License 2.0 | 7 votes |
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { ResourceBundle resourceBundle = request.getResourceBundle(null); List<Resource> values = new ArrayList<>(); for (RelationType relationType : RelationType.values()) { ValueMap vm = new ValueMapDecorator(new HashMap<String, Object>()); vm.put("value", relationType); vm.put("text", toText(resourceBundle, relationType.getText())); values.add(new ValueMapResource(request.getResourceResolver(), new ResourceMetadata(), JcrConstants.NT_UNSTRUCTURED, vm)); } DataSource ds = new SimpleDataSource(values.iterator()); request.setAttribute(DataSource.class.getName(), ds); }
Example #2
Source File: SearchDataSourceServlet.java From commerce-cif-connector with Apache License 2.0 | 5 votes |
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException { final String PARAMETER_OFFSET = "_commerce_offset"; final String PARAMETER_LIMIT = "_commerce_limit"; final String PARAMETER_COMMERCE_TYPE = "_commerce_commerce_type"; final Config cfg = new Config(request.getResource().getChild(Config.DATASOURCE)); final SlingScriptHelper sling = ((SlingBindings) request.getAttribute(SlingBindings.class.getName())).getSling(); final ExpressionHelper ex = new ExpressionHelper(sling.getService(ExpressionResolver.class), request); final String itemRT = cfg.get("itemResourceType", String.class); final long offset = ex.get(cfg.get("offset", "0"), long.class); final long limit = ex.get(cfg.get("limit", "20"), long.class); final String commerceType = ex.get(cfg.get("commerceType", "product"), String.class); Map<String, Object> queryParameters = new HashMap<>(request.getParameterMap()); queryParameters.put(PARAMETER_OFFSET, String.valueOf(offset)); queryParameters.put(PARAMETER_LIMIT, String.valueOf(limit)); queryParameters.put(PARAMETER_COMMERCE_TYPE, commerceType); final String rootPath = request.getParameter("root"); String rootCategoryId = new CatalogSearchSupport(request.getResourceResolver()).findCategoryId(rootPath); if (rootCategoryId != null) { queryParameters.put(CATEGORY_ID_PARAMETER, rootCategoryId); queryParameters.put(CATEGORY_PATH_PARAMETER, rootPath); } String queryString = new ObjectMapper().writeValueAsString(queryParameters); try { Iterator<Resource> virtualResults = request.getResourceResolver().findResources(queryString, VIRTUAL_PRODUCT_QUERY_LANGUAGE); final DataSource ds = new SimpleDataSource(new TransformIterator<>(virtualResults, r -> new ResourceWrapper(r) { public String getResourceType() { return itemRT; } })); request.setAttribute(DataSource.class.getName(), ds); } catch (Exception x) { response.sendError(500, x.getMessage()); LOGGER.error("Error finding resources", x); } }
Example #3
Source File: ScriptsDatasourceServlet.java From APM with Apache License 2.0 | 5 votes |
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) { String path = request.getRequestPathInfo().getSuffix(); List<Resource> scripts = new ArrayList<>(); Resource resource = request.getResourceResolver().getResource(path); for (Resource child : resource.getChildren()) { if (ScriptsRowModel.isFolder(child) || ScriptModel.isScript(child)) { scripts.add(new ResourceTypeWrapper(child)); } } DataSource dataSource = new SimpleDataSource(scripts.iterator()); request.setAttribute(DataSource.class.getName(), dataSource); }
Example #4
Source File: HistoryDatasourceServlet.java From APM with Apache License 2.0 | 5 votes |
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) { Pagination pagination = createPagination(request); List<Resource> allHistoryResources = pagination.getPage(history.findAllResources(request.getResourceResolver())) .stream() .map(ResourceTypeWrapper::new) .collect(Collectors.toList()); DataSource dataSource = new SimpleDataSource(allHistoryResources.iterator()); request.setAttribute(DataSource.class.getName(), dataSource); }
Example #5
Source File: ChildrenDatasourceServlet.java From APM with Apache License 2.0 | 5 votes |
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) { Iterator<Resource> iterator = Optional.ofNullable(request.getResource()) .flatMap(parent -> Optional.ofNullable(parent.getChild("items"))) .map(items -> items.listChildren()) .orElse(Collections.emptyIterator()); DataSource dataSource = new SimpleDataSource(iterator); request.setAttribute(DataSource.class.getName(), dataSource); }
Example #6
Source File: CatalogIdentifierDatasource.java From commerce-cif-connector with Apache License 2.0 | 4 votes |
protected DataSource toDataSource(List<Resource> resources) { return resources.isEmpty() ? EmptyDataSource.instance() : new SimpleDataSource(resources.iterator()); }
Example #7
Source File: GraphqlClientDataSourceServlet.java From aem-core-cif-components with Apache License 2.0 | 4 votes |
@Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) { i18n = new I18n(request); SimpleDataSource graphqlClientDataSource = new SimpleDataSource(getGraphqlClients(request).iterator()); request.setAttribute(DataSource.class.getName(), graphqlClientDataSource); }
Example #8
Source File: SimpleDataSourceBuilder.java From APM with Apache License 2.0 | 4 votes |
public SimpleDataSource build() { List<Resource> resources = options.stream() .map(option -> createDataSourceItem(resourceResolver, option.name, option.value)) .collect(Collectors.toList()); return new SimpleDataSource(resources.iterator()); }