/** * @see org.apache.wicket.model.IModel#getObject() */ @Override public T getObject() { return entity.getAttribute(propertyName, type); }
/** * @see org.apache.wicket.model.IModel#setObject(java.lang.Object) */ @Override public void setObject(final T object) { entity.putAttribute(propertyName, object); }
private List<T> getTimeableAttrRowsOfThisGroup() { return timeableService.getTimeableAttrRowsForGroup(entity, attrGroup); }
@Override public AttrGroup getAttrGroup(final EntityWithConfigurableAttr entity, final String groupName) { if (attrSchemata == null) { loadAttrSchema(); } final AttrSchema entitySchema = attrSchemata.get(entity.getAttrSchemaName()); return entitySchema .getGroups() .stream() .filter(group -> group.getName().equals(groupName)) .findFirst() .orElse(null); }
default void setAndOutputMarkupId(final Component component, final AttrGroup group, final AttrDescription desc) { component.setMarkupId(group.getName() + "-" + desc.getPropertyName()).setOutputMarkupId(true); } }
@Override public <PK extends Serializable, T extends TimeableAttrRow<PK>, U extends EntityWithTimeableAttr<PK, T> & EntityWithConfigurableAttr> Optional<IModel<String>> getStringAttribute(final U entity, final Date date, final String groupName, final String descName) { final T attrRowForCurrentDate = timeableService.getAttrRowValidAtDate(entity, groupName, date); if (attrRowForCurrentDate == null) { return Optional.empty(); } final String attribute = attrRowForCurrentDate.getStringAttribute(descName); if (attribute == null) { return Optional.empty(); } final AttrDescription attrDescription = getAttrDescription(entity, groupName, descName); final IModel<String> valueModel = (attrDescription.getWicketComponentFactoryClass() instanceof DropDownAttrWicketComponentFactory) ? new ResourceModel(attribute) : // DropDownAttrWicketComponentFactory -> it's a list of i18nkeys, so we need a ResourceModel for the translation new Model<>(attribute); return Optional.of(valueModel); }
@Override public <PK extends Serializable, T extends TimeableAttrRow<PK>, U extends EntityWithConfigurableAttr & EntityWithTimeableAttr<PK, T> & EntityWithAttributes> void createAttrPanels( final DivPanel divPanel, final U entity, final AbstractEditPage<?, ?, ?> parentPage, final Function<AttrGroup, T> addNewEntryFunction) { addHtmlClass(divPanel); final AttrSchema attrSchema = getAttrSchema(entity.getAttrSchemaName()); if (attrSchema == null) { return; } for (AttrGroup group : attrSchema.getGroups()) { createAttrPanel(divPanel, entity, parentPage, addNewEntryFunction, group); } }
@Override public <PK extends Serializable, T extends TimeableAttrRow<PK>, U extends EntityWithConfigurableAttr & EntityWithTimeableAttr<PK, T> & EntityWithAttributes> void createAttrPanels( final TabPanel tabPanel, final U entity, final AbstractEditPage<?, ?, ?> parentPage, final Function<AttrGroup, T> addNewEntryFunction) { final AttrSchema attrSchema = getAttrSchema(entity.getAttrSchemaName()); if (attrSchema == null) { return; } for (AttrGroup group : attrSchema.getGroups()) { final GridBuilder tabContainer = tabPanel.getOrCreateTab(group.getI18nKeySubmenu()); final DivPanel divPanel = tabContainer.getPanel(); if (!divPanel.hasChilds()) { // this panel is fresh, we have to add our css class addHtmlClass(divPanel); } createAttrPanel(divPanel, entity, parentPage, addNewEntryFunction, group); } }
@Override public AttrDescription getAttrDescription(final AttrGroup attrGroup, final String descriptionName) { return (attrGroup == null) ? null : attrGroup .getDescriptions() .stream() .filter(desc -> desc.getPropertyName().equals(descriptionName)) .findFirst() .orElse(null); } }
@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 VisitorbookTimedDO getNewestEntry(final VisitorbookDO visitor) { List<VisitorbookTimedDO> timeableAttributes = timeableService.getTimeableAttrRowsForGroupName(visitor, "timeofvisit"); if (timeableAttributes != null && timeableAttributes.size() > 0) { List<VisitorbookTimedDO> sortedList = timeableService.sortTimeableAttrRowsByDateDescending(timeableAttributes); return sortedList.get(0); } return null; }
private String getAttrValueForMonthAsString(EmployeeDO employee, String attrGroup, String attrProperty, Calendar selectedDate) { final EmployeeTimedDO attribute = timeableService.getAttrRowForSameMonth(employee, attrGroup, selectedDate.getTime()); return attribute != null ? attribute.getStringAttribute(attrProperty) : null; }
private T getAttrRowForCurrentDate(final List<T> attrRows) { return timeableService.getAttrRowValidAtDate(attrRows, attrGroup, new Date()); }
private void normalizeStartTime(final TimeableRow entity) { final Date oldStartTime = entity.getStartTime(); final Date newStartTime = DateHelper.convertMidnightDateToUTC(oldStartTime); entity.setStartTime(newStartTime); }
private ColumnMetadata getColumnMetadataFromColumnDesc(EntityMetadata entm, AttrDescription ad) { ColumnMetadataBean mb = new ColumnMetadataBean(entm); mb.setName(ad.getPropertyName()); mb.setJavaType(String.class); // TODO RK more fields return mb; }
@Override public Object getDisplayValue(T attrRow) { final Date startTime = attrRow.getStartTime(); return dateConverter.convertToString(startTime, null); }
private List<T> getTimeableAttrRowsOfThisGroupSorted() { return timeableService.sortTimeableAttrRowsByDateDescending(getTimeableAttrRowsOfThisGroup()); }
@Override public <PK extends Serializable, T extends TimeableAttrRow<PK>, U extends EntityWithConfigurableAttr & EntityWithTimeableAttr<PK, T>> void createTimedAttrPanels( final DivPanel divPanel, final U entity, final AbstractEditPage<?, ?, ?> parentPage, final Function<AttrGroup, T> addNewEntryFunction) { addHtmlClass(divPanel); final AttrSchema attrSchema = getAttrSchema(entity.getAttrSchemaName()); if (attrSchema == null) { return; } for (AttrGroup group : attrSchema.getGroups()) { createTimedAttrPanel(divPanel, entity, parentPage, addNewEntryFunction, group); } }
private BigDecimal getAttrValueForMonthAsBigDecimal(EmployeeDO employee, String attrGroupString, String attrProperty, Calendar selectedDate) { final EmployeeTimedDO attribute = timeableService.getAttrRowForSameMonth(employee, attrGroupString, selectedDate.getTime()); return attribute != null ? attribute.getAttribute(attrProperty, BigDecimal.class) : null; }
private String getAttribute(final EmployeeDO employee, final AttrColumnDescription desc) { final EmployeeTimedDO attrRow = timeableService.getAttrRowForSameMonth(employee, desc.getGroupName(), dateToSelectAttrRow); return attrRow.getStringAttribute(desc.getPropertyName()); } }