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:com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.java

protected void setFilterActionsEnabled() {
    boolean isGlobal = filterEntity.getUser() == null;
    boolean userCanEditGlobalFilter = uerCanEditGlobalFilter();
    boolean userCanEditFilters = userCanEditFilers();
    boolean filterEditable = isEditable();
    boolean userCanEditGlobalAppFolder = userSessionSource.getUserSession()
            .isSpecificPermitted(GLOBAL_APP_FOLDERS_PERMISSION);
    boolean createdByCurrentUser = userSessionSource.getUserSession().getCurrentOrSubstitutedUser()
            .equals(filterEntity.getUser());
    boolean hasCode = !Strings.isNullOrEmpty(filterEntity.getCode());
    boolean isFolder = filterEntity.getFolder() != null;
    boolean isSearchFolder = isFolder && (filterEntity.getFolder() instanceof SearchFolder);
    boolean isAppFolder = isFolder && (filterEntity.getFolder() instanceof AppFolder);
    boolean isSet = BooleanUtils.isTrue(filterEntity.getIsSet());
    boolean isDefault = BooleanUtils.isTrue(filterEntity.getIsDefault());
    boolean isAdHocFilter = filterEntity == adHocFilter;

    boolean editActionEnabled = !isSet && filterEditable && userCanEditFilters
            && (!isGlobal || userCanEditGlobalFilter);
    filterSavingPossible = editActionEnabled
            && ((isGlobal && userCanEditGlobalFilter) || (!isGlobal && createdByCurrentUser))
            && ((!isFolder && !hasCode) || isSearchFolder || (isAppFolder && userCanEditGlobalAppFolder));
    boolean saveActionEnabled = filterSavingPossible && (isFolder || isFilterModified());
    boolean saveAsActionEnabled = !isSet && filterEditable && userCanEditFilters;
    boolean removeActionEnabled = !isSet && (!hasCode && !isFolder)
            && ((isGlobal && userCanEditGlobalFilter) || (!isGlobal && createdByCurrentUser)) && !isAdHocFilter
            && filterEditable && userCanEditFilters;
    boolean makeDefaultActionEnabled = !isDefault && !isFolder && !isSet && !isAdHocFilter
            && (!isGlobal || userCanEditGlobalFilter);
    boolean pinAppliedActionEnabled = lastAppliedFilter != null
            && !(lastAppliedFilter.getFilterEntity() == adHocFilter
                    && lastAppliedFilter.getConditions().getRoots().size() == 0)
            && (datasource == null
                    || Stores.isMain(metadata.getTools().getStoreName(datasource.getMetaClass())));
    boolean saveAsSearchFolderActionEnabled = folderActionsEnabled && !isFolder && !hasCode;
    boolean saveAsAppFolderActionEnabled = folderActionsEnabled && !isFolder && !hasCode
            && userCanEditGlobalAppFolder;

    saveAction.setEnabled(saveActionEnabled);
    saveWithValuesAction.setEnabled(filterSavingPossible && !conditions.toConditionsList().isEmpty());
    saveAsAction.setEnabled(saveAsActionEnabled);
    editAction.setEnabled(editActionEnabled);
    removeAction.setEnabled(removeActionEnabled);
    makeDefaultAction.setEnabled(makeDefaultActionEnabled);
    pinAppliedAction.setEnabled(pinAppliedActionEnabled);
    saveAsSearchFolderAction.setEnabled(saveAsSearchFolderActionEnabled);
    saveAsAppFolderAction.setEnabled(saveAsAppFolderActionEnabled);

    if (filterHelper.isTableActionsEnabled()) {
        fillTableActions();//w ww  .j a v  a2s .c o  m
    }
}

From source file:com.evolveum.midpoint.model.impl.lens.projector.focus.ObjectTemplateProcessor.java

private boolean autoassignEnabled(PrismObject<SystemConfigurationType> systemConfiguration) {
    if (systemConfiguration == null) {
        return false;
    }/*from   www .j a v  a2 s  .  c  o  m*/
    RoleManagementConfigurationType roleManagement = systemConfiguration.asObjectable().getRoleManagement();
    if (roleManagement == null) {
        return false;
    }
    return BooleanUtils.isTrue(roleManagement.isAutoassignEnabled());
}

From source file:com.wineaccess.winepermit.WinePermitHelper.java

/**
 * @param optionSelectedNoPermit/*  w  w w  . j  a v a2 s  . c o m*/
 * @param wineId
 */
