use of io.jmix.core.entity.annotation.EmbeddedParameters in project jmix by jmix-framework.
the class EmbeddedAttributesMappingProcessor method process.
@Override
public void process(MappingProcessorContext context) {
DatabaseMapping mapping = context.getMapping();
if (mapping instanceof AggregateObjectMapping) {
MetaClass metaClass = metadata.getClass(mapping.getDescriptor().getJavaClass());
MetaProperty metaProperty = metaClass.getProperty(mapping.getAttributeName());
EmbeddedParameters embeddedParameters = metaProperty.getAnnotatedElement().getAnnotation(EmbeddedParameters.class);
if (embeddedParameters != null && !embeddedParameters.nullAllowed()) {
((AggregateObjectMapping) mapping).setIsNullAllowed(false);
}
}
}
use of io.jmix.core.entity.annotation.EmbeddedParameters in project jmix by jmix-framework.
the class EntityEmbeddedInitializer method initEntity.
@Override
public void initEntity(Object entity) {
MetaClass metaClass = metadata.getClass(entity.getClass());
for (MetaProperty property : metaClass.getProperties()) {
if (property.getRange().isClass() && metadataTools.isEmbedded(property)) {
EmbeddedParameters embeddedParameters = property.getAnnotatedElement().getAnnotation(EmbeddedParameters.class);
if (embeddedParameters != null && !embeddedParameters.nullAllowed()) {
MetaClass embeddableMetaClass = property.getRange().asClass();
Object embeddableEntity = metadata.create(embeddableMetaClass);
EntityValues.setValue(entity, property.getName(), embeddableEntity);
}
}
}
}
Aggregations