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

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

Introduction

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

Prototype

public static Boolean negate(Boolean bool) 

Source Link

Document

Negates the specified boolean.

If null is passed in, null will be returned.

 BooleanUtils.negate(Boolean.TRUE)  = Boolean.FALSE; BooleanUtils.negate(Boolean.FALSE) = Boolean.TRUE; BooleanUtils.negate(null)          = null; 

Usage

From source file:com.steeleforge.aem.ironsites.wcm.page.filter.property.PropertyEqualsFilter.java

public boolean includes(Page page) {
    if (null == page || null == property || null == value) {
        return false;
    }/*  w w  w  .j av a  2 s .  c o m*/
    if (negate) {
        return BooleanUtils.negate(propertyEquals(page, property, value));
    } else {
        return propertyEquals(page, property, value);
    }
}

From source file:de.mpg.imeji.presentation.upload.UploadSession.java

public void uploadFileToItemListener() {
    this.importImageToFile = BooleanUtils.negate(importImageToFile);
}

From source file:de.mpg.imeji.presentation.upload.UploadSession.java

public void importImageToFileListener() {
    this.uploadFileToItem = BooleanUtils.negate(uploadFileToItem);
}

From source file:de.mpg.imeji.presentation.upload.UploadSession.java

public void checkNameUniqueListener() {
    this.checkNameUnique = BooleanUtils.negate(checkNameUnique);
}

From source file:fr.hoteia.qalingo.core.i18n.message.impl.CoreMessageSourceImpl.java

public String getMessage(final String code, final Object args[], final String defaultMessage,
        final Locale locale) {
    try {/*from ww  w.j a v a  2  s .c o  m*/
        return messageSource.getMessage(code, args, defaultMessage, locale);
    } catch (Exception e) {
        if (code != null && code.contains("javax")) {
            LOG.warn("This message key doesn't exist: " + code + ", for this locale: " + locale.toString());
        } else {
            LOG.error("This message key doesn't exist: " + code + ", for this locale: " + locale.toString());
        }
        if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) {
            return getMessage(code, args, defaultMessage, new Locale(Constants.DEFAULT_LOCALE_CODE));
        }
    }
    return null;
}

From source file:fr.hoteia.qalingo.core.domain.Store.java

public StoreAttribute getStoreAttribute(String attributeCode, Long marketAreaId, String localizationCode) {
    StoreAttribute storeAttributeToReturn = null;
    if (storeAttributes != null) {
        List<StoreAttribute> storeAttributesFilter = new ArrayList<StoreAttribute>();
        for (Iterator<StoreAttribute> iterator = storeAttributes.iterator(); iterator.hasNext();) {
            StoreAttribute storeAttribute = (StoreAttribute) iterator.next();
            AttributeDefinition attributeDefinition = storeAttribute.getAttributeDefinition();
            if (attributeDefinition != null && attributeDefinition.getCode().equalsIgnoreCase(attributeCode)) {
                storeAttributesFilter.add(storeAttribute);
            }//w ww.j  a  va  2 s .  c o  m
        }
        if (marketAreaId != null) {
            for (Iterator<StoreAttribute> iterator = storeAttributesFilter.iterator(); iterator.hasNext();) {
                StoreAttribute storeAttribute = (StoreAttribute) iterator.next();
                AttributeDefinition attributeDefinition = storeAttribute.getAttributeDefinition();
                if (BooleanUtils.negate(attributeDefinition.isGlobal())) {
                    if (storeAttribute.getMarketAreaId() != null
                            && BooleanUtils.negate(storeAttribute.getMarketAreaId().equals(marketAreaId))) {
                        iterator.remove();
                    }
                }
            }
            if (storeAttributesFilter.size() == 0) {
                // TODO : throw error ?
            }
        }
        if (StringUtils.isNotEmpty(localizationCode)) {
            for (Iterator<StoreAttribute> iterator = storeAttributesFilter.iterator(); iterator.hasNext();) {
                StoreAttribute storeAttribute = (StoreAttribute) iterator.next();
                AttributeDefinition attributeDefinition = storeAttribute.getAttributeDefinition();
                if (BooleanUtils.negate(attributeDefinition.isGlobal())) {
                    String attributeLocalizationCode = storeAttribute.getLocalizationCode();
                    if (StringUtils.isNotEmpty(attributeLocalizationCode)
                            && BooleanUtils.negate(attributeLocalizationCode.equals(localizationCode))) {
                        iterator.remove();
                    }
                }
            }
            if (storeAttributesFilter.size() == 0) {
                // TODO : throw error ?

                for (Iterator<StoreAttribute> iterator = storeAttributes.iterator(); iterator.hasNext();) {
                    StoreAttribute storeAttribute = (StoreAttribute) iterator.next();

                    // TODO : get a default locale code from setting database ?

                    if (storeAttribute.getLocalizationCode().equals(Constants.DEFAULT_LOCALE_CODE)) {
                        storeAttributeToReturn = storeAttribute;
                    }
                }
            }
        }
        if (storeAttributesFilter.size() == 1) {
            storeAttributeToReturn = storeAttributesFilter.get(0);
        } else {
            // TODO : throw error ?
        }
    }
    return storeAttributeToReturn;
}

