Add new entity property (feature attribute)
Level: Beginner
Keywords: add entity property, add feature attribute
The result: new feature attribute is visible in the application (entities browse, entity detail, etc.)
To add new entity property (= feature attribute), it is necessary to:
- Add attribute to LIDS model
- Create column in database
- Show new property in application
Add attribute to LIDS model​
Every object that is stored in SAMO application is defined in LIDS model. Each feature (entity) has own set of attributes (properties). To add new attribute to certain feature, define new attribute tag in featureAttributeArray of this feature.
ID of featureType to be edited can be found in teh application URL when viewing detail of entity - check URL part detail=ft_example
<ber:featureType id="ft_example" name="Example featuretype" parentId="ft_5000002" abstract="false">
<ber:featureAttributeArray>
<ber:attribute dbName="NEWATTRIBUTE" id="newAttribute" name="New attribute label" nillable="false">
<ber:description>Text description of new attributes</ber:description>
<ber:dataType>
<ber:string maxLength="200"/>
</ber:dataType>
</ber:attribute>
</ber:featureAttributeArray>
</ber:featureType>
Detail and all configuration options can be found in LIDS Implementation Guide - attributes.
Create column in database​
Once a new attribute is defined, it is necessary to synchronize model and database (create new column in database table where the data could be stored). SQL query should be prepared by Database Synchronization in LIDS Administration Console
Steps to perform in LAS console:
- Project:
- RESTART PROJECT without flag
Validate metadata(to loadmodel.xmlchanges) - RESTART PROJECT with flag
Validate metadata(to check if there is no mistake in model)
- RESTART PROJECT without flag
- Database / LIDS DS:
- CREATE/UPDATE CHANGE LIST with flag
Modified containers - Tick checkboxex
Missing column NEWATTRIBUTE in the table CT_EXAMPLE,Missing column NEWATTRIBUTE in the table CT_EXAMPLE_H,Different subquery for the view CT_EXAMPLE_A, will create SQL query such asALTER TABLE CT_BOFNNDATA ADD NEWATTRIBUTE VARCHAR2(200 CHAR); - Either directly APPLY CHANGES IN DB or CREATE SQL FILE and apply this manually or via script (to be executed later on test and producion environments) to database
- CREATE/UPDATE CHANGE LIST with flag
- Project / SET PRIVILEGED MODE
- Database / Security DS / SYNCHRONIZE SECURITY in order to give users permissions to see attribute content in the application.
- Project / RELEASE PRIVILEGED MODE
- SAMO search extension / Index Features / find ft_example and INDEX SELECTED TYPES
Whole process is described with details in New LIDS Feature Type
Show new property in application​
Once a new attribute is defined and can be saved in database, it is necessary to show it in SAMO application. Which entity properties (feature attributes) will be shown can be defined either using LIDS forms or by SAMO property groups. Configuration details can be found in Entity property groups.
Property groups are further used in SAMO Browse (defaultPropertyGroup configuration parameter) and details (defaultDetailPropertyGroup configuration parameter). These parameters are configured in entity metadata.
{
"extends" : "parentFeature",
"defaultPropertyGroup": "pgEntityBrowse",
"defaultDetailPropertyGroup": "frmEntityDetail"
}
Add entity property to LIDS form​
Add one field line with new attribute to form in formArray in featureType. It is necessary to RESTART PROJECT via LIDS console after modifying form.
<ber:featureType id="ft_example" name="Example featuretype" parentId="ft_5000002" abstract="false">
<ber:featureAttributeArray>
...
</ber:featureAttributeArray>
<ber:formArray>
<ber:form id="frmEntityDetail" name="entity detail and edit">
<ber:field refId="existingAttribute1" readOnly="false"/>
<ber:field refId="existingAttribute2" readOnly="false"/>
<ber:field refId="newAttribute" readOnly="false"/>
</ber:form>
</ber:formArray>
</ber:featureType>
Add entity property to SAMO property group​
Add one property (just id of the attribute) to the property group definition.
{
"properties": [
"existingAttribute1",
"existingAttribute2",
"newAttribute"
]
}
Hide property for particular cases​
Even if there are many attributes defined to be shown by using LIDS form or property group, it is possible to hide individual attributes for particular cases (independently if form or property groups are used).
{
"extends" : "parentFeature",
"defaultPropertyGroup": "pgEntityBrowse",
"defaultDetailPropertyGroup": "frmEntityDetail",
"detail": {
"default": {
"sections": [
{
"module": {
"type": "component:entity-modules/detail/samo-entity-properties-detail",
"hideProperties": [
"newAttribute"
]
}
}
]
}
},
"edit": {
"default": {
"sections": [
{
"module": {
"type": "component:entity-modules/form/samo-entity-properties-form",
"entityType": "ft_example",
"overrideProperties": {
"newAttribute": {
"hidden": true
}
}
}
}
]
}
}
}