Package org.apache.stanbol.enhancer.servicesapi

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


        List<String> chainNames = new ArrayList<String>();
        BundleContext bundleContext = context.getBundleContext();
        ServiceReference[] references = bundleContext.getServiceReferences(Chain.class.getName(), null);
        if (references != null) {
            for (ServiceReference ref : references) {
                Chain chain = (Chain) bundleContext.getService(ref);
                try {
                    if (chain.getEngines().contains(getName())) {
                        chainNames.add(chain.getName());
                    }
                } catch (ChainException e) {
                    // This chain is currently not active ... ignore
                }
            }
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

        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

    @GET
    @Path("/ep")
    @Produces(value = {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

        List<String> chainNames = new ArrayList<String>();
        BundleContext bundleContext = context.getBundleContext();
        ServiceReference[] references = bundleContext.getServiceReferences(Chain.class.getName(), null);
        if (references != null) {
            for (ServiceReference ref : references) {
                Chain chain = (Chain) bundleContext.getService(ref);
                if (chain.getEngines().contains(getName())) {
                    chainNames.add(chain.getName());
                }
            }
        }
        return chainNames;
    }
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

    @GET
    @Path("/ep")
    @Produces(value = {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

        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

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.