2ronwalf// The MIT License
2ronwalf//
2ronwalf// Copyright (c) 2004 Evren Sirin
2ronwalf//
2ronwalf// Permission is hereby granted, free of charge, to any person obtaining a copy
2ronwalf// of this software and associated documentation files (the "Software"), to
2ronwalf// deal in the Software without restriction, including without limitation the
2ronwalf// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
2ronwalf// sell copies of the Software, and to permit persons to whom the Software is
2ronwalf// furnished to do so, subject to the following conditions:
2ronwalf//
2ronwalf// The above copyright notice and this permission notice shall be included in
2ronwalf// all copies or substantial portions of the Software.
2ronwalf//
2ronwalf// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2ronwalf// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2ronwalf// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2ronwalf// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2ronwalf// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2ronwalf// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2ronwalf// IN THE SOFTWARE.
2ronwalf
2ronwalf/*
2ronwalf * Created on Dec 27, 2003
2ronwalf *
2ronwalf */
22daenzeroramapackage impl.owls.process.parameter;
2ronwalf
2ronwalfimport impl.owl.WrappedIndividual;
2ronwalf
2ronwalfimport java.net.URI;
2ronwalf
2ronwalfimport org.mindswap.owl.EntityFactory;
2ronwalfimport org.mindswap.owl.OWLDataValue;
2ronwalfimport org.mindswap.owl.OWLIndividual;
2ronwalfimport org.mindswap.owl.OWLType;
2ronwalfimport org.mindswap.owl.OWLValue;
2ronwalfimport org.mindswap.owls.process.Parameter;
2ronwalfimport org.mindswap.owls.process.Process;
2ronwalfimport org.mindswap.owls.profile.Profile;
2ronwalfimport org.mindswap.owls.service.Service;
2ronwalfimport org.mindswap.owls.vocabulary.OWLS;
2ronwalfimport org.mindswap.utils.RDFUtils;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf *
2ronwalf */
2ronwalfpublic abstract class ParameterImpl extends WrappedIndividual implements Parameter {
2ronwalf public ParameterImpl(OWLIndividual ind) {
2ronwalf super(ind);
2ronwalf }
2ronwalf
2ronwalf public OWLType getParamType() {
2ronwalf URI typeURI = getPropertyAsURI(OWLS.Process.parameterType);
2ronwalf
2ronwalf OWLType type = null;
2ronwalf
2ronwalf if(typeURI != null) {
2ronwalf type = getKB().getType(typeURI);
2ronwalf
2ronwalf // if it is an unknown entity assume it is a OWLClass
2ronwalf if(type == null)
2ronwalf type = EntityFactory.createClass(typeURI);
2ronwalf }
2ronwalf
2ronwalf return type;
2ronwalf }
2ronwalf
2ronwalf public void setParamType(OWLType type) {
2ronwalf setProperty(OWLS.Process.parameterType, type.getURI());
2ronwalf }
2ronwalf
2ronwalf /* (non-Javadoc)
2ronwalf * @see org.mindswap.owls.process.Parameter#getProcess()
2ronwalf */
2ronwalf public Process getProcess() {
2ronwalf OWLIndividual ind = getIncomingProperty(OWLS.Process.hasParameter);
2ronwalf return (ind == null) ? null : (Process) ind.castTo(Process.class);
2ronwalf }
2ronwalf
2ronwalf /* (non-Javadoc)
2ronwalf * @see org.mindswap.owls.process.Parameter#getProcess(org.mindswap.owls.process.Process)
2ronwalf */
2ronwalf public void setProcess(Process process) {
2ronwalf process.addParameter(this);
2ronwalf }
2ronwalf
2ronwalf /* (non-Javadoc)
2ronwalf * @see org.mindswap.owls.process.Parameter#getService()
2ronwalf */
2ronwalf public Service getService() {
2ronwalf Process process = getProcess();
2ronwalf return (process == null) ? null : process.getService();
2ronwalf }
2ronwalf
2ronwalf /* (non-Javadoc)
2ronwalf * @see org.mindswap.owls.process.Parameter#getProfile()
2ronwalf */
2ronwalf public Profile getProfile() {
2ronwalf OWLIndividual ind = getIncomingProperty(OWLS.Profile.hasInput);
2ronwalf return (ind == null) ? null : (Profile) ind.castTo(Profile.class);
2ronwalf }
2ronwalf
2ronwalf public String debugString() {
2ronwalf String str = getLabel() + " " + getParamType() + " " + getURI();
2ronwalf
2ronwalf return str;
2ronwalf }
2ronwalf
2ronwalf /**
2ronwalf * @return Returns the constantValue.
2ronwalf */
2ronwalf public OWLValue getConstantValue() {
2ronwalf OWLDataValue dataValue = getProperty(OWLS.Process.parameterValue);
2ronwalf if(dataValue != null) {
2ronwalf OWLType paramType = getParamType();
2ronwalf OWLValue owlValue = null;
2ronwalf if((paramType == null) || paramType.isDataType())
2ronwalf owlValue = dataValue;
2ronwalf else {
2ronwalf String rdf = RDFUtils.addRDFTag( dataValue.getLexicalValue() );
2ronwalf owlValue = getOntology().parseLiteral( rdf );
2ronwalf }
2ronwalf
2ronwalf return owlValue;
2ronwalf }
2ronwalf
2ronwalf return null;
2ronwalf }
2ronwalf
2ronwalf /**
2ronwalf * @param constantValue The constantValue to set.
2ronwalf */
2ronwalf public void setConstantValue(OWLValue value) {
2ronwalf if( value.isDataValue() )
2ronwalf setProperty(OWLS.Process.valueData, (OWLDataValue) value);
2ronwalf else
2ronwalf setProperty(OWLS.Process.valueData, ((OWLIndividual) value).toRDF(false));
2ronwalf }
2ronwalf}