From source file:fr.hoteia.qalingo.core.i18n.message.impl.CoreMessageSourceImpl.java

public String getMessage(final String code, final Object args[], final Locale locale)
        throws NoSuchMessageException {
    try {// ww  w  .ja v  a  2  s  . c o  m
        return messageSource.getMessage(code, args, locale);
    } catch (Exception e) {
        LOG.error("This message key doesn't exist: " + code + ", for this locale: " + locale.toString());
        if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) {
            return getMessage(code, args, new Locale(Constants.DEFAULT_LOCALE_CODE));
        }
    }
    return null;
}

From source file:fr.hoteia.qalingo.web.mvc.controller.user.UserController.java

@RequestMapping(value = BoUrls.USER_EDIT_URL, method = RequestMethod.POST)
public ModelAndView submitUserEdit(final HttpServletRequest request, final Model model,
        @Valid UserForm userForm, BindingResult result, ModelMap modelMap) throws Exception {

    final String userId = userForm.getId();
    User user = userService.getUserById(userId);
    if (result.hasErrors()) {
        return userEdit(request, model);
    }/*  w ww .  j  a  va 2  s.co  m*/

    // SANITY CHECK
    if (BooleanUtils.negate(userForm.getLogin().equalsIgnoreCase(user.getLogin()))) {
        User userCheck = userService.getUserByLoginOrEmail(userForm.getLogin());
        if (userCheck != null) {
            result.rejectValue("login", "error.form.user.update.login.already.exist", null,
                    "This email customer account already exist!.");
            return userEdit(request, model);
        }
    }
    if (BooleanUtils.negate(userForm.getEmail().equalsIgnoreCase(user.getEmail()))) {
        User userCheck = userService.getUserByLoginOrEmail(userForm.getEmail());
        if (userCheck != null) {
            result.rejectValue("email", "error.form.user.update.email.already.exist", null,
                    "This email customer account already exist!.");
            return userEdit(request, model);
        }
    }

    // UPDATE USER
    webBackofficeService.updateUser(user, userForm);

    Map<String, String> urlParams = new HashMap<String, String>();
    urlParams.put(RequestConstants.REQUEST_PARAMETER_USER_ID, userId);
    return new ModelAndView(new RedirectView(backofficeUrlService.generateUrl(BoUrls.USER_DETAILS,
            requestUtil.getRequestData(request), urlParams)));
}

From source file:fr.hoteia.qalingo.core.i18n.message.impl.CoreMessageSourceImpl.java

