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);
}
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);
}
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;
}
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);
}
}
}
}
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;
}
Aggregations