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;
}
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);
}
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);
}
}
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;
}
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;
}
Aggregations