Package org.apache.stanbol.entityhub.servicesapi.model

Examples of org.apache.stanbol.entityhub.servicesapi.model.Entity


    public final Entity getMappingById(String id) throws IllegalArgumentException, EntityhubException{
        if(id == null || id.isEmpty()){
            throw new IllegalArgumentException("The parsed id MUST NOT be NULL nor empty");
        }
        Yard entityhubYard = lookupYard();
        Entity mapping = loadEntity(entityhubYard, id);
        if(mapping == null){
            return null;
        } else if(mapping != null && EntityMapping.isValid(mapping)){
            return mapping;
        } else {
View Full Code Here


    @Override
    public final QueryResultList<Entity> findEntities(FieldQuery query) throws YardException{
        QueryResultList<String> references = lookupYard().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",
View Full Code Here

        QueryResultList<Representation> externalEnties = referencedSiteManager.find(fieldQuery);
        String entityId = null;
        if (externalEnties != null && externalEnties.size() > 0) {
            entityId = externalEnties.iterator().next().getId();
            try {
                Entity entity = entityhub.lookupLocalEntity(entityId, true);
                if (entity != null) {
                    results = getRelatedKeywordsFromEntity(entity);
                } else {
                    logger.warn("There is no obtained external entity having id: {}", entityId);
                }
View Full Code Here

        Float maxScore = null;
        Float maxSuggestedScore = null;
        Iterator<Entity> guesses = results.iterator();
        log.info("disambiguate {}: ", savedEntity.getName());
        while (guesses.hasNext()) {
            Entity guess = guesses.next();
            Float score =
                    guess.getRepresentation().getFirst(RdfResourceEnum.resultScore.getUri(), Float.class);
            if (score == null) {
                log.warn("Missing Score for Entityhub Query Result {}!", guess.getId());
                continue;
            }
            if (maxScore == null) {
                maxScore = score;
            }
            UriRef uri = new UriRef(guess.getId());
            Suggestion suggestion = savedEntity.getSuggestion(uri);
            if (suggestion == null) {
                log.info(" - not found {}", guess.getId());
                continue;
            }
            if (maxSuggestedScore == null) {
                maxSuggestedScore = score;
            }
View Full Code Here

                        results.iterator(),
                        new AdaptingIterator.Adapter<Representation,Entity>() {
                            private final String siteId = config.getId();
                            @Override
                            public Entity adapt(Representation value, Class<Entity> type) {
                                Entity entity = new EntityImpl(siteId,value,null);
                                SiteUtils.initEntityMetadata(entity, siteMetadata, null);
                                return entity;
                            }
                        }, Entity.class),Entity.class);
    }
View Full Code Here

            rep = getYard().getRepresentation(id);
        } catch (YardException e) {
            throw new ManagedSiteException(e.getMessage(), e);
        }
        if(rep != null){
            Entity entity = new EntityImpl(config.getId(), rep, null);
            SiteUtils.initEntityMetadata(entity, siteMetadata, null);
            return entity;
        } else {
            return null;
        }
View Full Code Here

        if (symbolId == null || symbolId.isEmpty()) {
            // TODO: how to parse an error message
            throw new WebApplicationException(BAD_REQUEST);
        }
        Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
        Entity entity;
        try {
            entity = entityhub.getEntity(symbolId);
        } catch (EntityhubException e) {
            throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
        }
View Full Code Here

        } else {
            if (reference == null || reference.isEmpty()) {
                // TODO: how to parse an error message
                throw new WebApplicationException(BAD_REQUEST);
            }
            Entity entity;
            try {
                entity = entityhub.lookupLocalEntity(reference, create);
            } catch (EntityhubException e) {
                throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
            }
View Full Code Here

            return Response.status(Status.BAD_REQUEST).entity("The Request does" +
                    "not provide the id of the Entity to delete (parameter 'id').")
                    .header(HttpHeaders.ACCEPT, accepted).build();
        }
        Entityhub entityhub = ContextHelper.getServiceFromContext(Entityhub.class, servletContext);
        Entity entity;
        ResponseBuilder rb;
        try {
            if(id.equals("*")){
                log.info("Deleting all Entities form the Entityhub");
                entityhub.deleteAll();
View Full Code Here

        //for remote Entiteis as suggested by
        // http://incubator.apache.org/stanbol/docs/trunk/entityhub/entityhubandlinkeddata.html
        Map<String,Entity> updated = new HashMap<String,Entity>();
        for(Representation representation : parsed.values()){
            try {
                Entity entity = entityhub.store(representation);
                updated.put(entity.getId(), entity);
            }catch (EntityhubException e) {
                log.error(String.format("Exception while storing Entity %s" +
                        "in the Entityhub.",representation),e);
            }
        }
        //create the response for the Entity
        // for now directly return the added entity. one could also
        // consider returning a seeOther (303) with the get URI for the
        // created/updated entity
        if(updated.isEmpty()){
            // No (valid) data parsed
            ResponseBuilder rb = Response.status(Status.NOT_MODIFIED);
            addCORSOrigin(servletContext, rb, headers);
            return rb.build();
        } else {
            Entity entity = updated.values().iterator().next();
            if(method.equals(HttpMethod.POST)){
                ResponseBuilder rb = Response.created(uriInfo.getAbsolutePathBuilder()
                    .queryParam("id", "{entityId}")
                    .build(entity.getId()));
                addCORSOrigin(servletContext, rb, headers);
                return rb.build();
            } else {
                //return Response.noContent().build();
                //As alternative return the modified entity
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.model.Entity

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.