Package com.asakusafw.compiler.flow

Examples of com.asakusafw.compiler.flow.DataClass


            for (ResolvedSlot slot : slots) {
                Expression object;
                if (slot.getSortProperties().isEmpty() && ParallelSortClientEmitter.legacy(environment) == false) {
                    object = Models.toNullLiteral(factory);
                } else {
                    DataClass slotClass = slot.getValueClass();
                    object = slotClass.createNewInstance(importer.toType(slotClass.getType()));
                }
                statements.add(new ExpressionBuilder(factory, resultName)
                    .array(slot.getSlotNumber())
                    .assignFrom(object)
                    .toStatement());
View Full Code Here


    private void emitTerm(
            Context context,
            Joined.Term term,
            FlowElementPortDescription inputPort,
            FlowElementPortDescription outputPort) {
        DataClass inputType = getEnvironment().getDataClasses().load(inputPort.getDataType());
        DataClass outputType = getEnvironment().getDataClasses().load(outputPort.getDataType());
        DataObjectMirror cache = context.createModelCache(term.source());
        context.add(cache.createReset());
        for (Joined.Mapping mapping : term.mappings()) {
            // input: joined(destination), output: origin(source)
            Property source = inputType.findProperty(mapping.destination());
            Property destination = outputType.findProperty(mapping.source());
            context.add(destination.createSetter(
                    cache.get(),
                    source.createGetter(context.getInput())));
        }
        ResultMirror result = context.getOutput(outputPort);
View Full Code Here

        FlowElementPortDescription joinedPort = context.getOutputPort(SideDataJoin.ID_OUTPUT_JOINED);
        FlowElementPortDescription missedPort = context.getOutputPort(SideDataJoin.ID_OUTPUT_MISSED);

        DataObjectMirror resultCache = context.createModelCache(joinedPort.getDataType());
        DataClass outputType = getEnvironment().getDataClasses().load(joinedPort.getDataType());
        List<Statement> process = Lists.create();
        process.add(resultCache.createReset());
        Joined annotation = TypeUtil.erase(joinedPort.getDataType()).getAnnotation(Joined.class);
        Set<String> saw = Sets.create();
        for (Joined.Term term : annotation.terms()) {
            DataClass inputType = getEnvironment().getDataClasses().load(term.source());
            Expression input;
            if (term.source().equals(context.getInputPort(SideDataJoin.ID_INPUT_TRANSACTION).getDataType())) {
                input = context.getInput();
            } else {
                input = helper.getGetRawMasterExpression();
            }
            for (Joined.Mapping mapping : term.mappings()) {
                if (saw.contains(mapping.destination())) {
                    continue;
                }
                saw.add(mapping.destination());
                Property sourceProperty = inputType.findProperty(mapping.source());
                Property destinationProperty = outputType.findProperty(mapping.destination());
                process.add(destinationProperty.createSetter(
                        resultCache.get(),
                        sourceProperty.createGetter(input)));
            }
View Full Code Here

        FlowElementPortDescription input = context.getInputPort(Restructure.ID_INPUT);
        FlowElementPortDescription output = context.getOutputPort(Restructure.ID_OUTPUT);
        DataObjectMirror cache = context.createModelCache(output.getDataType());
        context.setOutput(cache.get());

        DataClass sourceType = loadChecked(input);
        DataClass sinkType = loadChecked(output);
        if (sourceType == null || sinkType == null) {
            return;
        }

        context.add(cache.createReset());
        Expression inputObject = context.getInput();
        Expression outputObject = cache.get();
        for (DataClass.Property sourceProperty : sourceType.getProperties()) {
            Property sinkProperty = sinkType.findProperty(sourceProperty.getName());
            if (sinkProperty == null) {
                // skip this property
            } else if (sourceProperty.getType().equals(sinkProperty.getType()) == false) {
                getEnvironment().error(
                        "{0}において、{1}.{2}と{3}.{4}のプロパティ型が一致しません",
View Full Code Here

            }
        }
    }

    private DataClass loadChecked(FlowElementPortDescription port) {
        DataClass resolved = getEnvironment().getDataClasses().load(port.getDataType());
        if (resolved == null) {
            getEnvironment().error(
                    "型{0}を解決できませんでした",
                    port.getDataType());
        }
View Full Code Here

        }

        private FieldDeclaration createProperty(Segment segment) {
            assert segment != null;
            String name = createPropertyName(segment);
            DataClass target = segment.getTarget();
            return factory.newFieldDeclaration(
                    new JavadocBuilder(factory)
                        .text("{0}#{1}が利用するモデル ({2})。",
                                segment.getPort().getOwner().getDescription().getName(),
                                segment.getPort().getDescription().getName(),
                                segment.getPortId())
                        .toJavadoc(),
                    new AttributeBuilder(factory)
                        .Public()
                        .toAttributes(),
                    t(target.getType()),
                    factory.newSimpleName(name),
                    target.createNewInstance(t(target.getType())));
        }
View Full Code Here

        }

        private MethodDeclaration createSetter(Segment segment) {
            assert segment != null;
            String methodName = Naming.getShuffleValueSetter(segment.getPortId());
            DataClass type = segment.getTarget();

            SimpleName argument = factory.newSimpleName("model");

            List<Statement> statements = Lists.create();
            statements.add(new ExpressionBuilder(factory, factory.newThis())
                .field(factory.newSimpleName(SEGMENT_ID_FIELD_NAME))
                .assignFrom(v(segment.getPortId()))
                .toStatement());
            statements.add(type.assign(
                    new ExpressionBuilder(factory, factory.newThis())
                        .field(createPropertyName(segment))
                        .toExpression(),
                    argument));

            return factory.newMethodDeclaration(
                    new JavadocBuilder(factory)
                        .text("{0}#{1}で使用するモデルオブジェクトを設定する。",
                                segment.getPort().getOwner().getDescription().getName(),
                                segment.getPort().getDescription().getName())
                        .param(argument)
                            .text("設定するモデルオブジェクト")
                        .toJavadoc(),
                    new AttributeBuilder(factory)
                        .Public()
                        .toAttributes(),
                    t(void.class),
                    factory.newSimpleName(methodName),
                    Collections.singletonList(factory.newFormalParameterDeclaration(
                            t(type.getType()),
                            argument)),
                    statements);
        }
View Full Code Here

        return results;
    }

    private ResolvedSlot compile(Slot slot, int number) {
        assert slot != null;
        DataClass valueClass = environment.getDataClasses().load(slot.getType());
        List<Property> sortProperties = Lists.create();
        if (valueClass == null) {
            valueClass = new DataClass.Unresolved(environment.getModelFactory(), slot.getType());
            environment.error("型{0}をロードできませんでした", slot.getType());
        } else {
            for (String name : slot.getSortPropertyNames()) {
                Property property = valueClass.findProperty(name);
                if (property == null) {
                    environment.error("型{0}のプロパティをロードできませんでした", slot.getType(), name);
                } else {
                    sortProperties.add(property);
                }
View Full Code Here

            .toStatement());

        DataObjectMirror cache = context.createModelCache(output.getDataType());

        List<Statement> combine = Lists.create();
        DataClass outputType = getEnvironment().getDataClasses().load(output.getDataType());
        Summarized summarized = TypeUtil.erase(output.getDataType()).getAnnotation(Summarized.class);
        for (Summarized.Folding folding : summarized.term().foldings()) {
            if (folding.aggregator() == Aggregator.ANY) {
                continue;
            }
View Full Code Here

        @Override
        public void emitLinePart(Context context) {
            Summarized summarized = TypeUtil.erase(outputType).getAnnotation(Summarized.class);
            DataObjectMirror cache = context.createModelCache(outputType);
            DataClass inputData = getEnvironment().getDataClasses().load(inputType);
            DataClass outputData = getEnvironment().getDataClasses().load(outputType);
            for (Summarized.Folding folding : summarized.term().foldings()) {
                context.add(createStartSummarizeFor(context, folding, inputData, outputData, cache.get()));
            }
            context.setOutput(cache.get());
        }
View Full Code Here

TOP

Related Classes of com.asakusafw.compiler.flow.DataClass

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.