use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class PojoMappingUtils method getLibrary.
public static Library getLibrary(Misc compilationUnits, IBindingManager bindings) {
PathExpression javaModelToPojoModel = new JavaModelToPojoModelQuery().create();
Library library = BehaviorUtils.<Library>evaluateFirstResult(javaModelToPojoModel, compilationUnits, bindings);
Matcher.removeVars(library, true);
return library;
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class PojoMappingUtils method getModel.
public static Model getModel(Library library) {
IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
PathExpression pojoModelToModels = new PojoModelToModelsQuery().create();
Library normalizedLibrary = NormalizerOperation.normalize(EntityUtils.clone(library));
Model model = BehaviorUtils.<Model>evaluateFirstResult(pojoModelToModels, normalizedLibrary, bindings);
Matcher.removeVars(model, true);
return model;
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class BindVariablesInPathTest method testBindVariablesInPathOK2.
@Test
public void testBindVariablesInPathOK2() throws Exception {
IBindingManager bindings = BindingManagerFactory.instance.createArguments();
IEntity compilationUnits = BindVariablesInPathTemplateManager.instance().create("compilationUnit");
PathExpression findClassDeclarationsOK2 = (PathExpression) BindVariablesInPathTemplateManager.instance().create("findClassDeclarationsOK2");
IEntityIterator<IEntity> iterator;
iterator = BehaviorUtils.<IEntity>compileAndLazyEvaluate(findClassDeclarationsOK2, compilationUnits, bindings);
while (iterator.hasNext()) {
assertNotNull(iterator.next());
assertTrue(bindings.wIsSet("methodDeclaration"));
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class BindVariablesInPathTest method testBindVariablesInPathOK1.
@Test
public void testBindVariablesInPathOK1() throws Exception {
IBindingManager bindings = BindingManagerFactory.instance.createArguments();
IEntity compilationUnits = BindVariablesInPathTemplateManager.instance().create("compilationUnit");
PathExpression findClassDeclarationsOK1 = (PathExpression) BindVariablesInPathTemplateManager.instance().create("findClassDeclarationsOK1");
IEntityIterator<IEntity> iterator;
iterator = BehaviorUtils.<IEntity>compileAndLazyEvaluate(findClassDeclarationsOK1, compilationUnits, bindings);
while (iterator.hasNext()) {
assertNotNull(iterator.next());
assertTrue(bindings.wIsSet("methodDeclaration"));
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class ControlQueriesTest method testIf4.
@Test
public void testIf4() {
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("if4");
QueriesEntityFactory qef = QueriesEntityFactory.instance;
IEntity queryExp1 = qef.createDivision(qef.createIntLiteral(10), qef.createIntLiteral(8));
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, queryExp1, bm);
assertTrue(iterator.hasNext());
IEntity exp1 = iterator.next();
assertSame(queryExp1.wGet(0), exp1);
assertTrue(bm.wIsSet("a"));
assertFalse(bm.wIsSet("b"));
assertFalse(bm.wIsSet("exp1"));
assertFalse(bm.wIsSet("exp2"));
assertTrue(iterator.hasNext());
IEntity exp2 = iterator.next();
assertSame(queryExp1.wGet(1), exp2);
assertFalse(bm.wIsSet("a"));
assertTrue(bm.wIsSet("b"));
assertFalse(bm.wIsSet("exp1"));
assertFalse(bm.wIsSet("exp2"));
assertFalse(iterator.hasNext());
}
Aggregations