@Override protected void addMappings(PropertyMapping mapping, Object entry) { @SuppressWarnings("unchecked") final EntityWithTimeableAttr<PK, T> entity = (EntityWithTimeableAttr<PK, T>) entry; for (final AttrColumnDescription attrFieldToExport : attrFieldsToExport) { final T attrRow = timeableService.getAttrRowForSameMonth(entity, attrFieldToExport.getGroupName(), dateToSelectAttrRow); if (attrRow != null) { final String attributeValue = attrRow.getStringAttribute(attrFieldToExport.getPropertyName()); mapping.add(attrFieldToExport.getCombinedName(), attributeValue); } } }
private String getAttribute(final EmployeeDO employee, final AttrColumnDescription desc) { final EmployeeTimedDO attrRow = timeableService.getAttrRowForSameMonth(employee, desc.getGroupName(), dateToSelectAttrRow); return attrRow.getStringAttribute(desc.getPropertyName()); } }
private void createAttrColumns(ExtendEmployeeDataEnum eede, List<IColumn<EmployeeDO, String>> columns, boolean sortable, CellItemListener<EmployeeDO> cellItemListener) { if (eede != null) { columns.addAll( eede.getAttrColumnDescriptions() .stream() .map(desc -> new AttrInputCellItemListenerPropertyColumn<>( new ResourceModel(desc.getI18nKey()), getSortable(desc.getI18nKey(), sortable), desc.getGroupName(), desc.getPropertyName(), cellItemListener, timeableService, employeeService, guiAttrSchemaService, form.selectedMonth, form.selectedYear)) .collect(Collectors.toList())); } }
private List<AttrColumnDescription> importEmployeeBillings(final ExcelImport<EmployeeBillingExcelRow> importer) { final ImportedSheet<EmployeeDO> importedSheet = new ImportedSheet<>(); storage.addSheet(importedSheet); importedSheet.setName(NAME_OF_EXCEL_SHEET); importer.setNameRowIndex(ROW_INDEX_OF_COLUMN_NAMES); importer.setStartingRowIndex(ROW_INDEX_OF_COLUMN_NAMES + 1); // mapping from excel column name to the bean field name final Map<String, String> map = new HashMap<>(); map.put("Id", "id"); map.put(I18nHelper.getLocalizedMessage("fibu.employee.user"), "fullName"); ExtendEmployeeDataEnum.getAllAttrColumnDescriptions().forEach( desc -> map.put(I18nHelper.getLocalizedMessage(desc.getI18nKey()), desc.getCombinedName())); importer.setColumnMapping(map); final List<AttrColumnDescription> attrColumnsInSheet = getAttrColumnsUsedInSheet(importer); final EmployeeBillingExcelRow[] rows = importer.convertToRows(EmployeeBillingExcelRow.class); for (final EmployeeBillingExcelRow row : rows) { final ImportedElement<EmployeeDO> element = convertRowToDo(attrColumnsInSheet, row); importedSheet.addElement(element); } return attrColumnsInSheet; }
public I18nExportColumn toI18nExportColumn() { return new I18nExportColumn(getCombinedName(), i18nKey, colWidth); }
private List<AttrColumnDescription> getAttrColumnsUsedInSheet(ExcelImport<EmployeeBillingExcelRow> importer) { final List<String> columnNames = importer.getColumnNames(); return ExtendEmployeeDataEnum .getAllAttrColumnDescriptions() .stream() .filter(desc -> columnNames.contains(I18nHelper.getLocalizedMessage(desc.getI18nKey()))) .collect(Collectors.toList()); }
private PropertyDelta createPropertyDelta(final AttrColumnDescription colDesc) { final String fieldName = colDesc.getGroupName() + "." + colDesc.getPropertyName(); final T attrRow = timeableService.getAttrRowForSameMonth(value, colDesc.getGroupName(), dateToSelectAttrRow); final T oldAttrRow = timeableService.getAttrRowForSameMonth(oldValue, colDesc.getGroupName(), dateToSelectAttrRow); if (attrRow == null) { return null; } final Object newVal = attrRow.getAttribute(colDesc.getPropertyName()); final Object oldVal = (oldAttrRow == null) ? null : oldAttrRow.getAttribute(colDesc.getPropertyName()); if (newVal == null && oldVal == null) { return null; } final Class type = (newVal != null) ? newVal.getClass() : oldVal.getClass(); return createPropertyDelta(fieldName, newVal, oldVal, type).orElse(null); } }
@Override protected void addHeadColumns(final RepeatingView headColRepeater) { headColRepeater.add(new Label(headColRepeater.newChildId(), getString("id"))); headColRepeater.add(new Label(headColRepeater.newChildId(), getString("fibu.employee.user"))); final List<AttrColumnDescription> attrColumnsInSheet = parentPage.getAttrColumnsInSheet(); if (attrColumnsInSheet != null) { attrColumnsInSheet.forEach( desc -> headColRepeater.add(new Label(headColRepeater.newChildId(), getString(desc.getI18nKey()))) ); } }
private void getOrCreateAttrRowAndPutAttribute(final EmployeeDO employee, final AttrColumnDescription colDesc, final EmployeeBillingExcelRow row) { EmployeeTimedDO attrRow = timeableService.getAttrRowForSameMonth(employee, colDesc.getGroupName(), dateToSelectAttrRow); if (attrRow == null) { attrRow = employeeService.addNewTimeAttributeRow(employee, colDesc.getGroupName()); attrRow.setStartTime(dateToSelectAttrRow); } final Object fieldValue = PrivateBeanUtils.readField(row, colDesc.getCombinedName()); attrRow.putAttribute(colDesc.getPropertyName(), fieldValue); } }