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.constructs;
2ronwalf
2ronwalfimport impl.owl.WrappedIndividual;
22daenzeroramaimport impl.owls.process.ValueOfImpl;
2ronwalf
10daenzeroramaimport java.util.Iterator;
10daenzerorama
2ronwalfimport org.mindswap.owl.OWLIndividual;
3daenzeroramaimport org.mindswap.owl.OWLIndividualList;
10daenzeroramaimport org.mindswap.owls.OWLSListFactory;
10daenzeroramaimport org.mindswap.owls.process.BindingList;
2ronwalfimport org.mindswap.owls.process.ControlConstruct;
10daenzeroramaimport org.mindswap.owls.process.Perform;
3daenzeroramaimport org.mindswap.owls.process.Process;
2ronwalfimport org.mindswap.owls.process.ProcessList;
10daenzeroramaimport org.mindswap.owls.process.ValueOf;
3daenzeroramaimport org.mindswap.owls.vocabulary.OWLS;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf *
2ronwalf */
2ronwalfpublic abstract class ControlConstructImpl extends WrappedIndividual implements ControlConstruct {
16daenzerorama
2ronwalf public ControlConstructImpl(OWLIndividual ind) {
2ronwalf super(ind);
2ronwalf }
2ronwalf
2ronwalf public ProcessList getAllProcesses() {
2ronwalf return getAllProcesses(false);
2ronwalf }
3daenzerorama
3daenzerorama public Process getParentProcess() {
3daenzerorama OWLIndividualList processes = getIncomingProperties(OWLS.Process.composedOf);
3daenzerorama if (processes.size() == 0)
3daenzerorama return null;
3daenzerorama if (processes.size() > 1)
3daenzerorama return null;
3daenzerorama else
3daenzerorama return (Process) processes.individualAt(0).castTo(Process.class);
3daenzerorama }
10daenzerorama
10daenzerorama public BindingList getAllBindings() {
10daenzerorama BindingList bindings = OWLSListFactory.createBindingList();
10daenzerorama return getBindingsRecursively(this, bindings);
10daenzerorama }
10daenzerorama
10daenzerorama private BindingList getBindingsRecursively(ControlConstruct cc, BindingList bindings) {
10daenzerorama if (cc instanceof Perform) {
10daenzerorama Perform perform = (Perform) cc;
10daenzerorama
10daenzerorama // get bindings for flows to this perform
10daenzerorama bindings.addBindingWithoutDuplicate((BindingList)perform.getBindings());
10daenzerorama
10daenzerorama // get bindings for flows going out of this perform
10daenzerorama OWLIndividualList list = perform.getIncomingProperties(OWLS.Process.fromProcess);
10daenzerorama
10daenzerorama for (int index = 0; index < list.size(); index++) {
10daenzerorama ValueOf valueOf = new ValueOfImpl((OWLIndividual) list.get(index));
10daenzerorama bindings.addBindingWithoutDuplicate(valueOf.getEnclosingBinding());
10daenzerorama }
10daenzerorama } else {
10daenzerorama Iterator<ControlConstruct> ccs = cc.getConstructs().iterator();
10daenzerorama while (ccs.hasNext())
10daenzerorama bindings = getBindingsRecursively(ccs.next(), bindings);
10daenzerorama }
10daenzerorama
10daenzerorama return bindings;
10daenzerorama }
10daenzerorama
16daenzerorama public boolean removeConstruct(ControlConstruct CC) {
16daenzerorama return true;
16daenzerorama }
2ronwalf}