Examples of RdfValueFactory


Examples of org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory

            }
        }
        // now write the results (requires write lock)
        ci.getLock().writeLock().lock();
        try {
            RdfValueFactory factory = RdfValueFactory.getInstance();
            Map<String,Representation> entityData = new HashMap<String,Representation>();
            for (Entry<NamedEntity,List<Suggestion>> entitySuggestions : suggestions.entrySet()) {
                List<UriRef> subsumed = textAnnotations.get(entitySuggestions.getKey());
                List<NonLiteral> annotationsToRelate = new ArrayList<NonLiteral>(subsumed);
                annotationsToRelate.add(entitySuggestions.getKey().getEntity());
                for (Suggestion suggestion : entitySuggestions.getValue()) {
                    log.debug("Add Suggestion {} for {}", suggestion.getEntity().getId(),
                        entitySuggestions.getKey());
                    EnhancementRDFUtils.writeEntityAnnotation(this, literalFactory, graph, ci.getUri(),
                        annotationsToRelate, suggestion, nameField,
                        // TODO: maybe we want labels in a different
                        // language than the
                        // language of the content (e.g. Accept-Language
                        // header)?!
                        contentLangauge == null ? DEFAULT_LANGUAGE : contentLangauge);
                    if (dereferenceEntities) {
                        entityData.put(suggestion.getEntity().getId(), suggestion.getEntity()
                                .getRepresentation());
                    }
                }
            }
            // if dereferneceEntities is true the entityData will also contain
            // all
            // Representations to add! If false entityData will be empty
            for (Representation rep : entityData.values()) {
                graph.addAll(factory.toRdfRepresentation(rep).getRdfGraph());
            }
        } finally {
            ci.getLock().writeLock().unlock();
        }
View Full Code Here

Examples of org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory

            }
        }
        //now write the results (requires write lock)
        ci.getLock().writeLock().lock();
        try {
            RdfValueFactory factory = RdfValueFactory.getInstance();
            Map<String, Representation> entityData = new HashMap<String,Representation>();
            for(Entry<NamedEntity,List<Entity>> entitySuggestions : suggestions.entrySet()){
                List<UriRef> subsumed = textAnnotations.get(entitySuggestions.getKey());
                List<NonLiteral> annotationsToRelate = new ArrayList<NonLiteral>(subsumed);
                annotationsToRelate.add(entitySuggestions.getKey().getEntity());
                for(Entity suggestion : entitySuggestions.getValue()){
                    log.debug("Add Suggestion {} for {}", suggestion.getId(), entitySuggestions.getKey());
                    EnhancementRDFUtils.writeEntityAnnotation(this, literalFactory, graph, ci.getUri(),
                        annotationsToRelate, suggestion.getRepresentation(), nameField);
                    if (dereferenceEntities) {
                        entityData.put(suggestion.getId(), suggestion.getRepresentation());
                    }
                }
            }
            //if dereferneceEntities is true the entityData will also contain all
            //Representations to add! If false entityData will be empty
            for(Representation rep : entityData.values()){
                graph.addAll(factory.toRdfRepresentation(rep).getRdfGraph());
            }
        } finally {
            ci.getLock().writeLock().unlock();
        }
View Full Code Here

