Package org.apache.stanbol.rules.base.api.util

Examples of org.apache.stanbol.rules.base.api.util.RecipeList


        return recipes;
    }

    @Override
    public RecipeList listRecipes() throws NoSuchRecipeException, RecipeConstructionException {
        RecipeList recipeList = new RecipeList();

        for (UriRef recipeID : recipes) {
            Recipe recipe;
            try {
                recipe = getRecipe(recipeID);
            } catch (NoSuchRecipeException e) {
                throw e;
            } catch (RecipeConstructionException e) {
                throw e;
            }
            recipeList.add(recipe);
        }

        log.info("The Clerezza rule store contains {} recipes", recipeList.size());

        return recipeList;

    }
View Full Code Here


                        + "?recipe " + Symbols.description + " ?description . "
                        + "FILTER (regex(?description, \"" + term + "\", \"i\"))" + "}";

        TripleCollection tripleCollection = tcManager.getMGraph(new UriRef(recipeIndexLocation));

        RecipeList matchingRecipes = new RecipeList();

        try {

            SelectQuery query = (SelectQuery) QueryParser.getInstance().parse(sparql);

            ResultSet resultSet = tcManager.executeSparqlQuery(query, tripleCollection);

            while (resultSet.hasNext()) {
                SolutionMapping solutionMapping = resultSet.next();
                UriRef recipeID = (UriRef) solutionMapping.get("recipe");

                try {
                    Recipe recipe = getRecipe(recipeID);

                    log.info("Found recipe {}.", recipeID.toString());
                    matchingRecipes.add(recipe);
                    log.info("Found {} matching recipes.", matchingRecipes.size());
                } catch (NoSuchRecipeException e) {
                    // in this case go on in the iteration by fetching other matching recipes
                } catch (RecipeConstructionException e) {
                    // in this case go on in the iteration by fetching other matching recipes
                }
View Full Code Here

        }

    }

    private void findRecipesByDescriptionTest() throws Exception {
        RecipeList recipes = store.findRecipesByDescription("recipe named A");
        if (recipes.isEmpty()) {
            Assert.fail();
        } else {
            Assert.assertTrue(true);
        }
View Full Code Here

    }

    private void removeRecipeTest() throws Exception {

        RecipeList recipeListInitial = store.listRecipes();
        Recipe[] initialRecipes = new Recipe[recipeListInitial.size()];
        initialRecipes = recipeListInitial.toArray(initialRecipes);

        Recipe recipe = store.getRecipe(new UriRef("http://incubator.apache.com/stanbol/rules/test/recipeA"));
        store.removeRecipe(recipe);

        RecipeList recipeListFinal = store.listRecipes();
        Recipe[] finalRecipes = new Recipe[recipeListInitial.size()];
        finalRecipes = recipeListFinal.toArray(finalRecipes);

        Assert.assertNotSame(initialRecipes, finalRecipes);

    }
View Full Code Here

    @Path("/find/recipes")
    public Response findRecipes(@QueryParam("description") String description) {

        log.info("Searching for recipes with description like to {}.", description);

        RecipeList recipes = ruleStore.findRecipesByDescription(description);

        log.info("The recipe list is emplty? {} ", recipes.isEmpty());
        if (recipes.isEmpty()) {
            return Response.status(Status.NOT_FOUND).build();
        }

        return Response.ok(recipes).build();
View Full Code Here

    @Produces(value = {KRFormat.RDF_XML, KRFormat.TURTLE, KRFormat.OWL_XML, KRFormat.RDF_JSON,
                       KRFormat.FUNCTIONAL_OWL, KRFormat.MANCHESTER_OWL})
    public Response listRecipes(@Context HttpHeaders headers) {
        ResponseBuilder responseBuilder = null;
        try {
            RecipeList recipeList = getListRecipes();
            responseBuilder = Response.ok(recipeList);
        } catch (NoSuchRecipeException e) {
            log.error(e.getMessage(), e);
            responseBuilder = Response.status(Status.NOT_FOUND);
        } catch (RecipeConstructionException e) {
View Full Code Here

        return recipeIRIs;
    }

    @Override
    public RecipeList listRecipes() {
        RecipeList recipies = null;

        Set<IRI> recipeIRIs = listIRIRecipes();

        if (recipeIRIs != null && recipeIRIs.size() > 0) {

            recipies = new RecipeList();
            for (IRI recipeIRI : recipeIRIs) {
                try {
                    recipies.add(getRecipe(recipeIRI));
                } catch (NoSuchRecipeException e) {
                    log.error("Recipe missing: " + recipeIRI.toString(), e);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.rules.base.api.util.RecipeList

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.