com.github.javaparser.ast.expr.LongLiteralExpr Java Examples

The following examples show how to use com.github.javaparser.ast.expr.LongLiteralExpr. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorkItemNodeVisitor.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Override
public void visitNode(String factoryField, T node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    Work work = node.getWork();
    String workName = node.getWork().getName();

    if (workName.equals("Service Task")) {
        ServiceTaskDescriptor d = new ServiceTaskDescriptor(node, contextClassLoader);
        String mangledName = d.mangledName();
        CompilationUnit generatedHandler = d.generateHandlerClassForService();
        metadata.getGeneratedHandlers().put(mangledName, generatedHandler);
        workName = mangledName;
    }

    body.addStatement(getAssignedFactoryMethod(factoryField, WorkItemNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, work.getName()))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_WORK_NAME, new StringLiteralExpr(workName)));

    addWorkItemParameters(work, body, getNodeId(node));
    addNodeMappings(node, body, getNodeId(node));

    body.addStatement(getDoneMethod(getNodeId(node)));

    visitMetaData(node.getMetaData(), body, getNodeId(node));

    metadata.getWorkItems().add(workName);
}
 
Example #2
Source File: StateNodeVisitor.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Override
public Stream<MethodCallExpr> visitCustomFields(StateNode node, VariableScope variableScope) {
    if (node.getConstraints() == null) {
        return Stream.empty();
    }
    return node.getConstraints()
            .entrySet()
            .stream()
            .map((e -> getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT,
                    getOrNullExpr(e.getKey().getConnectionId()),
                    new LongLiteralExpr(e.getKey().getNodeId()),
                    new StringLiteralExpr(e.getKey().getToType()),
                    new StringLiteralExpr(e.getValue().getDialect()),
                    new StringLiteralExpr(StringEscapeUtils.escapeJava(e.getValue().getConstraint())),
                    new IntegerLiteralExpr(e.getValue().getPriority()))));
}
 
Example #3
Source File: CompositeContextNodeVisitor.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Override
public void visitNode(String factoryField, T node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, factoryClass(), getNodeId(node), factoryMethod(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, getDefaultName()));
    visitMetaData(node.getMetaData(), body, getNodeId(node));
    VariableScope variableScopeNode = (VariableScope) node.getDefaultContext(VariableScope.VARIABLE_SCOPE);

    if (variableScope != null) {
        visitVariableScope(getNodeId(node), variableScopeNode, body, new HashSet<>());
    }

    visitCustomFields(node, variableScope).forEach(body::addStatement);

    // composite context node might not have variable scope
    // in that case inherit it from parent
    VariableScope scope = variableScope;
    if (node.getDefaultContext(VariableScope.VARIABLE_SCOPE) != null && !((VariableScope) node.getDefaultContext(VariableScope.VARIABLE_SCOPE)).getVariables().isEmpty()) {
        scope = (VariableScope) node.getDefaultContext(VariableScope.VARIABLE_SCOPE);
    }
    body.addStatement(getFactoryMethod(getNodeId(node), CompositeContextNodeFactory.METHOD_AUTO_COMPLETE, new BooleanLiteralExpr(node.isAutoComplete())));
    visitNodes(getNodeId(node), node.getNodes(), body, scope, metadata);
    visitConnections(getNodeId(node), node.getNodes(), body);
    body.addStatement(getDoneMethod(getNodeId(node)));
}
 
Example #4
Source File: TimerNodeVisitor.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Override
public void visitNode(String factoryField, TimerNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, TimerNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
    .addStatement(getNameMethod(node,"Timer"));

    Timer timer = node.getTimer();
    body.addStatement(getFactoryMethod(getNodeId(node), METHOD_TYPE, new IntegerLiteralExpr(timer.getTimeType())));

    if (timer.getTimeType() == Timer.TIME_CYCLE) {
        body.addStatement(getFactoryMethod(getNodeId(node), METHOD_DELAY, new StringLiteralExpr(timer.getDelay())));
        if (timer.getPeriod() != null && !timer.getPeriod().isEmpty()) {
            body.addStatement(getFactoryMethod(getNodeId(node), METHOD_PERIOD, new StringLiteralExpr(timer.getPeriod())));
        }
    } else if (timer.getTimeType() == Timer.TIME_DURATION) {
        body.addStatement(getFactoryMethod(getNodeId(node), METHOD_DELAY, new StringLiteralExpr(timer.getDelay())));
    } else if (timer.getTimeType() == Timer.TIME_DATE) {
        body.addStatement(getFactoryMethod(getNodeId(node), METHOD_DATE, new StringLiteralExpr(timer.getDate())));
    }

    visitMetaData(node.getMetaData(), body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));
}
 
