Package org.apache.stanbol.entityhub.servicesapi.site

Examples of org.apache.stanbol.entityhub.servicesapi.site.Site


                                           Set<UriRef> includeFields,
                                           List<String> search,
                                           String[] languages,
                                           Integer limit) throws IllegalStateException {
        //build the query and than return the result
        Site site = getSearchService();
        if(site == null){
            throw new IllegalStateException("ReferencedSite "+siteId+" is currently not available");
        }
        FieldQuery query = EntitySearcherUtils.createFieldQuery(site.getQueryFactory(),
            field, includeFields, search, languages);
        if(limit != null && limit > 0){
            query.setLimit(limit);
        } else if(this.limit != null){
            query.setLimit(this.limit);
        }
        QueryResultList<Representation> results;
        try {
            results = site.find(query);
        } catch (SiteException e) {
            throw new IllegalStateException("Exception while searchign for "+
                search+'@'+Arrays.toString(languages)+"in the ReferencedSite "+
                site.getId(), e);
        }
        Collection<Entity> entities = new ArrayList<Entity>(results.size());
        for(Representation result : results){
            entities.add(new EntityhubEntity(result));
        }
View Full Code Here


        return entities;
        }

    @Override
    public boolean supportsOfflineMode() {
        Site site = getSearchService();
        //Do not throw an exception here if the site is not available. Just return false
        return site == null ? false : site.supportsLocalMode();
    }
View Full Code Here

    public Representation get(String id,Set<String> includeFields) {
        if(id == null || id.isEmpty()){
            return null;
        }
        Entity entity;
        Site site = getSearchService();
        if(site == null){
            throw new IllegalStateException("ReferencedSite "+siteId+" is currently not available");
        }
        try {
            entity = site.getEntity(id);
        catch (SiteException e) {
            throw new IllegalStateException("Exception while getting "+id+
                " from the ReferencedSite "+site.getId(),e);
        }
        return entity == null ? null : entity.getRepresentation();
    }
View Full Code Here

    public Collection<? extends Representation> lookup(String field,
                                           Set<String> includeFields,
                                           List<String> search,
                                           String... languages) throws IllegalStateException {
        //build the query and than return the result
        Site site = getSearchService();
        if(site == null){
            throw new IllegalStateException("ReferencedSite "+siteId+" is currently not available");
        }
        FieldQuery query = EntitySearcherUtils.createFieldQuery(site.getQueryFactory(),
            field, includeFields, search, languages);
        if(limit != null){
            query.setLimit(limit);
        }
        QueryResultList<Representation> results;
        try {
            results = site.find(query);
        } catch (SiteException e) {
            throw new IllegalStateException("Exception while searchign for "+
                search+'@'+Arrays.toString(languages)+"in the ReferencedSite "+
                site.getId(), e);
        }
        return results.results();
    }
View Full Code Here

        return results.results();
    }

    @Override
    public boolean supportsOfflineMode() {
        Site site = getSearchService();
        //Do not throw an exception here if the site is not available. Just return false
        return site == null ? false : site.supportsLocalMode();
    }
View Full Code Here

    }


   
    public void computeEnhancements(ContentItem ci) throws EngineException {
        final Site site;
        if (referencedSiteID != null) { // lookup the referenced site
            site = siteManager.getSite(referencedSiteID);
            // ensure that it is present
            if (site == null) {
                String msg = String.format(
                    "Unable to enhance %s because Referenced Site %s is currently not active!", ci.getUri()
                            .getUnicodeString(), referencedSiteID);
                log.warn(msg);
                // TODO: throwing Exceptions is currently deactivated. We need a
                // more clear
                // policy what do to in such situations
                // throw new EngineException(msg);
                return;
            }
            // and that it supports offline mode if required
            if (isOfflineMode() && !site.supportsLocalMode()) {
                log.warn(
                    "Unable to enhance ci {} because OfflineMode is not supported by ReferencedSite {}.", ci
                            .getUri().getUnicodeString(), site.getId());
                return;
            }
        } else { // null indicates to use the Entityhub to lookup Entities
            site = null;
        }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.site.Site

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.