use of io.jmix.dynattr.model.CategoryAttribute in project jmix by jmix-framework.
the class DynAttrManagerImpl method fetchCollectionValues.
protected List<CategoryAttributeValue> fetchCollectionValues(List<CategoryAttributeValue> values) {
EntityManager entityManager = storeAwareLocator.getEntityManager(dynamicAttributesStore);
List<UUID> ids = values.stream().map(CategoryAttributeValue::getId).collect(Collectors.toList());
FetchPlan fetchPlan = fetchPlans.builder(CategoryAttributeValue.class).addFetchPlan(FetchPlan.LOCAL).add("childValues", FetchPlan.LOCAL).add("categoryAttribute", builder -> builder.addFetchPlan(FetchPlan.LOCAL).add("category")).build();
return entityManager.createQuery("select v from dynat_CategoryAttributeValue v where v.id in :ids", CategoryAttributeValue.class).setParameter("ids", ids).setHint(PersistenceHints.FETCH_PLAN, fetchPlan).getResultList();
}
use of io.jmix.dynattr.model.CategoryAttribute in project jmix by jmix-framework.
the class CategoryAttrsEdit method refreshCodeFieldValue.
protected void refreshCodeFieldValue() {
CategoryAttribute attribute = getEditedEntity();
if (Strings.isNullOrEmpty(attribute.getCode()) && !Strings.isNullOrEmpty(attribute.getName())) {
String categoryName = StringUtils.EMPTY;
if (attribute.getCategory() != null) {
categoryName = StringUtils.defaultString(attribute.getCategory().getName());
}
codeField.setValue(StringUtils.deleteWhitespace(categoryName + attribute.getName()));
}
}
use of io.jmix.dynattr.model.CategoryAttribute in project jmix by jmix-framework.
the class CategoryAttrsEdit method preCommitTargetScreensField.
protected void preCommitTargetScreensField(DataContext.PreCommitEvent event) {
CategoryAttribute attribute = getEditedEntity();
StringBuilder stringBuilder = new StringBuilder();
for (TargetScreenComponent targetScreenComponent : targetScreensDc.getItems()) {
if (StringUtils.isNotBlank(targetScreenComponent.getScreen())) {
stringBuilder.append(targetScreenComponent.getScreen());
if (StringUtils.isNotBlank(targetScreenComponent.getComponent())) {
stringBuilder.append("#");
stringBuilder.append(targetScreenComponent.getComponent());
}
stringBuilder.append(",");
}
}
if (stringBuilder.length() > 0) {
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
}
attribute.setTargetScreens(stringBuilder.toString());
}
use of io.jmix.dynattr.model.CategoryAttribute in project jmix by jmix-framework.
the class CategoryAttrsEdit method initDependsOnAttributesField.
@SuppressWarnings("unchecked")
protected void initDependsOnAttributesField() {
ValuesSelectAction<CategoryAttribute> selectAction = (ValuesSelectAction<CategoryAttribute>) dependsOnAttributesField.getActionNN("select");
selectAction.setOptions(new ListEntityOptions<>(getAttributesOptions(), metadata));
if (getEditedEntity().getConfiguration() != null && getEditedEntity().getConfiguration().getDependsOnAttributeCodes() != null) {
dependsOnAttributesField.setValue(getAttributesOptions().stream().filter(o -> getEditedEntity().getConfiguration().getDependsOnAttributeCodes().contains(o.getCode())).collect(Collectors.toList()));
}
CrudEntityContext crudEntityContext = new CrudEntityContext(configurationDc.getEntityMetaClass());
accessManager.applyRegisteredConstraints(crudEntityContext);
if (!crudEntityContext.isUpdatePermitted()) {
dependsOnAttributesField.setEnabled(false);
dependsOnAttributesFieldClear.setEnabled(false);
dependsOnAttributesFieldSelect.setEnabled(false);
}
}
use of io.jmix.dynattr.model.CategoryAttribute in project jmix by jmix-framework.
the class CategoryAttrsEdit method initCategoryAttributeConfigurationField.
protected void initCategoryAttributeConfigurationField() {
CategoryAttribute attribute = getEditedEntity();
CategoryAttributeConfiguration configuration = attribute.getConfiguration();
if (ENTITY.equals(attribute.getDataType()) && Boolean.TRUE.equals(attribute.getLookup()) && configuration.getOptionsLoaderType() == null) {
optionsLoaderTypeField.setValue(JPQL);
}
}
Aggregations