Examples of org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory

     * @param headers the http headers of the request
     * @return the response
     */
    private Response executeLDPathQuery(FieldQuery query, String ldpathProgramString, MediaType mediaType, HttpHeaders headers) {
        QueryResultList<Representation> result;
        ValueFactory vf = new RdfValueFactory(new IndexedMGraph());
        SiteBackend backend = new SiteBackend(site,vf);
        EntityhubLDPath ldPath = new EntityhubLDPath(backend,vf);
        //copy the selected fields, because we might need to delete some during
        //the preparation phase
        Set<String> selectedFields = new HashSet<String>(query.getSelectedFields());
View Full Code Here

Examples of org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory

     * Transforms a site to a Representation that can be serialised
     * @param context
     * @return
     */
    private Representation site2Representation(String id){
        RdfValueFactory valueFactory = RdfValueFactory.getInstance();
        RdfRepresentation rep = valueFactory.createRepresentation(id);
        String namespace = NamespaceEnum.entityhubModel.getNamespace();
        rep.add(namespace+"localMode", site.supportsLocalMode());
        rep.add(namespace+"supportsSearch", site.supportsSearch());
        SiteConfiguration config = site.getConfiguration();
        rep.add(NamespaceEnum.rdfs+"label", config.getName());
        rep.add(NamespaceEnum.rdf+"type", valueFactory.createReference(namespace+"ReferencedSite"));
        if(config.getDescription() != null){
            rep.add(NamespaceEnum.rdfs+"description", config.getDescription());
        }
        if(config.getCacheStrategy() != null){
            rep.add(namespace+"cacheStrategy", valueFactory.createReference(namespace+"cacheStrategy-"+config.getCacheStrategy().name()));
        }
        //add the accessUri and queryUri
        if(config.getAccessUri() != null){
            rep.add(namespace+"accessUri", valueFactory.createReference(config.getAccessUri()));
        }
        if(config.getQueryUri() != null){
            rep.add(namespace+"queryUri", valueFactory.createReference(config.getQueryUri()));
        }
        if(config.getAttribution() != null){
            rep.add(NamespaceEnum.cc.getNamespace()+"attributionName", config.getAttribution());
        }
        if(config.getAttributionUrl() != null){
View Full Code Here

Examples of org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory

            rep.add(namespace+"entityPrefix", "*");
        }
        return rep;
    }
    private Representation license2Representation(String id, License license) {
        RdfValueFactory valueFactory = RdfValueFactory.getInstance();
        RdfRepresentation rep = valueFactory.createRepresentation(id);
       
        if(license.getName() != null){
            rep.add(NamespaceEnum.dcTerms.getNamespace()+"license", license.getName());
            rep.add(NamespaceEnum.rdfs+"label", license.getName());
            rep.add(NamespaceEnum.dcTerms+"title", license.getName());
View Full Code Here

Examples of org.apache.stanbol.entityhub.model.sesame.RdfValueFactory

        URI doubleTestField = vf.createURI("http://www.example.org/field/double");
        graph.add(id, doubleTestField, vf.createLiteral(Double.NaN));
        graph.add(id, doubleTestField, vf.createLiteral(Double.POSITIVE_INFINITY));
        graph.add(id, doubleTestField, vf.createLiteral(Double.NEGATIVE_INFINITY));
       
        RdfValueFactory valueFactory = new RdfValueFactory(graph,vf);
        Representation r = valueFactory.createRepresentation(id.stringValue());
        Set<Double> expected = new HashSet<Double>(Arrays.asList(
            Double.NaN, Double.POSITIVE_INFINITY,Double.NEGATIVE_INFINITY));
        Iterator<Double> dit = r.get(doubleTestField.stringValue(), Double.class);
        while(dit.hasNext()){
            Double val = dit.next();
View Full Code Here

Examples of org.apache.stanbol.entityhub.model.sesame.RdfValueFactory

        URI floatTestField = vf.createURI("http://www.example.org/field/float");
        graph.add(id, floatTestField, vf.createLiteral(Float.NaN));
        graph.add(id, floatTestField, vf.createLiteral(Float.POSITIVE_INFINITY));
        graph.add(id, floatTestField, vf.createLiteral(Float.NEGATIVE_INFINITY));
       
        RdfValueFactory valueFactory = new RdfValueFactory(graph,vf);
        Representation r = valueFactory.createRepresentation(id.stringValue());
        Set<Float> expected = new HashSet<Float>(Arrays.asList(
            Float.NaN, Float.POSITIVE_INFINITY,Float.NEGATIVE_INFINITY));
        Iterator<Float> dit = r.get(floatTestField.stringValue(), Float.class);
        while(dit.hasNext()){
            Float val = dit.next();
View Full Code Here

Examples of org.apache.stanbol.entityhub.model.sesame.RdfValueFactory

        this.repository = repo;
        if(config == null){
            throw new IllegalArgumentException("The parsed configuration MUST NOT be NULL!");
        }
        this.sesameFactory = repo.getValueFactory();
        this.valueFactory = new RdfValueFactory(null, sesameFactory);
        this.managedRepresentation = sesameFactory.createURI(MANAGED_REPRESENTATION_URI);
        this.managedRepresentationState = sesameFactory.createLiteral(true);
        this.includeInferred = config.isIncludeInferred();
        //init the super class
        activate(this.valueFactory, SparqlFieldQueryFactory.getInstance(), config);
View Full Code Here

Examples of org.apache.stanbol.entityhub.model.sesame.RdfValueFactory

            results = executeSparqlFieldQuery(con,query, limit, false);
            //parse the results and generate the Representations
            //create an own valueFactors so that all the data of the query results
            //are added to the same Sesame Model
            Model model = new TreeModel();
            RdfValueFactory valueFactory = new RdfValueFactory(model, sesameFactory);
            List<Representation> representations = limit > 0 ?
                    new ArrayList<Representation>(limit) : new ArrayList<Representation>();
            while(results.hasNext()){
                BindingSet result = results.next();
                Value value = result.getValue(query.getRootVariableName());
View Full Code Here

Examples of org.apache.stanbol.entityhub.model.sesame.RdfValueFactory

            results = executeSparqlFieldQuery(con,query, limit, true);
            //parse the results and generate the Representations
            //create an own valueFactors so that all the data of the query results
            //are added to the same Sesame Model
            Model model = new TreeModel();
            RdfValueFactory valueFactory = new RdfValueFactory(model, sesameFactory);
            List<Representation> representations = limit > 0 ? new ArrayList<Representation>(limit)
                    : new ArrayList<Representation>();
            Map<String,URI> bindings = new HashMap<String,URI>(query.getFieldVariableMappings().size());
            for(Entry<String,String> mapping : query.getFieldVariableMappings().entrySet()){
                bindings.put(mapping.getValue(), sesameFactory.createURI(mapping.getKey()));
            }
            while(results.hasNext()){
                BindingSet result = results.next();
                Value value = result.getValue(query.getRootVariableName());
                if(value instanceof URI){
                    URI subject = (URI) value;
                    //link the result with the query result
                    model.add(queryRoot, queryResult, subject);
                    //now copy over the other selected data
                    for(String binding : result.getBindingNames()){
                        URI property = bindings.get(binding);
                        if(property != null){
                            model.add(subject, property, result.getValue(binding));
                        } //else no mapping for the query.getRootVariableName()
                    }
                    //create a representation and add it to the results
                    representations.add(valueFactory.createRdfRepresentation(subject));
                } //ignore non URI results
            }
            con.commit();
            return new SesameQueryResultList(model, query, representations);
        } catch (RepositoryException e) {
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.