01: package org.andromda.metafacades.emf.uml2;
02:
03: import java.util.ArrayList;
04: import java.util.Collection;
05: import java.util.Iterator;
06: import java.util.LinkedHashSet;
07: import java.util.List;
08:
09: import org.andromda.metafacades.uml.DependencyFacade;
10: import org.andromda.metafacades.uml.FilteredCollection;
11: import org.andromda.metafacades.uml.FrontEndControllerOperation;
12: import org.andromda.metafacades.uml.Service;
13: import org.eclipse.uml2.Classifier;
14: import org.eclipse.uml2.Element;
15: import org.eclipse.uml2.UseCase;
16:
17: /**
18: * MetafacadeLogic implementation for
19: * org.andromda.metafacades.uml.FrontEndController.
20: *
21: * @see org.andromda.metafacades.uml.FrontEndController
22: */
23: public class FrontEndControllerLogicImpl extends
24: FrontEndControllerLogic {
25: public FrontEndControllerLogicImpl(final Object metaObject,
26: final String context) {
27: super (metaObject, context);
28: }
29:
30: /**
31: * @see org.andromda.metafacades.uml.FrontEndController#getServiceReferences()
32: */
33: protected java.util.List handleGetServiceReferences() {
34: return new FilteredCollection(this .getSourceDependencies()) {
35: public boolean evaluate(final Object object) {
36: return ((DependencyFacade) object).getTargetElement() instanceof Service;
37: }
38: };
39: }
40:
41: /**
42: * @see org.andromda.metafacades.uml.FrontEndController#getUseCase()
43: */
44: protected java.lang.Object handleGetUseCase() {
45: Element owner = (Classifier) this .metaObject;
46: while (!(owner == null || owner instanceof UseCase)) {
47: owner = owner.getOwner();
48: }
49: return owner;
50: }
51:
52: /**
53: * @see org.andromda.metafacades.uml.FrontEndController#getDeferringActions()
54: */
55: protected List handleGetDeferringActions() {
56: final Collection deferringActions = new LinkedHashSet();
57:
58: final Collection operations = this .getOperations();
59: for (final Iterator operationIterator = operations.iterator(); operationIterator
60: .hasNext();) {
61: final FrontEndControllerOperation operation = (FrontEndControllerOperation) operationIterator
62: .next();
63: deferringActions.addAll(operation.getDeferringActions());
64: }
65: return new ArrayList(deferringActions);
66: }
67:
68: // TODO: We may want to override getPackageName here, since in uml2
69: // statemachine and usecase are "packages".
70: // We may return the getUseCase package name
71: // For now, in ModelElement, we are handling this case.
72: }
|