Search in sources :

Example 11 with ModelsModel

use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.

the class RewriteQueriesTest method testUpdate9.

@Test
public void testUpdate9() {
    Model model = new ModelsModel().create();
    ModelDeclarations declarations = model.getDeclarations();
    ITemplateManager tm = RewriteQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("update9");
    for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.DataEntity, entity));
    for (int i = 0; i < declarations.wSize(); i++) {
        IEntity decl = declarations.wGet(i);
        if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl)) {
            assertEquals("Object", ((DataEntity) decl).getDataType().getValue());
            assertTrue(((DataEntity) decl).getName().getValue().startsWith("My"));
        }
    }
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) ITemplateManager(org.whole.lang.templates.ITemplateManager) DataEntity(org.whole.lang.models.model.DataEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Test(org.junit.Test)

Example 12 with ModelsModel

use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.

the class RewriteQueriesTest method testUpdate8.

@Test
public void testUpdate8() {
    Model model = new ModelsModel().create();
    ModelDeclarations declarations = model.getDeclarations();
    ITemplateManager tm = RewriteQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("update8");
    for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.DataEntity, entity));
    for (int i = 0; i < declarations.wSize(); i++) {
        IEntity decl = declarations.wGet(i);
        if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl)) {
            assertEquals("Object", ((DataEntity) decl).getDataType().getValue());
            assertTrue(((DataEntity) decl).getName().getValue().startsWith("My"));
        }
    }
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) ITemplateManager(org.whole.lang.templates.ITemplateManager) DataEntity(org.whole.lang.models.model.DataEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Test(org.junit.Test)

Example 13 with ModelsModel

use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.

the class CoreMetaModelsDeployer method deploy.

public void deploy(ReflectionFactory platform) {
    platform.setMetaModelTemplate(CommonsLanguageKit.URI, "Commons model", "org/whole/lang/commons/CommonsModel.xwl");
    platform.setMetaModelTemplate(ActionsLanguageKit.URI, new ActionsModel());
    platform.setMetaModelTemplate(ArtifactsLanguageKit.URI, "Artifacts model", "org/whole/lang/artifacts/ArtifactsModel.xwl");
    platform.setMetaModelTemplate(ChangesLanguageKit.URI, "Changes model", "org/whole/lang/changes/ChangesModel.xwl");
    platform.setMetaModelTemplate(EditorsLanguageKit.URI, new EditorsModel());
    platform.setMetaModelTemplate(EnvironmentLanguageKit.URI, "Environment model", "org/whole/lang/environment/EnvironmentModel.xwl");
    platform.setMetaModelTemplate(FramesLanguageKit.URI, new FramesModel());
    platform.setMetaModelTemplate(GrammarsLanguageKit.URI, new GrammarsModel());
    platform.setMetaModelTemplate(GRAMMAR_BASED_URI, new GrammarBasedModel());
    platform.setMetaModelTemplate(MathLanguageKit.URI, new MathModel());
    platform.setMetaModelTemplate(MiscLanguageKit.URI, new MiscModel());
    platform.setMetaModelTemplate(ModelsLanguageKit.URI, new ModelsModel());
    platform.setMetaModelTemplate(PatternsLanguageKit.URI, "Patterns model", "org/whole/lang/patterns/PatternsModel.xwl");
    platform.setMetaModelTemplate(PojoLanguageKit.URI, new PojoModel());
    platform.setMetaModelTemplate(QueriesLanguageKit.URI, "Queries Model", "org/whole/lang/queries/QueriesModel.xwl");
    platform.setMetaModelTemplate(ReusablesLanguageKit.URI, "Reusables model", "org/whole/lang/reusables/ReusablesModel.xwl");
    platform.setMetaModelTemplate(SemanticsLanguageKit.URI, "Semantics model", "org/whole/lang/semantics/SemanticsModel.xwl");
    platform.setMetaModelTemplate(STATUS_URI, new StatusModel());
    platform.setMetaModelTemplate(SyntaxTreesLanguageKit.URI, "Syntax Trees Model", "org/whole/lang/syntaxtrees/SyntaxTreesModel.xwl");
    platform.setMetaModelTemplate(TestsLanguageKit.URI, "Tests model", "org/whole/lang/tests/TestsModel.xwl");
    platform.setMetaModelTemplate(TemplatesLanguageKit.URI, new TemplatesModel());
    platform.setMetaModelTemplate(TypesLanguageKit.URI, new TypesModel());
    platform.setMetaModelTemplate(WorkflowsLanguageKit.URI, new WorkflowModel());
}
Also used : MathModel(org.whole.lang.models.codebase.MathModel) MiscModel(org.whole.lang.models.codebase.MiscModel) TypesModel(org.whole.lang.models.codebase.TypesModel) FramesModel(org.whole.lang.models.codebase.FramesModel) ActionsModel(org.whole.lang.models.codebase.ActionsModel) TemplatesModel(org.whole.lang.models.codebase.TemplatesModel) PojoModel(org.whole.lang.models.codebase.PojoModel) EditorsModel(org.whole.lang.models.codebase.EditorsModel) GrammarsModel(org.whole.lang.models.codebase.GrammarsModel) WorkflowModel(org.whole.lang.models.codebase.WorkflowModel) ModelsModel(org.whole.lang.models.codebase.ModelsModel) StatusModel(org.whole.lang.models.codebase.StatusModel) GrammarBasedModel(org.whole.lang.models.codebase.GrammarBasedModel)

Example 14 with ModelsModel

use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.

the class RewriteQueriesTest method testInsert1.

@Test
public void testInsert1() {
    Model model = new ModelsModel().create();
    ModelDeclarations declarations = model.getDeclarations();
    ITemplateManager tm = RewriteQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("insert1");
    for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.Feature, entity));
    for (int i = 0; i < declarations.wSize(); i++) {
        IEntity decl = declarations.wGet(i);
        if (Matcher.match(ModelsEntityDescriptorEnum.SimpleEntity, decl)) {
            Features features = ((SimpleEntity) decl).getFeatures();
            int size = features.wSize();
            assertTrue(size >= 2);
            String name1 = ((Feature) features.wGet(size - 2)).getName().getValue();
            assertEquals("n1", name1);
            String name2 = ((Feature) features.wGet(size - 1)).getName().getValue();
            assertEquals("n2", name2);
        }
    }
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) SimpleEntity(org.whole.lang.models.model.SimpleEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) ITemplateManager(org.whole.lang.templates.ITemplateManager) Features(org.whole.lang.models.model.Features) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Test(org.junit.Test)

