Search in sources :

Example 1 with EntityParameterValue

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);
    }
}
Also used : EntityListParameterValue(io.jmix.dashboards.model.parameter.type.EntityListParameterValue) EntityParameterValue(io.jmix.dashboards.model.parameter.type.EntityParameterValue) KeyValueEntity(io.jmix.core.entity.KeyValueEntity)

Example 2 with EntityParameterValue

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);
            }
        }
    }
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) java.util(java.util) io.jmix.ui.screen(io.jmix.ui.screen) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) ComboBox(io.jmix.ui.component.ComboBox) EntityParameterValue(io.jmix.dashboards.model.parameter.type.EntityParameterValue) Autowired(org.springframework.beans.factory.annotation.Autowired) io.jmix.core(io.jmix.core) ParameterValue(io.jmix.dashboards.model.parameter.type.ParameterValue) Collectors(java.util.stream.Collectors) EntityValues(io.jmix.core.entity.EntityValues) String.format(java.lang.String.format) MetaClass(io.jmix.core.metamodel.model.MetaClass)

Example 3 with EntityParameterValue

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;
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) EntityParameterValue(io.jmix.dashboards.model.parameter.type.EntityParameterValue)

Aggregations

EntityParameterValue (io.jmix.dashboards.model.parameter.type.EntityParameterValue)3 MetaClass (io.jmix.core.metamodel.model.MetaClass)2 io.jmix.core (io.jmix.core)1 EntityValues (io.jmix.core.entity.EntityValues)1 KeyValueEntity (io.jmix.core.entity.KeyValueEntity)1 EntityListParameterValue (io.jmix.dashboards.model.parameter.type.EntityListParameterValue)1 ParameterValue (io.jmix.dashboards.model.parameter.type.ParameterValue)1 ComboBox (io.jmix.ui.component.ComboBox)1 io.jmix.ui.screen (io.jmix.ui.screen)1 String.format (java.lang.String.format)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 StringUtils.isNotBlank (org.apache.commons.lang3.StringUtils.isNotBlank)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1