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(); }
/* @see org.mindswap.owl.OWLProvider#castList(java.util.List, java.lang.Class) */ public <T extends OWLIndividual> OWLIndividualList<T> castList( final List<? extends OWLIndividual> list, final Class<T> castTarget) { assert (list != null && castTarget != null) : "Illegal: list and/or cast target parameter was null."; final OWLIndividualList<T> result = createIndividualList(); T element; for (final OWLIndividual individual : list) { element = individual.castTo(castTarget); result.add(element); } return result; }
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(); }
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(); }
/** * Assuming that the range of values of the given data property can be parsed to URIs (e.g. typed * to <tt>xsd:anyURI</tt>), this method gets all values of the property in the backing KB and * tries to parse them into a URI. If a value can not be parsed it will be silently ignored. * * @param prop The data property whose range is expected to be <tt>xsd:anyURI</tt>. * @return The list of all URIs. */ protected List<URI> getPropertiesAsURI(final OWLDataProperty prop) { List<OWLDataValue> tmp = individual.getProperties(prop); List<URI> uris = new ArrayList<URI>(tmp.size()); for (OWLDataValue dataValue : tmp) { final Object value = dataValue.getValue(); if (value instanceof URI) uris.add((URI) value); try { uris.add(new URI(value.toString())); } catch (URISyntaxException ignore) { // we can not recover anyway; we could log something, which would be additional work } } return uris; }
/** * @param prop * @return */ protected URI getPropertyAsURI(final OWLDataProperty prop) { final OWLDataValue dv = individual.getProperty(prop); if (dv != null) { final Object value = dv.getValue(); if (value instanceof URI) return (URI) value; try { return new URI(value.toString().trim()); } catch (NullPointerException e) { /* fall through, we can not recover anyway */ } catch (URISyntaxException e) { /* fall through, we can not recover anyway */ } } return null; }
/** * This method can be used if it is known that the value of the given property syntactically * represents a URL. * * @return The value of the property converted to an URL. Returns <code>null</code> if there is no * statement containing this individual and the property, or the value is a malformed URL. */ protected URL getPropertyAsURL(final OWLDataProperty prop) { final OWLDataValue dv = individual.getProperty(prop); if (dv != null) { final Object value = dv.getValue(); try { if (value instanceof URI) return ((URI) value).toURL(); return new URL(value.toString().trim()); } catch (NullPointerException e) { /* fall through, we can not recover anyway */ } catch (IllegalArgumentException e) { /* fall through, we can not recover anyway */ } catch (MalformedURLException ignore) { /* fall through, we can not recover anyway */ } } return null; }
@Override public Service getIndividual() { Service service = null; if (allFieldsPopulated() && !isForReading) { // create service WSDLTranslatorBuilder builder = new WSDLTranslatorBuilder(model.getOntology(), operationName, wsdlURL); service = builder.getTranslator().getService(); service.setLabel(label, null); if (isOperatorService) { service.addProperty(supportingToolkitProperty, getToolkitAsOWLIndividual()); service.addProperty(implementsOperatorProperty, getOperatorAsOWLIndividual()); } else service.addProperty(implementsExtractorProperty, getExtractorAsOWLIndividual()); } else if (!allFieldsPopulated() && !isForReading) { System.out.println("all fields not populated...."); } else { // read service and populate service object service = model.readService(uri); OWLIndividual operator = service.getProperty(implementsOperatorProperty); OWLIndividual toolkit = service.getProperty(supportingToolkitProperty); OWLIndividual extractor = service.getProperty(implementsExtractorProperty); ViskoModel viskoModel = new ViskoModel(); if (operator != null && toolkit != null) { supportingToolkit = new Toolkit(toolkit.getURI().toASCIIString(), viskoModel); implementedOperator = new Operator(operator.getURI().toASCIIString(), viskoModel); } if (extractor != null) implementedExtractor = new Extractor(extractor.getURI().toASCIIString(), viskoModel); } return service; }
public WrappedIndividual(final OWLIndividual ind) { individual = ind; setNextView(ind.getNextView()); ind.setNextView(this); }
/* @see org.mindswap.owl.OWLEntity#getNamespace() */ public String getNamespace() { return individual.getNamespace(); }
/* @see org.mindswap.owl.OWLIndividual#delete() */ public void delete() { individual.delete(); }
/* @see org.mindswap.owl.OWLEntity#toPrettyString() */ public String toPrettyString() { return individual.toPrettyString(); }
/* @see org.mindswap.owl.OWLIndividual#getProperty(org.mindswap.owl.OWLObjectProperty) */ public OWLIndividual getProperty(final OWLObjectProperty prop) { return individual.getProperty(prop); }
/* @see org.mindswap.owl.OWLIndividual#hasProperty(org.mindswap.owl.OWLProperty, org.mindswap.owl.OWLValue) */ public boolean hasProperty(final OWLProperty prop, final OWLValue value) { return individual.hasProperty(prop, value); }
/* @see org.mindswap.owl.OWLIndividual#addDifferentFrom(org.mindswap.owl.OWLIndividual) */ public void addDifferentFrom(final OWLIndividual other) { individual.addDifferentFrom(other); }
/* @see org.mindswap.owl.OWLIndividual#getSameIndividuals() */ public OWLIndividualList<?> getSameIndividuals() { return individual.getSameIndividuals(); }
/* @see org.mindswap.owl.OWLIndividual#isSameAs(org.mindswap.owl.OWLIndividual) */ public boolean isSameAs(final OWLIndividual other) { return individual.isSameAs(other); }
/* @see org.mindswap.owl.OWLIndividual#addSameAs(org.mindswap.owl.OWLIndividual) */ public void addSameAs(final OWLIndividual other) { individual.addSameAs(other); }
/* @see org.mindswap.owl.OWLIndividual#getSourceOntology() */ public OWLOntology getSourceOntology() { return individual.getSourceOntology(); }
/* @see org.mindswap.owl.OWLIndividual#toRDF(boolean, boolean) */ public String toRDF(final boolean withRDFTag, final boolean keepNamespaces) { return individual.toRDF(withRDFTag, keepNamespaces); }
/* @see org.mindswap.owl.OWLObject#getImplementation() */ public Object getImplementation() { return individual.getImplementation(); }
/* @see org.mindswap.owl.OWLIndividual#hasProperty(org.mindswap.owl.OWLProperty) */ public boolean hasProperty(final OWLProperty prop) { return individual.hasProperty(prop); }
/* @see org.mindswap.owl.OWLIndividual#isDifferentFrom(org.mindswap.owl.OWLIndividual) */ public boolean isDifferentFrom(final OWLIndividual other) { return individual.isDifferentFrom(other); }
/* @see org.mindswap.owl.OWLIndividual#getProperties() */ public Map<OWLProperty, List<OWLValue>> getProperties() { return individual.getProperties(); }
/* @see org.mindswap.owl.OWLIndividual#getDifferentIndividuals() */ public OWLIndividualList<?> getDifferentIndividuals() { return individual.getDifferentIndividuals(); }
/* @see org.mindswap.owl.OWLIndividual#removeSameAs(org.mindswap.owl.OWLIndividual) */ public void removeSameAs(final OWLIndividual other) { individual.removeSameAs(other); }
/* @see org.mindswap.owl.OWLIndividual#removeDifferentFrom(org.mindswap.owl.OWLIndividual) */ public void removeDifferentFrom(final OWLIndividual other) { individual.removeDifferentFrom(other); }