Package com.sun.star.rdf

Examples of com.sun.star.rdf.XDocumentRepository


            xComp = util.DesktopTools.loadDoc(xMSF, file, loadProps);

            XRepositorySupplier xRepoSupplier = UnoRuntime.queryInterface(XRepositorySupplier.class, xComp);
            assertTrue("xRS null", null != xRepoSupplier);

            XDocumentRepository xDocRepository = UnoRuntime.queryInterface(XDocumentRepository.class, xRepoSupplier.getRDFRepository());
            assertTrue("xRep null", null != xDocRepository);

            XTextDocument xTextDoc = UnoRuntime.queryInterface(XTextDocument.class, xComp);

            XText xText = xTextDoc.getText();

            XEnumerationAccess xEA = UnoRuntime.queryInterface(XEnumerationAccess.class, xText);
            XEnumeration xEnum = xEA.createEnumeration();

            System.out.println("...done");

            System.out.println("Checking RDFa in loaded test document...");

            XMetadatable xPara;
            Pair<Statement[], Boolean> result;

            Statement x_FooBarLit1 = new Statement(foo, bar, mkLit("1"), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 1",
                !result.Second &&
                eq(result.First, new Statement[] {
                        x_FooBarLit1
                    }));

            Statement x_FooBarLit2 = new Statement(foo, bar, mkLit("2"), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 2",
                !result.Second &&
                eq(result.First, new Statement[] {
                        x_FooBarLit2
                    }));

            Statement x_BlankBarLit3 =
                new Statement(blank1, bar, mkLit("3"), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 3",
                !result.Second &&
                eq(result.First, new Statement[] {
                        x_BlankBarLit3
                    }));
            XBlankNode b3 = UnoRuntime.queryInterface(XBlankNode.class, result.First[0].Subject);

            Statement x_BlankBarLit4 =
                new Statement(blank2, bar, mkLit("4"), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 4",
                !result.Second &&
                eq(result.First, new Statement[] {
                        x_BlankBarLit4
                    }));
            XBlankNode b4 = UnoRuntime.queryInterface(XBlankNode.class, result.First[0].Subject);

            Statement x_BlankBarLit5 =
                new Statement(blank1, bar, mkLit("5"), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 5",
                !result.Second &&
                eq(result.First, new Statement[] {
                        x_BlankBarLit5
                    }));
            XBlankNode b5 = UnoRuntime.queryInterface(XBlankNode.class, result.First[0].Subject);

            assertTrue("RDFa: 3 != 4",
                !b3.getStringValue().equals(b4.getStringValue()));
            assertTrue("RDFa: 3 == 5",
                 b3.getStringValue().equals(b5.getStringValue()));

            Statement x_FooBarLit6 = new Statement(foo, bar, mkLit("6"), null);
            Statement x_FooBazLit6 = new Statement(foo, baz, mkLit("6"), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 6",
                !result.Second &&
                eq(result.First, new Statement[] {
                        x_FooBarLit6, x_FooBazLit6
                    }));

            Statement x_FooBarLit7 = new Statement(foo, bar, mkLit("7"), null);
            Statement x_FooBazLit7 = new Statement(foo, baz, mkLit("7"), null);
            Statement x_FooFooLit7 = new Statement(foo, foo, mkLit("7"), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 7",
                !result.Second &&
                eq(result.First, new Statement[] {
                        x_FooBarLit7, x_FooBazLit7, x_FooFooLit7
                    }));

            XNode lit = mkLit("a fooish bar");
            XNode lit_type= mkLit("a fooish bar", bar);
            Statement x_FooBarLit = new Statement(foo, bar, lit, null);
            Statement x_FooBarLittype = new Statement(foo, bar, lit_type, null);

            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 8",
                result.Second &&
                eq(result.First, new Statement[] {
                        x_FooBarLit
                    }));

            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 9",
                result.Second &&
                eq(result.First, new Statement[] {
                        x_FooBarLit
                    }));

            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 10",
                result.Second &&
                eq(result.First, new Statement[] {
                        x_FooBarLittype
                    }));

            Statement x_FooBarLit11
                = new Statement(foo, bar, mkLit("11", bar), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 11",
                !result.Second &&
                eq(result.First, new Statement[] {
                        x_FooBarLit11
                    }));

            XURI xFile = URI.createNS(xContext, file, "/" + contentPath);
            Statement x_FileBarLit12 =
                new Statement(xFile, bar, mkLit("12"), null);
              xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 12",
                !result.Second &&
                eq(result.First, new Statement[] {
                        x_FileBarLit12
                    }));

            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 13",
                result.Second &&
                eq(result.First, new Statement[] {
                        x_FooBarLit
                    }));

            Statement x_FooLabelLit14 =
                new Statement(foo, rdfs_label, mkLit("14"), null);
            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 14",
                result.Second &&
                eq(result.First, new Statement[] {
                        /* x_FooLabelLit14 */ x_FooBarLit
                    }));

            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 15", eq(result.First, new Statement[] { } ));

            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 16", eq(result.First, new Statement[] { } ));

            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 17", eq(result.First, new Statement[] { } ));

            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 18", eq(result.First, new Statement[] { } ));

            xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 19", eq(result.First, new Statement[] { } ));

            xPara = UnoRuntime.queryInterface(
                XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 20", eq(result.First, new Statement[] { } ));

            xPara = UnoRuntime.queryInterface(
                XMetadatable.class, xEnum.nextElement());
            result = xDocRepository.getStatementRDFa(xPara);
            assertTrue("RDFa: 21", eq(result.First, new Statement[] { } ));

            System.out.println("...done");

        } catch (Exception e) {
View Full Code Here


        System.out.println("Checking bookmarks in loaded test document...");

        XRepositorySupplier xRS = (XRepositorySupplier)
            UnoRuntime.queryInterface(XRepositorySupplier.class, xTextDoc);
        XDocumentRepository xRepo = (XDocumentRepository)
            UnoRuntime.queryInterface(XDocumentRepository.class,
                xRS.getRDFRepository());
        XBookmarksSupplier xBMS = (XBookmarksSupplier)
            UnoRuntime.queryInterface(XBookmarksSupplier.class, xTextDoc);
        XNameAccess xBookmarks = xBMS.getBookmarks();
        XMetadatable xMark1 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xBookmarks.getByName("mk1"));
        assertTrue("mark1",
                eq(xMark1.getMetadataReference(),
                    new StringPair("content.xml", "id90")));

        XMetadatable xMark2 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xBookmarks.getByName("mk2"));
        Pair<Statement[], Boolean> result = xRepo.getStatementRDFa(xMark2);
        assertTrue("mark2", (result.First.length == 1)
            && result.First[0].Subject.getStringValue().equals("uri:foo")
            && result.First[0].Predicate.getStringValue().equals("uri:bar")
            && result.First[0].Object.getStringValue().contains("a fooish bar")
            );
