@Nullable @Override public E getParent(E item) { Preconditions.checkNotNullArgument(item); return item.getValue(hierarchyProperty); } }
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); } }
@Override public boolean hasChildren(E item) { return container.getItems().stream().anyMatch(it -> { E parentItem = it.getValue(hierarchyProperty); return parentItem != null && parentItem.equals(item); }); }
protected Object getPropertyValue(Entity entity, MetaPropertyPath propertyPath) { return entity.getValue(propertyPath.toString()); } }
@Override public boolean hasChildren(E item) { return container.getItems().stream().anyMatch(it -> { E parentItem = it.getValue(hierarchyProperty); return parentItem != null && parentItem.equals(item); }); }
@Nullable @Override public E getParent(E item) { Preconditions.checkNotNullArgument(item, "item is null"); return item.getValue(hierarchyProperty); }
@Override public boolean hasChildren(K itemId) { final Entity item = getItem(itemId); if (item == null) return false; if (hierarchyPropertyName != null) { for (T currentItem : getItems()) { Object parentItem = currentItem.getValue(hierarchyPropertyName); if (parentItem != null && parentItem.equals(item)) return true; } } return false; }
@Override public Date getStart() { if (provider.getStartDateProperty() != null) { return entity.getValue(provider.getStartDateProperty()); } else { return null; } }
@Override public String getCaption() { if (provider.getCaptionProperty() != null) { return entity.getValue(provider.getCaptionProperty()); } else { return null; } }
@Override public String getStyleName() { if (provider.getStyleNameProperty() != null) { return entity.getValue(provider.getStyleNameProperty()); } else { return null; } }
@Override public Date getEnd() { if (provider.getEndDateProperty() != null) { return entity.getValue(provider.getEndDateProperty()); } else { return null; } }
@Override public String getDescription() { if (provider.getDescriptionProperty() != null) { return entity.getValue(provider.getDescriptionProperty()); } else { return null; } }
protected void writeSimpleProperty(JsonWriter out, Entity entity, MetaProperty property) throws IOException { Object value = entity.getValue(property.getName()); if (value != null) { out.name(property.getName()); Datatype datatype = Datatypes.get(property.getJavaType()); if (datatype != null) { out.value(datatype.format(value)); } else { out.value(String.valueOf(value)); } } }
@Override public boolean isAllDay() { if (provider.getIsAllDayProperty() != null) { return BooleanUtils.isTrue(entity.getValue(provider.getIsAllDayProperty())); } else { return false; } }
protected boolean checkIfEntityBelongsToMaster(MetaProperty property, Entity entityToRemove) { MetaProperty inverseProperty = property.getInverse(); if (inverseProperty != null && !inverseProperty.getRange().getCardinality().isMany()) { Entity master = entityToRemove.getValue(inverseProperty.getName()); return entity.equals(master); } else { return true; } }
protected void updateMaster() { MetaProperty masterProperty = getMasterProperty(); Collection masterCollection = master.getItem().getValue(masterProperty.getName()); updateMasterCollection(masterProperty, masterCollection, this.collection); }
protected String getFieldValue(String name) { if (datasource != null) { return datasource.getItem().getValue(name); } else if (window != null) { Field field = (Field) window.getComponentNN(name); return (String) field.getValue(); } else { return (String) fieldGroup.getFieldValue(name); } }
protected void checkRequiredAttributes(Entity entity) { SecurityState securityState = getSecurityState(entity); if (securityState != null && !securityState.getRequiredAttributes().isEmpty()) { for (MetaProperty metaProperty : entity.getMetaClass().getProperties()) { String propertyName = metaProperty.getName(); if (BaseEntityInternalAccess.isRequired(securityState, propertyName) && entity.getValue(propertyName) == null) { throw new RowLevelSecurityException(format("Attribute [%s] is required for entity %s", propertyName, entity), entity.getMetaClass().getName()); } } } }
protected Entity getReference(Entity entity, MetaProperty property) { if (PersistenceHelper.isLoaded(entity, property.getName())) return entity.getValue(property.getName()); else { Query query = entityManager.createQuery( "select e." + property.getName() + " from " + entity.getMetaClass().getName() + " e where e." + primaryKeyName + " = ?1"); query.setParameter(1, entity.getId()); Object refEntity = query.getFirstResult(); return (Entity) refEntity; } }
private void loadOne(EntityCrossDataStoreProperty entityCrossDataStoreProperty) { Entity entity = entityCrossDataStoreProperty.entity; CrossDataStoreProperty aProp = entityCrossDataStoreProperty.crossProp; Object id = entity.getValue(aProp.relatedPropertyName); LoadContext<Entity> loadContext = new LoadContext<>(aProp.property.getRange().asClass()); loadContext.setId(id); if (aProp.viewProperty.getView() != null) loadContext.setView(aProp.viewProperty.getView()); loadContext.setJoinTransaction(joinTransaction); Entity relatedEntity = dataManager.load(loadContext); entity.setValue(aProp.property.getName(), relatedEntity); }