use of io.jmix.dashboards.model.parameter.type.EntityParameterValue in project jmix by jmix-framework.
the class EntityListValueFragment method initDc.
protected void initDc(Map<String, Object> params) {
EntityListParameterValue value = (EntityListParameterValue) params.get(VALUE);
if (value == null || value.getEntityValues() == null) {
value = new EntityListParameterValue();
}
for (EntityParameterValue entityValue : value.getEntityValues()) {
KeyValueEntity keyValueEntity = createKeyValueEntity(entityValue);
entitiesDc.getMutableItems().add(keyValueEntity);
tableValues.put(keyValueEntity, entityValue);
}
}
use of io.jmix.dashboards.model.parameter.type.EntityParameterValue in project jmix by jmix-framework.
the class EntityValueFragment method selectIfExist.
public void selectIfExist(EntityParameterValue value) {
if (value != null && isNotBlank(value.getMetaClassName())) {
String metaClassName = value.getMetaClassName();
Optional<MetaClass> classOpt = metaClassComboBox.getOptions().getOptions().collect(Collectors.toList()).stream().filter(clazz -> metaClassName.equals(clazz.getName())).findFirst();
if (classOpt.isPresent()) {
MetaClass metaClass = classOpt.get();
metaClassComboBox.setValue(metaClass);
loadEntities(metaClass);
loadFetchPlans(metaClass);
String entityId = value.getEntityId();
if (isNotBlank(entityId)) {
entitiesComboBox.getOptions().getOptions().collect(Collectors.toList()).stream().filter(entity -> entityId.equals(EntityValues.getId(entity).toString())).findFirst().ifPresent(entity -> entitiesComboBox.setValue(entity));
}
String fetchPlan = value.getFetchPlanName();
if (isNotBlank(fetchPlan) && fetchPlanComboBox.getOptions().getOptions().anyMatch(e -> e.equals(fetchPlan))) {
fetchPlanComboBox.setValue(fetchPlan);
}
}
}
}
use of io.jmix.dashboards.model.parameter.type.EntityParameterValue in project jmix by jmix-framework.
the class EntityValueFragment method getValue.
@Override
public ParameterValue getValue() {
EntityParameterValue value = new EntityParameterValue();
MetaClass metaClass = metaClassComboBox.getValue();
if (metaClass != null) {
value.setMetaClassName(metaClass.getName());
Object entity = entitiesComboBox.getValue();
value.setEntityId(entity == null ? null : EntityValues.getId(entity).toString());
String fetchPlan = fetchPlanComboBox.getValue();
value.setFetchPlanName(fetchPlan);
}
return value;
}
Aggregations