001package org.andromda.cartridges.bpm4struts.metafacades; 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.DependencyFacade; 009import org.andromda.metafacades.uml.FrontEndAction; 010import org.andromda.metafacades.uml.ModelElementFacade; 011import org.andromda.metafacades.uml.OperationFacade; 012import org.andromda.metafacades.uml.ParameterFacade; 013 014/** 015 * MetafacadeLogic implementation. 016 * 017 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsController 018 */ 019public class StrutsControllerLogicImpl 020 extends StrutsControllerLogic 021{ 022 private static final long serialVersionUID = 34L; 023 /** 024 * @param metaObject 025 * @param context 026 */ 027 public StrutsControllerLogicImpl( 028 Object metaObject, 029 String context) 030 { 031 super(metaObject, context); 032 } 033 034 /** 035 * @return '/' + getPackageName().replace('.', '/') + '/' + getName() 036 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsController#getFullPath() 037 */ 038 protected String handleGetFullPath() 039 { 040 return '/' + getPackageName().replace('.', '/') + '/' + getName(); 041 } 042 043 /** 044 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsController#getDeferringActions() 045 */ 046 public List<FrontEndAction> getDeferringActions() 047 { 048 final Collection<FrontEndAction> deferringActions = new LinkedHashSet<FrontEndAction>(); 049 050 final Collection<OperationFacade> operations = getOperations(); 051 for (final Iterator<OperationFacade> operationIterator = operations.iterator(); operationIterator.hasNext();) 052 { 053 final StrutsControllerOperation operation = (StrutsControllerOperation)operationIterator.next(); 054 deferringActions.addAll(operation.getDeferringActions()); 055 } 056 return new ArrayList<FrontEndAction>(deferringActions); 057 } 058 059 /** 060 * @return getSourceDependencies().getTargetElement() StrutsSessionObject 061 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsController#getSessionObjects() 062 */ 063 protected List<StrutsSessionObject> handleGetSessionObjects() 064 { 065 final List<StrutsSessionObject> objectsList = new ArrayList<StrutsSessionObject>(); 066 067 for (final DependencyFacade dependency : this.getSourceDependencies()) 068 { 069 final ModelElementFacade modelElement = dependency.getTargetElement(); 070 if (modelElement instanceof StrutsSessionObject) 071 { 072 objectsList.add((StrutsSessionObject)modelElement); 073 } 074 } 075 076 return objectsList; 077 } 078 079 /** 080 * @return getOperations().getArguments() 081 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsController#getAllArguments() 082 */ 083 protected List<ParameterFacade> handleGetAllArguments() 084 { 085 final List<ParameterFacade> allArguments = new ArrayList<ParameterFacade>(); 086 for (final OperationFacade operationFacade : this.getOperations()) 087 { 088 for (final ParameterFacade parameterFacade : operationFacade.getArguments()) 089 { 090 allArguments.add(parameterFacade); 091 } 092 } 093 094 return allArguments; 095 } 096}