Package com.asakusafw.modelgen.model

Examples of com.asakusafw.modelgen.model.Source


    }

    private Statement createStartSummarizeFor(
            SimpleName parameterName,
            ModelProperty property) {
        Source source = property.getFrom();
        Expression to = f.newFieldAccessExpression(
                f.newThis(),
                common.getFieldNameOf(property.getName(), property.getType()));
        switch (source.getAggregator()) {
        case IDENT:
        case MAX:
        case MIN:
        case SUM:
            return new ExpressionBuilder(f, to)
                .method(Constants.NAME_OPTION_MODIFIER,
                        new ExpressionBuilder(f, parameterName)
                            .method(common.getGetterNameOf(source.getName(), source.getType()))
                            .toExpression())
                .toStatement();
        case COUNT:
            return new ExpressionBuilder(f, to)
                .method(Constants.NAME_OPTION_MODIFIER, Models.toLiteral(f, 1))
View Full Code Here


    }

    private Statement createAddSummarizeFor(
            String parameterName,
            ModelProperty property) {
        Source source = property.getFrom();
        Expression self = f.newFieldAccessExpression(
                f.newThis(),
                common.getFieldNameOf(property.getName(), property.getType()));
        Expression other = f.newFieldAccessExpression(
                f.newSimpleName(parameterName),
                common.getFieldNameOf(property.getName(), property.getType()));
        Aggregator aggregator = source.getAggregator();
        switch (aggregator) {
        case MAX:
        case MIN:
            return new ExpressionBuilder(f, self)
                .method(aggregator.name().toLowerCase(), other)
View Full Code Here

                .text("設定する値")
            .toJavadoc();
    }

    private String getColumnDescription(ModelProperty property) {
        Source source = property.getFrom();
        if (source.getAggregator() == Aggregator.IDENT) {
            return MessageFormat.format(
                    "グループ化したカラム<code>{0}</code>の内容",
                    source.getName());
        } else {
            return MessageFormat.format(
                    "カラム<code>{0}</code>を<code>{1}()</code>で集約した結果",
                    source.getName(),
                    source.getAggregator());
        }
    }
View Full Code Here

    private void pairingTrivialSource(Side a, Side b) {
        assert a != null;
        assert b != null;
        // 結合条件になったフィールドが結果に含まれる場合、それもソースとして登録する
        for (int i = 0, n = a.condition.size(); i < n; i++) {
            Source as = a.condition.get(i);
            Source bs = b.condition.get(i);
            if (a.mapping.containsKey(as.getName())
                    && b.mapping.containsKey(bs.getName()) == false) {
                String column = a.mapping.get(as.getName());
                b.mapping.put(bs.getName(), column);
            }
        }
    }
View Full Code Here

            if (opposite == null) {
                continue; // 逆側でもマッピングされていない
            }

            // 見つかった場合、型の互換性を確認
            Source as = a.sources.get(unmapped);
            Source bs = b.sources.get(unmapped);
            assert as != null;
            assert bs != null;
            if (as.getType().equals(bs.getType()) == false) {
                continue; // 型に互換性が無い
            }

            // 合致したら、逆側のマッピングに相乗りする
            entry.setValue(opposite);
View Full Code Here

                        sourceProperty,
                        getReference()));
            }
            simpleName = sourceProperty.substring(qualified + 1);
        }
        Source source = sources.get(simpleName);
        if (source == null) {
            throw new IllegalArgumentException(MessageFormat.format(
                    "\"{0}\" が見つかりません ({1})",
                    simpleName,
                    getReference()));
View Full Code Here

            throw new IllegalArgumentException("aggregator must not be null"); //$NON-NLS-1$
        }
        if (sourceProperty == null) {
            throw new IllegalArgumentException("sourceProperty must not be null"); //$NON-NLS-1$
        }
        Source source = find(sourceProperty);
        if (aggregator.inferType(source.getType()) == null) {
            throw new IllegalArgumentException(MessageFormat.format(
                    "プロパティ ({0}.{1}:{2}) に集約関数 {3} を適用できません ({4})",
                    source.getDeclaring(),
                    source.getName(),
                    source.getType(),
                    aggregator.name(),
                    getReference()));
        }
        Column column = new Column(columnName, aggregator, source);
        columns.add(column);
View Full Code Here

                    getReference()));
        }
        List<ModelProperty> properties = new ArrayList<ModelProperty>();
        for (Column column : columns) {
            Aggregator aggregator = column.aggregator;
            Source source = column.source;
            if (aggregator == Aggregator.IDENT
                    && groupProperties.contains(source) == false) {
                throw new IllegalStateException(MessageFormat.format(
                        "プロパティ \"{0}.{1}\" は集約関数かグループ化のキーとして指定する必要があります ({2})",
                        source.getDeclaring(),
                        source.getName(),
                        getReference()));
            }
            ModelProperty property = toProperty(column);
            properties.add(property);
        }
View Full Code Here

    }

    private ModelProperty toProperty(Column column) {
        assert column != null;
        // aggregatorだけを書き換えたソースを作成
        Source source = new Source(
                column.aggregator,
                column.source.getDeclaring(),
                column.source.getName(),
                column.source.getType(),
                Collections.<Attribute>emptySet());
View Full Code Here

        return new TableModelDescription(getReference(), properties);
    }

    private ModelProperty toProperty(Column column) {
        assert column != null;
        Source source = new Source(
                Aggregator.IDENT,
                getReference(),
                column.name,
                column.type,
                column.attributes);
View Full Code Here

TOP

Related Classes of com.asakusafw.modelgen.model.Source

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.