001: package org.andromda.metafacades.uml14;
002:
003: import java.util.ArrayList;
004: import java.util.Collection;
005: import java.util.LinkedHashMap;
006: import java.util.Iterator;
007: import java.util.List;
008: import java.util.Map;
009:
010: import org.andromda.metafacades.uml.ActivityGraphFacade;
011: import org.andromda.metafacades.uml.EventFacade;
012: import org.andromda.metafacades.uml.FrontEndAction;
013: import org.andromda.metafacades.uml.FrontEndUseCase;
014: import org.andromda.metafacades.uml.ModelElementFacade;
015: import org.andromda.metafacades.uml.StateMachineFacade;
016: import org.andromda.metafacades.uml.TransitionFacade;
017: import org.andromda.metafacades.uml.UMLProfile;
018: import org.andromda.metafacades.uml.UseCaseFacade;
019:
020: /**
021: * MetafacadeLogic implementation for org.andromda.metafacades.uml.FrontEndView.
022: *
023: * @see org.andromda.metafacades.uml.FrontEndView
024: */
025: public class FrontEndViewLogicImpl extends FrontEndViewLogic {
026: public FrontEndViewLogicImpl(Object metaObject, String context) {
027: super (metaObject, context);
028: }
029:
030: /**
031: * @see org.andromda.metafacades.uml.FrontEndView#isFrontEndView()
032: */
033: protected boolean handleIsFrontEndView() {
034: return this .hasStereotype(UMLProfile.STEREOTYPE_FRONT_END_VIEW);
035: }
036:
037: /**
038: * @see org.andromda.metafacades.uml.FrontEndView#getActions()
039: */
040: protected List handleGetActions() {
041: final List actions = new ArrayList();
042: final Collection outgoing = getOutgoing();
043: for (final Iterator iterator = outgoing.iterator(); iterator
044: .hasNext();) {
045: final Object object = iterator.next();
046: if (object instanceof FrontEndAction) {
047: actions.add(object);
048: }
049: }
050: return actions;
051: }
052:
053: /**
054: * @see org.andromda.metafacades.uml.FrontEndView#getUseCase()
055: */
056: protected Object handleGetUseCase() {
057: UseCaseFacade useCase = null;
058: final StateMachineFacade graphContext = this .getStateMachine();
059: if (graphContext instanceof ActivityGraphFacade) {
060: useCase = ((ActivityGraphFacade) graphContext).getUseCase();
061: if (!(useCase instanceof FrontEndUseCase)) {
062: useCase = null;
063: }
064: }
065: return useCase;
066: }
067:
068: /**
069: * Override to create the package of the view.
070: *
071: * @see org.andromda.metafacades.uml14.ModelElementFacadeLogic#handleGetPackageName()
072: */
073: public String handleGetPackageName() {
074: String packageName = null;
075: final StateMachineFacade graphContext = this .getStateMachine();
076: if (graphContext instanceof ActivityGraphFacade) {
077: final UseCaseFacade graphUseCase = ((ActivityGraphFacade) graphContext)
078: .getUseCase();
079: if (graphUseCase instanceof FrontEndUseCase) {
080: final FrontEndUseCase useCase = (FrontEndUseCase) graphUseCase;
081: packageName = useCase.getPackageName();
082: }
083: }
084: return packageName;
085: }
086:
087: /**
088: * @see org.andromda.metafacades.uml.FrontEndView#getVariables()
089: */
090: protected List handleGetVariables() {
091: final Map variablesMap = new LinkedHashMap();
092: final Collection incoming = getIncoming();
093: for (final Iterator iterator = incoming.iterator(); iterator
094: .hasNext();) {
095: final TransitionFacade transition = (TransitionFacade) iterator
096: .next();
097: final EventFacade trigger = transition.getTrigger();
098: if (trigger != null) {
099: for (final Iterator parameterIterator = trigger
100: .getParameters().iterator(); parameterIterator
101: .hasNext();) {
102: final ModelElementFacade modelElement = (ModelElementFacade) parameterIterator
103: .next();
104: variablesMap.put(modelElement.getName(),
105: modelElement);
106: }
107: }
108: }
109: return new ArrayList(variablesMap.values());
110: }
111:
112: /**
113: * @see org.andromda.metafacades.uml.FrontEndView#getAllActionParameters()
114: */
115: protected List handleGetAllActionParameters() {
116: final List actionParameters = new ArrayList();
117: final Collection actions = this .getActions();
118: for (final Iterator iterator = actions.iterator(); iterator
119: .hasNext();) {
120: final FrontEndAction action = (FrontEndAction) iterator
121: .next();
122: actionParameters.addAll(action.getParameters());
123: }
124: return actionParameters;
125: }
126:
127: /**
128: * @see org.andromda.metafacades.uml.FrontEndView#getAllFormFields()
129: */
130: protected List handleGetAllFormFields() {
131: final List actionParameters = new ArrayList();
132: final Collection actions = getActions();
133: for (final Iterator iterator = actions.iterator(); iterator
134: .hasNext();) {
135: final FrontEndAction action = (FrontEndAction) iterator
136: .next();
137: actionParameters.addAll(action.getParameters());
138: }
139: return actionParameters;
140: }
141: }
|