Search in sources :

Example 31 with DtObject

use of io.vertigo.dynamo.domain.model.DtObject 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 32 with DtObject

use of io.vertigo.dynamo.domain.model.DtObject in project vertigo by KleeGroup.

the class UiErrorBuilder method checkFieldEquals.

/**
 * Vérifie l'égalité des champs.
 * @param dto Object a tester
 * @param fieldName1 Champs 1
 * @param fieldName2 Champs 2
 * @param messageText Message à appliquer si erreur
 */
public void checkFieldEquals(final DtObject dto, final String fieldName1, final String fieldName2, final MessageText messageText) {
    final DtField dtField1 = getDtField(dto, fieldName1);
    final DtField dtField2 = getDtField(dto, fieldName2);
    final Object value1 = getValue(dto, dtField1);
    final Object value2 = getValue(dto, dtField2);
    // value1 et value2 == null ou value1 equals value2, sinon error
    if ((value1 != null && !value1.equals(value2)) || value2 != null) {
        addError(dto, dtField2, messageText);
    }
}
Also used : DtObject(io.vertigo.dynamo.domain.model.DtObject) DtField(io.vertigo.dynamo.domain.metamodel.DtField)

Aggregations

DtObject (io.vertigo.dynamo.domain.model.DtObject)32 DtField (io.vertigo.dynamo.domain.metamodel.DtField)14 Entity (io.vertigo.dynamo.domain.model.Entity)9 URI (io.vertigo.dynamo.domain.model.URI)8 Type (java.lang.reflect.Type)8 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)5 DtList (io.vertigo.dynamo.domain.model.DtList)5 ParameterizedType (java.lang.reflect.ParameterizedType)5 VFile (io.vertigo.dynamo.file.model.VFile)4 UiContext (io.vertigo.vega.engines.webservice.json.UiContext)4 UiListDelta (io.vertigo.vega.engines.webservice.json.UiListDelta)4 FileInfoURI (io.vertigo.dynamo.domain.model.FileInfoURI)3 Instant (java.time.Instant)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Optional (java.util.Optional)3 JsonObject (com.google.gson.JsonObject)2 CollectionsManager (io.vertigo.dynamo.collections.CollectionsManager)2