/** * Creates the {@link Descriptor}s for pagination parameters. * * @param type * @return */ private List<Descriptor> getPaginationDescriptors(Class<?> type, HttpMethod method) { RepositoryInformation information = repositories.getRequiredRepositoryInformation(type); if (!information.isPagingRepository() || !getType(method).equals(Type.SAFE)) { return Collections.emptyList(); } Link linkToCollectionResource = entityLinks.linkToCollectionResource(type); List<TemplateVariable> variables = linkToCollectionResource.getVariables(); List<Descriptor> descriptors = new ArrayList<Descriptor>(variables.size()); ProjectionDefinitionConfiguration projectionConfiguration = configuration.getProjectionConfiguration(); for (TemplateVariable variable : variables) { // Skip projection parameter if (projectionConfiguration.getParameterName().equals(variable.getName())) { continue; } ResourceDescription description = SimpleResourceDescription.defaultFor(variable.getDescription()); descriptors.add(// descriptor().// name(variable.getName()).// type(Type.SEMANTIC).// doc(getDocFor(description)).// build()); } return descriptors; }
/** * Returns template variables contained in the underlying Link with basic distinction of required and optional * variables based on the variable type. If actionDescriptors are present, they should be preferred over variables * because they consider the handler methods to determine if a variable is required or optional. * * @return variables */ @Override public List<TemplateVariable> getVariables() { return super.getVariables(); }
/** * Returns template variables contained in the underlying Link with basic distinction of required and optional * variables based on the variable type. If actionDescriptors are present, they should be preferred over variables * because they consider the handler methods to determine if a variable is required or optional. * * @return variables */ @Override public List<TemplateVariable> getVariables() { return super.getVariables(); }
/** * Creates the {@link Descriptor}s for pagination parameters. * * @param type * @return */ private List<Descriptor> getPaginationDescriptors(Class<?> type, HttpMethod method) { RepositoryInformation information = repositories.getRequiredRepositoryInformation(type); if (!information.isPagingRepository() || !getType(method).equals(Type.SAFE)) { return Collections.emptyList(); } Link linkToCollectionResource = entityLinks.linkToCollectionResource(type); List<TemplateVariable> variables = linkToCollectionResource.getVariables(); List<Descriptor> descriptors = new ArrayList<Descriptor>(variables.size()); ProjectionDefinitionConfiguration projectionConfiguration = configuration.getProjectionConfiguration(); for (TemplateVariable variable : variables) { // Skip projection parameter if (projectionConfiguration.getParameterName().equals(variable.getName())) { continue; } ResourceDescription description = SimpleResourceDescription.defaultFor(variable.getDescription()); descriptors.add(// descriptor().// name(variable.getName()).// type(Type.SEMANTIC).// doc(getDocFor(description)).// build()); } return descriptors; }
List<TemplateVariable> variables = link.getVariables(); boolean queryOnly = false; for (TemplateVariable variable : variables) {
List<TemplateVariable> variables = link.getVariables(); boolean queryOnly = false; for (TemplateVariable variable : variables) {
private void appendLinkWithoutActionDescriptor(Link link) throws IOException { if (link.isTemplated()) { // TODO ensure that template expansion takes place for base uri Link expanded = link.expand(); // remove query variables beginForm(OptionalAttributes.attr("action", expanded.getHref()) .and("method", "GET")); List<TemplateVariable> variables = link.getVariables(); for (TemplateVariable variable : variables) { String variableName = variable.getName(); String label = variable.hasDescription() ? variable.getDescription() : variableName; writeLabelWithDoc(label, variableName, null); // no documentation url input(variableName, Type.TEXT); } } else { String rel = link.getRel(); String title = (rel != null ? rel : link.getHref()); // TODO: write html <link> instead of anchor <a> here? writeAnchor(OptionalAttributes.attr("href", link.getHref()) .and("rel", link.getRel()), title); } }
private void appendLinkWithoutActionDescriptor(Link link) throws IOException { if (link.isTemplated()) { // TODO ensure that template expansion takes place for base uri Link expanded = link.expand(); // remove query variables beginForm(OptionalAttributes.attr("action", expanded.getHref()) .and("method", "GET")); List<TemplateVariable> variables = link.getVariables(); for (TemplateVariable variable : variables) { String variableName = variable.getName(); String label = variable.hasDescription() ? variable.getDescription() : variableName; writeLabelWithDoc(label, variableName, null); // no documentation url input(variableName, Type.TEXT); } } else { String rel = link.getRel(); String title = (rel != null ? rel : link.getHref()); // TODO: write html <link> instead of anchor <a> here? writeAnchor(OptionalAttributes.attr("href", link.getHref()) .and("rel", link.getRel()), title); } }