use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testTrim.
/**
* Test du preprocessor trim.
* Note: nous n'avons pas accès à la chaine trimée, on check juste que la requete est valide.
*/
@Test
public void testTrim() {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskObject("TK_SCRIPT_TEST", "select * from SUPER_HERO \n<%if(false) {%>\nwhere ID = #DTO_SUPER_HERO.ID#\n<%}%>\n");
final SuperHero superHero = new SuperHero();
superHero.setId(10001L + 1);
final Task task = Task.builder(taskDefinition).addValue(DTO_SUPER_HERO, superHero).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(10, resultList.size());
}
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testWhereIn2200.
/**
* Test where in avec 2200 Id a inclure.
*/
@Test
public void testWhereIn2200() {
superHeroDataBase.populateSuperHero(storeManager, 4500);
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO where ID in (#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
final DtList<SuperHero> ids = new DtList<>(SuperHero.class);
for (int i = 0; i < 2200; i++) {
ids.add(createSuperHero(10001L + 2 * i));
}
final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(2200, resultList.size());
}
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testWhereInTab.
/**
* Test exécution d'une tache.
*/
@Test
public void testWhereInTab() {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO where\tID in\t(#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
final DtList<SuperHero> ids = DtList.of(createSuperHero(10001L + 1), createSuperHero(10001L + 3));
final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(2, resultList.size());
Assert.assertEquals(10001L + 1, resultList.get(0).getId().longValue());
Assert.assertEquals(10001L + 3, resultList.get(1).getId().longValue());
}
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testScriptVar.
/**
* Test des scripts.
*/
@Test
public void testScriptVar() {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskObject("TK_SCRIPT_TEST", "select * from SUPER_HERO <%if(dtoSuperHero.getId() == 10002L) {%>where ID = #DTO_SUPER_HERO.ID#<%}%>");
final SuperHero superHero = new SuperHero();
superHero.setId(10001L + 1);
final Task task = Task.builder(taskDefinition).addValue(DTO_SUPER_HERO, superHero).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(1, resultList.size());
Assert.assertEquals(10001L + 1, resultList.get(0).getId().longValue());
}
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class SqlDataStorePlugin method readNullable.
/**
* {@inheritDoc}
*/
@Override
public <E extends Entity> E readNullable(final DtDefinition dtDefinition, final URI<E> uri) {
final String tableName = getTableName(dtDefinition);
final String taskName = TASK.TK_SELECT + "_" + dtDefinition.getLocalName() + "_BY_URI";
final String requestedFields = getRequestedFields(dtDefinition);
final DtField idField = getIdField(dtDefinition);
final String idFieldName = idField.getName();
final String request = new StringBuilder().append(" select ").append(requestedFields).append(" from ").append(tableName).append(" where ").append(idFieldName).append(" = #").append(idFieldName).append('#').toString();
final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dataSpace).withRequest(request).addInRequired(idFieldName, idField.getDomain()).withOutOptional("dto", Home.getApp().getDefinitionSpace().resolve(DOMAIN_PREFIX + SEPARATOR + uri.getDefinition().getName() + "_DTO", Domain.class)).build();
final Task task = Task.builder(taskDefinition).addValue(idFieldName, uri.getId()).build();
return taskManager.execute(task).getResult();
}
Aggregations