Package com.asakusafw.dmdl.semantics

Examples of com.asakusafw.dmdl.semantics.ModelDeclaration


     * does not include superset.
     */
    @Test
    public void auto_projection_superset() {
        DmdlSemantics world = resolve();
        ModelDeclaration model = world.findModelDeclaration("simple");
        assertThat(model.getSymbol(), is(model("simple")));

        List<ModelSymbol> projections = projections(model);
        assertThat(projections.size(), is(0));
    }
View Full Code Here


     * does not include superset.
     */
    @Test
    public void auto_projection_incompatible() {
        DmdlSemantics world = resolve();
        ModelDeclaration model = world.findModelDeclaration("simple");
        assertThat(model.getSymbol(), is(model("simple")));

        List<ModelSymbol> projections = projections(model);
        assertThat(projections.size(), is(0));
    }
View Full Code Here

     * only includes projective models.
     */
    @Test
    public void auto_projection_record() {
        DmdlSemantics world = resolve();
        ModelDeclaration model = world.findModelDeclaration("simple");
        assertThat(model.getSymbol(), is(model("simple")));

        List<ModelSymbol> projections = projections(model);
        assertThat(projections.size(), is(0));
    }
View Full Code Here

     * already includes some projections.
     */
    @Test
    public void auto_projection_already() {
        DmdlSemantics world = resolve();
        ModelDeclaration model = world.findModelDeclaration("simple");
        assertThat(model.getSymbol(), is(model("simple")));

        List<ModelSymbol> projections = projections(model);
        assertThat(projections.size(), is(2));
        assertThat(projections, has(model("p1")));
        assertThat(projections, has(model("p2")));
View Full Code Here

     * auto projection for summarization.
     */
    @Test
    public void auto_projection_summarize() {
        DmdlSemantics world = resolve();
        ModelDeclaration model = world.findModelDeclaration("simple");
        assertThat(model.getSymbol(), is(model("simple")));

        List<ModelSymbol> projections = projections(model);
        assertThat(projections.size(), is(1));
        assertThat(projections, has(model("total")));
    }
View Full Code Here

        }

        @Override
        public Void visitModelReference(ModelDeclaration model, AstModelReference node) {
            LOG.debug("processing model reference: {}", node); //$NON-NLS-1$
            ModelDeclaration decl = context.getWorld().findModelDeclaration(node.name.identifier);
            if (decl == null) {
                report(new Diagnostic(
                        Level.ERROR,
                        node.name,
                        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(),
                                model.getName()));
                    }
                    continue;
                }
                model.declareProperty(
                        node,
                        property.getName(),
                        property.getType(),
                        property.getDescription(),
                        property.getAttributes());
            }
            if (decl.getOriginalAst().kind == ModelDefinitionKind.PROJECTIVE) {
                projections.add(context.getWorld().createModelSymbol(node.name));
            }
            return null;
        }
View Full Code Here

        Set<Set<String>> circuits = Graphs.findCircuit(modelDependencies);
        if (circuits.isEmpty() == false) {
            for (Set<String> loop : circuits) {
                for (String modelName : loop) {
                    AstSimpleName node = null;
                    ModelDeclaration md = context.getWorld().findModelDeclaration(modelName);
                    if (md != null) {
                        node = md.getName();
                    }
                    report(new Diagnostic(
                            Level.ERROR,
                            node,
                            Messages.getString("DmdlAnalyzer.diagnosticCyclicDependencies"), //$NON-NLS-1$
                            modelName,
                            loop));
                }
            }
            return;
        }

        DmdlSemantics world = context.getWorld();
        for (String name : Graphs.sortPostOrder(modelDependencies)) {
            ModelDeclaration model = world.findModelDeclaration(name);
            if (model == null) {
                // means "model have not been declared, but is referenced."
                continue;
            }
            resolveModelSymbol(model);
View Full Code Here

        if (term.grouping != null) {
            for (AstSimpleName name : term.grouping.properties) {
                groupingPropertyNames.add(name.identifier);
            }
        }
        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$
View Full Code Here

    }

    private List<MappingFactor> resolveMapping(ModelDeclaration model, ModelSymbol source, AstModelMapping mapping) {
        assert model != null;
        assert source != null;
        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,
View Full Code Here

        assert model != null;
        assert source != null;
        assert term != null;
        LOG.debug("processing model folding: {}", term.folding); //$NON-NLS-1$

        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$
View Full Code Here

TOP

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

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.