Package com.asakusafw.vocabulary.flow.graph

Examples of com.asakusafw.vocabulary.flow.graph.OperatorDescription


        ModelFactory f = context.getModelFactory();
        MasterKindFlowAnalyzer masterAnalyzer = new MasterKindFlowAnalyzer(context);

        FlowElementPortDescription tx = context.getInputPort(MasterBranch.ID_INPUT_TRANSACTION);

        OperatorDescription desc = context.getOperatorDescription();
        List<Expression> arguments = Lists.create();
        arguments.add(masterAnalyzer.getGetCheckedMasterExpression());
        arguments.add(context.getProcessInput(tx));
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }

        Method method = desc.getDeclaration().toMethod();
        assert method != null : desc.getDeclaration();
        Class<?> enumType = method.getReturnType();
        List<Tuple2<Enum<?>, FlowElementPortDescription>> constants =
            EnumUtil.extractConstants(enumType, desc.getOutputPorts());

        Expression impl = context.createImplementation();
        SimpleName branch = context.createName("branch");
        context.addProcess(tx, new ExpressionBuilder(f, impl)
            .method(desc.getDeclaration().getName(), arguments)
            .toLocalVariableDeclaration(
                    context.convert(enumType),
                    branch));

        List<Statement> cases = Lists.create();
View Full Code Here


            Class<?> type, String name,
            String inputList, String outputList,
            FlowElementAttribute... attributes) {
        List<FlowElementPortDescription> inputs = parsePorts(PortDirection.INPUT, inputList);
        List<FlowElementPortDescription> outputs = parsePorts(PortDirection.OUTPUT, outputList);
        FlowElementDescription desc = new OperatorDescription(
                new OperatorDescription.Declaration(
                        Identity.class,
                        type,
                        type,
                        name,
View Full Code Here

        MockOut<CharSequence> out = new MockOut<CharSequence>(CharSequence.class, "out");
        out.add(op);

        FlowElementOutput port = op.toOutputPort();
        FlowElement element = port.getOwner();
        OperatorDescription desc = (OperatorDescription) element.getDescription();
        List<Parameter> params = desc.getParameters();
        assertThat(params.size(), is(1));
        assertThat(params.get(0).getName(), is("param"));
        assertThat(params.get(0).getType(), is((Type) int.class));
        assertThat(params.get(0).getValue(), is((Object) 5));

        Declaration decl = desc.getDeclaration();
        assertThat(decl.getAnnotationType(), is((Type) MockOperator.class));
        assertThat(decl.getDeclaring().getName(), is("com.example.Simple"));
        assertThat(decl.getImplementing().getName(), is("com.example.SimpleImpl"));
        assertThat(decl.getName(), is("example"));
        assertThat(decl.getParameterTypes(), is((Object) Arrays.<Object>asList(
                String.class, int.class)));

        Graph<String> graph = toGraph(in);
        assertThat(graph.getConnected("in"), isJust(desc.getName()));
        assertThat(graph.getConnected(desc.getName()), isJust("out"));
    }
View Full Code Here

        FlowResourceDescription resource = context.getResourceDescription(SideDataJoinUpdate.ID_RESOURCE_MASTER);
        SideDataKindFlowAnalyzer helper = new SideDataKindFlowAnalyzer(
                context,
                (JoinResourceDescription) resource);
        ModelFactory f = context.getModelFactory();
        OperatorDescription desc = context.getOperatorDescription();

        FlowElementPortDescription updatedPort = context.getOutputPort(SideDataJoinUpdate.ID_OUTPUT_UPDATED);
        FlowElementPortDescription missedPort = context.getOutputPort(SideDataJoinUpdate.ID_OUTPUT_MISSED);
        ResultMirror updated = context.getOutput(updatedPort);
        ResultMirror missed = context.getOutput(missedPort);

        Expression impl = context.createImplementation();
        List<Expression> arguments = Lists.create();
        arguments.add(helper.getGetRawMasterExpression());
        arguments.add(context.getInput());
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }

        context.add(f.newIfStatement(
                helper.getHasMasterExpresion(),
                f.newBlock(new Statement[] {
                        new ExpressionBuilder(f, impl)
                            .method(desc.getDeclaration().getName(), arguments)
                            .toStatement(),
                        updated.createAdd(context.getInput())
                }),
                f.newBlock(missed.createAdd(context.getInput()))));
    }