public String getMessage(final MessageSourceResolvable resolvable, final Locale locale)
        throws NoSuchMessageException {
    try {/*from  w w w  . j a  va 2s. c  om*/
        return messageSource.getMessage(resolvable, locale);
    } catch (Exception e) {
        LOG.error("This message key doesn't exist: " + resolvable.getCodes() + ", for this locale: "
                + locale.toString());
        if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) {
            return getMessage(resolvable, new Locale(Constants.DEFAULT_LOCALE_CODE));
        }
    }
    return null;
}

From source file:fr.hoteia.qalingo.core.domain.ProductSku.java

public ProductSkuAttribute getProductSkuAttribute(String attributeCode, Long marketAreaId,
        String localizationCode) {
    ProductSkuAttribute productSkuAttributeToReturn = null;
    if (productSkuMarketAreaAttributes != null) {
        List<ProductSkuAttribute> productSkuAttributesFilter = new ArrayList<ProductSkuAttribute>();
        for (Iterator<ProductSkuAttribute> iterator = productSkuMarketAreaAttributes.iterator(); iterator
                .hasNext();) {//from ww w.  j  av  a2s.  c o  m
            ProductSkuAttribute productSkuAttribute = (ProductSkuAttribute) iterator.next();
            AttributeDefinition attributeDefinition = productSkuAttribute.getAttributeDefinition();
            if (attributeDefinition != null && attributeDefinition.getCode().equalsIgnoreCase(attributeCode)) {
                productSkuAttributesFilter.add(productSkuAttribute);
            }
        }
        if (marketAreaId != null) {
            for (Iterator<ProductSkuAttribute> iterator = productSkuAttributesFilter.iterator(); iterator
                    .hasNext();) {
                ProductSkuAttribute productSkuAttribute = (ProductSkuAttribute) iterator.next();
                AttributeDefinition attributeDefinition = productSkuAttribute.getAttributeDefinition();
                if (BooleanUtils.negate(attributeDefinition.isGlobal())) {
                    if (productSkuAttribute.getMarketAreaId() != null && BooleanUtils
                            .negate(productSkuAttribute.getMarketAreaId().equals(marketAreaId))) {
                        iterator.remove();
                    }
                }
            }
            if (productSkuAttributesFilter.size() == 0) {
                // TODO : throw error ?
            }
        }
        if (StringUtils.isNotEmpty(localizationCode)) {
            for (Iterator<ProductSkuAttribute> iterator = productSkuAttributesFilter.iterator(); iterator
                    .hasNext();) {
                ProductSkuAttribute productSkuAttribute = (ProductSkuAttribute) iterator.next();
                AttributeDefinition attributeDefinition = productSkuAttribute.getAttributeDefinition();
                if (BooleanUtils.negate(attributeDefinition.isGlobal())) {
                    String attributeLocalizationCode = productSkuAttribute.getLocalizationCode();
                    if (StringUtils.isNotEmpty(attributeLocalizationCode)
                            && BooleanUtils.negate(attributeLocalizationCode.equals(localizationCode))) {
                        iterator.remove();
                    }
                }
            }
            if (productSkuAttributesFilter.size() == 0) {
                // TODO : throw error ?

                for (Iterator<ProductSkuAttribute> iterator = productSkuMarketAreaAttributes
                        .iterator(); iterator.hasNext();) {
                    ProductSkuAttribute productSkuAttribute = (ProductSkuAttribute) iterator.next();

                    // TODO : get a default locale code from setting database ?

                    if (productSkuAttribute.getLocalizationCode().equals(Constants.DEFAULT_LOCALE_CODE)) {
                        productSkuAttributeToReturn = productSkuAttribute;
                    }
                }

            }
        }
        if (productSkuAttributesFilter.size() == 1) {
            productSkuAttributeToReturn = productSkuAttributesFilter.get(0);
        } else {
            // TODO : throw error ?
        }
    }
    return productSkuAttributeToReturn;
}