ProcessExecutionEngineImpl.java revision 2
// The MIT License
//
// Copyright (c) 2004 Evren Sirin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
/*
* Created on Dec 29, 2003
*
*/
/**
* @author Evren Sirin
*
*/
public class ProcessExecutionEngineImpl implements ProcessExecutionEngine {
public static boolean DEBUG = false;
protected List executionListeners ;
protected OWLKnowledgeBase env;
protected OWLKnowledgeBase kb;
protected boolean checkPreconditions;
protected boolean allowMultipleSatisifedPreconditions;
protected Map performResults;
public ProcessExecutionEngineImpl() {
executionListeners = new ArrayList();
checkPreconditions = true;
}
}
public OWLKnowledgeBase getKB() {
return kb;
}
public void setPreconditionCheck(boolean checkPreconditions) {
this.checkPreconditions = checkPreconditions;
}
public boolean isPreconditionCheck() {
return checkPreconditions;
}
public boolean isAllowMultipleSatisifedPreconditions() {
}
public void setAllowMultipleSatisifedPreconditions(boolean allowMultipleSatisifedPreconditions) {
}
/**
* @deprecated
*/
while(i.hasNext()) {
l.printMessage(msg);
}
}
/**
* @deprecated
*/
protected void setCurrentExecuteService(Process p) {
while (i.hasNext()) {
l.setCurrentExecuteService(p);
}
}
/**
* @deprecated
*/
protected void finishExecution(int retCode) {
while (i.hasNext())
{
}
}
/**
* @deprecated
*/
}
}
}
protected void executionFailed(Exception e) {
executionFailed( new ExecutionException( e ) );
}
protected void executionFailed(ExecutionException e) {
}
throw e;
}
if( process instanceof AtomicProcess )
else if( process instanceof CompositeProcess )
else
}
}
}
}
}
protected void executionStarted() {
}
}
protected void executionFinished() {
}
}
else
performResults = new HashMap();
}
return result;
}
try {
} catch( ExecutionException e ) {
executionFailed( e );
}
notifyListeners("[DONE]");
return result;
}
try {
result = executePerform( p );
} catch( ExecutionException e ) {
executionFailed( e );
}
notifyListeners("[DONE]");
return result;
}
if( checkPreconditions ) {
}
if(process instanceof AtomicProcess) {
}
else if(process instanceof CompositeProcess) {
}
else if(process instanceof SimpleProcess) {
new NotImplementedException("Executing simple processes is not implemented!") );
}
else
// just for safety
else
return result;
}
if(DEBUG) System.out.println("Executing AtomicProcess " + process + "\nInputs:\n" + values.debugString());
if( !env.isConsistent() )
throw new ExecutionException(
"Invalid value returned from the process " + process );
return result;
}
// ValueMap prevThisPerform = (ValueMap) performResults.get(OWLS.Process.ThisPerform);
// performResults.put(OWLS.Process.ThisPerform, new ValueMap());
if(paramValue instanceof ValueOf) {
if(performResult == null)
}
else
new NotImplementedException("Only ValueOf construct in Bindings is supported!") );
}
}
// values.addMap( (ValueMap) performResults.get( OWLS.Process.ThisPerform ) );
// performResults.put(OWLS.Process.ThisPerform, prevThisPerform);
return values;
}
if(paramValue instanceof ValueData)
else if(paramValue instanceof ValueOf) {
if(performResult == null)
else
}
else
}
}
}
return values;
}
if(paramValue instanceof ValueData)
else if(paramValue instanceof ValueOf) {
if(performResult == null)
}
}
}
else if(cc instanceof IfThenElse)
else if(cc instanceof RepeatWhile)
else if(cc instanceof RepeatUntil)
else
}
}
}
// AnyOrder says it doesn't matter in which order subelements
// are executed so let's try the sequential order
// FIXME check preconditions to find a correct ordering
}
}
// Choose a random component to execute
// FIXME check preconditions to find an executable component
}
if( isTrue( ifCondition ))
}
while( isTrue( whileCondition ) )
}
do {
}
while( !isTrue( repeatCondition ) );
}
if(performResult == null)
}
}
// Get the precondition
// Get the conjunction of atoms and apply the current value bindings
// This is empty body so nothing to do here (trivially true)
continue;
// Turn this into
}
}
}
}
class ProcessExecutionThread extends Thread {
}
public void run() {
}
}
}
if(join) {
try {
} catch (InterruptedException e) {
notifyListeners("[ERROR]\n");
notifyListeners("Execution Stopped\n");
executionFailed( e );
}
}
}
}
}