Examples of AddRecipe


Examples of omnom.newRecipes.AddRecipe

    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void newRecipeItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newRecipeItemActionPerformed
        if (addRecipe == null) {
            JFrame mainFrame = RecipesApp.getApplication().getMainFrame();
            addRecipe = new AddRecipe(mainFrame, this);

        }
        addRecipe.clearFields();
        RecipesApp.getApplication().show(addRecipe);
    }//GEN-LAST:event_newRecipeItemActionPerformed
View Full Code Here

Examples of org.apache.stanbol.rules.manager.changes.AddRecipe

                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                }

                // Add the recipe with the new rule
                AddRecipe newadd = new AddRecipe(ruleStore);
                ok = newadd.addRecipe(IRI.create(recipe), ruleseq, desc);

                if (ok) {
                    ruleStore.saveOntology();
                    ResponseBuilder rb = Response.ok();
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                } else {
                    ResponseBuilder rb = Response.status(Status.NO_CONTENT);
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                }
            }

            // The rule is added to the store and to the recipe
            if ((kres_syntax != null) & (description != null)) {
                // Get the rule
                AddRule inrule = new AddRule(ruleStore);
                boolean ok = inrule.addRule(IRI.create(rule), kres_syntax, description);
                if (!ok) {
                    log.error("Problem to add: " + rule);
                    ResponseBuilder rb = Response.status(Status.CONFLICT);
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                }

                // Get the recipe
                GetRecipe getrecipe = new GetRecipe(ruleStore);
                this.map = getrecipe.getRecipe(IRI.create(recipe));
                if (map != null) {
                    this.desc = getrecipe.getDescription(IRI.create(recipe));

                    if (desc == null){
                        ResponseBuilder rb = Response.status(Status.NOT_FOUND);
                        MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                        if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                        addCORSOrigin(servletContext, rb, headers);
                        return rb.build();
                    }
                } else {
                    ResponseBuilder rb = Response.status(Status.NOT_FOUND);
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                }

                String[] sequence = map.get(IRI.create(recipe)).split(",");
                Vector<IRI> ruleseq = new Vector();
                if (!sequence[0].isEmpty()) for (String seq : sequence)
                    ruleseq.add(IRI.create(seq.replace(" ", "").trim()));

                // Add the new rule to the end
                ruleseq.add(IRI.create(rule));
                // Remove the old recipe
                RemoveRecipe remove = new RemoveRecipe(ruleStore);
                ok = remove.removeRecipe(IRI.create(recipe));
                if (!ok) {
                    log.error("ERROR TO REMOVE OLD RECIPE: " + recipe);
                    ResponseBuilder rb = Response.status(Status.CONFLICT);
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                }

                // Add the recipe with the new rule
                AddRecipe newadd = new AddRecipe(ruleStore);
                ok = newadd.addRecipe(IRI.create(recipe), ruleseq, desc);
                if (ok) {
                    ruleStore.saveOntology();
                    ResponseBuilder rb = Response.ok();
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
View Full Code Here

Examples of org.apache.stanbol.rules.manager.changes.AddRecipe

        Vector<IRI> rules = new Vector();
        rules.add(IRI.create(ID+"MyRuleC"));
        rules.add(IRI.create(ID+"MyRuleB"));
        rules.add(IRI.create(ID+"MyRuleA"));
        String recipeDescription = "My comment to the recipe";
        AddRecipe instance = new AddRecipe(load.getStore());
        boolean result = instance.addRecipe(recipeName, rules, recipeDescription);
        OWLOntology newonto = instance.getStore().getOntology();
        if(result){
            OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID + "MyRecipeNew"));
            int axiom = newonto.getAxioms(ruleind).size();
            assertEquals(8,axiom);
            // TODO review the generated test code and remove the default call to fail.
View Full Code Here

Examples of org.apache.stanbol.rules.manager.changes.AddRecipe

        String ID = owl.getOntologyID().toString().replace("<","").replace(">","")+"#";

        String recipeName = "MyRecipeNew";
        String recipeDescription = "My comment to the recipe";
        AddRecipe instance = new AddRecipe(store);
        boolean result = instance.addSimpleRecipe(recipeName,recipeDescription);
        OWLOntology newonto = instance.getStore().getOntology();
        if(result){
            OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID + "MyRecipeNew"));
          
            int axiom = newonto.getAxioms(ruleind).size();
            assertEquals(2,axiom);
