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