public I18nExportColumn toI18nExportColumn() { return new I18nExportColumn(getCombinedName(), i18nKey, colWidth); }
@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 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; }
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); } }