if (!ArrayUtils.contains(getFormHiddenVisibilities(), fmd.getVisibility())) {
// Depending on visibility, field for the particular property is not created on the form
String fieldType = fmd.getFieldType() == null ? null : fmd.getFieldType().toString();
// Create the field and set some basic attributes
Field f;
if (fieldType.equals(SupportedFieldType.BROADLEAF_ENUMERATION.toString())
|| fieldType.equals(SupportedFieldType.EXPLICIT_ENUMERATION.toString())
|| fieldType.equals(SupportedFieldType.DATA_DRIVEN_ENUMERATION.toString())
|| fieldType.equals(SupportedFieldType.EMPTY_ENUMERATION.toString())) {
// We're dealing with fields that should render as drop-downs, so set their possible values
f = new ComboField();
((ComboField) f).setOptions(fmd.getEnumerationValues());
} else if (fieldType.equals(SupportedFieldType.CODE.toString())) {
f = new CodeField();
} else if (fieldType.equals(SupportedFieldType.RULE_SIMPLE.toString())
|| fieldType.equals(SupportedFieldType.RULE_WITH_QUANTITY.toString())) {
// We're dealing with rule builders, so we'll create those specialized fields
f = new RuleBuilderField();
((RuleBuilderField) f).setJsonFieldName(property.getName() + "Json");
((RuleBuilderField) f).setDataWrapper(new DataWrapper());
((RuleBuilderField) f).setFieldBuilder(fmd.getRuleIdentifier());
String blankJsonString = "{\"data\":[]}";
((RuleBuilderField) f).setJson(blankJsonString);
DataWrapper dw = convertJsonToDataWrapper(blankJsonString);
if (dw != null) {
((RuleBuilderField) f).setDataWrapper(dw);
}
if (fieldType.equals(SupportedFieldType.RULE_SIMPLE.toString())) {
((RuleBuilderField) f).setStyleClass("rule-builder-simple");
} else if (fieldType.equals(SupportedFieldType.RULE_WITH_QUANTITY.toString())) {
((RuleBuilderField) f).setStyleClass("rule-builder-complex");
}
} else if (LookupType.DROPDOWN.equals(fmd.getLookupType())) {
// We're dealing with a to-one field that wants to be rendered as a dropdown instead of in a
// modal, so we'll provision the combo field here. Available options will be set as part of a
// subsequent operation
f = new ComboField();
} else if (fieldType.equals(SupportedFieldType.MEDIA.toString())) {
f = new MediaField();
} else {
// Create a default field since there was no specialized handler
f = new Field();
}
Boolean required = fmd.getRequiredOverride();
if (required == null) {
required = fmd.getRequired();
}
f.withName(property.getName())
.withFieldType(fieldType)
.withOrder(fmd.getOrder())
.withFriendlyName(fmd.getFriendlyName())
.withForeignKeyDisplayValueProperty(fmd.getForeignKeyDisplayValueProperty())
.withForeignKeyClass(fmd.getForeignKeyClass())
.withOwningEntityClass(fmd.getOwningClass()!=null?fmd.getOwningClass():fmd.getInheritedFromType())
.withRequired(required)
.withReadOnly(fmd.getReadOnly())
.withTranslatable(fmd.getTranslatable())
.withAlternateOrdering((Boolean) fmd.getAdditionalMetadata().get(Field.ALTERNATE_ORDERING))
.withLargeEntry(fmd.isLargeEntry())
.withHint(fmd.getHint())
.withTooltip(fmd.getTooltip())
.withHelp(fmd.getHelpText())
.withTypeaheadEnabled(fmd.getEnableTypeaheadLookup());
if (StringUtils.isBlank(f.getFriendlyName())) {
f.setFriendlyName(f.getName());
}
// Add the field to the appropriate FieldGroup
ef.addField(f, fmd.getGroup(), fmd.getGroupOrder(), fmd.getTab(), fmd.getTabOrder());
}