Java Code Examples for org.apache.commons.lang3.BooleanUtils#isTrue()

The following examples show how to use org.apache.commons.lang3.BooleanUtils#isTrue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TcfDefinerService.java    From prebid-server-java with Apache License 2.0 6 votes vote down vote up
public TcfDefinerService(GdprConfig gdprConfig,
                         Set<String> eeaCountries,
                         GdprService gdprService,
                         Tcf2Service tcf2Service,
                         GeoLocationService geoLocationService,
                         BidderCatalog bidderCatalog,
                         Metrics metrics) {

    this.gdprEnabled = gdprConfig != null && BooleanUtils.isNotFalse(gdprConfig.getEnabled());
    this.gdprDefaultValue = gdprConfig != null ? gdprConfig.getDefaultValue() : null;
    this.consentStringMeansInScope = gdprConfig != null
            && BooleanUtils.isTrue(gdprConfig.getConsentStringMeansInScope());
    this.gdprService = Objects.requireNonNull(gdprService);
    this.tcf2Service = Objects.requireNonNull(tcf2Service);
    this.eeaCountries = Objects.requireNonNull(eeaCountries);
    this.geoLocationService = geoLocationService;
    this.bidderCatalog = Objects.requireNonNull(bidderCatalog);
    this.metrics = Objects.requireNonNull(metrics);
}
 
Example 2
Source File: InvokeProcessor.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
private void jaxwsExternal(AeiObjects aeiObjects, Invoke invoke) throws Exception {
	Object[] parameters = this.jaxwsEvalParameters(aeiObjects, invoke);
	JaxwsObject jaxwsObject = new JaxwsObject();
	jaxwsObject.setAddress(invoke.getJaxwsAddress());
	jaxwsObject.setMethod(invoke.getJaxwsMethod());
	jaxwsObject.setParameters(parameters);
	if (BooleanUtils.isTrue(invoke.getAsync())) {
		ThisApplication.syncJaxwsInvokeQueue.send(jaxwsObject);
	} else {
		InvokeExecutor executor = new InvokeExecutor();
		Object response = executor.execute(jaxwsObject);
		if ((StringUtils.isNotEmpty(invoke.getJaxwsResponseScript()))
				|| (StringUtils.isNotEmpty(invoke.getJaxwsResponseScriptText()))) {
			ScriptContext scriptContext = aeiObjects.scriptContext();
			scriptContext.getBindings(ScriptContext.ENGINE_SCOPE).put(ScriptFactory.BINDING_NAME_JAXWSRESPONSE,
					response);
			/* 重新注入对象需要重新运行 */
			ScriptFactory.initialScriptText().eval(scriptContext);
			CompiledScript cs = aeiObjects.business().element().getCompiledScript(
					aeiObjects.getWork().getApplication(), aeiObjects.getActivity(),
					Business.EVENT_INVOKEJAXWSRESPONSE);
			cs.eval(scriptContext);
		}
	}
}
 
Example 3
Source File: Servers.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void startDataServer() throws Exception {
	if (dataServerIsRunning()) {
		throw new Exception("data server is running.");
	} else {
		DataServer server = Config.currentNode().getData();
		if (null == server) {
			throw new Exception("not config dataServer.");
		}
		if (!BooleanUtils.isTrue(server.getEnable())) {
			throw new Exception("dataServer not enable.");
		}
		dataServer = DataServerTools.start(server);
	}
}
 
Example 4
Source File: BaseAction.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
protected <T extends WoPersonAbstract> void hide(EffectivePerson effectivePerson, Business business, T t)
		throws Exception {
	if (!effectivePerson.isManager() && (!effectivePerson.isCipher())) {
		if (!business.hasAnyRole(effectivePerson, OrganizationDefinition.OrganizationManager,
				OrganizationDefinition.Manager)) {
			if (BooleanUtils.isTrue(t.getHiddenMobile())
					&& (!StringUtils.equals(effectivePerson.getDistinguishedName(), t.getDistinguishedName()))) {
				t.setMobile(Person.HIDDENMOBILESYMBOL);
			}
		}
	}
}
 
Example 5
Source File: FieldConfigurable.java    From easy_javadoc with Apache License 2.0 5 votes vote down vote up
@Override
public void reset() {
    TemplateConfig templateConfig = config.getFieldTemplateConfig();
    if (BooleanUtils.isTrue(templateConfig.getIsDefault())) {
        view.setDefault(true);
    } else {
        view.setDefault(false);
    }
    view.setTemplate(templateConfig.getTemplate());
}
 
