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.DependencyFacade; 010import org.andromda.metafacades.uml.FilteredCollection; 011import org.andromda.metafacades.uml.FrontEndAction; 012import org.andromda.metafacades.uml.FrontEndActivityGraph; 013import org.andromda.metafacades.uml.FrontEndControllerOperation; 014import org.andromda.metafacades.uml.OperationFacade; 015import org.andromda.metafacades.uml.Service; 016import org.andromda.metafacades.uml.StateMachineFacade; 017import org.andromda.metafacades.uml.UMLProfile; 018import org.andromda.metafacades.uml.UseCaseFacade; 019 020/** 021 * MetafacadeLogic implementation for org.andromda.metafacades.uml.FrontEndController. 022 * 023 * @see org.andromda.metafacades.uml.FrontEndController 024 * @author Bob Fields 025 */ 026public class FrontEndControllerLogicImpl 027 extends FrontEndControllerLogic 028{ 029 private static final long serialVersionUID = 8320339804450106876L; 030 031 /** 032 * @param metaObject 033 * @param context 034 */ 035 public FrontEndControllerLogicImpl( 036 Object metaObject, 037 String context) 038 { 039 super(metaObject, context); 040 } 041 042 /** 043 * @see org.andromda.metafacades.uml.FrontEndController#getServiceReferences() 044 */ 045 @Override 046 protected List<DependencyFacade> handleGetServiceReferences() 047 { 048 return new FilteredCollection(this.getSourceDependencies()) 049 { 050 private static final long serialVersionUID = 2214453181869436835L; 051 052 public boolean evaluate(Object object) 053 { 054 return ((DependencyFacade)object).getTargetElement() instanceof Service; 055 } 056 }; 057 } 058 059 /** 060 * @see org.andromda.metafacades.uml.FrontEndController#getUseCase() 061 */ 062 @Override 063 protected UseCaseFacade handleGetUseCase() 064 { 065 UseCaseFacade useCase = null; 066 final StateMachineFacade graphContext = this.getStateMachineContext(); 067 if (graphContext instanceof FrontEndActivityGraph) 068 { 069 useCase = ((ActivityGraphFacade)graphContext).getUseCase(); 070 } 071 else 072 { 073 final Object useCaseTaggedValue = findTaggedValue( 074 UMLProfile.TAGGEDVALUE_PRESENTATION_CONTROLLER_USECASE); 075 if (useCaseTaggedValue != null) 076 { 077 final String tag = useCaseTaggedValue.toString(); 078 079 // - return the first use-case with this name 080 useCase = this.getModel().findUseCaseWithNameAndStereotype( 081 tag, UMLProfile.STEREOTYPE_FRONT_END_USECASE); 082 } 083 } 084 return useCase; 085 } 086 087 /** 088 * @see org.andromda.metafacades.uml.FrontEndController#getDeferringActions() 089 */ 090 @Override 091 protected List<FrontEndAction> handleGetDeferringActions() 092 { 093 final Collection<FrontEndAction> deferringActions = new LinkedHashSet<FrontEndAction>(); 094 095 final Collection<OperationFacade> operations = getOperations(); 096 for (final Iterator<OperationFacade> operationIterator = operations.iterator(); operationIterator.hasNext();) 097 { 098 final FrontEndControllerOperation operation = (FrontEndControllerOperation)operationIterator.next(); 099 deferringActions.addAll(operation.getDeferringActions()); 100 } 101 return new ArrayList<FrontEndAction>(deferringActions); 102 } 103}