List of usage examples for org.apache.commons.lang BooleanUtils toBooleanObject
public static Boolean toBooleanObject(String str)
Converts a String to a Boolean.
'true'
, 'on'
or 'yes'
(case insensitive) will return true
.
From source file:org.eclipse.gyrex.jobs.internal.externalprocess.ExternalProcessJobParameter.java
public static ExternalProcessJobParameter fromParameter(final Map<String, String> params, final boolean resolveInheritedEnvironmentVariables) { final ExternalProcessJobParameter p = new ExternalProcessJobParameter(); // collect arguments into a sorting map final SortedMap<String, String> arguments = new TreeMap<>(new ArgumentsParameterKeyComparator()); // walk through all possible parameter final Map<String, String> environment = new HashMap<>(); for (final Entry<String, String> e : params.entrySet()) { String value = e.getValue(); switch (e.getKey()) { case PARAM_COMMAND: p.setCommand(value);//ww w .jav a 2s . c o m break; case PARAM_CLEAR_ENVIRONMENT: p.setClearEnvironment(BooleanUtils.toBooleanObject(value)); break; case PARAM_EXPECTED_RETURN_CODE: p.setExpectedReturnCode(NumberUtils.toInt(value)); break; case PARAM_WORKING_DIR: p.setWorkingDir(value); break; default: if (e.getKey().startsWith(PARAM_PREFIX_ENV)) { final String name = e.getKey().substring(PARAM_PREFIX_ENV.length()); if (resolveInheritedEnvironmentVariables && StringUtils.equals(ENV_VALUE_INHERIT, value)) { value = System.getenv(name); } environment.put(name, value); } else if (e.getKey().startsWith(PARAM_PREFIX_ARG)) { arguments.put(e.getKey().substring(PARAM_PREFIX_ARG.length()), value); } break; } } if (!arguments.isEmpty()) { p.setArguments(new ArrayList<>(arguments.values())); } if (!environment.isEmpty()) { p.setEnvironment(environment); } return p; }
From source file:org.fao.geonet.Geonetwork.java
/** * Init StatusActions./* w w w .j a va2s. c o m*/ * */ private Class setupStatusActions(ServiceConfig handlerConfig) throws ClassNotFoundException { // Status actions class - load it String statusActionsClassName = handlerConfig.getMandatoryValue(Geonet.Config.STATUS_ACTIONS_CLASS); Class statusActionsClass = Class.forName(statusActionsClassName); String useHtml5uiParam = handlerConfig.getValue(Geonet.Config.USE_HTML5_GUI); boolean useHtml5ui; if (useHtml5uiParam != null) { useHtml5ui = BooleanUtils.isTrue(BooleanUtils.toBooleanObject(useHtml5uiParam)); } else { logger.info("Parameter " + Geonet.Config.USE_HTML5_GUI + " not found. Default to true."); useHtml5ui = true; } // init html5 value if possible try { final String HTML5_PROP_NAME = "useHtml5ui"; StatusActions statusActionsImpl = (StatusActions) statusActionsClass.newInstance(); if (PropertyUtils.isWriteable(statusActionsImpl, HTML5_PROP_NAME)) { BeanUtils.setProperty(statusActionsImpl, HTML5_PROP_NAME, useHtml5ui); logger.info(Geonet.Config.USE_HTML5_GUI + " set to " + useHtml5ui); } else { logger.warning("Could not find setter for " + Geonet.Config.USE_HTML5_GUI); } } catch (Exception ex) { logger.warning("Could not inject " + Geonet.Config.USE_HTML5_GUI + " value: " + ex.getMessage()); } return statusActionsClass; }
From source file:org.fao.geonet.services.dataprep.ChangeColumnType.java
public void init(String appPath, ServiceConfig params) throws Exception { this.stylePath = appPath + Geonet.Path.IMPORT_STYLESHEETS; this.jsonOutput = BooleanUtils.toBooleanObject(params.getValue("jsonOutput")); this.cmd = params.getValue("cmd"); }
From source file:org.hoteia.qalingo.core.service.impl.WebBackofficeServiceImpl.java
private void updateCatalogCategoryMasterAttribute( final CatalogCategoryMasterAttribute catalogCategoryMasterAttribute, final String attributeValue) { AttributeDefinition attributeDefinition = catalogCategoryMasterAttribute.getAttributeDefinition(); if (AttributeDefinition.ATTRIBUTE_TYPE_STRING == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setStringValue(attributeValue); } else if (AttributeDefinition.ATTRIBUTE_TYPE_DOUBLE == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setDoubleValue(Double.parseDouble(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_FLOAT == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setFloatValue(Float.parseFloat(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_INTEGER == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setIntegerValue(Integer.parseInt(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BLOB == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setBlobValue(attributeValue.getBytes()); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BOOLEAN == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setBooleanValue(BooleanUtils.toBooleanObject(attributeValue)); }// www.j a v a 2 s . c om }
From source file:org.hoteia.qalingo.core.service.impl.WebBackofficeServiceImpl.java
private CatalogCategoryMasterAttribute buildCatalogCategoryMasterAttribute(final MarketArea currentMarketArea, final Localization currentLocalization, final String attributeKey, final String attributeValue, boolean isGlobal) { //TODO : denis : 20130125 : add cache AttributeDefinition attributeDefinition = attributeService.getAttributeDefinitionByCode(attributeKey); CatalogCategoryMasterAttribute catalogCategoryMasterAttribute = new CatalogCategoryMasterAttribute(); catalogCategoryMasterAttribute.setAttributeDefinition(attributeDefinition); catalogCategoryMasterAttribute.setLocalizationCode(currentLocalization.getCode()); catalogCategoryMasterAttribute.setMarketAreaId(currentMarketArea.getId()); catalogCategoryMasterAttribute.setStartDate(new Date()); if (AttributeDefinition.ATTRIBUTE_TYPE_STRING == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setStringValue(attributeValue); } else if (AttributeDefinition.ATTRIBUTE_TYPE_DOUBLE == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setDoubleValue(Double.parseDouble(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_FLOAT == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setFloatValue(Float.parseFloat(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_INTEGER == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setIntegerValue(Integer.parseInt(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BLOB == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setBlobValue(attributeValue.getBytes()); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BOOLEAN == attributeDefinition.getAttributeType()) { catalogCategoryMasterAttribute.setBooleanValue(BooleanUtils.toBooleanObject(attributeValue)); }/* w w w . ja v a 2s . c om*/ return catalogCategoryMasterAttribute; }
From source file:org.hoteia.qalingo.core.service.impl.WebBackofficeServiceImpl.java
private void updateCatalogCategoryVirtualAttribute( final CatalogCategoryVirtualAttribute catalogCategoryVirtualAttribute, final String attributeValue) { AttributeDefinition attributeDefinition = catalogCategoryVirtualAttribute.getAttributeDefinition(); if (AttributeDefinition.ATTRIBUTE_TYPE_STRING == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setStringValue(attributeValue); } else if (AttributeDefinition.ATTRIBUTE_TYPE_DOUBLE == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setDoubleValue(Double.parseDouble(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_FLOAT == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setFloatValue(Float.parseFloat(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_INTEGER == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setIntegerValue(Integer.parseInt(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BLOB == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setBlobValue(attributeValue.getBytes()); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BOOLEAN == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setBooleanValue(BooleanUtils.toBooleanObject(attributeValue)); }/* ww w . j a v a 2s .c o m*/ }
From source file:org.hoteia.qalingo.core.service.impl.WebBackofficeServiceImpl.java
private CatalogCategoryVirtualAttribute buildCatalogCategoryVirtualAttribute(final MarketArea currentMarketArea, final Localization currentLocalization, final String attributeKey, final String attributeValue, boolean isGlobal) { //TODO : denis : 20130125 : add cache AttributeDefinition attributeDefinition = attributeService.getAttributeDefinitionByCode(attributeKey); CatalogCategoryVirtualAttribute catalogCategoryVirtualAttribute = new CatalogCategoryVirtualAttribute(); catalogCategoryVirtualAttribute.setAttributeDefinition(attributeDefinition); catalogCategoryVirtualAttribute.setLocalizationCode(currentLocalization.getCode()); catalogCategoryVirtualAttribute.setMarketAreaId(currentMarketArea.getId()); catalogCategoryVirtualAttribute.setStartDate(new Date()); if (AttributeDefinition.ATTRIBUTE_TYPE_STRING == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setStringValue(attributeValue); } else if (AttributeDefinition.ATTRIBUTE_TYPE_DOUBLE == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setDoubleValue(Double.parseDouble(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_FLOAT == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setFloatValue(Float.parseFloat(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_INTEGER == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setIntegerValue(Integer.parseInt(attributeValue)); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BLOB == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setBlobValue(attributeValue.getBytes()); } else if (AttributeDefinition.ATTRIBUTE_TYPE_BOOLEAN == attributeDefinition.getAttributeType()) { catalogCategoryVirtualAttribute.setBooleanValue(BooleanUtils.toBooleanObject(attributeValue)); }/*from ww w. j av a 2s . c o m*/ return catalogCategoryVirtualAttribute; }
From source file:org.jboss.windup.decorator.integration.mvn.MavenCentralSHA1VersionDecorator.java
public void setActive(String active) { this.active = BooleanUtils.toBooleanObject(active); }
From source file:org.kuali.rice.kew.xml.RuleTemplateXmlParser.java
/** * Updates the rule template defaults options with those in the defaults element * @param defaultsElement the ruleDefaults element * @param updatedRuleTemplate the Rule Template being updated *///from w ww .j a v a 2 s. co m protected void updateRuleTemplateOptions(Element defaultsElement, RuleTemplateBo updatedRuleTemplate, boolean isDelegation) throws XmlException { // the possible defaults options // NOTE: the current implementation will remove any existing RuleTemplateOption records for any values which are null, i.e. not set in the incoming XML. // to pro-actively set default values for omitted options, simply set those values here, and records will be added if not present String defaultActionRequested = null; Boolean supportsComplete = null; Boolean supportsApprove = null; Boolean supportsAcknowledge = null; Boolean supportsFYI = null; // remove any RuleTemplateOptions the template may have but that we know we aren't going to update/reset // (not sure if this case even exists...does anything else set rule template options?) updatedRuleTemplate.removeNonDefaultOptions(); // read in new settings if (defaultsElement != null) { defaultActionRequested = defaultsElement.getChildText(DEFAULT_ACTION_REQUESTED, RULE_TEMPLATE_NAMESPACE); supportsComplete = BooleanUtils .toBooleanObject(defaultsElement.getChildText(SUPPORTS_COMPLETE, RULE_TEMPLATE_NAMESPACE)); supportsApprove = BooleanUtils .toBooleanObject(defaultsElement.getChildText(SUPPORTS_APPROVE, RULE_TEMPLATE_NAMESPACE)); supportsAcknowledge = BooleanUtils .toBooleanObject(defaultsElement.getChildText(SUPPORTS_ACKNOWLEDGE, RULE_TEMPLATE_NAMESPACE)); supportsFYI = BooleanUtils .toBooleanObject(defaultsElement.getChildText(SUPPORTS_FYI, RULE_TEMPLATE_NAMESPACE)); } if (!isDelegation) { // if this is not a delegation template, store the template options that govern rule action constraints // in the RuleTemplateOptions of the template // we have two options for this behavior: // 1) conditionally parse above, and then unconditionally set/unset the properties; this will have the effect of REMOVING // any of these previously specified rule template options (and is arguably the right thing to do) // 2) unconditionally parse above, and then conditionally set/unset the properties; this will have the effect of PRESERVING // the existing rule template options on this template if it is a delegation template (which of course will be overwritten // by this very same code if they subsequently upload without the delegation flag) // This is a minor point, but the second implementation is chosen as it preserved the current behavior updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KewApiConstants.ACTION_REQUEST_DEFAULT_CD, defaultActionRequested); updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KewApiConstants.ACTION_REQUEST_APPROVE_REQ, supportsApprove); updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, supportsAcknowledge); updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KewApiConstants.ACTION_REQUEST_FYI_REQ, supportsFYI); updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KewApiConstants.ACTION_REQUEST_COMPLETE_REQ, supportsComplete); } }
From source file:org.kuali.rice.kew.xml.RuleTemplateXmlParser.java
/** * /* w w w. j a va 2s . c o m*/ * Updates the default/template rule options with those in the defaults element * @param defaultsElement the ruleDefaults element * @param updatedRuleTemplate the Rule Template being updated * @return whether this is a delegation rule template */ protected boolean updateRuleDefaults(Element defaultsElement, RuleTemplateBo updatedRuleTemplate) throws XmlException { // NOTE: implementation detail: in contrast with the other options, the delegate template, and the rule attributes, // we unconditionally blow away the default rule and re-create it (we don't update the existing one, if there is one) if (updatedRuleTemplate.getId() != null) { RuleBaseValues ruleDefaults = KEWServiceLocator.getRuleService() .findDefaultRuleByRuleTemplateId(updatedRuleTemplate.getId()); if (ruleDefaults != null) { List ruleDelegationDefaults = KEWServiceLocator.getRuleDelegationService() .findByDelegateRuleId(ruleDefaults.getId()); // delete the rule KEWServiceLocator.getRuleService().delete(ruleDefaults.getId()); // delete the associated rule delegation defaults for (Iterator iterator = ruleDelegationDefaults.iterator(); iterator.hasNext();) { RuleDelegationBo ruleDelegation = (RuleDelegationBo) iterator.next(); KEWServiceLocator.getRuleDelegationService().delete(ruleDelegation.getRuleDelegationId()); } } } boolean isDelegation = false; if (defaultsElement != null) { String delegationTypeCode = defaultsElement.getChildText(DELEGATION_TYPE, RULE_TEMPLATE_NAMESPACE); DelegationType delegationType = null; isDelegation = !org.apache.commons.lang.StringUtils.isEmpty(delegationTypeCode); String description = defaultsElement.getChildText(DESCRIPTION, RULE_TEMPLATE_NAMESPACE); // would normally be validated via schema but might not be present if invoking RuleXmlParser directly if (description == null) { throw new XmlException("Description must be specified in rule defaults"); } String fromDate = defaultsElement.getChildText(FROM_DATE, RULE_TEMPLATE_NAMESPACE); String toDate = defaultsElement.getChildText(TO_DATE, RULE_TEMPLATE_NAMESPACE); // toBooleanObject ensures that if the value is null (not set) that the Boolean object will likewise be null (will not default to a value) Boolean forceAction = BooleanUtils .toBooleanObject(defaultsElement.getChildText(FORCE_ACTION, RULE_TEMPLATE_NAMESPACE)); Boolean active = BooleanUtils .toBooleanObject(defaultsElement.getChildText(ACTIVE, RULE_TEMPLATE_NAMESPACE)); if (isDelegation) { delegationType = DelegationType.parseCode(delegationTypeCode); if (delegationType == null) { throw new XmlException( "Invalid delegation type '" + delegationType + "'." + " Expected one of: " + DelegationType.PRIMARY.getCode() + "," + DelegationType.SECONDARY.getCode()); } } // create our "default rule" which encapsulates the defaults for the rule RuleBaseValues ruleDefaults = new RuleBaseValues(); // set simple values ruleDefaults.setRuleTemplate(updatedRuleTemplate); ruleDefaults.setRuleTemplateId(updatedRuleTemplate.getId()); ruleDefaults.setDocTypeName(DUMMY_DOCUMENT_TYPE); ruleDefaults.setTemplateRuleInd(Boolean.TRUE); ruleDefaults.setCurrentInd(Boolean.TRUE); ruleDefaults.setVersionNbr(new Integer(0)); ruleDefaults.setDescription(description); // these are non-nullable fields, so default them if they were not set in the defaults section ruleDefaults.setForceAction(Boolean.valueOf(BooleanUtils.isTrue(forceAction))); ruleDefaults.setActive(Boolean.valueOf(BooleanUtils.isTrue(active))); if (ruleDefaults.getActivationDate() == null) { ruleDefaults.setActivationDate(new Timestamp(System.currentTimeMillis())); } ruleDefaults.setFromDateValue(formatDate("fromDate", fromDate)); ruleDefaults.setToDateValue(formatDate("toDate", toDate)); // ok, if this is a "Delegate Template", then we need to set this other RuleDelegation object which contains // some delegation-related info RuleDelegationBo ruleDelegationDefaults = null; if (isDelegation) { ruleDelegationDefaults = new RuleDelegationBo(); ruleDelegationDefaults.setDelegationRule(ruleDefaults); ruleDelegationDefaults.setDelegationType(delegationType); ruleDelegationDefaults.setResponsibilityId(KewApiConstants.ADHOC_REQUEST_RESPONSIBILITY_ID); } // explicitly save the new rule delegation defaults and default rule KEWServiceLocator.getRuleTemplateService().saveRuleDefaults(ruleDelegationDefaults, ruleDefaults); } else { // do nothing, rule defaults will be deleted if ruleDefaults element is omitted } return isDelegation; }