Example usage for org.apache.commons.lang BooleanUtils isTrue

List of usage examples for org.apache.commons.lang BooleanUtils isTrue

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils isTrue.

Prototype

public static boolean isTrue(Boolean bool) 

Source Link

Document

Checks if a Boolean value is true, handling null by returning false.

 BooleanUtils.isTrue(Boolean.TRUE)  = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null)          = false 

Usage

From source file:jp.primecloud.auto.ui.WinServerEdit.java

WinServerEdit(Application ap, Long instanceNo) {
    apl = ap;//from w ww.jav a2s .c  o m
    this.instanceNo = instanceNo;

    // ???
    initData();

    //
    setCaption(ViewProperties.getCaption("window.winServerEdit"));
    setModal(true);
    setWidth("600px");
    setIcon(Icons.EDITMINI.resource());

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setMargin(false, true, false, true);
    layout.setSpacing(true);

    //Tab?
    basicTab = new BasicTab();
    tab.addTab(basicTab, ViewProperties.getCaption("tab.basic"), Icons.BASIC.resource());
    layout.addComponent(tab);
    // ??
    basicTab.initValidation();
    // ?
    basicTab.showData();

    //Tab?
    String platformType = platformDto.getPlatform().getPlatformType();
    // TODO CLOUD BRANCHING
    if (PCCConstant.PLATFORM_TYPE_AWS.equals(platformType)) {
        awsDetailTab = new AWSDetailTab();
        tab.addTab(awsDetailTab, ViewProperties.getCaption("tab.detail"), Icons.DETAIL.resource());
        layout.addComponent(tab);
        // ??
        awsDetailTab.initValidation();
        // ?
        awsDetailTab.showData();
    } else if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platformType)) {
        vmwareDetailTab = new VMWareDetailTab();
        tab.addTab(vmwareDetailTab, ViewProperties.getCaption("tab.detail"), Icons.DETAIL.resource());
        // ??
        vmwareDetailTab.initValidation();
        // ?
        vmwareDetailTab.showData();

        boolean enableVmwareStaticIp = BooleanUtils.toBoolean(Config.getProperty("ui.enableVmwareEditIp"));
        if (BooleanUtils.isTrue(enableVmwareStaticIp)) {
            this.vmwareEditIpTab = new VmwareEditIpTab();
            tab.addTab(vmwareEditIpTab, ViewProperties.getCaption("tab.editIp"), Icons.DETAIL.resource());
            this.vmwareEditIpTab.showData();
            this.vmwareEditIpTab.initValidation();
        }

        layout.addComponent(tab);

    } else if (PCCConstant.PLATFORM_TYPE_NIFTY.equals(platformType)) {
        niftyDetailTab = new NiftyDetailTab();
        tab.addTab(niftyDetailTab, ViewProperties.getCaption("tab.detail"), Icons.DETAIL.resource());
        layout.addComponent(tab);
        // ??
        niftyDetailTab.initValidation();
        // ?
        niftyDetailTab.showData();

    } else if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platformType)) {
        cloudStackDetailTab = new CloudStackDetailTab();
        tab.addTab(cloudStackDetailTab, ViewProperties.getCaption("tab.detail"), Icons.DETAIL.resource());
        layout.addComponent(tab);
        // ??
        cloudStackDetailTab.initValidation();
        // ?
        cloudStackDetailTab.showData();
    } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platformType)) {
        //
        vcloudDetailTab = new VcloudDetailTab();
        tab.addTab(vcloudDetailTab, ViewProperties.getCaption("tab.detail"), Icons.DETAIL.resource());
        // ??
        vcloudDetailTab.initValidation();
        // ?
        vcloudDetailTab.showData();

        //?
        vcloudNetworkTab = new VcloudNetworkTab();
        tab.addTab(vcloudNetworkTab, ViewProperties.getCaption("tab.network"), Icons.DETAIL.resource());
        vcloudNetworkTab.showData();

        layout.addComponent(tab);
    } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platformType)) {
        azureDetailTab = new AzureDetailTab();
        tab.addTab(azureDetailTab, ViewProperties.getCaption("tab.detail"), Icons.DETAIL.resource());
        layout.addComponent(tab);
        // ??
        azureDetailTab.initValidation();
        // ?
        azureDetailTab.showData();
    } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platformType)) {
        openStackDetailTab = new OpenStackDetailTab();
        tab.addTab(openStackDetailTab, ViewProperties.getCaption("tab.detail"), Icons.DETAIL.resource());
        layout.addComponent(tab);
        // ??
        openStackDetailTab.initValidation();
        // ?
        openStackDetailTab.showData();
    }

    //        tab.addTab(new UserTab(), "", new ThemeResource("icons/user.png"));
    //        layout.addComponent(tab);

    // ??
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setSpacing(true);
    okbar.setMargin(false, false, true, false);
    layout.addComponent(okbar);
    layout.setComponentAlignment(okbar, Alignment.BOTTOM_RIGHT);

    // OK
    Button okButton = new Button(ViewProperties.getCaption("button.ok"));
    okButton.setDescription(ViewProperties.getCaption("description.editServer.ok"));
    okButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            okButtonClick(event);
        }
    });
    okbar.addComponent(okButton);
    // [Enter]?okButton
    okButton.setClickShortcut(KeyCode.ENTER);
    okButton.focus();

    Button cancelButton = new Button(ViewProperties.getCaption("button.cancel"));
    cancelButton.setDescription(ViewProperties.getCaption("description.cancel"));
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    okbar.addComponent(cancelButton);
}