Example 15 with ModelsModel

use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.

the class RewriteQueriesTest method testUpdate3.

@Test
public void testUpdate3() {
    Model model = new ModelsModel().create();
    ModelDeclarations declarations = model.getDeclarations();
    ITemplateManager tm = RewriteQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("update3");
    List<String> names = new ArrayList<String>();
    for (int i = 0; i < declarations.wSize(); i++) {
        IEntity decl = declarations.wGet(i);
        if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl))
            names.add(((DataEntity) decl).getName().getValue());
    }
    for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.SimpleName, entity));
    Iterator<String> iterator = names.iterator();
    for (int i = 0; i < declarations.wSize() && iterator.hasNext(); i++) {
        IEntity decl = declarations.wGet(i);
        if (Matcher.match(ModelsEntityDescriptorEnum.SimpleEntity, decl))
            assertEquals(iterator.next(), ((SimpleEntity) decl).getName().getValue());
    }
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) ArrayList(java.util.ArrayList) ITemplateManager(org.whole.lang.templates.ITemplateManager) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Test(org.junit.Test)

Aggregations

ModelsModel (org.whole.lang.models.codebase.ModelsModel)26 Test (org.junit.Test)25 IEntity (org.whole.lang.model.IEntity)22 Model (org.whole.lang.models.model.Model)20 PathExpression (org.whole.lang.queries.model.PathExpression)18 ITemplateManager (org.whole.lang.templates.ITemplateManager)18 ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)17 DataEntity (org.whole.lang.models.model.DataEntity)10 SimpleEntity (org.whole.lang.models.model.SimpleEntity)6 XmlModel (org.whole.lang.models.codebase.XmlModel)5 CompositeEntity (org.whole.lang.models.model.CompositeEntity)5 Features (org.whole.lang.models.model.Features)5 EnumEntity (org.whole.lang.models.model.EnumEntity)4 Feature (org.whole.lang.models.model.Feature)4 ArrayList (java.util.ArrayList)3 IBindingManager (org.whole.lang.bindings.IBindingManager)2 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)2 ModelFeaturesBuilder (org.whole.lang.builders.builder.ModelFeaturesBuilder)2 EnumValues (org.whole.lang.models.model.EnumValues)2 ModelTemplate (org.whole.lang.templates.ModelTemplate)2