public String getGroupPropertyPath() { return groupInfo.getProperty().toString(); } }
public Object getValue() { if (groupProperty == null) { throw new IllegalStateException(); } return getPropertyValue(groupProperty); }
@Override public int hashCode() { return toString().hashCode(); } }
protected GroupInfo<MetaPropertyPath> groupItems(int propertyIndex, GroupInfo parent, List<GroupInfo> children, T item, LinkedMap<MetaPropertyPath, Object> groupValues) { MetaPropertyPath property = (MetaPropertyPath) groupProperties[propertyIndex++]; Object itemValue = getValueByProperty(item, property); groupValues.put(property, itemValue); GroupInfo<MetaPropertyPath> groupInfo = new GroupInfo<>(groupValues); itemGroups.put(item.getId(), groupInfo); if (!parents.containsKey(groupInfo)) { parents.put(groupInfo, parent); } if (!children.contains(groupInfo)) { children.add(groupInfo); } List<GroupInfo> groupChildren = this.children.computeIfAbsent(groupInfo, k -> new ArrayList<>()); if (propertyIndex < groupProperties.length) { groupInfo = groupItems(propertyIndex, groupInfo, groupChildren, item, groupValues); } return groupInfo; }
protected GroupInfo<MetaPropertyPath> groupItems(int propertyIndex, GroupInfo parent, List<GroupInfo> children, E item, LinkedMap<MetaPropertyPath, Object> groupValues) { MetaPropertyPath property = (MetaPropertyPath) groupProperties[propertyIndex++]; Object itemValue = getValueByProperty(item, property); groupValues.put(property, itemValue); GroupInfo<MetaPropertyPath> groupInfo = new GroupInfo<>(groupValues); itemGroups.put(item.getId(), groupInfo); if (!parents.containsKey(groupInfo)) { parents.put(groupInfo, parent); } if (!children.contains(groupInfo)) { children.add(groupInfo); } List<GroupInfo> groupChildren = this.children.computeIfAbsent(groupInfo, k -> new ArrayList<>()); if (propertyIndex < groupProperties.length) { groupInfo = groupItems(propertyIndex, groupInfo, groupChildren, item, groupValues); } return groupInfo; }
@Override public Object getGroupProperty(GroupInfo groupId) { if (containsGroup(groupId)) { return groupId.getProperty(); } return null; }
@Override public Object getGroupPropertyValue(GroupInfo groupId) { if (containsGroup(groupId)) { return groupId.getValue(); } return null; }
public Object getGroupProperty(GroupInfo groupId) { if (containsGroup(groupId)) { return groupId.getProperty(); } return null; }
public Object getGroupPropertyValue(GroupInfo groupId) { if (containsGroup(groupId)) { return groupId.getValue(); } return null; }
protected void doGroupSort(CollectionDatasource.Sortable.SortInfo<MetaPropertyPath>[] sortInfo) { if (hasGroups()) { MetaPropertyPath propertyPath = sortInfo[0].getPropertyPath(); boolean asc = CollectionDatasource.Sortable.Order.ASC.equals(sortInfo[0].getOrder()); int index = ArrayUtils.indexOf(groupProperties, propertyPath); if (index > -1) { if (index == 0) { // Sort roots roots.sort(new GroupInfoComparator(asc)); } else { Object parentProperty = groupProperties[index - 1]; for (Map.Entry<GroupInfo, List<GroupInfo>> entry : children.entrySet()) { Object property = entry.getKey().getProperty(); if (property.equals(parentProperty)) { entry.getValue().sort(new GroupInfoComparator(asc)); } } } } else { Set<GroupInfo> groups = parents.keySet(); for (GroupInfo groupInfo : groups) { List<K> items = groupItems.get(groupInfo); if (items != null) { items.sort(new EntityByIdComparator<>(propertyPath, datasource, asc)); } } } } }
if (i == initialGroupNumber) { HSSFCell cell = row.createCell(i); Object val = groupInfo.getValue();
Object parentProperty = groupProperties[index - 1]; for (Map.Entry<GroupInfo, List<GroupInfo>> entry : children.entrySet()) { Object property = entry.getKey().getProperty(); if (property.equals(parentProperty)) { entry.getValue().sort(new GroupInfoComparator(asc));
protected String formatGroupPropertyValue(GroupInfo<MetaPropertyPath> groupId, @Nullable Object value) { if (value == null) { return ""; } MetaPropertyPath propertyPath = groupId.getProperty(); Table.Column<E> column = columns.get(propertyPath); if (column != null && column.getXmlDescriptor() != null) { String captionProperty = column.getXmlDescriptor().attributeValue("captionProperty"); // vaadin8 move to Column if (column.getFormatter() != null) { return column.getFormatter().apply(value); } else if (StringUtils.isNotEmpty(captionProperty)) { Collection<?> children = component.getGroupItemIds(groupId); if (children.isEmpty()) { return null; } Object itemId = children.iterator().next(); TableDataContainer container = (TableDataContainer) component.getContainerDataSource(); Instance item = (Instance) container.getInternalItem(itemId); Object captionValue = item.getValueEx(captionProperty); // vaadin8 use metadataTools format with metaproperty return metadataTools.format(captionValue); } } return metadataTools.format(value, propertyPath.getMetaProperty()); }