001: package org.andromda.metafacades.uml14;
002:
003: import java.util.ArrayList;
004: import java.util.Collection;
005: import java.util.Iterator;
006: import java.util.LinkedHashSet;
007: import java.util.List;
008: import java.util.Set;
009:
010: import org.andromda.metafacades.uml.ActivityGraphFacade;
011: import org.andromda.metafacades.uml.CallEventFacade;
012: import org.andromda.metafacades.uml.EventFacade;
013: import org.andromda.metafacades.uml.FrontEndAction;
014: import org.andromda.metafacades.uml.FrontEndActivityGraph;
015: import org.andromda.metafacades.uml.FrontEndEvent;
016: import org.andromda.metafacades.uml.FrontEndExceptionHandler;
017: import org.andromda.metafacades.uml.FrontEndUseCase;
018: import org.andromda.metafacades.uml.FrontEndView;
019: import org.andromda.metafacades.uml.StateMachineFacade;
020: import org.andromda.metafacades.uml.TransitionFacade;
021: import org.andromda.metafacades.uml.UseCaseFacade;
022: import org.andromda.utils.StringUtilsHelper;
023:
024: /**
025: * MetafacadeLogic implementation for org.andromda.metafacades.uml.FrontEndActionState.
026: *
027: * @see org.andromda.metafacades.uml.FrontEndActionState
028: */
029: public class FrontEndActionStateLogicImpl extends
030: FrontEndActionStateLogic {
031: public FrontEndActionStateLogicImpl(Object metaObject,
032: String context) {
033: super (metaObject, context);
034: }
035:
036: /**
037: * @see org.andromda.metafacades.uml.FrontEndActionState#isServerSide()
038: */
039: protected boolean handleIsServerSide() {
040: return !(this .THIS() instanceof FrontEndView);
041: }
042:
043: /**
044: * @see org.andromda.metafacades.uml.FrontEndActionState#getActionMethodName()
045: */
046: protected java.lang.String handleGetActionMethodName() {
047: return '_' + StringUtilsHelper.lowerCamelCaseName(getName());
048: }
049:
050: /**
051: * @see org.andromda.metafacades.uml.FrontEndActionState#isContainedInFrontEndUseCase()
052: */
053: protected boolean handleIsContainedInFrontEndUseCase() {
054: return this .getStateMachine() instanceof FrontEndActivityGraph;
055: }
056:
057: /**
058: * @see org.andromda.metafacades.uml.FrontEndActionState#getForward()
059: */
060: protected Object handleGetForward() {
061: Object forward = null;
062:
063: for (final Iterator iterator = this .getOutgoing().iterator(); iterator
064: .hasNext()
065: && forward == null;) {
066: final TransitionFacade transition = (TransitionFacade) iterator
067: .next();
068: if (!(transition instanceof FrontEndExceptionHandler)) {
069: forward = transition;
070: }
071: }
072: return forward;
073: }
074:
075: /**
076: * @see org.andromda.metafacades.uml.FrontEndActionState#getControllerCalls()
077: */
078: protected List handleGetControllerCalls() {
079: final List controllerCallsList = new ArrayList();
080: final Collection deferrableEvents = this .getDeferrableEvents();
081: for (final Iterator iterator = deferrableEvents.iterator(); iterator
082: .hasNext();) {
083: final EventFacade event = (EventFacade) iterator.next();
084: if (event instanceof CallEventFacade) {
085: final Object operationObject = ((CallEventFacade) event)
086: .getOperation();
087: if (operationObject != null) {
088: controllerCallsList.add(operationObject);
089: }
090: } else if (event instanceof FrontEndEvent) {
091: final Object callObject = ((FrontEndEvent) event)
092: .getControllerCall();
093: if (callObject != null) {
094: controllerCallsList.add(callObject);
095: }
096: }
097: }
098: return controllerCallsList;
099: }
100:
101: /**
102: * @see org.andromda.metafacades.uml.FrontEndActionState#getExceptions()
103: */
104: protected List handleGetExceptions() {
105: final Set exceptions = new LinkedHashSet();
106: final Collection outgoing = getOutgoing();
107: for (final Iterator iterator = outgoing.iterator(); iterator
108: .hasNext();) {
109: final TransitionFacade transition = (TransitionFacade) iterator
110: .next();
111: if (transition instanceof FrontEndExceptionHandler) {
112: exceptions.add(transition);
113: }
114: }
115: return new ArrayList(exceptions);
116: }
117:
118: /**
119: * @see org.andromda.metafacades.uml.FrontEndActionState#getContainerActions()
120: */
121: protected List handleGetContainerActions() {
122: final Collection actionSet = new LinkedHashSet();
123:
124: final StateMachineFacade stateMachineFacade = this
125: .getStateMachine();
126: if (stateMachineFacade instanceof ActivityGraphFacade) {
127: final ActivityGraphFacade activityGraph = (ActivityGraphFacade) stateMachineFacade;
128: final UseCaseFacade useCase = activityGraph.getUseCase();
129:
130: if (useCase instanceof FrontEndUseCase) {
131: final Collection actions = ((FrontEndUseCase) useCase)
132: .getActions();
133: for (final Iterator actionIterator = actions.iterator(); actionIterator
134: .hasNext();) {
135: final FrontEndAction action = (FrontEndAction) actionIterator
136: .next();
137: if (action.getActionStates().contains(this )) {
138: actionSet.add(action);
139: }
140: }
141: }
142: }
143: return new ArrayList(actionSet);
144: }
145: }
|