use of org.apache.stanbol.entityhub.core.query.QueryResultListImpl in project stanbol by apache.
the class EntityhubImpl method findEntities.
@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);
}
use of org.apache.stanbol.entityhub.core.query.QueryResultListImpl in project stanbol by apache.
the class MockEntityCorefDbpediaSite method findEntities.
@SuppressWarnings("deprecation")
@Override
public QueryResultList<Entity> findEntities(FieldQuery query) throws SiteException {
TextConstraint labelConstraint = (TextConstraint) query.getConstraint(RDFS_LABEL.getUnicodeString());
for (Entity entity : entities.values()) {
Iterator<Object> entityAttributes = entity.getRepresentation().get(RDFS_LABEL.getUnicodeString());
while (entityAttributes.hasNext()) {
Text entityAttribute = (Text) entityAttributes.next();
if (entityAttribute.getText().equals(labelConstraint.getText())) {
Collection<Entity> retEntities = new ArrayList<>(1);
retEntities.add(entity);
return new QueryResultListImpl<Entity>(null, retEntities, Entity.class);
}
}
}
return null;
}
Aggregations