From source file:com.haulmont.restapi.service.EntitiesControllerManager.java

protected String _loadEntitiesList(String queryString, @Nullable String viewName, @Nullable Integer limit,
        @Nullable Integer offset, @Nullable String sort, @Nullable Boolean returnNulls,
        @Nullable Boolean dynamicAttributes, @Nullable String modelVersion, MetaClass metaClass,
        Map<String, Object> queryParameters) {
    LoadContext<Entity> ctx = new LoadContext<>(metaClass);
    if (!Strings.isNullOrEmpty(sort)) {
        boolean descSortOrder = false;
        if (sort.startsWith("-")) {
            descSortOrder = true;/*  w  ww. j a v  a  2s  . c  om*/
            sort = sort.substring(1);
        } else if (sort.startsWith("+")) {
            sort = sort.substring(1);
        }
        queryString += " order by e." + sort + (descSortOrder ? " desc" : "");
    }
    LoadContext.Query query = new LoadContext.Query(queryString);
    if (limit != null) {
        query.setMaxResults(limit);
    } else {
        query.setMaxResults(persistenceManagerClient.getMaxFetchUI(metaClass.getName()));
    }
    if (offset != null) {
        query.setFirstResult(offset);
    }
    if (queryParameters != null) {
        query.setParameters(queryParameters);
    }
    ctx.setQuery(query);

    View view = null;
    if (!Strings.isNullOrEmpty(viewName)) {
        view = restControllerUtils.getView(metaClass, viewName);
        ctx.setView(view);
    }

    ctx.setLoadDynamicAttributes(BooleanUtils.isTrue(dynamicAttributes));

    List<Entity> entities = dataManager.loadList(ctx);
    entities.forEach(entity -> restControllerUtils.applyAttributesSecurity(entity));

    List<EntitySerializationOption> serializationOptions = new ArrayList<>();
    serializationOptions.add(EntitySerializationOption.SERIALIZE_INSTANCE_NAME);
    if (BooleanUtils.isTrue(returnNulls))
        serializationOptions.add(EntitySerializationOption.SERIALIZE_NULLS);

    String json = entitySerializationAPI.toJson(entities, view,
            serializationOptions.toArray(new EntitySerializationOption[0]));
    json = restControllerUtils.transformJsonIfRequired(metaClass.getName(), modelVersion,
            JsonTransformationDirection.TO_VERSION, json);
    return json;
}

From source file:com.evolveum.midpoint.repo.common.expression.Expression.java

private PrismValueDeltaSetTriple<V> evaluateExpressionEvaluators(
        ExpressionEvaluationContext contextWithProcessedVariables)
        throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException,
        ConfigurationException, SecurityViolationException {

    for (ExpressionEvaluator<?, ?> evaluator : evaluators) {
        PrismValueDeltaSetTriple<V> outputTriple = (PrismValueDeltaSetTriple<V>) evaluator
                .evaluate(contextWithProcessedVariables);
        if (outputTriple != null) {
            boolean allowEmptyRealValues = false;
            if (expressionType != null) {
                allowEmptyRealValues = BooleanUtils.isTrue(expressionType.isAllowEmptyValues());
            }/*from  w w w.  j a  v  a 2s.co  m*/
            outputTriple.removeEmptyValues(allowEmptyRealValues);
            if (InternalsConfig.consistencyChecks) {
                try {
                    outputTriple.checkConsistence();
                } catch (IllegalStateException e) {
                    throw new IllegalStateException(
                            e.getMessage() + "; in expression " + this + ", evaluator " + evaluator, e);
                }
            }
            return outputTriple;
        }
    }

    return null;

}

