Package com.asakusafw.dmdl.semantics

Examples of com.asakusafw.dmdl.semantics.PropertyDeclaration


    public void summarize_whole() {
        DmdlSemantics resolved = resolve();
        ModelDeclaration counter = resolved.findModelDeclaration("counter");
        assertThat(counter, not(nullValue()));

        PropertyDeclaration count = counter.findPropertyDeclaration("count");
        assertThat(count, not(nullValue()));
        assertThat(count.getType(), is(type(BasicTypeKind.LONG)));

        SummarizeTrait trait = counter.getTrait(SummarizeTrait.class);
        assertThat(trait, not(nullValue()));
        assertThat(trait.getTerms().size(), is(1));
View Full Code Here


        assert folding != null;
        ModelDeclaration sourceModel = source.findDeclaration();
        assert sourceModel != null;
        List<MappingFactor> results = Lists.create();
        for (AstPropertyFolding propertyFolding : folding.properties) {
            PropertyDeclaration targetProperty = model.findPropertyDeclaration(propertyFolding.target.identifier);
            PropertyMappingKind mapping = resolveAggregateFunction(propertyFolding.aggregator);
            if (targetProperty != null && mapping != null) {
                results.add(new MappingFactor(
                        source.getName(),
                        mapping,
                        source.createPropertySymbol(propertyFolding.source),
                        targetProperty.getSymbol()));
            }
        }
        return results;
    }
