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:com.haulmont.cuba.gui.dynamicattributes.DynamicAttributeCustomFieldGenerator.java
@Override public Component generateField(Datasource datasource, String propertyId) { ComponentsFactory componentsFactory = AppBeans.get(ComponentsFactory.class); ListEditor listEditor = componentsFactory.createComponent(ListEditor.class); MetaPropertyPath metaPropertyPath = DynamicAttributesUtils.getMetaPropertyPath(datasource.getMetaClass(), propertyId);//www . j a va2s. co m if (metaPropertyPath == null) { log.error("MetaPropertyPath for dynamic attribute {} not found", propertyId); return null; } CategoryAttribute categoryAttribute = DynamicAttributesUtils .getCategoryAttribute(metaPropertyPath.getMetaProperty()); if (categoryAttribute == null) { log.error("Dynamic attribute {} not found", propertyId); return null; } listEditor.setEntityJoinClause(categoryAttribute.getJoinClause()); listEditor.setEntityWhereClause(categoryAttribute.getWhereClause()); ListEditor.ItemType itemType = listEditorItemTypeFromDynamicAttrType(categoryAttribute.getDataType()); listEditor.setItemType(itemType); Metadata metadata = AppBeans.get(Metadata.class); Scripting scripting = AppBeans.get(Scripting.class); if (!Strings.isNullOrEmpty(categoryAttribute.getEntityClass())) { Class<?> clazz = scripting.loadClass(categoryAttribute.getEntityClass()); if (clazz == null) { log.error("Unable to find class of entity {} for dynamic attribute {}", categoryAttribute.getEntityClass(), categoryAttribute.getCode()); return null; } MetaClass metaClass = metadata.getClassNN(clazz); listEditor.setEntityName(metaClass.getName()); listEditor.setUseLookupField(BooleanUtils.isTrue(categoryAttribute.getLookup())); } //noinspection unchecked datasource.addStateChangeListener(e -> { if (e.getState() == Datasource.State.VALID) { Object value = datasource.getItem().getValue(propertyId); if (value != null && value instanceof Collection) { listEditor.setValue(value); } } }); listEditor.addValueChangeListener(e -> { datasource.getItem().setValue(propertyId, e.getValue()); }); listEditor.setWidthFull(); return listEditor; }
From source file:com.wineaccess.winerypermit.WineryPermitHelper.java
/** * @param winePermitViewPO//from w w w .j a va 2s . c o m * @return */ public static Map<String, Object> generateViewPermitResponse(WineryPermitViewPO wineryPermitViewPO) { response = new FailureResponse(); Map<String, Object> outputViewPermit = new HashMap<String, Object>(); Long wineryId = Long.parseLong(wineryPermitViewPO.getWineryId()); WineryModel wineryModel = WineryRepository.getWineryById(wineryId); if (wineryModel == null) { response.addError(new WineaccessError(SystemErrorCode.PERMIT_WINERY_ERROR, SystemErrorCode.PERMIT_WINERY_ERROR_TEXT)); } else { WineryPermitDetailVO wineryPermitViewVO = new WineryPermitDetailVO(); wineryPermitViewVO.setWineryId(wineryModel.getId()); wineryPermitViewVO.setIsSellInMainStates(wineryModel.getSellInMainStates()); /*if(BooleanUtils.isTrue(wineryModel.getSellInAltStates())) {*/ SellInAltStatesResultModel sellInAltStatesModel = new SellInAltStatesResultModel(); if (BooleanUtils.isTrue(wineryModel.getSellInAltStates())) sellInAltStatesModel.setIsSelected(true); Integer optionSelected = wineryModel.getOptionSelectedAltstates(); if (optionSelected != null && optionSelected.equals(0)) { sellInAltStatesModel.setIsOptionSelectedKachinaAlt(true); } if (optionSelected != null && optionSelected.equals(2)) { sellInAltStatesModel.setOptionSelectedNoPermit(true); } /*else if(optionSelected.equals(1)) {*/ List<PermitModelResult> permitModelResultsList = new ArrayList<PermitModelResult>(); OptionSelectedAltStatesResult optionSelectedAltStates = new OptionSelectedAltStatesResult(); List<WineryLicensePermitAltStates> wineryLicensePermitAltStates = WineryPermitRepository .findWineryLicensePermitAltStates(wineryId); /*if(wineLicensePermitAltStates != null && !wineLicensePermitAltStates.isEmpty()) {*/ //Set<MasterData> wineryPermitMasterDataList = MasterDataTypeAdapterHelper.getMasterDataListByMasterTypeName("Winery Licence Permit"); for (WineryLicensePermitAltStates permitModelFromDB : wineryLicensePermitAltStates) { PermitModelResult permitModelResult = new PermitModelResult(); WineryPermitModelWithMasterData wineryPermitModelWithMasterData = new WineryPermitModelWithMasterData(); MasterDataModel masterDataModel = new MasterDataModel(); Long masterDataForPermit = permitModelFromDB.getWineryPermit().getId(); permitModelResult.setDtcPermitEndDate(permitModelFromDB.getDtcPermitEndDate()); permitModelResult.setDtcPermitStartDate(permitModelFromDB.getDtcPermitStartDate()); permitModelResult.setDtcPermitNumber(permitModelFromDB.getDtcPermitNumber()); permitModelResult.setIsSelected(permitModelFromDB.getIsSelected()); permitModelResult.setPermitDurationInMonths(permitModelFromDB.getDtcPermitDurationInMonths()); masterDataModel.setId(masterDataForPermit); masterDataModel.setMasterDataTypeName("WineryLicencePermit"); masterDataModel.setMasterDataName(permitModelFromDB.getWineryPermit().getName()); wineryPermitModelWithMasterData.setMasterData(masterDataModel); //wineryPermitModelWithMasterData.setPermitModelResult(permitModelResult); permitModelResult.setWineryPermit(wineryPermitModelWithMasterData); permitModelResultsList.add(permitModelResult); } optionSelectedAltStates.setPermit(permitModelResultsList); /*}*/ WineryLicenseFullfillAltStates fulfilModelFromDB = WineryPermitRepository .findFulfilModelByWineryId(wineryId); FulFillModel fulfiModel = new FulFillModel(); if (fulfilModelFromDB != null) { if (BooleanUtils.isTrue(fulfilModelFromDB.getWaWillNotFullFill())) { } fulfiModel.setIsSelected(BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getIsSelected())); fulfiModel.setEscrowContract(BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getEscrowContract())); fulfiModel.setWaPlatformContract( BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getWaPlatformContract())); fulfiModel.setIsStorageContact( BooleanUtils.toStringTrueFalse(fulfilModelFromDB.getWineryStorageContract())); optionSelectedAltStates.setFulfillDirectlyNotWA(fulfilModelFromDB.getWaWillNotFullFill()); } /*else if() optionSelectedAltStates.setFulfillDirectlyNotWA(true);*/ optionSelectedAltStates.setFulfill(fulfiModel); /*WineLicenseFullfillAltStates wineFullfillAltStatesModel = WinePermitRepository.findFulfilModelByWineId(wineModel.getId()); if(wineFullfillAltStatesModel!=null) { } sellInAltStatesModel.setOptionSelectedAltStates(optionSelectedAltStates); } } wineFullfillAltStatesModel = WinePermitRepository.findFulfilModelByWineId(wineModel.getId()); if(wineFullfillAltStatesModel!=null) { }*/ sellInAltStatesModel.setOptionSelectedAltStates(optionSelectedAltStates); Integer optionSelect = wineryModel.getOptionSelectedAltstates(); if (optionSelect != null) { if (0 == optionSelect) { sellInAltStatesModel.setIsOptionSelectedKachinaAlt(true); } else if (2 == optionSelect) { sellInAltStatesModel.setOptionSelectedNoPermit(true); } } wineryPermitViewVO.setSellInAltStates(sellInAltStatesModel); /*}*/ response = new com.wineaccess.response.SuccessResponse(wineryPermitViewVO, 200); } outputViewPermit.put("FINAL-RESPONSE", response); return outputViewPermit; }
From source file:com.haulmont.cuba.gui.components.calendar.EntityCalendarEvent.java
@Override public boolean isAllDay() { if (provider.getIsAllDayProperty() != null) { return BooleanUtils.isTrue(entity.getValue(provider.getIsAllDayProperty())); } else {/*from w w w . j a va2 s . c om*/ return false; } }
From source file:jp.primecloud.auto.api.component.StartComponent.java
/** * * ?// w w w .j ava2s . c om * * @param uriInfo URI(InstanceNo??) * @param farmNo ? * @param componentNo ??? * @param instanceNos ?(?) * @return StartComponentResponse */ @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public StartComponentResponse startComponent(@Context UriInfo uriInfo, @QueryParam(PARAM_NAME_FARM_NO) String farmNo, @QueryParam(PARAM_NAME_COMPONENT_NO) String componentNo, @QueryParam(PARAM_NAME_INSTANCE_NOS) String instanceNos) { StartComponentResponse response = new StartComponentResponse(); try { // ? // FarmNo ApiValidate.validateFarmNo(farmNo); // ComponentNo ApiValidate.validateComponentNo(componentNo); // InstanceNo List<Long> instanceNoList = createInstanceNosToList(instanceNos); // ? Farm farm = farmDao.read(Long.parseLong(farmNo)); if (farm == null) { // ???? throw new AutoApplicationException("EAPI-100000", "Farm", PARAM_NAME_FARM_NO, farmNo); } // ? for (Long instanceNo : instanceNoList) { Instance instance = instanceDao.read(instanceNo); if (instance == null || BooleanUtils.isTrue(instance.getLoadBalancer())) { // ???? or ?? throw new AutoApplicationException("EAPI-100000", "Instance", PARAM_NAME_INSTANCE_NO, instanceNo); } } // ??? Component component = componentDao.read(Long.parseLong(componentNo)); if (component == null || BooleanUtils.isTrue(component.getLoadBalancer())) { // ?????? ??? ??? throw new AutoApplicationException("EAPI-100000", "Component", PARAM_NAME_COMPONENT_NO, componentNo); } if (BooleanUtils.isFalse(component.getFarmNo().equals(Long.parseLong(farmNo)))) { //??????? throw new AutoApplicationException("EAPI-100022", "Component", farmNo, PARAM_NAME_COMPONENT_NO, componentNo); } boolean skipServer = false; for (Long instanceNo : instanceNoList) { // ??? ComponentInstance componentInstance = componentInstanceDao.read(Long.parseLong(componentNo), instanceNo); if (componentInstance == null) { // ?????? throw new AutoApplicationException("EAPI-100000", "ComponentInstance", PARAM_NAME_INSTANCE_NO, instanceNo); } Instance instance = instanceDao.read(componentInstance.getInstanceNo()); Platform platform = platformDao.read(instance.getPlatformNo()); PlatformAws platformAws = platformAwsDao.read(instance.getPlatformNo()); AwsInstance awsInstance = awsInstanceDao.read(instance.getInstanceNo()); AzureInstance azureInstance = azureInstanceDao.read(instance.getInstanceNo()); boolean vpc = false; String subnetId = null; boolean subnetErrFlg; if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { // ?? vpc = platformAws.getVpc(); subnetId = awsInstance.getSubnetId(); subnetErrFlg = processService.checkSubnet(platform.getPlatformType(), vpc, subnetId); if (subnetErrFlg == true) { // EC2+VPC???????????? throw new AutoApplicationException("EAPI-100034", component.getComponentName(), instance.getInstanceName()); } } if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { // ?? subnetId = azureInstance.getSubnetId(); subnetErrFlg = processService.checkSubnet(platform.getPlatformType(), vpc, subnetId); if (subnetErrFlg == true) { // ??????????? throw new AutoApplicationException("EAPI-100034", component.getComponentName(), instance.getInstanceName()); } // ?? HashMap<String, Boolean> flgMap = new HashMap<String, Boolean>(); flgMap = processService.checkStartupAll(platform.getPlatformType(), azureInstance.getInstanceName(), skipServer); skipServer = flgMap.get("skipServer"); boolean startupAllErrFlg; startupAllErrFlg = flgMap.get("startupAllErrFlg"); if (startupAllErrFlg == true) { // ???????????? throw new AutoApplicationException("EAPI-100039", component.getComponentName(), instance.getInstanceName()); } // ? boolean startupErrFlg; startupErrFlg = processService.checkStartup(platform.getPlatformType(), azureInstance.getInstanceName(), azureInstance.getInstanceNo()); if (startupErrFlg == true) { // ???????????? // ?No??? throw new AutoApplicationException("EAPI-100039", component.getComponentName(), instance.getInstanceName()); } } } // processService.startComponents(Long.valueOf(farmNo), Long.valueOf(componentNo), instanceNoList); response.setSuccess(true); } catch (Throwable e) { String message = ""; if (e instanceof AutoException || e instanceof AutoApplicationException) { message = e.getMessage(); } else { message = MessageUtils.getMessage("EAPI-000000"); } log.error(message, e); response.setMessage(message); response.setSuccess(false); } return response; }
From source file:jp.primecloud.auto.process.DnsProcess.java
public void startDns(Platform platform, Long instanceNo) { Instance instance = instanceDao.read(instanceNo); // TODO CLOUD BRANCHING if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())) { startDnsCloudstack(instanceNo);//from w ww .jav a2 s .c o m } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) { if (platform.getInternal()) { //(VPN??) startDnsVcloud(instanceNo); } else { //(VPN?) startDnsVcloudVPN(instanceNo); } // Azure?? } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { startDnsAzure(instanceNo); } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) { startDnsOpenstack(instanceNo); } else if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { PlatformAws platformAws = platformAwsDao.read(platform.getPlatformNo()); if (platform.getInternal()) { // ??? if (BooleanUtils.isTrue(platformAws.getEuca())) { // Eucalyptus?? log.debug("DnsProcess:startDnsVpc[internal=true, vpc=euca]"); startDnsNormalEuca(instanceNo); } else { // Amazon EC2?? if (BooleanUtils.isTrue(platformAws.getVpc())) { // VPC???? log.debug("DnsProcess:startDnsVpc[internal=true, vpc=true]"); startDnsVpc(instanceNo); } else { // VPC???? log.debug("DnsProcess:startDnsNormalEc2[internal=true, vpc=false]"); startDnsNormalEc2(instanceNo); } } } else { // ??? // Windows???VPN??? Image image = imageDao.read(instance.getImageNo()); if (StringUtils.startsWithIgnoreCase(image.getOs(), PCCConstant.OS_NAME_WIN)) { // VPN?????? log.debug("DnsProcess:startDnsNormalEc2[internal=false, os=windows]"); startDnsNormalEc2(instanceNo); } else { // VPN????(VPC+VPN?????VPN) log.debug("DnsProcess:startDnsVpn[internal=false, os=linux]VPC+VPN"); startDnsVpn(instanceNo); } } } // instance = instanceDao.read(instanceNo); processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance, "DnsRegist", new Object[] { instance.getFqdn(), instance.getPublicIp() }); }
From source file:com.opengamma.web.portfolio.WebPortfolioResource.java
@PUT @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON)// ww w . jav a2s. co m public Response putJSON(@FormParam("name") String name, @FormParam("hidden") Boolean isHidden) { PortfolioDocument doc = data().getPortfolio(); if (doc.isLatest() == false) { return Response.status(Status.FORBIDDEN).entity(getHTML()).build(); } name = StringUtils.trimToNull(name); DocumentVisibility visibility = BooleanUtils.isTrue(isHidden) ? DocumentVisibility.HIDDEN : DocumentVisibility.VISIBLE; updatePortfolio(name, visibility, doc); return Response.ok().build(); }
From source file:com.haulmont.cuba.gui.app.core.scheduled.ScheduledTaskBrowser.java
protected boolean checkAllTasksIsNotActive(Set<ScheduledTask> tasks) { if (!tasks.isEmpty()) { for (ScheduledTask task : tasks) { if (BooleanUtils.isTrue(task.getActive())) { return false; }/*from w w w .j av a 2 s. com*/ } return true; } else { return false; } }
From source file:jp.primecloud.auto.process.InstancesProcess.java
public void stop(Long farmNo) { Farm farm = farmDao.read(farmNo);/* w w w. j av a 2s.c o m*/ if (BooleanUtils.isTrue(farm.getComponentProcessing())) { // ?????????? if (log.isDebugEnabled()) { String message = MessageUtils.format("Component is being configured.(farmNo={0})", farmNo); log.debug(message); } return; } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100021", farmNo)); } // farm.setComponentProcessing(true); farmDao.update(farm); // processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, null, "InstanceCoordinate", null); try { // ???? List<Long> startInstanceNos = new ArrayList<Long>(); List<Long> stopInstanceNos = new ArrayList<Long>(); List<Instance> allInstances = instanceDao.readByFarmNo(farmNo); for (Instance instance : allInstances) { // ??????????????????? if (InstanceStatus.fromStatus(instance.getStatus()) == InstanceStatus.RUNNING) { if (BooleanUtils.isTrue(instance.getEnabled())) { startInstanceNos.add(instance.getInstanceNo()); } else if (InstanceCoodinateStatus .fromStatus(instance.getCoodinateStatus()) == InstanceCoodinateStatus.COODINATED) { stopInstanceNos.add(instance.getInstanceNo()); } } } InstancesProcessContext context = new InstancesProcessContext(); context.setFarmNo(farmNo); context.setStartInstanceNos(startInstanceNos); context.setStopInstanceNos(stopInstanceNos); // ?? puppetNodesProcess.configureNodes(context); } finally { // farm = farmDao.read(farmNo); farm.setComponentProcessing(false); farmDao.update(farm); } // processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, null, "InstanceCoordinateFinish", null); if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100022", farmNo)); } }
From source file:gov.nih.nci.cabig.caaers.web.ae.SubmitReportController.java
@Override protected Object formBackingObject(HttpServletRequest request) throws Exception { if (log.isDebugEnabled()) log.debug("In form backing object"); Report report = null;// w w w .j a va 2 s . c o m String reportId = request.getParameter("reportId"); if (reportId != null) { int repId = WebUtils.getIntParameter(request, "reportId"); report = reportDao.getById(repId); log.debug("fetched report : " + reportId); } Boolean workflowEnabled = getConfiguration().get(Configuration.ENABLE_WORKFLOW); Boolean unidentifiedMode = getConfiguration().get(Configuration.UNIDENTIFIED_MODE); SubmitExpeditedAdverseEventCommand command = new SubmitExpeditedAdverseEventCommand(report, BooleanUtils.isTrue(unidentifiedMode), reportDao, reportRepository); command.setReportId(reportId); command.setFrom(request.getParameter("from")); command.setWorkflowEnabled(workflowEnabled); command.setReport(report); if (report.getSubmitter() == null) { report.setSubmitter(new Submitter()); } return command; }
From source file:com.haulmont.restapi.service.EntitiesControllerManager.java
public String loadEntity(String entityName, String entityId, @Nullable String viewName, @Nullable Boolean returnNulls, @Nullable Boolean dynamicAttributes, @Nullable String modelVersion) { entityName = restControllerUtils.transformEntityNameIfRequired(entityName, modelVersion, JsonTransformationDirection.FROM_VERSION); MetaClass metaClass = restControllerUtils.getMetaClass(entityName); checkCanReadEntity(metaClass);/*from ww w . j av a 2s. co m*/ LoadContext<Entity> ctx = new LoadContext<>(metaClass); Object id = getIdFromString(entityId, metaClass); ctx.setId(id); if (!Strings.isNullOrEmpty(viewName)) { View view = restControllerUtils.getView(metaClass, viewName); ctx.setView(view); } ctx.setLoadDynamicAttributes(BooleanUtils.isTrue(dynamicAttributes)); Entity entity = dataManager.load(ctx); checkEntityIsNotNull(entityName, entityId, entity); List<EntitySerializationOption> serializationOptions = new ArrayList<>(); serializationOptions.add(EntitySerializationOption.SERIALIZE_INSTANCE_NAME); if (BooleanUtils.isTrue(returnNulls)) serializationOptions.add(EntitySerializationOption.SERIALIZE_NULLS); restControllerUtils.applyAttributesSecurity(entity); String json = entitySerializationAPI.toJson(entity, null, serializationOptions.toArray(new EntitySerializationOption[0])); json = restControllerUtils.transformJsonIfRequired(entityName, modelVersion, JsonTransformationDirection.TO_VERSION, json); return json; }