From source file:jp.primecloud.auto.process.InstanceProcess.java

public void stop(Long instanceNo) {
    Instance instance = instanceDao.read(instanceNo);
    if (instance == null) {
        // ????// ww w. ja  v  a2s.  c om
        throw new AutoException("EPROCESS-000002", instanceNo);
    }

    if (BooleanUtils.isTrue(instance.getEnabled())) {
        // ?????
        return;
    }

    //??
    Farm farm = farmDao.read(instance.getFarmNo());

    // ?
    LoggingUtils.setInstanceNo(instanceNo);
    LoggingUtils.setInstanceName(instance.getInstanceName());
    LoggingUtils.setInstanceType(processLogger.getInstanceType(instanceNo));
    LoggingUtils.setPlatformNo(instance.getPlatformNo());

    InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus());
    if (status != InstanceStatus.STOPPED && status != InstanceStatus.RUNNING
            && status != InstanceStatus.WARNING) {
        // ??????????
        if (log.isDebugEnabled()) {
            log.debug(MessageUtils.format("Instance {1} status is {2}.(instanceNo={0})", instanceNo,
                    instance.getInstanceName(), status));
        }
        return;
    }

    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100003", instanceNo, instance.getInstanceName()));
    }

    // ???
    instance.setStatus(InstanceStatus.STOPPING.toString());
    instanceDao.update(instance);

    // 
    processLogger.writeLogSupport(ProcessLogger.LOG_INFO, null, instance, "InstanceStop", null);

    try {
        // ?
        if (zabbixInstanceDao.countByInstanceNo(instanceNo) > 0) {
            zabbixHostProcess.stopHost(instanceNo);
        }
    } catch (RuntimeException e) {
        log.warn(e.getMessage());
    }

    // ???
    instance = instanceDao.read(instanceNo);
    instanceDao.update(instance);

    try {
        // ?
        if (puppetInstanceDao.countByInstanceNo(instanceNo) > 0) {
            puppetNodeProcess.stopNode(instanceNo);
        }
    } catch (RuntimeException e) {
        log.warn(e.getMessage());
    }

    // ???
    instance = instanceDao.read(instanceNo);
    instanceDao.update(instance);
    Platform platform = platformDao.read(instance.getPlatformNo());

    try {

        //?? AWS or Cloudstack or VCloud????
        // TODO CLOUD BRANCHING
        if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())
                || PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())
                || PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())
                || PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())
                || PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) {
            // DNS???
            dnsProcess.stopDns(platform, instanceNo);
        }

        // ??
        // TODO CLOUD BRANCHING
        if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())
                || PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())
                || PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())
                || PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())
                || PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) {
            // IaasGateway
            IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(farm.getUserNo(),
                    instance.getPlatformNo());
            gateway.stopInstance(instanceNo);

        } else if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platform.getPlatformType())) {
            //**********************************TODO IaasGateway?????
            // VMware??
            vmwareProcess.stop(instanceNo);
        } else if (PCCConstant.PLATFORM_TYPE_NIFTY.equals(platform.getPlatformType())) {
            //**********************************TODO IaasGateway?????
            // Nifty??
            niftyProcess.stop(instanceNo);
        }

    } catch (RuntimeException e) {
        instance = instanceDao.read(instanceNo);
        status = InstanceStatus.fromStatus(instance.getStatus());

        // 
        if (status == InstanceStatus.STOPPING) {
            processLogger.writeLogSupport(ProcessLogger.LOG_INFO, null, instance, "InstanceStopFail", null);
        } else if (status == InstanceStatus.CONFIGURING) {
            processLogger.writeLogSupport(ProcessLogger.LOG_INFO, null, instance, "InstanceReloadFail", null);
        }

        // ?
        instance.setStatus(InstanceStatus.WARNING.toString());
        instance.setEnabled(true);
        instanceDao.update(instance);

        throw e;
    }

    // 
    processLogger.writeLogSupport(ProcessLogger.LOG_INFO, null, instance, "InstanceStopFinish", null);

    // ???
    instance = instanceDao.read(instanceNo);
    instance.setStatus(InstanceStatus.STOPPED.toString());
    //??Warning????????Warning??????????????
    if (InstanceCoodinateStatus.fromStatus(instance.getCoodinateStatus()) == InstanceCoodinateStatus.WARNING) {
        instance.setCoodinateStatus(InstanceCoodinateStatus.UN_COODINATED.toString());
    }
    instanceDao.update(instance);

    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100004", instanceNo, instance.getInstanceName()));
    }
}

