@Test public void testRelatedLinks() { List<Link> links = dhn.relatedLinks(); assertEquals( 3, links.size() ); boolean sortBy = false; boolean sortByDesc = false; boolean requireToBe = false; for (Link l: links) { if (l.title().matches( ".*sort by *$" )) { sortBy = true; } if (l.title().matches( ".*sort by.*descending.*$" )) { sortByDesc = true; } if (l.title().matches( ".*require *to.*" )) { requireToBe = true; } } assertTrue( sortBy ); assertTrue( sortByDesc ); assertTrue( requireToBe ); }
public List<Link> relatedLinks() { List<Link> links = new ArrayList<Link>(); boolean isLiteral = rdfNode().isLiteral(); boolean isNumeric = isLiteral && (rdfNode().getValue() instanceof Number); Page page = rdfNode().page(); String param = pathTo().toString(); String paramHTML = pathTo.toHTMLString(); String valueStr = isLiteral ? rdfNode().getLexicalForm() : rdfNode.getName(); String valueLabel = "<code class='rdf-value'>" + StringEscapeUtils.escapeHtml( truncateToMaxLength( valueStr ) ) + "</code>"; if (isNumeric) { links.add( generateLink( "max-" + param, paramHTML, valueStr, valueLabel, "&le;", "filter-less-than", true, page )); } if (isLiteral) { links.add( generateLink( param, paramHTML, valueStr, valueLabel, "to be", "filter-equals", true, page )); } else if (!rdfNode().isAnon()){ String shortName = null; if (shortNameRenderer != null) { shortName = shortNameRenderer.lookupURI( rdfNode().getURI() ); } String uriValue = (shortName == null) ? rdfNode().getURI() : shortName; links.add( generateLink( param, paramHTML, uriValue, valueLabel, "to be", "filter-equals", true, page )); } if (isNumeric) { links.add( generateLink( "min-" + param, paramHTML, valueStr, valueLabel, "&ge;", "filter-greater-than", true, page )); } links.add( generateSortLink( param, paramHTML, "sort sort-asc", true, page )); links.add( generateSortLink( param, paramHTML, "sort sort-desc", false, page )); return links; }
DisplayHierarchyNode { public List<Link> relatedLinks() { List<Link> links = new ArrayList<Link>(); boolean isLiteral = rdfNode().isLiteral(); boolean isNumeric = isLiteral && (rdfNode().getValue() instanceof Number); Page page = rdfNode().page(); String param = pathTo().toString(); String paramHTML = pathTo.toHTMLString(); String valueStr = isLiteral ? rdfNode().getLexicalForm() : rdfNode.getName(); String valueLabel = "<code class='rdf-value'>" + StringEscapeUtils.escapeHtml( truncateToMaxLength( valueStr ) ) + "</code>"; if (isNumeric) { links.add( generateLink( "max-" + param, paramHTML, valueStr, valueLabel, "&le;", "filter-less-than", true, page )); } if (isLiteral) { links.add( generateLink( param, paramHTML, valueStr, valueLabel, "to be", "filter-equals", true, page )); } else if (!rdfNode().isAnon()){ String shortName = null; if (shortNameRenderer != null) { shortName = shortNameRenderer.lookupURI( rdfNode().getURI() ); } String uriValue = (shortName == null) ? rdfNode().getURI() : shortName; links.add( generateLink( param, paramHTML, uriValue, valueLabel, "to be", "filter-equals", true, page )); } if (isNumeric) { links.add( generateLink( "min-" + param, paramHTML, valueStr, valueLabel, "&ge;", "filter-greater-than", true, page )); } links.add( generateSortLink( param, paramHTML, "sort sort-asc", true, page )); links.add( generateSortLink( param, paramHTML, "sort sort-desc", false, page )); return links; } }
DisplayHierarchyNode { public List<Link> relatedLinks() { List<Link> links = new ArrayList<Link>(); boolean isLiteral = rdfNode().isLiteral(); boolean isNumeric = isLiteral && (rdfNode().getValue() instanceof Number); Page page = rdfNode().page(); String param = pathTo().toString(); String paramHTML = pathTo.toHTMLString(); String valueStr = isLiteral ? rdfNode().getLexicalForm() : rdfNode.getName(); String valueLabel = "<code class='rdf-value'>" + StringEscapeUtils.escapeHtml( truncateToMaxLength( valueStr ) ) + "</code>"; if (isNumeric) { links.add( generateLink( "max-" + param, paramHTML, valueStr, valueLabel, "&le;", "filter-less-than", true, page )); } if (isLiteral) { links.add( generateLink( param, paramHTML, valueStr, valueLabel, "to be", "filter-equals", true, page )); } else if (!rdfNode().isAnon()){ String shortName = null; if (shortNameRenderer != null) { shortName = shortNameRenderer.lookupURI( rdfNode().getURI() ); } String uriValue = (shortName == null) ? rdfNode().getURI() : shortName; links.add( generateLink( param, paramHTML, uriValue, valueLabel, "to be", "filter-equals", true, page )); } if (isNumeric) { links.add( generateLink( "min-" + param, paramHTML, valueStr, valueLabel, "&ge;", "filter-greater-than", true, page )); } links.add( generateSortLink( param, paramHTML, "sort sort-asc", true, page )); links.add( generateSortLink( param, paramHTML, "sort sort-desc", false, page )); return links; } DisplayHierarchyNode( PropertyPath pathTo, DisplayHierarchyNode parent,
                                 DisplayRdfNode rdfNode, ShortNameRenderer shortNameRenderer ); }
