ProcessImpl.java revision 24
cfba646ddfa9d543f0c40e4c7788c65b4a24b34dPhill Cunnington// The MIT License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster//
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// Copyright (c) 2004 Evren Sirin
b5d0a7678bb70ad5c444450d4527d04a87b6945fNeil Madden//
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// Permission is hereby granted, free of charge, to any person obtaining a copy
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// of this software and associated documentation files (the "Software"), to
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// deal in the Software without restriction, including without limitation the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// sell copies of the Software, and to permit persons to whom the Software is
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// furnished to do so, subject to the following conditions:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster//
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// The above copyright notice and this permission notice shall be included in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// all copies or substantial portions of the Software.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster//
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// IN THE SOFTWARE.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp/*
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp * Created on Dec 27, 2003
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenpackage impl.owls.process;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenimport impl.owl.WrappedIndividual;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenimport java.net.URI;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenimport org.mindswap.owl.OWLDataValueList;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owl.OWLIndividual;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owl.OWLType;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.OWLSFactory;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.process.Condition;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenimport org.mindswap.owls.process.ConditionList;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.process.Input;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.process.InputList;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.process.Local;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenimport org.mindswap.owls.process.Output;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.process.OutputList;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.process.Parameter;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenimport org.mindswap.owls.process.ParameterList;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenimport org.mindswap.owls.process.Perform;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.process.Process;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.process.Result;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenimport org.mindswap.owls.process.ResultList;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.mindswap.owls.profile.Profile;
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Pappimport org.mindswap.owls.service.Service;
a82d04bc19fee9d5e34b41ccd7641da1f62ab634Neil Maddenimport org.mindswap.owls.vocabulary.OWLS;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Maddenimport org.mindswap.owls.vocabulary.OWLS_Extensions;
19d4a53f98a937856572a10d60720f45f18b4ae2Neil Madden
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @author Evren Sirin
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic abstract class ProcessImpl extends WrappedIndividual implements Process {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ProcessImpl(OWLIndividual ind) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super(ind);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden /* (non-Javadoc)
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp * @see org.mindswap.owls.process.Process#getService()
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Service getService() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (Service) getPropertyAs(OWLS.Service.describes, Service.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setService(Service service) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if(hasProperty(OWLS.Service.describes, service))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setProperty(OWLS.Service.describes, service);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster service.setProcess(this);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeService() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if(hasProperty(OWLS.Service.describes, getService()))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removeProperty(OWLS.Service.describes, getService());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Profile getProfile() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return getService().getProfile();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addInput(Input input) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addProperty(OWLS.Process.hasInput, input);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Input createInput(URI uri, OWLType paramType) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Input in = getOntology().createInput( uri );
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden if( paramType != null )
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden in.setParamType( paramType );
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden addInput( in );
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
b5d0a7678bb70ad5c444450d4527d04a87b6945fNeil Madden return in;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addInputs(InputList inputs) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int i = 0; i < inputs.size(); i++)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addInput(inputs.inputAt(i));
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addOutput(Output output) {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden addProperty(OWLS.Process.hasOutput, output);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Output createOutput(URI uri, OWLType paramType) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Output out = getOntology().createOutput( uri );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if( paramType != null )
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster out.setParamType( paramType );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addOutput( out );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return out;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addOutputs(OutputList outputs) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int i = 0; i < outputs.size(); i++)
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden addOutput(outputs.outputAt(i));
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addLocal(Local local) {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden addProperty(OWLS.Process.hasLocal, local);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public Local createLocal(URI uri, OWLType paramType) {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden Local local = getOntology().createLocal( uri );
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden if( paramType != null )
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden local.setParamType( paramType );
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden addLocal( local );
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden return local;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public void addParameter(Parameter param) {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden if(param instanceof Input)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addInput((Input) param);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster else if(param instanceof Output)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addOutput((Output) param);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster else if(param instanceof Local)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addLocal((Local) param);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster else
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addProperty(OWLS.Process.hasParameter, param);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addResult(Result result) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addProperty(OWLS.Process.hasResult, result);
19d4a53f98a937856572a10d60720f45f18b4ae2Neil Madden }
19d4a53f98a937856572a10d60720f45f18b4ae2Neil Madden
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setResult(Result result) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setProperty(OWLS.Process.hasResult, result);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public Result createResult() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Result result = getOntology().createResult();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addResult( result );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
75defebd183fd3c20f32e746e0840eb1fa12f8dbPeter Major return result;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Result createResult( URI uri ) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Result result = getOntology().createResult( uri );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addResult( result );
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden return result;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeResult(Result result) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp if (hasProperty(OWLS.Process.hasResult, result))
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp removeProperty(OWLS.Process.hasResult, result);
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public void removeResults() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp ResultList list = getResults();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp for (int i = 0; i < list.size(); i++)
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp removeResult((Result) list.get(i));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public InputList getInputs() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return OWLSFactory.createInputList(getProperties(OWLS.Process.hasInput));
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public Input getInput() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp InputList inputs = getInputs();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return inputs.isEmpty() ? null : inputs.inputAt(0);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public Input getInput(int i) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp InputList inputs = getInputs();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return inputs.inputAt(i);
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public Input getInput(String localName) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp InputList inputs = getInputs();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return (Input) inputs.getParameter(localName);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public OutputList getOutputs() {
c11e5b267744dd8487fef1dd1ccc89be08fbd16bPeter Major return OWLSFactory.createOutputList(getProperties(OWLS.Process.hasOutput));
c11e5b267744dd8487fef1dd1ccc89be08fbd16bPeter Major }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
c11e5b267744dd8487fef1dd1ccc89be08fbd16bPeter Major public Output getOutput() {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden OutputList outputs = getOutputs();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return outputs.isEmpty() ? null : outputs.outputAt(0);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public Output getOutput(int i) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp OutputList outputs = getOutputs();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return outputs.outputAt(i);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public Output getOutput(String localName) {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden OutputList outputs = getOutputs();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return (Output) outputs.getParameter(localName);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public ParameterList getLocals() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return OWLSFactory.createParameterList(getProperties(OWLS.Process.hasLocal));
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
75defebd183fd3c20f32e746e0840eb1fa12f8dbPeter Major
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public ParameterList getParameters() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp ParameterList parameters = OWLSFactory.createParameterList(getInputs());
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp parameters.addAll(getOutputs());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster parameters.addAll(getLocals());
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return parameters;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* (non-Javadoc)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see org.mindswap.owls.process.Process#getParameter(java.net.URI)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Parameter getParameter(URI parameterURI) {
4617bf16e6b67d2c607d3c4bccb1b7b250e54008Travis Papp return getParameters().getParameter(parameterURI);
4617bf16e6b67d2c607d3c4bccb1b7b250e54008Travis Papp }
4617bf16e6b67d2c607d3c4bccb1b7b250e54008Travis Papp
4617bf16e6b67d2c607d3c4bccb1b7b250e54008Travis Papp /* (non-Javadoc)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see org.mindswap.owls.process.Conditional#getCondition()
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Condition getCondition() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (Condition) getPropertyAs(OWLS.Process.hasPrecondition, Condition.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ConditionList getConditions() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return OWLSFactory.createConditionList(getProperties(OWLS.Process.hasPrecondition));
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setCondition(Condition condition) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp setProperty(OWLS.Process.hasPrecondition, condition);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public void addCondition(Condition condition) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp addProperty(OWLS.Process.hasPrecondition, condition);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public ResultList getResults() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return OWLSFactory.createResultList(getProperties(OWLS.Process.hasResult));
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public Result getResult() {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden return (Result) getPropertyAs(OWLS.Process.hasResult, Result.class);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public String getName() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return getPropertyAsString(OWLS.Process.name);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getName(String lang) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return getPropertyAsString(OWLS.Process.name, lang);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public OWLDataValueList getNames() {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden return getProperties(OWLS.Process.name);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String debugString() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster InputList inputs = getInputs();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster OutputList outputs = getOutputs();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String str = getLabel() + " " + getURI() + "\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for(int i = 0; i < inputs.size(); i++)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster str += inputs.inputAt(i).debugString() + "\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for(int i = 0; i < outputs.size(); i++)
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp str += outputs.outputAt(i).debugString() + "\n";
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return str;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public Perform getPerform() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp return (Perform) getPropertyAs(OWLS_Extensions.Process.hasPerform, Perform.class);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setPerform(Perform perform) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp if(hasProperty(OWLS_Extensions.Process.hasPerform, perform))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return;
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp setProperty(OWLS_Extensions.Process.hasPerform, perform);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp if (perform != null)
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp perform.setProcess(this);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public void removeInput(Input input) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp if (hasProperty(OWLS.Process.hasInput, input))
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp removeProperty(OWLS.Process.hasInput, input);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public void removeInputs() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster InputList list = getInputs();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int i = 0; i < list.size(); i++)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removeInput((Input) list.individualAt(i));
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
a82d04bc19fee9d5e34b41ccd7641da1f62ab634Neil Madden public void removeLocal(Local local) {
ce4d3fddc8fe2eddd68a20af9570b3cc63ece5abNeil Madden if (hasProperty(OWLS.Process.hasLocal, local))
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp removeProperty(OWLS.Process.hasLocal, local);
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeLocals() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ParameterList list = getLocals();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int i = 0; i < list.size(); i++)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removeLocal((Local) list.individualAt(i));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeOutput(Output output) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (hasProperty(OWLS.Process.hasOutput, output))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removeProperty(OWLS.Process.hasOutput, output);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeOutputs() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster OutputList list = getOutputs();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int i = 0; i < list.size(); i++)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removeOutput((Output) list.individualAt(i));
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public void deleteInput(Input input) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp removeInput(input);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp input.delete();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public void deleteInputs() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp InputList inputs = getInputs();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp removeInputs();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp for (int index = 0; index < inputs.size(); index++)
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp inputs.individualAt(index).delete();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public void deleteLocal(Local local) {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp removeLocal(local);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp local.delete();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public void deleteLocals() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp ParameterList locals = getLocals();
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden removeLocals();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp for (int index = 0; index < locals.size(); index++)
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp locals.individualAt(index).delete();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void deleteOutput(Output output) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removeOutput(output);
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden output.delete();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public void deleteOutputs() {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden OutputList outputs = getOutputs();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removeOutputs();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int index = 0; index < outputs.size(); index++)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster outputs.individualAt(index).delete();
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void deleteResult(Result result) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removeResult(result);
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp result.delete();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp public void deleteResults() {
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp ResultList results = getResults();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp removeResults();
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden for (int index = 0; index < results.size(); index++)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster results.individualAt(index).delete();
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp }
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public void deleteAllParameters() {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden deleteInputs();
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden deleteOutputs();
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden deleteLocals();
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden deleteResults();
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden }
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden @Override
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden public void delete() {
ef88f1a01f0248a7321f6abcf304acfeeafab9ceNeil Madden deleteAllParameters();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}
5fa3e419a5008528550756b7eb0ed31ab5d06b8cTravis Papp