Search in sources :

Example 16 with DtField

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);
}
Also used : DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 17 with DtField

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());
}
Also used : Entity(io.vertigo.dynamo.domain.model.Entity) GenerationMode(io.vertigo.database.sql.vendor.SqlDialect.GenerationMode) Tuples(io.vertigo.lang.Tuples) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 18 with DtField

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);
}
Also used : SmartItem(io.vertigo.dynamo.collections.data.domain.SmartItem) DtField(io.vertigo.dynamo.domain.metamodel.DtField) Test(org.junit.Test)

Example 19 with DtField

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);
}
Also used : SmartItem(io.vertigo.dynamo.collections.data.domain.SmartItem) DtField(io.vertigo.dynamo.domain.metamodel.DtField) Test(org.junit.Test)

Example 20 with DtField

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);
}
Also used : JsonObject(com.google.gson.JsonObject) RuleMultiExpression(io.vertigo.account.authorization.metamodel.rulemodel.RuleMultiExpression) DtField(io.vertigo.dynamo.domain.metamodel.DtField) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JsonDeserializationContext(com.google.gson.JsonDeserializationContext) JsonElement(com.google.gson.JsonElement) Home(io.vertigo.app.Home) WrappedException(io.vertigo.lang.WrappedException) Map(java.util.Map) Assertion(io.vertigo.lang.Assertion) SecuredEntity(io.vertigo.account.authorization.metamodel.SecuredEntity) SecurityDimensionType(io.vertigo.account.authorization.metamodel.SecurityDimensionType) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) Set(java.util.Set) DslParserUtil(io.vertigo.account.impl.authorization.dsl.rules.DslParserUtil) Collectors(java.util.stream.Collectors) Definition(io.vertigo.core.definition.Definition) List(java.util.List) DefinitionUtil(io.vertigo.core.definition.DefinitionUtil) Type(java.lang.reflect.Type) StringUtil(io.vertigo.util.StringUtil) JsonDeserializer(com.google.gson.JsonDeserializer) Optional(java.util.Optional) Authorization(io.vertigo.account.authorization.metamodel.Authorization) PegNoMatchFoundException(io.vertigo.commons.peg.PegNoMatchFoundException) Collections(java.util.Collections) SecurityDimension(io.vertigo.account.authorization.metamodel.SecurityDimension) SecurityDimension(io.vertigo.account.authorization.metamodel.SecurityDimension) SecurityDimensionType(io.vertigo.account.authorization.metamodel.SecurityDimensionType) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Aggregations

DtField (io.vertigo.dynamo.domain.metamodel.DtField)77 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)28 DtObject (io.vertigo.dynamo.domain.model.DtObject)14 DtList (io.vertigo.dynamo.domain.model.DtList)13 URI (io.vertigo.dynamo.domain.model.URI)12 HashMap (java.util.HashMap)11 Map (java.util.Map)8 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)7 Task (io.vertigo.dynamo.task.model.Task)7 ArrayList (java.util.ArrayList)7 Entity (io.vertigo.dynamo.domain.model.Entity)6 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)6 Serializable (java.io.Serializable)6 LinkedHashMap (java.util.LinkedHashMap)6 List (java.util.List)6 MessageText (io.vertigo.core.locale.MessageText)5 FacetValue (io.vertigo.dynamo.collections.model.FacetValue)5 Date (java.util.Date)4 SearchHit (org.elasticsearch.search.SearchHit)4 JsonObject (com.google.gson.JsonObject)3