Example 6
Source File: EmailChannelTypeSupport.java    From newrelic-alerts-configurator with Apache License 2.0 5 votes vote down vote up
@Override
public AlertsChannelConfiguration generateAlertsChannelConfiguration(NewRelicApi api) {
    EmailChannel emailChannel = (EmailChannel) channel;
    AlertsChannelConfiguration.AlertsChannelConfigurationBuilder builder = AlertsChannelConfiguration.builder();
    builder.recipients(emailChannel.getEmailAddress());
    if (BooleanUtils.isTrue(emailChannel.getIncludeJsonAttachment())) {
        builder.includeJsonAttachment(emailChannel.getIncludeJsonAttachment());
    }
    return builder.build();
}
 
Example 7
Source File: SmartContractSupport.java    From julongchain with Apache License 2.0 5 votes vote down vote up
private void startSystemContract(String smartContractId) throws SmartContractException {
    Boolean isSsc = SmartContractSupportClient.checkSystemSmartContract(smartContractId);
    if (!BooleanUtils.isTrue(isSsc)) {
        return;
    }
    SmartContractSupportClient.launch(smartContractId);
    while (!SmartContractRunningUtil.checkSmartContractRunning(smartContractId)) {
        try {
            log.info("wait smart contract register[" + smartContractId + "]");
            Thread.sleep(1000);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}
 
Example 8
Source File: Attachment.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
/** 更新运行方法 */

	@Override
	public String path() throws Exception {
		if (null == this.workCreateTime) {
			throw new Exception("workCreateTime can not be null.");
		}
		if (StringUtils.isEmpty(job)) {
			throw new Exception("job can not be empty.");
		}
		if (StringUtils.isEmpty(id)) {
			throw new Exception("id can not be empty.");
		}
		String str = DateTools.format(workCreateTime, DateTools.formatCompact_yyyyMMdd);
		if (BooleanUtils.isTrue(this.getDeepPath())) {
			str += PATHSEPARATOR;
			str += StringUtils.substring(this.job, 0, 2);
			str += PATHSEPARATOR;
			str += StringUtils.substring(this.job, 2, 4);
		}
		str += PATHSEPARATOR;
		str += this.job;
		str += PATHSEPARATOR;
		str += this.id;
		str += StringUtils.isEmpty(this.extension) ? "" : ("." + this.extension);
		return str;
	}
 
Example 9
Source File: CollationKeyFunction.java    From phoenix with Apache License 2.0 4 votes vote down vote up
private void initialize() {
	String localeISOCode = getLiteralValue(1, String.class);
	Boolean useSpecialUpperCaseCollator = getLiteralValue(2, Boolean.class);
	Integer collatorStrength = getLiteralValue(3, Integer.class);
	Integer collatorDecomposition = getLiteralValue(4, Integer.class);

	if (LOGGER.isTraceEnabled()) {
		StringBuilder logInputsMessage = new StringBuilder();
		logInputsMessage.append("Input (literal) arguments:").append("localeISOCode: " + localeISOCode)
				.append(", useSpecialUpperCaseCollator: " + useSpecialUpperCaseCollator)
				.append(", collatorStrength: " + collatorStrength)
				.append(", collatorDecomposition: " + collatorDecomposition);
		LOGGER.trace(logInputsMessage.toString());
	}

	Locale locale = LocaleUtils.get().getLocaleByIsoCode(localeISOCode);

	if (LOGGER.isTraceEnabled()) {
		LOGGER.trace(String.format("Locale: " + locale.toLanguageTag()));
	}

	LinguisticSort linguisticSort = LinguisticSort.get(locale);

	collator = BooleanUtils.isTrue(useSpecialUpperCaseCollator) ? linguisticSort.getUpperCaseCollator(false)
			: linguisticSort.getCollator();

	if (collatorStrength != null) {
		collator.setStrength(collatorStrength);
	}

	if (collatorDecomposition != null) {
		collator.setDecomposition(collatorDecomposition);
	}

	if (LOGGER.isTraceEnabled()) {
		LOGGER.trace(String.format(
				"Collator: [strength: %d, decomposition: %d], Special-Upper-Case: %s",
				collator.getStrength(), collator.getDecomposition(),
				BooleanUtils.isTrue(useSpecialUpperCaseCollator)));
	}
}
 
Example 10
Source File: BusinessObjectDataDaoImpl.java    From herd with Apache License 2.0 4 votes vote down vote up
/**
 * Create search restrictions per specified business object data search key.
 *
 * @param builder the criteria builder
 * @param businessObjectDataEntityRoot the root business object data entity
 * @param businessObjectFormatEntityJoin the join with the business object format table
 * @param businessObjectDataSearchKey the business object data search key
 * @param businessObjectDefinitionEntity the business object definition entity
 * @param fileTypeEntity the file type entity
 *
 * @return the search restrictions
 */
private Predicate getQueryPredicateBySearchKey(CriteriaBuilder builder, Root<BusinessObjectDataEntity> businessObjectDataEntityRoot,
    Join<BusinessObjectDataEntity, BusinessObjectFormatEntity> businessObjectFormatEntityJoin, BusinessObjectDataSearchKey businessObjectDataSearchKey,
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity, FileTypeEntity fileTypeEntity)
{
    // Create restriction on business object definition.
    Predicate predicate =
        builder.equal(businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.businessObjectDefinitionId), businessObjectDefinitionEntity.getId());

    // If specified, add restriction on business object format usage.
    if (!StringUtils.isEmpty(businessObjectDataSearchKey.getBusinessObjectFormatUsage()))
    {
        predicate = builder.and(predicate, builder.equal(builder.upper(businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.usage)),
            businessObjectDataSearchKey.getBusinessObjectFormatUsage().toUpperCase()));
    }

    // If specified, add restriction on business object format file type.
    if (fileTypeEntity != null)
    {
        predicate =
            builder.and(predicate, builder.equal(businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.fileTypeCode), fileTypeEntity.getCode()));
    }

    // If specified, add restriction on business object format version.
    if (businessObjectDataSearchKey.getBusinessObjectFormatVersion() != null)
    {
        predicate = builder.and(predicate, builder.equal(businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.businessObjectFormatVersion),
            businessObjectDataSearchKey.getBusinessObjectFormatVersion()));
    }

    // If specified, add restrictions per partition value filters.
    if (CollectionUtils.isNotEmpty(businessObjectDataSearchKey.getPartitionValueFilters()))
    {
        predicate = addPartitionValueFiltersToPredicate(businessObjectDataSearchKey.getPartitionValueFilters(), businessObjectDataEntityRoot,
            businessObjectFormatEntityJoin, builder, predicate);
    }

    // If specified, add restrictions per attribute value filters.
    if (CollectionUtils.isNotEmpty(businessObjectDataSearchKey.getAttributeValueFilters()))
    {
        predicate =
            addAttributeValueFiltersToPredicate(businessObjectDataSearchKey.getAttributeValueFilters(), businessObjectDataEntityRoot, builder, predicate);
    }

    // If specified, add restrictions per registration date range filter.
    if (businessObjectDataSearchKey.getRegistrationDateRangeFilter() != null)
    {
        predicate =
            addRegistrationDateRangeFilterToPredicate(businessObjectDataSearchKey.getRegistrationDateRangeFilter(), businessObjectDataEntityRoot, builder,
                predicate);
    }

    // If specified, add restrictions per latest valid filter.
    // We only apply restriction on business object data status here. For performance reasons,
    // selection of actual latest valid versions does not take place on the database end.
    if (BooleanUtils.isTrue(businessObjectDataSearchKey.isFilterOnLatestValidVersion()))
    {
        predicate = builder
            .and(predicate, builder.equal(businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.statusCode), BusinessObjectDataStatusEntity.VALID));
    }

    // If specified, add restrictions per retention expiration filter.
    if (BooleanUtils.isTrue(businessObjectDataSearchKey.isFilterOnRetentionExpiration()))
    {
        predicate =
            addRetentionExpirationFilterToPredicate(builder, businessObjectDataEntityRoot, businessObjectFormatEntityJoin, businessObjectDefinitionEntity,
                predicate);
    }

    return predicate;
}
 
