Search in sources :

Example 1 with AdminPresentationMergeEntry

use of org.broadleafcommerce.common.presentation.override.AdminPresentationMergeEntry in project BroadleafCommerce by BroadleafCommerce.

the class BasicFieldMetadataProvider method overrideMergeMetadata.

protected FieldMetadataOverride overrideMergeMetadata(AdminPresentationMergeOverride merge) {
    FieldMetadataOverride fieldMetadataOverride = new FieldMetadataOverride();
    Map<String, AdminPresentationMergeEntry> overrideValues = getAdminPresentationEntries(merge.mergeEntries());
    for (Map.Entry<String, AdminPresentationMergeEntry> entry : overrideValues.entrySet()) {
        String stringValue = entry.getValue().overrideValue();
        if (entry.getKey().equals(PropertyType.AdminPresentation.FRIENDLYNAME)) {
            fieldMetadataOverride.setFriendlyName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.ADDFRIENDLYNAME)) {
            fieldMetadataOverride.setAddFriendlyName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.SECURITYLEVEL)) {
            fieldMetadataOverride.setSecurityLevel(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.GROUP)) {
            fieldMetadataOverride.setGroup(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.TAB)) {
            fieldMetadataOverride.setTab(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.COLUMNWIDTH)) {
            fieldMetadataOverride.setColumnWidth(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.BROADLEAFENUMERATION)) {
            fieldMetadataOverride.setBroadleafEnumeration(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.HIDEENUMERATIONIFEMPTY)) {
            fieldMetadataOverride.setHideEnumerationIfEmpty(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.FIELDCOMPONENTRENDERER)) {
            fieldMetadataOverride.setFieldComponentRenderer(SupportedFieldType.valueOf(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.FIELDCOMPONENTRENDERERTEMPLATE)) {
            fieldMetadataOverride.setFieldComponentRendererTemplate(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.GRIDFIELDCOMPONENTRENDERER)) {
            fieldMetadataOverride.setGridFieldComponentRenderer(SupportedFieldType.valueOf(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.GRIDFIELDCOMPONENTRENDERERTEMPLATE)) {
            fieldMetadataOverride.setGridFieldComponentRendererTemplate(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.TOOLTIP)) {
            fieldMetadataOverride.setTooltip(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.HELPTEXT)) {
            fieldMetadataOverride.setHelpText(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.HINT)) {
            fieldMetadataOverride.setHint(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.SHOWIFPROPERTY)) {
            fieldMetadataOverride.setShowIfProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.SHOWIFFIELDEQUALS)) {
            processShowIfFieldEqualsAnnotations(entry.getValue().showIfFieldEquals(), fieldMetadataOverride);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.CURRENCYCODEFIELD)) {
            fieldMetadataOverride.setCurrencyCodeField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.RULEIDENTIFIER)) {
            fieldMetadataOverride.setRuleIdentifier(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.ORDER)) {
            fieldMetadataOverride.setOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.GRIDORDER)) {
            fieldMetadataOverride.setGridOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.VISIBILITY)) {
            fieldMetadataOverride.setVisibility(VisibilityEnum.valueOf(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.FIELDTYPE)) {
            fieldMetadataOverride.setFieldType(SupportedFieldType.valueOf(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.GROUPORDER)) {
            fieldMetadataOverride.setGroupOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.GROUPCOLLAPSED)) {
            fieldMetadataOverride.setGroupCollapsed(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.TABORDER)) {
            fieldMetadataOverride.setTabOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.LARGEENTRY)) {
            fieldMetadataOverride.setLargeEntry(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.PROMINENT)) {
            fieldMetadataOverride.setProminent(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.READONLY)) {
            fieldMetadataOverride.setReadOnly(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.REQUIREDOVERRIDE)) {
            if (RequiredOverride.IGNORED != RequiredOverride.valueOf(stringValue)) {
                fieldMetadataOverride.setRequiredOverride(RequiredOverride.REQUIRED == RequiredOverride.valueOf(stringValue));
            }
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.EXCLUDED)) {
            fieldMetadataOverride.setExcluded(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.DEFAULTVALUE)) {
            fieldMetadataOverride.setDefaultValue(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.VALIDATIONCONFIGURATIONS)) {
            processValidationAnnotations(entry.getValue().validationConfigurations(), fieldMetadataOverride);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.ASSOCIATEDFIELDNAME)) {
            fieldMetadataOverride.setAssociatedFieldName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationToOneLookup.LOOKUPDISPLAYPROPERTY)) {
            fieldMetadataOverride.setLookupDisplayProperty(stringValue);
            fieldMetadataOverride.setForeignKeyDisplayValueProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationToOneLookup.FORCEPOPULATECHILDPROPERTIES)) {
            fieldMetadataOverride.setForcePopulateChildProperties(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationToOneLookup.ENABLETYPEAHEADLOOKUP)) {
            fieldMetadataOverride.setEnableTypeaheadLookup(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationToOneLookup.USESERVERSIDEINSPECTIONCACHE)) {
            fieldMetadataOverride.setUseServerSideInspectionCache(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationToOneLookup.LOOKUPTYPE)) {
            fieldMetadataOverride.setLookupType(LookupType.valueOf(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationToOneLookup.CUSTOMCRITERIA)) {
            fieldMetadataOverride.setCustomCriteria(entry.getValue().stringArrayOverrideValue());
        } else if (entry.getKey().equals(PropertyType.AdminPresentationDataDrivenEnumeration.OPTIONLISTENTITY)) {
            fieldMetadataOverride.setOptionListEntity(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationDataDrivenEnumeration.OPTIONVALUEFIELDNAME)) {
            fieldMetadataOverride.setOptionValueFieldName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationDataDrivenEnumeration.OPTIONDISPLAYFIELDNAME)) {
            fieldMetadataOverride.setOptionDisplayFieldName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationDataDrivenEnumeration.OPTIONHIDEIFEMPTY)) {
            fieldMetadataOverride.setHideEnumerationIfEmpty(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationDataDrivenEnumeration.OPTIONCANEDITVALUES)) {
            fieldMetadataOverride.setOptionCanEditValues(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationDataDrivenEnumeration.OPTIONFILTERPARAMS)) {
            OptionFilterParam[] optionFilterParams = entry.getValue().optionFilterParams();
            String[][] params = new String[optionFilterParams.length][3];
            for (int j = 0; j < params.length; j++) {
                params[j][0] = optionFilterParams[j].param();
                params[j][1] = optionFilterParams[j].value();
                params[j][2] = String.valueOf(optionFilterParams[j].paramType());
            }
            fieldMetadataOverride.setOptionFilterValues(params);
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.CANLINKTOEXTERNALENTITY)) {
            fieldMetadataOverride.setCanLinkToExternalEntity(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentation.TRANSLATABLE)) {
            fieldMetadataOverride.setTranslatable(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unrecognized type: " + entry.getKey() + ". Not setting on basic field.");
            }
        }
    }
    return fieldMetadataOverride;
}
Also used : AdminPresentationMergeEntry(org.broadleafcommerce.common.presentation.override.AdminPresentationMergeEntry) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FieldMetadataOverride(org.broadleafcommerce.openadmin.dto.override.FieldMetadataOverride)

