Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
devel:documentation:application_configuration:dev:dynamic-forms [2019/02/01 10:47]
tomiskar
devel:documentation:application_configuration:dev:dynamic-forms [2019/07/25 12:41]
tomiskar
Line 1: Line 1:
 ====== Dynamic forms (eav) ====== ====== Dynamic forms (eav) ======
  
-{{tag> configuration eav form}} +{{tag> configuration eav form attachment}}
- +
-Dynamic forms are used for: +
-  * extending standard entity attributes with custom, project specific attributes, +
-  * dynamic configurations - e.g. system connector configurations. +
- +
-Dynamic forms are supported for selected entities: +
-  * ''SysSystem'' - linked to the systems  +
-  * ''IdmIdentity'' - identities +
-  * ''IdmIdentityRole'' - assigned roles to identities (respectively assigned to identity contracts) +
-  * ''IdmIdentityContract'' - Contractual relationships +
-  * ''IdmRole'' - roles +
-  * ''IdmTreeNode'' - tree structure items. +
-  * ''IdmForm'' - [[#common_forms|common forms]] +
-  * ''VsAccountFormValue'' - virtual system attributes+
  
 Dynamic form instances (values) are saved in the individual tables according to the entity which they are linked to => which is their owner (e.g. the entity ''IdmIdentityFormValue'', ''IdmRoleFormValue''). Form values are not saved, if ''null'' value (by persistent type) is given => filled values are saved only. Dynamic form instances (values) are saved in the individual tables according to the entity which they are linked to => which is their owner (e.g. the entity ''IdmIdentityFormValue'', ''IdmRoleFormValue''). Form values are not saved, if ''null'' value (by persistent type) is given => filled values are saved only.
Line 30: Line 16:
 Dynamic form attribute supports data types (''persistentType''): Dynamic form attribute supports data types (''persistentType''):
   * ''CHAR'' - one character   * ''CHAR'' - one character
-  * ''TEXT'' -  strings (long text). Not indexed - ''SHORTTEXT'' usage is preferred.+  * ''TEXT'' -  strings (long text). Searching by ''TEXT'' is not supported,  column is not indexed - **''SHORTTEXT'' usage is preferred (+ indexed)**.
   * ''SHORTTEXT'' - strings (2000 chars). Indexed.   * ''SHORTTEXT'' - strings (2000 chars). Indexed.
   * ''INT'' - integer   * ''INT'' - integer
Line 40: Line 26:
   * ''BYTEARRAY'' - byte[]   * ''BYTEARRAY'' - byte[]
   * ''UUID'' - uuid identifier. Indexed.   * ''UUID'' - uuid identifier. Indexed.
-  * ''ATTACHMENT'' - attachment (~binary file). Read more about [[..:..:modules_rpt:dev:attachment_manager|attachments]].+  * ''ATTACHMENT'' - attachment (~binary file). Read more about [[#attachments|attachments]]. 
 +  * ''CODELIST'' - referenced code list - persists items "code" into short text. Uses face type as code list code. 
 +  * ''ENUMERATION'' referenced frontend enumeration - persists items "code" into short text. Uses face type as enumeration name. 
 + 
 + 
 +<note info>Changing ''persistentType'' and ''confidential'' is possible only for attributes without persisted values => when attribute is not used for some values. Data migration, when attribute's ''persistentType'' or ''confidential'' is changed is not supported now.</note>
  
 with properties: with properties:
-  * ''code'' - unique code in the one form definition (scope) 
-  * ''name'' - user friendly attribute name 
-  * '' 
   * ''readonly''   * ''readonly''
   * ''multi values'' - Is represented on the front-end by a textarea, where a line is a value (a new line separates the values). This property is supported for persistent types ''CHAR'', ''TEXT'', ''INT'', ''LONG'', ''DOUBLE'' and ''UUID''.   * ''multi values'' - Is represented on the front-end by a textarea, where a line is a value (a new line separates the values). This property is supported for persistent types ''CHAR'', ''TEXT'', ''INT'', ''LONG'', ''DOUBLE'' and ''UUID''.
   * ''confidential'' - .The values are stored in an [[..:..:security:dev:confidential-storage|confidential storage]]). Stored values of these attributes - substitute characters only - are loaded on the front-end. The value can only be changed and determined whether it is filled in. This property is supported for persistent types ''CHAR'', ''TEXT'', ''INT'', ''LONG'', ''DOUBLE'', ''UUID'', ''BYTEARRAY''.   * ''confidential'' - .The values are stored in an [[..:..:security:dev:confidential-storage|confidential storage]]). Stored values of these attributes - substitute characters only - are loaded on the front-end. The value can only be changed and determined whether it is filled in. This property is supported for persistent types ''CHAR'', ''TEXT'', ''INT'', ''LONG'', ''DOUBLE'', ''UUID'', ''BYTEARRAY''.
-  * ''required'' - value validation, read more. +  * ''required'' - value validation, [[#validation|read more]]
-  * ''unique'' - value validation, read more. +  * ''unique'' - value validation, [[#validation|read more]]
-  * ''min'' - value validation, read more. +  * ''min'' - value validation, [[#validation|read more]]
-  * ''max'' - value validation, read more. +  * ''max'' - value validation, [[#validation|read more]]
-  * ''regex'' - value validation, read more. +  * ''regex'' - value validation, [[#validation|read more]]
-  * ''validationMessage'' - custom message, when some validation fails, read more.+  * ''validationMessage'' - custom message, when some validation fails, [[#validation|read more]].
  
-Dynamic form attribute can be rendered differently on frontend. Face type (faceType) property is used for choosing frontend renderer. Default renderer is chosen by persistent type (e.g. UUID → UUID). +Dynamic form attributes can be rendered differently on frontend. Face type (faceType) property is used for choosing frontend renderer. The default renderer is chosen by persistent type (e.g. UUID → UUID). 
  
-Renderer is frontend component, superclass component ''AbstractFormAttributeRenderer'' is used for all renderer implementations. Renderer is responsible for ''IdmFormValue <=> input value'' transformation. +Renderer is frontend component, superclass component ''AbstractFormAttributeRenderer'' is used for all renderer implementations. Renderer is responsible for ''IdmFormValue <=> input value'' transformation. 
  
 Renderers are registered in module's ''component-descriptor.js'' as single component with attributes: Renderers are registered in module's ''component-descriptor.js'' as single component with attributes:
Line 89: Line 77:
  
 On the FE, there is an agenda of forms - their definition and attributes. Each definition can contain zero or more attributes. To maintain the integrity, an interface [[https://github.com/bcvsolutions/CzechIdMng/blob/develop/Realization/backend/core/core-api/src/main/java/eu/bcvsolutions/idm/core/api/entity/UnmodifiableEntity.java|UnmodifiableEntity]] has been created, which allows adding a flag that the entity has been created by the system and cannot be modified (or some of its attributes) and deleted (this logic now needs to be implemented manually into the relevant controllers), for example in [[https://github.com/bcvsolutions/CzechIdMng/blob/develop/Realization/backend/core/core-impl/src/main/java/eu/bcvsolutions/idm/core/eav/rest/impl/IdmFormAttributeController.java|IdmFormAttributeController]]. On the FE, there is an agenda of forms - their definition and attributes. Each definition can contain zero or more attributes. To maintain the integrity, an interface [[https://github.com/bcvsolutions/CzechIdMng/blob/develop/Realization/backend/core/core-api/src/main/java/eu/bcvsolutions/idm/core/api/entity/UnmodifiableEntity.java|UnmodifiableEntity]] has been created, which allows adding a flag that the entity has been created by the system and cannot be modified (or some of its attributes) and deleted (this logic now needs to be implemented manually into the relevant controllers), for example in [[https://github.com/bcvsolutions/CzechIdMng/blob/develop/Realization/backend/core/core-impl/src/main/java/eu/bcvsolutions/idm/core/eav/rest/impl/IdmFormAttributeController.java|IdmFormAttributeController]].
- 
-It is necessary to be cautious when editing individual form attributes as the logic linked to this form can be rendered non-functional. 
  
 <note important>Data migration, when attribute's ''persistentType'' or ''confidential'' is changed is not supported now.</note> <note important>Data migration, when attribute's ''persistentType'' or ''confidential'' is changed is not supported now.</note>
  
-===== Common forms ===== 
  
-Common forms is used for saving internal dynamic forms for: +===== Localization =====
-- report filters +
-- long running task properties (comming soon) +
-- authorization policiy properties (comming soon)+
  
-Form has to have form definition and ownerwhich can be an entity implementing ''FormableEntity'' interface. One owner can have more forms. When owner is deleted, then all forms have to be deleted to - override owner's service delete method properly. Form can be shared between owners e.g. report filter can be used as input (properties) for long running task - this is the main reason, why common forms exists, don't use this common forms for storing extended attributes mentioned above (e.g. they will not be shown on frontend).+<note important>Beware, **form type, form code and attribute code** is used for composing the key for localization and in the string ** all special characters (white spacesdots, colons etc.) will by replaced by dash** (''spinal-case'' or ''kebab-case'' on frontend).</note>
  
-===== Localization =====+Example form code **eu.bcvsolutions.idm.acc.entity.SysSystem** will be transformed into **eu-bcvsolutions-idm-acc-entity-syssystem**
  
-For form attributes is possible add localization into cs.json and en.json for each module. +Read more in [[tutorial:dev:dynamic_form_localization|tutorial]]
  
-<note important>Beware, **form type, form code and attribute code** is used for compose key for localization and in the string **will by replaced all special characters (white spaces, dots, colons etc.) by dash** (''spinal-case'' or ''kebab-case'' on frontend).</note>+===== Validation ===== 
 +{{tag>validation}}
  
-<note tip>New tab on form definition detail can be used for creating localization.</note> 
  
-Example form code **eu.bcvsolutions.idm.acc.entity.SysSystem** will be transformed into **eu-bcvsolutions-idm-acc-entity-syssystem**+==== Regex ====
  
-Read more in [[tutorial:dev:dynamic_form_localization|tutorial]]+Value has to match given regular expression ([[https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html|java pattern]] is used).
  
-===== Code lists =====+<note info>Unique validation is not supported for ''BYTEARRAY'' and ''ATTACHMENT'' persistent types.</note>
  
-Code list can be defined and used on frontend forms -defines options for the select box (e.gused on role detail for the ''environment'' attribute). Code lists items could have additional extended attributes.  +<note info> 
-Code list works as decorator onlyWhen whole code list is deleted, then the only impact is raw item codes will be rendered on frontend =when code list or code list item is not found, then raw value (item's code) is shown instead.+Use single back slash for configure regex on GUI =use double back slash in java.  
 +Example regex for the ip v4 address: 
 +  * GUI: ''^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$'' 
 +  * java: ''^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$'' 
 +</note> 
 + 
 + 
 +==== Validation message ==== 
 + 
 +Custom validation messageIf message is not defined, then default message by invalid validation type will be shown. 
 + 
 +<note tip>Can contain localization key (e.g. ''core:validationError.invalid.unique''). Parameters ''min'', ''max'', ''regex'', ''unique'', ''required'' is available for localization message.</note> 
 + 
 + 
 +===== Code lists =====
  
 <note tip>Use ''CodeListManager'' for creating and providing code lists and items through application on backend (e.g. available for scripts, which could be used in provisioning).</note> <note tip>Use ''CodeListManager'' for creating and providing code lists and items through application on backend (e.g. available for scripts, which could be used in provisioning).</note>
Line 129: Line 125:
 ===== Authorization policies support ===== ===== Authorization policies support =====
  
-Identity form values can be secured by authorization policies - see how to [[..:..:security:dev:authorization#secure_identity_form_extended_attribute_values|configure authorization policies]], when some identity extended attributes have to be secured.+Identity form values can be secured by authorization policies when some identity extended attributes have to be secured - see how in [[..:..:security:dev:authorization#secure_identity_form_extended_attribute_values|configure authorization policies]].  
 + 
 +<note tip>Authorization policies only support identity extended attribute values. Support for other entities can be added in the future.</note> 
  
-<note tip>Only identity extended attribute values support authorization policies. Support for other entities can be added in future.</note> 
 ===== Future development ===== ===== Future development =====
  
-  * API for saving the owner and the eav form in one transaction (=> save ''IdmFormInstance''). 
-  * Attribute properties validation - by supported persistent type (see above). 
   * Form value data migration, when persistent type is changed.   * Form value data migration, when persistent type is changed.
-  * [[https://redmine.czechidm.com/issues/1140|#1140]] Add module into form definition table - now is module resolved dynamically by ownerbut this cannot be overriden by module - e.g. when reg module adds new form for identity, localization is searched by owner in core module => and cannot be found.+  * Attachment renderersupport multiple files, validation support (now is validation on input) 
 +  * Created deep copy, when form values are copied => attachment is linked to two form values and is removed, when the first one is deleted.
  • by tomiskar