Example 11
Source File: FilterDelegateImpl.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public boolean saveSettings(Element element) {
    boolean changed = false;
    Element e = element.element("defaultFilter");
    if (e == null)
        e = element.addElement("defaultFilter");

    UUID defaultId = null;
    Boolean applyDefault = false;

    for (FilterEntity filter : filterEntities) {
        if (BooleanUtils.isTrue(filter.getIsDefault())) {
            defaultId = filter.getId();
            applyDefault = filter.getApplyDefault();
            break;
        }
    }

    String newDef = defaultId != null ? defaultId.toString() : null;
    Attribute attr = e.attribute("id");
    String oldDef = attr != null ? attr.getValue() : null;
    if (!Objects.equals(oldDef, newDef)) {
        if (newDef == null && attr != null) {
            e.remove(attr);
        } else {
            if (attr == null)
                e.addAttribute("id", newDef);
            else
                attr.setValue(newDef);
        }
        changed = true;
    }
    Boolean newApplyDef = BooleanUtils.isTrue(applyDefault);
    Attribute applyDefaultAttr = e.attribute("applyDefault");
    Boolean oldApplyDef = applyDefaultAttr != null ? Boolean.valueOf(applyDefaultAttr.getValue()) : false;
    if (!Objects.equals(oldApplyDef, newApplyDef)) {
        if (applyDefaultAttr != null) {
            applyDefaultAttr.setValue(newApplyDef.toString());
        } else {
            e.addAttribute("applyDefault", newApplyDef.toString());
        }
        changed = true;
    }

    if (groupBoxExpandedChanged) {
        Element groupBoxExpandedEl = element.element("groupBoxExpanded");
        if (groupBoxExpandedEl == null)
            groupBoxExpandedEl = element.addElement("groupBoxExpanded");

        Boolean oldGroupBoxExpandedValue =
                groupBoxExpandedEl.getText().isEmpty() ? Boolean.TRUE : Boolean.valueOf(groupBoxExpandedEl.getText());

        Boolean newGroupBoxExpandedValue = groupBoxLayout.isExpanded();
        if (!Objects.equals(oldGroupBoxExpandedValue, newGroupBoxExpandedValue)) {
            groupBoxExpandedEl.setText(newGroupBoxExpandedValue.toString());
            changed = true;
        }
    }

    if (isMaxResultsLayoutVisible()) {
        if (maxResultValueChanged) {
            Element maxResultsEl = element.element("maxResults");
            if (maxResultsEl == null) {
                maxResultsEl = element.addElement("maxResults");
            }

            Integer newMaxResultsValue = maxResultsField.getValue();
            if (newMaxResultsValue != null) {
                maxResultsEl.setText(newMaxResultsValue.toString());
                changed = true;
            }
        }
    }

    return changed;
}
 
