}
}
protected void buildBasicMetadata(Class<?> parentClass, Class<?> targetClass, Map<String, FieldMetadata> attributes,
FieldInfo field, FieldMetadataOverride basicFieldMetadata, DynamicEntityDao dynamicEntityDao) {
BasicFieldMetadata serverMetadata = (BasicFieldMetadata) attributes.get(field.getName());
BasicFieldMetadata metadata;
if (serverMetadata != null) {
metadata = serverMetadata;
} else {
metadata = new BasicFieldMetadata();
}
metadata.setName(field.getName());
metadata.setTargetClass(targetClass.getName());
metadata.setFieldName(field.getName());
if (basicFieldMetadata.getFieldType() != null) {
metadata.setFieldType(basicFieldMetadata.getFieldType());
}
if (basicFieldMetadata.getFriendlyName() != null) {
metadata.setFriendlyName(basicFieldMetadata.getFriendlyName());
}
if (basicFieldMetadata.getSecurityLevel() != null) {
metadata.setSecurityLevel(basicFieldMetadata.getSecurityLevel());
}
if (basicFieldMetadata.getVisibility() != null) {
metadata.setVisibility(basicFieldMetadata.getVisibility());
}
if (basicFieldMetadata.getOrder() != null) {
metadata.setOrder(basicFieldMetadata.getOrder());
}
if (basicFieldMetadata.getGridOrder() != null) {
metadata.setGridOrder(basicFieldMetadata.getGridOrder());
}
if (basicFieldMetadata.getExplicitFieldType() != null) {
metadata.setExplicitFieldType(basicFieldMetadata.getExplicitFieldType());
}
if (metadata.getExplicitFieldType()==SupportedFieldType.ADDITIONAL_FOREIGN_KEY) {
//this is a lookup - exclude the fields on this OneToOne or ManyToOne field
//metadata.setExcluded(true);
if (basicFieldMetadata.getForcePopulateChildProperties() == null || !basicFieldMetadata.getForcePopulateChildProperties()) {
metadata.setChildrenExcluded(true);
}
//metadata.setVisibility(VisibilityEnum.GRID_HIDDEN);
} else {
if (basicFieldMetadata.getExcluded()!=null) {
if (LOG.isDebugEnabled()) {
if (basicFieldMetadata.getExcluded()) {
LOG.debug("buildBasicMetadata:Excluding " + field.getName() + " because it was explicitly declared in config");
} else {
LOG.debug("buildBasicMetadata:Showing " + field.getName() + " because it was explicitly declared in config");
}
}
metadata.setExcluded(basicFieldMetadata.getExcluded());
}
}
if (basicFieldMetadata.getGroup()!=null) {
metadata.setGroup(basicFieldMetadata.getGroup());
}
if (basicFieldMetadata.getGroupOrder()!=null) {
metadata.setGroupOrder(basicFieldMetadata.getGroupOrder());
}
if (basicFieldMetadata.getGroupCollapsed()!=null) {
metadata.setGroupCollapsed(basicFieldMetadata.getGroupCollapsed());
}
if (basicFieldMetadata.getTab() != null) {
metadata.setTab(basicFieldMetadata.getTab());
}
if (basicFieldMetadata.getTabOrder() != null) {
metadata.setTabOrder(basicFieldMetadata.getTabOrder());
}
if (basicFieldMetadata.isLargeEntry()!=null) {
metadata.setLargeEntry(basicFieldMetadata.isLargeEntry());
}
if (basicFieldMetadata.isProminent()!=null) {
metadata.setProminent(basicFieldMetadata.isProminent());
}
if (basicFieldMetadata.getColumnWidth()!=null) {
metadata.setColumnWidth(basicFieldMetadata.getColumnWidth());
}
if (basicFieldMetadata.getBroadleafEnumeration()!=null) {
metadata.setBroadleafEnumeration(basicFieldMetadata.getBroadleafEnumeration());
}
if (!StringUtils.isEmpty(metadata.getBroadleafEnumeration()) && metadata.getFieldType()==SupportedFieldType.BROADLEAF_ENUMERATION) {
try {
setupBroadleafEnumeration(metadata.getBroadleafEnumeration(), metadata, dynamicEntityDao);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
if (basicFieldMetadata.getReadOnly()!=null) {
metadata.setReadOnly(basicFieldMetadata.getReadOnly());
}
if (basicFieldMetadata.getTooltip()!=null) {
metadata.setTooltip(basicFieldMetadata.getTooltip());
}
if (basicFieldMetadata.getHelpText()!=null) {
metadata.setHelpText(basicFieldMetadata.getHelpText());
}
if (basicFieldMetadata.getHint()!=null) {
metadata.setHint(basicFieldMetadata.getHint());
}
if (basicFieldMetadata.getShowIfProperty()!=null) {
metadata.setShowIfProperty(basicFieldMetadata.getShowIfProperty());
}
if (basicFieldMetadata.getCurrencyCodeField()!=null) {
metadata.setCurrencyCodeField(basicFieldMetadata.getCurrencyCodeField());
}
if (basicFieldMetadata.getLookupDisplayProperty()!=null) {
metadata.setLookupDisplayProperty(basicFieldMetadata.getLookupDisplayProperty());
metadata.setForeignKeyDisplayValueProperty(basicFieldMetadata.getLookupDisplayProperty());
}
if (basicFieldMetadata.getForcePopulateChildProperties()!=null) {
metadata.setForcePopulateChildProperties(basicFieldMetadata.getForcePopulateChildProperties());
}
if (basicFieldMetadata.getEnableTypeaheadLookup()!=null) {
metadata.setEnableTypeaheadLookup(basicFieldMetadata.getEnableTypeaheadLookup());
}
if (basicFieldMetadata.getCustomCriteria() != null) {
metadata.setCustomCriteria(basicFieldMetadata.getCustomCriteria());
}
if (basicFieldMetadata.getUseServerSideInspectionCache() != null) {
metadata.setUseServerSideInspectionCache(basicFieldMetadata.getUseServerSideInspectionCache());
}
if (basicFieldMetadata.getToOneLookupCreatedViaAnnotation()!=null) {
metadata.setToOneLookupCreatedViaAnnotation(basicFieldMetadata.getToOneLookupCreatedViaAnnotation());
}
if (basicFieldMetadata.getOptionListEntity()!=null) {
metadata.setOptionListEntity(basicFieldMetadata.getOptionListEntity());
}
if (metadata.getOptionListEntity() != null && metadata.getOptionListEntity().equals(DataDrivenEnumerationValueImpl.class.getName())) {
metadata.setOptionValueFieldName("key");
metadata.setOptionDisplayFieldName("display");
} else {
if (basicFieldMetadata.getOptionValueFieldName()!=null) {
metadata.setOptionValueFieldName(basicFieldMetadata.getOptionValueFieldName());
}
if (basicFieldMetadata.getOptionDisplayFieldName()!=null) {
metadata.setOptionDisplayFieldName(basicFieldMetadata.getOptionDisplayFieldName());
}
}
if (!StringUtils.isEmpty(metadata.getOptionListEntity()) && (StringUtils.isEmpty(metadata.getOptionValueFieldName()) || StringUtils.isEmpty(metadata.getOptionDisplayFieldName()))) {
throw new IllegalArgumentException("Problem setting up data driven enumeration for ("+field.getName()+"). The optionListEntity, optionValueFieldName and optionDisplayFieldName properties must all be included if not using DataDrivenEnumerationValueImpl as the optionListEntity.");
}
if (basicFieldMetadata.getOptionFilterValues() != null) {
String[][] options = new String[basicFieldMetadata.getOptionFilterValues().length][3];
int j = 0;
for (Serializable[] option : basicFieldMetadata.getOptionFilterValues()) {
options[j][0] = String.valueOf(option[0]);
options[j][1] = String.valueOf(option[1]);
options[j][2] = String.valueOf(option[2]);
}
metadata.setOptionFilterParams(options);
}
if (!StringUtils.isEmpty(metadata.getOptionListEntity())) {
buildDataDrivenList(metadata, dynamicEntityDao);
}
if (basicFieldMetadata.getRequiredOverride()!=null) {
metadata.setRequiredOverride(basicFieldMetadata.getRequiredOverride());
}
if (basicFieldMetadata.getValidationConfigurations()!=null) {
metadata.setValidationConfigurations(basicFieldMetadata.getValidationConfigurations());
}
if ((basicFieldMetadata.getFieldType() == SupportedFieldType.RULE_SIMPLE ||
basicFieldMetadata.getFieldType() == SupportedFieldType.RULE_WITH_QUANTITY)
&& basicFieldMetadata.getRuleIdentifier() == null) {
throw new IllegalArgumentException("ruleIdentifier property must be set on AdminPresentation when the fieldType is RULE_SIMPLE or RULE_WITH_QUANTITY");
}
if (basicFieldMetadata.getRuleIdentifier()!=null) {
metadata.setRuleIdentifier(basicFieldMetadata.getRuleIdentifier());
}
if (basicFieldMetadata.getLookupType()!=null) {
metadata.setLookupType(basicFieldMetadata.getLookupType());
}
if (basicFieldMetadata.getTranslatable() != null) {
metadata.setTranslatable(basicFieldMetadata.getTranslatable());
}
if (basicFieldMetadata.getIsDerived() != null) {
metadata.setDerived(basicFieldMetadata.getIsDerived());
}
attributes.put(field.getName(), metadata);
}