Package org.apache.stanbol.enhancer.servicesapi

Examples of org.apache.stanbol.enhancer.servicesapi.Chain


    private void enhance(ContentItem ci, String chainName) throws StoreException {
        try {
            if (chainName == null || chainName.trim().isEmpty()) {
                jobManager.enhanceContent(ci);
            } else {
                Chain chain = chainManager.getChain(chainName.trim());
                if (chain == null) {
                    String msg = String.format("Failed to get chain with name: %s", chainName);
                    log.error(msg);
                    throw new StoreException(msg);
                }
View Full Code Here


    public static Map<String,Map.Entry<ServiceReference,Chain>> buildChainsMap(ChainManager chainManager) {
        Map<String,Map.Entry<ServiceReference,Chain>> chains = new HashMap<String,Map.Entry<ServiceReference,Chain>>();
        for(String chainName : chainManager.getActiveChainNames()){
            ServiceReference chainRef = chainManager.getReference(chainName);
            if(chainRef != null){
                Chain chain = chainManager.getChain(chainRef);
                if(chain != null){
                    Map<ServiceReference,Chain> m = Collections.singletonMap(chainRef, chain);
                    chains.put(chainName, m.entrySet().iterator().next());
                }
            }
View Full Code Here

        final VelocityContext ctx = getVelocityContext(request, "Benchmark Results");
        ctx.put("contentItemFactory", ciFactory);
        ctx.put("jobManager", jobManager);
        List<? extends Benchmark> benchmarks = parser.parse(new StringReader(content));
        if(chainName != null && !chainName.isEmpty()){
            Chain chain = chainManager.getChain(chainName);
            if(chain == null){
                response.setStatus(404);
                PrintWriter w = response.getWriter();
                w.println("Unable to perform benchmark on EnhancementChain '"
                    +chainName+"' because no chain with that name is active!");
View Full Code Here

        }
       
        @Override
        protected State consume(String line) throws IOException {
            if(ctx.currentBenchmark.getChain() == null){
                Chain chain = chainManager.getChain(line);
                if(chain != null){
                    ctx.currentBenchmark.setChain(chain);
                } //defined chain not active
            } //do not override
            return this;
View Full Code Here

    @GET
    @Path("/ep")
    @Produces(value = {JSON_LD, APPLICATION_JSON, N3, N_TRIPLE, RDF_JSON, RDF_XML, TURTLE, X_TURTLE})
    public Response getExecutionPlan(@Context HttpHeaders headers) {
        ResponseBuilder res;
        Chain chain = null;
        try {
            chain = getChain();
            res = Response.ok(chain.getExecutionPlan());
        } catch (ChainException e) {
            String chainName = chain == null ? "" : ("'"+chain.getName()+"' ");
            res = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
                    .entity("The Enhancement Chain "+chainName+"is currently" +
                        "not executeable (message: "+e.getMessage()+")!");
        }
        addCORSOrigin(servletContext, res, headers);
View Full Code Here

    private void enhance(ContentItem ci, String chainName) throws StoreException {
        try {
            if (chainName == null || chainName.trim().isEmpty()) {
                jobManager.enhanceContent(ci);
            } else {
                Chain chain = chainManager.getChain(chainName.trim());
                if (chain == null) {
                    String msg = String.format("Failed to get chain with name: %s", chainName);
                    log.error(msg);
                    throw new StoreException(msg);
                }
View Full Code Here

        jobHandlerRegistration = null;
    }
   
    @Override
    public void enhanceContent(ContentItem ci) throws EngineException, ChainException {
        Chain defaultChain = chainManager.getDefault();
        if(defaultChain == null){
            throw new ChainException("Unable to enhance ContentItem '"+ci.getUri()+
                "' because currently no enhancement chain is active. Please" +
                "configure a Chain or enable the default chain");
        }
View Full Code Here

    @Override
    public List<EnhancementEngine> getActiveEngines() {
        //This implementation return the list of active engined for the default
        //Chain in the order they would be executed
        Chain defaultChain = chainManager.getDefault();
        if(defaultChain == null){
            throw new IllegalStateException("Currently no enhancement chain is " +
                "active. Please configure a Chain or enable the default chain");
        }
        Graph ep;
        try {
            ep = defaultChain.getExecutionPlan();
        } catch (ChainException e) {
            throw new IllegalStateException("Unable to get Execution Plan for " +
                "default enhancement chain (name: '"+defaultChain.getName()+
                "'| class: '"+defaultChain.getClass()+"')!",e);
        }
        return ExecutionPlanHelper.getActiveEngines(engineManager,ep);
    }
View Full Code Here

                file.getFileName());
        final ContentItem contentItem = contentItemFactory.createContentItem(contentSource);
        if ((chainName == null) || chainName.trim().equals("")) {
            enhancementJobManager.enhanceContent(contentItem);
        } else {
            final Chain chain = chainManager.getChain(chainName);
            if (chain == null) {
                throw new RuntimeException("No chain by that name: "+chainName);
            }
            enhancementJobManager.enhanceContent(contentItem, chain);
        }
View Full Code Here

     * (non-Javadoc)
     * @see org.apache.stanbol.enhancer.servicesapi.ChainManager#getDefault()
     */
    @Override
    public Chain getDefault() {
        Chain chain = getChain(DEFAULT_CHAIN_NAME);
        if(chain == null){
            chain = (Chain)nameTracker.getService();
        }
        return chain;
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.enhancer.servicesapi.Chain

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.