Example 2 with AdminPresentationMergeEntry

use of org.broadleafcommerce.common.presentation.override.AdminPresentationMergeEntry in project BroadleafCommerce by BroadleafCommerce.

the class AdornedTargetCollectionFieldMetadataProvider method overrideAdornedTargetMergeMetadata.

protected FieldMetadataOverride overrideAdornedTargetMergeMetadata(AdminPresentationMergeOverride merge) {
    FieldMetadataOverride fieldMetadataOverride = new FieldMetadataOverride();
    Map<String, AdminPresentationMergeEntry> overrideValues = getAdminPresentationEntries(merge.mergeEntries());
    for (Map.Entry<String, AdminPresentationMergeEntry> entry : overrideValues.entrySet()) {
        String stringValue = entry.getValue().overrideValue();
        if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.CURRENCYCODEFIELD)) {
            fieldMetadataOverride.setCurrencyCodeField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.CUSTOMCRITERIA)) {
            fieldMetadataOverride.setCustomCriteria(entry.getValue().stringArrayOverrideValue());
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.EXCLUDED)) {
            fieldMetadataOverride.setExcluded(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.FRIENDLYNAME)) {
            fieldMetadataOverride.setFriendlyName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.GRIDVISIBLEFIELDS)) {
            fieldMetadataOverride.setGridVisibleFields(entry.getValue().stringArrayOverrideValue());
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.IGNOREADORNEDPROPERTIES)) {
            fieldMetadataOverride.setIgnoreAdornedProperties(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.ADORNEDTARGETADDTYPE)) {
            fieldMetadataOverride.setAdornedTargetAddMethodType(AdornedTargetAddMethodType.valueOf(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.GROUP)) {
            fieldMetadataOverride.setGroup(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.JOINENTITYCLASS)) {
            fieldMetadataOverride.setJoinEntityClass(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.MAINTAINEDADORNEDTARGETFIELDS)) {
            fieldMetadataOverride.setMaintainedAdornedTargetFields(entry.getValue().stringArrayOverrideValue());
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.OPERATIONTYPES)) {
            AdminPresentationOperationTypes operationType = entry.getValue().operationTypes();
            fieldMetadataOverride.setAddType(operationType.addType());
            fieldMetadataOverride.setRemoveType(operationType.removeType());
            fieldMetadataOverride.setUpdateType(operationType.updateType());
            fieldMetadataOverride.setFetchType(operationType.fetchType());
            fieldMetadataOverride.setInspectType(operationType.inspectType());
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.ORDER)) {
            fieldMetadataOverride.setOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.PARENTOBJECTIDPROPERTY)) {
            fieldMetadataOverride.setParentObjectIdProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.PARENTOBJECTPROPERTY)) {
            fieldMetadataOverride.setParentObjectProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.READONLY)) {
            fieldMetadataOverride.setReadOnly(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.SECURITYLEVEL)) {
            fieldMetadataOverride.setSecurityLevel(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.SHOWIFPROPERTY)) {
            fieldMetadataOverride.setShowIfProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.SHOWIFFIELDEQUALS)) {
            processShowIfFieldEqualsAnnotations(entry.getValue().showIfFieldEquals(), fieldMetadataOverride);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.SORTASCENDING)) {
            fieldMetadataOverride.setSortAscending(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.SORTPROPERTY)) {
            fieldMetadataOverride.setSortProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.TAB)) {
            fieldMetadataOverride.setTab(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.TABORDER)) {
            fieldMetadataOverride.setTabOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.TARGETOBJECTIDPROPERTY)) {
            fieldMetadataOverride.setTargetObjectIdProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.TARGETOBJECTPROPERTY)) {
            fieldMetadataOverride.setTargetObjectProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationAdornedTargetCollection.USESERVERSIDEINSPECTIONCACHE)) {
            fieldMetadataOverride.setUseServerSideInspectionCache(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unrecognized type: " + entry.getKey() + ". Not setting on adorned target field.");
            }
        }
    }
    return fieldMetadataOverride;
}
Also used : AdminPresentationMergeEntry(org.broadleafcommerce.common.presentation.override.AdminPresentationMergeEntry) AdminPresentationOperationTypes(org.broadleafcommerce.common.presentation.AdminPresentationOperationTypes) HashMap(java.util.HashMap) Map(java.util.Map) FieldMetadataOverride(org.broadleafcommerce.openadmin.dto.override.FieldMetadataOverride)

