Search in sources :

Example 11 with DtField

use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.

the class AbstractDbFileStorePlugin method getValue.

/**
 * Retourne une valeur d'un champ à partir du DtObject.
 * @param <V> Type de la valeur	 *
 * @param dto DtObject
 * @param fieldName Nom du champ
 * @param valueClass Type du champ
 * @return Valeur typé du champ
 */
protected static <V> V getValue(final DtObject dto, final DtFieldName fieldName, final Class<V> valueClass) {
    final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(dto);
    final DtField dtField = dtDefinition.getField(fieldName.name());
    return valueClass.cast(dtField.getDataAccessor().getValue(dto));
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 12 with DtField

use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.

the class AbstractDbFileStorePlugin method setValue.

/**
 * Fixe une valeur d'un champ d'un DtObject.
 *
 * @param dto DtObject
 * @param fieldName Nom du champs
 * @param value Valeur
 */
protected static void setValue(final DtObject dto, final DtFieldName fieldName, final Object value) {
    final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(dto);
    final DtField dtField = dtDefinition.getField(fieldName.name());
    dtField.getDataAccessor().setValue(dto, value);
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 13 with DtField

use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.

the class FsFileStorePlugin method getValue.

/**
 * Retourne une valeur d'un champ à partir du DtObject.
 *
 * @param dto DtObject
 * @param field Nom du champs
 * @return Valeur typé du champ
 */
private static <V> V getValue(final DtObject dto, final DtoFields field, final Class<V> valueClass) {
    final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(dto);
    final DtField dtField = dtDefinition.getField(field.name());
    return valueClass.cast(dtField.getDataAccessor().getValue(dto));
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 14 with DtField

use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.

the class FsFileStorePlugin method setIdValue.

private static void setIdValue(final DtObject dto, final Object value) {
    final DtField dtField = DtObjectUtil.findDtDefinition(dto).getIdField().get();
    dtField.getDataAccessor().setValue(dto, value);
}
Also used : DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 15 with DtField

use of io.vertigo.dynamo.domain.metamodel.DtField in project vertigo by KleeGroup.

the class ESFacetedQueryResultBuilder method build.

/**
 * {@inheritDoc}
 */
@Override
public FacetedQueryResult<I, SearchQuery> build() {
    final Map<I, Map<DtField, String>> resultHighlights = new HashMap<>();
    final Map<FacetValue, DtList<I>> resultCluster;
    final DtList<I> dtc = new DtList<>(indexDefinition.getIndexDtDefinition());
    if (searchQuery.isClusteringFacet()) {
        final Map<String, I> dtcIndex = new LinkedHashMap<>();
        resultCluster = createCluster(dtcIndex, resultHighlights);
        dtc.addAll(dtcIndex.values());
    } else {
        for (final SearchHit searchHit : queryResponse.getHits()) {
            final SearchIndex<?, I> index = esDocumentCodec.searchHit2Index(indexDefinition, searchHit);
            final I result = index.getIndexDtObject();
            dtc.add(result);
            final Map<DtField, String> highlights = createHighlight(searchHit, indexDefinition.getIndexDtDefinition());
            resultHighlights.put(result, highlights);
        }
        resultCluster = Collections.emptyMap();
    }
    // On fabrique à la volée le résultat.
    final List<Facet> facets = createFacetList(searchQuery, queryResponse);
    final long count = queryResponse.getHits().getTotalHits();
    return new FacetedQueryResult<>(searchQuery.getFacetedQuery(), count, dtc, facets, searchQuery.isClusteringFacet() ? Optional.of(searchQuery.getClusteringFacetDefinition()) : Optional.empty(), resultCluster, resultHighlights, searchQuery);
}
Also used : SearchHit(org.elasticsearch.search.SearchHit) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FacetedQueryResult(io.vertigo.dynamo.collections.model.FacetedQueryResult) LinkedHashMap(java.util.LinkedHashMap) DtField(io.vertigo.dynamo.domain.metamodel.DtField) FacetValue(io.vertigo.dynamo.collections.model.FacetValue) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) DtList(io.vertigo.dynamo.domain.model.DtList) Facet(io.vertigo.dynamo.collections.model.Facet)

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