Example #5
Source File: ForEachNodeVisitor.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Override
public void visitNode(String factoryField, ForEachNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, ForEachNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "ForEach"));
    visitMetaData(node.getMetaData(), body, getNodeId(node));

    body.addStatement(getFactoryMethod(getNodeId(node), METHOD_COLLECTION_EXPRESSION, new StringLiteralExpr(stripExpression(node.getCollectionExpression()))))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_VARIABLE, new StringLiteralExpr(node.getVariableName()),
                    new ObjectCreationExpr(null, new ClassOrInterfaceType(null, ObjectDataType.class.getSimpleName()), NodeList.nodeList(
                            new StringLiteralExpr(node.getVariableType().getStringType())
                    ))));

    if (node.getOutputCollectionExpression() != null) {
        body.addStatement(getFactoryMethod(getNodeId(node), METHOD_OUTPUT_COLLECTION_EXPRESSION, new StringLiteralExpr(stripExpression(node.getOutputCollectionExpression()))))
                .addStatement(getFactoryMethod(getNodeId(node), METHOD_OUTPUT_VARIABLE, new StringLiteralExpr(node.getOutputVariableName()),
                        new ObjectCreationExpr(null, new ClassOrInterfaceType(null, ObjectDataType.class.getSimpleName()), NodeList.nodeList(
                                new StringLiteralExpr(node.getOutputVariableType().getStringType())
                        ))));
    }
    // visit nodes
    visitNodes(getNodeId(node), node.getNodes(), body, ((VariableScope) node.getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE)), metadata);
    body.addStatement(getFactoryMethod(getNodeId(node), METHOD_LINK_INCOMING_CONNECTIONS, new LongLiteralExpr(node.getLinkedIncomingNode(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE).getNodeId())))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_LINK_OUTGOING_CONNECTIONS, new LongLiteralExpr(node.getLinkedOutgoingNode(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE).getNodeId())))
            .addStatement(getDoneMethod(getNodeId(node)));

}
 
Example #6
Source File: MilestoneNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, MilestoneNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, MilestoneNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "Milestone"));
    if (node.getCondition() != null && !node.getCondition().trim().isEmpty()) {
        body.addStatement(getConditionStatement(node, variableScope));
    }
    body.addStatement(getDoneMethod(getNodeId(node)));
    visitMetaData(node.getMetaData(), body, getNodeId(node));
}
 
Example #7
Source File: JoinNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, Join node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, JoinFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())));
    body.addStatement(getNameMethod(node, "Join"));
    body.addStatement(getFactoryMethod(getNodeId(node), METHOD_TYPE, new IntegerLiteralExpr(node.getType())));

    visitMetaData(node.getMetaData(), body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));
}
 
Example #8
Source File: FaultNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, FaultNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, FaultNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "Error"));
    if (node.getFaultVariable() != null) {
        body.addStatement(getFactoryMethod(getNodeId(node), METHOD_FAULT_VARIABLE, new StringLiteralExpr(node.getFaultVariable())));
    }
    if (node.getFaultName() != null) {
        body.addStatement(getFactoryMethod(getNodeId(node), METHOD_FAULT_NAME, new StringLiteralExpr(node.getFaultName())));
    }

    visitMetaData(node.getMetaData(), body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));

}
 