View Full Code Here

    }

    private void processMasterFirst(RendezvousProcessor.Context context) {
        assert context != null;
        ModelFactory f = context.getModelFactory();
        OperatorDescription desc = context.getOperatorDescription();
        FlowElementPortDescription master = desc.getInputPorts().get(0);

        Expression hasMaster = context.createField(boolean.class, "sawMaster");
        DataObjectMirror masterCache = context.createModelCache(master.getDataType());
        context.addBegin(new ExpressionBuilder(f, hasMaster)
            .assignFrom(Models.toLiteral(f, false))
View Full Code Here

            RendezvousProcessor.Context context,
            OperatorHelper selector) {
        assert context != null;
        assert selector != null;
        ModelFactory f = context.getModelFactory();
        OperatorDescription desc = context.getOperatorDescription();
        FlowElementPortDescription master = desc.getInputPorts().get(0);
        FlowElementPortDescription tx = desc.getInputPorts().get(1);

        ListBufferMirror list = context.createListBuffer(master.getDataType(), InputBuffer.EXPAND);
        context.addBegin(list.createBegin());
        Expression proc = context.getProcessInput(master);
        context.addProcess(master, list.createAdvance(proc));
        context.addEnd(list.createEnd());

        List<Expression> arguments = Lists.create();
        arguments.add(list.get());
        arguments.add(context.getProcessInput(tx));
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }
        assert selector.getParameterTypes().size() <= arguments.size();
        if (selector.getParameterTypes().size() <= arguments.size()) {
            arguments = arguments.subList(0, selector.getParameterTypes().size());
View Full Code Here

    private boolean isDebugLogging(FlowElement element) {
        assert element != null;
        if (element.getDescription().getKind() != FlowElementKind.OPERATOR) {
            return false;
        }
        OperatorDescription desc = (OperatorDescription) element.getDescription();
        if (desc.getDeclaration().getAnnotationType() != Logging.class) {
            return false;
        }
        if (desc.getAttribute(Logging.Level.class) != Level.DEBUG) {
            return false;
        }
        return true;
    }
View Full Code Here

    @Override
    public void emitLinePart(Context context) {
        ModelFactory f = context.getModelFactory();
        Expression input = context.getInput();
        Expression impl = context.createImplementation();
        OperatorDescription desc = context.getOperatorDescription();

        List<Expression> arguments = Lists.create();
        arguments.add(input);
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }
        Expression result = context.createLocalVariable(
                String.class,
                new ExpressionBuilder(f, impl)
                    .method(desc.getDeclaration().getName(), arguments)
                    .toExpression());

        Level level = context.getOperatorDescription().getAttribute(Logging.Level.class);
        switch (level == null ? Level.getDefault() : level) {
        case WARN:
View Full Code Here

public class FoldFlowProcessor extends RendezvousProcessor {

    @Override
    public void emitRendezvous(Context context) {
        ModelFactory f = context.getModelFactory();
        OperatorDescription desc = context.getOperatorDescription();

        FlowElementPortDescription input = context.getInputPort(Fold.ID_INPUT);
        FlowElementPortDescription output = context.getOutputPort(Fold.ID_OUTPUT);

        Expression init = context.createField(boolean.class, "initialized");
        context.addBegin(new ExpressionBuilder(f, init)
            .assignFrom(Models.toLiteral(f, false))
            .toStatement());

        DataObjectMirror cache = context.createModelCache(output.getDataType());
        Expression impl = context.createImplementation();
        Expression proc = context.getProcessInput(input);
        List<Expression> arguments = Lists.create();
        arguments.add(cache.get());
        arguments.add(proc);
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }

        context.addProcess(input, f.newIfStatement(
                init,
                f.newBlock(new ExpressionBuilder(f, impl)
                    .method(desc.getDeclaration().getName(), arguments)
                    .toStatement()),
                f.newBlock(
                        cache.createSet(proc),
                        new ExpressionBuilder(f, init)
                            .assignFrom(Models.toLiteral(f, true))
View Full Code Here

        }
        FlowElementDescription desc = element.getDescription();
        if (desc.getKind() == FlowElementKind.PSEUD) {
            return true;
        } else if (desc.getKind() == FlowElementKind.OPERATOR) {
            OperatorDescription op = (OperatorDescription) desc;
            Class<? extends Annotation> kind = op.getDeclaration().getAnnotationType();
            if (kind == Branch.class
                    || kind == Split.class
                    || kind == Project.class
                    || kind == Restructure.class
                    || kind == SideDataCheck.class
View Full Code Here

TOP

Related Classes of com.asakusafw.vocabulary.flow.graph.OperatorDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.