Package org.jrdf.graph

Examples of org.jrdf.graph.URIReference


        }
        performance.outputResult(graph, startTime, "Testing Update Performance: " + noUpdates);
    }

    private List<Triple> addTriplesToArray(Graph graph, URI subjectURI) throws Exception {
        URIReference newSubject = graph.getElementFactory().createURIReference(subjectURI);
        ClosableIterable<Triple> triples = findAllPredicates(graph, newSubject);
        List<Triple> triplesToChange = new ArrayList<Triple>();
        try {
            for (Triple triple : triples) {
                triplesToChange.add(triple);
View Full Code Here


            }
        }

        if (!"Description".equals(localName) || !namespaceURI.equals(BASE_URI_STR)) {
            // element name is uri's type
            URIReference className;
            if ("".equals(namespaceURI)) {
                // No namespace, use base URI
                className = buildResourceFromLocalName(localName);
            } else {
                className = createURIReference(namespaceURI + localName);
            }
            reportStatement(nodeResource, RDF_TYPE, className);
        }

        Att type = atts.removeAtt(BASE_URI_STR, "type");
        if (null != type) {
            // rdf:type attribute, value is a URI-reference
            URIReference className = buildURIFromReference(type.getValue());
            reportStatement(nodeResource, RDF_TYPE, className);
        }

        if (verifyData) {
            checkRdfAtts(atts);
View Full Code Here

        Iterator iter = atts.iterator();

        while (iter.hasNext()) {
            Att att = (Att) iter.next();
            URIReference predicate = createURIReference(att.getURI());
            Literal lit = createLiteral(att.getValue(), xmlLang, null);
            reportStatement(subject, predicate, lit);
        }
    }
View Full Code Here

        if (verifyData) {
            checkPropertyEltName(namespaceURI, localName, qName);
        }

        // Get the URI of the property
        URIReference propURI;
        if ("".equals(namespaceURI)) {
            // no namespace URI
            sendError("unqualified property element <" + qName + "> not allowed");
            // Use base URI as namespace:
            propURI = buildResourceFromLocalName(localName);
        } else {
            propURI = createURIReference(namespaceURI + localName);
        }

        // List expansion rule
        if (propURI.equals(RDF_LI)) {
            NodeElement subject = (NodeElement) peekStack(0);
            propURI = createURIReference(BASE_URI_STR + "_" + subject.getNextLiCounter());
        }

        // Push the property on the stack.
        PropertyElement predicate = new PropertyElement(propURI);
        elementStack.push(predicate);

        // Check if property has a reification ID
        Att id = atts.removeAtt(BASE_URI_STR, "ID");
        if (null != id) {
            URIReference reifURI = buildURIFromID(id.getValue());
            predicate.setReificationURI(reifURI);
        }

        // Check for presence of rdf:parseType attribute
        Att parseType = atts.removeAtt(BASE_URI_STR, "parseType");

        if (null != parseType) {
            if (verifyData) {
                checkNoMoreAtts(atts);
            }

            String parseTypeValue = parseType.getValue();

            if ("Resource".equals(parseTypeValue)) {
                BlankNode objectResource = createBNode();
                NodeElement subject = (NodeElement) peekStack(1);

                reportStatement(subject.getResource(), propURI, objectResource);

                if (isEmptyElt) {
                    handleReification(objectResource);
                } else {
                    NodeElement object = new NodeElement(objectResource);
                    object.setIsVolatile(true);
                    elementStack.push(object);
                }
            } else if ("Collection".equals(parseTypeValue)) {
                if (isEmptyElt) {
                    NodeElement subject = (NodeElement) peekStack(1);
                    reportStatement(subject.getResource(), propURI, RDF_NIL);
                    handleReification(RDF_NIL);
                } else {
                    predicate.setParseCollection(true);
                }
            } else {
                // other parseType
                if (!"Literal".equals(parseTypeValue)) {
                    sendWarning("unknown parseType: " + parseType.getValue());
                }

                if (isEmptyElt) {
                    NodeElement subject = (NodeElement) peekStack(1);

                    Literal lit = createLiteral("", null, RDF.XML_LITERAL.toString());

                    reportStatement(subject.getResource(), propURI, lit);

                    handleReification(lit);
                } else {
                    // The next string is an rdf:XMLLiteral
                    predicate.setDatatype(RDF.XML_LITERAL.toString());
                    saxFilter.setParseLiteralMode();
                }
            }
        } else if (isEmptyElt) {
            // empty element without an rdf:parseType attribute
            if (0 == atts.size() || 1 == atts.size() && atts.getAtt(RDF.BASE_URI.toString(), "datatype") != null) {
                // element had no attributes, or only the optional rdf:ID
                NodeElement subject = (NodeElement) peekStack(1);
                Literal lit = createLiteral("", xmlLang, null);
                reportStatement(subject.getResource(), propURI, lit);
                handleReification(lit);
            } else {
                // Create resource for the statement's object.
                SubjectNode resourceRes = getPropertyResource(atts);

                // All special rdf attributes have been checked/removed.
                if (verifyData) {
                    checkRdfAtts(atts);
                }

                NodeElement resourceElt = new NodeElement(resourceRes);
                NodeElement subject = (NodeElement) peekStack(1);

                reportStatement(subject.getResource(), propURI, (ObjectNode) resourceRes);
                handleReification((ObjectNode) resourceRes);

                Att type = atts.removeAtt(BASE_URI_STR, "type");
                if (null != type) {
                    // rdf:type attribute, value is a URI-reference
                    URIReference className = buildURIFromReference(type.getValue());
                    reportStatement(resourceRes, RDF_TYPE, className);
                }

                processSubjectAtts(resourceElt, atts);
            }
View Full Code Here

    private void handleReification(ObjectNode value) throws SAXException {
        PropertyElement predicate = (PropertyElement) peekStack(0);

        if (predicate.isReified()) {
            NodeElement subject = (NodeElement) peekStack(1);
            URIReference reifRes = predicate.getReificationURI();
            reifyStatement(reifRes, subject.getResource(), predicate.getURI(), value);
        }
    }
View Full Code Here

    private URIReference addCommonTriples(DOReader reader, Set<Triple> set)
            throws ResourceIndexException {

        try {

            URIReference objURI = new SimpleURIReference(
                    new URI(PID.toURI(reader.GetObjectPID())));

            addCoreObjectTriples(reader, objURI, set);

            Datastream[] datastreams = reader.GetDatastreams(null, null);
View Full Code Here

     */
    private void addCoreDatastreamTriples(Datastream ds,
                                          URIReference objURI,
                                          Set<Triple> set) throws Exception {

        URIReference dsURI = new SimpleURIReference(
                new URI(objURI.getURI().toString() + "/" + ds.DatastreamID));

        add(objURI, VIEW.DISSEMINATES, dsURI, set);

        URIReference dsDissType = new SimpleURIReference(
                new URI(FEDORA.uri + "*/" + ds.DatastreamID));

        add(dsURI, VIEW.DISSEMINATION_TYPE, dsDissType, set);

        boolean isVolatile =
View Full Code Here

    public Set<Triple> getTriplesForObject(DOReader reader)
            throws ResourceIndexException {
        Set<Triple> set = new HashSet<Triple>();

        try {
            URIReference objURI = new SimpleURIReference(
                    new URI(PID.toURI(reader.GetObjectPID())));

            /* Now add the SDef operation-specific triples */
            addMethodDefTriples(objURI, reader, set);
        } catch (Exception e) {
View Full Code Here

            r = m_manager.getReader(Server.USE_DEFINITIVE_STORE, context, pid);
            logger.debug("Getting Relationships:  pid = " + pid + " predicate = "
                         + relationship);
            try {
                URIReference pred = null;
                if (relationship != null) {
                    pred = new SimpleURIReference(new URI(relationship));
                }
                URIReference subj = null;
                if (subject != null) {
                    subj = new SimpleURIReference(new URI(SubjectProcessor.getSubjectAsUri(subject)));
                }
                Set<RelationshipTuple> tuples =
                        r.getRelationships(subj, pred, null);
View Full Code Here

     * Gets a localized URIReference based on the given Node.
     */
    private URIReference getLocalizedResource(Node n)
            throws GraphElementFactoryException {
        if (n instanceof URIReference) {
            URIReference u = (URIReference) n;
            return _connector.getElementFactory().createResource(u.getURI());
        } else {
            throw new RuntimeException("Error localizing triple; "
                    + n.getClass().getName() + " is not a URIReference");
        }
    }
View Full Code Here

TOP

Related Classes of org.jrdf.graph.URIReference

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.