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); } }
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 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); } }
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())); } }
@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); } } }