use of io.vertigo.core.locale.MessageText in project vertigo by KleeGroup.
the class DtDefinitionBuilder method createField.
private DtField createField(final String fieldName, final DtField.FieldType type, final Domain domain, final String strLabel, final boolean required, final boolean persistent, final String fkDtDefinitionName, final ComputedExpression computedExpression) {
final String shortName = DefinitionUtil.getLocalName(myName, DtDefinition.class);
// -----
// Le DtField vérifie ses propres règles et gère ses propres optimisations
final String id = DtField.PREFIX + shortName + '$' + fieldName;
// 2. Sinon Indication de longueur portée par le champ du DT.
// -----
final MessageText labelMsg = MessageText.builder().withKey(new MessageKeyImpl(id)).withDefaultMsg(strLabel).build();
// Un champ est persisanty s'il est marqué comme tel et si la définition l'est aussi.
return new DtField(id, fieldName, type, domain, labelMsg, required, persistent, fkDtDefinitionName, computedExpression);
}
use of io.vertigo.core.locale.MessageText in project vertigo by KleeGroup.
the class ESFacetedQueryResultBuilder method createCluster.
private Map<FacetValue, DtList<I>> createCluster(final Map<String, I> dtcIndex, final Map<I, Map<DtField, String>> resultHighlights) {
final Map<FacetValue, DtList<I>> resultCluster = new LinkedHashMap<>();
final FacetDefinition facetDefinition = searchQuery.getClusteringFacetDefinition();
final Aggregation facetAggregation = queryResponse.getAggregations().get(facetDefinition.getName());
if (facetDefinition.isRangeFacet()) {
// Cas des facettes par 'range'
final MultiBucketsAggregation multiBuckets = (MultiBucketsAggregation) facetAggregation;
for (final FacetValue facetRange : facetDefinition.getFacetRanges()) {
final Bucket value = getBucketByKey(multiBuckets, facetRange.getListFilter().getFilterValue());
populateCluster(value, facetRange, resultCluster, dtcIndex, resultHighlights);
}
} else {
// Cas des facettes par 'term'
final MultiBucketsAggregation multiBuckets = (MultiBucketsAggregation) facetAggregation;
FacetValue facetValue;
for (final Bucket bucket : multiBuckets.getBuckets()) {
final String term = bucket.getKeyAsString();
final String query = facetDefinition.getDtField().getName() + ":\"" + term + "\"";
final MessageText label = MessageText.of(term);
facetValue = new FacetValue(term, ListFilter.of(query), label);
populateCluster(bucket, facetValue, resultCluster, dtcIndex, resultHighlights);
}
}
return resultCluster;
}
use of io.vertigo.core.locale.MessageText in project vertigo by KleeGroup.
the class AbstractSqlExceptionHandler method handleConstraintSQLException.
/**
* Traite l'exception lié à la contrainte d'intégrité.
* Et lance une KUserException avec le message par défaut passé en paramètre et une MessageKey basé sur le nom de la contrainte.
* @param sqle Exception SQL
* @param defaultMsg Message par defaut
*/
protected final VUserException handleConstraintSQLException(final SQLException sqle, final MessageKey defaultMsg) {
final String msg = sqle.getMessage();
// recherche le nom de la contrainte d'intégrité
final String constraintName = extractConstraintName(msg);
Assertion.checkNotNull(constraintName, "Impossible d''extraire le nom de la contrainte : {0}", msg);
// recherche le message pour l'utilisateur
// On crée une clé de MessageText dynamiquement sur le nom de la contrainte d'intégrité
// Ex: CK_PERSON_FULL_NAME_UNIQUE
final MessageKey constraintKey = new SQLConstraintMessageKey(constraintName);
// On récupère ici le message externalisé par défaut : Resources.DYNAMO_SQL_CONSTRAINT_IMPOSSIBLE_TO_DELETE ou Resources.DYNAMO_SQL_CONSTRAINT_ALREADY_REGISTRED)
final String defaultConstraintMsg = MessageText.of(defaultMsg).getDisplay();
final MessageText userContraintMessageText = MessageText.builder().withKey(constraintKey).withDefaultMsg(defaultConstraintMsg).build();
final VUserException constraintException = new VUserException(userContraintMessageText);
constraintException.initCause(sqle);
return constraintException;
}
use of io.vertigo.core.locale.MessageText 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.core.locale.MessageText in project vertigo by KleeGroup.
the class SearchDynamicRegistry method createFacetValue.
private static FacetValue createFacetValue(final DslDefinition rangeDefinition) {
final String listFilterString = (String) rangeDefinition.getPropertyValue(SearchGrammar.RANGE_FILTER_PROPERTY);
final ListFilter listFilter = ListFilter.of(listFilterString);
final String label = (String) rangeDefinition.getPropertyValue(KspProperty.LABEL);
final MessageText labelMsg = MessageText.of(label);
final String code = rangeDefinition.getName();
return new FacetValue(code, listFilter, labelMsg);
}
Aggregations