View Full Code Here

        if (grouping == null) {
            return Collections.emptyList();
        } else {
            List<PropertySymbol> results = Lists.create();
            for (AstSimpleName name : grouping.properties) {
                PropertyDeclaration property = properties.get(name.identifier);
                if (property == null) {
                    report(new Diagnostic(
                            Level.ERROR,
                            name,
                            Messages.getString("DmdlAnalyzer.diagnosticMissingSummarizeGroupingProperty"), //$NON-NLS-1$
View Full Code Here

                return false;
            }
            List<PropertyDeclaration> nextSources = resolveGroupingSources(next);
            assert firstSources.size() == nextSources.size();
            for (int i = 0, n = firstSources.size(); i < n; i++) {
                PropertyDeclaration left = firstSources.get(i);
                PropertyDeclaration right = nextSources.get(i);
                if (left.getType().isSame(right.getType()) == false) {
                    PropertySymbol rightSymbol = next.getGrouping().get(i);
                    report(new Diagnostic(
                            Level.ERROR,
                            rightSymbol.getOriginalAst(),
                            Messages.getString("DmdlAnalyzer.diagnosticInconsistentTypeGroupingProperty"), //$NON-NLS-1$
View Full Code Here

                        Messages.getString("DmdlAnalyzer.diagnosticMissingModel"), //$NON-NLS-1$
                        node.name.identifier));
                return null;
            }
            for (PropertyDeclaration property : decl.getDeclaredProperties()) {
                PropertyDeclaration other = model.findPropertyDeclaration(property.getName().identifier);
                if (other != null) {
                    LOG.debug("property {} is duplicated", property.getSymbol()); //$NON-NLS-1$
                    if (property.getType().isSame(other.getType()) == false) {
                        report(new Diagnostic(
                                Level.ERROR,
                                node,
                                Messages.getString("DmdlAnalyzer.diagnosticInconsistentTypeProperty"), //$NON-NLS-1$
                                property.getName(),
View Full Code Here

                            Messages.getString("DmdlAnalyzer.diagnosticUnknownTypeProperty"), //$NON-NLS-1$
                            property.type.toString()));
                    continue;
                }

                PropertyDeclaration other = model.findPropertyDeclaration(property.name.identifier);
                if (other != null) {
                    LOG.debug("property {} is duplicated", property.name); //$NON-NLS-1$
                    if (type.equals(other.getType()) == false) {
                        report(new Diagnostic(
                                Level.ERROR,
                                property.name,
                                Messages.getString(
                                        "DmdlAnalyzer.diagnosticInconsistentTypeRepordProperty"), //$NON-NLS-1$
View Full Code Here

        ModelDeclaration sourceDecl = sourceModel.findDeclaration();
        assert sourceDecl != null;
        Map<String, PropertyDeclaration> results = new HashMap<String, PropertyDeclaration>();
        if (term.mapping == null) {
            for (PropertyDeclaration prop : sourceDecl.getDeclaredProperties()) {
                PropertyDeclaration declared = model.findPropertyDeclaration(prop.getName().identifier);
                if (declared != null) {
                    LOG.debug("property {} is duplicated", prop.getSymbol()); //$NON-NLS-1$
                    results.put(declared.getName().identifier, declared);
                } else {
                    declared = model.declareProperty(
                            sourceModel.getName(),
                            prop.getName(),
                            prop.getType(),
                            prop.getDescription(),
                            prop.getAttributes());
                    results.put(declared.getName().identifier, declared);
                }
            }
        } else {
            Set<String> saw = Sets.create();
            for (AstPropertyMapping property : term.mapping.properties) {
                if (saw.contains(property.target.identifier)) {
                    report(new Diagnostic(
                            Level.ERROR,
                            property,
                            Messages.getString("DmdlAnalyzer.diagnosticDuplicatedJoinMappingProperty"), //$NON-NLS-1$
                            property.target.identifier));
                    continue;
                }
                saw.add(property.target.identifier);
                PropertyDeclaration sourceProp = sourceDecl.findPropertyDeclaration(property.source.identifier);
                if (sourceProp == null) {
                    report(new Diagnostic(
                            Level.ERROR,
                            sourceModel.getName(),
                            Messages.getString("DmdlAnalyzer.diagnosticMissingJoinProperty"), //$NON-NLS-1$
                            property.source.identifier,
                            sourceModel.getName().identifier));
                    continue;
                }
                PropertyDeclaration declared = model.findPropertyDeclaration(property.target.identifier);
                if (declared != null) {
                    LOG.debug("property {} is duplicated", property.target); //$NON-NLS-1$
                    results.put(declared.getName().identifier, declared);
                } else {
                    declared = model.declareProperty(
                            property,
                            property.target,
                            sourceProp.getType(),
                            property.description,
                            property.attributes);
                    results.put(declared.getName().identifier, declared);
                }
            }
        }
        return results;
    }
View Full Code Here

        ModelDeclaration sourceModel = source.findDeclaration();
        assert sourceModel != null;
        List<MappingFactor> results = Lists.create();
        if (mapping == null) {
            for (PropertyDeclaration property : sourceModel.getDeclaredProperties()) {
                PropertyDeclaration targetProperty = model.findPropertyDeclaration(property.getName().identifier);
                if (targetProperty != null) {
                    results.add(new MappingFactor(
                            source.getName(),
                            PropertyMappingKind.ANY,
                            source.createPropertySymbol(property.getName()),
                            targetProperty.getSymbol()));
                }
            }
        } else {
            for (AstPropertyMapping propertyMapping : mapping.properties) {
                PropertyDeclaration targetProperty = model.findPropertyDeclaration(propertyMapping.target.identifier);
                if (targetProperty != null) {
                    results.add(new MappingFactor(
                            source.getName(),
                            PropertyMappingKind.ANY,
                            source.createPropertySymbol(propertyMapping.source),
                            targetProperty.getSymbol()));
                }
            }
        }
        return results;
    }
View Full Code Here

        ModelDeclaration decl = source.findDeclaration();
        assert decl != null;
        Map<String, PropertyDeclaration> results = new HashMap<String, PropertyDeclaration>();
        for (AstPropertyFolding property : term.folding.properties) {
            PropertyDeclaration original = decl.findPropertyDeclaration(property.source.identifier);
            if (original == null) {
                report(new Diagnostic(
                        Level.ERROR,
                        source.getName(),
                        Messages.getString("DmdlAnalyzer.diagnosticMissingSummarizeFoldingProperty"), //$NON-NLS-1$
                        property.source.identifier,
                        source.getName().identifier));
                continue;
            }
            PropertyMappingKind mapping = resolveAggregateFunction(property.aggregator);
            if (mapping == null) {
                report(new Diagnostic(
                        Level.ERROR,
                        property.aggregator,
                        Messages.getString("DmdlAnalyzer.diagnosticMissingSummarizeAggregateFunction"), //$NON-NLS-1$
                        property.aggregator.toString()));
                continue;
            }
            Type resolved = original.getType().map(mapping);
            if (resolved == null) {
                report(new Diagnostic(
                        Level.ERROR,
                        property,
                        Messages.getString(
                                "DmdlAnalyzer.diagnosticInconsistentSummarizeAggregateFunction"), //$NON-NLS-1$
                        property.aggregator.toString(),
                        property.source.identifier,
                        original.getType()));
                continue;
            }
            PropertyDeclaration declared = model.findPropertyDeclaration(property.target.identifier);
            if (declared != null) {
                report(new Diagnostic(
                        Level.ERROR,
                        property.target,
                        Messages.getString("DmdlAnalyzer.diagnosticDuplicatedSummarizeProperty"), //$NON-NLS-1$
                        property.target.identifier));
                continue;
            }
            PropertyDeclaration result = model.declareProperty(
                    property,
                    property.target,
                    resolved,
                    property.description,
                    property.attributes);
            results.put(result.getName().identifier, result);
        }
        return results;
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.dmdl.semantics.PropertyDeclaration

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.