Search in sources :

Example 6 with Assembler

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

the class TestAssemblerGroup method testPassesSelfIn.

public void testPassesSelfIn() {
    final AssemblerGroup group = AssemblerGroup.create();
    final Object result = new Object();
    Assembler fake = new AssemblerBase() {

        @Override
        public Object open(Assembler a, Resource root, Mode irrelevant) {
            assertSame("nested call should pass in assembler group:", group, a);
            return result;
        }
    };
    group.implementWith(JA.Object, fake);
    assertSame(result, group.open(resourceInModel("x rdf:type ja:Object")));
}
Also used : Mode(org.apache.jena.assembler.Mode) Resource(org.apache.jena.rdf.model.Resource) ExpandingAssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup.ExpandingAssemblerGroup) AssemblerGroup(org.apache.jena.assembler.assemblers.AssemblerGroup) Assembler(org.apache.jena.assembler.Assembler) InfModelAssembler(org.apache.jena.assembler.assemblers.InfModelAssembler) AssemblerBase(org.apache.jena.assembler.assemblers.AssemblerBase)

Example 7 with Assembler

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

the class InitGeoSPARQL method start.

@Override
public void start() {
    // SIS uses JUL for logging.
    LogCtlJUL.routeJULtoSLF4J();
    JenaSystem.logLifecycle("InitGeoSPARQL - start");
    GeometryDatatype.registerDatatypes();
    // Logs "SIS_DATA is not set"
    GeoSPARQLConfig.loadFunctions();
    Assembler assembler = new GeoAssembler();
    AssemblerUtils.registerDataset(VocabGeoSPARQL.tGeoDataset, assembler);
    AssemblerUtils.registerDataset(VocabGeoSPARQL.tGeoDatasetAlt, assembler);
    JenaSystem.logLifecycle("InitGeoSPARQL - finish");
}
Also used : Assembler(org.apache.jena.assembler.Assembler) GeoAssembler(org.apache.jena.geosparql.assembler.GeoAssembler) GeoAssembler(org.apache.jena.geosparql.assembler.GeoAssembler)

Example 8 with Assembler

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

the class TestModelSourceAssembler method testMemModelMakerSource.

public void testMemModelMakerSource() {
    Assembler a = new ModelSourceAssembler();
    ModelGetter g = (ModelGetter) a.open(resourceInModel("mg rdf:type ja:ModelSource"));
    assertInstanceOf(MemoryModelGetter.class, g);
}
Also used : ModelSourceAssembler(org.apache.jena.assembler.assemblers.ModelSourceAssembler) ModelGetter(org.apache.jena.rdf.model.ModelGetter) MemoryModelGetter(org.apache.jena.rdf.model.impl.MemoryModelGetter) Assembler(org.apache.jena.assembler.Assembler) ModelSourceAssembler(org.apache.jena.assembler.assemblers.ModelSourceAssembler)

Example 9 with Assembler

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

the class FusekiConfig method readConfigurationDirectory.

// ---- Directory of assemblers
/**
 * Read service descriptions in the given directory
 */
public static List<DataAccessPoint> readConfigurationDirectory(String dir) {
    Path pDir = Path.of(dir).normalize();
    File dirFile = pDir.toFile();
    if (!dirFile.exists()) {
        log.warn("Not found: directory for assembler files for services: '" + dir + "'");
        return Collections.emptyList();
    }
    if (!dirFile.isDirectory()) {
        log.warn("Not a directory: '" + dir + "'");
        return Collections.emptyList();
    }
    // Files that are not hidden.
    DirectoryStream.Filter<Path> filter = (entry) -> {
        File f = entry.toFile();
        final Lang lang = filenameToLang(f.getName());
        return !f.isHidden() && f.isFile() && lang != null && isRegistered(lang);
    };
    List<DataAccessPoint> dataServiceRef = new ArrayList<>();
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(pDir, filter)) {
        for (Path p : stream) {
            DatasetDescriptionMap dsDescMap = new DatasetDescriptionMap();
            String fn = IRILib.filenameToIRI(p.toString());
            log.info("Load configuration: " + fn);
            Model m = readAssemblerFile(fn);
            readConfiguration(m, dsDescMap, dataServiceRef);
        }
    } catch (IOException ex) {
        log.warn("IOException:" + ex.getMessage(), ex);
    }
    return dataServiceRef;
}
Also used : Path(java.nio.file.Path) Context(org.apache.jena.sparql.util.Context) java.util(java.util) RDF(org.apache.jena.vocabulary.RDF) Auth(org.apache.jena.fuseki.auth.Auth) AuthPolicy(org.apache.jena.fuseki.auth.AuthPolicy) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) FmtUtils(org.apache.jena.sparql.util.FmtUtils) StringUtils(org.apache.commons.lang3.StringUtils) StrUtils(org.apache.jena.atlas.lib.StrUtils) RDFParserRegistry.isRegistered(org.apache.jena.riot.RDFParserRegistry.isRegistered) JA(org.apache.jena.assembler.JA) DirectoryStream(java.nio.file.DirectoryStream) QuerySolution(org.apache.jena.query.QuerySolution) GraphUtils(org.apache.jena.sparql.util.graph.GraphUtils) Fuseki(org.apache.jena.fuseki.Fuseki) FusekiException(org.apache.jena.fuseki.FusekiException) Method(java.lang.reflect.Method) Path(java.nio.file.Path) Dataset(org.apache.jena.query.Dataset) BuildLib.nodeLabel(org.apache.jena.fuseki.build.BuildLib.nodeLabel) FusekiVocab(org.apache.jena.fuseki.server.FusekiVocab) Lang(org.apache.jena.riot.Lang) Logger(org.slf4j.Logger) Assembler(org.apache.jena.assembler.Assembler) Files(java.nio.file.Files) ActionService(org.apache.jena.fuseki.servlets.ActionService) BuildLib.getZeroOrOne(org.apache.jena.fuseki.build.BuildLib.getZeroOrOne) IOException(java.io.IOException) org.apache.jena.fuseki.server(org.apache.jena.fuseki.server) String.format(java.lang.String.format) RDFLanguages.filenameToLang(org.apache.jena.riot.RDFLanguages.filenameToLang) File(java.io.File) org.apache.jena.rdf.model(org.apache.jena.rdf.model) IRILib(org.apache.jena.atlas.lib.IRILib) FusekiConfigException(org.apache.jena.fuseki.FusekiConfigException) Collectors.toList(java.util.stream.Collectors.toList) Util(org.apache.jena.rdf.model.impl.Util) Node(org.apache.jena.graph.Node) XSDDatatype(org.apache.jena.datatypes.xsd.XSDDatatype) ReadWrite(org.apache.jena.query.ReadWrite) Pair(org.apache.jena.atlas.lib.Pair) AssemblerUtils(org.apache.jena.sparql.core.assembler.AssemblerUtils) JenaException(org.apache.jena.shared.JenaException) AuthPolicyList(org.apache.jena.fuseki.auth.AuthPolicyList) ResultSet(org.apache.jena.query.ResultSet) DirectoryStream(java.nio.file.DirectoryStream) Lang(org.apache.jena.riot.Lang) RDFLanguages.filenameToLang(org.apache.jena.riot.RDFLanguages.filenameToLang) IOException(java.io.IOException) File(java.io.File)

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