Search in sources :

Example 1 with TabMetadata

use of org.broadleafcommerce.openadmin.dto.TabMetadata 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 TabMetadata

use of org.broadleafcommerce.openadmin.dto.TabMetadata 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 TabMetadata

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

the class AdminEntityServiceImpl method getRecordsForSelectedTab.

@Override
public Map<String, DynamicResultSet> getRecordsForSelectedTab(ClassMetadata cmd, Entity containingEntity, List<SectionCrumb> sectionCrumb, String currentTabName) throws ServiceException {
    Map<String, DynamicResultSet> map = new HashMap<String, DynamicResultSet>();
    for (Property p : cmd.getProperties()) {
        if (ArrayUtils.contains(p.getMetadata().getAvailableToTypes(), containingEntity.getType()[0]) && p.getMetadata() instanceof CollectionMetadata) {
            CollectionMetadata collectionMetadata = (CollectionMetadata) p.getMetadata();
            // Give preference to the Group since EntityForm.addListGrid() gives preference to the Group
            TabMetadata tabMetadata = cmd.getTabMetadataUsingGroupKey(collectionMetadata.getGroup());
            if (tabMetadata == null) {
                tabMetadata = cmd.getTabMetadataUsingTabKey(collectionMetadata.getTab());
            }
            String tabName = tabMetadata == null ? collectionMetadata.getTab() : tabMetadata.getTabName();
            int tabOrder = tabMetadata == null ? collectionMetadata.getTabOrder() : tabMetadata.getTabOrder();
            updateTabInfo(collectionMetadata, cmd, tabName, tabOrder);
            if (collectionMetadata.getLazyFetch() != null && collectionMetadata.getLazyFetch() && tabName.toUpperCase().startsWith(currentTabName.toUpperCase()) && !collectionMetadata.getManualFetch()) {
                PersistenceResponse response2 = getRecordsForCollection(cmd, containingEntity, p, null, null, null, sectionCrumb);
                map.put(p.getName(), response2.getDynamicResultSet());
            } else if (collectionMetadata.getLazyFetch() != null && !collectionMetadata.getLazyFetch() && !collectionMetadata.getManualFetch()) {
                PersistenceResponse response2 = getRecordsForCollection(cmd, containingEntity, p, null, null, null, sectionCrumb);
                map.put(p.getName(), response2.getDynamicResultSet());
            } else {
                DynamicResultSet drs = new DynamicResultSet();
                Map<String, Tab> tabMap = new HashMap<String, Tab>();
                Tab tab = new Tab();
                tab.setKey(tabName);
                tab.setTitle(BLCMessageUtils.getMessage(tabName));
                tab.setOrder(tabOrder);
                tabMap.put(tab.getTitle(), tab);
                drs.setUnselectedTabMetadata(tabMap);
                drs.setTotalRecords(0);
                drs.setStartIndex(0);
                drs.setBatchId(1);
                drs.setClassMetaData(null);
                drs.setPageSize(1);
                drs.setRecords(new Entity[0]);
                map.put(p.getName(), drs);
            }
        }
    }
    return map;
}
Also used : AdminMainEntity(org.broadleafcommerce.common.admin.domain.AdminMainEntity) Entity(org.broadleafcommerce.openadmin.dto.Entity) BasicCollectionMetadata(org.broadleafcommerce.openadmin.dto.BasicCollectionMetadata) CollectionMetadata(org.broadleafcommerce.openadmin.dto.CollectionMetadata) AdornedTargetCollectionMetadata(org.broadleafcommerce.openadmin.dto.AdornedTargetCollectionMetadata) HashMap(java.util.HashMap) PersistenceResponse(org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse) Tab(org.broadleafcommerce.openadmin.web.form.entity.Tab) TabMetadata(org.broadleafcommerce.openadmin.dto.TabMetadata) DynamicResultSet(org.broadleafcommerce.openadmin.dto.DynamicResultSet) BLCSystemProperty(org.broadleafcommerce.common.util.BLCSystemProperty) Property(org.broadleafcommerce.openadmin.dto.Property) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with TabMetadata

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

the class FormBuilderServiceImpl method setEntityFormTabsAndGroups.

/**
 * NOTE: This method will attempt to merge tabs if the unprocessed {@link TabMetadata#getTabName()} is equal to
 *  the processed value of another tab.
 *
 * For example, if {@link TabMetadata#getTabName()} is "Example", there is a another tab where
 *  {@link 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 void setEntityFormTabsAndGroups(EntityForm ef, Map<String, TabMetadata> tabMetadataMap) {
    if (tabMetadataMap != null) {
        Set<String> tabMetadataKeySet = tabMetadataMap.keySet();
        for (String tabKey : tabMetadataKeySet) {
            TabMetadata tabMetadata = tabMetadataMap.get(tabKey);
            String unprocessedTabName = getUnprocessedNameOfMatchingTab(tabMetadata, tabMetadataKeySet);
            if (foundMatchingTab(unprocessedTabName)) {
                if (!tabExists(ef, unprocessedTabName)) {
                    TabMetadata originalTabMetadata = tabMetadataMap.get(unprocessedTabName);
                    unprocessedTabName = ef.addTabFromTabMetadata(originalTabMetadata);
                }
            } else {
                if (tabExists(ef, tabKey)) {
                    unprocessedTabName = tabKey;
                } else {
                    unprocessedTabName = ef.addTabFromTabMetadata(tabMetadata);
                }
            }
            Set<String> groupMetadataKeySet = tabMetadata.getGroupMetadata().keySet();
            for (String groupKey : groupMetadataKeySet) {
                ef.addGroupFromGroupMetadata(tabMetadata.getGroupMetadata().get(groupKey), unprocessedTabName);
            }
        }
    }
}
Also used : TabMetadata(org.broadleafcommerce.openadmin.dto.TabMetadata)

Example 5 with TabMetadata

use of org.broadleafcommerce.openadmin.dto.TabMetadata 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)

Aggregations

TabMetadata (org.broadleafcommerce.openadmin.dto.TabMetadata)6 GroupMetadata (org.broadleafcommerce.openadmin.dto.GroupMetadata)4 Property (org.broadleafcommerce.openadmin.dto.Property)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AdminMainEntity (org.broadleafcommerce.common.admin.domain.AdminMainEntity)1 AdminGroupPresentation (org.broadleafcommerce.common.presentation.AdminGroupPresentation)1 AdminGroupPresentationOverride (org.broadleafcommerce.common.presentation.override.AdminGroupPresentationOverride)1 AdminTabPresentationOverride (org.broadleafcommerce.common.presentation.override.AdminTabPresentationOverride)1 BLCSystemProperty (org.broadleafcommerce.common.util.BLCSystemProperty)1 AdornedTargetCollectionMetadata (org.broadleafcommerce.openadmin.dto.AdornedTargetCollectionMetadata)1 BasicCollectionMetadata (org.broadleafcommerce.openadmin.dto.BasicCollectionMetadata)1 BasicFieldMetadata (org.broadleafcommerce.openadmin.dto.BasicFieldMetadata)1 CollectionMetadata (org.broadleafcommerce.openadmin.dto.CollectionMetadata)1 DynamicResultSet (org.broadleafcommerce.openadmin.dto.DynamicResultSet)1 Entity (org.broadleafcommerce.openadmin.dto.Entity)1 FieldMetadata (org.broadleafcommerce.openadmin.dto.FieldMetadata)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