@Override protected QueryResultList<Representation> performQuery(String siteId, FieldQuery query) throws EntityhubException { return entityhub.find(query); }
public EntityhubBackend(Entityhub entityhub,ValueConverterFactory valueConverter) { super(entityhub.getYard(),valueConverter); }
@Override protected Representation getRepresentation(Entityhub eh, String id, boolean offlineMode) throws EntityhubException { Entity e = eh.getEntity(id); return e == null ? null : e.getRepresentation(); }
ValueFactory valueFactory) { SiteConfiguration siteConfig = site.getConfiguration(); ManagedEntityState state; state = siteConfig.getDefaultManagedEntityState(); if(state == null){ state = config.getDefaultManagedEntityState(); FieldMapper siteMapper = site.getFieldMapper(); FieldMapper mapper = this.fieldMapper.clone(); for(FieldMapping siteMapping : siteMapper.getMappings()){ mapper.addMapping(siteMapping); mapper.applyMappings(remoteEntity.getRepresentation(), localEntity.getRepresentation(),valueFactory); managedEntity.addAttributionLink(site.getConfiguration().getAttributionUrl()); managedEntity.addAttributionText(site.getConfiguration().getAttribution(), null); managedEntity.addContributorName(site.getConfiguration().getName());
Representation data; Representation metadata = null; String entityId = ModelUtils.getAboutRepresentation(rep); if(entityId != null){ data = entityhubYard.getRepresentation(entityId); metadata = rep; } else { data = rep; entityId = rep.getId(); //needed for logs metadata = lookupMetadata(rep.getId(),true); return new EntityImpl(config.getID(), data,metadata); } else { log.warn("Unable find representation for Entity {} (metadata: {}",
@Override public final QueryResultList<Entity> findEntities(FieldQuery query) throws YardException{ QueryResultList<String> references = entityhubYard.findReferences(query); List<Entity> entities = new ArrayList<Entity>(references.size()); for(String reference : references){ Entity entity = lookupLocalEntity(reference); if(entity != null){ entities.add(entity); } else { log.warn("Unable to create Entity for Reference {} in the Yard " + "usd by the entity hub [id={}] -> ignore reference", reference,config.getEntityhubYardId()); } } return new QueryResultListImpl<Entity>(references.getQuery(), entities, Entity.class); }
@Override protected FieldQuery createFieldQuery(String siteId) { return entityhub.getQueryFactory().createFieldQuery(); }
SiteConfiguration siteConfig = site.getConfiguration(); MappingState mappingState = siteConfig.getDefaultMappedEntityState(); if(mappingState == null){ mappingState = config.getDefaultMappingState(); long expireDuration = siteConfig.getDefaultExpireDuration(); if(expireDuration > 0){ Date expireDate = new Date(System.currentTimeMillis()+expireDuration); entityMapping.setExpires(expireDate); entityMapping.setSourceId(remoteEntity.getId()); entityMapping.setTargetId(localEntity.getId());
@Override public Collection<? extends Representation> lookup(String field, Set<String> includeFields, List<String> search, String... languages) throws IllegalStateException { Entityhub entityhub = getSearchService(); if(entityhub == null){ throw new IllegalStateException("The Entityhub is currently not active"); } FieldQuery query = EntitySearcherUtils.createFieldQuery(entityhub.getQueryFactory(), field, includeFields, search, languages); QueryResultList<Representation> results; try { results = entityhub.find(query); } catch (EntityhubException e) { throw new IllegalStateException("Exception while searchign for "+ search+'@'+Arrays.toString(languages)+"in the Entityhub", e); } return results.results(); }
public EntityhubImpl(Yard entityhubYard, SiteManager siteManager, EntityhubConfiguration config, NamespacePrefixService nsPrefixService) { if(entityhubYard == null){ throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!"); } this.entityhubYard = entityhubYard; if(siteManager == null){ throw new IllegalArgumentException("The parsed SiteManager MUST NOT be NULL!"); } this.siteManager = siteManager; if(config == null){ throw new IllegalArgumentException("The parsed EntityhubConfig MUST NOT be NULL!"); } this.config = config; log.info(" ... init FieldMappings"); fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); for(String mappingString : config.getFieldMappingConfig()){ FieldMapping mapping = FieldMappingUtils.parseFieldMapping(mappingString,nsPrefixService); if(mapping != null){ log.info(" + mapping: "+mapping); fieldMapper.addMapping(mapping); } } }
QueryResultList<Representation> result; try { result = entityhub.find(query); } catch (EntityhubException e) { String message = String.format("Exception while performing the " + "FieldQuery on the EntityHub (message: %s)", e.getMessage()); log.error(message, e); return Response.status(Status.INTERNAL_SERVER_ERROR)
if(id.equals("*")){ log.info("Deleting all Entities form the Entityhub"); entityhub.deleteAll(); rb = Response.status(Response.Status.OK); } else { entity = entityhub.delete(id); if(entity == null){ rb = Response.status(Status.NOT_FOUND).entity("An Entity with the" + rb = Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()) .header(HttpHeaders.ACCEPT, accepted);
String prefix = config.getEntityhubPrefix(); if(prefix == null || prefix.isEmpty()){ prefix = Entityhub.DEFAUTL_ENTITYHUB_PREFIX; id.append('.'); id.append(ModelUtils.randomUUID()); return id.toString();
Representation data; Representation metadata = null; String entityId = ModelUtils.getAboutRepresentation(rep); if(entityId != null){ data = entityhubYard.getRepresentation(entityId); metadata = rep; } else { data = rep; entityId = rep.getId(); //needed for logs metadata = lookupMetadata(rep.getId(),true); return new EntityImpl(config.getID(), data,metadata); } else { log.warn("Unable find representation for Entity {} (metadata: {}",
@Override public Representation get(String id,Set<String> includeFields) { if(id == null || id.isEmpty()){ return null; } Entityhub entityhub = getSearchService(); if(entityhub == null){ throw new IllegalStateException("The Entityhub is currently not active"); } Entity entity; try { entity = entityhub.getEntity(id); } catch (EntityhubException e) { throw new IllegalStateException("Exception while getting "+id+ " from the Entityhub",e); } return entity == null ? null : entity.getRepresentation(); } @Override
@Override public final QueryResultList<Entity> findEntities(FieldQuery query) throws YardException{ QueryResultList<String> references = entityhubYard.findReferences(query); List<Entity> entities = new ArrayList<Entity>(references.size()); for(String reference : references){ Entity entity = lookupLocalEntity(reference); if(entity != null){ entities.add(entity); } else { log.warn("Unable to create Entity for Reference {} in the Yard " + "usd by the entity hub [id={}] -> ignore reference", reference,config.getEntityhubYardId()); } } return new QueryResultListImpl<Entity>(references.getQuery(), entities, Entity.class); }
SiteConfiguration siteConfig = site.getConfiguration(); MappingState mappingState = siteConfig.getDefaultMappedEntityState(); if(mappingState == null){ mappingState = config.getDefaultMappingState(); long expireDuration = siteConfig.getDefaultExpireDuration(); if(expireDuration > 0){ Date expireDate = new Date(System.currentTimeMillis()+expireDuration); entityMapping.setExpires(expireDate); entityMapping.setSourceId(remoteEntity.getId()); entityMapping.setTargetId(localEntity.getId());
public EntityhubImpl(Yard entityhubYard, SiteManager siteManager, EntityhubConfiguration config, NamespacePrefixService nsPrefixService) { if(entityhubYard == null){ throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!"); } this.entityhubYard = entityhubYard; if(siteManager == null){ throw new IllegalArgumentException("The parsed SiteManager MUST NOT be NULL!"); } this.siteManager = siteManager; if(config == null){ throw new IllegalArgumentException("The parsed EntityhubConfig MUST NOT be NULL!"); } this.config = config; log.info(" ... init FieldMappings"); fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); for(String mappingString : config.getFieldMappingConfig()){ FieldMapping mapping = FieldMappingUtils.parseFieldMapping(mappingString,nsPrefixService); if(mapping != null){ log.info(" + mapping: "+mapping); fieldMapper.addMapping(mapping); } } }
@POST @Path("/ldpath") public Response handleLDPathPost( @FormParam(value = "context")Set<String> contexts, @FormParam(value = "ldpath")String ldpath, @Context HttpHeaders headers){ //Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext); return handleLDPathRequest(this,new YardBackend(entityhub.getYard()), ldpath, contexts, headers); }
String prefix = config.getEntityhubPrefix(); if(prefix == null || prefix.isEmpty()){ prefix = Entityhub.DEFAUTL_ENTITYHUB_PREFIX; id.append('.'); id.append(ModelUtils.randomUUID()); return id.toString();