View Full Code Here

Examples of org.apache.stanbol.rules.manager.changes.AddRecipe

        Vector<IRI> rules = new Vector();
        rules.add(IRI.create(ID+"MyRuleC"));
        rules.add(IRI.create(ID+"MyRuleB"));
        rules.add(IRI.create(ID+"MyRuleA"));
        String recipeDescription = "My comment to the recipe";
        AddRecipe instance = new AddRecipe(load.getStore());
        boolean result = instance.addRecipe(recipeName, rules, recipeDescription);
        OWLOntology newonto = instance.getStore().getOntology();

        if(result){
            OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID + "MyRecipeNew"));
            int axiom = newonto.getAxioms(ruleind).size();
            assertEquals(8,axiom);
View Full Code Here

Examples of org.apache.stanbol.rules.manager.changes.AddRecipe

        //Load the example file
        LoadRuleFile load = new LoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
        String ID = owl.getOntologyID().toString().replace("<","").replace(">","")+"#";
        HashMap<String, Vector<IRI>> recipeMap = new HashMap();
        HashMap<String, String> recipeDescriptionMap = new HashMap();
        AddRecipe instance = new AddRecipe(load.getStore());

        Vector<IRI> rules = new Vector();
        rules.add(IRI.create(ID+"MyRuleC"));
        rules.add(IRI.create(ID+"MyRuleB"));
        rules.add(IRI.create(ID+"MyRuleA"));

        Vector<IRI> rules2 = new Vector();
        rules2.add(IRI.create(ID+"MyRuleE"));
        rules2.add(IRI.create(ID+"MyRuleF"));
        rules2.add(IRI.create(ID+"MyRuleD"));

        recipeMap.put("MyRecipeNEW1",rules);
        recipeMap.put("MyRecipeNEW2",rules2);
        recipeDescriptionMap.put("MyRecipeNEW1","My comment to the recipe new 1");
        recipeDescriptionMap.put("MyRecipeNEW2","My comment to the recipe new 2");

        boolean result = instance.addRecipeMap(recipeMap, recipeDescriptionMap);
        OWLOntology newonto = instance.getStore().getOntology();

       if(result){
            Iterator<String> keys = recipeMap.keySet().iterator();
            int axiom = 0;
            while(keys.hasNext()){
View Full Code Here

Examples of org.apache.stanbol.rules.manager.changes.AddRecipe

        LoadRuleFile load = new LoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);

        String ID = owl.getOntologyID().toString().replace("<","").replace(">","")+"#";
        HashMap<IRI, Vector<IRI>> recipeMap = new HashMap();
        HashMap<IRI, String> recipeDescriptionMap = new HashMap();
        AddRecipe instance = new AddRecipe(load.getStore());

        Vector<IRI> rules = new Vector();
        rules.add(IRI.create(ID+"MyRuleC"));
        rules.add(IRI.create(ID+"MyRuleB"));
        rules.add(IRI.create(ID+"MyRuleA"));

        Vector<IRI> rules2 = new Vector();
        rules2.add(IRI.create(ID+"MyRuleE"));
        rules2.add(IRI.create(ID+"MyRuleF"));
        rules2.add(IRI.create(ID+"MyRuleD"));

        recipeMap.put(IRI.create(ID+"MyRecipeNEW1"),rules);
        recipeMap.put(IRI.create(ID+"MyRecipeNEW2"),rules2);
        recipeDescriptionMap.put(IRI.create(ID+"MyRecipeNEW1"),"My comment to the recipe new 1");
        recipeDescriptionMap.put(IRI.create(ID+"MyRecipeNEW2"),"My comment to the recipe new 2");

        boolean result = instance.addRecipeMapIRI(recipeMap, recipeDescriptionMap);
        OWLOntology newonto = instance.getStore().getOntology();

       if(result){
            Iterator<IRI> keys = recipeMap.keySet().iterator();
            int axiom = 0;
            while(keys.hasNext()){
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.