Example #9
Source File: EventNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, EventNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, EventNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "Event"))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_EVENT_TYPE, new StringLiteralExpr(node.getType())));

    Variable variable = null;
    if (node.getVariableName() != null) {
        body.addStatement(getFactoryMethod(getNodeId(node), METHOD_VARIABLE_NAME, new StringLiteralExpr(node.getVariableName())));
        variable = variableScope.findVariable(node.getVariableName());
    }

    if (EVENT_TYPE_SIGNAL.equals(node.getMetaData(EVENT_TYPE))) {
        metadata.getSignals().put(node.getType(), variable != null ? variable.getType().getStringType() : null);
    } else if (EVENT_TYPE_MESSAGE.equals(node.getMetaData(EVENT_TYPE))) {
        Map<String, Object> nodeMetaData = node.getMetaData();
        try {
            TriggerMetaData triggerMetaData = new TriggerMetaData((String) nodeMetaData.get(TRIGGER_REF),
                    (String) nodeMetaData.get(TRIGGER_TYPE),
                    (String) nodeMetaData.get(MESSAGE_TYPE),
                    node.getVariableName(),
                    String.valueOf(node.getId())).validate();
            metadata.getTriggers().add(triggerMetaData);
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException(
                    MessageFormat.format(
                            "Invalid parameters for event node \"{0}\": {1}",
                            node.getName(),
                            e.getMessage()), e);
        }
    }
    visitMetaData(node.getMetaData(), body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));
}
 
Example #10
Source File: StartNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, StartNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, StartNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "Start"))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_INTERRUPTING, new BooleanLiteralExpr(node.isInterrupting())));

    visitMetaData(node.getMetaData(), body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));
    if (node.getTimer() != null) {
        Timer timer = node.getTimer();
        body.addStatement(getFactoryMethod(getNodeId(node), METHOD_TIMER, getOrNullExpr(timer.getDelay()),
                getOrNullExpr(timer.getPeriod()),
                getOrNullExpr(timer.getDate()),
                new IntegerLiteralExpr(node.getTimer().getTimeType())));

    } else if (node.getTriggers() != null && !node.getTriggers().isEmpty()) {
        Map<String, Object> nodeMetaData = node.getMetaData();
        metadata.getTriggers().add(new TriggerMetaData((String) nodeMetaData.get(TRIGGER_REF),
                (String) nodeMetaData.get(TRIGGER_TYPE),
                (String) nodeMetaData.get(MESSAGE_TYPE),
                (String) nodeMetaData.get(TRIGGER_MAPPING),
                String.valueOf(node.getId())).validate());

        handleSignal(node, nodeMetaData, body, variableScope, metadata);
    } else {
        // since there is start node without trigger then make sure it is startable
        metadata.setStartable(true);
    }

}
 
Example #11
Source File: SplitNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, Split node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, SplitFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "Split"))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_TYPE, new IntegerLiteralExpr(node.getType())));

    visitMetaData(node.getMetaData(), body, getNodeId(node));

    if (node.getType() == Split.TYPE_OR || node.getType() == Split.TYPE_XOR) {
        for (Entry<ConnectionRef, Constraint> entry : node.getConstraints().entrySet()) {
            if (entry.getValue() != null) {
                BlockStmt actionBody = new BlockStmt();
                LambdaExpr lambda = new LambdaExpr(
                        new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) ->
                        actionBody
                );

                for (Variable v : variableScope.getVariables()) {
                    actionBody.addStatement(makeAssignment(v));
                }
                BlockStmt constraintBody = new BlockStmt();
                constraintBody.addStatement(entry.getValue().getConstraint());

                actionBody.addStatement(constraintBody);

                body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT,
                        new LongLiteralExpr(entry.getKey().getNodeId()),
                        new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")),
                        new StringLiteralExpr(entry.getKey().getToType()),
                        new StringLiteralExpr(entry.getValue().getDialect()),
                        lambda,
                        new IntegerLiteralExpr(entry.getValue().getPriority())));
            }
        }
    }
    body.addStatement(getDoneMethod(getNodeId(node)));
}
 
