Package org.apache.marmotta.commons.sesame.facading.api

Examples of org.apache.marmotta.commons.sesame.facading.api.Facading


        subject = repositoryRDF.getValueFactory().createURI("urn:", UUID.randomUUID().toString());
        random = new Random();

        facadingConnection = repositoryRDF.getConnection();
        facadingConnection.begin();
        final Facading factory = FacadingFactory.createFacading(facadingConnection);
        primitive = factory.createFacade(subject, Primitive.class);

    }
View Full Code Here


        e = new Date(a.getTime() + rnd.nextInt(tenYrsInMin) * 60000L);

        final RepositoryConnection connection = repositoryRDF.getConnection();
        try {
            connection.begin();
            final Facading facading = FacadingFactory.createFacading(connection);

            URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/collections");
            CollectionFacade facade = facading.createFacade(uri, CollectionFacade.class);

            facade.setDates(Arrays.asList(a, b, c));
            Assert.assertThat(facade.getDates(), hasItems(a, b, c));

            facade.addDate(e);
View Full Code Here

        final RepositoryConnection connection = repositoryRDF.getConnection();

        String a1 = UUID.randomUUID().toString(), a2 = UUID.randomUUID().toString(), a3 = UUID.randomUUID().toString();

        try {
            final Facading facading = FacadingFactory.createFacading(connection);
            connection.begin();

            URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/document");
            CollectionFacade facade = facading.createFacade(uri, CollectionFacade.class);

            facade.setAutors(Arrays.asList(a1, a2));

            facade.addAutor(a3);
View Full Code Here

                lbl_none = lbl + ": " + none.toString();

        final RepositoryConnection connection = repositoryRDF.getConnection();
        try {
            connection.begin();
            final Facading facading = FacadingFactory.createFacading(connection);

            final URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/locale");
            final LocaleFacade f = facading.createFacade(uri, LocaleFacade.class);

            f.setLabel(lbl);
            assertEquals(lbl, f.getLabel());
            assertNull(f.getLabel(none));
View Full Code Here

        c = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
        d = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);
        e = new Date(a.getTime() + rnd.nextInt(tenYrsInSecs) * 1000L);

        try {
            final Facading facading = FacadingFactory.createFacading(connection);

            URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/collections");
            CollectionFacade facade = facading.createFacade(uri, CollectionFacade.class);

            facade.setDates(Arrays.asList(a, b, c));
            Assert.assertThat(facade.getDates(), hasItems(a, b, c));

            facade.addDate(e);
View Full Code Here

        final RepositoryConnection connection = repositoryRDF.getConnection();

        String a1 = UUID.randomUUID().toString(), a2 = UUID.randomUUID().toString(), a3 = UUID.randomUUID().toString();

        try {
            final Facading facading = FacadingFactory.createFacading(connection);

            URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/document");
            CollectionFacade facade = facading.createFacade(uri, CollectionFacade.class);

            facade.setAutors(Arrays.asList(a1, a2));

            facade.addAutor(a3);
View Full Code Here

            while(triples.hasNext()) {
                resources.add(triples.next().getSubject());
            }
            triples.close();

            Facading facading = FacadingFactory.createFacading(connectionRDF);

            // test individual resource
            URI u_hans_meier = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
            URI u_anna_schmidt = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/anna_schmidt");
            Person hans_meier = facading.createFacade(u_hans_meier,Person.class);

            Assert.assertEquals("Hans Meier",hans_meier.getName());
            Assert.assertEquals(2,hans_meier.getFriends().size());
            Assert.assertThat(hans_meier.getOnlineAccounts(),
                    CoreMatchers.<OnlineAccount> hasItem(hasProperty("accountName", is("Example"))));

            Assert.assertThat(hans_meier.getFriends(), allOf(
                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Anna Schmidt"))),
                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Sepp Huber")))
                    ));

            // test collection
            Collection<Person> persons = facading.createFacade(resources,Person.class);
            Assert.assertEquals(3, persons.size());
            Assert.assertThat(persons,allOf(
                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Hans Meier"))),
                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Anna Schmidt"))),
                    CoreMatchers.<Person> hasItem(hasProperty("name", is("Sepp Huber")))
View Full Code Here

                lbl_fr = lbl + ": " + fr.toString(),
                lbl_none = lbl + ": " + none.toString();

        final RepositoryConnection connection = repositoryRDF.getConnection();
        try {
            final Facading facading = FacadingFactory.createFacading(connection);

            final URI uri = connection.getValueFactory().createURI("http://www.example.com/rdf/test/locale");
            final LocaleFacade f = facading.createFacade(uri, LocaleFacade.class);

            f.setLabel(lbl);
            assertEquals(lbl, f.getLabel());
            assertNull(f.getLabel(none));
View Full Code Here

            while(triples.hasNext()) {
                resources.add(triples.next().getSubject());
            }
            triples.close();

            Facading facading = FacadingFactory.createFacading(connectionRDF);

            // test individual resource
            URI u_hans_meier = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
            Person hans_meier = facading.createFacade(u_hans_meier,Person.class);

            Assert.assertNull(hans_meier.getNick());

            // set nick name and check if it is now set
            hans_meier.setNick("hansi");
            Assert.assertNotNull(hans_meier.getNick());
            Assert.assertEquals("hansi",hans_meier.getNick());

            // check in triple store if the triple is there
            URI p_foaf_nick = connectionRDF.getValueFactory().createURI(Namespaces.NS_FOAF + "nick");
            RepositoryResult<Statement> nicknames = connectionRDF.getStatements(u_hans_meier,p_foaf_nick,null,true);
            Assert.assertTrue(nicknames.hasNext());
            Assert.assertEquals("hansi",nicknames.next().getObject().stringValue());
            nicknames.close();

            // test creating a completely new resource
            URI u_fritz_fischer = connectionRDF.getValueFactory().createURI("http://localhost:8080/LMF/resource/fritz_fischer");
            Person fritz_fischer = facading.createFacade(u_fritz_fischer,Person.class);
            fritz_fischer.setName("Fritz Fischer");

            Assert.assertEquals("Fritz Fischer", fritz_fischer.getName());

            // test if it is now there
View Full Code Here

    @Test
    public void testReadInverseRDF() throws RepositoryException {

        final RepositoryConnection connection = repositoryRDF.getConnection();
        try {
            final Facading facading = FacadingFactory.createFacading(connection);

            URI u_hans_meier = connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier");
            Person hans_meier = facading.createFacade(u_hans_meier, Person.class);
            Assume.assumeThat("Could not load test-person", hans_meier, notNullValue(Person.class));

            for (OnlineAccount account : hans_meier.getOnlineAccounts()) {
                Assert.assertNotNull(account);
                final Resource accountRSC = account.getDelegate();
                Assert.assertNotNull(accountRSC);

                final OnlineAccount oa = facading.createFacade(accountRSC, OnlineAccount.class);
                Assert.assertNotNull(oa);

                Assert.assertEquals(hans_meier, oa.getHolder());
            }
View Full Code Here

TOP

Related Classes of org.apache.marmotta.commons.sesame.facading.api.Facading

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.