Search in sources :

Example 11 with KeyValueEntity

use of io.jmix.core.entity.KeyValueEntity in project jmix by jmix-framework.

the class EntityListValueFragment method createKeyValueEntity.

protected KeyValueEntity createKeyValueEntity(EntityParameterValue value) {
    KeyValueEntity keyValueEntity = metadata.create(KeyValueEntity.class);
    keyValueEntity.setValue("metaClassName", value.getMetaClassName());
    keyValueEntity.setValue("entityId", value.getEntityId());
    keyValueEntity.setValue("fetchPlanName", value.getFetchPlanName());
    return keyValueEntity;
}
Also used : KeyValueEntity(io.jmix.core.entity.KeyValueEntity)

Example 12 with KeyValueEntity

use of io.jmix.core.entity.KeyValueEntity in project jmix by jmix-framework.

the class EntityListValueFragment method saveWindowValue.

protected void saveWindowValue(EntityParameterValue windowValue) {
    if (oldValue != null) {
        entitiesDc.getMutableItems().remove(oldValue);
        tableValues.remove(oldValue);
        oldValue = null;
    }
    KeyValueEntity newValue = EntityListValueFragment.this.createKeyValueEntity(windowValue);
    entitiesDc.getMutableItems().add(newValue);
    tableValues.put(newValue, windowValue);
}
Also used : KeyValueEntity(io.jmix.core.entity.KeyValueEntity)

Example 13 with KeyValueEntity

use of io.jmix.core.entity.KeyValueEntity 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 14 with KeyValueEntity

use of io.jmix.core.entity.KeyValueEntity in project jmix by jmix-framework.

the class RandomPivotTableDataGenerator method generate.

public List<KeyValueEntity> generate(PivotTableDescription description, int size) {
    List<KeyValueEntity> result = new ArrayList<>(size);
    List<String> aggregationProperties = description.getAggregationProperties();
    for (int i = 0; i < size; i++) {
        KeyValueEntity entity = metadata.create(KeyValueEntity.class);
        for (PivotTableProperty property : description.getProperties()) {
            entity.setValue(property.getName(), generatePropertyValue(property.getName(), aggregationProperties.contains(property.getName()), size));
        }
        result.add(entity);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) KeyValueEntity(io.jmix.core.entity.KeyValueEntity) PivotTableProperty(io.jmix.reports.entity.pivottable.PivotTableProperty)

Example 15 with KeyValueEntity

use of io.jmix.core.entity.KeyValueEntity in project jmix by jmix-framework.

the class KeyValueMapper method mapToKeyValueEntity.

protected KeyValueEntity mapToKeyValueEntity(Object object, String idProperty, List<String> properties, List<Integer> deniedProperties) {
    // noinspection JmixIncorrectCreateEntity
    KeyValueEntity entity = new KeyValueEntity();
    entity.setIdName(idProperty);
    if (object instanceof Object[]) {
        Object[] array = (Object[]) object;
        for (int i = 0; i < properties.size(); i++) {
            String key = properties.get(i);
            if (array.length > i) {
                if (deniedProperties.contains(i)) {
                    entity.setValue(key, null);
                } else {
                    entity.setValue(key, array[i]);
                }
            }
        }
    } else if (!properties.isEmpty()) {
        if (!deniedProperties.isEmpty()) {
            entity.setValue(properties.get(0), null);
        } else {
            entity.setValue(properties.get(0), object);
        }
    }
    return entity;
}
Also used : KeyValueEntity(io.jmix.core.entity.KeyValueEntity)

Aggregations

KeyValueEntity (io.jmix.core.entity.KeyValueEntity)23 ValueLoadContext (io.jmix.core.ValueLoadContext)3 MetaClass (io.jmix.core.metamodel.model.MetaClass)3 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)3 EntityMap (io.jmix.reports.app.EntityMap)2 JmixTableData (io.jmix.reports.entity.JmixTableData)2 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 EntityManager (javax.persistence.EntityManager)2 Query (javax.persistence.Query)2 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)2 ValueLoadContext (com.haulmont.cuba.core.global.ValueLoadContext)1 BandData (com.haulmont.yarg.structure.BandData)1 Customer (dataaccess.ex1.entity.Customer)1 Customer (datamodel.ex1.entity.Customer)1 DataManager (io.jmix.core.DataManager)1 Entity (io.jmix.core.Entity)1 Metadata (io.jmix.core.Metadata)1 MetadataTools (io.jmix.core.MetadataTools)1 EntityListParameterValue (io.jmix.dashboards.model.parameter.type.EntityListParameterValue)1