Search in sources :

Example 61 with DtField

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

the class RamLuceneQueryFactory method createKeywordQuery.

private static Query createKeywordQuery(final Analyzer queryAnalyser, final String keywords, final Collection<DtField> searchedFieldList, final Optional<DtField> boostedField) throws IOException {
    if (StringUtil.isEmpty(keywords)) {
        return new MatchAllDocsQuery();
    }
    // -----
    final Builder queryBuilder = new BooleanQuery.Builder();
    for (final DtField dtField : searchedFieldList) {
        Query queryWord = createParsedKeywordsQuery(queryAnalyser, dtField.getName(), keywords);
        if (boostedField.isPresent() && dtField.equals(boostedField.get())) {
            queryWord = new BoostQuery(queryWord, 4);
        }
        queryBuilder.add(queryWord, BooleanClause.Occur.SHOULD);
    }
    return queryBuilder.build();
}
Also used : Query(org.apache.lucene.search.Query) SpanFirstQuery(org.apache.lucene.search.spans.SpanFirstQuery) PrefixQuery(org.apache.lucene.search.PrefixQuery) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) BooleanQuery(org.apache.lucene.search.BooleanQuery) BoostQuery(org.apache.lucene.search.BoostQuery) Builder(org.apache.lucene.search.BooleanQuery.Builder) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) BoostQuery(org.apache.lucene.search.BoostQuery) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 62 with DtField

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

the class SearchDynamicRegistry method createIndexDefinition.

private static SearchIndexDefinition createIndexDefinition(final DefinitionSpace definitionSpace, final DslDefinition xsearchObjet) {
    final DtDefinition keyConceptDtDefinition = definitionSpace.resolve(xsearchObjet.getDefinitionLinkName("keyConcept"), DtDefinition.class);
    final DtDefinition indexDtDefinition = definitionSpace.resolve(xsearchObjet.getDefinitionLinkName("dtIndex"), DtDefinition.class);
    final String definitionName = xsearchObjet.getName();
    // Déclaration des copyField
    final Map<DtField, List<DtField>> copyFields = populateCopyFields(xsearchObjet, indexDtDefinition);
    final String searchLoaderId = (String) xsearchObjet.getPropertyValue(SearchGrammar.SEARCH_LOADER_PROPERTY);
    return new SearchIndexDefinition(definitionName, keyConceptDtDefinition, indexDtDefinition, copyFields, searchLoaderId);
}
Also used : SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) ArrayList(java.util.ArrayList) List(java.util.List) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 63 with DtField

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

the class SearchDynamicRegistry method createFacetDefinition.

private static FacetDefinition createFacetDefinition(final DefinitionSpace definitionSpace, final DslDefinition xdefinition) {
    final String definitionName = xdefinition.getName();
    final DtDefinition indexDtDefinition = definitionSpace.resolve(xdefinition.getDefinitionLinkName("dtDefinition"), DtDefinition.class);
    final String dtFieldName = (String) xdefinition.getPropertyValue(SearchGrammar.FIELD_NAME);
    final DtField dtField = indexDtDefinition.getField(dtFieldName);
    final String label = (String) xdefinition.getPropertyValue(KspProperty.LABEL);
    // Déclaration des ranges
    final List<DslDefinition> rangeDefinitions = xdefinition.getChildDefinitions("range");
    final MessageText labelMsg = MessageText.of(label);
    final FacetDefinition facetDefinition;
    if (rangeDefinitions.isEmpty()) {
        facetDefinition = FacetDefinition.createFacetDefinitionByTerm(definitionName, dtField, labelMsg, isMultiSelectable(xdefinition, false), getFacetOrder(xdefinition, FacetOrder.count));
    } else {
        final List<FacetValue> facetValues = rangeDefinitions.stream().map(SearchDynamicRegistry::createFacetValue).collect(Collectors.toList());
        facetDefinition = FacetDefinition.createFacetDefinitionByRange(definitionName, dtField, labelMsg, facetValues, isMultiSelectable(xdefinition, false), getFacetOrder(xdefinition, FacetOrder.definition));
    }
    return facetDefinition;
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) FacetValue(io.vertigo.dynamo.collections.model.FacetValue) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) MessageText(io.vertigo.core.locale.MessageText) FacetDefinition(io.vertigo.dynamo.collections.metamodel.FacetDefinition) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 64 with DtField

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

the class BrokerBatchImpl method getListByField.

/**
 * {@inheritDoc}
 */
@Override
public <O> DtList<E> getListByField(final DtDefinition dtDefinition, final String fieldName, final Collection<O> value) {
    Assertion.checkNotNull(dtDefinition);
    Assertion.checkNotNull(fieldName);
    // -----
    Assertion.checkNotNull(value);
    final DtList<E> dtc = new DtList<>(dtDefinition);
    // On regarde s'il y a quelquechose à faire
    if (value.isEmpty()) {
        // Rien à faire
        return dtc;
    }
    // On génère une DTC d'identifiant
    final DtField field = dtDefinition.getField(fieldName);
    for (final O sel : value) {
        Assertion.checkNotNull(sel);
        final E entity = (E) DtObjectUtil.createDtObject(dtDefinition);
        field.getDataAccessor().setValue(entity, sel);
        dtc.add(entity);
    }
    return getList(dtDefinition, field.getName(), dtc);
}
Also used : DtList(io.vertigo.dynamo.domain.model.DtList) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 65 with DtField

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

the class DAO method getFragment.

/**
 * Récupération d'un fragment persistant par son URI. L'objet doit exister.
 *
 * @param uri URI de l'objet à récupérer
 * @param fragmentClass Fragment class
 * @return F Fragment recherché
 */
public final <F extends Fragment<E>> F getFragment(final URI<E> uri, final Class<F> fragmentClass) {
    final E dto = dataStore.readOne(uri);
    final DtDefinition fragmentDefinition = DtObjectUtil.findDtDefinition(fragmentClass);
    final F fragment = fragmentClass.cast(DtObjectUtil.createDtObject(fragmentDefinition));
    for (final DtField dtField : fragmentDefinition.getFields()) {
        final DataAccessor dataAccessor = dtField.getDataAccessor();
        dataAccessor.setValue(fragment, dataAccessor.getValue(dto));
    // etrange on utilise l'accessor du fragment sur l'entity
    }
    return fragment;
}
Also used : DataAccessor(io.vertigo.dynamo.domain.metamodel.DataAccessor) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) 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