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.desktop.gui.components.DesktopCheckBox.java

private void updateComponent(Object value) {
    impl.setSelected(value != null && BooleanUtils.isTrue((Boolean) value));
}

From source file:com.tesora.dve.sql.statement.session.ShowPassthroughStatement.java

public boolean isFull() {
    return BooleanUtils.isTrue(full);
}

From source file:de.hybris.platform.secureportaladdon.services.impl.DefaultB2BRegistrationService.java

@Override
public List<EmailAddressModel> getEmailAddressesOfEmployees(final List<EmployeeModel> employees) {

    final List<EmailAddressModel> emails = new ArrayList<>();

    for (final EmployeeModel employee : employees) {
        for (final AddressModel address : Lists.newArrayList(employee.getAddresses())) {
            if (BooleanUtils.isTrue(address.getContactAddress())) {
                if (StringUtils.isNotBlank(address.getEmail())) {
                    final EmailAddressModel emailAddress = emailService
                            .getOrCreateEmailAddressForEmail(address.getEmail(), employee.getName());
                    emails.add(emailAddress);
                }/*from  w w  w  .  j  av a  2s  . c  om*/
                break;
            }
        }
    }

    return emails;

}

From source file:net.neurowork.cenatic.centraldir.workers.SatelitesExecutorJob.java

protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException {
    logger.info("Se ejecuta la busqueda en los satlites");

    if (sateliteService == null) {
        logger.error("Servicio invlido.");
        return;/*  w  w w. j  ava2  s  .  c  o m*/
    }

    try {
        Collection<Satelite> satelites = sateliteService.findActivado();

        for (Satelite satelite : satelites) {
            if (BooleanUtils.isTrue(satelite.isActivado())) {
                if (StringUtils.hasLength(satelite.getHostUrl()) && StringUtils.hasLength(satelite.getUser())
                        && StringUtils.hasLength(satelite.getPassword())) {

                    Thread t = new Thread(new XMLRestWorker(satelite, sateliteService, provinciaService,
                            organizacionService, organizacionSedeService, formaJuridicaService, sectorService,
                            asociacionService));
                    t.start();
                }
                //            else{
                //               logger.warn("No se inicia la busqueda para el satelite: " + satelite + " por falta de informacin.");
                //            }            
            }
        }
    } catch (ServiceException e) {
        logger.error(e.getMessage());
    }
}

From source file:jp.primecloud.auto.api.component.StartAllComponent.java

/**
 *
 * ?(All) ?????//ww  w . j  a  va2s . c o m
 *
 * @param farmNo ?
 * @return StartAllComponentResponse
 */
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public StartAllComponentResponse startAllComponent(@QueryParam(PARAM_NAME_FARM_NO) String farmNo) {

    StartAllComponentResponse response = new StartAllComponentResponse();

    try {
        // ?
        // FarmNo
        ApiValidate.validateFarmNo(farmNo);

        // ?
        Farm farm = farmDao.read(Long.parseLong(farmNo));
        if (farm == null) {
            // ????
            throw new AutoApplicationException("EAPI-100000", "Farm", PARAM_NAME_FARM_NO, farmNo);
        }

        // ???
        List<Component> components = componentDao.readByFarmNo(Long.parseLong(farmNo));
        List<Long> componentNos = new ArrayList<Long>();
        for (Component component : components) {
            if (BooleanUtils.isTrue(component.getLoadBalancer())) {
                //????
                continue;
            }
            componentNos.add(component.getComponentNo());
        }

        // 
        processService.startComponents(Long.parseLong(farmNo), componentNos);

        response.setSuccess(true);
    } catch (Throwable e) {
        String message = "";
        if (e instanceof AutoException || e instanceof AutoApplicationException) {
            message = e.getMessage();
        } else {
            message = MessageUtils.getMessage("EAPI-000000");
        }
        log.error(message, e);
        response.setMessage(message);
        response.setSuccess(false);
    }

    return response;
}

From source file:jp.primecloud.auto.api.component.DescribeComponent.java

