01: package org.andromda.metafacades.uml14;
02:
03: import java.util.Collection;
04: import java.util.Iterator;
05:
06: import org.apache.commons.collections.Predicate;
07: import org.omg.uml.behavioralelements.activitygraphs.ActionState;
08: import org.omg.uml.behavioralelements.activitygraphs.ObjectFlowState;
09: import org.omg.uml.behavioralelements.usecases.UseCase;
10:
11: /**
12: * Metaclass facade implementation.
13: */
14: public class ActivityGraphFacadeLogicImpl extends
15: ActivityGraphFacadeLogic {
16: public ActivityGraphFacadeLogicImpl(
17: org.omg.uml.behavioralelements.activitygraphs.ActivityGraph metaObject,
18: String context) {
19: super (metaObject, context);
20: }
21:
22: /**
23: * @see org.andromda.metafacades.uml.ActivityGraphFacade#getActionStates()
24: */
25: public Collection handleGetActionStates() {
26: final Predicate filter = new Predicate() {
27: public boolean evaluate(Object object) {
28: return object instanceof ActionState;
29: }
30: };
31: return getSubvertices(filter);
32: }
33:
34: /**
35: * @see org.andromda.metafacades.uml.ActivityGraphFacade#getObjectFlowStates()
36: */
37: public Collection handleGetObjectFlowStates() {
38: final Predicate filter = new Predicate() {
39: public boolean evaluate(Object object) {
40: return object instanceof ObjectFlowState;
41: }
42: };
43: return getSubvertices(filter);
44: }
45:
46: /**
47: * @see org.andromda.metafacades.uml.ActivityGraphFacade#getUseCase()
48: */
49: protected Object handleGetUseCase() {
50: UseCase stateMachineUseCase = null;
51:
52: final Collection useCases = UML14MetafacadeUtils.getModel()
53: .getUseCases().getUseCase().refAllOfType();
54: for (final Iterator useCaseIterator = useCases.iterator(); useCaseIterator
55: .hasNext()
56: && stateMachineUseCase == null;) {
57: // loop over all use-cases
58: final UseCase useCase = (UseCase) useCaseIterator.next();
59: if (useCase.getOwnedElement().contains(metaObject)) {
60: stateMachineUseCase = useCase;
61: }
62: }
63:
64: return stateMachineUseCase;
65: }
66:
67: /**
68: * @see org.andromda.metafacades.uml.ActivityGraphFacade#getPartitions()
69: */
70: protected Collection handleGetPartitions() {
71: return metaObject.getPartition();
72: }
73:
74: /**
75: * @see org.andromda.core.metafacade.MetafacadeBase#getValidationOwner()
76: */
77: public Object getValidationOwner() {
78: Object validationOwner = getUseCase();
79:
80: if (validationOwner == null) {
81: validationOwner = getStateMachineContext();
82: }
83: if (validationOwner == null) {
84: validationOwner = getPackage();
85: }
86:
87: return validationOwner;
88: }
89: }
|