Search in sources :

Example 1 with GroupMetadata

use of org.broadleafcommerce.openadmin.dto.GroupMetadata in project BroadleafCommerce by BroadleafCommerce.

the class BasicEntityMetadataProvider method buildGroupFromMetadataOverride.

private void buildGroupFromMetadataOverride(String groupName, String tabName, GroupMetadataOverride override, Map<String, TabMetadata> metadata) {
    TabMetadata constructedTab = getTabFromMetadata(tabName, metadata);
    groupName = override.getName() == null || override.getName().isEmpty() ? groupName : override.getName();
    GroupMetadata group = new GroupMetadata();
    group.setGroupName(groupName);
    group.setGroupOrder(override.getOrder());
    group.setColumn(override.getColumn());
    group.setUntitled(override.getUntitled());
    group.setTooltip(override.getTooltip());
    group.setCollapsed(override.getCollapsed());
    constructedTab.getGroupMetadata().put(groupName, group);
}
Also used : GroupMetadata(org.broadleafcommerce.openadmin.dto.GroupMetadata) TabMetadata(org.broadleafcommerce.openadmin.dto.TabMetadata)

Example 2 with GroupMetadata

use of org.broadleafcommerce.openadmin.dto.GroupMetadata in project BroadleafCommerce by BroadleafCommerce.

the class BasicEntityMetadataProvider method buildTabFromMetadataOverride.

private void buildTabFromMetadataOverride(String tabName, MetadataOverride override, Map<String, TabMetadata> metadata) {
    tabName = override.getName() == null || override.getName().isEmpty() ? tabName : override.getName();
    TabMetadata tab = new TabMetadata();
    tab.setTabName(tabName);
    tab.setTabOrder(override.getOrder());
    tab.setGroupMetadata(new HashMap<String, GroupMetadata>());
    metadata.put(tabName, tab);
}
Also used : GroupMetadata(org.broadleafcommerce.openadmin.dto.GroupMetadata) TabMetadata(org.broadleafcommerce.openadmin.dto.TabMetadata)

Example 3 with GroupMetadata

use of org.broadleafcommerce.openadmin.dto.GroupMetadata in project BroadleafCommerce by BroadleafCommerce.

the class BasicEntityMetadataProvider method buildGroupMetadata.

protected GroupMetadata buildGroupMetadata(AdminGroupPresentation groupPresentation, Class<?> owningClass, Map<String, TabMetadata> metadata) {
    GroupMetadata group = new GroupMetadata();
    group.setOwningClass(owningClass.getCanonicalName());
    group.setGroupName(groupPresentation.name());
    group.setGroupOrder(groupPresentation.order());
    group.setColumn(groupPresentation.column());
    group.setUntitled(groupPresentation.untitled());
    group.setTooltip(groupPresentation.tooltip());
    group.setCollapsed(groupPresentation.collapsed());
    return group;
}
Also used : GroupMetadata(org.broadleafcommerce.openadmin.dto.GroupMetadata)

Example 4 with GroupMetadata

use of org.broadleafcommerce.openadmin.dto.GroupMetadata in project BroadleafCommerce by BroadleafCommerce.

the class BasicEntityMetadataProvider method addTabAndGroupMetadataFromCmdProperties.

