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();
}
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);
}
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;
}
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);
}
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;
}
Aggregations