Search in sources :

Example 1 with OntDocumentManager

use of org.apache.jena.ontology.OntDocumentManager in project jena by apache.

the class DocumentManagerAssembler method open.

@Override
public Object open(Assembler a, Resource root, Mode irrelevant) {
    checkType(root, JA.DocumentManager);
    OntDocumentManager result = createDocumentManager();
    result.setMetadataSearchPath(getPath(a, root), false);
    result.configure(ResourceUtils.reachableClosure(root), false);
    result.setFileManager(getFileManager(a, root));
    return result;
}
Also used : OntDocumentManager(org.apache.jena.ontology.OntDocumentManager)

Example 2 with OntDocumentManager

use of org.apache.jena.ontology.OntDocumentManager in project jena by apache.

the class TestDocumentManagerAssembler method testSetsMetadata.

public void testSetsMetadata() {
    // we set policyPath to avoid Ont default models being thrown at us
    Resource root = resourceInModel("x rdf:type ja:DocumentManager; x ja:policyPath ''; x P a; a Q b; y R z");
    final Model expected = model("x rdf:type ja:DocumentManager; x ja:policyPath ''; x P a; a Q b");
    final List<String> history = new ArrayList<>();
    Assembler a = new DocumentManagerAssembler() {

        @Override
        protected OntDocumentManager createDocumentManager() {
            return new OntDocumentManager("") {

                @Override
                public void processMetadata(Model m) {
                    assertIsoModels(expected, m);
                    history.add("called");
                    super.processMetadata(m);
                }
            };
        }
    };
    OntDocumentManager d = (OntDocumentManager) a.open(root);
    assertEquals(listOfOne("called"), history);
}
Also used : DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) OntDocumentManager(org.apache.jena.ontology.OntDocumentManager) DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler)

Example 3 with OntDocumentManager

use of org.apache.jena.ontology.OntDocumentManager in project jena by apache.

the class TestDocumentManagerAssembler method testSetsPolicyPath.

public void testSetsPolicyPath() {
    Resource root = resourceInModel("x rdf:type ja:DocumentManager; x ja:policyPath 'somePath'");
    final List<String> history = new ArrayList<>();
    Assembler a = new DocumentManagerAssembler() {

        @Override
        protected OntDocumentManager createDocumentManager() {
            return new OntDocumentManager("") {

                @Override
                public void setMetadataSearchPath(String path, boolean replace) {
                    assertEquals(false, replace);
                    history.add(path);
                    super.setMetadataSearchPath(path, replace);
                }
            };
        }
    };
    OntDocumentManager d = (OntDocumentManager) a.open(root);
    assertEquals(listOfOne("somePath"), history);
}
Also used : DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler) OntDocumentManager(org.apache.jena.ontology.OntDocumentManager) DocumentManagerAssembler(org.apache.jena.assembler.assemblers.DocumentManagerAssembler)

Aggregations

OntDocumentManager (org.apache.jena.ontology.OntDocumentManager)3 DocumentManagerAssembler (org.apache.jena.assembler.assemblers.DocumentManagerAssembler)2