Search in sources :

Example 71 with DtField

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

the class VegaUiObject method setInputValue.

/**
 * {@inheritDoc}
 */
@Override
public void setInputValue(final String fieldName, final String stringValue) {
    Assertion.checkArgNotEmpty(fieldName);
    Assertion.checkNotNull(stringValue, "formatted value can't be null, but may be empty : {0}", fieldName);
    // -----
    final DtField dtField = getDtField(fieldName);
    inputBuffer.put(fieldName, formatValue(dtField, stringValue));
}
Also used : DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 72 with DtField

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

the class VegaUiObject method setTypedValue.

@Override
public final void setTypedValue(final String fieldName, final Serializable value) {
    final DtField dtField = getDtField(fieldName);
    isChecked = false;
    // on a trois choix :
    // 1) soit on ne fait pas de controle ici (sera fait par le check plus tard)
    // 2) soit on fait un check et on remplit la stack d'erreur
    // 3) soit on check et on lance une Runtime si erreur (comme dans DtObject)
    // 100924 NPI : choix retenu 1
    doSetTypedValue(dtField, value);
    inputBuffer.put(fieldName, getInputValue(fieldName));
}
Also used : DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 73 with DtField

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

the class FacetedQueryResultJsonSerializerV4 method serializeHighLight.

private static JsonArray serializeHighLight(final DtList<?> dtList, final FacetedQueryResult<DtObject, ?> facetedQueryResult) {
    final JsonArray jsonHighlightList = new JsonArray();
    final Map<DtField, String> ccFieldNames = new HashMap<>();
    for (final DtObject document : dtList) {
        final Map<DtField, String> highlights = (facetedQueryResult).getHighlights(document);
        final JsonObject jsonHighlight = new JsonObject();
        for (final Map.Entry<DtField, String> entry : highlights.entrySet()) {
            final String ccFieldName = obtainCcFieldName(entry.getKey(), ccFieldNames);
            jsonHighlight.addProperty(ccFieldName, entry.getValue());
        }
        jsonHighlightList.add(jsonHighlight);
    }
    return jsonHighlightList;
}
Also used : JsonArray(com.google.gson.JsonArray) HashMap(java.util.HashMap) DtObject(io.vertigo.dynamo.domain.model.DtObject) JsonObject(com.google.gson.JsonObject) HashMap(java.util.HashMap) Map(java.util.Map) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 74 with DtField

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

the class SwaggerApiBuilder method appendPropertiesDtObject.

private void appendPropertiesDtObject(final Map<String, Object> entity, final Class<? extends DtObject> objectClass) {
    // can't be a primitive nor array nor DtListDelta
    final Map<String, Object> properties = new LinkedHashMap<>();
    // mandatory fields
    final List<String> required = new ArrayList<>();
    final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(objectClass);
    for (final DtField dtField : dtDefinition.getFields()) {
        final String fieldName = StringUtil.constToLowerCamelCase(dtField.getName());
        final Type fieldType = getFieldType(dtField);
        // not Nullable
        final Map<String, Object> fieldSchema = createSchemaObject(fieldType);
        fieldSchema.put("title", dtField.getLabel().getDisplay());
        if (dtField.isRequired()) {
            required.add(fieldName);
        }
        // could add enum on field to specify all values authorized
        properties.put(fieldName, fieldSchema);
    }
    putIfNotEmpty(entity, REQUIRED, required);
    putIfNotEmpty(entity, "properties", properties);
}
Also used : WildcardType(java.lang.reflect.WildcardType) WebServiceParamType(io.vertigo.vega.webservice.metamodel.WebServiceParam.WebServiceParamType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ArrayList(java.util.ArrayList) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) DtObject(io.vertigo.dynamo.domain.model.DtObject) LinkedHashMap(java.util.LinkedHashMap) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Example 75 with DtField

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

the class UiErrorBuilder method checkFieldDateAfter.

/**
 * Vérifie que la date du champ 2 est après (strictement) la date du champ 1.
 * @param dto Object a tester
 * @param fieldName1 Champs 1
 * @param fieldName2 Champs 2
 * @param messageText Message à appliquer si erreur
 */
public void checkFieldDateAfter(final DtObject dto, final String fieldName1, final String fieldName2, final MessageText messageText) {
    final DtField dtField1 = getDtField(dto, fieldName1);
    final DtField dtField2 = getDtField(dto, fieldName2);
    // la valeur typée peut être null
    final Date value1 = (Date) getValue(dto, dtField1);
    final Date value2 = (Date) getValue(dto, dtField2);
    if (value1 != null && value2 != null && !value2.after(value1)) {
        addError(dto, dtField2, messageText);
    }
}
Also used : Date(java.util.Date) 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