@Override public T apply(E entity) { return propertyPath != null ? entity.getValueEx(propertyPath) : null; } }
@Override public V getValue() { E item = datasource.getItem(); if (item != null) { return item.getValueEx(metaPropertyPath); } return null; }
@Override public Object getItemValue(Object itemId, Object propertyId) { MetaPropertyPath propertyPath = (MetaPropertyPath) propertyId; return container.getItem(itemId).getValueEx(propertyPath); }
@Override public Object getItemValue(Object itemId, Object propertyId) { MetaPropertyPath propertyPath = (MetaPropertyPath) propertyId; return datasource.getItemNN(itemId).getValueEx(propertyPath); }
@Override public V getValue() { E item = container.getItemOrNull(); if (item != null) { return item.getValueEx(metaPropertyPath); } return null; }
/** * Returns the value of entity property with the specified property name. * * @param property name of entity property * @return the value of entity property with the specified property name. * <ul> * <li>If property value is an instance of {@link Collection}, * then method returns {@link List} of {@link EntityDataItem}.</li> * <li>Otherwise method returns value by {@link Instance#getValue(java.lang.String)}</li> * </ul> */ @Override public Object getValue(String property) { Object value = item.getValueEx(property); if (value instanceof Collection) { List<DataItem> items = new ArrayList<>(); for (Object item : (Collection) value) { items.add(new EntityDataItem((Entity) item)); } return items; } return value; }
protected List<String> convertWhere(String tableAlias, FieldEntry fieldEntry, Entity entity) { List<String> where = new ArrayList<>(); if (fieldEntry.isEmbedded) { for (FieldEntry entry : fieldEntry.fieldsMapping.values()) { where.addAll(convertWhere(tableAlias, entry, entity)); } } else { where.add(tableAlias + "." + fieldEntry.columnName + " = " + convertValue(entity, fieldEntry.getFieldName(), entity.getValueEx(fieldEntry.getFieldName()))); } return where; }
protected Object getValueByProperty(E item, MetaPropertyPath property) { Preconditions.checkNotNullArgument(item); return item.getValueEx(property.toString()); }
protected Pair<List<String>, List<String>> getInsertStrings(FieldEntry fieldEntry, Entity entity) { List<String> columnNames = new ArrayList<>(); List<String> valuesStr = new ArrayList<>(); String fieldName = fieldEntry.getFieldName(); if (fieldEntry.isEmbedded) { for (FieldEntry entry : fieldEntry.fieldsMapping.values()) { Pair<List<String>, List<String>> insertStrings = getInsertStrings(entry, entity); columnNames.addAll(insertStrings.getFirst()); valuesStr.addAll(insertStrings.getSecond()); } } else { Object value = entity.getValueEx(fieldName); columnNames.add(fieldEntry.columnName); valuesStr.add(convertValue(entity, fieldName, value)); } return new Pair<>(columnNames, valuesStr); }
protected Pair<List<String>, List<String>> getUpdateStrings(FieldEntry fieldEntry, Entity entity) { List<String> valuesStr = new ArrayList<>(); List<String> whereStr = new ArrayList<>(); String fieldName = fieldEntry.getFieldName(); if (!fieldName.equalsIgnoreCase(ID)) { if (fieldEntry.isEmbedded) { for (FieldEntry entry : fieldEntry.fieldsMapping.values()) { Pair<List<String>, List<String>> updateStrings = getUpdateStrings(entry, entity); valuesStr.addAll(updateStrings.getSecond()); } } else { Object value = entity.getValueEx(fieldName); valuesStr.add(format("%s=%s", fieldEntry.columnName, convertValue(entity, fieldName, value))); } } else { if (fieldEntry.isEmbedded) { for (FieldEntry entry : fieldEntry.fieldsMapping.values()) { Pair<List<String>, List<String>> updateStrings = getUpdateStrings(entry, entity); whereStr.addAll(updateStrings.getFirst()); } } else { Object value = entity.getValueEx(fieldName); whereStr.add(format("%s=%s", fieldEntry.columnName, convertValue(entity, fieldName, value))); } } return new Pair<>(valuesStr, whereStr); }
@Override public String apply(Object o) { if (!(o instanceof Entity)) { return ""; } Entity entity = (Entity) o; if (captionMode == CaptionMode.PROPERTY && captionProperty != null) { if (entity.getMetaClass().getPropertyPath(captionProperty) == null) { throw new IllegalArgumentException(String.format("Couldn't find property with name '%s'", captionProperty)); } Object propertyValue = entity.getValueEx(captionProperty); return propertyValue != null ? propertyValue.toString() : " "; } return metadata.getTools().getInstanceName(entity); }
protected String createAllFieldContent(Entity entity, EntityDescr descr) throws IndexingException { StringBuilder sb = new StringBuilder(); for (String propName : descr.getLocalProperties()) { Object value = entity.getValueEx(propName); // using getValueEx() to support embedded entities String str = valueFormatter.format(value); if (str != null && !StringUtils.isBlank(str)) { if (ftsConfig.getStoreContentInIndex()) { appendString(sb, makeFieldName(propName)); } appendString(sb, str); } } if (entity instanceof FileDescriptor) { appendString(sb, makeFieldName(FTS.FILE_CONT_PROP)); sb.append(FTS.FIELD_SEP).append(((FileDescriptor) entity).getName().replaceAll("\\s+", FTS.FIELD_SEP)); appendFileContent(sb, (FileDescriptor) entity); } if (log.isTraceEnabled()) log.trace("Entity {} all field: {}", entity, sb.toString()); return sb.toString(); }
protected Object getValueByProperty(T item, MetaPropertyPath property) { Preconditions.checkNotNullArgument(item); if (property.getMetaProperties().length == 1) { return item.getValue(property.getMetaProperty().getName()); } else { return item.getValueEx(property); } }
Object value = item.getValueEx(propertyPath); String stringValue; if (value instanceof String) { stringValue = item.getValueEx(propertyPath); } else { if (DynamicAttributesUtils.isDynamicAttribute(propertyPath.getMetaProperty())) { Entity item = dataBinding.getTableItems().getItem(itemId); if (item != null) { Boolean value = item.getValueEx(propertyPath); if (BooleanUtils.isTrue(value)) { style = "boolean-cell boolean-cell-true";
/** * Set field's "required" flag to false if the value has been filtered by Row Level Security * This is necessary to allow user to submit form with filtered attribute even if attribute is required */ public static void handleFilteredAttributes(Field component, Datasource datasource, MetaPropertyPath mpp) { if (component.isRequired() && datasource.getState() == Datasource.State.VALID && datasource.getItem() != null && mpp.getMetaProperty().getRange().isClass()) { Entity targetItem = datasource.getItem(); MetaProperty[] propertiesChain = mpp.getMetaProperties(); if (propertiesChain.length > 1) { String basePropertyItem = Arrays.stream(propertiesChain) .limit(propertiesChain.length - 1) .map(MetadataObject::getName) .collect(Collectors.joining(".")); targetItem = datasource.getItem().getValueEx(basePropertyItem); } if (targetItem instanceof BaseGenericIdEntity) { String metaPropertyName = mpp.getMetaProperty().getName(); Object value = targetItem.getValue(metaPropertyName); BaseGenericIdEntity baseGenericIdEntity = (BaseGenericIdEntity) targetItem; String[] filteredAttributes = getFilteredAttributes(baseGenericIdEntity); if (value == null && filteredAttributes != null && ArrayUtils.contains(filteredAttributes, metaPropertyName)) { component.setRequired(false); } } } }
Collection<? extends V> itemValue = getItem().getValueEx(metaPropertyPath.toPathString()); Collection<V> oldValue = itemValue != null ? new ArrayList<>(itemValue) : null;
Collection<V> itemValue = getMaster().getItem().getValueEx(metaPropertyPath.toPathString()); Collection<V> oldValue = itemValue == null ? null
MetaProperty metaProperty = propertyPath.getMetaProperty(); String value = stringify(entity.getValueEx(name), metaProperty); attr.setValue(value); Object valueId = getValueId(entity.getValueEx(name)); if (valueId != null) attr.setValueId(valueId.toString());
if (StringUtils.isNotEmpty(captionProperty)) { E item = getItems().getItemNN(rowId); Object captionValue = item.getValueEx(captionProperty); return captionValue != null ? String.valueOf(captionValue) : null;
if (DynamicAttributesUtils.isDynamicAttribute(columnId)) { metaProperty = dynamicAttributesTools.getMetaPropertyPath(item.getMetaClass(), columnId).getMetaProperty(); value = dynamicAttributesTools.getDynamicAttributeValueAsString(metaProperty, item.getValueEx(columnId)); } else { value = item.getValueEx(columnId);