OWLSTranslator_1_0.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 27, 2003
*
*/
/**
* @author Evren Sirin
*
*/
public class OWLSTranslator_1_0 implements OWLSVersionTranslator {
public static boolean DEBUG = false;
private OWLKnowledgeBase kb;
private OWLOntology inputOnt;
private OWLOntology outputOnt;
/*******************************************
** added by guang huang @2005-4-12 **
********************************************/
/*******************************************
** end by guang huang **
********************************************/
private Map translation;
/**
*
*/
public OWLSTranslator_1_0() {
}
public String getVersion() {
return "1.0";
}
}
translation = new HashMap();
}
/*******************************************
** added by guang huang @2005-4-8 **
*corrrect source version bug
********************************************/
if (canTranslate(ont))
outputOnt.addType(ont.getInstances(OWLS_1_0.Service.Service).individualAt(0), OWLS_1_0.Service.Service);
/*******************************************
** end by guang huang **
********************************************/
return outputOnt;
}
private void translateServices() {
}
}
private void translateProfiles() {
}
}
private void translateProcesses() {
// we are not using reasoning so loop through all possible process
// instances
OWLClass[] processClass = {
}
}
}
private void translateGroundings() {
OWLClass[] groundingClass = {
}
}
}
private void translateAtomicGroundings() {
OWLClass[] groundingClass = {
}
}
}
while(i.hasNext()) {
}
}
return null;
}
if(translated == null) {
else
}
return translated;
}
if(translated == null) {
else
}
return translated;
}
try{
if(translated != null) {
}
return service;
} catch (RuntimeException e) {
error("Invalid service description");
e.printStackTrace();
return null;
}
}
return createProcess(processInfo);
}
try {
if(translated != null) {
}
else {
return null;
}
return process;
} catch (RuntimeException e) {
error("Invalid process description");
e.printStackTrace();
return null;
}
}
AtomicProcess process = (AtomicProcess) translate(processInfo, AtomicProcess.class, OWLS_1_1.Process.AtomicProcess);
return process;
}
SimpleProcess process = (SimpleProcess) translate(processInfo, SimpleProcess.class, OWLS_1_1.Process.SimpleProcess);
// FIXME translate SimpleProcess properties
return process;
}
CompositeProcess process = (CompositeProcess) translate(processInfo, CompositeProcess.class, OWLS_1_1.Process.CompositeProcess);
if(composedInfo == null) {
error("Cannot find the components for composite process (" +
}
else {
}
return process;
}
}
else
return cc;
}
return perform;
}
return sequence;
}
IfThenElse ifThenElse = (IfThenElse) translate(ifThenElseInfo, IfThenElse.class, OWLS_1_1.Process.IfThenElse);
}
else
error("If-Then-Else does not have a process:ifCondition associated with it (" +
if(thenComponent != null)
else
error("If-Then-Else has an invalid process:then associated with it (" +
}
else
error("If-Then-Else does not have a process:then associated with it (" +
if(elseComponent != null)
else
error("If-Then-Else has an invalid process:else associated with it (" +
}
return ifThenElse;
}
return split;
}
return split;
}
return unordered;
}
// createComponents(iterate, iterateInfo);
// if(iterate.getComponents().size() > 1)
// error("Iterate should have only one component " + iterateInfo);
return iterate;
}
RepeatUntil repeat = (RepeatUntil) translate(repeatInfo, RepeatUntil.class, OWLS_1_1.Process.RepeatUntil);
}
else
error("RepeatUntil does not have a process:untilCondition associated with it (" +
error("RepeatUntil cannot have a process:components property. Use process:untilProcess instead!");
}
if(untilComponent != null)
else
error("RepeatUntil has an invalid process:untilProcess associated with it (" +
}
else
error("RepeatUntil does not have a process:untilProcess associated with it (" +
return repeat;
}
RepeatWhile repeat = (RepeatWhile) translate(repeatInfo, RepeatWhile.class, OWLS_1_1.Process.RepeatWhile);
}
else
error("RepeatUntil does not have a process:ifCondition associated with it (" +
error("RepeatWhile cannot have a process:components property. Use process:untilProcess instead!");
}
if(whileComponent != null)
else
error("RepeatWhile has an invalid process:whileProcess associated with it (" +
}
else
error("RepeatWhile does not have a process:whileProcess associated with it (" +
return repeat;
}
return choice;
}
if(componentsInfo == null) {
return;
}
while(i.hasNext()) {
else
throw new RuntimeException("Invalid control construct!");
}
}
try {
// FIXME handle this case using ThisPerform
error("Same process used twice in the ValueOf!");
}
// add binding to the perform
}
else {
// add result to the process
}
}
}
// add binding to the perform
}
else {
// add result to the process
}
}
}
else {
// add binding to the perform1
}
else {
// add binding to the perform1
}
}
}
} catch(Exception e) {
error("Invalid data flow specification ");
e.printStackTrace();
}
}
if(translated != null) {
}
else {
return null;
}
}
else {
// FIXME default values
}
}
else
error("Cannot find the type for the process parameter (" +
/*******************************************
** added by guang huang @2005-4-8 **
*Keep <fla:useRandomInput>true</fla:useRandomInput> in
*process:Input or process:Onput
********************************************/
try {
}
} catch (Exception e) {
// TODO: handle exception
}
}
/*******************************************
** end by guang huang **
********************************************/
return param;
}
if(isInput) {
param = createParam(p);
}
else {
param = createParam(p);
}
if(DEBUG) {
}
}
}
try {
if(translated != null) {
}
copyPropertyValues(profileInfo, OWLS_1_0.Profile.serviceName, profile, OWLS_1_1.Profile.serviceName);
/*******************************************
** added by guang huang @2005-4-8 **
*Keep FLAServiceParameter
********************************************/
/*******************************************
** end by guang huang **
********************************************/
return profile;
} catch (RuntimeException e) {
error("Invalid profile description");
e.printStackTrace();
return null;
}
}
copyPropertyValues(serviceParamInfo, OWLS_1_0.Profile.serviceParameterName, serviceParam, OWLS_1_1.Profile.serviceParameterName);
}
}
}
if(translated == null) {
return createProcess(ind);
if(prop instanceof OWLDataProperty)
else {
}
}
}
}
return translated;
}
error("The parameter defined in profile does not exist in the process model (" +
"\n parameter: " + p + ", " +
}
else {
if(isInput) {
}
}
else
if(DEBUG) {
p.getURI() + "\n" +
}
}
}
}
return;
Condition condition = (Condition) translate(conditionInfo, Condition.class, OWLS_1_1.Expression.Condition);
}
Condition condition = (Condition) translate(conditionInfo, Condition.class, OWLS_1_1.Expression.Condition);
}
}
if(translated != null) {
}
Grounding grounding = (Grounding) translate(groundingInfo, Grounding.class, OWLS_1_1.Grounding.WsdlGrounding);
OWLIndividualList list = inputOnt.getProperties(groundingInfo, OWLS_1_0.Grounding.hasAtomicProcessGrounding);
if(apGrounding != null)
else
}
if(apGrounding != null)
else
}
warning("The grounding of the service is empty (" +
return grounding;
}
try {
if(translated != null) {
}
return grounding;
} catch (RuntimeException e) {
error("Invalid profile description");
e.printStackTrace();
return null;
}
}
try {
} catch(Exception e) {
+ groundingInfo + " is not a valid URI literal");
}
return null;
}
return null;
}
error("The process specified in the grounding cannot be found (" +
return null;
}
return process;
}
OWLIndividual operationInfo = inputOnt.getProperty(groundingInfo, OWLS_1_0.Grounding.wsdlOperation);
WSDLAtomicGrounding g = (WSDLAtomicGrounding) translate(groundingInfo, WSDLAtomicGrounding.class, OWLS_1_1.Grounding.WsdlAtomicProcessGrounding);
g.setOperation(opName);
g.setPortType(portType);
g.setProcess(process);
createMessageMapList(g, groundingInfo, true);
createMessageMapList(g, groundingInfo, false);
}
else
if(DEBUG) {
}
return g;
}
UPnPAtomicGrounding g = (UPnPAtomicGrounding) translate(groundingInfo, UPnPAtomicGrounding.class, FLAServiceOnt.UPnPAtomicProcessGrounding);
g.setProcess(process);
createMessageMapList(g, groundingInfo, true);
createMessageMapList(g, groundingInfo, false);
if(DEBUG) {
}
return g;
}
private void createMessageMapList(AtomicGrounding g, OWLIndividual groundingInfo, boolean isInput) {
if(g instanceof UPnPAtomicGrounding) {
messageParts = isInput ?
}
else if(g instanceof WSDLAtomicGrounding) {
messageParts = isInput ?
}
// try older property name
if(messageMaps != null)
}
if(messageMaps == null) {
warning("No mapping defined for parameters (" +
"\n parameters: " + params +
}
return;
}
/*******************************************
** modified by guang huang @2005-4-14**
********************************************/
/*******************************************
** end by guang huang **
********************************************/
while(i.hasNext()) {
URI owlsParameterInfo = inputOnt.getProperty(messageMap, OWLS_1_0.Grounding.owlsParameter).getURI();
transformation = inputOnt.getProperty(messageMap, OWLS_1_0.Grounding.xsltTransformation).toString();
}
if(owlsParameter == null) {
}
else
if(DEBUG) {
}
}
}
private void copyPropertyValues(OWLIndividual src, OWLDataProperty srcProp, OWLIndividual target, OWLDataProperty targetProp) {
}
private void copyPropertyValues(OWLIndividual src, URI srcProp, OWLIndividual target, URI targetProp) {
}
}
}
/*******************************************
** added by guang huang @2005-4-8 **
********************************************/
if(translated != null) {
if(prop instanceof OWLDataProperty) {
}
} else {
translated.addProperty((OWLDataProperty)FLAServiceOnt.flaObjectPropertiesToDataProperties.get(prop), serviceParamInfo);
}
serviceParamValue = translate(serviceParamValue, (OWLClass) FLAServiceOnt.flaObjectProperties.get(objProp));
}
}
}
}
}
return translated;
}
// private URI getURI(OWLDataValue value) {
// try {
// return new URI(value.getLexicalValue().trim());
// } catch (URISyntaxException e) {
// // TODO Auto-generated catch block
//// e.printStackTrace();
// try {
// return new URI("http://fla.flacp.fujitsu.com/" + value.getLexicalValue().trim());
// } catch (URISyntaxException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// return null;
// }
// }
// }
/*******************************************
** end by guang huang **
********************************************/
}