private void storeArguments(OJIfStatement ifTokenFound, AcceptEventAction aea) { List<OutputPin> result = aea.getResults(); Jbpm5ObjectNodeExpressor expressor = new Jbpm5ObjectNodeExpressor(ojUtil); for (int i = 0; i < result.size(); i++) { OutputPin argument = result.get(i); PropertyMap pinMap = ojUtil.buildStructuralFeatureMap(argument); TypedElement parm = EmfActionUtil.getLinkedTypedElement(argument); if (parm == null) { String param = "unknown"; if (EmfActionUtil.acceptsDeadline(aea)) { param = i == 1 ? "source.getTaskRequest()" : "triggerDate"; } else if (EmfEventUtil.containsTriggerType(aea, TimeEvent.class)) { param = "triggerDate"; } ifTokenFound.getThenPart().addToStatements(expressor.storeResults(pinMap, param, false)); } else { PropertyMap parmMap = ojUtil.buildStructuralFeatureMap(parm); String expression = parmMap.fieldname(); if (parm instanceof Property) { // signal expression = "signal." + parmMap.getter() + "()"; } ifTokenFound .getThenPart() .addToStatements(expressor.storeResults(pinMap, expression, parmMap.isMany())); } } }
@Override protected void implementEventConsumer( Behavior behavior, OJAnnotatedClass ojBehavior, ElementsWaitingForEvent eventActions) { OJAnnotatedOperation eventConsumer = super.createEventConsumerSignature(behavior, ojBehavior, eventActions.getEvent()); OJForStatement forEachToken = new OJForStatement("token", ActivityProcessImplementor.ACTIVITY_TOKEN, "getTokens()"); eventConsumer.getBody().addToStatements(forEachToken); for (NamedElement waitingNode : eventActions.getWaitingNodes()) { AcceptEventAction action = (AcceptEventAction) waitingNode; OJPathName waitingClass = ojUtil.classifierPathname(action); ojBehavior.addToImports(waitingClass); if (EmfActivityUtil.getAllEffectiveIncoming(action).isEmpty()) { // TODO check if the activityNodeContainer of this action is active and create a new token } else { String condition = "result==false && token.isActive() && token.getCurrentExecutionElement() instanceof " + waitingClass.getName(); OJIfStatement ifMatchFound = new OJIfStatement(condition); forEachToken.getBody().addToStatements(ifMatchFound); OJAnnotatedField stateActivation = new OJAnnotatedField("state", waitingClass); stateActivation.setInitExp( "(" + waitingClass.getName() + ")token.getCurrentExecutionElement()"); ifMatchFound.getThenPart().addToLocals(stateActivation); for (ActivityEdge transition : action.getOutgoings()) { OJPathName tpn = ojUtil.classifierPathname(transition); OJIfStatement ifAccept = new OJIfStatement( "result==false && get" + tpn.getLast() + "()." + OperationAnnotator.delegateParameters(eventConsumer)); ifMatchFound.getThenPart().addToStatements(ifAccept); ifAccept.getThenPart().addToStatements("result=true"); ifAccept.getThenPart().addToStatements("break"); break; } } } }
private OJBlock checkWeight(OJOperation operationContext, OJBlock block, ActivityNode node) { StringBuilder sb = new StringBuilder(); // Check if all weights have been satisfied // NB!! the weight logic only makes sense on AcceptEventActions. This is the only place where // outputpin value count equates to // weight. Everywhere else it is impossible to determine weight. In other places it could also // lead to stuck contractedProcesses // TODO implement validation for (ActivityEdge edge : EmfActivityUtil.getDefaultOutgoing(node)) { if (edge.getSource() instanceof OutputPin) { PropertyMap map = ojUtil.buildStructuralFeatureMap((OutputPin) edge.getSource()); if (edge.getWeight() != null) { if (map.isCollection()) { Classifier integerType = getLibrary().getIntegerType(); if (edge.getWeight() != null) {} String weight = valueSpecificationUtil.expressValue( operationContext, edge.getWeight(), EmfActivityUtil.getContainingActivity(edge.getSource()), integerType); if (sb.length() > 0) { sb.append(" && "); } sb.append(map.getter() + "().size()>=" + weight); } else { // would not make sense - ignore } } } } if (sb.length() > 0) { OJIfStatement ifStatement = new OJIfStatement(); block.addToStatements(ifStatement); ifStatement.setCondition(sb.toString()); block = ifStatement.getThenPart(); } return block; }