Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.MGraph.filter()


        mGraph.add(new TripleImpl(bNode, uriRef1, uriRef2));
        mGraph.add(new TripleImpl(bNodeClone, uriRef2, uriRef3));
        NonLiteral bNodeBack = mGraph.filter(null, uriRef1, uriRef2).next().getSubject();
        Assert.assertEquals("The bnode we get back is not equals to the one we added", bNode, bNodeBack);
        NonLiteral bNodeBack2 = mGraph.filter(null, uriRef2, uriRef3).next().getSubject();
        Assert.assertEquals("The returnned bnodes are no longer equals", bNodeBack, bNodeBack2);
        Assert.assertTrue("Not finding a triple when searching with equal bNode", mGraph.filter(bNodeBack, uriRef2, null).hasNext());
    }
    @Test
    public void iteratorRemove() {
View Full Code Here


        mGraph.add(new TripleImpl(bNodeClone, uriRef2, uriRef3));
        NonLiteral bNodeBack = mGraph.filter(null, uriRef1, uriRef2).next().getSubject();
        Assert.assertEquals("The bnode we get back is not equals to the one we added", bNode, bNodeBack);
        NonLiteral bNodeBack2 = mGraph.filter(null, uriRef2, uriRef3).next().getSubject();
        Assert.assertEquals("The returnned bnodes are no longer equals", bNodeBack, bNodeBack2);
        Assert.assertTrue("Not finding a triple when searching with equal bNode", mGraph.filter(bNodeBack, uriRef2, null).hasNext());
    }
    @Test
    public void iteratorRemove() {
        TripleCollection itc = new IndexedTripleCollection();
        itc.add(triple1);
View Full Code Here

        MGraph rolesGraph = getUserRolesGraph(userName);

        ArrayList<String> userRoleNames = new ArrayList<String>();

        Iterator<Triple> userRoleTriples = rolesGraph.filter(null, RDF.type, PERMISSION.Role);
        while (userRoleTriples.hasNext()) {
            Triple triple = userRoleTriples.next();
            GraphNode roleNode = new GraphNode(triple.getSubject(), rolesGraph);

            Iterator<Literal> titlesIterator = roleNode.getLiterals(DC.title);
View Full Code Here

        // available
        String contentLangauge;
        ci.getLock().readLock().lock();
        try {
            contentLangauge = EnhancementEngineHelper.getLanguage(ci);
            for (Iterator<Triple> it = graph.filter(null, RDF_TYPE, TechnicalClasses.ENHANCER_TEXTANNOTATION); it
                    .hasNext();) {
                UriRef uri = (UriRef) it.next().getSubject();
                if (graph.filter(uri, Properties.DC_RELATION, null).hasNext()) {
                    // this is not the most specific occurrence of this name:
                    // skip
View Full Code Here

        try {
            contentLangauge = EnhancementEngineHelper.getLanguage(ci);
            for (Iterator<Triple> it = graph.filter(null, RDF_TYPE, TechnicalClasses.ENHANCER_TEXTANNOTATION); it
                    .hasNext();) {
                UriRef uri = (UriRef) it.next().getSubject();
                if (graph.filter(uri, Properties.DC_RELATION, null).hasNext()) {
                    // this is not the most specific occurrence of this name:
                    // skip
                    continue;
                }
                NamedEntity namedEntity = NamedEntity.createFromTextAnnotation(graph, uri);
View Full Code Here

                NamedEntity namedEntity = NamedEntity.createFromTextAnnotation(graph, uri);
                if (namedEntity != null) {
                    // This is a first occurrence, collect any subsumed
                    // annotations
                    List<UriRef> subsumed = new ArrayList<UriRef>();
                    for (Iterator<Triple> it2 = graph.filter(null, Properties.DC_RELATION, uri); it2
                            .hasNext();) {
                        subsumed.add((UriRef) it2.next().getSubject());
                    }
                    textAnnotations.put(namedEntity, subsumed);
                }
View Full Code Here

        MGraph graph = contentItem.getMetadata();
        LiteralFactory lf = LiteralFactory.getInstance();
        Map<UriRef,Collection<NonLiteral>> suggestionMap = new HashMap<UriRef,Collection<NonLiteral>>();
        // 1) get Entity Annotations
        Map<NonLiteral,Map<EAProps,Object>> entitySuggestionMap = new HashMap<NonLiteral,Map<EAProps,Object>>();
        Iterator<Triple> entityAnnotations = graph.filter(null, RDF.type, ENHANCER_ENTITYANNOTATION);
        while(entityAnnotations.hasNext()){
            NonLiteral entityAnnotation = entityAnnotations.next().getSubject();
            //to avoid multiple lookups (e.g. if one entityAnnotation links to+
            //several TextAnnotations) we cache the data in an intermediate Map
            Map<EAProps,Object> eaData = new EnumMap<EAProps,Object>(EAProps.class);
View Full Code Here

                }
                suggestions.add(entityAnnotation);
            }
        }
        // 2) get the TextAnnotations
        Iterator<Triple> textAnnotations = graph.filter(null, RDF.type, ENHANCER_TEXTANNOTATION);
        while(textAnnotations.hasNext()){
            NonLiteral textAnnotation = textAnnotations.next().getSubject();
            //we need to process those to show multiple mentions
//            if (graph.filter(textAnnotation, DC_RELATION, null).hasNext()) {
//                // this is not the most specific occurrence of this name: skip
View Full Code Here

            EntitySuggestion bestGuess = p.getBestGuess();
            if (bestGuess == null) {
                continue;
            }
            UriRef uri = new UriRef(bestGuess.getUri());
            Iterator<Triple> latitudes = metadata.filter(uri, GEO_LAT, null);
            if (latitudes.hasNext()) {
                g.add(latitudes.next());
            }
            Iterator<Triple> longitutes = metadata.filter(uri, GEO_LONG, null);
            if (longitutes.hasNext()) {
View Full Code Here

            UriRef uri = new UriRef(bestGuess.getUri());
            Iterator<Triple> latitudes = metadata.filter(uri, GEO_LAT, null);
            if (latitudes.hasNext()) {
                g.add(latitudes.next());
            }
            Iterator<Triple> longitutes = metadata.filter(uri, GEO_LONG, null);
            if (longitutes.hasNext()) {
                g.add(longitutes.next());
                g.add(new TripleImpl(uri, Properties.RDFS_LABEL, lf.createTypedLiteral(bestGuess.getLabel())));
            }
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.