@Override
public MetadataProviderResponse addTabAndGroupMetadataFromCmdProperties(ClassMetadata cmd, Map<String, TabMetadata> metadata) {
    for (Property p : cmd.getProperties()) {
        FieldMetadata fmd = p.getMetadata();
        boolean isExcluded = fmd.getExcluded() != null && fmd.getExcluded() == true;
        boolean isHidden = fmd instanceof BasicFieldMetadata && ((BasicFieldMetadata) fmd).getVisibility() != null && (((BasicFieldMetadata) fmd).getVisibility().equals(VisibilityEnum.HIDDEN_ALL) || ((BasicFieldMetadata) fmd).getVisibility().equals(VisibilityEnum.FORM_HIDDEN));
        if (!(isExcluded || isHidden)) {
            GroupMetadata groupMetadata = getGroupFromMetadata(fmd.getGroup(), metadata);
            if (groupMetadata == null) {
                TabMetadata tabMetadata = getTabFromMetadata(fmd.getTab(), metadata);
                Map<String, GroupMetadata> groupMetadataMap = tabMetadata == null || tabMetadata.getGroupMetadata() == null ? new HashMap<String, GroupMetadata>() : tabMetadata.getGroupMetadata();
                if (tabMetadata == null && !(fmd.getTab() == null || fmd.getTab().isEmpty())) {
                    tabMetadata = new TabMetadata();
                    tabMetadata.setTabName(fmd.getTab());
                    tabMetadata.setTabOrder(fmd.getTabOrder());
                    tabMetadata.setOwningClass(cmd.getPolymorphicEntities().getFullyQualifiedClassname());
                    tabMetadata.setGroupMetadata(groupMetadataMap);
                    metadata.put(fmd.getTab(), tabMetadata);
                }
                // is a collection being added to only the specified tab, not a group as well.
                if (!(fmd.getGroup() == null || fmd.getGroup().isEmpty())) {
                    groupMetadata = new GroupMetadata();
                    groupMetadata.setOwningClass(cmd.getPolymorphicEntities().getFullyQualifiedClassname());
                    groupMetadata.setGroupName(fmd.getGroup());
                    groupMetadata.setGroupOrder(fmd.getGroupOrder());
                    groupMetadata.setColumn(0);
                    groupMetadata.setUntitled(false);
                    groupMetadata.setCollapsed(false);
                    groupMetadataMap.put(fmd.getGroup(), groupMetadata);
                }
            }
        }
    }
    return MetadataProviderResponse.HANDLED;
}
Also used : FieldMetadata(org.broadleafcommerce.openadmin.dto.FieldMetadata) BasicFieldMetadata(org.broadleafcommerce.openadmin.dto.BasicFieldMetadata) BasicFieldMetadata(org.broadleafcommerce.openadmin.dto.BasicFieldMetadata) GroupMetadata(org.broadleafcommerce.openadmin.dto.GroupMetadata) TabMetadata(org.broadleafcommerce.openadmin.dto.TabMetadata) Property(org.broadleafcommerce.openadmin.dto.Property) FieldMetadataOverride(org.broadleafcommerce.openadmin.dto.override.FieldMetadataOverride) AdminTabPresentationOverride(org.broadleafcommerce.common.presentation.override.AdminTabPresentationOverride) AdminGroupPresentationOverride(org.broadleafcommerce.common.presentation.override.AdminGroupPresentationOverride) GroupMetadataOverride(org.broadleafcommerce.openadmin.dto.override.GroupMetadataOverride) MetadataOverride(org.broadleafcommerce.openadmin.dto.override.MetadataOverride)

Example 5 with GroupMetadata

use of org.broadleafcommerce.openadmin.dto.GroupMetadata in project BroadleafCommerce by BroadleafCommerce.

the class BasicEntityMetadataProvider method buildTabMetadata.

protected TabMetadata buildTabMetadata(AdminTabPresentation tabPresentation, Class<?> owningClass, Map<String, TabMetadata> metadata) {
    TabMetadata constructedTab = getTabFromMetadata(tabPresentation.name(), metadata);
    TabMetadata tab;
    Map<String, GroupMetadata> groupMetadataMap;
    if (constructedTab != null) {
        tab = constructedTab;
        groupMetadataMap = tab.getGroupMetadata();
    } else {
        tab = new TabMetadata();
        groupMetadataMap = new HashMap<>();
        tab.setTabName(tabPresentation.name());
        tab.setTabOrder(tabPresentation.order());
        tab.setOwningClass(owningClass.getCanonicalName());
    }
    for (AdminGroupPresentation groupPresentation : tabPresentation.groups()) {
        if (getGroupFromMetadata(groupPresentation.name(), metadata) == null) {
            groupMetadataMap.put(groupPresentation.name(), buildGroupMetadata(groupPresentation, owningClass, metadata));
        }
    }
    tab.setGroupMetadata(groupMetadataMap);
    return tab;
}
Also used : AdminGroupPresentation(org.broadleafcommerce.common.presentation.AdminGroupPresentation) GroupMetadata(org.broadleafcommerce.openadmin.dto.GroupMetadata) TabMetadata(org.broadleafcommerce.openadmin.dto.TabMetadata)

Aggregations

GroupMetadata (org.broadleafcommerce.openadmin.dto.GroupMetadata)6 TabMetadata (org.broadleafcommerce.openadmin.dto.TabMetadata)4 AdminGroupPresentation (org.broadleafcommerce.common.presentation.AdminGroupPresentation)1 AdminGroupPresentationOverride (org.broadleafcommerce.common.presentation.override.AdminGroupPresentationOverride)1 AdminTabPresentationOverride (org.broadleafcommerce.common.presentation.override.AdminTabPresentationOverride)1 BasicFieldMetadata (org.broadleafcommerce.openadmin.dto.BasicFieldMetadata)1 FieldMetadata (org.broadleafcommerce.openadmin.dto.FieldMetadata)1 Property (org.broadleafcommerce.openadmin.dto.Property)1 FieldMetadataOverride (org.broadleafcommerce.openadmin.dto.override.FieldMetadataOverride)1 GroupMetadataOverride (org.broadleafcommerce.openadmin.dto.override.GroupMetadataOverride)1 MetadataOverride (org.broadleafcommerce.openadmin.dto.override.MetadataOverride)1