private void validateoptionSelectedNoPermit(Boolean isOptionSelectedNoPermit,
        List<OptionSelectedNoPermit> optionSelectedNoPermit, String wineId) {

    int numberOfItems = optionSelectedNoPermit.size();
    if (BooleanUtils.isTrue(isOptionSelectedNoPermit) && numberOfItems == 0)
        response.addError(new WineaccessError(SystemErrorCode.WINE_PERMIT_SELECT_VALUE_NO_PERMIT,
                SystemErrorCode.WINE_PERMIT_SELECT_VALUE_NO_PERMIT_TEXT));

    /*else if(BooleanUtils.isFalse(isOptionSelectedNoPermit) && numberOfItems!=0)
        response.addError(new WineaccessError(SystemErrorCode.WINE_PERMIT_NOT_SELECT_VALUE_NO_PERMIT,SystemErrorCode.WINE_PERMIT_NOT_SELECT_VALUE_NO_PERMIT_TEXT));*/
    else {
        for (OptionSelectedNoPermit noPermitObject : optionSelectedNoPermit) {
            Long masterDataId = (noPermitObject.getMasterDataId() != null)
                    ? Long.parseLong(noPermitObject.getMasterDataId())
                    : null;
            if (masterDataId == null) {
                response.addError(new WineaccessError(SystemErrorCode.NO_WINE_PERMITS_ERROR,
                        SystemErrorCode.NO_WINE_PERMITS_ERROR_TEXT));

            } else {
                MasterData masterData = MasterDataRepository.getMasterDataById(masterDataId);
                if (masterData == null || !masterData.getMasterDataType().getName()
                        .equals(MasterDataTypeEnum.WineryLicenceNoPermit.name())) {
                    response.addError(new WineaccessError(SystemErrorCode.NO_PERMIT_INVALID_MASTER_DATA_WINE,
                            SystemErrorCode.NO_PERMIT_INVALID_MASTER_DATA_WINE_TEXT));

                }

            }
        }
    }

}

From source file:gov.nih.nci.cabig.caaers.domain.report.Report.java

/**
 * This method will return true, if the adverse event is reported in this report.
 *
 * @param ae the ae/*from w  ww . j a  v  a2 s .c o  m*/
 * @return true, if is reported
 */
@Transient
public boolean isReported(AdverseEvent ae) {
    if (BooleanUtils.isTrue(ae.getReported())) {
        List<ReportedAdverseEvent> reportedAdverseEvents = getLastVersion().getReportedAdversEvents();
        if (reportedAdverseEvents != null) {
            for (ReportedAdverseEvent reportedAe : reportedAdverseEvents) {
                if (ae.getId().equals(reportedAe.getAdverseEvent().getId())) {
                    return true;
                }
            }
        }
    }
    return false;
}

From source file:jp.primecloud.auto.service.impl.LoadBalancerServiceImpl.java

/**
 * {@inheritDoc}/*from w  w  w.j av  a 2s .c om*/
 */
