Package com.asakusafw.dmdl.semantics

Examples of com.asakusafw.dmdl.semantics.ModelDeclaration


     */
    public Type resolve(ModelSymbol model) {
        if (model == null) {
            throw new IllegalArgumentException("model must not be null"); //$NON-NLS-1$
        }
        ModelDeclaration decl = model.findDeclaration();
        if (decl == null) {
            throw new IllegalArgumentException();
        }
        Name qualifiedName = Models.append(factory,
                config.getBasePackage(),
View Full Code Here


     * simple record.
     */
    @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

     * simple record with projections.
     */
    @Test
    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

     * joined model.
     */
    @Test
    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));

        ReduceTerm<AstJoin> aTerm = trait.getTerms().get(0);
        assertThat(aTerm.getSource(), is(model("a")));
View Full Code Here

     * summarized model.
     */
    @Test
    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));

        ReduceTerm<AstSummarize> aTerm = trait.getTerms().get(0);
        assertThat(aTerm.getSource(), is(model("a")));
View Full Code Here

     * summarized model.
     */
    @Test
    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));

        ReduceTerm<AstSummarize> aTerm = trait.getTerms().get(0);
        assertThat(aTerm.getSource(), is(model("simple")));
View Full Code Here

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

        NamespaceTrait trait = model.getTrait(NamespaceTrait.class);
        assertThat(trait, not(nullValue()));
        assertThat(trait.getNamespace().toString(), is("com.example"));
    }
View Full Code Here

     * namespace is not specified.
     */
    @Test
    public void empty() {
        DmdlSemantics world = resolve();
        ModelDeclaration model = world.findModelDeclaration("simple");
        assertThat(model.getSymbol(), is(model("simple")));

        NamespaceTrait trait = model.getTrait(NamespaceTrait.class);
        assertThat(trait, nullValue());
    }
View Full Code Here

     * auto projection.
     */
    @Test
    public void auto_projection() {
        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("p1")));
    }
View Full Code Here

     * includes subset.
     */
    @Test
    public void auto_projection_subset() {
        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("p1")));
    }
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.