From source file:com.haulmont.cuba.web.app.folders.FolderEditWindow.java

protected void commit() {
    SearchFolder folder = (SearchFolder) FolderEditWindow.this.folder;
    if (StringUtils.trimToNull(nameField.getValue()) == null) {
        String msg = messages.getMainMessage("folders.folderEditWindow.emptyName");
        App.getInstance().getWindowManager().showNotification(msg, Frame.NotificationType.TRAY);
        return;/*from   w w  w  .  j  a v  a  2s . c o  m*/
    }
    folder.setName(nameField.getValue());
    folder.setTabName(tabNameField.getValue());

    if (sortOrderField.getValue() == null || "".equals(sortOrderField.getValue())) {
        folder.setSortOrder(null);
    } else {
        String value = sortOrderField.getValue();
        int sortOrder;
        try {
            sortOrder = Integer.parseInt(value);
        } catch (NumberFormatException e) {
            String msg = messages.getMainMessage("folders.folderEditWindow.invalidSortOrder");
            App.getInstance().getWindowManager().showNotification(msg, Frame.NotificationType.WARNING);
            return;
        }
        folder.setSortOrder(sortOrder);
    }

    Object parent = parentSelect.getValue();
    if (parent instanceof Folder)
        folder.setParent((Folder) parent);
    else
        folder.setParent(null);

    folder.setApplyDefault(Boolean.valueOf(applyDefaultCb.getValue().toString()));
    if (globalCb != null) {
        if (BooleanUtils.isTrue(globalCb.getValue())) {
            folder.setUser(null);
        } else {
            folder.setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
        }
    } else {
        folder.setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
    }

    if (presentation != null) {
        folder.setPresentation((Presentation) presentation.getValue());
    }

    FolderEditWindow.this.commitHandler.run();

    close();
}

From source file:jp.primecloud.auto.process.vmware.VmwareInitProcess.java

/**
 * TODO: /*  w  w  w. ja va 2  s .c  o m*/
 *
 * @param vmwareProcessClient
 * @param instanceNo
 * @param vmwareNetworkProcess
 */
