Skip to content
stemey edited this page Feb 2, 2013 · 10 revisions

In Atem you can add meta data of any type to entities. Typically you attach transient objects at startup time to attributes or types. But it is also possible to attach meta data stored in a fileor a db to attributes or types. in fact you can attach meta data to any objects - not just attributes and types. Of course java annotations are also supported. All meta data is accessible via meta attributes on the target's type. These meta attributes need to be defined first before any meta data can be read and written.

To add meta data to an object you first add a meta attribute to the object's type.

// the elements that can be annotated are attributes
EntityType<Attribute> annotatedType = entityTypeRepository.getEntityType(Attribute.class);
// The meta data should be instances of AttributeDescription
EntityType<AttributeDescription> metaDataType = entityTypeRepository.getEntityType(AttributeDescription.class);
// add the meta attribute by using a specific metaAttributeService
metaAttributeService.addMetaAttribute("description",annotatedType,metaDataType);

Now we can retrieve the attribute without using the metaAttributeService

// the elements that can be annotated are attributes
EntityType<Attribute> annotatedType = entityTypeRepository.getEntityType(Attribute.class);
SingleAttribute<AttributeDescription> descriptionMetaAttribute=annotatedType.getMetaAttribute("description");

Now we add metadata to a concrete attribute:

Attribute nameAttribute = etityTypeRepository.getEntityType(Person.class).getAttribute("firstname");
descriptionMetaAttribute.setValue(nameAttribute,new AttriuteDescription("the name attribute"));

Noew we read metadata on a concrete attribute:

AttributeDescription description=descriptionMetaAttribute.getValue(nameAttribute);

The MetaAttributeService defines how the meta data is persisted. The basic implemnetation stores the meta data in memory.

Implementations

  • Annotations
    Annotations can be read as metaAttributes. See here
  • Javadoc
    Javadoc information can be read as meta attribute. See here
  • Custom
    To define new meta attributes see here

Clone this wiki locally