Example #1
0
  /**
   * Create a new Sequence from the processes of the given services and put them in a new Service
   * object with a automatically generated Profile. This function assumes that each service in the
   * list has exactly one input and one output (except the first and last one) such that in the
   * resulting Service the output of each service will be fed as input to the next one. The first
   * service does not have to have an input and the last one does not need to have an output. The
   * resulting service will have an input (or an output) depending on this.
   *
   * @param services List of Service objects
   * @return The Service which is a Sequence of the given services
   */
  Service createSequenceService(final List<Service> services) {
    final Service service = ont.createService(URIUtils.createURI(baseURI, "BookService"));
    final CompositeProcess process =
        ont.createCompositeProcess(URIUtils.createURI(baseURI, "BookProcess"));
    final Profile profile = ont.createProfile(URIUtils.createURI(baseURI, "BookProfile"));
    final WSDLGrounding grounding =
        ont.createWSDLGrounding(URIUtils.createURI(baseURI, "BookGrounding"));

    System.out.println(ont.getKB().getServices(false));

    createSequenceProcess(process, services);
    createProfile(profile, process);

    final OWLIndividualList<Process> list = process.getComposedOf().getAllProcesses(false);
    for (Process pc : list) {
      if (pc instanceof AtomicProcess) {
        final AtomicGrounding<?> ag = ((AtomicProcess) pc).getGrounding();
        if (ag == null) continue;
        grounding.addGrounding(ag.castTo(WSDLAtomicGrounding.class));
      }
    }

    profile.setLabel(createLabel(services), null);
    profile.setTextDescription(profile.getLabel(null));

    service.addProfile(profile);
    service.setProcess(process);
    service.addGrounding(grounding);
    return service;
  }
Example #2
0
  /**
   * Create a Profile for the composite service. We only set the input and output of the profile
   * based on the process.
   */
  Profile createProfile(final Profile profile, final Process process) {
    for (Input input : process.getInputs()) {
      profile.addInput(input);
    }

    for (Output output : process.getOutputs()) {
      profile.addOutput(output);
    }

    return profile;
  }