@Override
public Long createAwsLoadBalancer(Long farmNo, String loadBalancerName, String comment, Long platformNo,
        Long componentNo, boolean internal) {
    // ?
    if (farmNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "farmNo");
    }
    if (loadBalancerName == null || loadBalancerName.length() == 0) {
        throw new AutoApplicationException("ECOMMON-000003", "loadBalancerName");
    }
    if (platformNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "platformNo");
    }
    if (componentNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "componentNo");
    }

    // ??
    if (!Pattern.matches("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", loadBalancerName)) {
        throw new AutoApplicationException("ECOMMON-000012", "loadBalancerName");
    }

    // TODO: ??

    // ??
    Platform platform = platformDao.read(platformNo);
    if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType()) == false) {
        throw new AutoApplicationException("ESERVICE-000606", platformNo);
    }

    // ??
    Image image = null;
    List<Image> images = imageDao.readAll();
    for (Image image2 : images) {
        if (image2.getPlatformNo().equals(platformNo.longValue())
                && PCCConstant.IMAGE_NAME_ELB.equals(image2.getImageName())) {
            image = image2;
            break;
        }
    }
    if (image == null) {
        // aws?????
        throw new AutoApplicationException("ESERVICE-000631", platformNo);
    }

    // ??????
    LoadBalancer checkLoadBalancer = loadBalancerDao.readByFarmNoAndLoadBalancerName(farmNo, loadBalancerName);
    if (checkLoadBalancer != null) {
        // ????????
        throw new AutoApplicationException("ESERVICE-000601", loadBalancerName);
    }

    // ????
    Instance checkInstance = instanceDao.readByFarmNoAndInstanceName(farmNo, loadBalancerName);
    if (checkInstance != null) {
        // ???????
        throw new AutoApplicationException("ESERVICE-000626", loadBalancerName);
    }

    // ??
    Farm farm = farmDao.read(farmNo);
    if (farm == null) {
        throw new AutoApplicationException("ESERVICE-000602", farmNo);
    }

    // ????
    long countComponent = componentDao.countByComponentNo(componentNo);
    if (countComponent == 0) {
        // ???????
        throw new AutoApplicationException("ESERVICE-000607", componentNo);
    }

    //AWS???
    AwsCertificate awsCertificate = awsCertificateDao.read(farm.getUserNo(), platformNo);

    //?()??
    PlatformAws platformAws = platformAwsDao.read(platformNo);
    String subnetId = null;
    String availabilityZone = null;
    if (platformAws.getVpc() && StringUtils.isNotEmpty(awsCertificate.getDefLbSubnet())) {
        //VPC ?? ?(?)???
        List<String> defLbSubnets = new ArrayList<String>();
        for (String lbSubnet : awsCertificate.getDefLbSubnet().split(",")) {
            defLbSubnets.add(lbSubnet.trim());
        }
        List<String> zones = new ArrayList<String>();
        StringBuffer subnetBuffer = new StringBuffer();
        StringBuffer zoneBuffer = new StringBuffer();
        List<SubnetDto> subnetDtos = iaasDescribeService.getSubnets(farm.getUserNo(), platformNo,
                platformAws.getVpcId());
        for (SubnetDto subnetDto : subnetDtos) {
            if (defLbSubnets.contains(subnetDto.getSubnetId())
                    && zones.contains(subnetDto.getZoneid()) == false) {
                subnetBuffer.append(
                        subnetBuffer.length() > 0 ? "," + subnetDto.getSubnetId() : subnetDto.getSubnetId());
                zoneBuffer
                        .append(zoneBuffer.length() > 0 ? "," + subnetDto.getZoneid() : subnetDto.getZoneid());
                zones.add(subnetDto.getZoneid());
            }
        }
        //??
        subnetId = subnetBuffer.toString();
        availabilityZone = zoneBuffer.toString();
    }

    //??
    String groupName = null;
    if (platformAws.getVpc()) {
        //VPC??
        List<SecurityGroupDto> securityGroupDtos = iaasDescribeService.getSecurityGroups(farm.getUserNo(),
                platformNo, platformAws.getVpcId());
        for (SecurityGroupDto securityGroupDto : securityGroupDtos) {
            if ("default".equals(securityGroupDto.getGroupName())) {
                //default?????default?
                groupName = securityGroupDto.getGroupName();
                break;
            }
        }
        if (groupName == null && securityGroupDtos.size() > 0) {
            //default????1
            groupName = securityGroupDtos.get(0).getGroupName();
        }
    }

    // ???
    LoadBalancer loadBalancer = new LoadBalancer();
    loadBalancer.setFarmNo(farmNo);
    loadBalancer.setLoadBalancerName(loadBalancerName);
    loadBalancer.setComment(comment);
    loadBalancer.setFqdn(loadBalancerName + "." + farm.getDomainName());
    loadBalancer.setPlatformNo(platformNo);
    loadBalancer.setType(PCCConstant.LOAD_BALANCER_ELB);
    loadBalancer.setEnabled(false);
    loadBalancer.setStatus(LoadBalancerStatus.STOPPED.toString());
    loadBalancer.setComponentNo(componentNo);
    loadBalancerDao.create(loadBalancer);

    Long loadBalancerNo = loadBalancer.getLoadBalancerNo();

    // AWS???
    AwsLoadBalancer awsLoadBalancer = new AwsLoadBalancer();
    awsLoadBalancer.setLoadBalancerNo(loadBalancerNo);
    awsLoadBalancer.setName(loadBalancerName + "-" + loadBalancerNo);
    awsLoadBalancer.setDnsName(null);
    awsLoadBalancer.setSubnetId(subnetId);
    awsLoadBalancer.setSecurityGroups(groupName);
    awsLoadBalancer.setAvailabilityZone(availabilityZone);
    awsLoadBalancer.setInternal(internal);
    awsLoadBalancerDao.create(awsLoadBalancer);

    // ???
    createDefaultHealthCheck(loadBalancer);

    // ??
    createDefaultAutoScalingConf(loadBalancer);

    // ??
    registerInstances(loadBalancer);

    // ??
    Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix"));
    if (BooleanUtils.isTrue(useZabbix)) {
        elbZabbixHostProcess.createElbHostgroup(loadBalancerNo);
    }

    // 
    eventLogger.log(EventLogLevel.INFO, farmNo, farm.getFarmName(), null, null, null, null,
            "LoadBalancerCreate", null, null,
            new Object[] { loadBalancerName, platform.getPlatformName(), PCCConstant.LOAD_BALANCER_ELB });

    return loadBalancerNo;
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

