List of usage examples for org.apache.commons.lang BooleanUtils isNotTrue
public static boolean isNotTrue(Boolean bool)
Checks if a Boolean
value is not true
, handling null
by returning true
.
BooleanUtils.isNotTrue(Boolean.TRUE) = false BooleanUtils.isNotTrue(Boolean.FALSE) = true BooleanUtils.isNotTrue(null) = true
From source file:au.org.theark.study.web.component.subject.SubjectContainerPanel.java
@SuppressWarnings("unchecked") protected WebMarkupContainer initialiseSearchResults(AbstractDetailModalWindow modalWindow, final String gender, final List<RelationshipVo> relatives) { searchResultsPanel = new SearchResultListPanel("searchResults", arkContextMarkup, containerForm, arkCrudContainerVO, studyNameMarkup, studyLogoMarkup); searchResultsPanel.setOutputMarkupId(true); if (sessionStudyId != null) { LinkSubjectStudy linkSubjectStudy = new LinkSubjectStudy(); linkSubjectStudy.setStudy(study); // containerForm.getModelObject().setLinkSubjectStudy(linkSubjectStudy); }// w w w . j ava2 s . co m // Data providor to paginate resultList subjectProvider = new ArkDataProvider<SubjectVO, IArkCommonService>(iArkCommonService) { private static final long serialVersionUID = 1L; private GenderType genderType; { Collection<GenderType> genderTypes = service.getGenderTypes(); for (GenderType type : genderTypes) { if (gender.equalsIgnoreCase(type.getName())) { this.genderType = type; break; } } } public int size() { String subjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); model.getObject().getRelativeUIDs().add(subjectUID); // TODO comment this block to check inbred relatives Boolean inbreedAllowed = (Boolean) SecurityUtils.getSubject().getSession() .getAttribute(Constants.INBREED_ALLOWED); if (BooleanUtils.isNotTrue(inbreedAllowed)) { for (RelationshipVo relationshipVo : relatives) { model.getObject().getRelativeUIDs().add(relationshipVo.getIndividualId()); } } else { List<RelationshipVo> childRelatives = iStudyService.getSubjectChildren(subjectUID, sessionStudyId); for (RelationshipVo relationshipVo : childRelatives) { model.getObject().getRelativeUIDs().add(relationshipVo.getIndividualId()); } } model.getObject().getLinkSubjectStudy().getPerson().setGenderType(genderType); return (int) service.getStudySubjectCount(model.getObject()); } public Iterator<SubjectVO> iterator(int first, int count) { List<SubjectVO> listSubjects = new ArrayList<SubjectVO>(); if (isActionPermitted()) { model.getObject().getLinkSubjectStudy().getPerson().setGenderType(genderType); String subjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); model.getObject().getRelativeUIDs().add(subjectUID); // TODO comment this block to check inbred relatives Boolean inbreedAllowed = (Boolean) SecurityUtils.getSubject().getSession() .getAttribute(Constants.INBREED_ALLOWED); if (BooleanUtils.isNotTrue(inbreedAllowed)) { for (RelationshipVo relationshipVo : relatives) { model.getObject().getRelativeUIDs().add(relationshipVo.getIndividualId()); } } else { List<RelationshipVo> childRelatives = iStudyService.getSubjectChildren(subjectUID, sessionStudyId); for (RelationshipVo relationshipVo : childRelatives) { model.getObject().getRelativeUIDs().add(relationshipVo.getIndividualId()); } } listSubjects = iArkCommonService.searchPageableSubjects(model.getObject(), first, count); } return listSubjects.iterator(); } }; subjectProvider.setModel(this.cpModel); dataView = searchResultsPanel.buildDataView(subjectProvider, modalWindow, relatives, feedBackPanel); dataView.setItemsPerPage( iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) { private static final long serialVersionUID = 1L; @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(searchResultsPanel); } }; resultsWmc.add(pageNavigator); List<IColumn<SubjectVO>> columns = new ArrayList<IColumn<SubjectVO>>(); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("SubjectUID"), "subjectUID")); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Full Name"), "subjectFullName")); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Preferred Name"), "linkSubjectStudy.person.preferredName")); columns.add(new ExportableDateColumn<SubjectVO>(Model.of("Date Of Birth"), "linkSubjectStudy.person.dateOfBirth", au.org.theark.core.Constants.DD_MM_YYYY)); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Vital Status"), "linkSubjectStudy.person.vitalStatus.name")); columns.add( new ExportableTextColumn<SubjectVO>(Model.of("Gender"), "linkSubjectStudy.person.genderType.name")); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Subject Status"), "linkSubjectStudy.subjectStatus.name")); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Consent Status"), "linkSubjectStudy.consentStatus.name")); DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(), iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); List<String> headers = new ArrayList<String>(0); headers.add("SubjectUID"); headers.add("Full Name"); headers.add("Preferred Name"); headers.add("Date of Birth"); headers.add("Vital Status"); headers.add("Gender"); headers.add("Subject Status"); headers.add("Consent Status"); String filename = study.getName() + "_subjects"; RepeatingView toolbars = new RepeatingView("toolbars"); ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename); toolbars.add(new Component[] { exportToolBar }); resultsWmc.add(toolbars); resultsWmc.add(dataView); searchResultsPanel.add(resultsWmc); arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultsPanel); return arkCrudContainerVO.getSearchResultPanelContainer(); }
From source file:com.wineaccess.winerypermit.WineryPermitHelper.java
/** * @param wineryPermitPO//from ww w .j a v a 2 s .c o m */ private void validateWineryPermitPO(WineryPermitPO wineryPermitPO) { response = new FailureResponse(); Boolean isSellInMainStates = BooleanUtils.toBoolean(wineryPermitPO.getIsSellInMainStates()); SellInAltStatesModel isSellInAltStates = wineryPermitPO.getSellInAltStates(); if (BooleanUtils.isNotTrue(isSellInMainStates) && isSellInAltStates == null) { response.addError(new WineaccessError(SystemErrorCode.PERMIT_NO_OPTION_SELECTED_ERROR, SystemErrorCode.PERMIT_NO_OPTION_SELECTED_ERROR_TEXT)); } if (BooleanUtils.isNotTrue(isSellInMainStates) && isSellInAltStates != null && !BooleanUtils.toBoolean(isSellInAltStates.getIsSelected())) { response.addError(new WineaccessError(SystemErrorCode.PERMIT_NO_OPTION_SELECTED_ERROR, SystemErrorCode.PERMIT_NO_OPTION_SELECTED_ERROR_TEXT)); } else if (isSellInAltStates != null) { validateSellInAltModel(isSellInAltStates, wineryPermitPO.getWineryId()); } }
From source file:jp.primecloud.auto.service.impl.ProcessServiceImpl.java
/** * {@inheritDoc}/*from w w w . ja v a 2 s . c om*/ */ @Override public void startLoadBalancers(Long farmNo, List<Long> loadBalancerNos) { // ??? List<LoadBalancer> loadBalancers = loadBalancerDao.readInLoadBalancerNos(loadBalancerNos); for (LoadBalancer loadBalancer : loadBalancers) { if (BooleanUtils.isNotTrue(loadBalancer.getEnabled()) || BooleanUtils.isNotTrue(loadBalancer.getConfigure())) { loadBalancer.setEnabled(true); loadBalancer.setConfigure(true); loadBalancerDao.update(loadBalancer); } } // ?????????? List<ComponentLoadBalancer> componentLoadBalancers = componentLoadBalancerDao .readInLoadBalancerNos(loadBalancerNos); if (!componentLoadBalancers.isEmpty()) { // ?????? Set<Long> componentNos = new HashSet<Long>(); for (ComponentLoadBalancer componentLoadBalancer : componentLoadBalancers) { componentNos.add(componentLoadBalancer.getComponentNo()); } // ???? List<ComponentInstance> componentInstances = componentInstanceDao.readInComponentNos(componentNos); for (ComponentInstance componentInstance : componentInstances) { if (BooleanUtils.isNotTrue(componentInstance.getEnabled())) { componentInstance.setEnabled(true); componentInstanceDao.update(componentInstance); } } // ?? Set<Long> instanceNos = new HashSet<Long>(); for (ComponentInstance componentInstance : componentInstances) { instanceNos.add(componentInstance.getInstanceNo()); } List<Instance> instances = instanceDao.readInInstanceNos(instanceNos); for (Instance instance : instances) { if (BooleanUtils.isNotTrue(instance.getEnabled())) { instance.setEnabled(true); instanceDao.update(instance); } } } // ???? scheduleFarm(farmNo); }
From source file:com.wineaccess.winerypermit.WineryPermitHelper.java
/** * @param sellInAltStatesModel// w w w . ja va2 s. c o m * @param string */ private void validateSellInAltModel(SellInAltStatesModel sellInAltStatesModel, String wineryId) { Boolean isOptionSelectedKachinaAlt = BooleanUtils .toBoolean(sellInAltStatesModel.getIsOptionSelectedKachinaAlt()); OptionSelectedAltStates optionSelectedAltStates = sellInAltStatesModel.getOptionSelectedAltStates(); Boolean isOptionSelectedNoPermit = BooleanUtils .toBoolean(sellInAltStatesModel.getIsOptionSelectedNoPermit()); Boolean isSelectedAltStates = BooleanUtils.toBoolean(sellInAltStatesModel.getIsSelected()); if (BooleanUtils.isTrue(isSelectedAltStates) && BooleanUtils.isNotTrue(isOptionSelectedKachinaAlt) && optionSelectedAltStates == null && BooleanUtils.isNotTrue(isOptionSelectedNoPermit)) { response.addError(new WineaccessError(SystemErrorCode.PERMIT_NO_OPTION_SELECTED_WINERY_LICENCES_ERROR, SystemErrorCode.PERMIT_NO_OPTION_SELECTED_WINERY_LICENCES_ERROR_TEXT)); } else if ((BooleanUtils.isTrue(isOptionSelectedKachinaAlt) && optionSelectedAltStates != null) || BooleanUtils.isTrue(isOptionSelectedKachinaAlt) && BooleanUtils.isTrue(isOptionSelectedNoPermit) || BooleanUtils.isTrue(isOptionSelectedNoPermit) && optionSelectedAltStates != null) { response.addError(new WineaccessError(SystemErrorCode.PERMIT_MORE_THAN_ONE_OPTION_SELECTED_ERROR, SystemErrorCode.PERMIT_MORE_THAN_ONE_OPTION_SELECTED_ERROR_TEXT)); } else { if (optionSelectedAltStates != null) { validateoptionSelectedAltstates(optionSelectedAltStates, wineryId); } } }
From source file:jp.primecloud.auto.process.ProcessManager.java
protected boolean processStopInstances(final Farm farm) { // ??????/*from w ww.j a v a 2 s. c o m*/ if (BooleanUtils.isTrue(farm.getComponentProcessing())) { return false; } // ???????????????????? boolean coodinated = false; List<Instance> allInstances = instanceDao.readByFarmNo(farm.getFarmNo()); for (Instance instance : allInstances) { if (InstanceStatus.fromStatus(instance.getStatus()) == InstanceStatus.RUNNING) { if (BooleanUtils.isNotTrue(instance.getEnabled())) { if (InstanceCoodinateStatus .fromStatus(instance.getCoodinateStatus()) == InstanceCoodinateStatus.COODINATED) { coodinated = true; break; } } } } // ??????????????? if (coodinated) { final User user = userDao.read(farm.getUserNo()); Runnable runnable = new Runnable() { @Override public void run() { LoggingUtils.setUserNo(user.getMasterUser()); LoggingUtils.setUserName(user.getUsername()); LoggingUtils.setFarmNo(farm.getFarmNo()); LoggingUtils.setFarmName(farm.getFarmName()); LoggingUtils.setLoginUserNo(user.getUserNo()); try { instancesProcess.stop(farm.getFarmNo()); } catch (MultiCauseException ignore) { } catch (Throwable e) { log.error(e.getMessage(), e); // eventLogger.error("SystemError", new Object[] { e.getMessage() }); } finally { LoggingUtils.removeContext(); } } }; executorService.execute(runnable); } return !coodinated; }
From source file:jp.primecloud.auto.service.impl.ProcessServiceImpl.java
/** * {@inheritDoc}/*from w ww .ja v a 2 s . c o m*/ */ @Override public void stopLoadBalancers(Long farmNo, List<Long> loadBalancerNos) { // ??? List<LoadBalancer> loadBalancers = loadBalancerDao.readInLoadBalancerNos(loadBalancerNos); for (LoadBalancer loadBalancer : loadBalancers) { if (BooleanUtils.isTrue(loadBalancer.getEnabled()) || BooleanUtils.isNotTrue(loadBalancer.getConfigure())) { loadBalancer.setEnabled(false); loadBalancer.setConfigure(true); loadBalancerDao.update(loadBalancer); } } // ?????????? List<ComponentLoadBalancer> componentLoadBalancers = componentLoadBalancerDao .readInLoadBalancerNos(loadBalancerNos); if (!componentLoadBalancers.isEmpty()) { // ?????? Set<Long> componentNos = new HashSet<Long>(); for (ComponentLoadBalancer componentLoadBalancer : componentLoadBalancers) { componentNos.add(componentLoadBalancer.getComponentNo()); } // ???? List<ComponentInstance> componentInstances = componentInstanceDao.readInComponentNos(componentNos); for (ComponentInstance componentInstance : componentInstances) { if (BooleanUtils.isTrue(componentInstance.getEnabled())) { componentInstance.setEnabled(false); componentInstanceDao.update(componentInstance); } } // ?? Set<Long> instanceNos = new HashSet<Long>(); for (ComponentInstance componentInstance : componentInstances) { instanceNos.add(componentInstance.getInstanceNo()); } List<Instance> instances = instanceDao.readInInstanceNos(instanceNos); for (Instance instance : instances) { if (BooleanUtils.isTrue(instance.getEnabled())) { instance.setEnabled(false); instanceDao.update(instance); } } } // ?? List<LoadBalancerListener> listeners = loadBalancerListenerDao.readInLoadBalancerNos(loadBalancerNos); for (LoadBalancerListener listener : listeners) { if (BooleanUtils.isTrue(listener.getEnabled())) { listener.setEnabled(false); loadBalancerListenerDao.update(listener); } } // ???? scheduleFarm(farmNo); }
From source file:jp.primecloud.auto.process.ProcessManager.java
protected boolean processStopInstance(final Farm farm) { // ??/*w ww. j a va 2s. co m*/ List<Instance> instances = new ArrayList<Instance>(); List<Instance> allInstances = instanceDao.readByFarmNo(farm.getFarmNo()); for (Instance instance : allInstances) { // ?? if (BooleanUtils.isTrue(instance.getLoadBalancer())) { continue; } if (BooleanUtils.isNotTrue(instance.getEnabled())) { instances.add(instance); } } // ???? if (instances.isEmpty()) { return true; } // ?? boolean processing = false; List<Long> targetInstanceNos = new ArrayList<Long>(); for (Instance instance : instances) { InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus()); if (status != InstanceStatus.STOPPED) { processing = true; if (status == InstanceStatus.RUNNING || status == InstanceStatus.WARNING) { targetInstanceNos.add(instance.getInstanceNo()); } } } // ????? if (!targetInstanceNos.isEmpty()) { final User user = userDao.read(farm.getUserNo()); for (final Long instanceNo : targetInstanceNos) { Runnable runnable = new Runnable() { @Override public void run() { LoggingUtils.setUserNo(user.getMasterUser()); LoggingUtils.setUserName(user.getUsername()); LoggingUtils.setFarmNo(farm.getFarmNo()); LoggingUtils.setFarmName(farm.getFarmName()); LoggingUtils.setLoginUserNo(user.getUserNo()); try { log.debug("instanceProcess.stop(instanceNo):" + String.valueOf(instanceNo)); instanceProcess.stop(instanceNo); } catch (MultiCauseException ignore) { } catch (Throwable e) { log.error(e.getMessage(), e); // eventLogger.error("SystemError", new Object[] { e.getMessage() }); } finally { LoggingUtils.removeContext(); } } }; executorService.execute(runnable); } } // ????? if (processing) { return false; } return true; }
From source file:jp.primecloud.auto.service.impl.ComponentServiceImpl.java
/** * {@inheritDoc}/* ww w . ja v a2 s.c om*/ */ protected void doAssociate(Long componentNo, List<Long> instanceNos) { Component component = componentDao.read(componentNo); // ???? List<Instance> allInstances = instanceDao.readByFarmNo(component.getFarmNo()); List<ComponentInstance> componentInstances = componentInstanceDao.readByComponentNo(componentNo); for (Instance instance : allInstances) { // ??????? ComponentInstance componentInstance = null; for (ComponentInstance tmpComponentInstance : componentInstances) { if (instance.getInstanceNo().equals(tmpComponentInstance.getInstanceNo())) { componentInstance = tmpComponentInstance; break; } } if (instanceNos.contains(instance.getInstanceNo())) { // ?????? if (componentInstance == null) { // ???????? componentInstance = new ComponentInstance(); componentInstance.setComponentNo(componentNo); componentInstance.setInstanceNo(instance.getInstanceNo()); componentInstance.setAssociate(true); componentInstance.setEnabled(false); componentInstance.setStatus(ComponentInstanceStatus.STOPPED.toString()); componentInstanceDao.create(componentInstance); } else { // ??????? if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) { componentInstance.setAssociate(true); componentInstanceDao.update(componentInstance); } } } else { // ???????? if (componentInstance != null) { // ???? ComponentInstanceStatus status = ComponentInstanceStatus .fromStatus(componentInstance.getStatus()); if (status == ComponentInstanceStatus.STOPPED) { // Zabbix??? if (zabbixInstanceDao.countByInstanceNo(componentInstance.getInstanceNo()) > 0) { zabbixHostProcess.removeTemplate(componentInstance.getInstanceNo(), componentNo); } /****************************************************************** * ??????? * ??VCLOUDUSiZE????? ******************************************************************/ List<VcloudDisk> vdisks = vcloudDiskDao.readByInstanceNo(instance.getInstanceNo()); for (VcloudDisk disk : vdisks) { if (componentNo.equals(disk.getComponentNo())) { //componentNo???????? Farm farm = farmDao.read(instance.getFarmNo()); IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(farm.getUserNo(), instance.getPlatformNo()); try { gateway.deleteVolume(String.valueOf(disk.getDiskNo())); } catch (AutoException ignore) { // ?????????????? } // vcloudDiskDao.delete(disk); } } // ??????????? componentInstanceDao.delete(componentInstance); } else { // ?? if (BooleanUtils.isTrue(componentInstance.getAssociate())) { componentInstance.setAssociate(false); componentInstanceDao.update(componentInstance); } } } } } ComponentType componentType = componentTypeDao.read(component.getComponentTypeNo()); // MySQL?????Master?Slave? if (MySQLConstants.COMPONENT_TYPE_NAME.equals(componentType.getComponentTypeName())) { // Master/Slave?? Long masterInstanceNo = null; Set<Long> slaveInstanceNos = new LinkedHashSet<Long>(); List<InstanceConfig> instanceConfigs = instanceConfigDao.readByComponentNo(componentNo); for (InstanceConfig instanceConfig : instanceConfigs) { if (MySQLConstants.CONFIG_NAME_MASTER_INSTANCE_NO.equals(instanceConfig.getConfigName())) { if (StringUtils.isEmpty(instanceConfig.getConfigValue())) { masterInstanceNo = instanceConfig.getInstanceNo(); } else { slaveInstanceNos.add(instanceConfig.getInstanceNo()); } } } // Master?????????Master?? if (masterInstanceNo == null && instanceNos.size() > 0) { masterInstanceNo = instanceNos.get(0); InstanceConfig instanceConfig = new InstanceConfig(); instanceConfig.setInstanceNo(masterInstanceNo); instanceConfig.setComponentNo(componentNo); instanceConfig.setConfigName(MySQLConstants.CONFIG_NAME_MASTER_INSTANCE_NO); instanceConfig.setConfigValue(null); instanceConfigDao.create(instanceConfig); } // Master/Slave??????Slave?? if (masterInstanceNo != null) { for (Long instanceNo : instanceNos) { if (!instanceNo.equals(masterInstanceNo) && !slaveInstanceNos.contains(instanceNo)) { InstanceConfig instanceConfig = new InstanceConfig(); instanceConfig.setInstanceNo(instanceNo); instanceConfig.setComponentNo(componentNo); instanceConfig.setConfigName(MySQLConstants.CONFIG_NAME_MASTER_INSTANCE_NO); instanceConfig.setConfigValue(masterInstanceNo.toString()); instanceConfigDao.create(instanceConfig); } } } } }
From source file:jp.primecloud.auto.service.impl.ProcessServiceImpl.java
/** * {@inheritDoc}/*from ww w. j a va 2s . c o m*/ */ @Override public void startLoadBalancerListeners(Long farmNo, Long loadBalancerNo, List<Integer> loadBalancerPorts) { if (loadBalancerPorts.isEmpty()) { return; } // ?? List<LoadBalancerListener> listeners = loadBalancerListenerDao.readByLoadBalancerNo(loadBalancerNo); for (LoadBalancerListener listener : listeners) { if (!loadBalancerPorts.contains(listener.getLoadBalancerPort())) { continue; } if (BooleanUtils.isNotTrue(listener.getEnabled()) || BooleanUtils.isNotTrue(listener.getConfigure())) { listener.setEnabled(true); listener.setConfigure(true); loadBalancerListenerDao.update(listener); } } // ??? startLoadBalancers(farmNo, Arrays.asList(loadBalancerNo)); }
From source file:com.wineaccess.winepermit.WinePermitHelper.java
/** * @param wineryPermitPO/*from ww w.j a va 2 s . co m*/ */ private void validateWinePermitPO(WinePermitPO wineryPermitPO) { response = new FailureResponse(); Boolean isSellInMainStates = BooleanUtils.toBoolean(wineryPermitPO.getIsSellInMainStates()); SellInAltStatesModel isSellInAltStates = wineryPermitPO.getSellInAltStates(); if (BooleanUtils.isNotTrue(isSellInMainStates) && isSellInAltStates == null) { response.addError(new WineaccessError(SystemErrorCode.PERMIT_NO_OPTION_SELECTED_ERROR_WINE, SystemErrorCode.PERMIT_NO_OPTION_SELECTED_ERROR_WINE_TEXT)); } if (BooleanUtils.isNotTrue(isSellInMainStates) && isSellInAltStates != null && !BooleanUtils.toBoolean(isSellInAltStates.getIsSelected())) { response.addError(new WineaccessError(SystemErrorCode.PERMIT_NO_OPTION_SELECTED_ERROR_WINE, SystemErrorCode.PERMIT_NO_OPTION_SELECTED_ERROR_WINE_TEXT)); } else if (isSellInAltStates != null) { validateSellInAltModel(isSellInAltStates, wineryPermitPO.getProductId()); } }