Search in sources :

Example 1 with CategoryAttribute

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();
}
Also used : EntitySystemAccess(io.jmix.core.entity.EntitySystemAccess) MetaClass(io.jmix.core.metamodel.model.MetaClass) java.util(java.util) io.jmix.dynattr(io.jmix.dynattr) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) io.jmix.core(io.jmix.core) CrudEntityContext(io.jmix.core.accesscontext.CrudEntityContext) BooleanUtils(org.apache.commons.lang3.BooleanUtils) Multimap(com.google.common.collect.Multimap) EntityValues(io.jmix.core.entity.EntityValues) BigDecimal(java.math.BigDecimal) HashMultimap(com.google.common.collect.HashMultimap) CategoryAttribute(io.jmix.dynattr.model.CategoryAttribute) CategoryAttributeValue(io.jmix.dynattr.model.CategoryAttributeValue) Nullable(javax.annotation.Nullable) Logger(org.slf4j.Logger) PersistenceHints(io.jmix.data.PersistenceHints) EntityManager(javax.persistence.EntityManager) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) Stream(java.util.stream.Stream) LocalDate(java.time.LocalDate) ReflectionHelper(io.jmix.core.common.util.ReflectionHelper) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) AccessConstraint(io.jmix.core.constraint.AccessConstraint) StoreAwareLocator(io.jmix.data.StoreAwareLocator) EntityManager(javax.persistence.EntityManager) CategoryAttributeValue(io.jmix.dynattr.model.CategoryAttributeValue)

Example 2 with CategoryAttribute

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()));
    }
}
Also used : CategoryAttribute(io.jmix.dynattr.model.CategoryAttribute)

Example 3 with CategoryAttribute

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());
}
Also used : CategoryAttribute(io.jmix.dynattr.model.CategoryAttribute) TargetScreenComponent(io.jmix.dynattrui.impl.model.TargetScreenComponent)

Example 4 with CategoryAttribute

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);
    }
}
Also used : ValuesSelectAction(io.jmix.ui.action.valuespicker.ValuesSelectAction) CategoryAttribute(io.jmix.dynattr.model.CategoryAttribute) CrudEntityContext(io.jmix.core.accesscontext.CrudEntityContext)

Example 5 with CategoryAttribute

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);
    }
}
Also used : CategoryAttribute(io.jmix.dynattr.model.CategoryAttribute) CategoryAttributeConfiguration(io.jmix.dynattr.model.CategoryAttributeConfiguration)

Aggregations

CategoryAttribute (io.jmix.dynattr.model.CategoryAttribute)21 CategoryAttributeConfiguration (io.jmix.dynattr.model.CategoryAttributeConfiguration)8 MetaClass (io.jmix.core.metamodel.model.MetaClass)6 CrudEntityContext (io.jmix.core.accesscontext.CrudEntityContext)5 Multimap (com.google.common.collect.Multimap)4 io.jmix.core (io.jmix.core)4 BigDecimal (java.math.BigDecimal)4 LocalDate (java.time.LocalDate)4 java.util (java.util)4 Collectors (java.util.stream.Collectors)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 HashMultimap (com.google.common.collect.HashMultimap)3 ReflectionHelper (io.jmix.core.common.util.ReflectionHelper)3 AccessConstraint (io.jmix.core.constraint.AccessConstraint)3 EntitySystemAccess (io.jmix.core.entity.EntitySystemAccess)3 EntityValues (io.jmix.core.entity.EntityValues)3 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)3 PersistenceHints (io.jmix.data.PersistenceHints)3 StoreAwareLocator (io.jmix.data.StoreAwareLocator)3 io.jmix.dynattr (io.jmix.dynattr)3