/** * {@inheritDoc} */ @Override public RDFList createList(Iterator<? extends RDFNode> members) { return super.object.createList(members); }
/** * {@inheritDoc} */ @Override public RDFList createList() { return super.object.createList(); }
/** * {@inheritDoc} */ @Override public RDFList createList(RDFNode[] members) { return super.object.createList(members); }
public RDFList createList(Iterator<? extends RDFNode> members) { return model.createList(members); }
public RDFList createList(RDFNode[] members) { return model.createList(members); }
public RDFList createList() { return model.createList(); }
private RDFList serializeToList(Collection c, ClassMeta<?> type) throws Exception { ClassMeta<?> elementType = type.getElementType(); List<RDFNode> l = new ArrayList<>(c.size()); for (Object e : c) { l.add(serializeAnything(e, false, elementType, null, null, null)); } return model.createList(l.iterator()); }
private void writeManifest(ArrayList<Resource> testcases, String localName, String label, String description) { if (testcases.size() == 0) return; Resource manifest = model.createResource(namespace + localName+"Manifest", TestManifest.Manifest); manifest.addProperty(DCTerms.title, label); manifest.addProperty(TestManifest.name, label); manifest.addProperty(RDFS.comment, description); Resource[] ra={}; RDFList l = model.createList(testcases.toArray(ra)); manifest.addProperty(TestManifest.entries, l); }
protected RDFNode decodeList(JsonArray array) throws JsonException { if (array.size() == 0) { return RDF.nil; } else { RDFNode[] listContents = new RDFNode[ array.size() ]; for (int i = 0; i < array.size(); i++) { listContents[i] = decodeNode(array.get(i), null); } return model.createList(listContents); } }
private FeedRenderer makeDateFeedRenderer(Property ...properties) { RDFList l = configModel.createList( properties ); config.addProperty( ELDA_API.feedDateProperties, l ); return makeFeedRenderer(config); }
@Test public void testRendersFeedAuthorsIfPresent() { Resource a = configModel.createProperty( "eh:/author_A" ); RDFNode b = configModel.createLiteral( "author_B" ); // RDFNode[] properties = new RDFNode[] {a, b}; RDFList authors = configModel.createList( properties ); config.addProperty( ELDA_API.feedAuthors, authors ); // String rendering = renderFeed(); // if (!rendering.contains( "<author>" + a.toString() + "</author>" )) { fail( "rendering\n" + rendering + "\nshould contain author\n" + a ); } // if (!rendering.contains( "<author>" + b.toString() + "</author>" )) { fail( "rendering\n" + rendering + "\nshould contain author\n" + b ); } }
@Test public void testDeConfiguredRightsProperties() { Property a = configModel.createProperty( "eh:/a" ); Property b = configModel.createProperty( "eh:/b" ); Property c = configModel.createProperty( "eh:/c" ); Property[] properties = new Property[] {a, b, c}; RDFList l = configModel.createList( properties ); config.addProperty( ELDA_API.feedRightsProperties, l ); FeedRenderer fr = makeFeedRenderer( config ); assertEquals( Arrays.asList( properties ), fr.getRightsProperties() ); }
@Test public void testRendersEntryAuthorsIfPresent() { Property a = configModel.createProperty( "eh:/author_A" ); Property b = configModel.createProperty( "eh:/author_B" ); RDFNode[] properties = new RDFNode[] {a, b}; RDFList authors = configModel.createList( properties ); config.addProperty( ELDA_API.feedAuthorProperties, authors ); // item.addProperty( a, "the author is A" ); item.addProperty( b, "the author is B" ); String rendering = renderFeed(); // if (!rendering.contains( "<author>the author is A</author>" )) { fail( "rendering\n" + rendering + "\nshould contain author\n" + a ); } // if (rendering.contains( "<author>the author is B</author>" )) { fail( "rendering\n" + rendering + "\nshould not contain author\n" + b ); } }
@Test public void testConfiguredAuthors() { Literal a = configModel.createLiteral( "author_A" ); Resource b = configModel.createResource( "eh:/authorB" ); RDFNode[] properties = new RDFNode[] {a, b}; RDFList l = configModel.createList( properties ); config.addProperty( ELDA_API.feedAuthors, l ); FeedRenderer fr = makeFeedRenderer( config ); assertEquals( list( a, b ), fr.getAuthors() ); }
@Test public void testConfiguredAuthorProperties() { Property a = configModel.createProperty( "eh:/A" ); Property b = configModel.createProperty( "eh:/B" ); // Property[] properties = new Property[] {a, b}; RDFList l = configModel.createList( properties ); config.addProperty( ELDA_API.feedAuthorProperties, l ); // FeedRenderer fr = makeFeedRenderer( config ); assertEquals( list(a, b), fr.getAuthorProperties() ); }
@Test public void testRendersManagesCyclesIfPresent() { Property a = configModel.createProperty( "eh:/author_A" ); Property b = configModel.createProperty( "eh:/author_B" ); RDFNode[] properties = new RDFNode[] {a, b}; RDFList authors = configModel.createList( properties ); config.addProperty( ELDA_API.feedAuthorProperties, authors ); // item.addProperty( a, "the author is A" ); item.addProperty( b, "the author is B" ); item.addProperty( a, item ); // renderFeed(); // // we don't get here if the cycle isn't handled. }
private void ensureRendering( String wrapped, Resource root ) { Model m = root.getModel(); // PrefixMapping pm = root.getModel(); ShortnameService sns = new SNS("P=eh:/P; Q=eh:/Q; R=eh:/R; HAS=eh:/HAS" ); // XMLRenderer xr = new XMLRenderer( sns ); Document d = DOMUtils.newDocument(); MergedModels mm = new MergedModels( m ); // Model meta = mm.getMetaModel(); meta.add( root, API.items, meta.createList( new RDFNode[] {root} ) ); xr.renderInto( root.inModel( meta ), mm, d, new HashMap<String, String>() ); // Node de = d.getDocumentElement().getFirstChild(); Node expected = new TinyParser().parse( wrapped ); // if (!de.isEqualNode( expected )) { String exp = DOMUtils.renderNodeToString( new Times(), expected, pm ); String obt = DOMUtils.renderNodeToString( new Times(), de, pm ); fail( "ALAS -- rendering not as expected:\n" + exp + "obtained:\n" + obt ); } }
Literal c = config.createTypedLiteral( number ); Resource operand = config.createList( new RDFNode[] {a, b, c} ); endpoint.addProperty( ELDA_API.textSearchOperand, operand ); final Source s = new HereSource( config, endpoint );
@Test public void testXML() throws IOException { XMLRenderer x = new XMLRenderer( new SNS("value=" + RDF.value.getURI() + ";it=eh:/it") ); Times t = new Times(); Bindings rc = new Bindings(); Map<String, String> termBindings = new HashMap<String, String>(); // Resource root = model.createResource( "eh:/root" ); RDFList l = model.createList( new RDFNode[] {item} ); model.add( root, API.items, l ); // APIResultSet results = new APIResultSet ( model.getGraph() , items , true , false , "the details query" , View.DESCRIBE ); results.setRoot(root); // results.getModels().getMetaModel().add( root, API.items, l ); // ByteArrayOutputStream os = new ByteArrayOutputStream(); Renderer.BytesOut bo = x.render(t, rc, termBindings, results); bo.writeAll(t, os); // String content = UTF8.toString( os ); // Assert.assertNotNull(content); }
@Test public void testTextSearchListOperand() { Resource config = model.createResource( "eh:/spec" ); Resource endpoint = model.createResource( "eh:/sparql" ); // Resource a = model.createResource( "eh:/a" ); Literal b = model.createLiteral( "b" ); Literal c = model.createLiteral( "?c" ); // Resource operand = model.createList( new RDFNode[] {a, b, c} ); // endpoint.addProperty( ELDA_API.textSearchOperand, operand ); config.addProperty( API.sparqlEndpoint, endpoint ); Source s = GetDataSource.sourceFromSpec( fm, config, am ); // Any qA = RDFQ.uri( a ); Any qB = RDFQ.literal( b.getLexicalForm() ); Any qC = RDFQ.literal( c.getLexicalForm() ); // AnyList expected = RDFQ.list( qA, qB, qC ); assertEquals( expected, s.getTextSearchConfig().getTextSearchOperand() ); }