public void runZipCode() throws Exception { OWLKnowledgeBase kb = OWLFactory.createKB(); service = kb.readService("http://localhost:8080/Temperatura/owls/getNameCar_NameCar.owl"); process = service.getProcess(); // initialize the input values to be empty values = new ValueMap(); values.setDataValue(process.getInput("arg0"), "CARRO"); values = exec.execute(process, values); // get the result OWLIndividual out = values.getIndividualValue(process.getOutput()); // display the results System.out.println("Executed service '" + service + "'"); System.out.println( "Grounding WSDL: " + ((AtomicProcess) process).getGrounding().getDescriptionURL()); System.out.println("City = " + "College Park"); System.out.println("State = " + "MD"); System.out.println("Output = "); System.out.println(Utils.formatRDF(out.toRDF())); System.out.println(); }
public void runFindCheaperBook() throws Exception { OWLKnowledgeBase kb = OWLFactory.createKB(); // we need a reasoner for example to work kb.setReasoner("Pellet"); // we need to check preconditions so that local variables will be assigned values exec.setPreconditionCheck(true); // read the service description service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/FindCheaperBook.owl"); process = service.getProcess(); // initialize the input values to be empty values = new ValueMap(); // use an arbitrary book name values.setDataValue(process.getInput("BookName"), "City of Glass"); values = exec.execute(process, values); // get the output values OWLIndividual price = values.getIndividualValue(process.getOutput("BookPrice")); String bookstore = values.getStringValue(process.getOutput("Bookstore")); // display the results System.out.println("Executed service " + service); System.out.println("Bookstore = " + bookstore); System.out.println("Price = "); System.out.println(Utils.formatRDF(price.toRDF())); System.out.println(); }
public void runBookPrice() throws Exception { String currencyOnt = "http://www.daml.ecs.soton.ac.uk/ont/currency.owl#"; OWLKnowledgeBase kb = OWLFactory.createKB(); // read the service description service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/BookPrice.owl"); process = service.getProcess(); // initialize the input values to be empty values = new ValueMap(); // use an arbitrary book name inValue = "City of Glass"; // get the parameter using the local name values.setDataValue(process.getInput("BookName"), inValue); values.setValue( process.getInput("Currency"), kb.getIndividual(URI.create(currencyOnt + "EUR"))); values = exec.execute(process, values); // get the output param using the index OWLIndividual out = values.getIndividualValue(process.getOutput()); // display the results System.out.println("Executed service " + service); System.out.println("Book Name = " + inValue); System.out.println("Price = "); System.out.println(Utils.formatRDF(out.toRDF())); System.out.println(); }
public void runBookFinder() throws Exception { OWLKnowledgeBase kb = OWLFactory.createKB(); // read the service description service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/BookFinder.owl"); process = service.getProcess(); // initialize the input values to be empty values = new ValueMap(); // use any book name inValue = "City of Glass"; // get the parameter using the local name values.setDataValue(process.getInput("BookName"), inValue); values = exec.execute(process, values); // get the output param using the index OWLIndividual out = values.getIndividualValue(process.getOutput()); // display the results System.out.println("Executing OWL-S service " + service); System.out.println( "Grounding WSDL: " + service .getGrounding() .getAtomicGrounding((AtomicProcess) process) .getDescriptionURL()); System.out.println("BookName = " + inValue); System.out.println("BookInfo = "); System.out.println(Utils.formatRDF(out.toRDF())); System.out.println(); }
public ValueMap invoke(ValueMap values, OWLKnowledgeBase kb) { System.out.println("invoke UPnPAtomic"); ControlPoint cp = new ControlPoint(); Device device = cp.getProxyDevice(getUPnPDescription()); Service service = device.getService(getUPnPService()); Action action = service.getAction(getUPnPAction()); ValueMap results = new ValueMap(); MessageMapList inputMapList = getInputMap(); ArgumentList inArguments = action.getInputArgumentList(); for (int i = 0; i < inArguments.size(); i++) { Argument in = inArguments.getArgument(i); MessageMap mp = inputMapList.getMessageMap(in.getName()); Parameter param = mp.getOWLSParameter(); Object value = values.getValue(param); Object inputValue = value; System.out.println("value = " + value); if (mp.getTransformation() != null) { value = XSLTEngine.transform(value.toString(), mp.getTransformation()); Node node = Utils.getAsNode(value.toString()); inputValue = node.getFirstChild().getNodeValue(); System.out.println("input value = " + value); } action.setArgumentValue(mp.getGroundingParameter().toString(), inputValue.toString()); } boolean ctrlRes = action.postControlAction(); if (ctrlRes == false) { UPnPStatus err = action.getControlStatus(); throw new ExecutionException( err.getDescription() + " (" + Integer.toString(err.getCode()) + ")"); } MessageMapList outputMapList = getOutputMap(); ArgumentList outArguments = action.getOutputArgumentList(); for (int i = 0; i < outArguments.size(); i++) { Argument out = outArguments.getArgument(i); MessageMap mp = outputMapList.getMessageMap(out.getName()); if (mp == null) continue; Parameter param = mp.getOWLSParameter(); Object outputValue = null; if (mp.getTransformation() == null) outputValue = out.getValue(); else outputValue = XSLTEngine.transform(out.getValue().toString(), mp.getTransformation()); // FIXME UPnP // results.setValue(param, outputValue); } return results; }
public void runCurrencyConverter() throws Exception { String currencyOnt = "http://www.daml.ecs.soton.ac.uk/ont/currency.owl#"; String conceptsOnt = "http://www.mindswap.org/2004/owl-s/concepts.owl#"; OWLKnowledgeBase kb = OWLFactory.createKB(); // read the service description service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/CurrencyConverter.owl"); process = service.getProcess(); // initialize the input values to be empty values = new ValueMap(); OWLIndividual EUR = kb.getIndividual(URI.create(currencyOnt + "EUR")); values.setValue(process.getInput("OutputCurrency"), EUR); OWLIndividual USD = kb.getIndividual(URI.create(currencyOnt + "USD")); OWLClass Price = kb.getClass(URI.create(conceptsOnt + "Price")); OWLObjectProperty currency = kb.getObjectProperty(URI.create(conceptsOnt + "currency")); OWLDataProperty amount = kb.getDataProperty(URI.create(conceptsOnt + "amount")); OWLIndividual inputPrice = kb.createInstance(Price); inputPrice.addProperty(currency, USD); inputPrice.addProperty(amount, "100"); // get the parameter using the local name values.setValue(process.getInput("InputPrice"), inputPrice); values = exec.execute(process, values); // get the output param using the index OWLIndividual out = values.getIndividualValue(process.getOutput()); // display the results System.out.println("Executed service " + service); System.out.println( "Grounding WSDL: " + ((AtomicProcess) process).getGrounding().getDescriptionURL()); System.out.println("Input = "); System.out.println(Utils.formatRDF(inputPrice.toRDF())); System.out.println("Output = "); System.out.println(Utils.formatRDF(out.toRDF())); System.out.println(); }
public void runTest() throws Exception { // create an OWL-S knowledge base final OWLKnowledgeBase kb = OWLFactory.createKB(); // create an empty ontology in this KB ont = kb.createOntology(URIUtils.standardURI(baseURI)); // create an execution engine final ProcessExecutionEngine exec = OWLSFactory.createExecutionEngine(); // load two services final Service s1 = kb.readService(ExampleURIs.BOOK_FINDER_OWLS12); final Service s2 = kb.readService(ExampleURIs.BN_BOOK_PRICE_OWLS12); // put the services in a list final List<Service> services = new ArrayList<Service>(); services.add(s1); services.add(s2); // create a new service as a sequence of the list final Service s = createSequenceService(services); // print the description of new service to standard output ont.write(System.out, baseURI); System.out.println(); // get the process of the new service final Process process = s.getProcess(); // initialize the input values to be empty ValueMap<Input, OWLValue> inputs = new ValueMap<Input, OWLValue>(); // get the parameter using the local name inputs.setValue(process.getInputs().get(0), kb.createDataValue("City of Glass")); // execute the service System.out.print("Executing..."); ValueMap<Output, OWLValue> outputs = exec.execute(process, inputs, kb); System.out.println("done"); // get the output parameter using the index final OWLIndividual outValue = outputs.getIndividualValue(process.getOutput()); // display the result System.out.println("Book Price = "); System.out.println(Utils.formatRDF(outValue.toRDF(true, true))); System.out.println(); }