Package org.trippi

Examples of org.trippi.TripleIterator


        // delete all triples from the RI
        File dump = new File(TEST_DIR + "/all-triples.txt");
        FileOutputStream out = null;
        try {
            // write all to temp file
            TripleIterator triples = _ri.findTriples(null, null, null, -1);
            out = new FileOutputStream(dump);
            triples.toStream(out, RDFFormat.TURTLE);
            try {
                out.close();
            } catch (Exception e) {
            }
            out = null;
View Full Code Here


    protected Set<Triple> getActualTriples(SubjectNode subject,
                                           PredicateNode predicate,
                                           ObjectNode object) throws Exception {
        Set<Triple> set = new HashSet<Triple>();
        TripleIterator iter = _ri.findTriples(subject, predicate, object, -1);
        while (iter.hasNext()) {
            set.add(iter.next());
        }
        iter.close();
        return set;
    }
View Full Code Here

        private RDFDataModel() {
        } // only for use by clone

        public RDFDataModel(InputStream data) {
            TripleIterator iter;
            try {
                iter = m_factory.fromStream(data, RDFFormat.RDF_XML);
                entries = new ArrayList<RelationshipTuple>();
                for (int i = 0; iter.hasNext(); i++) {
                    Triple triple = iter.next();
                    String object = null;
                    boolean isLiteral = false;
                    URI typeURI = null;
                    ObjectNode oNode = triple.getObject();
                    if (oNode instanceof Literal) {
View Full Code Here

        String query =
                String.format("<info:fedora/%s> <%s> *",
                              pid,
                              Constants.MODEL.CREATED_DATE.uri);
        TripleIterator results = spo(query);

        try {
            assertTrue(results.hasNext());
            ObjectNode dateNode = results.next().getObject();
            assertTrue(dateNode instanceof Literal);
            Literal dateLiteral = (Literal) dateNode;
            assertEquals(dateLiteral.getDatatypeURI().toString(),
                         Constants.RDF_XSD.DATE_TIME.uri);
            assertEquals(xsdDateTime, dateLiteral.getLexicalForm());
        } finally {
            results.close();
        }
    }
View Full Code Here

        }
    }

    private void validateAndClear(String dsId) throws Exception {
        try {
            TripleIterator iter = new MockTripleIterator(triples);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            iter.toStream(out, RDFFormat.RDF_XML, false);
            new RelsValidator().validate(pid, dsId, new ByteArrayInputStream(out.toByteArray()));
        } finally {
            triples.clear();
        }
    }
View Full Code Here

                                   String o,
                                   boolean exists) throws TrippiException,
            UnsupportedEncodingException {
        StringBuilder sb = new StringBuilder();
        sb.append("RDF: " + new String(rdf, "UTF-8"));
        TripleIterator it =
                TripleIteratorFactory.defaultInstance().fromStream(new ByteArrayInputStream(rdf), null,
                RDFFormat.RDF_XML);

        boolean found = false;
        while (it.hasNext()) {
            Triple t = it.next();

            sb.append(t.getSubject().stringValue() + ", ");
            sb.append(t.getPredicate().stringValue() + ", ");
            sb.append(t.getObject().stringValue() + "\n");
View Full Code Here

            }
        } else {
            query = String.format("* <%s> <%s>", predicate, object);
        }

        TripleIterator triples = queryRI(query);
        try {
            assertTrue("Relationship not found in RI (query = " + query + ")",
                       triples.hasNext());
            while (triples.hasNext()) {
                assertEquals(triples.next().getSubject().stringValue(),
                             subjectAsURI(subject));
            }
        } finally {
            triples.close();
        }
    }
View Full Code Here

TOP

Related Classes of org.trippi.TripleIterator

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.