Example 3 with AdminPresentationMergeEntry

use of org.broadleafcommerce.common.presentation.override.AdminPresentationMergeEntry in project BroadleafCommerce by BroadleafCommerce.

the class CollectionFieldMetadataProvider method overrideCollectionMergeMetadata.

protected FieldMetadataOverride overrideCollectionMergeMetadata(AdminPresentationMergeOverride merge) {
    FieldMetadataOverride fieldMetadataOverride = new FieldMetadataOverride();
    Map<String, AdminPresentationMergeEntry> overrideValues = getAdminPresentationEntries(merge.mergeEntries());
    for (Map.Entry<String, AdminPresentationMergeEntry> entry : overrideValues.entrySet()) {
        String stringValue = entry.getValue().overrideValue();
        if (entry.getKey().equals(PropertyType.AdminPresentationCollection.ADDTYPE)) {
            fieldMetadataOverride.setAddType(OperationType.valueOf(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.SELECTIZEVISIBLEFIELD)) {
            fieldMetadataOverride.setSelectizeVisibleField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.CURRENCYCODEFIELD)) {
            fieldMetadataOverride.setCurrencyCodeField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.CUSTOMCRITERIA)) {
            fieldMetadataOverride.setCustomCriteria(entry.getValue().stringArrayOverrideValue());
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.EXCLUDED)) {
            fieldMetadataOverride.setExcluded(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.FRIENDLYNAME)) {
            fieldMetadataOverride.setFriendlyName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.ADDFRIENDLYNAME)) {
            fieldMetadataOverride.setAddFriendlyName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.GROUP)) {
            fieldMetadataOverride.setGroup(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.MANYTOFIELD)) {
            fieldMetadataOverride.setManyToField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.OPERATIONTYPES)) {
            AdminPresentationOperationTypes operationType = entry.getValue().operationTypes();
            fieldMetadataOverride.setAddType(operationType.addType());
            fieldMetadataOverride.setRemoveType(operationType.removeType());
            fieldMetadataOverride.setUpdateType(operationType.updateType());
            fieldMetadataOverride.setFetchType(operationType.fetchType());
            fieldMetadataOverride.setInspectType(operationType.inspectType());
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.ORDER)) {
            fieldMetadataOverride.setOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.MANYTOFIELD)) {
            fieldMetadataOverride.setManyToField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.READONLY)) {
            fieldMetadataOverride.setReadOnly(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.SECURITYLEVEL)) {
            fieldMetadataOverride.setSecurityLevel(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.SHOWIFPROPERTY)) {
            fieldMetadataOverride.setShowIfProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.SHOWIFFIELDEQUALS)) {
            processShowIfFieldEqualsAnnotations(entry.getValue().showIfFieldEquals(), fieldMetadataOverride);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.SORTASCENDING)) {
            fieldMetadataOverride.setSortAscending(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.SORTPROPERTY)) {
            fieldMetadataOverride.setSortProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.TAB)) {
            fieldMetadataOverride.setTab(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.TABORDER)) {
            fieldMetadataOverride.setTabOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationCollection.USESERVERSIDEINSPECTIONCACHE)) {
            fieldMetadataOverride.setUseServerSideInspectionCache(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unrecognized type: " + entry.getKey() + ". Not setting on collection field.");
            }
        }
    }
    return fieldMetadataOverride;
}
Also used : AdminPresentationMergeEntry(org.broadleafcommerce.common.presentation.override.AdminPresentationMergeEntry) AdminPresentationOperationTypes(org.broadleafcommerce.common.presentation.AdminPresentationOperationTypes) HashMap(java.util.HashMap) Map(java.util.Map) FieldMetadataOverride(org.broadleafcommerce.openadmin.dto.override.FieldMetadataOverride)