public void initializeNetwork(VmwareProcessClient vmwareProcessClient, Long instanceNo,
        VmwareNetworkProcess vmwareNetworkProcess) {
    VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo);

    // VirtualMachine
    VirtualMachine machine = vmwareProcessClient.getVirtualMachine(vmwareInstance.getMachineName());

    // ExtraConfig
    Map<String, Object> extraConfigs = new LinkedHashMap<String, Object>();

    // ?????
    PlatformVmware platformVmware = platformVmwareDao.read(vmwareProcessClient.getPlatformNo());
    String publicNetworkName = platformVmware.getPublicNetwork();

    boolean configPublic = false;
    DistributedVirtualPortgroupInfo dvPortgroupInfo = null;
    String publicPortGroup = null;
    // ??
    dvPortgroupInfo = vmwareNetworkProcess.getDVPortgroupInfo(machine, publicNetworkName);
    // ???
    if (dvPortgroupInfo != null) {
        publicPortGroup = dvPortgroupInfo.getPortgroupKey();
    }

    int i = 1;
    for (VirtualDevice device : machine.getConfig().getHardware().getDevice()) {
        if (device instanceof VirtualEthernetCard) {
            VirtualEthernetCard ethernetCard = (VirtualEthernetCard) device;
            String networkName = null;
            String portGroup = null;
            if (ethernetCard.getBacking() instanceof VirtualEthernetCardNetworkBackingInfo) {
                VirtualEthernetCardNetworkBackingInfo backingInfo1 = (VirtualEthernetCardNetworkBackingInfo) ethernetCard
                        .getBacking();
                networkName = backingInfo1.getDeviceName();
            }
            if (ethernetCard.getBacking() instanceof VirtualEthernetCardDistributedVirtualPortBackingInfo) {
                VirtualEthernetCardDistributedVirtualPortBackingInfo backingInfo2 = (VirtualEthernetCardDistributedVirtualPortBackingInfo) ethernetCard
                        .getBacking();
                portGroup = backingInfo2.getPort().getPortgroupKey();
            }

            Map<String, String> map;
            if ((StringUtils.isNotEmpty(networkName) && StringUtils.equals(networkName, publicNetworkName))
                    || (StringUtils.isNotEmpty(portGroup) && StringUtils.equals(portGroup, publicPortGroup))) {
                // ????
                map = createPublicNetworkData(instanceNo, ethernetCard);
                configPublic = true;
            } else {
                // ???????IP
                map = createDhcpNetworkData(ethernetCard);
            }

            String networkData = convertMapToString(map);
            extraConfigs.put("guestinfo.network" + i, networkData);
            i++;
        }
    }

    // ??
    vmwareProcessClient.setExtraConfigVM(vmwareInstance.getMachineName(), extraConfigs);

    // ?
    if (configPublic) {
        VmwareAddress vmwareAddress = vmwareAddressDao.readByInstanceNo(instanceNo);
        if (vmwareAddress != null) {
            if (BooleanUtils.isTrue(vmwareAddress.getEnabled())) {
                // 
                Instance instance = instanceDao.read(instanceNo);
                processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance,
                        "VmwareNetworkCustomizeStatic",
                        new Object[] { vmwareInstance.getMachineName(), vmwareAddress.getIpAddress() });

                if (BooleanUtils.isNotTrue(vmwareAddress.getAssociated())) {
                    // 
                    vmwareAddress.setAssociated(true);
                    vmwareAddressDao.update(vmwareAddress);
                }

                // 
                if (log.isInfoEnabled()) {
                    log.info(MessageUtils.getMessage("IPROCESS-100445", vmwareInstance.getMachineName(),
                            vmwareAddress.getIpAddress()));
                }
            } else {
                // 
                Instance instance = instanceDao.read(instanceNo);
                processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance,
                        "VmwareNetworkCustomizeDhcp", new Object[] { vmwareInstance.getMachineName() });

                if (BooleanUtils.isTrue(vmwareAddress.getAssociated())) {
                    // 
                    vmwareAddress.setAssociated(false);
                    vmwareAddressDao.update(vmwareAddress);
                }

                // 
                if (log.isInfoEnabled()) {
                    log.info(MessageUtils.getMessage("IPROCESS-100446", vmwareInstance.getMachineName()));
                }
            }
        }
    }
}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

protected boolean hasModalWindow() {
    for (Map.Entry<Window, WindowOpenInfo> entry : windowOpenMode.entrySet()) {
        if (OpenMode.DIALOG == entry.getValue().getOpenMode()
                && BooleanUtils.isTrue(entry.getKey().getDialogOptions().getModal())) {
            return true;
        }/*from  w w  w . j  a v  a  2s.c o m*/
    }
    return false;
}

From source file:com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesManager.java

@SuppressWarnings("unchecked")
protected void doStoreDynamicAttributes(BaseGenericIdEntity entity) {
    final EntityManager em = persistence.getEntityManager();
    Map<String, CategoryAttributeValue> dynamicAttributes = entity.getDynamicAttributes();
    if (dynamicAttributes != null) {
        Map<String, CategoryAttributeValue> mergedDynamicAttributes = new HashMap<>();
        for (Map.Entry<String, CategoryAttributeValue> entry : dynamicAttributes.entrySet()) {
            CategoryAttributeValue categoryAttributeValue = entry.getValue();
            if (categoryAttributeValue.getCategoryAttribute() == null
                    && categoryAttributeValue.getCode() != null) {
                CategoryAttribute attribute = getAttributeForMetaClass(entity.getMetaClass(),
                        categoryAttributeValue.getCode());
                categoryAttributeValue.setCategoryAttribute(attribute);
            }/*from  w  ww  . j a  v a  2s.c  o m*/

            //remove deleted and empty attributes
            if (categoryAttributeValue.getDeleteTs() == null && categoryAttributeValue.getValue() != null) {
                if (entity instanceof BaseDbGeneratedIdEntity
                        && categoryAttributeValue.getObjectEntityId() == null) {
                    categoryAttributeValue.setObjectEntityId(referenceToEntitySupport.getReferenceId(entity));
                }
                CategoryAttributeValue mergedCategoryAttributeValue = em.merge(categoryAttributeValue);
                mergedCategoryAttributeValue
                        .setCategoryAttribute(categoryAttributeValue.getCategoryAttribute());

                //copy transient fields (for nested CAVs as well)
                mergedCategoryAttributeValue
                        .setTransientEntityValue(categoryAttributeValue.getTransientEntityValue());
                mergedCategoryAttributeValue
                        .setTransientCollectionValue(categoryAttributeValue.getTransientCollectionValue());
                if (BooleanUtils.isTrue(categoryAttributeValue.getCategoryAttribute().getIsCollection())
                        && categoryAttributeValue.getChildValues() != null) {
                    for (CategoryAttributeValue childCAV : categoryAttributeValue.getChildValues()) {
                        for (CategoryAttributeValue mergedChildCAV : mergedCategoryAttributeValue
                                .getChildValues()) {
                            if (mergedChildCAV.getId().equals(childCAV.getId())) {
                                mergedChildCAV.setTransientEntityValue(childCAV.getTransientEntityValue());
                                break;
                            }
                        }

                    }
                }

                if (BooleanUtils
                        .isTrue(mergedCategoryAttributeValue.getCategoryAttribute().getIsCollection())) {
                    storeCategoryAttributeValueWithCollectionType(mergedCategoryAttributeValue);
                }

                mergedDynamicAttributes.put(entry.getKey(), mergedCategoryAttributeValue);
            } else {
                em.remove(categoryAttributeValue);
            }
        }

        entity.setDynamicAttributes(mergedDynamicAttributes);
    }
}

