use of io.jmix.graphql.schema.messages.MessageDetail in project jmix by jmix-framework.
the class MessagesDataFetcher method getEntityMessages.
protected List<MessageDetail> getEntityMessages(MetaClass metaClass, Locale locale) {
List<MessageDetail> messages = new ArrayList<>();
CrudEntityContext entityContext = new CrudEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
String metaClassName = metaClass.getName();
if (entityContext.isReadPermitted()) {
String entityCaption = messageTools.getEntityCaption(metaClass, locale);
messages.add(new MessageDetail(metaClassName, entityCaption));
}
for (MetaProperty metaProperty : metaClass.getProperties()) {
EntityAttributeContext attributeContext = new EntityAttributeContext(metaClass, metaProperty.getName());
accessManager.applyRegisteredConstraints(attributeContext);
if (attributeContext.canView()) {
String propertyCaption = messageTools.getPropertyCaption(metaProperty, locale);
messages.add(new MessageDetail(metaClassName + "." + metaProperty.getName(), propertyCaption));
}
}
return messages;
}
use of io.jmix.graphql.schema.messages.MessageDetail in project jmix by jmix-framework.
the class MessagesDataFetcher method getEnumMessages.
protected List<MessageDetail> getEnumMessages(Class<?> enumClass, Locale locale) {
List<MessageDetail> enumMessages = new ArrayList<>();
String classCaption;
if (locale == null) {
classCaption = messages.getMessage(enumClass, enumClass.getSimpleName());
} else {
classCaption = messages.getMessage(enumClass, enumClass.getSimpleName(), locale);
}
enumMessages.add(new MessageDetail(enumClass.getName(), classCaption));
Object[] enumConstants = enumClass.getEnumConstants();
for (Object enumConstant : enumConstants) {
Enum<?> enumValue = (Enum<?>) enumConstant;
String msgKey = enumClass.getName() + "." + enumValue.name();
String msgValue;
if (locale == null) {
msgValue = messages.getMessage(enumValue);
} else {
msgValue = messages.getMessage(enumValue, locale);
}
enumMessages.add(new MessageDetail(msgKey, msgValue));
}
return enumMessages;
}
Aggregations