Example 4 with AdminPresentationMergeEntry

use of org.broadleafcommerce.common.presentation.override.AdminPresentationMergeEntry in project BroadleafCommerce by BroadleafCommerce.

the class MapFieldMetadataProvider method overrideMapMergeMetadata.

protected FieldMetadataOverride overrideMapMergeMetadata(AdminPresentationMergeOverride merge) {
    FieldMetadataOverride fieldMetadataOverride = new FieldMetadataOverride();
    Map<String, AdminPresentationMergeEntry> overrideValues = getAdminPresentationEntries(merge.mergeEntries());
    for (Map.Entry<String, AdminPresentationMergeEntry> entry : overrideValues.entrySet()) {
        String stringValue = entry.getValue().overrideValue();
        if (entry.getKey().equals(PropertyType.AdminPresentationMap.CURRENCYCODEFIELD)) {
            fieldMetadataOverride.setCurrencyCodeField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.CUSTOMCRITERIA)) {
            fieldMetadataOverride.setCustomCriteria(entry.getValue().stringArrayOverrideValue());
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.DELETEENTITYUPONREMOVE)) {
            fieldMetadataOverride.setDeleteEntityUponRemove(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.EXCLUDED)) {
            fieldMetadataOverride.setExcluded(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.FORCEFREEFORMKEYS)) {
            fieldMetadataOverride.setForceFreeFormKeys(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.FRIENDLYNAME)) {
            fieldMetadataOverride.setFriendlyName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.ISSIMPLEVALUE)) {
            fieldMetadataOverride.setSimpleValue(UnspecifiedBooleanType.valueOf(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.KEYCLASS)) {
            fieldMetadataOverride.setKeyClass(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.KEYPROPERTYFRIENDLYNAME)) {
            fieldMetadataOverride.setKeyPropertyFriendlyName(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.MAPKEYVALUEPROPERTY)) {
            fieldMetadataOverride.setMapKeyValueProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.KEYS)) {
            if (!ArrayUtils.isEmpty(entry.getValue().keys())) {
                String[][] keys = new String[entry.getValue().keys().length][2];
                for (int j = 0; j < keys.length; j++) {
                    keys[j][0] = entry.getValue().keys()[j].keyName();
                    keys[j][1] = entry.getValue().keys()[j].friendlyKeyName();
                }
                fieldMetadataOverride.setKeys(keys);
            }
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.MANYTOFIELD)) {
            fieldMetadataOverride.setManyToField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.MAPKEYOPTIONENTITYCLASS)) {
            fieldMetadataOverride.setMapKeyOptionEntityClass(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.MAPKEYOPTIONENTITYDISPLAYFIELD)) {
            fieldMetadataOverride.setMapKeyOptionEntityDisplayField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.MAPKEYOPTIONENTITYVALUEFIELD)) {
            fieldMetadataOverride.setMapKeyOptionEntityValueField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.MEDIAFIELD)) {
            fieldMetadataOverride.setMediaField(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.OPERATIONTYPES)) {
            AdminPresentationOperationTypes operationType = entry.getValue().operationTypes();
            fieldMetadataOverride.setAddType(operationType.addType());
            fieldMetadataOverride.setRemoveType(operationType.removeType());
            fieldMetadataOverride.setUpdateType(operationType.updateType());
            fieldMetadataOverride.setFetchType(operationType.fetchType());
            fieldMetadataOverride.setInspectType(operationType.inspectType());
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.ORDER)) {
            fieldMetadataOverride.setOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.READONLY)) {
            fieldMetadataOverride.setReadOnly(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.SECURITYLEVEL)) {
            fieldMetadataOverride.setSecurityLevel(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.SHOWIFPROPERTY)) {
            fieldMetadataOverride.setShowIfProperty(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.SHOWIFFIELDEQUALS)) {
            processShowIfFieldEqualsAnnotations(entry.getValue().showIfFieldEquals(), fieldMetadataOverride);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.TAB)) {
            fieldMetadataOverride.setTab(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.TABORDER)) {
            fieldMetadataOverride.setTabOrder(StringUtils.isEmpty(stringValue) ? entry.getValue().intOverrideValue() : Integer.parseInt(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.USESERVERSIDEINSPECTIONCACHE)) {
            fieldMetadataOverride.setUseServerSideInspectionCache(StringUtils.isEmpty(stringValue) ? entry.getValue().booleanOverrideValue() : Boolean.parseBoolean(stringValue));
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.VALUECLASS)) {
            fieldMetadataOverride.setValueClass(stringValue);
        } else if (entry.getKey().equals(PropertyType.AdminPresentationMap.VALUEPROPERTYFRIENDLYNAME)) {
            fieldMetadataOverride.setValuePropertyFriendlyName(stringValue);
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unrecognized type: " + entry.getKey() + ". Not setting on map field.");
            }
        }
    }
    return fieldMetadataOverride;
}
Also used : AdminPresentationMergeEntry(org.broadleafcommerce.common.presentation.override.AdminPresentationMergeEntry) AdminPresentationOperationTypes(org.broadleafcommerce.common.presentation.AdminPresentationOperationTypes) HashMap(java.util.HashMap) Map(java.util.Map) AdminPresentationMap(org.broadleafcommerce.common.presentation.AdminPresentationMap) FieldMetadataOverride(org.broadleafcommerce.openadmin.dto.override.FieldMetadataOverride)

Aggregations

HashMap (java.util.HashMap)4 Map (java.util.Map)4 AdminPresentationMergeEntry (org.broadleafcommerce.common.presentation.override.AdminPresentationMergeEntry)4 FieldMetadataOverride (org.broadleafcommerce.openadmin.dto.override.FieldMetadataOverride)4 AdminPresentationOperationTypes (org.broadleafcommerce.common.presentation.AdminPresentationOperationTypes)3 LinkedHashMap (java.util.LinkedHashMap)1 AdminPresentationMap (org.broadleafcommerce.common.presentation.AdminPresentationMap)1