2ronwalf/*
2ronwalf * Created on Aug 30, 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.process.Condition;
2ronwalfimport org.mindswap.owls.process.ControlConstruct;
2ronwalfimport org.mindswap.owls.process.IfThenElse;
2ronwalfimport org.mindswap.owls.process.ProcessList;
2ronwalfimport org.mindswap.owls.vocabulary.OWLS;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf */
2ronwalfpublic class IfThenElseImpl extends ControlConstructImpl implements IfThenElse {
2ronwalf public IfThenElseImpl(OWLIndividual ind) {
2ronwalf super(ind);
2ronwalf }
2ronwalf
2ronwalf public ControlConstruct getThen() {
2ronwalf return (ControlConstruct) getPropertyAs(OWLS.Process.thenP, ControlConstruct.class);
2ronwalf }
2ronwalf
2ronwalf public ControlConstruct getElse() {
2ronwalf return (ControlConstruct) getPropertyAs(OWLS.Process.elseP, ControlConstruct.class);
2ronwalf }
2ronwalf
2ronwalf public Condition getCondition() {
2ronwalf return (Condition) getPropertyAs(OWLS.Process.ifCondition, Condition.class);
2ronwalf }
2ronwalf
2ronwalf public void setCondition(Condition condition) {
2ronwalf setProperty(OWLS.Process.ifCondition, condition);
2ronwalf }
2ronwalf
2ronwalf public void setThen(ControlConstruct cc) {
2ronwalf setProperty(OWLS.Process.thenP, cc);
2ronwalf }
2ronwalf
2ronwalf public void setElse(ControlConstruct cc) {
2ronwalf setProperty(OWLS.Process.elseP, cc);
2ronwalf }
2ronwalf
2ronwalf public List getConstructs() {
2ronwalf ControlConstruct thenP = getThen();
2ronwalf ControlConstruct elseP = getElse();
2ronwalf
2ronwalf List list = new ArrayList();
2ronwalf list.add(thenP);
2ronwalf if(elseP != null) list.add(elseP);
2ronwalf return list;
2ronwalf }
2ronwalf
2ronwalf public ProcessList getAllProcesses( boolean recursive ) {
2ronwalf ControlConstruct thenP = getThen();
2ronwalf ControlConstruct elseP = getElse();
2ronwalf
2ronwalf ProcessList list = new ProcessListImpl();
2ronwalf list.addAll(thenP.getAllProcesses(recursive));
2ronwalf if(elseP != null) list.addAll(elseP.getAllProcesses(recursive));
2ronwalf
2ronwalf return list;
2ronwalf }
2ronwalf
2ronwalf public String getConstructName() {
2ronwalf return "If-Then-Else";
2ronwalf }
2ronwalf
16daenzerorama public boolean removeConstruct(ControlConstruct CC) {
16daenzerorama if (getThen().equals(CC))
16daenzerorama setThen(null);
16daenzerorama if (getElse().equals(CC))
16daenzerorama setElse(null);
16daenzerorama return true;
18daenzerorama }
18daenzerorama
18daenzerorama public void deleteElse() {
18daenzerorama ControlConstruct elseCC = getElse();
18daenzerorama removeElse();
18daenzerorama elseCC.delete();
18daenzerorama }
18daenzerorama
18daenzerorama public void deleteThen() {
18daenzerorama ControlConstruct thenCC = getThen();
18daenzerorama removeThen();
18daenzerorama thenCC.delete();
18daenzerorama }
18daenzerorama
18daenzerorama public void removeElse() {
18daenzerorama if (hasProperty(OWLS.Process.elseP))
18daenzerorama removeProperties(OWLS.Process.elseP);
18daenzerorama }
18daenzerorama
18daenzerorama public void removeThen() {
18daenzerorama if (hasProperty(OWLS.Process.thenP))
18daenzerorama removeProperties(OWLS.Process.thenP);
18daenzerorama }
18daenzerorama
18daenzerorama @Override
18daenzerorama public void delete() {
18daenzerorama deleteElse();
18daenzerorama deleteThen();
18daenzerorama individual.delete();
16daenzerorama }
18daenzerorama
18daenzerorama
2ronwalf}