List of usage examples for org.apache.commons.lang BooleanUtils toBoolean
public static boolean toBoolean(String str)
Converts a String to a boolean (optimised for performance).
'true'
, 'on'
or 'yes'
(case insensitive) will return true
.
From source file:org.candlepin.service.impl.DefaultEntitlementCertServiceAdapter.java
/** * Modify the entitlements end date// w w w .j a v a 2 s .c o m * @param ent */ private void setupEntitlementEndDate(Entitlement ent) { Pool pool = ent.getPool(); Consumer consumer = ent.getConsumer(); Date startDate = new Date(); if (consumer.getCreated() != null) { startDate = consumer.getCreated(); } boolean isUnmappedGuestPool = BooleanUtils .toBoolean(pool.getAttributeValue(Pool.Attributes.UNMAPPED_GUESTS_ONLY)); if (isUnmappedGuestPool) { Date oneDayFromRegistration = new Date(startDate.getTime() + 24L * 60L * 60L * 1000L); log.info("Setting 24h expiration for unmapped guest pool entilement: {}", oneDayFromRegistration); ent.setEndDateOverride(oneDayFromRegistration); entCurator.merge(ent); } }
From source file:org.carewebframework.cal.ui.reporting.drilldown.DrillDownUtil.java
/** * Returns true if drill down icons are enabled. * * @return True if drill down icons are enabled. *///from w ww.j a v a2s. c o m public static boolean showIcons() { Boolean result = (Boolean) FrameworkUtil.getAttribute(Constants.PROPERTY_ID_DRILLDOWN); if (result == null) { try { String value = PropertyUtil.getValue(Constants.PROPERTY_ID_DRILLDOWN); result = BooleanUtils.toBoolean(value); } catch (Exception e) { result = true; } FrameworkUtil.setAttribute(Constants.PROPERTY_ID_DRILLDOWN, result); } return result; }
From source file:org.carewebframework.rpms.ui.anticoag.AntiCoagRecord.java
/** * @param data <code>//from w w w . ja v a 2 s. co m * V IEN [1] ^ Indication [2] ^ Visit Date [3] ^ Goal [4] ^ Min [5] ^ Max [6] ^ * Duration [7] ^ Start Date [8] ^ Facility Name [9] ^ Practitioner IEN [10] ^ Location IEN [11] ^ * Entered Date [12]^ Visit IEN [13] ^ Visit Category [14] ^ Visit Locked [15] ^ Comment[16] ^ * Practitioner Name [17] * </code> */ public AntiCoagRecord(String data) { String[] pcs = split(data, U, 17); setId(pcs[0]); setIndicated(BooleanUtils.toBoolean(pcs[1])); setVisitDate(VistAUtil.parseDate(pcs[2])); setGoalRange(pcs[3]); setGoalMin(parseDouble(pcs[4])); setGoalMax(parseDouble(pcs[5])); setDuration(pcs[6]); setStartDate(VistAUtil.parseDate(pcs[7])); setProvider(parseProvider(pcs[9], pcs[16])); setEnteredDate(VistAUtil.parseDate(pcs[11])); setVisitIEN(pcs[12]); setVisitCategory(pcs[13]); setVisitLocked("1".equals(pcs[14])); setComment(pcs[15]); }
From source file:org.carewebframework.shell.CareWebShell.java
/** * Perform additional initializations./*ww w . ja va 2 s.com*/ */ @Override public void afterCompose() { try { CommandUtil.associateCommand("help", this); appendChild(registeredStyles); appendChild(messageWindow = new MessageWindow()); desktop = new UIElementDesktop(this); ZKUtil.suppressContextMenu(this); appFramework.registerObject(userContextListener); String confirmClose = FrameworkWebSupport.getFrameworkProperty("confirmClose", "CAREWEB.CONFIRM.CLOSE"); if (StringUtils.isEmpty(confirmClose) || BooleanUtils.toBoolean(confirmClose)) { Clients.confirmClose(LBL_CONFIRM_CLOSE); } String layout = defaultLayoutName != null ? defaultLayoutName : FrameworkWebSupport.getFrameworkProperty("layout", "CAREWEB.LAYOUT.DEFAULT"); if (!StringUtils.isEmpty(layout)) { loadLayoutFromResource(layout); } } catch (Exception e) { log.error("Error initializing the shell.", e); throw new RuntimeException(e); } }
From source file:org.carewebframework.ui.sharedforms.ListViewForm.java
/** * Setter method for Layout property. This property allows an application to control the * position of the splitter bar and ordering of columns. * // ww w. j a v a2 s .c o m * @param layout The layout data. */ public void setLayout(String layout) { String[] pcs = StrUtil.split(layout, ";"); if (pcs.length > 0) { String[] spl = StrUtil.split(pcs[0], ":", 3); setSize(NumberUtils.toInt(spl[0])); sortColumn = NumberUtils.toInt(spl[1]); sortAscending = BooleanUtils.toBoolean(spl[2]); } for (int i = 1; i < pcs.length; i++) { String[] col = StrUtil.split(pcs[i], ":", 2); Listheader lhdr = getColumnByIndex(NumberUtils.toInt(col[0])); if (lhdr != null) { lhdr.setWidth(col[1]); ZKUtil.moveChild(lhdr, i - 1); } } doSort(); }
From source file:org.carewebframework.ui.zk.ZKUtil.java
/** * Returns named boolean attribute from the specified component. * //from www .j ava 2s .com * @param c The component containing the desired attribute. * @param attr The name of the attribute. * @return Value of named attribute, or null if not found. */ public static boolean getAttributeBoolean(Component c, String attr) { Boolean val = getAttribute(c, attr, Boolean.class); return val != null ? val : BooleanUtils.toBoolean(getAttributeString(c, attr)); }
From source file:org.carewebframework.vista.plugin.familyhistory.view.ConditionRenderer.java
/** * Render the row for the specified family member condition. * * @param row Row to render.//w ww . j ava 2 s . c o m * @param condition A family member condition. */ @Override public Component renderRow(Row row, Condition condition) { Component root = row.getFellowIfAny("root", true); Cell cell = createCell(row, null); A anchor = new A(); anchor.setIconSclass("glyphicon glyphicon-pencil"); anchor.addForward(Events.ON_CLICK, root, "onReviewCondition", condition); cell.appendChild(anchor); anchor = new A(); anchor.setIconSclass("glyphicon glyphicon-remove"); anchor.addForward(Events.ON_CLICK, root, "onDeleteCondition", condition); cell.appendChild(anchor); createCell(row, condition.getSCTText()); createCell(row, condition.getNote()); boolean approxAge = BooleanUtils.toBoolean(condition.isAgeApproximate()); String onsetAge = condition.getAgeAtOnset() == null ? "" : (approxAge ? "~" : "") + condition.getAgeAtOnset(); createCell(row, onsetAge); createCell(row, condition.getDateModified()); createCell(row, condition.getICD9()); row.setSclass("alert-warning"); return null; }
From source file:org.cleverbus.core.alerts.AlertsJmxConfiguration.java
@Override public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { Assert.notNull(attribute, "attribute must not be null"); String attrName = attribute.getName(); String value = (String) attribute.getValue(); AlertInfo alert = getAlert(attrName); if (StringUtils.endsWith(attrName, ENABLE_SUFFIX)) { alert.setEnabled(BooleanUtils.toBoolean(value)); } else if (StringUtils.endsWith(attrName, LIMIT_SUFFIX)) { alert.setLimit(Long.valueOf(value)); } else {/*from w w w . j a va 2s. c om*/ throw new IllegalStateException("unsupported attribute name '" + attrName + "'"); } }
From source file:org.cleverbus.core.alerts.AlertsPropertiesConfiguration.java
/** * Initializes configuration from properties. *//* w w w . j a v a 2 s.c o m*/ private void initProps() { // example of alert configuration // alerts.900.id=WAITING_MSG_ALERT // alerts.900.limit=0 // alerts.900.sql=SELECT COUNT(*) FROM message WHERE state = 'WAITING_FOR_RES' // alerts.900.enabled=true // alerts.900.mail.subject=There are %d message(s) in WAITING_FOR_RESPONSE state for more then %d seconds. // alerts.900.mail.body=Alert: notification about WAITING messages // get relevant properties for alerts List<String> propNames = new ArrayList<String>(); Enumeration<?> propNamesEnum = properties.propertyNames(); while (propNamesEnum.hasMoreElements()) { String propName = (String) propNamesEnum.nextElement(); if (propName.startsWith(ALERT_PROP_PREFIX)) { propNames.add(propName); } } // get alert IDs Set<String> orders = new HashSet<String>(); Pattern pattern = Pattern.compile("alerts\\.(\\d+)\\.id"); for (String propName : propNames) { Matcher matcher = pattern.matcher(propName); if (matcher.matches()) { String order = StringUtils.substringBetween(propName, ALERT_PROP_PREFIX, "."); if (orders.contains(order)) { throw new IllegalStateException( "Wrong alert's configuration - alert order '" + order + "' was already used."); } else { orders.add(order); } } } // get property values Set<String> ids = new HashSet<String>(); for (String order : orders) { String propPrefix = ALERT_PROP_PREFIX + order + "."; String id = properties.getProperty(propPrefix + ID_PROP); // check if id is unique if (ids.contains(id)) { throw new IllegalStateException("Wrong alert's configuration - id '" + id + "' is not unique."); } else { ids.add(id); } String limit = properties.getProperty(propPrefix + LIMIT_PROP); String sql = properties.getProperty(propPrefix + SQL_PROP); // check if sql contains count() if (!StringUtils.containsIgnoreCase(sql, "count(")) { throw new IllegalStateException( "Wrong alert's configuration - SQL clause for id '" + id + "' doesn't contain count()."); } String enabled = properties.getProperty(propPrefix + ENABLED_PROP); enabled = enabled == null ? "true" : enabled; String subject = properties.getProperty(propPrefix + MAIL_SBJ_PROP); String body = properties.getProperty(propPrefix + MAIL_BODY_PROP); // add new alert try { AlertInfo alertInfo = new AlertInfo(id, Long.valueOf(limit), sql, BooleanUtils.toBoolean(enabled), subject, body); addAlert(alertInfo); } catch (Exception ex) { throw new IllegalStateException("Wrong alert's configuration - conversion error", ex); } } }
From source file:org.cloudbyexample.dc.shell.command.ApplicationCommand.java
@CliCommand(value = CONTAINER_TEMPLATE_CMD, help = CONTAINER_TEMPLATE_HELP) public void containerTemplate( @CliOption(key = { "image" }, mandatory = true, help = "Image template name.") String image, @CliOption(key = { "name" }, help = "Name of the container.") String name, @CliOption(key = {/*from w ww.j a v a2 s.c o m*/ "expose-ports" }, help = "Expose any available ports externally.") String exposePortsParam, @CliOption(key = { "cluster-size" }, help = "Cluster size (number of containers to make from this container template).") Integer clusterSize, @CliOption(key = { "links" }, help = "Comma delimitted links to bind to [name:alias]. ex: 'postgresql:db.") String linksParam) { boolean exposePorts = BooleanUtils.toBoolean(exposePortsParam); ContainerTemplate containerTemplate = new ContainerTemplate().withImage(image).withExposePorts(exposePorts) .withClusterSize((clusterSize != null ? clusterSize : 1)); if (StringUtils.isNotBlank(name)) { containerTemplate = containerTemplate.withName(name); } processLinks(containerTemplate, linksParam); commandState.getApplication().withContainerTemplates(containerTemplate); }