@Service(value="blFormBuilderService") public class FormBuilderServiceImpl extends Object implements FormBuilderService
| Modifier and Type | Field and Description |
|---|---|
protected AdminEntityService |
adminEntityService |
protected AdminNavigationService |
adminNavigationService |
protected SecurityVerifier |
adminRemoteSecurityService |
static String |
ALTERNATE_ID_PROPERTY |
protected EntityConfiguration |
entityConfiguration |
protected FormBuilderExtensionManager |
extensionManager |
protected static VisibilityEnum[] |
FORM_HIDDEN_VISIBILITIES |
protected static VisibilityEnum[] |
GRID_HIDDEN_VISIBILITIES |
protected ListGridErrorMessageExtensionManager |
listGridErrorExtensionManager |
protected MediaBuilderService |
mediaBuilderService |
protected AdminNavigationService |
navigationService |
protected RowLevelSecurityService |
rowLevelSecurityService |
| Constructor and Description |
|---|
FormBuilderServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAdditionalFormActions(EntityForm ef)
This method is invoked when EntityForms are created and is meant to provide a hook to add
additional entity form actions for implementors of Broadleaf.
|
protected void |
addDeleteActionIfAllowed(EntityForm entityForm,
ClassMetadata cmd,
Entity entity)
Adds the
DefaultEntityFormActions.DELETE if the user is allowed to delete the entity. |
EntityForm |
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
new EntityForm this simply uses the EntityForm that was passed in as ef. |
EntityForm |
buildAdornedListForm(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.
|
ListGrid |
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.
|
ListGrid |
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.
|
EntityForm |
buildMapForm(MapMetadata mapMd,
MapStructure mapStructure,
ClassMetadata cmd,
String parentId)
Builds the EntityForm used in modal dialogs when adding items to map collections.
|
EntityForm |
buildMapForm(MapMetadata mapMd,
MapStructure mapStructure,
ClassMetadata cmd,
String parentId,
EntityForm ef)
Equivalent to
FormBuilderService.buildMapForm(MapMetadata, MapStructure, ClassMetadata, String) except rather than creating a
new EntityForm this simply uses the EntityForm that was passed in as ef. |
protected String |
buildMsgForDefValException(String type,
BasicFieldMetadata fmd,
String defaultValue) |
Map<String,Object> |
buildSelectizeCollectionInfo(String containingEntityId,
DynamicResultSet drs,
Property field,
String sectionKey,
List<SectionCrumb> sectionCrumbs) |
protected String |
buildSelectizeUrl(ListGrid listGrid) |
protected FieldDTO |
constructFieldDTOFromFieldData(Field field,
BasicFieldMetadata fmd) |
Map<String,Object> |
constructSelectizeOptionMap(DynamicResultSet drs,
ClassMetadata cmd)
constructs the selectize option map based on the dynamic result set and class metadata
|
protected DataWrapper |
convertJsonToDataWrapper(String json)
When using Thymeleaf, we need to convert the JSON string back to
a DataWrapper object because Thymeleaf escapes JSON strings.
|
EntityForm |
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.
|
EntityForm |
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.
|
EntityForm |
createEntityForm(ClassMetadata cmd,
List<SectionCrumb> sectionCrumbs)
Creates a new EntityForm with the a default 'Save' action.
|
protected Field |
createHeaderField(Property p,
BasicFieldMetadata fmd) |
protected ListGrid |
createListGrid(String className,
List<Field> headerFields,
ListGrid.Type type,
DynamicResultSet drs,
String sectionKey,
Integer order,
String idProperty,
List<SectionCrumb> sectionCrumbs,
String sortPropery)
Populate a ListGrid with ListGridRecords.
|
protected ListGrid |
createListGrid(String className,
List<Field> headerFields,
ListGrid.Type type,
DynamicResultSet drs,
String sectionKey,
int order,
String idProperty,
List<SectionCrumb> sectionCrumbs)
|
protected EntityForm |
createStandardAdornedEntityForm() |
protected EntityForm |
createStandardEntityForm() |
String |
extractDefaultValueFromFieldData(String fieldType,
BasicFieldMetadata fmd)
Extracts the DefaultValue from the FieldMetaData and parses it based on the
SupportedFieldType that the field uses. |
protected String |
extractSectionIdentifierFromCrumb(List<SectionCrumb> sectionCrumbs) |
protected void |
filterMapFormProperties(List<Property> mapFormProperties,
List<String> classNames) |
protected boolean |
foundMatchingTab(String unprocessedTabName) |
protected String |
getAdminSectionPath(String foreignKeyClass)
This method gets the
AdminSection for the given foreignKeyClass parameter. |
protected String |
getFieldComponentRenderer(BasicFieldMetadata fmd) |
protected VisibilityEnum[] |
getFormHiddenVisibilities() |
protected String |
getGridFieldComponentRenderer(BasicFieldMetadata fmd) |
protected VisibilityEnum[] |
getGridHiddenVisibilities() |
protected String |
getMapKeyFriendlyName(Property property) |
protected String |
getSecurityClassname(EntityForm entityForm,
ClassMetadata cmd)
Obtains the class name suitable for passing along to the
SecurityVerifier |
protected String |
getUnprocessedNameOfMatchingTab(TabMetadata tabMetadata,
Set<String> tabMetadataKeySet)
Search for any other tab on the target entity that has the same display value
as the value provided tab name.
|
protected List<String> |
getValueClassNames(String valueClassName) |
protected Boolean |
isDerivedField(Field headerField,
Field recordField,
Property p)
Determines whether or not a particular field in a record is derived.
|
void |
populateAdornedEntityFormFields(EntityForm ef,
Entity entity,
AdornedTargetList adornedList)
Sets values for the necessary adorned fields on the EntityForm from the specified entity.
|
protected void |
populateDropdownToOneFields(EntityForm ef,
ClassMetadata cmd) |
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 |
populateEntityForm(ClassMetadata cmd,
Entity entity,
Map<String,DynamicResultSet> collectionRecords,
EntityForm ef,
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 |
populateEntityFormFields(EntityForm ef,
Entity entity)
Delegates to
FormBuilderService.populateEntityFormFields(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 given
EntityForm with values based on the Entity 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.
|
protected boolean |
processedTabKeyMatchesTabName(String tabName,
String candidateTabKey) |
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.
|
protected void |
setEntityFormFields(ClassMetadata cmd,
EntityForm ef,
List<Property> properties) |
protected void |
setEntityFormTabsAndGroups(EntityForm ef,
Map<String,TabMetadata> tabMetadataMap)
NOTE: This method will attempt to merge tabs if the unprocessed
TabMetadata.getTabName() is equal to
the processed value of another tab. |
protected void |
setReadOnlyState(EntityForm entityForm,
ClassMetadata cmd,
Entity entity)
The given entityForm is marked as readonly for the following cases:
All of the properties from cmd are readonly
The user does not have the security to
EntityOperationType.UPDATE the given class name represented by
the entityForm (determined by getSecurityClassname(EntityForm, ClassMetadata))
The user does not have the security necessary to modify the given entity according to the
RowLevelSecurityProvider.canUpdate(AdminUser, Entity)
|
protected void |
setVisibilityBasedOnShowIfFieldEquals(ClassMetadata cmd,
Entity entity,
EntityForm ef) |
protected boolean |
shouldHideField(FieldMetadata fmd,
Entity entity) |
protected boolean |
tabExists(EntityForm ef,
String tabKey) |
public static final String ALTERNATE_ID_PROPERTY
protected AdminEntityService adminEntityService
protected AdminNavigationService navigationService
protected FormBuilderExtensionManager extensionManager
protected EntityConfiguration entityConfiguration
protected SecurityVerifier adminRemoteSecurityService
protected RowLevelSecurityService rowLevelSecurityService
protected MediaBuilderService mediaBuilderService
protected ListGridErrorMessageExtensionManager listGridErrorExtensionManager
protected AdminNavigationService adminNavigationService
protected static final VisibilityEnum[] FORM_HIDDEN_VISIBILITIES
protected static final VisibilityEnum[] GRID_HIDDEN_VISIBILITIES
public ListGrid buildMainListGrid(DynamicResultSet drs, ClassMetadata cmd, String sectionKey, List<SectionCrumb> sectionCrumbs) throws ServiceException
FormBuilderServicebuildMainListGrid in interface FormBuilderServiceServiceExceptionprotected FieldDTO constructFieldDTOFromFieldData(Field field, BasicFieldMetadata fmd)
protected Field createHeaderField(Property p, BasicFieldMetadata fmd)
public ListGrid buildCollectionListGrid(String containingEntityId, DynamicResultSet drs, Property field, String sectionKey, List<SectionCrumb> sectionCrumbs) throws ServiceException
FormBuilderServicebuildCollectionListGrid in interface FormBuilderServiceServiceExceptionpublic Map<String,Object> buildSelectizeCollectionInfo(String containingEntityId, DynamicResultSet drs, Property field, String sectionKey, List<SectionCrumb> sectionCrumbs) throws ServiceException
buildSelectizeCollectionInfo in interface FormBuilderServiceServiceExceptionpublic Map<String,Object> constructSelectizeOptionMap(DynamicResultSet drs, ClassMetadata cmd)
FormBuilderServiceconstructSelectizeOptionMap in interface FormBuilderService@Deprecated protected ListGrid createListGrid(String className, List<Field> headerFields, ListGrid.Type type, DynamicResultSet drs, String sectionKey, int order, String idProperty, List<SectionCrumb> sectionCrumbs)
createListGrid(String, List, ListGrid.Type, DynamicResultSet, String, Integer, String, List, String)className - headerFields - type - drs - sectionKey - order - idProperty - sectionCrumbs - protected ListGrid createListGrid(String className, List<Field> headerFields, ListGrid.Type type, DynamicResultSet drs, String sectionKey, Integer order, String idProperty, List<SectionCrumb> sectionCrumbs, String sortPropery)
className - headerFields - type - drs - sectionKey - order - idProperty - sectionCrumbs - sortPropery - protected Boolean isDerivedField(Field headerField, Field recordField, Property p)
BasicFieldMetadata
for the given Property to see if something on the backend has marked it as derivedheaderField - the header for this recordFieldrecordField - the recordField being populatedp - the property that relates to this recordField#createListGrid(String, List, ListGrid.Type, DynamicResultSet, String, Integer, String, List, String)}protected void setEntityFormFields(ClassMetadata cmd, EntityForm ef, List<Property> properties)
protected String getFieldComponentRenderer(BasicFieldMetadata fmd)
protected String getGridFieldComponentRenderer(BasicFieldMetadata fmd)
protected String getAdminSectionPath(String foreignKeyClass)
AdminSection for the given foreignKeyClass parameter. If none exists,
it returns the foreignKeyClass.foreignKeyClass - the String class nameprotected void setEntityFormTabsAndGroups(EntityForm ef, Map<String,TabMetadata> tabMetadataMap)
TabMetadata.getTabName() is equal to
the processed value of another tab.
For example, if TabMetadata.getTabName() is "Example", there is a another tab where
TabMetadata.getTabName() is "Example_Tab", and a message property where 'Example_Tab=Example',
then the tabs should be merged together, so that we do not end up rendering multiple "Example" tabs.protected String getUnprocessedNameOfMatchingTab(TabMetadata tabMetadata, Set<String> tabMetadataKeySet)
TabMetadata.getTabName() is in the form of a processed message property.
For example, if TabMetadata.getTabName() is "Example", there is a tabKey from the tabMetadataKeySet
that is "Example_Tab", and a message property where 'Example_Tab=Example', then this method should return
"Example_Tab" which will end up causing the tabs to merge together.
If a tab with the same display value cannot be found, then we should return null to indicate that there
is no matching tab with the same processed tabName value.protected boolean processedTabKeyMatchesTabName(String tabName, String candidateTabKey)
protected boolean foundMatchingTab(String unprocessedTabName)
protected boolean tabExists(EntityForm ef, String tabKey)
public String extractDefaultValueFromFieldData(String fieldType, BasicFieldMetadata fmd)
FormBuilderServiceSupportedFieldType that the field uses.
Logs a warning in the event of failure to parse the value and returns null.extractDefaultValueFromFieldData in interface FormBuilderServiceprotected String buildMsgForDefValException(String type, BasicFieldMetadata fmd, String defaultValue)
public void removeNonApplicableFields(ClassMetadata cmd, EntityForm entityForm, String entityType)
FormBuilderServiceremoveNonApplicableFields in interface FormBuilderServicepublic EntityForm createEntityForm(ClassMetadata cmd, List<SectionCrumb> sectionCrumbs) throws ServiceException
FormBuilderService#populateEntityForm(ClassMetadata, EntityForm) to ensure that the newly created EntityForm
has all of the appropriate fields set up without any values based on cmdcreateEntityForm in interface FormBuilderServiceServiceException#populateEntityForm(ClassMetadata, EntityForm)}protected String extractSectionIdentifierFromCrumb(List<SectionCrumb> sectionCrumbs)
public void populateEntityForm(ClassMetadata cmd, EntityForm ef, List<SectionCrumb> sectionCrumbs) throws ServiceException
FormBuilderService#populateEntityForm(ClassMetadata, Entity, EntityForm, boolean)populateEntityForm in interface FormBuilderServiceServiceExceptionprotected void addAdditionalFormActions(EntityForm ef)
FormBuilderExtensionHandler.addAdditionalFormActions(EntityForm) method.ef - public EntityForm createEntityForm(ClassMetadata cmd, Entity entity, List<SectionCrumb> sectionCrumbs) throws ServiceException
FormBuilderService#createEntityForm(ClassMetadata) for further populationcreateEntityForm in interface FormBuilderServicecmd - metadata that the created EntityForm should use to initialize its fieldsServiceException#createEntityForm(ClassMetadata)}public void populateEntityForm(ClassMetadata cmd, Entity entity, EntityForm ef, List<SectionCrumb> sectionCrumbs) throws ServiceException
FormBuilderServicepopulateEntityForm in interface FormBuilderServiceServiceException#populateEntityForm(ClassMetadata, EntityForm)}protected void setVisibilityBasedOnShowIfFieldEquals(ClassMetadata cmd, Entity entity, EntityForm ef)
protected boolean shouldHideField(FieldMetadata fmd, Entity entity)
public void populateEntityFormFieldValues(ClassMetadata cmd, Entity entity, EntityForm ef)
FormBuilderServiceEntityForm with values based on the Entity that has been passed in. The
ClassMetadata is used to determine which properties should be attempted to be populatedpopulateEntityFormFieldValues in interface FormBuilderServicecmd - 'inspect' metadata for the class being populatedentity - the Entity that should be used to fill out the field values in the given EntityFormef - the EntityForm to populate field values from the given Entityprotected DataWrapper convertJsonToDataWrapper(String json)
json - IOExceptionprotected void populateDropdownToOneFields(EntityForm ef, ClassMetadata cmd) throws ServiceException
ServiceExceptionpublic EntityForm createEntityForm(ClassMetadata cmd, Entity entity, Map<String,DynamicResultSet> collectionRecords, List<SectionCrumb> sectionCrumbs) throws ServiceException
FormBuilderServiceEntityForm (that has a save action) and then populates
that EntityForm 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.createEntityForm in interface FormBuilderServiceServiceException#populateEntityForm(ClassMetadata, Entity, Map, EntityForm)}public void populateEntityForm(ClassMetadata cmd, Entity entity, Map<String,DynamicResultSet> collectionRecords, EntityForm ef, List<SectionCrumb> sectionCrumbs) throws ServiceException
FormBuilderServiceEntityForm to the model or else you lose the whole BindingResult 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.populateEntityForm in interface FormBuilderServiceef - rather than instantiate a new EntityForm, this will use this parameter to fill outServiceExceptionprotected void addDeleteActionIfAllowed(EntityForm entityForm, ClassMetadata cmd, Entity entity)
DefaultEntityFormActions.DELETE if the user is allowed to delete the entity. The user can
delete an entity for the following cases:
EntityOperationType.REMOVE the given class name represented by
the entityForm (determined by getSecurityClassname(EntityForm, ClassMetadata))RowLevelSecurityProvider.canRemove(AdminUser, Entity)entityForm - the form being generatedcmd - the metatadata used to build the entityForm for the entityentity - the entity being editedSecurityVerifier#securityCheck(String, EntityOperationType)},
#getSecurityClassname(EntityForm, ClassMetadata)},
RowLevelSecurityService#canRemove(AdminUser, Entity)}protected void setReadOnlyState(EntityForm entityForm, ClassMetadata cmd, Entity entity)
EntityOperationType.UPDATE the given class name represented by
the entityForm (determined by getSecurityClassname(EntityForm, ClassMetadata))RowLevelSecurityProvider.canUpdate(AdminUser, Entity)entityForm - the form being generatedcmd - the metatadata used to build the entityForm for the entityentity - the entity being editedSecurityVerifier#securityCheck(String, EntityOperationType)},
#getSecurityClassname(EntityForm, ClassMetadata)},
RowLevelSecurityService#canUpdate(AdminUser, Entity)}protected String getSecurityClassname(EntityForm entityForm, ClassMetadata cmd)
SecurityVerifierentityForm - cmd - public void populateEntityFormFields(EntityForm ef, Entity entity)
FormBuilderServiceFormBuilderService.populateEntityFormFields(EntityForm, Entity, boolean, boolean) with true for populating both
the id and type.populateEntityFormFields in interface FormBuilderService#populateEntityFormFields(EntityForm, Entity, boolean, boolean)}public void populateEntityFormFields(EntityForm ef, Entity entity, boolean populateType, boolean populateId)
FormBuilderServicepopulateEntityFormFields in interface FormBuilderServicepopulateType - whether or not to use the type from the given Entity or keep the current value on
the EntityFormpopulateId - whether or not to use the id from the given Entity or keep the current value on
the EntityFormpublic void populateAdornedEntityFormFields(EntityForm ef, Entity entity, AdornedTargetList adornedList)
FormBuilderServicepopulateAdornedEntityFormFields in interface FormBuilderServicepublic void populateMapEntityFormFields(EntityForm ef, Entity entity)
FormBuilderServicepopulateMapEntityFormFields in interface FormBuilderServicepublic EntityForm buildAdornedListForm(AdornedTargetCollectionMetadata adornedMd, AdornedTargetList adornedList, String parentId, boolean isViewCollectionItem, List<SectionCrumb> sectionCrumbs, boolean isAdd) throws ServiceException
FormBuilderServicebuildAdornedListForm in interface FormBuilderServiceServiceExceptionpublic EntityForm buildAdornedListForm(AdornedTargetCollectionMetadata adornedMd, AdornedTargetList adornedList, String parentId, boolean isViewCollectionItem, EntityForm ef, List<SectionCrumb> sectionCrumbs, boolean isAdd) throws ServiceException
FormBuilderService#buildAdornedListForm(AdornedTargetCollectionMetadata, AdornedTargetList, String) except rather than creating a
new EntityForm this simply uses the EntityForm that was passed in as ef. Used mainly when
rebuilding an EntityForm 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 withbuildAdornedListForm in interface FormBuilderServiceef - the form DTO to populateEntityForm passed in but fully populatedServiceExceptionpublic EntityForm buildMapForm(MapMetadata mapMd, MapStructure mapStructure, ClassMetadata cmd, String parentId) throws ServiceException
FormBuilderServicebuildMapForm in interface FormBuilderServiceServiceExceptionpublic EntityForm buildMapForm(MapMetadata mapMd, MapStructure mapStructure, ClassMetadata cmd, String parentId, EntityForm ef) throws ServiceException
FormBuilderServiceFormBuilderService.buildMapForm(MapMetadata, MapStructure, ClassMetadata, String) except rather than creating a
new EntityForm this simply uses the EntityForm that was passed in as ef. Used mainly when
rebuilding an EntityForm 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 withbuildMapForm in interface FormBuilderServiceef - the form DTO to populateEntityForm passed in but fully populatedServiceExceptionprotected void filterMapFormProperties(List<Property> mapFormProperties, List<String> classNames)
protected EntityForm createStandardEntityForm()
protected EntityForm createStandardAdornedEntityForm()
protected VisibilityEnum[] getGridHiddenVisibilities()
protected VisibilityEnum[] getFormHiddenVisibilities()
Copyright © 2019. All rights reserved.