From source file:com.haulmont.cuba.gui.xml.layout.loaders.FieldGroupLoader.java

protected List<FieldGroup.FieldConfig> loadDynamicAttributeFields(Datasource ds) {
    if (ds != null && metadataTools.isPersistent(ds.getMetaClass())) {
        String windowId = ComponentsHelper.getWindow(resultComponent).getId();

        Set<CategoryAttribute> attributesToShow = dynamicAttributesGuiTools
                .getAttributesToShowOnTheScreen(ds.getMetaClass(), windowId, resultComponent.getId());

        if (!attributesToShow.isEmpty()) {
            List<FieldGroup.FieldConfig> fields = new ArrayList<>();

            ds.setLoadDynamicAttributes(true);

            for (CategoryAttribute attribute : attributesToShow) {
                FieldGroup.FieldConfig field = resultComponent
                        .createField(DynamicAttributesUtils.encodeAttributeCode(attribute.getCode()));
                field.setProperty(DynamicAttributesUtils.encodeAttributeCode(attribute.getCode()));
                field.setCaption(attribute.getLocaleName());
                field.setDatasource(ds);
                field.setRequired(attribute.getRequired());
                field.setRequiredMessage(messages.formatMainMessage("validation.required.defaultMsg",
                        attribute.getLocaleName()));
                loadWidth(field, attribute.getWidth());

                // Currently, ListEditor does not support datasource binding so we create custom field
                if (BooleanUtils.isTrue(attribute.getIsCollection())) {
                    CustomFieldGenerator fieldGenerator = new DynamicAttributeCustomFieldGenerator();

                    Component fieldComponent = fieldGenerator.generateField(ds,
                            DynamicAttributesUtils.encodeAttributeCode(attribute.getCode()));
                    field.setCustom(true);
                    field.setComponent(fieldComponent);
                    applyPermissions(fieldComponent);
                }/*  www. j  av  a  2  s  .  co  m*/
                fields.add(field);
            }

            dynamicAttributesGuiTools.listenDynamicAttributesChanges(ds);
            return fields;
        }
    }
    return Collections.emptyList();
}

From source file:com.haulmont.cuba.gui.components.filter.edit.DynamicAttributesConditionFrame.java

protected void fillOperationSelect(CategoryAttribute categoryAttribute) {
    Class clazz = DynamicAttributesUtils.getAttributeClass(categoryAttribute);
    OpManager opManager = AppBeans.get(OpManager.class);
    EnumSet<Op> availableOps = BooleanUtils.isTrue(categoryAttribute.getIsCollection())
            ? opManager.availableOpsForCollectionDynamicAttribute()
            : opManager.availableOps(clazz);
    List<Op> ops = new LinkedList<>(availableOps);
    operationLookup.setOptionsList(ops);
    Op operator = condition.getOperator();
    if (operator != null) {
        operationLookup.setValue(operator);
    }/*from   w  ww . j a va2 s .  c o m*/
}