List of usage examples for java.lang Boolean toString
public String toString()
From source file:org.keycloak.testsuite.federation.kerberos.AbstractKerberosTest.java
protected void updateProviderValidatePasswordPolicy(Boolean validatePasswordPolicy) { List<ComponentRepresentation> reps = testRealmResource().components().query("test", UserStorageProvider.class.getName()); Assert.assertEquals(1, reps.size()); ComponentRepresentation kerberosProvider = reps.get(0); kerberosProvider.getConfig().putSingle(LDAPConstants.VALIDATE_PASSWORD_POLICY, validatePasswordPolicy.toString()); testRealmResource().components().component(kerberosProvider.getId()).update(kerberosProvider); }
From source file:com.cloud.hypervisor.ovm3.resources.helpers.Ovm3HypervisorSupport.java
public FenceAnswer execute(FenceCommand cmd) { LOGGER.debug("FenceCommand"); try {// w w w. jav a 2 s . co m Boolean res = false; return new FenceAnswer(cmd, res, res.toString()); } catch (Exception e) { LOGGER.error("Unable to fence" + cmd.getHostIp(), e); return new FenceAnswer(cmd, false, e.getMessage()); } }
From source file:org.openmrs.web.controller.ConceptStatsFormController.java
/** * Called prior to form display. Allows for data to be put in the request to be used in the view * * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest) *//* www . java2s.c om*/ protected Map<String, Object> referenceData(HttpServletRequest request) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); if (!Context.hasPrivilege("View Observations")) { return map; } MessageSourceAccessor msa = getMessageSourceAccessor(); Locale locale = Context.getLocale(); ConceptService cs = Context.getConceptService(); String conceptId = request.getParameter("conceptId"); //List<Obs> obs = new Vector<Obs>(); //List<Obs> obsAnswered = new Vector<Obs>(); if (conceptId != null) { Concept concept = cs.getConcept(Integer.valueOf(conceptId)); ObsService obsService = Context.getObsService(); if (concept != null) { // previous/next ids for links map.put("previousConcept", cs.getPrevConcept(concept)); map.put("nextConcept", cs.getNextConcept(concept)); //obs = obsService.getObservations(concept, "valueNumeric, obsId"); //obsAnswered = obsService.getObservationsAnsweredByConcept(concept); if (ConceptDatatype.NUMERIC.equals(concept.getDatatype().getHl7Abbreviation())) { map.put("displayType", "numeric"); List<Obs> numericAnswers = obsService.getObservations(null, null, Collections.singletonList(concept), null, Collections.singletonList(OpenmrsConstants.PERSON_TYPE.PERSON), null, Collections.singletonList("valueNumeric"), null, null, null, null, false); if (numericAnswers.size() > 0) { Double min = numericAnswers.get(0).getValueNumeric(); Double max = (Double) numericAnswers.get(numericAnswers.size() - 1).getValueNumeric(); Double median = (Double) numericAnswers.get(numericAnswers.size() / 2).getValueNumeric(); Map<Double, Integer> counts = new HashMap<Double, Integer>(); // counts for the histogram Double total = 0.0; // sum of values. used for mean // dataset setup for lineChart TimeSeries timeSeries = new TimeSeries(concept.getName().getName(), Day.class); TimeSeriesCollection timeDataset = new TimeSeriesCollection(); Calendar calendar = Calendar.getInstance(); // array for histogram double[] obsNumerics = new double[(numericAnswers.size())]; Integer i = 0; for (Obs obs : numericAnswers) { Date date = (Date) obs.getObsDatetime(); Double value = (Double) obs.getValueNumeric(); // for mean calculation total += value; // for histogram obsNumerics[i++] = value; Integer count = counts.get(value); counts.put(value, count == null ? 1 : count + 1); // for line chart calendar.setTime(date); Day day = new Day(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1, // January = 0 calendar.get(Calendar.YEAR) < 1900 ? 1900 : calendar.get(Calendar.YEAR) // jfree chart doesn't like the 19th century ); timeSeries.addOrUpdate(day, value); } Double size = new Double(numericAnswers.size()); Double mean = total / size; map.put("size", numericAnswers.size()); map.put("min", min); map.put("max", max); map.put("mean", mean); map.put("median", median); // create histogram chart HistogramDataset histDataset = new HistogramDataset(); // dataset for histogram histDataset.addSeries(concept.getName().getName(), obsNumerics, counts.size()); JFreeChart histogram = ChartFactory.createHistogram(concept.getName().getName(), msa.getMessage("Concept.stats.histogramDomainAxisTitle"), msa.getMessage("Concept.stats.histogramRangeAxisTitle"), histDataset, PlotOrientation.VERTICAL, false, true, false); map.put("histogram", histogram); if (size > 25) { // calculate 98th percentile of the data: Double x = 0.98; Integer xpercentile = (int) (x * size); Double upperQuartile = numericAnswers.get(xpercentile).getValueNumeric(); Double lowerQuartile = numericAnswers.get((int) (size - xpercentile)).getValueNumeric(); Double innerQuartile = upperQuartile - lowerQuartile; Double innerQuartileLimit = innerQuartile * 1.5; // outliers will be greater than this from the upper/lower quartile Double upperQuartileLimit = upperQuartile + innerQuartileLimit; Double lowerQuartileLimit = lowerQuartile - innerQuartileLimit; List<Obs> outliers = new Vector<Obs>(); // move outliers to the outliers list // removing lower quartile outliers for (i = 0; i < size - xpercentile; i++) { Obs possibleOutlier = numericAnswers.get(i); if (possibleOutlier.getValueNumeric() >= lowerQuartileLimit) { break; // quit if this value is greater than the lower limit } outliers.add(possibleOutlier); } // removing upper quartile outliers for (i = size.intValue() - 1; i >= xpercentile; i--) { Obs possibleOutlier = numericAnswers.get(i); if (possibleOutlier.getValueNumeric() <= upperQuartileLimit) { break; // quit if this value is less than the upper limit } outliers.add(possibleOutlier); } numericAnswers.removeAll(outliers); double[] obsNumericsOutliers = new double[(numericAnswers.size())]; i = 0; counts.clear(); for (Obs values : numericAnswers) { Double value = values.getValueNumeric(); obsNumericsOutliers[i++] = value; Integer count = counts.get(value); counts.put(value, count == null ? 1 : count + 1); } // create outlier histogram chart HistogramDataset outlierHistDataset = new HistogramDataset(); outlierHistDataset.addSeries(concept.getName().getName(), obsNumericsOutliers, counts.size()); JFreeChart histogramOutliers = ChartFactory.createHistogram(concept.getName().getName(), msa.getMessage("Concept.stats.histogramDomainAxisTitle"), msa.getMessage("Concept.stats.histogramRangeAxisTitle"), outlierHistDataset, PlotOrientation.VERTICAL, false, true, false); map.put("histogramOutliers", histogramOutliers); map.put("outliers", outliers); } // create line graph chart timeDataset.addSeries(timeSeries); JFreeChart lineChart = ChartFactory.createTimeSeriesChart(concept.getName().getName(), msa.getMessage("Concept.stats.lineChartDomainAxisLabel"), msa.getMessage("Concept.stats.lineChartRangeAxisLabel"), timeDataset, false, true, false); map.put("timeSeries", lineChart); } } else if (ConceptDatatype.BOOLEAN.equals(concept.getDatatype().getHl7Abbreviation())) { // create bar chart for boolean answers map.put("displayType", "boolean"); List<Obs> obs = obsService.getObservations(null, null, Collections.singletonList(concept), null, Collections.singletonList(OpenmrsConstants.PERSON_TYPE.PERSON), null, null, null, null, null, null, false); DefaultPieDataset pieDataset = new DefaultPieDataset(); // count the number of unique answers Map<String, Integer> counts = new HashMap<String, Integer>(); for (Obs o : obs) { Boolean answer = o.getValueAsBoolean(); if (answer == null) { answer = false; } String name = answer.toString(); Integer count = counts.get(name); counts.put(name, count == null ? 1 : count + 1); } // put the counts into the dataset for (Map.Entry<String, Integer> entry : counts.entrySet()) { pieDataset.setValue(entry.getKey(), entry.getValue()); } JFreeChart pieChart = ChartFactory.createPieChart(concept.getName().getName(), pieDataset, true, true, false); map.put("pieChart", pieChart); } else if (ConceptDatatype.CODED.equals(concept.getDatatype().getHl7Abbreviation())) { // create pie graph for coded answers map.put("displayType", "coded"); List<Obs> obs = obsService.getObservations(null, null, Collections.singletonList(concept), null, Collections.singletonList(OpenmrsConstants.PERSON_TYPE.PERSON), null, null, null, null, null, null, false); DefaultPieDataset pieDataset = new DefaultPieDataset(); // count the number of unique answers Map<String, Integer> counts = new HashMap<String, Integer>(); for (Obs o : obs) { Concept value = o.getValueCoded(); String name; if (value == null) { name = "[value_coded is null]"; } else { name = value.getName().getName(); } Integer count = counts.get(name); counts.put(name, count == null ? 1 : count + 1); } // put the counts into the dataset for (Map.Entry<String, Integer> entry : counts.entrySet()) { pieDataset.setValue(entry.getKey(), entry.getValue()); } JFreeChart pieChart = ChartFactory.createPieChart(concept.getName().getName(), pieDataset, true, true, false); map.put("pieChart", pieChart); } } } //map.put("obs", obs); //map.put("obsAnswered", obsAnswered); map.put("locale", locale.getLanguage().substring(0, 2)); return map; }
From source file:fr.itldev.koya.webscript.dossier.ToggleConfidential.java
@Override public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException { Map<String, String> urlParams = KoyaWebscript.getUrlParamsMap(req); Map<String, Object> postParams = KoyaWebscript.getJsonMap(req); Boolean isConfidential = false; try {// w ww . j av a 2 s.c om SecuredItem item = koyaNodeService.getSecuredItem( koyaNodeService.getNodeRef((String) urlParams.get(KoyaWebscript.WSCONST_NODEREF))); User u = userService.getUserByUsername(authenticationService.getCurrentUserName()); isConfidential = subSpaceAclService.toggleConfidential(u, item, Boolean.valueOf(postParams.get("confidential").toString())); } catch (KoyaServiceException ex) { throw new WebScriptException("KoyaError : " + ex.getErrorCode().toString()); } res.setContentType("application/json"); res.getWriter().write(isConfidential.toString()); }
From source file:com.cinchapi.concourse.util.ConvertTest.java
@Test public void testConvertBoolean() { Boolean bool = Random.getBoolean(); String boolString = scrambleCase(bool.toString()); Assert.assertEquals(bool, Convert.stringToJava(boolString)); }
From source file:org.obiba.mica.config.MailConfiguration.java
@Bean public JavaMailSenderImpl javaMailSender() { log.debug("Configuring mail server"); String host = propertyResolver.getProperty(PROP_HOST, DEFAULT_PROP_HOST); int port = propertyResolver.getProperty(PROP_PORT, Integer.class, 0); String user = propertyResolver.getProperty(PROP_USER); String password = propertyResolver.getProperty(PROP_PASSWORD); String protocol = propertyResolver.getProperty(PROP_PROTO); Boolean tls = propertyResolver.getProperty(PROP_TLS, Boolean.class, false); Boolean auth = propertyResolver.getProperty(PROP_AUTH, Boolean.class, false); JavaMailSenderImpl sender = new JavaMailSenderImpl(); if (host != null && !host.isEmpty()) { sender.setHost(host);/* w ww . j av a 2 s. c o m*/ } else { log.warn("Warning! Your SMTP server is not configured. We will try to use one on localhost."); log.debug("Did you configure your SMTP settings in your application.yml?"); sender.setHost(DEFAULT_HOST); } sender.setPort(port); sender.setUsername(user); sender.setPassword(password); Properties sendProperties = new Properties(); sendProperties.setProperty(PROP_SMTP_AUTH, auth.toString()); sendProperties.setProperty(PROP_STARTTLS, tls.toString()); sendProperties.setProperty(PROP_TRANSPORT_PROTO, protocol); sender.setJavaMailProperties(sendProperties); return sender; }
From source file:com.cinchapi.concourse.util.ConvertTest.java
@Test public void testCannotConvertLinkFromBooleanValue() { Boolean number = Random.getBoolean(); String value = MessageFormat.format("{0}{1}{0}", "@", number.toString()); Assert.assertFalse(Convert.stringToJava(value) instanceof Link); }
From source file:fr.mailjet.rest.impl.ListsRESTServiceImpl.java
@Override public String addContact(EnumReturnType parType, Integer parListId, String parEmail, Boolean parForce) throws UniformInterfaceException, IllegalArgumentException { if (parListId == null || StringUtils.isEmpty(parEmail)) throw new IllegalArgumentException(); MultivaluedMap<String, String> locParameters = this.createHTTPProperties(parType); locParameters.putSingle(_ListId, parListId.toString()); locParameters.putSingle(_contact, parEmail); if (parForce != null) { locParameters.putSingle(_force, parForce.toString()); }/*from w w w . j a v a 2 s .c om*/ return this.createPOSTRequest("listsAddcontact", locParameters); }
From source file:com.aurel.track.fieldType.runtime.custom.check.CustomCheckBoxSingleRT.java
/** * Get the ISO show value for locale independent exporting to xml * typically same as show value, date and number values are formatted by iso format * @param fieldID//from ww w . j a va2s .c om * @param parameterCode * @param value * @param workItemID * @param localLookupContainer * @param locale * @return */ @Override public String getShowISOValue(Integer fieldID, Integer parameterCode, Object value, Integer workItemID, LocalLookupContainer localLookupContainer, Locale locale) { if (value != null) { //if the attribute value of the workItem (or workItemOld) was loaded from the database //than it is set to a boolean value (see getSpecificAttribute()) //So try converting it to a Boolean Boolean boolValue = null; try { boolValue = (Boolean) value; } catch (Exception e) { LOGGER.debug("Casting the value type " + value.getClass().getName() + " to Boolean failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (boolValue != null) { return boolValue.toString(); } } return ""; }
From source file:com.tremolosecurity.provisioning.core.providers.AlfrescoProviderREST.java
@Override public User findUser(String userID, Set<String> attributes, Map<String, Object> request) throws ProvisioningException { String token = ""; try {// www . j ava 2s .c om token = this.login(); } catch (Exception e) { throw new ProvisioningException("Could not initialize Alfresco Web Services Client", e); } try { AlfrescoUser userDetails = userLookup(userID, token); Method[] methods = AlfrescoUser.class.getDeclaredMethods(); User user = new User(userID); for (Method method : methods) { if (!method.getName().startsWith("get") || method.getParameterTypes().length > 0) { continue; } String val = null; if (method.getReturnType().equals(String.class)) { val = (String) method.invoke(userDetails); } else if (method.getReturnType().equals(Boolean.class)) { Boolean b = (Boolean) method.invoke(userDetails); val = b.toString(); } String name = method.getName().substring(3 + 1); StringBuffer b = new StringBuffer(); b.append(method.getName().toLowerCase().charAt(3)).append(name); name = b.toString(); if (attributes.size() > 0 && !attributes.contains(name)) { continue; } if (val != null && !val.isEmpty()) { Attribute userAttr = new Attribute(name, val); user.getAttribs().put(name, userAttr); } } List<String> groups = this.groupUserGroups(userID, token); for (String group : groups) { user.getGroups().add(group); } return user; } catch (Exception e) { StringBuffer b = new StringBuffer(); b.append("Could not retrieve user ").append(userID); throw new ProvisioningException(b.toString(), e); } }