DisplayHierarchyNode { public List<Link> relatedLinks() { List<Link> links = new ArrayList<Link>(); boolean isLiteral = rdfNode().isLiteral(); boolean isNumeric = isLiteral && (rdfNode().getValue() instanceof Number); Page page = rdfNode().page(); String param = pathTo().toString(); String paramHTML = pathTo.toHTMLString(); String valueStr = isLiteral ? rdfNode().getLexicalForm() : rdfNode.getName(); String valueLabel = "<code class='rdf-value'>" + StringEscapeUtils.escapeHtml( truncateToMaxLength( valueStr ) ) + "</code>"; if (isNumeric) { links.add( generateLink( "max-" + param, paramHTML, valueStr, valueLabel, "&le;", "filter-less-than", true, page )); } if (isLiteral) { links.add( generateLink( param, paramHTML, valueStr, valueLabel, "to be", "filter-equals", true, page )); } else if (!rdfNode().isAnon()){ String shortName = null; if (shortNameRenderer != null) { shortName = shortNameRenderer.lookupURI( rdfNode().getURI() ); } String uriValue = (shortName == null) ? rdfNode().getURI() : shortName; links.add( generateLink( param, paramHTML, uriValue, valueLabel, "to be", "filter-equals", true, page )); } if (isNumeric) { links.add( generateLink( "min-" + param, paramHTML, valueStr, valueLabel, "&ge;", "filter-greater-than", true, page )); } links.add( generateSortLink( param, paramHTML, "sort sort-asc", true, page )); links.add( generateSortLink( param, paramHTML, "sort sort-desc", false, page )); return links; } DisplayHierarchyNode( PropertyPath pathTo, DisplayHierarchyNode parent,
                                 DisplayRdfNode rdfNode, ShortNameRenderer shortNameRenderer ); PropertyPath pathTo(); RDFNodeWrapper terminalLink(); boolean isOnExplicitPath(); Set<PropertyPath> explicitPaths(); DisplayHierarchyNode parent(); boolean isRoot(); DisplayRdfNode rdfNode(); boolean isLoop(); boolean findAncestor( DisplayRdfNode resource ); boolean isLeaf( DisplayHierarchyContext context ); List<DisplayHierarchyNode> children(); void addSibling( DisplayHierarchyNode sibling ); List<DisplayHierarchyNode> siblings(); boolean hasSiblings(); void addHint( String hint ); String hintsString(); boolean hasHint( String hint ); boolean isSimpleResource(); String relatedLinksHTML(); List<Link> relatedLinks(); boolean hasAllProperties( Object... properties ); boolean hasAllProperties( List<Object> properties ); void pullToStart( Object... properties ); void pullToStart( List<Object> properties ); List<DisplayHierarchyNode> extractByPredicate( Object... properties ); List<DisplayHierarchyNode> extractByPredicate( List<Object> properties ); boolean isResource(); boolean isLiteral(); boolean isAnon(); boolean isList(); String getLexicalForm(); String getName(); Object getValue(); String getURI(); @Override String toString(); }
