@Override protected Representation getRepresentation(String id) throws EntityhubException { Entity entity = site.getEntity(id); return entity != null ? entity.getRepresentation():null; } @Override
@Override protected Representation getRepresentation(Site site, String id, boolean offlineMode) throws EntityhubException { Entity entity = site.getEntity(id); return entity == null ? null : entity.getRepresentation(); } @Override
@Override 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(); }
@Override public Entity getEntity(String entityId) { Collection<Site> sites = getSitesByEntityPrefix(entityId); if(sites.isEmpty()){ log.info("No Referenced Site registered for Entity {}",entityId); log.debug("Registered Prefixes {}",prefixList); return null; } for(Site site : sites){ Entity entity; try { entity = site.getEntity(entityId); if(entity != null){ log.debug("Return Representation of Site {} for Entity {}", site.getConfiguration().getName(),entityId); return entity; } } catch (SiteException e) { log.warn("Unable to access Site "+site.getConfiguration().getName()+ " (id = "+site.getId()+")",e); } } log.debug("Entity {} not found on any of the following Sites {}",entityId,sites); return null; }
@Override public Entity getEntity(String entityId) { Collection<Site> sites = getSitesByEntityPrefix(entityId); if(sites.isEmpty()){ log.info("No Referenced Site registered for Entity {}",entityId); log.debug("Registered Prefixes {}",prefixList); return null; } for(Site site : sites){ Entity entity; try { entity = site.getEntity(entityId); if(entity != null){ log.debug("Return Representation of Site {} for Entity {}", site.getConfiguration().getName(),entityId); return entity; } } catch (SiteException e) { log.warn("Unable to access Site "+site.getConfiguration().getName()+ " (id = "+site.getId()+")",e); } } log.debug("Entity {} not found on any of the following Sites {}",entityId,sites); return null; }
@Override public Entity get(IRI id,Set<IRI> fields, String ... languages) { if(id == null || id.getUnicodeString().isEmpty()){ return null; } org.apache.stanbol.entityhub.servicesapi.model.Entity entity; Site site = getSearchService(); if(site == null){ throw new IllegalStateException("ReferencedSite "+siteId+" is currently not available"); } try { entity = site.getEntity(id.getUnicodeString()); } catch (SiteException e) { throw new IllegalStateException("Exception while getting "+id+ " from the ReferencedSite "+site.getId(),e); } if(entity != null){ Set<String> languageSet; if(languages == null || languages.length < 1){ languageSet = null; } else if (languages.length == 1){ languageSet = Collections.singleton(languages[0]); } else { languageSet = new HashSet<String>(Arrays.asList(languages)); } return new EntityhubEntity(entity.getRepresentation(), fields, languageSet); } else { return null; } }
Entity entity; try { entity = site.getEntity(id); } catch (SiteException e) { log.error("ReferencedSiteException while accessing Site " + site.getConfiguration().getName() +
Site site = getReferencedSite(); Entity entityType = (site == null) ? this.entityHub.getEntity(typeUri) : site .getEntity(typeUri);