/*
* Created on Sep 9, 2005
*/
package examples;
/**
* <p>
* This example shows how to create a complex process model that is shown in the file
* <a href="http://www.mindswap.org/2004/owl-s/1.1/FindCheaperBook.owl">FindCheaperBook.owl
* </a>. The process model contains a sequence that starts with a service that gets the
* price for a given book title, then has a SplitJoin to get the book price from Amazon and
* Barnes&Nobles concurrently, and as a last step has an If-Then-Else construct to compare
* the prices and return the cheaper book price.
*
* @author Evren Sirin
*
*/
public class CreateComplexProcess {
public static final URI concepts = URI.create( "http://www.mindswap.org/2004/owl-s/concepts.owl#" );
// knowledge base we are going to use
// ontology where service descirption is saved
// swrl factory to create consitions and expressions
// processes we will use
// commonly used classes, properties, datatypes
// the process we create to do the comparison
// the inputs of the comparison process
// the outputs of the comparison process
public CreateComplexProcess() {
}
}
return service;
}
"Find the price of book in Amazon and Barnes & Nobles " +
"and return the cheaper price" );
}
}
return profile;
}
if( pc instanceof AtomicProcess ) {
}
}
return grounding;
}
// create the composite process
// Create an input that has parameterType xsd:string
// Create an output that has parameterType xsd:string
// Create an output that has parameterType concepts:Price
// process is composed of a sequence
// first element of the sequence is a simple perform
// the input of the perform is coming from the parent perform
// add thid perform as the first element of the sequence
// second element of the sequence is a Split-Join that has to performs in it
// first perform AmazonPrice
// the input of the perform is coming from FindBookInfo perform
// add it to the split-join
// then similarly perform BNPrice
// the input of the perform is coming from FindBookInfo perform
// add it to the split-join
// finally add the Split-Join to the sequence
// feed the input from book previous performs to the comparison process
// add the comparison step as the last construct in the sequence
return process;
}
// we need a new composite process for the last step to do the
// comparison (we need local variables whihc can only be declared
// in conjunction with a process)
// the price from two bookstores as input
// the actual value for each price as locals
Local CP_AmazonPriceAmount = ComparePricesProcess.createLocal( uri( "CP_AmazonPriceAmount"), xsdFloat );
// the minimum price and the associated bookstore as outputs
// the first precondition is just to bind the value of concepts:amount property
// to the local variable for AmazonPrice
// exactly same as the previous one but for BNPrice. note that we could have
// equivalently create one precondition and add two atoms in it. the operational
// semantics would be same because multiple preconditions are simply conjuncted
// ComparePricesProcess is simply one If-Then-Else
// now the condition for If-Then-Else to compare values
// set the condition
// create two produce constructs to generate the results
return ComparePricesProcess;
}
// the produce construct to produce the price
// we directly pass the input value from the parent process as output to the parent process
// the produce construct to produce the name
// we need a constant string value to produce so use process:ValueData
// add the binding for this output
// now add both produce into this sequence
return sequence;
}
// create an OWL-S knowledge base
// create an empty ontology in this KB
// create SWRLFactory we will use for creating conditions and expressions
// load three OWL-S files and directly get the processes we want
AmazonPrice = kb.readService("http://www.mindswap.org/2004/owl-s/1.1/AmazonBookPrice.owl#").getProcess();
// also add the imports statement
// get common classes, properties and datatypes we will need
// create the service
Service s = createService();
// print the description of new service to standard output
// create an execution engine
// get the process of the new service
// initialize the input values to be empty
// get the parameter using the local name
// execute the service
// get the output param using the index
// display the result
}
}
}