List of usage examples for org.apache.commons.lang BooleanUtils isTrue
public static boolean isTrue(Boolean bool)
Checks if a Boolean
value is true
, handling null
by returning false
.
BooleanUtils.isTrue(Boolean.TRUE) = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null) = false
From source file:org.obiba.onyx.quartz.editor.category.MultipleChoiceCategoryHeaderPanel.java
@SuppressWarnings("serial") public MultipleChoiceCategoryHeaderPanel(String id, final IModel<Questionnaire> questionnaireModel, final IModel<EditedQuestion> model) { super(id, model); setOutputMarkupId(true);/*w w w.j a v a 2 s . c om*/ this.questionnaireModel = questionnaireModel; final Form<Question> form = new Form<Question>("form", new Model<Question>(model.getObject().getElement())); editedQuestion = model.getObject(); question = model.getObject().getElement(); choices = new LoadableDetachableModel<List<QuestionCategory>>() { private static final long serialVersionUID = 1L; @Override protected List<QuestionCategory> load() { List<QuestionCategory> missingQuestionCategories = question.getMissingQuestionCategories(); List<QuestionCategory> correctQuestionCategories = new ArrayList<QuestionCategory>(); for (QuestionCategory questionCategory : missingQuestionCategories) { boolean noAnswer = questionCategory.getCategory().isNoAnswer(); boolean sharedIfLink = QuestionnaireSharedCategory.isSharedIfLink(questionCategory, questionnaireModel.getObject()); if (!sharedIfLink || noAnswer) { correctQuestionCategories.add(questionCategory); if (sharedIfLink && noAnswer) { correctQuestionCategories.clear(); correctQuestionCategories.add(questionCategory); return correctQuestionCategories; } } } return correctQuestionCategories; } }; requiredAnswer = new CheckBox("requiredAnswer", new Model<Boolean>()); requiredAnswer.setLabel(new ResourceModel("RequiredAnswer")); form.add(requiredAnswer).add(new SimpleFormComponentLabel("requiredAnswerLabel", requiredAnswer)); noAnswerCategoryModel = new Model<QuestionCategory>() { public QuestionCategory getObject() { return question.getNoAnswerQuestionCategory(); } @Override public void setObject(QuestionCategory questionCategory) { super.setObject(questionCategory); question.setNoAnswerCategory(questionCategory == null ? null : questionCategory.getCategory()); } }; IChoiceRenderer<QuestionCategory> choicesRenderer = new ChoiceRenderer<QuestionCategory>("category.name"); noAnswerCategoryDropDown = new DropDownChoice<QuestionCategory>("noAnswerCategoryDropDown", noAnswerCategoryModel, choices, choicesRenderer); noAnswerCategoryDropDown.setNullValid(true); noAnswerCategoryDropDown.setLabel(new ResourceModel("NoAnswer")); noAnswerCategoryDropDown.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { // Do nothing, it is only to ajax update model when we change value in dropdown } }); form.add(noAnswerCategoryDropDown) .add(new SimpleFormComponentLabel("noAnswerLabel", noAnswerCategoryDropDown)); form.add(new HelpTooltipPanel("noAnswerHelp", new ResourceModel("NoAnswer.Tooltip"))); minCountTextField = new TextField<Integer>("minCountTextField", new PropertyModel<Integer>(question, "minCount")); previousOrFirstMinValue = minCountTextField.getModelObject(); minCountTextField.setLabel(new ResourceModel("Min")); minCountTextField.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { // Do nothing, it is only to ajax update model when we change value } }); SimpleFormComponentLabel minCountLabelComponent = new SimpleFormComponentLabel("minCountLabel", minCountTextField); maxCountTextField = new TextField<Integer>("maxCountTextField", new PropertyModel<Integer>(question, "maxCount")); maxCountTextField.setLabel(new ResourceModel("Max")); SimpleFormComponentLabel maxCountLabelComponent = new SimpleFormComponentLabel("maxCountLabel", maxCountTextField); form.add(minCountTextField, maxCountTextField, minCountLabelComponent, maxCountLabelComponent); form.add(new HelpTooltipPanel("minHelp", new ResourceModel("Min.Tooltip"))); form.add(new HelpTooltipPanel("maxHelp", new ResourceModel("Max.Tooltip"))); requiredAnswer.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { clickRequired(target); } }); form.add(new IFormValidator() { @Override public void validate(@SuppressWarnings("hiding") Form<?> form) { Integer min = minCountTextField.getConvertedInput(); Integer max = maxCountTextField.getConvertedInput(); if (min != null && max != null && min > max) { form.error(new StringResourceModel("MinInfMax", MultipleChoiceCategoryHeaderPanel.this, null) .getObject()); } if (BooleanUtils.isTrue(requiredAnswer.getModelObject()) && min != null && min <= 0) { form.error(new StringResourceModel("MinMustBeMoreZero", MultipleChoiceCategoryHeaderPanel.this, null).getObject()); } } @Override public FormComponent<?>[] getDependentFormComponents() { return null; } }); add(form); }
From source file:org.obiba.onyx.quartz.editor.category.MultipleChoiceCategoryHeaderPanel.java
private void clickRequired(AjaxRequestTarget target) { boolean required = requiredAnswer.getModelObject(); noAnswerCategoryDropDown.setEnabled(!required); minCountTextField.setEnabled(required); if (required) { previousOrFirstNoAnswerQuestionCategory = noAnswerCategoryDropDown.getModelObject(); noAnswerCategoryDropDown.setModelObject(null); minCountTextField.setModelObject(previousOrFirstMinValue); } else {//from w w w .j av a 2s . c o m previousOrFirstMinValue = minCountTextField.getModelObject(); minCountTextField.setModelObject(null); noAnswerCategoryDropDown.setModelObject(previousOrFirstNoAnswerQuestionCategory); } if (isSingleChoice()) { minCountTextField.setModelObject(BooleanUtils.isTrue(requiredAnswer.getModelObject()) ? 1 : null); minCountTextField.setEnabled(false); } target.addComponent(noAnswerCategoryDropDown); target.addComponent(minCountTextField); }
From source file:org.obiba.onyx.quartz.editor.category.MultipleChoiceCategoryHeaderPanel.java
@Override protected void onBeforeRender() { super.onBeforeRender(); QuestionCategory noAnswerQuestionCategory = null; List<QuestionCategory> choiceList = choices.getObject(); if (choiceList.size() == 1 && QuestionnaireSharedCategory.isSharedIfLink(choiceList.iterator().next(), questionnaireModel.getObject())) { noAnswerQuestionCategory = choiceList.iterator().next(); } else {/* www . j a va 2s . c om*/ noAnswerQuestionCategory = noAnswerCategoryModel.getObject(); } if (noAnswerQuestionCategory != null && QuestionnaireSharedCategory.isSharedIfLink(noAnswerQuestionCategory, questionnaireModel.getObject())) { noAnswerCategoryDropDown.setNullValid(false); requiredAnswer.setEnabled(false); minCountTextField.setEnabled(false); noAnswerCategoryDropDown.setModelObject(noAnswerQuestionCategory); minCountTextField.setModelObject(null); } else { requiredAnswer.setEnabled(true); boolean minSupZero = question.getMinCount() == null ? false : question.getMinCount() > 0; noAnswerCategoryDropDown.setEnabled(!minSupZero); noAnswerCategoryDropDown.setNullValid(true); minCountTextField.setEnabled(minSupZero); noAnswerCategoryDropDown.setModelObject(noAnswerQuestionCategory); requiredAnswer.setModelObject(minSupZero); } if (isSingleChoice()) { minCountTextField.setModelObject(BooleanUtils.isTrue(requiredAnswer.getModelObject()) ? 1 : null); minCountTextField.setEnabled(false); maxCountTextField.setModelObject(1); maxCountTextField.setEnabled(false); } else { maxCountTextField.setEnabled(true); } }
From source file:org.ojbc.adapters.analyticsstaging.custody.processor.AbstractReportRepositoryProcessor.java
protected void processBehavioralHealthInfo(Node personNode, Integer personId, String extPrefix) throws Exception { String behavioralHealthInfoRef = XmlUtils.xPathStringSearch(personNode, extPrefix + ":PersonBehavioralHealthInformation/@s30:ref"); String personCareEpisodeRef = XmlUtils.xPathStringSearch(personNode, extPrefix + ":PersonCareEpisode/@s30:ref"); if (StringUtils.isNotBlank(behavioralHealthInfoRef) || StringUtils.isNotBlank(personCareEpisodeRef)) { BehavioralHealthAssessment assessment = new BehavioralHealthAssessment(); assessment.setPersonId(personId); Node behavioralHealthInfoNode = XmlUtils.xPathNodeSearch(personNode, "following-sibling::" + extPrefix + ":BehavioralHealthInformation['" + behavioralHealthInfoRef + "']"); if (behavioralHealthInfoNode != null) { String seriousMentalIllnessIndicator = XmlUtils.xPathStringSearch(behavioralHealthInfoNode, extPrefix + ":SeriousMentalIllnessIndicator"); assessment.setSeriousMentalIllness(BooleanUtils.toBooleanObject(seriousMentalIllnessIndicator)); String medicaidIndicator = XmlUtils.xPathStringSearch(behavioralHealthInfoNode, "hs:MedicaidIndicator"); Boolean medicaidIndicatorBoolean = BooleanUtils.toBooleanObject(medicaidIndicator); String medicaidStatusType = BooleanUtils.toString(medicaidIndicatorBoolean, "eligible", "not eligible", null); assessment.setMedicaidStatusTypeId(descriptionCodeLookupService .retrieveCode(CodeTable.MedicaidStatusType, medicaidStatusType)); String regionalAuthorityAssignmentText = XmlUtils.xPathStringSearch(behavioralHealthInfoNode, extPrefix + ":RegionalBehavioralHealthAuthorityAssignmentText"); assessment.setEnrolledProviderName(regionalAuthorityAssignmentText); Boolean substanceAbuseIndicator = BooleanUtils.toBooleanObject(XmlUtils .xPathStringSearch(behavioralHealthInfoNode, extPrefix + ":SubstanceAbuseIndicator")); if (BooleanUtils.isTrue(substanceAbuseIndicator)) { Integer assessmentCategoryTypeId = descriptionCodeLookupService .retrieveCode(CodeTable.AssessmentCategoryType, ASSESSMENT_CATEGORY_SUBSTANCE_ABUSE); assessment.getAssessmentCategory() .add(new KeyValue(assessmentCategoryTypeId, ASSESSMENT_CATEGORY_SUBSTANCE_ABUSE)); }// w ww . ja v a 2s . c o m Boolean generalMentalHealthConditionIndicator = BooleanUtils .toBooleanObject(XmlUtils.xPathStringSearch(behavioralHealthInfoNode, extPrefix + ":GeneralMentalHealthConditionIndicator")); if (BooleanUtils.isTrue(generalMentalHealthConditionIndicator)) { Integer assessmentCategoryTypeId = descriptionCodeLookupService.retrieveCode( CodeTable.AssessmentCategoryType, ASSESSMENT_CATEGORY_GENERAL_MENTAL_HEALTH); assessment.getAssessmentCategory() .add(new KeyValue(assessmentCategoryTypeId, ASSESSMENT_CATEGORY_GENERAL_MENTAL_HEALTH)); } String careEpisodeStartDateString = XmlUtils.xPathStringSearch(personNode, "following-sibling::" + extPrefix + ":CareEpisode[@s30:id='" + personCareEpisodeRef + "']/nc30:ActivityDateRange/nc30:StartDate/nc30:Date"); LocalDate careEpisodeStartDate = StringUtils.isNotBlank(careEpisodeStartDateString) ? LocalDate.parse(careEpisodeStartDateString) : null; assessment.setCareEpisodeStartDate(careEpisodeStartDate); String careEpisodeEndDateString = XmlUtils.xPathStringSearch(personNode, "following-sibling::" + extPrefix + ":CareEpisode[@s30:id='" + personCareEpisodeRef + "']/nc30:ActivityDateRange/nc30:EndDate/nc30:Date"); LocalDate careEpisodeEndDate = StringUtils.isNotBlank(careEpisodeEndDateString) ? LocalDate.parse(careEpisodeEndDateString) : null; assessment.setCareEpisodeEndDate(careEpisodeEndDate); Integer assessmentId = analyticalDatastoreDAO.saveBehavioralHealthAssessment(assessment); assessment.setBehavioralHealthAssessmentId(assessmentId); processEvaluationNodes(assessment, behavioralHealthInfoNode, extPrefix); processTreatmentNodes(assessment, behavioralHealthInfoNode, extPrefix); processPrescribedMedications(assessment, behavioralHealthInfoNode, extPrefix); } } }
From source file:org.ojbc.adapters.rapbackdatastore.dao.RapbackDAOImpl.java
@Override @Transactional//from w ww .java 2 s . c o m public void saveIdentificationTransaction(IdentificationTransaction identificationTransaction) { log.debug("Inserting row into IDENTIFICATION_TRANSACTION table : " + identificationTransaction.toString()); final String IDENTIFICATION_TRANSACTION_INSERT = "INSERT into IDENTIFICATION_TRANSACTION " + "(TRANSACTION_NUMBER, SUBJECT_ID, OTN, OWNER_ORI, OWNER_PROGRAM_OCA, ARCHIVED, IDENTIFICATION_CATEGORY) " + "values (?, ?, ?, ?, ?, ?, ?)"; Integer subjectId = null; if (identificationTransaction.getSubject() == null) { throw new IllegalArgumentException( "The subject should not be null when saving Identification Transaction :" + identificationTransaction.toString()); } else { subjectId = saveSubject(identificationTransaction.getSubject()); identificationTransaction.getSubject().setSubjectId(subjectId); } jdbcTemplate.update(IDENTIFICATION_TRANSACTION_INSERT, identificationTransaction.getTransactionNumber(), subjectId, identificationTransaction.getOtn(), identificationTransaction.getOwnerOri(), identificationTransaction.getOwnerProgramOca(), BooleanUtils.isTrue(identificationTransaction.getArchived()), identificationTransaction.getIdentificationCategory()); }
From source file:org.ojbc.adapters.rapbackdatastore.dao.RapbackDAOImpl.java
private IdentificationTransaction buildIdentificationTransaction(ResultSet rs, boolean includeSubscription) throws SQLException { IdentificationTransaction identificationTransaction = new IdentificationTransaction(); identificationTransaction.setTransactionNumber(rs.getString("transaction_number")); identificationTransaction.setOtn(rs.getString("otn")); identificationTransaction.setTimestamp(toDateTime(rs.getTimestamp("report_timestamp"))); identificationTransaction.setOwnerOri(rs.getString("owner_ori")); identificationTransaction.setOwnerProgramOca(rs.getString("owner_program_oca")); identificationTransaction.setIdentificationCategory(rs.getString("identification_category")); identificationTransaction.setArchived(BooleanUtils.isTrue(rs.getBoolean("archived"))); Integer subjectId = rs.getInt("subject_id"); if (subjectId != null) { Subject subject = buildSubject(rs); identificationTransaction.setSubject(subject); }/*from www.j a v a 2s.c o m*/ if (includeSubscription) { identificationTransaction.setHavingSubsequentResults(rs.getBoolean("having_subsequent_result")); Integer subscriptionId = rs.getInt("id"); if (subscriptionId != null && subscriptionId > 0) { Subscription subscription = buildSubscription(rs); identificationTransaction.setSubscription(subscription); } } return identificationTransaction; }
From source file:org.ojbc.adapters.rapbackdatastore.processor.RapbackSearchProcessor.java
private IdentificationTransactionState getCurrentState(IdentificationTransaction identificationTransaction) { if (BooleanUtils.isTrue(identificationTransaction.getArchived())) { return IdentificationTransactionState.Archived; } else {//from ww w. j a v a 2 s . c o m Subscription subscription = identificationTransaction.getSubscription(); if (subscription != null && subscription.getActive() == Boolean.TRUE) { return IdentificationTransactionState.Subscribed; } else { return IdentificationTransactionState.Available_for_subscription; } } }
From source file:org.ojbc.intermediaries.sn.dao.RapbackDAOImplTest.java
@Test @DirtiesContext/*from w w w .j a v a 2s .com*/ public void testGetFbiSubscriptionQualification() throws Exception { Boolean fbiSubscriptionQualificationByTransactionNumber = rapbackDao .getfbiSubscriptionQualification("000001820140729014008339993"); assertEquals(Boolean.TRUE, fbiSubscriptionQualificationByTransactionNumber); Boolean fbiSubscriptionQualificationBySubscriptionId = rapbackDao.getfbiSubscriptionQualification(62723); assertEquals(Boolean.TRUE, fbiSubscriptionQualificationBySubscriptionId); Boolean fbiSubscriptionQualification = rapbackDao.getfbiSubscriptionQualification(99999); log.info("fbiSubscriptionQualification:" + BooleanUtils.isTrue(fbiSubscriptionQualification)); assertNull(fbiSubscriptionQualification); }
From source file:org.ojbc.intermediaries.sn.FbiSubscriptionProcessor.java
public Boolean routeToProcessFbiUnsubscribeRoute(@Body Document document) throws Exception { if (BooleanUtils.isTrue(fbiSubscriptionMember)) { String subscriptionIdString = XmlUtils.xPathStringSearch(document, "//unsubmsg-exch:UnsubscriptionMessage/submsg-ext:SubscriptionIdentification/nc:IdentificationID"); if (StringUtils.isNotBlank(subscriptionIdString)) { Boolean fbiSubscriptionQualification = rapbackDao .getfbiSubscriptionQualification(new Integer(subscriptionIdString)); if (BooleanUtils.isTrue(fbiSubscriptionQualification)) { return true; }/*from w w w . j av a 2 s .c om*/ } } return false; }
From source file:org.ojbc.intermediaries.sn.FbiSubscriptionProcessor.java
public Boolean routeToProcessFbiSubscriptionRoute(@Body Document document) throws Exception { if (BooleanUtils.isTrue(fbiSubscriptionMember)) { String transactionNumber = XmlUtils.xPathStringSearch(document, "//submsg-exch:SubscriptionMessage/submsg-ext:SubscriptionRelatedCaseIdentification/nc:IdentificationID"); Boolean fbiSubscriptionQualification = rapbackDao.getfbiSubscriptionQualification(transactionNumber); if (BooleanUtils.isTrue(fbiSubscriptionQualification)) { return true; }//from w w w . j a va 2s. co m } return false; }