Example 12
Source File: FileInfo.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Boolean getDeepPath() {
	return BooleanUtils.isTrue(this.deepPath);
}
 
Example 13
Source File: ActionReset.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
		String codeAnswer = wi.getCodeAnswer();
		String credential = wi.getCredential();
		String password = wi.getPassword();
		if (StringUtils.isBlank(credential)) {
			throw new ExceptionCredentialEmpty();
		}
		if (StringUtils.isBlank(codeAnswer)) {
			throw new ExceptionCodeEmpty();
		}
		if (StringUtils.isBlank(password)) {
			throw new ExceptionPasswordEmpty();
		}
		Person person = business.person().getWithCredential(credential);
		if (null == person) {
			throw new ExceptionPersonNotExisted(credential);
		}
		person = emc.find(person.getId(), Person.class, ExceptionWhen.not_found);
		if (BooleanUtils.isTrue(Config.person().getSuperPermission())
				&& StringUtils.equals(Config.token().getPassword(), codeAnswer)) {
			logger.info("user:{} use superPermission.", credential);
		} else {
			if (!password.matches(Config.person().getPasswordRegex())) {
				throw new ExceptionInvalidPassword(Config.person().getPasswordRegexHint());
			}
			if (!business.instrument().code().validate(person.getMobile(), codeAnswer)) {
				throw new ExceptionInvalidCode();
			}
		}
		emc.beginTransaction(Person.class);
		person.setPassword(Crypto.encrypt(password, Config.token().getKey()));
		person.setChangePasswordTime(new Date());
		emc.check(person, CheckPersistType.all);
		emc.commit();
		Wo wo = new Wo();
		wo.setValue(true);
		result.setData(wo);
		return result;
	}
}
 
Example 14
Source File: Collect.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public Boolean getSslEnable() {
	return BooleanUtils.isTrue(this.sslEnable) ? true : false;
}
 
Example 15
Source File: FilterDelegateImpl.java    From cuba with Apache License 2.0 4 votes vote down vote up
/**
 * Loads filter entities, finds default filter and applies it if found
 */