Example #12
Source File: ProcessVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
private void visitConnection(Connection connection, BlockStmt body) {
    // if the connection was generated by a link event, don't dump.
    if (isConnectionRepresentingLinkEvent(connection)) {
        return;
    }
    // if the connection is a hidden one (compensations), don't dump
    Object hidden = ((ConnectionImpl) connection).getMetaData(HIDDEN);
    if (hidden != null && ((Boolean) hidden)) {
        return;
    }

    body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, METHOD_CONNECTION, new LongLiteralExpr(connection.getFrom().getId()),
            new LongLiteralExpr(connection.getTo().getId()),
            new StringLiteralExpr(getOrDefault((String) connection.getMetaData().get(UNIQUE_ID), ""))));
}
 
Example #13
Source File: RuleSetNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, RuleSetNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    String nodeName = node.getName();

    body.addStatement(getAssignedFactoryMethod(factoryField, RuleSetNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "Rule"));

    RuleSetNode.RuleType ruleType = node.getRuleType();
    if (ruleType.getName().isEmpty()) {
        throw new IllegalArgumentException(
                MessageFormat.format(
                        "Rule task \"{0}\" is invalid: you did not set a unit name, a rule flow group or a decision model.", nodeName));
    }

    addNodeMappings(node, body, getNodeId(node));

    NameExpr methodScope = new NameExpr(getNodeId(node));
    MethodCallExpr m;
    if (ruleType.isRuleFlowGroup()) {
        m = handleRuleFlowGroup(ruleType);
    } else if (ruleType.isRuleUnit()) {
        m = handleRuleUnit(variableScope, metadata, node, nodeName, ruleType);
    } else if (ruleType.isDecision()) {
        m = handleDecision((RuleSetNode.RuleType.Decision) ruleType);
    } else {
        throw new IllegalArgumentException("Rule task " + nodeName + "is invalid: unsupported rule language " + node.getLanguage());
    }
    m.setScope(methodScope);
    body.addStatement(m);

    visitMetaData(node.getMetaData(), body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));
}
 
Example #14
Source File: HumanTaskNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, HumanTaskNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    Work work = node.getWork();

    body.addStatement(getAssignedFactoryMethod(factoryField, HumanTaskNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "Task"));

    addWorkItemParameters(work, body, getNodeId(node));
    addNodeMappings(node, body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));

    visitMetaData(node.getMetaData(), body, getNodeId(node));

    metadata.getWorkItems().add(work.getName());
}
 
Example #15
Source File: AbstractNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
protected void visitConnection(String factoryField, Connection connection, BlockStmt body) {
    // if the connection is a hidden one (compensations), don't dump
    Object hidden = ((ConnectionImpl) connection).getMetaData(HIDDEN);
    if (hidden != null && ((Boolean) hidden)) {
        return;
    }

    body.addStatement(getFactoryMethod(factoryField, "connection", new LongLiteralExpr(connection.getFrom().getId()),
            new LongLiteralExpr(connection.getTo().getId()),
            new StringLiteralExpr(getOrDefault((String) connection.getMetaData().get("UniqueId"), ""))));
}
 
Example #16
Source File: BoundaryEventNodeVisitor.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@Override
public void visitNode(String factoryField, BoundaryEventNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    body.addStatement(getAssignedFactoryMethod(factoryField, BoundaryEventNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "BoundaryEvent"))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_EVENT_TYPE, new StringLiteralExpr(node.getType())))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_ATTACHED_TO, new StringLiteralExpr(node.getAttachedToNodeId())))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_SCOPE, getOrNullExpr(node.getScope())));

    Variable variable = null;
    if (node.getVariableName() != null) {
        body.addStatement(getFactoryMethod(getNodeId(node), METHOD_VARIABLE_NAME, new StringLiteralExpr(node.getVariableName())));
        variable = variableScope.findVariable(node.getVariableName());
    }

    if (EVENT_TYPE_SIGNAL.equals(node.getMetaData(EVENT_TYPE))) {
        metadata.getSignals().put(node.getType(), variable != null ? variable.getType().getStringType() : null);
    } else if (EVENT_TYPE_MESSAGE.equals(node.getMetaData(EVENT_TYPE))) {
        Map<String, Object> nodeMetaData = node.getMetaData();
        metadata.getTriggers().add(new TriggerMetaData((String) nodeMetaData.get(TRIGGER_REF),
                (String) nodeMetaData.get(TRIGGER_TYPE),
                (String) nodeMetaData.get(MESSAGE_TYPE),
                node.getVariableName(),
                String.valueOf(node.getId())).validate());
    }

    visitMetaData(node.getMetaData(), body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));
}
 