protected Component showWindowDialog(Window window, OpenType openType, boolean forciblyDialog) {
    final CubaWindow vWindow = createDialogWindow(window);
    vWindow.setStyleName("c-app-dialog-window");
    if (ui.isTestMode()) {
        vWindow.setCubaId("dialog_" + window.getId());
        vWindow.setId(ui.getTestIdManager().getTestId("dialog_" + window.getId()));
    }//  www.  ja va2  s . co  m

    Layout layout = (Layout) WebComponentsHelper.getComposition(window);
    vWindow.setContent(layout);

    vWindow.addPreCloseListener(event -> {
        event.setPreventClose(true);
        if (!isCloseWithCloseButtonPrevented(window)) {
            // user has clicked on X
            window.close(Window.CLOSE_ACTION_ID);
        }
    });

    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);

    ShortcutAction exitAction = new ShortcutAction("closeShortcutAction", closeCombination.getKey().getCode(),
            KeyCombination.Modifier.codes(closeCombination.getModifiers()));

    Map<com.vaadin.event.Action, Runnable> actions = singletonMap(exitAction, () -> {
        if (openType.getOpenMode() != OpenMode.DIALOG
                || BooleanUtils.isNotFalse(window.getDialogOptions().getCloseable())) {
            if (isCloseWithShortcutPrevented(window)) {
                return;
            }
            window.close(Window.CLOSE_ACTION_ID);
        }
    });

    WebComponentsHelper.setActions(vWindow, actions);

    boolean dialogParamsSizeUndefined = openType.getHeight() == null && openType.getWidth() == null;

    ThemeConstants theme = app.getThemeConstants();

    if (forciblyDialog && dialogParamsSizeUndefined) {
        layout.setHeight(100, Unit.PERCENTAGE);

        vWindow.setWidth(theme.getInt("cuba.web.WebWindowManager.forciblyDialog.width"), Unit.PIXELS);
        vWindow.setHeight(theme.getInt("cuba.web.WebWindowManager.forciblyDialog.height"), Unit.PIXELS);

        // resizable by default, but may be overridden in dialog params
        vWindow.setResizable(BooleanUtils.isNotFalse(openType.getResizable()));

        window.setHeightFull();
    } else {
        if (openType.getWidth() == null) {
            vWindow.setWidth(theme.getInt("cuba.web.WebWindowManager.dialog.width"), Unit.PIXELS);
        } else if (openType.getWidth() == AUTO_SIZE_PX) {
            vWindow.setWidthUndefined();
            layout.setWidthUndefined();
            window.setWidthAuto();
        } else {
            vWindow.setWidth(openType.getWidth(),
                    openType.getWidthUnit() != null ? WebWrapperUtils.toVaadinUnit(openType.getWidthUnit())
                            : Unit.PIXELS);
        }

        if (openType.getHeight() != null && openType.getHeight() != AUTO_SIZE_PX) {
            vWindow.setHeight(openType.getHeight(),
                    openType.getHeightUnit() != null ? WebWrapperUtils.toVaadinUnit(openType.getHeightUnit())
                            : Unit.PIXELS);
            layout.setHeight("100%");
            window.setHeightFull();
        } else {
            window.setHeightAuto();
        }

        // non resizable by default
        vWindow.setResizable(BooleanUtils.isTrue(openType.getResizable()));
    }

    if (openType.getCloseable() != null) {
        vWindow.setClosable(openType.getCloseable());
    }

    boolean modal = true;
    if (!hasModalWindow() && openType.getModal() != null) {
        modal = openType.getModal();
    }
    vWindow.setModal(modal);

    if (vWindow.isModal()) {
        boolean informationDialog = false;
        if (openType.getCloseOnClickOutside() != null) {
            informationDialog = openType.getCloseOnClickOutside();
        }
        vWindow.setCloseOnClickOutside(informationDialog);
    }

    if (openType.getMaximized() != null) {
        if (openType.getMaximized()) {
            vWindow.setWindowMode(WindowMode.MAXIMIZED);
        } else {
            vWindow.setWindowMode(WindowMode.NORMAL);
        }
    }

    if (openType.getPositionX() == null && openType.getPositionY() == null) {
        vWindow.center();
    } else {
        if (openType.getPositionX() != null) {
            vWindow.setPositionX(openType.getPositionX());
        }
        if (openType.getPositionY() != null) {
            vWindow.setPositionY(openType.getPositionY());
        }
    }

    getDialogParams().reset();

    ui.addWindow(vWindow);

    return vWindow;
}

