Ejemplo n.º 1
0
 protected String calculateDefaultValue(OJAnnotatedClass test, OJBlock block, Property f) {
   String value = calculateDefaultValue(f);
   if (EmfClassifierUtil.isSimpleType(f.getType())) {
     DataType baseType = (DataType) f.getType();
     test.addToImports(ojUtil.classifierPathname(baseType));
     if (EmfClassifierUtil.hasStrategy(baseType, TestModelValueStrategy.class)) {}
   } else if (f.getType() instanceof Enumeration) {
     OJAnnotatedClass javaType = findJavaClass((Classifier) f.getType());
     test.addToImports(javaType.getPathName());
   } else if (getConcreteImplementations((Interface) f.getType()).size() > 0) {
     return lookup(test, f);
   }
   return value;
 }
 @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;
       }
     }
   }
 }
Ejemplo n.º 3
0
 protected String lookup(OJAnnotatedClass test, Property f) {
   OJPathName featureTest = getTestDataPath((Classifier) f.getType());
   test.addToImports(featureTest);
   return lookup(f);
 }