PerformImpl.java revision 22
2ronwalf/*
2ronwalf * Created on Aug 26, 2004
2ronwalf */
22daenzeroramapackage impl.owls.process.constructs;
2ronwalf
22daenzeroramaimport impl.owls.process.ProcessListImpl;
22daenzerorama
2ronwalfimport java.util.ArrayList;
2ronwalfimport java.util.List;
2ronwalf
2ronwalfimport org.mindswap.owl.OWLIndividual;
2ronwalfimport org.mindswap.owls.OWLSFactory;
2ronwalfimport org.mindswap.owls.process.BindingList;
2ronwalfimport org.mindswap.owls.process.CompositeProcess;
2ronwalfimport org.mindswap.owls.process.ControlConstruct;
2ronwalfimport org.mindswap.owls.process.Input;
2ronwalfimport org.mindswap.owls.process.InputBinding;
2ronwalfimport org.mindswap.owls.process.InputBindingList;
2ronwalfimport org.mindswap.owls.process.Parameter;
2ronwalfimport org.mindswap.owls.process.ParameterValue;
2ronwalfimport org.mindswap.owls.process.Perform;
2ronwalfimport org.mindswap.owls.process.Process;
2ronwalfimport org.mindswap.owls.process.ProcessList;
2ronwalfimport org.mindswap.owls.process.ValueOf;
2ronwalfimport org.mindswap.owls.vocabulary.OWLS;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf */
2ronwalfpublic class PerformImpl extends ControlConstructImpl implements Perform {
2ronwalf public PerformImpl(OWLIndividual ind) {
2ronwalf super(ind);
2ronwalf }
2ronwalf
2ronwalf public void addBinding(Input input, ParameterValue paramValue) {
2ronwalf InputBinding binding = getOntology().createInputBinding();
2ronwalf binding.setParameter(input);
2ronwalf binding.setValue(paramValue);
2ronwalf
2ronwalf addBinding(binding);
2ronwalf }
2ronwalf
2ronwalf public void addBinding(Input input, Perform perform, Parameter param) {
2ronwalf ValueOf valueOf = getOntology().createValueOf();
2ronwalf valueOf.setPerform(perform);
2ronwalf valueOf.setParameter(param);
2ronwalf
2ronwalf addBinding(input, valueOf);
2ronwalf }
2ronwalf
2ronwalf public void addBinding(InputBinding binding) {
2ronwalf addProperty(OWLS.Process.hasDataFrom, binding);
2ronwalf }
2ronwalf
2ronwalf public InputBindingList getBindings() {
2ronwalf return OWLSFactory.createInputBindingList(getProperties(OWLS.Process.hasDataFrom));
2ronwalf }
2ronwalf
2ronwalf public InputBinding getBindingFor(Input input) {
2ronwalf BindingList bindings = getBindings();
2ronwalf return (bindings == null) ? null : (InputBinding) bindings.getBindingFor( input );
2ronwalf }
2ronwalf
2ronwalf public Process getProcess() {
7daenzerorama Process process = (Process) getPropertyAs(OWLS.Process.process, Process.class);
8daenzerorama if (process != null)
8daenzerorama process.setPerform(this);
7daenzerorama return process;
2ronwalf }
2ronwalf
2ronwalf public void setProcess(Process process) {
8daenzerorama if (process != null)
8daenzerorama process.setPerform(this);
2ronwalf setProperty(OWLS.Process.process, process);
2ronwalf }
2ronwalf
2ronwalf public List getConstructs() {
2ronwalf return new ArrayList();
2ronwalf }
2ronwalf
2ronwalf public ProcessList getAllProcesses( boolean recursive ) {
2ronwalf Process process = getProcess();
2ronwalf ProcessList list = new ProcessListImpl();
2ronwalf list.add(process);
2ronwalf if(recursive) {
2ronwalf if( process instanceof CompositeProcess ) {
2ronwalf ControlConstruct cc = ((CompositeProcess)process).getComposedOf();
2ronwalf ProcessList processes = cc.getAllProcesses(recursive);
2ronwalf list.addAll( processes );
2ronwalf }
2ronwalf }
2ronwalf
2ronwalf return list;
2ronwalf }
2ronwalf
2ronwalf public String getConstructName() {
2ronwalf return "Perform";
2ronwalf }
2ronwalf }