Examples of ReasoningServiceInputManager


Examples of org.apache.stanbol.reasoners.servicesapi.ReasoningServiceInputManager

        this.adapterManager = adapterManager;
    }

    @Override
    public ReasoningServiceInputManager createInputManager(Map<String,List<String>> parameters) {
        ReasoningServiceInputManager inmgr = new SimpleInputManager();
        String scope = null;
        String session = null;
        for (Entry<String,List<String>> entry : parameters.entrySet()) {
            if (entry.getKey().equals("url")) {
                if (!entry.getValue().isEmpty()) {
                    // We keep only the first value
                    // XXX (make sense support multiple values?)
                    inmgr.addInputProvider(new UrlInputProvider(entry.getValue().iterator().next()));
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'url' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }
            } else if (entry.getKey().equals("file")) {
                if (!entry.getValue().isEmpty()) {
                    // We keep only the first value
                    // FIXME We create the file once again...
                    inmgr.addInputProvider(new FileInputProvider(new File(entry.getValue().iterator().next())));
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'url' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }
            } else if (entry.getKey().equals("scope")) {
                if (!entry.getValue().isEmpty()) {
                    scope = entry.getValue().iterator().next();
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'scope' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            } else if (entry.getKey().equals("session")) {
                if (!entry.getValue().isEmpty()) {
                    session = entry.getValue().iterator().next();
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'session' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            } else if (entry.getKey().equals("recipe")) {
                if (!entry.getValue().isEmpty()) {
                    inmgr.addInputProvider(new RecipeInputProvider(rStore, adapterManager, entry.getValue()
                            .iterator().next()));
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'recipe' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            }
        }
        if (scope != null) {
            inmgr.addInputProvider(new OntologyManagerInputProvider(onm, sessionManager, scope, session));
        }
        return inmgr;
    }
View Full Code Here

Examples of org.apache.stanbol.reasoners.servicesapi.ReasoningServiceInputManager

            log.error("Cannot start job without input parameters... sending BAD REQUEST");
            throw new WebApplicationException(Response.Status.BAD_REQUEST);
        }
        String target = getTarget();
        // Setup the input
        ReasoningServiceInputManager imngr = prepareInput();
        // The service executor
        ReasoningServiceExecutor executor = new ReasoningServiceExecutor(tcManager, imngr,
                getCurrentService(), getCurrentTask(), target, parameters);
        String jid = getJobManager().execute(executor);
        URI location = URI.create(getPublicBaseUri() + "jobs/" + jid);
View Full Code Here

Examples of org.apache.stanbol.reasoners.servicesapi.ReasoningServiceInputManager

            return rb.build();
        }
        try {
            String target = getTarget();
            // Setup the input
            ReasoningServiceInputManager imngr = prepareInput();
            // The service executor
            ReasoningServiceExecutor executor = new ReasoningServiceExecutor(tcManager, imngr,
                    getCurrentService(), getCurrentTask(), target, parameters);
            ReasoningServiceResult<?> result = executor.call();
            return new ResponseTaskBuilder(uriInfo, context, headers).build(result);
View Full Code Here

Examples of org.apache.stanbol.reasoners.servicesapi.ReasoningServiceInputManager

     * resource/submodule.
     *
     * @return
     */
    private ReasoningServiceInputManager prepareInput() {
        ReasoningServiceInputManager inmgr = new SimpleInputManager();
        String scope = null;
        String session = null;
        for (Entry<String,List<String>> entry : this.parameters.entrySet()) {
            if (entry.getKey().equals("url")) {
                if (!entry.getValue().isEmpty()) {
                    // We keep only the first value
                    // XXX (make sense support multiple values?)
                    inmgr.addInputProvider(new UrlInputProvider(entry.getValue().iterator().next()));
                    // We remove it form the additional parameter list
                    this.parameters.remove("url");
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'url' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }
            } else if (entry.getKey().equals("file")) {
                if (!entry.getValue().isEmpty()) {
                    // We keep only the first value
                    // FIXME We create the file once again...
                    String fv = entry.getValue().iterator().next();
                    log.debug("File value is: {}", fv);
                    inmgr.addInputProvider(new FileInputProvider(new File(URI.create(fv))));
                    // We remove it form the additional parameter list
                    this.parameters.remove("url");
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'url' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }
            } else if (entry.getKey().equals("scope")) {
                if (!entry.getValue().isEmpty()) {
                    scope = entry.getValue().iterator().next();
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'scope' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            } else if (entry.getKey().equals("session")) {
                if (!entry.getValue().isEmpty()) {
                    session = entry.getValue().iterator().next();
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'session' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            } else if (entry.getKey().equals("recipe")) {
                if (!entry.getValue().isEmpty()) {
                    inmgr.addInputProvider(new RecipeInputProvider(ruleStore, adapterManager, entry
                            .getValue().iterator().next()));
                    // We remove it form the additional parameter list
                    this.parameters.remove("url");
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'recipe' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            }
        }
        if (scope != null) {
            inmgr.addInputProvider(new OntologyManagerInputProvider(onm, sessionManager, scope, session));
            this.parameters.remove("scope");
            this.parameters.remove("session");
        }
        return inmgr;
    }
View Full Code Here

Examples of org.apache.stanbol.reasoners.servicesapi.ReasoningServiceInputManager

            log.error("Cannot start job without input parameters... sending BAD REQUEST");
            throw new WebApplicationException(Response.Status.BAD_REQUEST);
        }
        String target = getTarget();
        // Setup the input
        ReasoningServiceInputManager imngr = prepareInput();
        // The service executor
        ReasoningServiceExecutor executor = new ReasoningServiceExecutor(tcManager, imngr,
                getCurrentService(), getCurrentTask(), target, parameters);
        String jid = getJobManager().execute(executor);
        URI location = URI.create(getPublicBaseUri() + "jobs/" + jid);
View Full Code Here

Examples of org.apache.stanbol.reasoners.servicesapi.ReasoningServiceInputManager

            return rb.build();
        }
        try {
            String target = getTarget();
            // Setup the input
            ReasoningServiceInputManager imngr = prepareInput();
            // The service executor
            ReasoningServiceExecutor executor = new ReasoningServiceExecutor(tcManager, imngr,
                    getCurrentService(), getCurrentTask(), target, parameters);
            ReasoningServiceResult<?> result = executor.call();
            return new ResponseTaskBuilder(uriInfo, context, headers).build(result);
View Full Code Here

Examples of org.apache.stanbol.reasoners.servicesapi.ReasoningServiceInputManager

     * resource/submodule.
     *
     * @return
     */
    private ReasoningServiceInputManager prepareInput() {
        ReasoningServiceInputManager inmgr = new SimpleInputManager();
        String scope = null;
        String session = null;
        for (Entry<String,List<String>> entry : this.parameters.entrySet()) {
            if (entry.getKey().equals("url")) {
                if (!entry.getValue().isEmpty()) {
                    // We keep only the first value
                    // XXX (make sense support multiple values?)
                    inmgr.addInputProvider(new UrlInputProvider(entry.getValue().iterator().next()));
                    // We remove it form the additional parameter list
                    this.parameters.remove("url");
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'url' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }
            } else if (entry.getKey().equals("file")) {
                if (!entry.getValue().isEmpty()) {
                    // We keep only the first value
                    // FIXME We create the file once again...
                    String fv = entry.getValue().iterator().next();
                    log.debug("File value is: {}", fv);
                    inmgr.addInputProvider(new FileInputProvider(new File(URI.create(fv))));
                    // We remove it form the additional parameter list
                    this.parameters.remove("url");
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'url' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }
            } else if (entry.getKey().equals("scope")) {
                if (!entry.getValue().isEmpty()) {
                    scope = entry.getValue().iterator().next();
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'scope' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            } else if (entry.getKey().equals("session")) {
                if (!entry.getValue().isEmpty()) {
                    session = entry.getValue().iterator().next();
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'session' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            } else if (entry.getKey().equals("recipe")) {
                if (!entry.getValue().isEmpty()) {
                    inmgr.addInputProvider(new RecipeInputProvider(ruleStore, entry.getValue().iterator()
                            .next()));
                    // We remove it form the additional parameter list
                    this.parameters.remove("url");
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'recipe' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            }
        }
        if (scope != null) {
            inmgr.addInputProvider(new OntonetInputProvider(onm, sessionManager, scope, session));
            this.parameters.remove("scope");
            this.parameters.remove("session");
        }
        return inmgr;
    }
View Full Code Here

Examples of org.apache.stanbol.reasoners.servicesapi.ReasoningServiceInputManager

        this.rStore = rStore;
    }

    @Override
    public ReasoningServiceInputManager createInputManager(Map<String,List<String>> parameters) {
        ReasoningServiceInputManager inmgr = new SimpleInputManager();
        String scope = null;
        String session = null;
        for (Entry<String,List<String>> entry : parameters.entrySet()) {
            if (entry.getKey().equals("url")) {
                if (!entry.getValue().isEmpty()) {
                    // We keep only the first value
                    // XXX (make sense support multiple values?)
                    inmgr.addInputProvider(new UrlInputProvider(entry.getValue().iterator().next()));
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'url' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }
            } else if (entry.getKey().equals("file")) {
                if (!entry.getValue().isEmpty()) {
                    // We keep only the first value
                    // FIXME We create the file once again...
                    inmgr.addInputProvider(new FileInputProvider(new File(entry.getValue().iterator().next())));
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'url' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }
            } else if (entry.getKey().equals("scope")) {
                if (!entry.getValue().isEmpty()) {
                    scope = entry.getValue().iterator().next();
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'scope' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            } else if (entry.getKey().equals("session")) {
                if (!entry.getValue().isEmpty()) {
                    session = entry.getValue().iterator().next();
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'session' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            } else if (entry.getKey().equals("recipe")) {
                if (!entry.getValue().isEmpty()) {
                    inmgr.addInputProvider(new RecipeInputProvider(rStore, entry.getValue().iterator().next()));
                } else {
                    // Parameter exists with no value
                    log.error("Parameter 'recipe' must have a value!");
                    throw new WebApplicationException(Response.Status.BAD_REQUEST);
                }

            }
        }
        if (scope != null) {
            inmgr.addInputProvider(new OntonetInputProvider(onm, sessionManager, scope, session));
        }
        return inmgr;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.