/**
 *
 * ?/*w ww  .  java2s  .co  m*/
 *
 * @param farmNo ?
 * @param componentNo ???
 *
 * @return DescribeComponentResponse
 */
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public DescribeComponentResponse describeComponent(@QueryParam(PARAM_NAME_FARM_NO) String farmNo,
        @QueryParam(PARAM_NAME_COMPONENT_NO) String componentNo) {

    DescribeComponentResponse response = new DescribeComponentResponse();

    try {
        // ?
        // FarmNo
        ApiValidate.validateFarmNo(farmNo);
        // ComponentNo
        ApiValidate.validateComponentNo(componentNo);

        // ???
        Component component = componentDao.read(Long.parseLong(componentNo));
        if (component == null || BooleanUtils.isTrue(component.getLoadBalancer())) {
            // ?????? ??? ???
            throw new AutoApplicationException("EAPI-100000", "Component", PARAM_NAME_COMPONENT_NO,
                    componentNo);
        }

        if (component.getFarmNo().equals(Long.parseLong(farmNo)) == false) {
            //???????
            throw new AutoApplicationException("EAPI-100022", "Component", farmNo, PARAM_NAME_COMPONENT_NO,
                    componentNo);
        }

        //??
        response = new DescribeComponentResponse(component);

        List<ComponentInstance> componentInstances = componentInstanceDao
                .readByComponentNo(Long.parseLong(componentNo));
        if (componentInstances.isEmpty() == false) {
            //
            Collections.sort(componentInstances, Comparators.COMPARATOR_COMPONENT_INSTANCE);
            for (ComponentInstance componentInstance : componentInstances) {
                // ?????????
                if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) {
                    ComponentInstanceStatus status = ComponentInstanceStatus
                            .fromStatus(componentInstance.getStatus());
                    if (status == ComponentInstanceStatus.STOPPED) {
                        continue;
                    }
                }
                //??
                response.addInstance(new ComponentInstanceResponse(componentInstance));
            }
        }

        response.setSuccess(true);
    } catch (Throwable e) {
        String message = "";
        if (e instanceof AutoException || e instanceof AutoApplicationException) {
            message = e.getMessage();
        } else {
            message = MessageUtils.getMessage("EAPI-000000");
        }
        log.error(message, e);
        response.setMessage(message);
        response.setSuccess(false);
    }

    return response;
}

From source file:jp.primecloud.auto.api.instance.StopAllInstance.java

/**
 *
 * ??(ALL) ??????//from  ww w .j  a v  a 2 s.c om
 *
 * @param farmNo ?
 *
 * @return StopAllInstanceResponse
 */
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public StopAllInstanceResponse stoptAllInstance(@QueryParam(PARAM_NAME_FARM_NO) String farmNo) {

    StopAllInstanceResponse response = new StopAllInstanceResponse();

    try {
        // ?
        // FarmNo
        ApiValidate.validateFarmNo(farmNo);

        // ?
        Farm farm = farmDao.read(Long.parseLong(farmNo));
        if (farm == null) {
            // ?????
            throw new AutoApplicationException("EAPI-100000", "Farm", PARAM_NAME_FARM_NO, farmNo);
        }

        // ?
        List<Long> instanceNos = new ArrayList<Long>();
        List<Instance> instances = instanceDao.readByFarmNo(Long.parseLong(farmNo));
        for (Instance instance : instances) {
            if (BooleanUtils.isTrue(instance.getLoadBalancer())) {
                //?
                continue;
            }
            InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus());
            if (InstanceStatus.RUNNING == status) {
                //?????
                instanceNos.add(instance.getInstanceNo());
            }
        }

        // ???
        processService.stopInstances(Long.parseLong(farmNo), instanceNos);

        response.setSuccess(true);
    } catch (Throwable e) {
        String message = "";
        if (e instanceof AutoException || e instanceof AutoApplicationException) {
            message = e.getMessage();
        } else {
            message = MessageUtils.getMessage("EAPI-000000");
        }
        log.error(message, e);
        response.setMessage(message);
        response.setSuccess(false);
    }

    return response;
}

From source file:de.hybris.platform.catalog.job.diff.impl.RemovedProductCatalogVersionDiffFinder.java

@Override
protected boolean shouldProcess(final CompareCatalogVersionsCronJobModel cronJobModel) {
    return BooleanUtils.isTrue(cronJobModel.getSearchMissingProducts());
}

From source file:de.hybris.platform.catalog.job.diff.impl.NewProductCatalogVersionDiffFinder.java

@Override
protected boolean shouldProcess(final CompareCatalogVersionsCronJobModel cronJobModel) {
    return BooleanUtils.isTrue(cronJobModel.getSearchNewProducts());
}

From source file:jp.primecloud.auto.api.instance.ListInstance.java

/**
 *
 * ?? ???????/* ww w  .  j a  v  a2 s.c  om*/
 *
 * @param farmNo ?
 *
 * @return ListInstanceResponse
 */
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ListInstanceResponse listInstance(@QueryParam(PARAM_NAME_FARM_NO) String farmNo) {

    ListInstanceResponse response = new ListInstanceResponse();

    try {
        // ?
        // FarmNo
        ApiValidate.validateFarmNo(farmNo);

        // ?
        Farm farm = farmDao.read(Long.parseLong(farmNo));
        if (farm == null) {
            // ????
            throw new AutoApplicationException("EAPI-100000", "Farm", PARAM_NAME_FARM_NO, farmNo);
        }

        // ?
        List<Instance> instances = instanceDao.readByFarmNo(Long.parseLong(farmNo));
        if (instances.isEmpty() == false) {
            //
            Collections.sort(instances, Comparators.COMPARATOR_INSTANCE);
        }

        for (Instance instance : instances) {
            if (BooleanUtils.isTrue(instance.getLoadBalancer())) {
                // ?????
                continue;
            }
            //
            response.addInstance(new InstanceResponse(instance));
        }

        response.setSuccess(true);
    } catch (Throwable e) {
        String message = "";
        if (e instanceof AutoException || e instanceof AutoApplicationException) {
            message = e.getMessage();
        } else {
            message = MessageUtils.getMessage("EAPI-000000");
        }
        log.error(message, e);
        response.setMessage(message);
        response.setSuccess(false);
    }

    return response;
}