001: package org.andromda.cartridges.jbpm.metafacades;
002:
003: import org.andromda.cartridges.jbpm.JBpmProfile;
004: import org.andromda.metafacades.uml.ActivityGraphFacade;
005: import org.andromda.metafacades.uml.ModelElementFacade;
006: import org.andromda.metafacades.uml.OperationFacade;
007: import org.andromda.metafacades.uml.StateMachineFacade;
008: import org.apache.commons.lang.StringUtils;
009:
010: /**
011: * MetafacadeLogic implementation for org.andromda.cartridges.jbpm.metafacades.JBpmAction.
012: *
013: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction
014: */
015: public class JBpmActionLogicImpl extends JBpmActionLogic {
016: public JBpmActionLogicImpl(Object metaObject, String context) {
017: super (metaObject, context);
018: }
019:
020: protected boolean handleIsContainedInBusinessProcess() {
021: boolean containedInBusinessProcess = false;
022: if (this .getState() != null) {
023: final StateMachineFacade stateMachine = this .getState()
024: .getStateMachine();
025: if (stateMachine instanceof ActivityGraphFacade) {
026: final ActivityGraphFacade activityGraph = (ActivityGraphFacade) stateMachine;
027: containedInBusinessProcess = activityGraph.getUseCase() instanceof JBpmProcessDefinition;
028: }
029: } else {
030: containedInBusinessProcess = this .getTransition() instanceof JBpmTransition;
031: }
032: return containedInBusinessProcess;
033: }
034:
035: /**
036: * We override this method in order to be able to return the call-event's operation name
037: * when the event's name itself has not been specified.
038: */
039: public String getName() {
040: String name = super .getName();
041:
042: if (StringUtils.isBlank(name)) {
043: final ModelElementFacade operation = getOperation();
044: if (operation != null) {
045: name = operation.getName();
046: }
047: }
048:
049: return name;
050: }
051:
052: /**
053: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#isBeforeSignal()
054: */
055: protected boolean handleIsBeforeSignal() {
056: return this .hasStereotype(JBpmProfile.STEREOTYPE_BEFORE_SIGNAL);
057: }
058:
059: /**
060: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#isAfterSignal()
061: */
062: protected boolean handleIsAfterSignal() {
063: return this .hasStereotype(JBpmProfile.STEREOTYPE_AFTER_SIGNAL);
064: }
065:
066: /**
067: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#isNodeEnter()
068: */
069: protected boolean handleIsNodeEnter() {
070: return this .hasStereotype(JBpmProfile.STEREOTYPE_NODE_ENTER);
071: }
072:
073: /**
074: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#isNodeLeave()
075: */
076: protected boolean handleIsNodeLeave() {
077: return this .hasStereotype(JBpmProfile.STEREOTYPE_NODE_LEAVE);
078: }
079:
080: /**
081: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#isTask()
082: */
083: protected boolean handleIsTask() {
084: // tasks may only be used on a node, not on a wait-state
085: return this .hasStereotype(JBpmProfile.STEREOTYPE_TASK)
086: && this .getState() instanceof JBpmNode;
087: }
088:
089: /**
090: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#isTimer()
091: */
092: protected boolean handleIsTimer() {
093: return this .hasStereotype(JBpmProfile.STEREOTYPE_TIMER);
094: }
095:
096: /**
097: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#isBlocking()
098: */
099: protected boolean handleIsBlocking() {
100: final String blocking = (String) this
101: .findTaggedValue(JBpmProfile.TAGGEDVALUE_TASK_BLOCKING);
102: return blocking == null
103: || Boolean.valueOf(blocking).booleanValue();
104: }
105:
106: /**
107: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#getDueDate()
108: */
109: protected java.lang.String handleGetDueDate() {
110: return isTimer() ? (String) findTaggedValue(JBpmProfile.TAGGEDVALUE_TIMER_DUEDATE)
111: : null;
112: }
113:
114: protected java.lang.String handleGetTimerRepeat() {
115: return (String) findTaggedValue(JBpmProfile.TAGGEDVALUE_TIMER_REPEAT);
116: }
117:
118: protected java.lang.String handleGetTimerTransition() {
119: return (String) findTaggedValue(JBpmProfile.TAGGEDVALUE_TIMER_TRANSITION);
120: }
121:
122: /**
123: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#getClazz()
124: */
125: protected java.lang.String handleGetClazz() {
126: String clazz = null;
127: if (this .isAssignment() || this .isTimer()) {
128: final OperationFacade handler = this .getOperation();
129:
130: if (handler instanceof JBpmHandler) {
131: final StringBuffer clazzBuffer = new StringBuffer();
132: final String packageName = handler.getOwner()
133: .getPackageName();
134: clazzBuffer.append(packageName);
135: if (StringUtils.isNotBlank(packageName)) {
136: clazzBuffer.append('.');
137: }
138: clazzBuffer.append(((JBpmHandler) handler)
139: .getHandlerClassName());
140: clazz = clazzBuffer.toString();
141: }
142: }
143:
144: return clazz;
145: }
146:
147: /**
148: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#getConfigType()
149: */
150: protected java.lang.String handleGetConfigType() {
151: // @todo
152: return null;
153: }
154:
155: /**
156: * @see org.andromda.cartridges.jbpm.metafacades.JBpmAction#isAssignment()
157: */
158: protected boolean handleIsAssignment() {
159: return this.getOperation() != null;
160: }
161: }
|