DisplayHierarchyNode { public List<Link> relatedLinks() { List<Link> links = new ArrayList<Link>(); boolean isLiteral = rdfNode().isLiteral(); boolean isNumeric = isLiteral && (rdfNode().getValue() instanceof Number); Page page = rdfNode().page(); String param = pathTo().toString(); String paramHTML = pathTo.toHTMLString(); String valueStr = isLiteral ? rdfNode().getLexicalForm() : rdfNode.getName(); String valueLabel = "<code class='rdf-value'>" + StringEscapeUtils.escapeHtml( truncateToMaxLength( valueStr ) ) + "</code>"; if (isNumeric) { links.add( generateLink( "max-" + param, paramHTML, valueStr, valueLabel, "&le;", "filter-less-than", true, page )); } if (isLiteral) { links.add( generateLink( param, paramHTML, valueStr, valueLabel, "to be", "filter-equals", true, page )); } else if (!rdfNode().isAnon()){ String shortName = null; if (shortNameRenderer != null) { shortName = shortNameRenderer.lookupURI( rdfNode().getURI() ); } String uriValue = (shortName == null) ? rdfNode().getURI() : shortName; links.add( generateLink( param, paramHTML, uriValue, valueLabel, "to be", "filter-equals", true, page )); } if (isNumeric) { links.add( generateLink( "min-" + param, paramHTML, valueStr, valueLabel, "&ge;", "filter-greater-than", true, page )); } links.add( generateSortLink( param, paramHTML, "sort sort-asc", true, page )); links.add( generateSortLink( param, paramHTML, "sort sort-desc", false, page )); return links; } DisplayHierarchyNode( PropertyPath pathTo, DisplayHierarchyNode parent,
                                 DisplayRdfNode rdfNode, ShortNameRenderer shortNameRenderer ); PropertyPath pathTo(); RDFNodeWrapper terminalLink(); boolean isOnExplicitPath(); Set<PropertyPath> explicitPaths(); DisplayHierarchyNode parent(); boolean isRoot(); DisplayRdfNode rdfNode(); boolean isLoop(); boolean findAncestor( DisplayRdfNode resource ); boolean isLeaf( DisplayHierarchyContext context ); List<DisplayHierarchyNode> children(); void addSibling( DisplayHierarchyNode sibling ); List<DisplayHierarchyNode> siblings(); boolean hasSiblings(); void addHint( String hint ); String hintsString(); boolean hasHint( String hint ); boolean isSimpleResource(); String relatedLinksHTML(); List<Link> relatedLinks(); boolean hasAllProperties( Object... properties ); boolean hasAllProperties( List<Object> properties ); void pullToStart( Object... properties ); void pullToStart( List<Object> properties ); List<DisplayHierarchyNode> extractByPredicate( Object... properties ); List<DisplayHierarchyNode> extractByPredicate( List<Object> properties ); boolean isResource(); boolean isLiteral(); boolean isAnon(); boolean isList(); String getLexicalForm(); String getName(); Object getValue(); String getURI(); @Override String toString(); static final String SORT_BY_FORMAT; static final int MAX_RELATED_LINK_LABEL_LENGTH; }