Esempio n. 1
0
  /* @see org.mindswap.owls.process.Input#transformInputType() */
  public boolean transformInputType() {
    OWLDataValue dv = getProperty(FLAServiceOnt.transformInputType);
    if (dv != null && Boolean.FALSE.toString().equals(dv.getLexicalValue().trim().toLowerCase()))
      return false;

    return true;
  }
Esempio n. 2
0
  /**
   * @param viskoService
   * @param inputDataURL
   * @param serviceIndex
   * @return
   * @throws ExecutionException
   */
  private String executeService(
      edu.utep.trustlab.visko.ontology.viskoService.Service viskoService,
      String inputDataURL,
      int serviceIndex)
      throws ExecutionException {

    OWLKnowledgeBase kb = OWLFactory.createKB();
    Service service = viskoService.getOWLSService().getIndividual();
    Process process = service.getProcess();

    ValueMap<Input, OWLValue> inputs =
        OWLSParameterBinder.buildInputValueMap(
            process, inputDataURL, job.getPipeline().getParameterBindings(), kb);

    String outputDataURL = null;

    if (inputs != null) {
      ValueMap<Output, OWLValue> outputs;

      if (job.isSimulated()) outputDataURL = ServiceSimulator.exec();
      else {
        outputs = exec.execute(process, inputs, kb);
        OWLDataValue out = (OWLDataValue) outputs.getValue(process.getOutput());
        outputDataURL = out.toString();
      }

      if (job.getProvenanceLogging()) {
        pmlLogger.recordServiceInvocation(viskoService, inputDataURL, outputDataURL, inputs);
        provLogger.recordServiceInvocation(viskoService, inputDataURL, outputDataURL, inputs);
      }
    }
    return outputDataURL;
  }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * @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;
 }
  /** @return Returns the constantValue. */
  public OWLValue getConstantValue() {
    OWLDataValue dataValue = getProperty(OWLS.Process.parameterValue);
    if (dataValue != null) {
      OWLType paramType = getParamType();
      OWLValue owlValue = null;
      if ((paramType == null) || paramType.isDataType()) owlValue = dataValue;
      else {
        String rdf = RDFUtils.addRDFTag(dataValue.getLexicalValue());
        owlValue = getOntology().parseLiteral(rdf);
      }

      return owlValue;
    }

    return null;
  }
Esempio n. 6
0
 /**
  * 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;
 }
Esempio n. 7
0
  public void runDictionary() throws Exception {
    OWLKnowledgeBase kb = OWLFactory.createKB();
    service = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/Dictionary.owl");
    process = service.getProcess();

    // initialize the input values to be empty
    values = new ValueMap();

    inValue = "hello";
    values.setDataValue(process.getInput("InputString"), inValue);
    values = exec.execute(process, values);

    // get the output
    OWLDataValue out = (OWLDataValue) values.getValue(process.getOutput());

    // display the results
    System.out.println("Executed service '" + service + "'");
    System.out.println(
        "Grounding WSDL: " + ((AtomicProcess) process).getGrounding().getDescriptionURL());
    System.out.println("Input  = " + inValue);
    System.out.println("Output = " + out.toString());
    System.out.println();
  }
Esempio n. 8
0
 /**
  * @param prop
  * @param lang
  * @return
  */
 protected String getPropertyAsString(final OWLDataProperty prop, final String lang) {
   final OWLDataValue value = individual.getProperty(prop, lang);
   return (value == null) ? null : value.toString();
 }
Esempio n. 9
0
 /**
  * @param <T>
  * @param prop
  * @param result
  * @return
  */
 protected <T extends OWLDataValue> T getPropertyAs(
     final OWLDataProperty prop, final Class<T> result) {
   final OWLDataValue value = individual.getProperty(prop);
   return (value == null) ? null : value.castTo(result);
 }