Search in sources :

Example 1 with FeatureModifiers

use of org.whole.lang.models.model.FeatureModifiers in project whole by wholeplatform.

the class ControlQueriesTest method testQueryDecl8.

@Test
public void testQueryDecl8() {
    ModelsEntityFactory mef = ModelsEntityFactory.instance;
    FeatureModifiers modifiers = mef.createFeatureModifiers(mef.createFeatureModifier(FeatureModifierEnum.optional), mef.createFeatureModifier(FeatureModifierEnum.derived), mef.createFeatureModifier(FeatureModifierEnum.id));
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("queryDecl8");
    int count = 0;
    for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, modifiers)) {
        IEntity modifier = modifiers.wGet(count++);
        assertTrue(Matcher.match(modifier, p));
    }
    assertEquals(modifiers.wSize(), count);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) FeatureModifiers(org.whole.lang.models.model.FeatureModifiers) ModelsEntityFactory(org.whole.lang.models.factories.ModelsEntityFactory) ITemplateManager(org.whole.lang.templates.ITemplateManager) Test(org.junit.Test)

Example 2 with FeatureModifiers

use of org.whole.lang.models.model.FeatureModifiers in project whole by wholeplatform.

the class ModelsJavaModelGeneratorVisitor method visit.

public void visit(Feature feature) {
    String name = feature.getName().wStringValue();
    // was StringUtils.javaKeywordFilter(name);
    String fName = modelInfo.featureImplName(name);
    String type = feature.getType().wStringValue();
    String fType = modelInfo.entityImplName(type);
    String fQType = modelsGen.entityInterfaceQName(fType);
    String oName = null;
    String ofName = null;
    SimpleName oppositeName = feature.getOppositeName();
    if (DataTypeUtils.getDataKind(oppositeName).isString()) {
        oName = oppositeName.getValue();
        // was StringUtils.javaKeywordFilter(oName);
        ofName = modelInfo.featureImplName(oName);
    }
    FeatureModifiers mods = feature.getModifiers();
    featureModifiers.clear();
    mods.accept(this);
    boolean isByReference = mods.wContainsValue(FeatureModifierEnum.reference);
    if (isConcrete)
        simpleEntityBuilder.addField(fType, fName, name, mods.wContainsValue(FeatureModifierEnum.id), mods.wContainsValue(FeatureModifierEnum.optional), isByReference, mods.wContainsValue(FeatureModifierEnum.shared), mods.wContainsValue(FeatureModifierEnum.derived));
    if (modelInfo.isNotInherited(metaName, name))
        simpleEntityInterfaceBuilder.addField(fType, fName, name);
    modelsGen.modelContextBuilder().addFeature(fType, fName);
    modelsGen.visitorsBuilder().addFeature(entityName, fType, fName, name, isByReference);
    modelsGen.entityDescriptorEnumBuilder().addFeature(qEntityName, fType, fName, ofName, featureModifiers);
    modelsGen.featureDescriptorEnumBuilder().addFeature(fType, fName, name);
    if (oName != null)
        modelsGen.featureDescriptorEnumBuilder().addFeature(entityName, ofName, oName);
    if (isConcrete)
        modelsGen.entityFactoryBuilder().addFactoryMethodCase(fQType, fName);
    entityAdapterBuilder.addFeature(fType, fName, name);
}
Also used : FeatureModifiers(org.whole.lang.models.model.FeatureModifiers) SimpleName(org.whole.lang.models.model.SimpleName)

Aggregations

FeatureModifiers (org.whole.lang.models.model.FeatureModifiers)2 Test (org.junit.Test)1 IEntity (org.whole.lang.model.IEntity)1 ModelsEntityFactory (org.whole.lang.models.factories.ModelsEntityFactory)1 SimpleName (org.whole.lang.models.model.SimpleName)1 PathExpression (org.whole.lang.queries.model.PathExpression)1 ITemplateManager (org.whole.lang.templates.ITemplateManager)1