use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class ESSearchRequestBuilder method getFieldSortBuilder.
private static FieldSortBuilder getFieldSortBuilder(final SearchIndexDefinition myIndexDefinition, final DtListState myListState) {
final DtField sortField = myIndexDefinition.getIndexDtDefinition().getField(myListState.getSortFieldName().get());
String sortIndexFieldName = sortField.getName();
final IndexType indexType = IndexType.readIndexType(sortField.getDomain());
if (indexType.isIndexSubKeyword()) {
// s'il y a un subKeyword on tri dessus
sortIndexFieldName = sortIndexFieldName + ".keyword";
}
return SortBuilders.fieldSort(sortIndexFieldName).order(myListState.isSortDesc().get() ? SortOrder.DESC : SortOrder.ASC);
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class TaskEngineInsertWithGeneratedKeys method doExecute.
/**
* {@inheritDoc}
*/
@Override
public OptionalInt doExecute(final SqlStatement sqlStatement, final SqlConnection connection) throws SQLException {
Assertion.checkNotNull(sqlStatement);
Assertion.checkNotNull(connection);
// --
final GenerationMode generationMode = connection.getDataBase().getSqlDialect().getGenerationMode();
// gestion de generatedKey
final Entity entity = getValue("DTO");
final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(entity);
final DtField idField = dtDefinition.getIdField().get();
final Tuples.Tuple2<Integer, ?> result = getDataBaseManager().executeUpdateWithGeneratedKey(sqlStatement, generationMode, idField.getName(), idField.getDomain().getJavaClass(), connection);
final Object id = result.getVal2();
idField.getDataAccessor().setValue(entity, id);
// ---
return /*sqlRowcount*/
OptionalInt.of(result.getVal1());
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class CollectionsManagerTest method testFilterFullTextMultiKeyword.
@Test
public void testFilterFullTextMultiKeyword() {
final DtList<SmartItem> dtc = createItems();
final Collection<DtField> searchedDtFields = dtDefinitionItem.getFields();
final SmartItem mock1 = new SmartItem();
mock1.setId(seqId++);
mock1.setLabel("Agence de l'Ouest");
dtc.add(mock1);
final SmartItem mock2 = new SmartItem();
mock2.setId(seqId++);
mock2.setLabel("Hôpital et autres accents çava où ãpied");
dtc.add(mock2);
// mots proches
Assert.assertTrue("La recherche ne supporte pas l'espace", filter(dtc, "agence de", 1000, searchedDtFields).size() == 1);
// mots séparés
Assert.assertTrue("La recherche ne supporte pas l'utilisation de plusieurs mots", filter(dtc, "hopital accent", 1000, searchedDtFields).size() == 1);
// inversés
Assert.assertTrue("La recherche ne supporte pas l'inversion des mots", filter(dtc, "accent hopital", 1000, searchedDtFields).size() == 1);
// multi doc
Assert.assertTrue("Les mots clés ne sont pas en 'ET'", filter(dtc, "agence hopital", 1000, searchedDtFields).size() == 0);
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class CollectionsManagerTest method testFilterFullTextTokenizer.
@Test
public void testFilterFullTextTokenizer() {
final DtList<SmartItem> dtc = createItems();
final Collection<DtField> searchedDtFields = dtDefinitionItem.getFields();
final SmartItem mock1 = new SmartItem();
mock1.setId(seqId++);
mock1.setLabel("Agence de l'Ouest");
dtc.add(mock1);
final SmartItem mock2 = new SmartItem();
mock2.setId(seqId++);
mock2.setLabel("Hôpital et autres accents çava où ãpied");
dtc.add(mock2);
// majuscule/minuscule
Assert.assertTrue("La recherche n'est pas case insensitive", filter(dtc, "agence", 1000, searchedDtFields).size() == 1);
// tokenizer
Assert.assertTrue("La recherche n'est pas plain text", filter(dtc, "l'ouest", 1000, searchedDtFields).size() == 1);
// accents
Assert.assertTrue("La recherche ne supporte pas les accents", filter(dtc, "hopital", 1000, searchedDtFields).size() == 1);
// accents fr (ç)
Assert.assertTrue("La recherche ne supporte pas les caractères spéciaux fr (ç)", filter(dtc, "cava", 1000, searchedDtFields).size() == 1);
// accents autre (ã)
Assert.assertTrue("La recherche ne supporte pas les caractères spéciaux latin1 (ã)", filter(dtc, "apied", 1000, searchedDtFields).size() == 1);
// prefix
Assert.assertTrue("La recherche ne supporte pas la recherche par préfix", filter(dtc, "apie", 1000, searchedDtFields).size() == 1);
}
use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.
the class SecuredEntityDeserializer method deserializeSecurityDimensions.
private static SecurityDimension deserializeSecurityDimensions(final DtDefinition entityDefinition, final JsonObject advancedDimension, final JsonDeserializationContext context) {
final String name = advancedDimension.get("name").getAsString();
final SecurityDimensionType type = SecurityDimensionType.valueOf(advancedDimension.get("type").getAsString());
final List<String> fieldNames = deserializeList(advancedDimension.get("fields"), String.class, context);
final List<DtField> fields = fieldNames.stream().map(fieldName -> deserializeDtField(entityDefinition, fieldName)).collect(Collectors.toList());
final List<String> values = deserializeList(advancedDimension.get("values"), String.class, context);
return new SecurityDimension(name, type, fields, values);
}
Aggregations