Example #17
Source File: LambdaSubProcessNodeVisitor.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
@Override
public void visitNode(String factoryField, SubProcessNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    InputStream resourceAsStream = this.getClass().getResourceAsStream("/class-templates/SubProcessFactoryTemplate.java");
    Optional<Expression> retValue = parse(resourceAsStream).findFirst(Expression.class);
    String name = node.getName();
    String subProcessId = node.getProcessId();

    NodeValidator.of(getNodeKey(), name)
            .notEmpty("subProcessId", subProcessId)
            .validate();


    body.addStatement(getAssignedFactoryMethod(factoryField, SubProcessNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId())))
            .addStatement(getNameMethod(node, "Call Activity"))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_PROCESS_ID, new StringLiteralExpr(subProcessId)))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_PROCESS_NAME, new StringLiteralExpr(getOrDefault(node.getProcessName(), ""))))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_WAIT_FOR_COMPLETION, new BooleanLiteralExpr(node.isWaitForCompletion())))
            .addStatement(getFactoryMethod(getNodeId(node), METHOD_INDEPENDENT, new BooleanLiteralExpr(node.isIndependent())));

    Map<String, String> inputTypes = (Map<String, String>) node.getMetaData("BPMN.InputTypes");

    String subProcessModelClassName = ProcessToExecModelGenerator.extractModelClassName(subProcessId);
    ModelMetaData subProcessModel = new ModelMetaData(subProcessId,
            metadata.getPackageName(),
            subProcessModelClassName,
            WorkflowProcess.PRIVATE_VISIBILITY,
            VariableDeclarations.ofRawInfo(inputTypes),
            false);

    retValue.ifPresent(retValueExpression -> {
        retValueExpression.findAll(ClassOrInterfaceType.class)
                .stream()
                .filter(t -> t.getNameAsString().equals("$Type$"))
                .forEach(t -> t.setName(subProcessModelClassName));

        retValueExpression.findFirst(MethodDeclaration.class, m -> m.getNameAsString().equals("bind"))
                .ifPresent(m -> m.setBody(bind(variableScope, node, subProcessModel)));
        retValueExpression.findFirst(MethodDeclaration.class, m -> m.getNameAsString().equals("createInstance"))
                .ifPresent(m -> m.setBody(createInstance(node, metadata)));
        retValueExpression.findFirst(MethodDeclaration.class, m -> m.getNameAsString().equals("unbind"))
                .ifPresent(m -> m.setBody(unbind(variableScope, node)));
    });

    if (retValue.isPresent()) {
        body.addStatement(getFactoryMethod(getNodeId(node), getNodeKey(), retValue.get()));
    } else {
        body.addStatement(getFactoryMethod(getNodeId(node), getNodeKey()));
    }

    visitMetaData(node.getMetaData(), body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));
}
 
Example #18
Source File: PrettyPrintVisitor.java    From stategen with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void visit(final LongLiteralExpr n, final Void arg) {
    printJavaComment(n.getComment(), arg);
    printer.print(n.getValue());
}
 
Example #19
Source File: TraceVisitor.java    From JCTools with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(LongLiteralExpr n, Void arg) {
    out.println("LongLiteralExpr: " + (extended ? n : n));
    super.visit(n, arg);
}
 
Example #20
Source File: LongLiteralExprMerger.java    From dolphin with Apache License 2.0 3 votes vote down vote up
@Override public LongLiteralExpr doMerge(LongLiteralExpr first, LongLiteralExpr second) {
  LongLiteralExpr lle = new LongLiteralExpr();

  lle.setValue(first.getValue());

  return lle;
}
 
Example #21
Source File: LongLiteralExprMerger.java    From dolphin with Apache License 2.0 2 votes vote down vote up
@Override public boolean doIsEquals(LongLiteralExpr first, LongLiteralExpr second) {

    if(!first.getValue().equals(second.getValue())) return false;

    return true;
  }