Examples of JoinTrait


Examples of com.asakusafw.dmdl.semantics.trait.JoinTrait

    @Override
    public List<Annotation> getTypeAnnotations(EmitContext context, ModelDeclaration model) {
        if (model.getOriginalAst().kind != ModelDefinitionKind.JOINED) {
            return Collections.emptyList();
        }
        JoinTrait trait = model.getTrait(JoinTrait.class);
        if (trait == null) {
            throw new IllegalStateException(MessageFormat.format(
                    "Internal Error: joined model {0} has no JoinTrait", //$NON-NLS-1$
                    model.getName()));
        }

        ModelFactory f = context.getModelFactory();
        List<Annotation> eTerms = Lists.create();
        for (ReduceTerm<?> term : trait.getTerms()) {
            ClassLiteral source = f.newClassLiteral(context.resolve(term.getSource()));
            ArrayInitializer mappings = toMappings(context, term.getMappings());
            Annotation shuffle = toKey(context, term);
            eTerms.addAll(new AttributeBuilder(f)
                .annotation(context.resolve(Joined.Term.class),
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.JoinTrait

        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")));
        assertThat(aTerm.getGrouping(), has(property("sid")));
        assertThat(aTerm.getMappings(), has(mapping(PropertyMappingKind.ANY, "sid", "sid")));
        assertThat(aTerm.getMappings(), has(mapping(PropertyMappingKind.ANY, "value", "a_value")));

        ReduceTerm<AstJoin> bTerm = trait.getTerms().get(1);
        assertThat(bTerm.getSource(), is(model("b")));
        assertThat(bTerm.getGrouping(), has(property("sid")));
        assertThat(bTerm.getMappings(), has(mapping(PropertyMappingKind.ANY, "sid", "sid")));
        assertThat(bTerm.getMappings(), has(mapping(PropertyMappingKind.ANY, "value", "b_value")));
    }
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.JoinTrait

            List<MappingFactor> mappings = resolveMapping(model, source, term.mapping);
            List<PropertySymbol> grouping = resolveGrouping(model, properties, term.grouping);
            results.add(new ReduceTerm<AstJoin>(term, source, mappings, grouping));
        }
        if (context.getWorld().hasError() == false && checkJoinTerms(model, results)) {
            model.putTrait(JoinTrait.class, new JoinTrait(expression, results));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.