Package org.apache.stanbol.entityhub.model.clerezza

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


            }
        }
        //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

     * @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

     * 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

            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

TOP

Related Classes of org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory

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.