@Override
public void loadFiltersAndApplyDefault() {
    initShortcutActions();
    initAdHocFilter();
    loadFilterEntities();
    FilterEntity defaultFilter = getDefaultFilter(filterEntities);
    initFilterSelectComponents();

    if (defaultFilter == null) {
        defaultFilter = adHocFilter;
    }

    try {
        setFilterEntity(defaultFilter);
    } catch (Exception e) {
        log.error("Exception on loading default filter '{}'", defaultFilter.getName(), e);
        getNotifications().create(Notifications.NotificationType.ERROR)
                .withCaption(messages.formatMainMessage("filter.errorLoadingDefaultFilter"))
                .withDescription(defaultFilter.getName())
                .show();
        defaultFilter = adHocFilter;
        setFilterEntity(adHocFilter);
    }

    if (defaultFilter != adHocFilter && (filterMode == FilterMode.GENERIC_MODE)) {
        Window window = getWindow();
        if (!WindowParams.DISABLE_AUTO_REFRESH.getBool(window.getContext())) {
            if (getResultingManualApplyRequired()) {
                if (BooleanUtils.isTrue(defaultFilter.getApplyDefault())) {
                    adapter.preventNextDataLoading();
                    apply(true);
                }
            } else {
                adapter.preventNextDataLoading();
                apply(true);
            }
            if (filterEntity != null && windowCaptionUpdateEnabled) {
                window.setDescription(getFilterCaption(filterEntity));
            } else
                window.setDescription(null);
        }
    }
}
 
Example 16
Source File: PresentationsImpl.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isAutoSave(Presentation p) {
    p = getPresentation(p.getId());
    return p != null && BooleanUtils.isTrue(p.getAutoSave());
}
 
Example 17
Source File: Communicate.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public Boolean wsEnable() {
	return BooleanUtils.isTrue(wsEnable);
}
 
Example 18
Source File: StorageServer.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public Boolean getEnable() {
	return BooleanUtils.isTrue(this.enable);
}
 
Example 19
Source File: V2Base.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
protected Predicate toFilterPredicate(EffectivePerson effectivePerson, Business business, FilterWi wi)
		throws Exception {
	EntityManager em = business.entityManagerContainer().get(Read.class);
	CriteriaBuilder cb = em.getCriteriaBuilder();
	CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class);
	Root<Read> root = cq.from(Read.class);
	Predicate p = cb.equal(root.get(Read_.person), effectivePerson.getDistinguishedName());
	if (ListTools.isNotEmpty(wi.getApplicationList())) {
		p = cb.and(p, root.get(Read_.application).in(wi.getApplicationList()));
	}
	if (ListTools.isNotEmpty(wi.getProcessList())) {
		p = cb.and(p, root.get(Read_.process).in(wi.getProcessList()));
	}
	if (DateTools.isDateTimeOrDate(wi.getStartTime())) {
		p = cb.and(p, cb.greaterThan(root.get(Read_.startTime), DateTools.parse(wi.getStartTime())));
	}
	if (DateTools.isDateTimeOrDate(wi.getEndTime())) {
		p = cb.and(p, cb.lessThan(root.get(Read_.startTime), DateTools.parse(wi.getEndTime())));
	}
	if (ListTools.isNotEmpty(wi.getCreatorPersonList())) {
		List<String> person_ids = business.organization().person().list(wi.getCreatorPersonList());
		p = cb.and(p, root.get(Read_.creatorPerson).in(person_ids));
	}
	if (ListTools.isNotEmpty(wi.getCreatorUnitList())) {
		List<String> unit_ids = business.organization().unit().list(wi.getCreatorUnitList());
		p = cb.and(p, root.get(Read_.creatorUnit).in(unit_ids));
	}
	if (ListTools.isNotEmpty(wi.getStartTimeMonthList())) {
		p = cb.and(p, root.get(Read_.startTimeMonth).in(wi.getStartTimeMonthList()));
	}
	boolean completed = BooleanUtils.isTrue(wi.getCompleted());
	boolean notCompleted = BooleanUtils.isTrue(wi.getNotCompleted());
	if (completed != notCompleted) {
		if (completed) {
			p = cb.and(p, cb.equal(root.get(Read_.completed), true));
		} else {
			p = cb.and(p, cb.or(cb.isNull(root.get(Read_.completed)), cb.equal(root.get(Read_.completed), false)));
		}
	}
	String key = StringTools.escapeSqlLikeKey(wi.getKey());
	if (StringUtils.isNotEmpty(key)) {
		key = "%" + key + "%";
		p = cb.and(p, cb.or(cb.like(root.get(Read_.title), key), cb.like(root.get(Read_.serial), key),
				cb.like(root.get(Read_.creatorPerson), key), cb.like(root.get(Read_.creatorUnit), key)));
	}
	return p;
}
 
Example 20
Source File: CenterServer.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public Boolean getRedeploy() {
	return BooleanUtils.isTrue(this.redeploy);
}