Search in sources :

Example 91 with DtDefinition

use of io.vertigo.dynamo.domain.metamodel.DtDefinition 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)

Aggregations

DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)91 DtField (io.vertigo.dynamo.domain.metamodel.DtField)29 Test (org.junit.Test)21 URI (io.vertigo.dynamo.domain.model.URI)18 List (java.util.List)17 ArrayList (java.util.ArrayList)16 Assertion (io.vertigo.lang.Assertion)12 Collectors (java.util.stream.Collectors)11 Home (io.vertigo.app.Home)10 Optional (java.util.Optional)10 Domain (io.vertigo.dynamo.domain.metamodel.Domain)9 Collections (java.util.Collections)8 DefinitionUtil (io.vertigo.core.definition.DefinitionUtil)7 DtObjectUtil (io.vertigo.dynamo.domain.util.DtObjectUtil)7 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)7 Inject (javax.inject.Inject)7 Authorization (io.vertigo.account.authorization.metamodel.Authorization)6 SecuredEntity (io.vertigo.account.authorization.metamodel.SecuredEntity)6 Criterions (io.vertigo.dynamo.criteria.Criterions)6 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)5