Package com.asakusafw.dmdl.semantics

Examples of com.asakusafw.dmdl.semantics.PropertyDeclaration


                "model = {",
                "  @directio.hive.char(length = 3)",
                "  simple : TEXT;",
                "};"
        }).findModelDeclaration("model");
        PropertyDeclaration property = model.findPropertyDeclaration("simple");
        HiveFieldTrait trait = property.getTrait(HiveFieldTrait.class);
        assertThat(trait, is(notNullValue()));
        assertThat(trait.getTypeKind(), is(HiveFieldTrait.TypeKind.CHAR));
        assertThat(trait.getStringLength(), is(3));
    }
View Full Code Here


                "model = {",
                "  @directio.hive.ignore",
                "  simple : INT;",
                "};"
        }).findModelDeclaration("model");
        PropertyDeclaration property = model.findPropertyDeclaration("simple");
        HiveFieldTrait trait = property.getTrait(HiveFieldTrait.class);
        assertThat(trait, is(notNullValue()));
        assertThat(trait.isColumnPresent(), is(false));
    }
View Full Code Here

                "model = {",
                "  @directio.hive.varchar(length = 3)",
                "  simple : TEXT;",
                "};"
        }).findModelDeclaration("model");
        PropertyDeclaration property = model.findPropertyDeclaration("simple");
        HiveFieldTrait trait = property.getTrait(HiveFieldTrait.class);
        assertThat(trait, is(notNullValue()));
        assertThat(trait.getTypeKind(), is(HiveFieldTrait.TypeKind.VARCHAR));
        assertThat(trait.getStringLength(), is(3));
    }
View Full Code Here

            reverseMapping.put(mapping.getTarget().getName().identifier, mapping.getSource());
        }
        for (PropertySymbol property : term.getGrouping()) {
            PropertySymbol origin = reverseMapping.get(property.getName().identifier);
            assert origin != null;
            PropertyDeclaration decl = origin.findDeclaration();
            properties.add(Models.toLiteral(f, context.getFieldName(decl).getToken()));
        }
        return new AttributeBuilder(f)
            .annotation(context.resolve(Key.class),
                    "group", f.newArrayInitializer(properties)) //$NON-NLS-1$
View Full Code Here

            reverseMapping.put(mapping.getTarget().getName().identifier, mapping.getSource());
        }
        for (PropertySymbol property : term.getGrouping()) {
            PropertySymbol origin = reverseMapping.get(property.getName().identifier);
            assert origin != null;
            PropertyDeclaration decl = origin.findDeclaration();
            properties.add(Models.toLiteral(f, context.getFieldName(decl).getToken()));
        }
        return new AttributeBuilder(f)
            .annotation(context.resolve(Key.class),
                    "group", f.newArrayInitializer(properties)) //$NON-NLS-1$
View Full Code Here

        }
    }

    private BasicTypeKind type(PropertySymbol symbol) {
        assert symbol != null;
        PropertyDeclaration decl = symbol.findDeclaration();
        assert decl != null;
        Type type = decl.getType();
        if ((type instanceof BasicType) == false) {
            return null;
        }
        return ((BasicType) type).getKind();
    }
View Full Code Here

    @Test
    public void simple() {
        DmdlSemantics resolved = resolve();
        ModelDeclaration simple = resolved.findModelDeclaration("simple");
        assertThat(simple, not(nullValue()));
        PropertyDeclaration property = simple.findPropertyDeclaration("a");
        assertThat(property, not(nullValue()));
        assertThat(property.getType(), is(type(BasicTypeKind.INT)));
    }
View Full Code Here

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

        PropertyDeclaration a = simple.findPropertyDeclaration("a");
        assertThat(a, not(nullValue()));
        assertThat(a.getType(), is(type(BasicTypeKind.INT)));

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

        ProjectionsTrait trait = simple.getTrait(ProjectionsTrait.class);
        assertThat(trait, not(nullValue()));
        assertThat(trait.getProjections(), has(model("a")));
        assertThat(trait.getProjections(), has(model("b")));
View Full Code Here

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

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

        PropertyDeclaration aValue = simple.findPropertyDeclaration("a_value");
        assertThat(aValue, not(nullValue()));
        assertThat(aValue.getType(), is(type(BasicTypeKind.TEXT)));

        PropertyDeclaration bValue = simple.findPropertyDeclaration("b_value");
        assertThat(bValue, not(nullValue()));
        assertThat(bValue.getType(), is(type(BasicTypeKind.DATE)));

        JoinTrait trait = simple.getTrait(JoinTrait.class);
        assertThat(trait, not(nullValue()));
        assertThat(trait.getTerms().size(), is(2));
View Full Code Here

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

        PropertyDeclaration key = simple.findPropertyDeclaration("key");
        assertThat(key, not(nullValue()));
        assertThat(key.getType(), is(type(BasicTypeKind.INT)));

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

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

        PropertyDeclaration max = simple.findPropertyDeclaration("max");
        assertThat(max, not(nullValue()));
        assertThat(max.getType(), is(type(BasicTypeKind.DATE)));

        PropertyDeclaration min = simple.findPropertyDeclaration("min");
        assertThat(min, not(nullValue()));
        assertThat(min.getType(), is(type(BasicTypeKind.DATE)));

        SummarizeTrait trait = simple.getTrait(SummarizeTrait.class);
        assertThat(trait, not(nullValue()));
        assertThat(trait.getTerms().size(), is(1));
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.