Hi,
i have an idea about a feature that i think of might be valuable for different people, so i’d like to share the idea in order to get some feedback if this is a general problem. Lately i saw [PL-8123] and i was thinking about the possibility to store these informations (or annotations on per entity or entityattribute level) in the database and additionally allow CUBA app devs to extend the meta information to their needs
(not only through the Annotations, but through the DB as well).
So when looking at the application properties browser and the mechanism you choosed to either define it in the code (with the config interface and their default values), in app.properties or in the database allows a very high level of flexibility for the app devs to decide where to put the information based upon the desired people that should be able to change it e.g.
With the metadata on the attributes it is actually the same thing. Sometimes it is appropriate to annotate the attributes in the code. But sometimes it is something that should be up to the user (or the administrator) to decide. Here are a couple of examples of that:
- Default values for entity attributes (this might either be a normal string value, or a reference to a N:1 assication)
- required attributes for entity attributes (no in the DB but only in the app itself - like it is implemented in the dynamic attributes feature)
But it doesn’t need to be only UI related. Another example would be that in case some entities get imported from other systems, it could be that some attributes should be excluded e.g. So there are plenty of information about an attribute of an entity where it makes sense to not hardcode it into the application code.
I created a sample application that will do the very basic implementation to show the idea.
The definition of a entity metainformation is done through the EntityMetainformation entity. In the customer editor it is used directly by going to the DB and fetching the corresponding value for the desired entity attribute.
I thought of the a real implementation of fetching the config by using the same mechanism as in the Config interface with the additional feature of passing parameters into the interface method:
@Source(type = SourceType.DB)
public interface EntityDefaultValueConfig extends EntityConfig {
@Property("entity.defaultValue")
Object getDefaultValue(MetaClass metaClass, MetaProperty metaProperty);
}
Actually, in the platform features there are already some examples where this would be a fit (like the entity logging config e.g.) This mechanism would not only be suitable for Entities and there attributes, but there are some other dimensions as well. One would probably be by screens (& their components).
As i understood the LookupType Annotation is the first step towards a more sophisticated entity meta model and so in this mindset this approach can be seen as well.
What do you think?
Bye
Mario