001package org.andromda.metafacades.uml14; 002 003import java.util.ArrayList; 004import java.util.Collection; 005import java.util.Iterator; 006import java.util.LinkedHashSet; 007import java.util.List; 008import org.andromda.metafacades.uml.ActivityGraphFacade; 009import org.andromda.metafacades.uml.FrontEndAction; 010import org.andromda.metafacades.uml.FrontEndActivityGraph; 011import org.andromda.metafacades.uml.FrontEndForward; 012import org.andromda.metafacades.uml.FrontEndUseCase; 013import org.andromda.metafacades.uml.StateMachineFacade; 014import org.andromda.metafacades.uml.TransitionFacade; 015import org.andromda.metafacades.uml.UseCaseFacade; 016 017/** 018 * MetafacadeLogic implementation for org.andromda.metafacades.uml.FrontEndPseudostate. 019 * 020 * @see org.andromda.metafacades.uml.FrontEndPseudostate 021 * @author Bob Fields 022 */ 023public class FrontEndPseudostateLogicImpl 024 extends FrontEndPseudostateLogic 025{ 026 private static final long serialVersionUID = -3741898725444635931L; 027 028 /** 029 * @param metaObject 030 * @param context 031 */ 032 public FrontEndPseudostateLogicImpl( 033 Object metaObject, 034 String context) 035 { 036 super(metaObject, context); 037 } 038 039 /** 040 * @see org.andromda.metafacades.uml.FrontEndPseudostate#isContainedInFrontEndUseCase() 041 */ 042 @Override 043 protected boolean handleIsContainedInFrontEndUseCase() 044 { 045 return this.getStateMachine() instanceof FrontEndActivityGraph; 046 } 047 048 /** 049 * @see org.andromda.metafacades.uml.FrontEndPseudostate#getContainerActions() 050 */ 051 @Override 052 protected List<FrontEndAction> handleGetContainerActions() 053 { 054 final Collection<FrontEndAction> actionSet = new LinkedHashSet<FrontEndAction>(); 055 final StateMachineFacade graphContext = getStateMachine(); 056 057 if (graphContext instanceof ActivityGraphFacade) 058 { 059 final UseCaseFacade useCase = ((ActivityGraphFacade)graphContext).getUseCase(); 060 061 if (useCase instanceof FrontEndUseCase) 062 { 063 for ( 064 final Iterator actionIterator = ((FrontEndUseCase)useCase).getActions().iterator(); 065 actionIterator.hasNext();) 066 { 067 final FrontEndAction action = (FrontEndAction)actionIterator.next(); 068 final Collection<FrontEndForward> transitions = action.getTransitions(); 069 for (final Iterator<FrontEndForward> transitionIterator = transitions.iterator(); transitionIterator.hasNext();) 070 { 071 TransitionFacade transition = (TransitionFacade)transitionIterator.next(); 072 if (this.equals(transition.getTarget())) 073 { 074 actionSet.add(action); 075 } 076 } 077 } 078 } 079 } 080 return new ArrayList<FrontEndAction>(actionSet); 081 } 082}