Search in sources :

Example 1 with Assembler

use of org.apache.jena.assembler.Assembler in project jena by apache.

the class TestTextIndexLuceneAssembler method testMemDirectory.

@Test
public void testMemDirectory() {
    TextIndexLuceneAssembler assembler = new TextIndexLuceneAssembler();
    Resource root = SIMPLE_INDEX_SPEC_MEM_DIR;
    Assembler a = Assembler.general;
    // the open method is not supposed to throw exceptions when the directory is
    // a iri resource
    TextIndexLucene index = (TextIndexLucene) assembler.open(a, root, /*mode*/
    null);
    try {
        assertTrue(index.getDirectory() instanceof ByteBuffersDirectory);
    } finally {
        index.close();
    }
}
Also used : ByteBuffersDirectory(org.apache.lucene.store.ByteBuffersDirectory) Resource(org.apache.jena.rdf.model.Resource) Assembler(org.apache.jena.assembler.Assembler) TextIndexLucene(org.apache.jena.query.text.TextIndexLucene) Test(org.junit.Test)

Example 2 with Assembler

use of org.apache.jena.assembler.Assembler in project jena by apache.

the class TestTextIndexLuceneAssembler method testLiteralDirectory.

@Test
public void testLiteralDirectory() {
    TextIndexLuceneAssembler assembler = new TextIndexLuceneAssembler();
    Resource root = SIMPLE_INDEX_SPEC_LITERAL_DIR;
    Assembler a = Assembler.general;
    // the open method is not supposed to throw exceptions when the directory is
    // a literal
    TextIndexLucene index = (TextIndexLucene) assembler.open(a, root, /*mode*/
    null);
    try {
        assertNotNull(index);
    } finally {
        index.close();
    }
}
Also used : Resource(org.apache.jena.rdf.model.Resource) Assembler(org.apache.jena.assembler.Assembler) TextIndexLucene(org.apache.jena.query.text.TextIndexLucene) Test(org.junit.Test)

Example 3 with Assembler

use of org.apache.jena.assembler.Assembler in project jena by apache.

the class TestTextIndexLuceneAssembler method testResourceDirectory.

@Test
public void testResourceDirectory() {
    TextIndexLuceneAssembler assembler = new TextIndexLuceneAssembler();
    Resource root = SIMPLE_INDEX_SPEC2;
    Assembler a = Assembler.general;
    // the open method is not supposed to throw exceptions when the directory is
    // a resource
    TextIndexLucene index = (TextIndexLucene) assembler.open(a, root, /*mode*/
    null);
    try {
        assertFalse(index.getDirectory() instanceof ByteBuffersDirectory);
        assertNotNull(index.getQueryAnalyzer());
    } finally {
        index.close();
    }
}
Also used : ByteBuffersDirectory(org.apache.lucene.store.ByteBuffersDirectory) Resource(org.apache.jena.rdf.model.Resource) Assembler(org.apache.jena.assembler.Assembler) TextIndexLucene(org.apache.jena.query.text.TextIndexLucene) Test(org.junit.Test)

Example 4 with Assembler

use of org.apache.jena.assembler.Assembler in project jena by apache.

the class VocabRDFS method init.

public static synchronized void init() {
    if (initialized)
        return;
    initialized = true;
    AssemblerUtils.registerDataset(tDatasetRDFS, new DatasetRDFSAssembler());
    Assembler a = new GraphRDFSAssembler();
    AssemblerUtils.registerModel(tGraphRDFS, a);
    AssemblerUtils.registerModel(tModelRDFS, a);
}
Also used : Assembler(org.apache.jena.assembler.Assembler)

Example 5 with Assembler

use of org.apache.jena.assembler.Assembler in project jena by apache.

the class TestModelAssembler method testGetsPrefixMappings.

public void testGetsPrefixMappings() {
    Assembler a = new FakeModelAssembler();
    PrefixMapping wanted = PrefixMapping.Factory.create().setNsPrefix("my", "urn:secret:42/").setNsPrefix("your", "urn:public:17#");
    Resource root = resourceInModel("x rdf:type ja:DefaultModel; x ja:prefixMapping p1; x ja:prefixMapping p2" + "; p1 rdf:type ja:PrefixMapping; p1 ja:prefix 'my'; p1 ja:namespace 'urn:secret:42/'" + "; p2 rdf:type ja:PrefixMapping; p2 ja:prefix 'your'; p2 ja:namespace 'urn:public:17#'");
    Model m = (Model) a.open(Assembler.prefixMapping, root);
    assertSamePrefixMapping(wanted, m);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Resource(org.apache.jena.rdf.model.Resource) Model(org.apache.jena.rdf.model.Model) ModelAssembler(org.apache.jena.assembler.assemblers.ModelAssembler) Assembler(org.apache.jena.assembler.Assembler) ContentAssembler(org.apache.jena.assembler.assemblers.ContentAssembler)

Aggregations

Assembler (org.apache.jena.assembler.Assembler)9 Resource (org.apache.jena.rdf.model.Resource)5 TextIndexLucene (org.apache.jena.query.text.TextIndexLucene)3 Test (org.junit.Test)3 ByteBuffersDirectory (org.apache.lucene.store.ByteBuffersDirectory)2 File (java.io.File)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 Method (java.lang.reflect.Method)1 DirectoryStream (java.nio.file.DirectoryStream)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 java.util (java.util)1 Collectors.toList (java.util.stream.Collectors.toList)1 StringUtils (org.apache.commons.lang3.StringUtils)1 JA (org.apache.jena.assembler.JA)1 Mode (org.apache.jena.assembler.Mode)1 AssemblerBase (org.apache.jena.assembler.assemblers.AssemblerBase)1 AssemblerGroup (org.apache.jena.assembler.assemblers.AssemblerGroup)1 ExpandingAssemblerGroup (org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup)1