View Full Code Here

        log.println("Checking bookmarks in loaded test document...");

        XRepositorySupplier xRS = (XRepositorySupplier)
            UnoRuntime.queryInterface(XRepositorySupplier.class, xTextDoc);
        XDocumentRepository xRepo = (XDocumentRepository)
            UnoRuntime.queryInterface(XDocumentRepository.class,
                xRS.getRDFRepository());
        XBookmarksSupplier xBMS = (XBookmarksSupplier)
            UnoRuntime.queryInterface(XBookmarksSupplier.class, xTextDoc);
        XNameAccess xBookmarks = xBMS.getBookmarks();
        XMetadatable xMark1 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xBookmarks.getByName("mk1"));
        assure("mark1",
                eq(xMark1.getMetadataReference(),
                    new StringPair("content.xml", "id90")));

        XMetadatable xMark2 = (XMetadatable) UnoRuntime.queryInterface(
                XMetadatable.class, xBookmarks.getByName("mk2"));
        Pair<Statement[], Boolean> result = xRepo.getStatementRDFa(xMark2);
        assure("mark2", (result.First.length == 1)
            && result.First[0].Subject.getStringValue().equals("uri:foo")
            && result.First[0].Predicate.getStringValue().equals("uri:bar")
            && result.First[0].Object.getStringValue().contains("a fooish bar")
            );
View Full Code Here

TOP

Related Classes of com.sun.star.rdf.XDocumentRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.