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"));
}
}
}
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"));
}
}
}
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());
}
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);
}
}
}
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());
}
}
Aggregations