Interface FormBuilderService
- All Known Implementing Classes:
FormBuilderServiceImpl
- Author:
- Andre Azzolini (apazzolini)
-
Method Summary
Modifier and TypeMethodDescriptionbuildAdornedListForm
(AdornedTargetCollectionMetadata adornedMd, AdornedTargetList adornedList, String parentId, boolean isViewCollectionItem, List<SectionCrumb> sectionCrumbs, boolean isAdd) Builds the EntityForm used in modal dialogs when adding items to adorned target collections.buildAdornedListForm
(AdornedTargetCollectionMetadata adornedMd, AdornedTargetList adornedList, String parentId, boolean isViewCollectionItem, EntityForm ef, List<SectionCrumb> sectionCrumbs, boolean isAdd) Equivalent to#buildAdornedListForm(AdornedTargetCollectionMetadata, AdornedTargetList, String)
except rather than creating a newEntityForm
this simply uses theEntityForm
that was passed in as ef.buildCollectionListGrid
(String containingEntityId, DynamicResultSet drs, Property field, String sectionKey, List<SectionCrumb> sectionCrumbs) Builds a list grid that is used to render a collection inline in an entity form.buildMainListGrid
(DynamicResultSet drs, ClassMetadata cmd, String sectionKey, List<SectionCrumb> sectionCrumbs) Builds a list grid that is typically used at the top entity level to select an entity for modification.buildMapForm
(MapMetadata mapMd, MapStructure mapStructure, ClassMetadata cmd, String parentId) Builds the EntityForm used in modal dialogs when adding items to map collections.buildMapForm
(MapMetadata mapMd, MapStructure mapStructure, ClassMetadata cmd, String parentId, EntityForm ef) Equivalent tobuildMapForm(MapMetadata, MapStructure, ClassMetadata, String)
except rather than creating a newEntityForm
this simply uses theEntityForm
that was passed in as ef.buildSelectizeCollectionInfo
(String containingEntityId, DynamicResultSet drs, Property field, String sectionKey, List<SectionCrumb> sectionCrumbs) constructs the selectize option map based on the dynamic result set and class metadatacreateEntityForm
(ClassMetadata cmd, List<SectionCrumb> sectionCrumbs) Creates a new EntityForm with the a default 'Save' action.createEntityForm
(ClassMetadata cmd, Entity entity, List<SectionCrumb> sectionCrumbs) Creates a new EntityForm that has all of the appropriate fields set up along with the values for those fields from the given Entity.createEntityForm
(ClassMetadata cmd, Entity entity, Map<String, DynamicResultSet> collectionRecords, List<SectionCrumb> sectionCrumbs) Builds an EntityForm that has all of the appropriate fields set up along with the values for those fields from the given Entity as well as all sub-collections of the given Entity that appear in the collectionRecords map.extractDefaultValueFromFieldData
(String fieldType, BasicFieldMetadata fmd) Extracts the DefaultValue from the FieldMetaData and parses it based on theSupportedFieldType
that the field uses.void
populateAdornedEntityFormFields
(EntityForm ef, Entity entity, AdornedTargetList adornedList) Sets values for the necessary adorned fields on the EntityForm from the specified entity.void
populateEntityForm
(ClassMetadata cmd, Entity entity, Map<String, DynamicResultSet> collectionRecords, EntityForm entityForm, List<SectionCrumb> sectionCrumbs) Builds an EntityForm that has all of the appropriate fields set up along with the values for thsoe fields from the given Entity as well as all sub-collections of the given Entity that appear in the collectionRecords map.void
populateEntityForm
(ClassMetadata cmd, Entity entity, EntityForm ef, List<SectionCrumb> sectionCrumbs) Populates a given ef based on the given cmd to initially create fields with the necessary metadata and then fills those fields out based on the property values from entity.void
populateEntityForm
(ClassMetadata cmd, EntityForm ef, List<SectionCrumb> sectionCrumbs) Populates the given ef with all of the fields based on the properties from cmd.void
populateEntityFormFields
(EntityForm ef, Entity entity) Delegates topopulateEntityFormFields(EntityForm, Entity, boolean, boolean)
with true for populating both the id and type.void
populateEntityFormFields
(EntityForm ef, Entity entity, boolean populateType, boolean populateId) Sets values for all fields found on the EntityForm from the specified entity.void
populateEntityFormFieldValues
(ClassMetadata cmd, Entity entity, EntityForm ef) Populates the givenEntityForm
with values based on theEntity
that has been passed in.void
populateMapEntityFormFields
(EntityForm ef, Entity entity) Sets values for the necessary map fields on the EntityForm from the specified entity.void
removeNonApplicableFields
(ClassMetadata cmd, EntityForm entityForm, String entityType) Loops through all of the fields that are specified in given class metadata and removes fields that are not applicable for the given polymorphic entity type from the entity form.
-
Method Details
-
buildMainListGrid
ListGrid buildMainListGrid(DynamicResultSet drs, ClassMetadata cmd, String sectionKey, List<SectionCrumb> sectionCrumbs) throws ServiceException Builds a list grid that is typically used at the top entity level to select an entity for modification.Note that it can also be used in other places that require the same grid as the main entity search screen provided the type on the returned ListGrid is set appropriately.
- Parameters:
drs
-cmd
-sectionKey
-- Returns:
- the ListGrid
- Throws:
ServiceException
-
buildCollectionListGrid
ListGrid buildCollectionListGrid(String containingEntityId, DynamicResultSet drs, Property field, String sectionKey, List<SectionCrumb> sectionCrumbs) throws ServiceException Builds a list grid that is used to render a collection inline in an entity form.Note that it can also be used in other places that require the same grid provided the type on the returned ListGrid is set appropriately.
- Parameters:
containingEntityId
-drs
-field
-sectionKey
-- Returns:
- the ListGrid
- Throws:
ServiceException
-
buildSelectizeCollectionInfo
Map<String,Object> buildSelectizeCollectionInfo(String containingEntityId, DynamicResultSet drs, Property field, String sectionKey, List<SectionCrumb> sectionCrumbs) throws ServiceException - Parameters:
containingEntityId
-drs
-field
-sectionKey
-- Returns:
- the ListGrid
- Throws:
ServiceException
-
constructSelectizeOptionMap
constructs the selectize option map based on the dynamic result set and class metadata- Parameters:
drs
-cmd
-- Returns:
-
extractDefaultValueFromFieldData
Extracts the DefaultValue from the FieldMetaData and parses it based on theSupportedFieldType
that the field uses.Logs a warning in the event of failure to parse the value and returns null.
- Parameters:
fieldType
-fmd
-- Returns:
- The value to be used on the form field.
-
removeNonApplicableFields
Loops through all of the fields that are specified in given class metadata and removes fields that are not applicable for the given polymorphic entity type from the entity form.- Parameters:
cmd
-entityForm
-entityType
-
-
createEntityForm
EntityForm createEntityForm(ClassMetadata cmd, List<SectionCrumb> sectionCrumbs) throws ServiceException Creates a new EntityForm with the a default 'Save' action. This will then delegate to#populateEntityForm(ClassMetadata, EntityForm)
to ensure that the newly createdEntityForm
has all of the appropriate fields set up without any values based on cmd- Parameters:
cmd
-- Returns:
- the EntityForm
- Throws:
ServiceException
-
populateEntityForm
void populateEntityForm(ClassMetadata cmd, EntityForm ef, List<SectionCrumb> sectionCrumbs) throws ServiceException Populates the given ef with all of the fields based on the properties from cmd. For all the fields that are created, no values are set (as cmd usually does not have any). In order to fill out values in the given ef, consider instead calling#populateEntityForm(ClassMetadata, Entity, EntityForm, boolean)
- Parameters:
cmd
-ef
-- Throws:
ServiceException
-
createEntityForm
EntityForm createEntityForm(ClassMetadata cmd, Entity entity, List<SectionCrumb> sectionCrumbs) throws ServiceException Creates a new EntityForm that has all of the appropriate fields set up along with the values for those fields from the given Entity. Delegates to#createEntityForm(ClassMetadata)
for further population- Parameters:
cmd
- metadata that the createdEntityForm
should use to initialize its fieldsentity
-- Returns:
- the EntityForm
- Throws:
ServiceException
-
populateEntityForm
void populateEntityForm(ClassMetadata cmd, Entity entity, EntityForm ef, List<SectionCrumb> sectionCrumbs) throws ServiceException Populates a given ef based on the given cmd to initially create fields with the necessary metadata and then fills those fields out based on the property values from entity.- Parameters:
cmd
-entity
-ef
-- Throws:
ServiceException
-
populateEntityFormFieldValues
Populates the givenEntityForm
with values based on theEntity
that has been passed in. TheClassMetadata
is used to determine which properties should be attempted to be populated- Parameters:
cmd
- 'inspect' metadata for the class being populatedentity
- theEntity
that should be used to fill out the field values in the givenEntityForm
ef
- theEntityForm
to populate field values from the givenEntity
-
createEntityForm
EntityForm createEntityForm(ClassMetadata cmd, Entity entity, Map<String, DynamicResultSet> collectionRecords, List<SectionCrumb> sectionCrumbs) throws ServiceExceptionBuilds an EntityForm that has all of the appropriate fields set up along with the values for those fields from the given Entity as well as all sub-collections of the given Entity that appear in the collectionRecords map. This method simply delegates to create a standardEntityForm
(that has a save action) and then populates thatEntityForm
using#populateEntityForm(ClassMetadata, Entity, Map, EntityForm)
.NOTE: if you are submitting a validation result, you must not call this method and instead invoke the one that has an
EntityForm
as a parameter. You cannot re-assign the entityForm to the model after it has already been bound to a BindingResult, else the binding result will be removed.- Parameters:
cmd
-entity
-collectionRecords
-- Returns:
- the EntityForm
- Throws:
ServiceException
-
populateEntityForm
void populateEntityForm(ClassMetadata cmd, Entity entity, Map<String, DynamicResultSet> collectionRecords, EntityForm entityForm, List<SectionCrumb> sectionCrumbs) throws ServiceExceptionBuilds an EntityForm that has all of the appropriate fields set up along with the values for thsoe fields from the given Entity as well as all sub-collections of the given Entity that appear in the collectionRecords map.NOTE: This method is mainly used when coming back from validation. In the case of validation, you cannot re-add a new
EntityForm
to the model or else you lose the wholeBindingResult
and errors will not properly be displayed. In that scenario, you must use this method rather than the one that does not take in an entityForm as it will attempt to instantiate a new object.- Parameters:
cmd
-entity
-collectionRecords
-entityForm
- rather than instantiate a new EntityForm, this will use this parameter to fill out- Throws:
ServiceException
-
populateEntityFormFields
Delegates topopulateEntityFormFields(EntityForm, Entity, boolean, boolean)
with true for populating both the id and type.- Parameters:
ef
-entity
-
-
populateEntityFormFields
void populateEntityFormFields(EntityForm ef, Entity entity, boolean populateType, boolean populateId) Sets values for all fields found on the EntityForm from the specified entity.- Parameters:
ef
-entity
-populateType
- whether or not to use the type from the givenEntity
or keep the current value on theEntityForm
populateId
- whether or not to use the id from the givenEntity
or keep the current value on theEntityForm
-
populateAdornedEntityFormFields
Sets values for the necessary adorned fields on the EntityForm from the specified entity.- Parameters:
ef
-entity
-adornedList
-
-
populateMapEntityFormFields
Sets values for the necessary map fields on the EntityForm from the specified entity.- Parameters:
ef
-entity
-
-
buildAdornedListForm
EntityForm buildAdornedListForm(AdornedTargetCollectionMetadata adornedMd, AdornedTargetList adornedList, String parentId, boolean isViewCollectionItem, List<SectionCrumb> sectionCrumbs, boolean isAdd) throws ServiceException Builds the EntityForm used in modal dialogs when adding items to adorned target collections.- Parameters:
adornedMd
-adornedList
-parentId
-isViewCollectionItem
-- Returns:
- the EntityForm
- Throws:
ServiceException
-
buildAdornedListForm
EntityForm buildAdornedListForm(AdornedTargetCollectionMetadata adornedMd, AdornedTargetList adornedList, String parentId, boolean isViewCollectionItem, EntityForm ef, List<SectionCrumb> sectionCrumbs, boolean isAdd) throws ServiceException Equivalent to#buildAdornedListForm(AdornedTargetCollectionMetadata, AdornedTargetList, String)
except rather than creating a newEntityForm
this simply uses theEntityForm
that was passed in as ef. Used mainly when rebuilding anEntityForm
after it has already been bound by Spring.Before invoking this method, you should invoke
EntityForm.clearFieldsMap()
to ensure that you have a clean set of field groups and tabs for this method to work with- Parameters:
mapMd
-mapStructure
-cmd
-parentId
-isViewCollectionItem
-ef
- the form DTO to populate- Returns:
- the original
EntityForm
passed in but fully populated - Throws:
ServiceException
-
buildMapForm
EntityForm buildMapForm(MapMetadata mapMd, MapStructure mapStructure, ClassMetadata cmd, String parentId) throws ServiceException Builds the EntityForm used in modal dialogs when adding items to map collections.- Parameters:
mapMd
-mapStructure
-cmd
-parentId
-- Returns:
- the EntityForm
- Throws:
ServiceException
-
buildMapForm
EntityForm buildMapForm(MapMetadata mapMd, MapStructure mapStructure, ClassMetadata cmd, String parentId, EntityForm ef) throws ServiceException Equivalent tobuildMapForm(MapMetadata, MapStructure, ClassMetadata, String)
except rather than creating a newEntityForm
this simply uses theEntityForm
that was passed in as ef. Used mainly when rebuilding anEntityForm
after it has already been bound by Spring.Before invoking this method, you should invoke
EntityForm.clearFieldsMap()
to ensure that you have a clean set of field groups and tabs for this method to work with- Parameters:
mapMd
-mapStructure
-cmd
-parentId
-ef
- the form DTO to populate- Returns:
- the original
EntityForm
passed in but fully populated - Throws:
ServiceException
-