From source file:com.haulmont.cuba.core.app.serialization.EntitySerialization.java

protected boolean isCollectionDynamicAttribute(MetaProperty metaProperty) {
    if (DynamicAttributesUtils.isDynamicAttribute(metaProperty.getName())) {
        CategoryAttribute attribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty);
        return attribute != null && BooleanUtils.isTrue(attribute.getIsCollection());
    }//  w w w. j a v  a 2s.  c  o m
    return false;
}

From source file:com.evolveum.midpoint.gui.api.util.WebModelServiceUtils.java

public static boolean isEnableExperimentalFeature(Task task, ModelServiceLocator pageBase) {
    OperationResult result = task.getResult();

    ModelInteractionService mInteractionService = pageBase.getModelInteractionService();

    AdminGuiConfigurationType adminGuiConfig = null;
    try {// w  ww.j a  v  a 2s  .  co  m
        adminGuiConfig = mInteractionService.getAdminGuiConfiguration(task, result);
        result.recomputeStatus();
        result.recordSuccessIfUnknown();
    } catch (Exception e) {
        LoggingUtils.logException(LOGGER, "Cannot load admin gui config", e);
        result.recordPartialError("Cannot load admin gui config. Reason: " + e.getLocalizedMessage());

    }

    if (adminGuiConfig == null) {
        return false;
    }

    return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());

}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopFieldGroup.java

protected void updateTooltipButton(FieldConfigImpl fci, Component component) {
    ToolTipButton toolTipButton = fci.getToolTipButton();

    boolean hasContextHelpIconClickListeners = hasContextHelpIconClickListeners(component);
    String contextHelpText = DesktopComponentsHelper.getContextHelpText(fci.getContextHelpText(),
            BooleanUtils.isTrue(fci.isContextHelpTextHtmlEnabled()));

    ActionListener toolTipButtonActionListener = fci.getToolTipButtonActionListener();
    if (hasContextHelpIconClickListeners) {
        if (toolTipButtonActionListener == null) {
            toolTipButtonActionListener = e -> fireContextHelpIconClickEvent(component);
            toolTipButton.addActionListener(toolTipButtonActionListener);
        }//from   w  w  w . j  a v  a2  s  . com

        toolTipButton.setToolTipText(null);
    } else {
        if (toolTipButtonActionListener != null) {
            toolTipButton.removeActionListener(toolTipButtonActionListener);
            fci.setToolTipButtonActionListener(null);
        }

        toolTipButton.setToolTipText(contextHelpText);
    }

    toolTipButton.setVisible(component.isVisible()
            && (StringUtils.isNotEmpty(contextHelpText) || hasContextHelpIconClickListeners));
}

From source file:com.haulmont.cuba.web.gui.components.WebAbstractTable.java

protected Collection<MetaPropertyPath> createColumns(com.vaadin.data.Container ds) {
    @SuppressWarnings("unchecked")
    final Collection<MetaPropertyPath> properties = (Collection<MetaPropertyPath>) ds.getContainerPropertyIds();

    Window window = ComponentsHelper.getWindowImplementation(this);
    boolean isLookup = window instanceof Window.Lookup;

    for (MetaPropertyPath propertyPath : properties) {
        final Table.Column column = columns.get(propertyPath);
        if (column != null && !(editable && BooleanUtils.isTrue(column.isEditable()))) {
            final String isLink = column.getXmlDescriptor() == null ? null
                    : column.getXmlDescriptor().attributeValue("link");

            if (propertyPath.getRange().isClass()) {
                if (!isLookup && StringUtils.isNotEmpty(isLink)) {
                    setClickListener(propertyPath.toString(), new LinkCellClickListener());
                }//from   ww  w .  ja  va2 s.  com
            } else if (propertyPath.getRange().isDatatype()) {
                if (!isLookup && !StringUtils.isEmpty(isLink)) {
                    setClickListener(propertyPath.toString(), new LinkCellClickListener());
                } else if (editable && BooleanUtils.isTrue(column.isCalculatable())) {
                    addGeneratedColumn(propertyPath, new CalculatableColumnGenerator());
                } else {
                    if (column.getMaxTextLength() != null) {
                        addGeneratedColumn(propertyPath, new AbbreviatedColumnGenerator(column));
                        setClickListener(propertyPath.toString(), new AbbreviatedCellClickListener());
                    }
                }
            } else if (!propertyPath.getRange().isEnum()) {
                throw new UnsupportedOperationException();
            }
        }
    }

    return properties;
}